diff --git a/Classes/KFMapVotingPageX.uc b/Classes/KFMapVotingPageX.uc new file mode 100644 index 0000000..51c1bd6 --- /dev/null +++ b/Classes/KFMapVotingPageX.uc @@ -0,0 +1,97 @@ +//----------------------------------------------------------- +// KFMapVotingPageX - Modification by Marco +//----------------------------------------------------------- +class KFMapVotingPageX extends ROMapVotingPage; + +// Also allow admins force mapswitch. +final function SendAdminSwitch(GUIComponent Sender) +{ + local int MapIndex,GameConfigIndex; + + if( Sender == lb_VoteCountListBox.List ) + { + MapIndex = MapVoteCountMultiColumnList(lb_VoteCountListBox.List).GetSelectedMapIndex(); + if( MapIndex>=0 ) + GameConfigIndex = MapVoteCountMultiColumnList(lb_VoteCountListBox.List).GetSelectedGameConfigIndex(); + } + else + { + MapIndex = MapVoteMultiColumnList(lb_MapListBox.List).GetSelectedMapIndex(); + if( MapIndex>=0 ) + GameConfigIndex = int(co_GameType.GetExtra()); + } + if( MapIndex>=0 ) + MVRI.SendMapVote(MapIndex,-(GameConfigIndex+1)); // Send with negative game index to indicate admin switch. +} + +// Allow admins vote like all other players. +function SendVote(GUIComponent Sender) +{ + local int MapIndex,GameConfigIndex; + + if( Sender == lb_VoteCountListBox.List ) + { + MapIndex = MapVoteCountMultiColumnList(lb_VoteCountListBox.List).GetSelectedMapIndex(); + if( MapIndex>=0 ) + GameConfigIndex = MapVoteCountMultiColumnList(lb_VoteCountListBox.List).GetSelectedGameConfigIndex(); + } + else + { + MapIndex = MapVoteMultiColumnList(lb_MapListBox.List).GetSelectedMapIndex(); + if( MapIndex>=0 ) + GameConfigIndex = int(co_GameType.GetExtra()); + } + if( MapIndex>=0 ) + { + if( MVRI.MapList[MapIndex].bEnabled ) + MVRI.SendMapVote(MapIndex,GameConfigIndex); + else PlayerOwner().ClientMessage(lmsgMapDisabled); + } +} + +DefaultProperties +{ + Begin Object Class=MVCountColumnListBox Name=VoteCountListBox + WinWidth=0.96 + WinHeight=0.223770 + WinLeft=0.02 + WinTop=0.052930 + bVisibleWhenEmpty=true + bScaleToParent=True + bBoundToParent=True + FontScale=FNS_Small + HeaderColumnPerc(0)=0.3 + HeaderColumnPerc(1)=0.3 + HeaderColumnPerc(2)=0.2 + HeaderColumnPerc(3)=0.2 + End Object + lb_VoteCountListBox=VoteCountListBox + + Begin Object Class=MVMultiColumnListBox Name=MapListBox + WinWidth=0.96 + WinHeight=0.293104 + WinLeft=0.02 + WinTop=0.371020 + bVisibleWhenEmpty=true + StyleName="ServerBrowserGrid" + bScaleToParent=True + bBoundToParent=True + FontScale=FNS_Small + HeaderColumnPerc(0)=0.5 + HeaderColumnPerc(1)=0.15 + HeaderColumnPerc(2)=0.15 + HeaderColumnPerc(3)=0.2 + End Object + lb_MapListBox=MapListBox + + Begin Object class=moComboBox Name=GameTypeCombo + WinWidth=0.757809 + WinHeight=0.037500 + WinLeft=0.199219 + WinTop=0.334309 + Caption="Select Game Type:" + CaptionWidth=0.35 + bScaleToParent=True + End Object + co_GameType=GameTypeCombo +} \ No newline at end of file diff --git a/Classes/KFVoteTimeMessage.uc b/Classes/KFVoteTimeMessage.uc new file mode 100644 index 0000000..f0a8522 --- /dev/null +++ b/Classes/KFVoteTimeMessage.uc @@ -0,0 +1,34 @@ +class KFVoteTimeMessage extends CriticalEventPlus; + +var(Message) localized string TimeString[13]; + +static function string GetString( + optional int Switch, + optional PlayerReplicationInfo RelatedPRI_1, + optional PlayerReplicationInfo RelatedPRI_2, + optional Object OptionalObject ) +{ + Return Default.TimeString[Switch]; +} + +defaultproperties +{ + bIsUnique=True + FontSize=2 + PosY=0.04 + DrawColor=(R=255,G=50,B=50) + bIsConsoleMessage=False + TimeString(0)="1..." + TimeString(1)="2..." + TimeString(2)="3..." + TimeString(3)="4..." + TimeString(4)="5..." + TimeString(5)="6..." + TimeString(6)="7..." + TimeString(7)="8..." + TimeString(8)="9..." + TimeString(9)="10..." + TimeString(10)="20 seconds..." + TimeString(11)="30 seconds left..." + TimeString(12)="1 minute remains!" +} diff --git a/Classes/KFVotingHandler.uc b/Classes/KFVotingHandler.uc new file mode 100644 index 0000000..b0fb29a --- /dev/null +++ b/Classes/KFVotingHandler.uc @@ -0,0 +1,375 @@ +// ==================================================================== +// KFVotingHandler - Modification by Marco +// ==================================================================== +class KFVotingHandler extends xVotingHandler + Config(KFMapVote); + +struct FMapRepType +{ + var int Positive,Negative; +}; +var array RepArray; // Map reputation array, should be in sync with MapList array. + +function PostBeginPlay() +{ + local int i; + + AddToPackageMap(); // Make sure in serverpackages. + + Super(VotingHandler).PostBeginPlay(); + + // disable voting in single player mode + if( Level.NetMode==NM_StandAlone ) + return; + + if(bKickVote) + log("Kick Voting Enabled",'MapVote'); + else + log("Kick Voting Disabled",'MapVote'); + + if(bMapVote) + { + log("Map Voting Enabled",'MapVote'); + // check current game settings + if( GameConfig.Length > 0 ) + { + if( !(string(Level.Game.Class) ~= GameConfig[CurrentGameConfig].GameClass) ) + { + CurrentGameConfig = 0; + // find matching game type in game config + for( i=0; i=GameConfig.Length || MapIndex<0 || MapIndex>=MapList.Length ) + return; // Something is wrong... + + // check for invalid vote from unpatch players + if( !IsValidVote(MapIndex, GameIndex) ) + return; + + if( bAdminForce && (PlayerController(Voter).PlayerReplicationInfo.bAdmin || PlayerController(Voter).PlayerReplicationInfo.bSilentAdmin) ) // Administrator Vote + { + TextMessage = lmsgAdminMapChange; + TextMessage = Repl(TextMessage, "%mapname%", MapList[MapIndex].MapName $ "(" $ GameConfig[GameIndex].Acronym $ ")"); + Level.Game.Broadcast(self,TextMessage); + + log("Admin has forced map switch to " $ MapList[MapIndex].MapName $ "(" $ GameConfig[GameIndex].Acronym $ ")",'MapVote'); + + CloseAllVoteWindows(); + + bLevelSwitchPending = true; + + MapInfo = History.PlayMap(MapList[MapIndex].MapName); + + ServerTravelString = SetupGameMap(MapList[MapIndex], GameIndex, MapInfo); + log("ServerTravelString = " $ ServerTravelString ,'MapVoteDebug'); + + Level.ServerTravel(ServerTravelString, false); // change the map + + settimer(1,true); + return; + } + + // check for invalid map, invalid gametype, player isnt revoting same as previous vote, and map choosen isnt disabled + if( !MapList[MapIndex].bEnabled || (MVRI[Index].MapVote==MapIndex && MVRI[Index].GameVote==GameIndex) ) + return; + + log("___" $ Index $ " - " $ PlayerController(Voter).PlayerReplicationInfo.PlayerName $ " voted for " $ MapList[MapIndex].MapName $ "(" $ GameConfig[GameIndex].Acronym $ ")",'MapVote'); + + PrevMapVote = MVRI[Index].MapVote; + PrevGameVote = MVRI[Index].GameVote; + MVRI[Index].MapVote = MapIndex; + MVRI[Index].GameVote = GameIndex; + + if(bAccumulationMode) + { + if(bScoreMode) + { + VoteCount = GetAccVote(PlayerController(Voter)) + int(GetPlayerScore(PlayerController(Voter))); + TextMessage = lmsgMapVotedForWithCount; + TextMessage = repl(TextMessage, "%playername%", PlayerController(Voter).PlayerReplicationInfo.PlayerName ); + TextMessage = repl(TextMessage, "%votecount%", string(VoteCount) ); + TextMessage = repl(TextMessage, "%mapname%", MapList[MapIndex].MapName $ "(" $ GameConfig[GameIndex].Acronym $ ")" ); + Level.Game.Broadcast(self,TextMessage); + } + else + { + VoteCount = GetAccVote(PlayerController(Voter)) + 1; + TextMessage = lmsgMapVotedForWithCount; + TextMessage = repl(TextMessage, "%playername%", PlayerController(Voter).PlayerReplicationInfo.PlayerName ); + TextMessage = repl(TextMessage, "%votecount%", string(VoteCount) ); + TextMessage = repl(TextMessage, "%mapname%", MapList[MapIndex].MapName $ "(" $ GameConfig[GameIndex].Acronym $ ")" ); + Level.Game.Broadcast(self,TextMessage); + } + } + else + { + if(bScoreMode) + { + VoteCount = int(GetPlayerScore(PlayerController(Voter))); + TextMessage = lmsgMapVotedForWithCount; + TextMessage = repl(TextMessage, "%playername%", PlayerController(Voter).PlayerReplicationInfo.PlayerName ); + TextMessage = repl(TextMessage, "%votecount%", string(VoteCount) ); + TextMessage = repl(TextMessage, "%mapname%", MapList[MapIndex].MapName $ "(" $ GameConfig[GameIndex].Acronym $ ")" ); + Level.Game.Broadcast(self,TextMessage); + } + else + { + VoteCount = 1; + TextMessage = lmsgMapVotedFor; + TextMessage = repl(TextMessage, "%playername%", PlayerController(Voter).PlayerReplicationInfo.PlayerName ); + TextMessage = repl(TextMessage, "%mapname%", MapList[MapIndex].MapName $ "(" $ GameConfig[GameIndex].Acronym $ ")" ); + Level.Game.Broadcast(self,TextMessage); + } + } + UpdateVoteCount(MapIndex, GameIndex, VoteCount); + if( PrevMapVote > -1 && PrevGameVote > -1 ) + UpdateVoteCount(PrevMapVote, PrevGameVote, -MVRI[Index].VoteCount); // undo previous vote + MVRI[Index].VoteCount = VoteCount; + TallyVotes(false); +} + +function TallyVotes(bool bForceMapSwitch) +{ + local int C; + + C = Level.Game.NumPlayers; + Level.Game.NumPlayers+=Level.Game.NumSpectators; + Super.TallyVotes(bForceMapSwitch); + Level.Game.NumPlayers = C; +} + +function AddMapVoteReplicationInfo(PlayerController Player) +{ + local KFVotingReplicationInfo M; + + M = Spawn(class'KFVotingReplicationInfo',Player,,Player.Location); + if(M == None) + { + Log("___Failed to spawn VotingReplicationInfo",'MapVote'); + return; + } + + M.PlayerID = Player.PlayerReplicationInfo.PlayerID; + MVRI[MVRI.Length] = M; +} + +function Timer() +{ + local int mapidx,gameidx,i; + local MapHistoryInfo MapInfo; + + if(bLevelSwitchPending) + { + if( Level.NextURL == "" ) + { + if(Level.NextSwitchCountdown < 0) // if negative then level switch failed + { + Log("___Map change Failed, bad or missing map file.",'MapVote'); + GetDefaultMap(mapidx, gameidx); + MapInfo = History.PlayMap(MapList[mapidx].MapName); + ServerTravelString = SetupGameMap(MapList[mapidx], gameidx, MapInfo); + log("ServerTravelString = " $ ServerTravelString ,'MapVoteDebug'); + History.Save(); + Level.ServerTravel(ServerTravelString, false); // change the map + } + } + return; + } + + if(ScoreBoardTime > -1) + { + if(ScoreBoardTime == 0) + OpenAllVoteWindows(); + ScoreBoardTime--; + return; + } + TimeLeft--; + + if( TimeLeft==60 || TimeLeft==30 || TimeLeft==20 || (TimeLeft<=10 && TimeLeft>0) ) // play announcer count down voice + { + for( i=0; i MapsInRotation; + local int i; + + // Add Per-GameType Mutators + if( Len(GameConfig[GameIndex].Mutators)!=0 ) + MutatorString = MutatorString $ GameConfig[GameIndex].Mutators; + + // Add Per-Map Mutators + if( Len(MapHistoryInfo.U)!=0 ) + MutatorString = MutatorString $ "," $ MapHistoryInfo.U; + + // Add Per-GameType Game Options + if(GameConfig[GameIndex].Options != "") + OptionString = OptionString $ Repl(Repl(GameConfig[GameIndex].Options,",","?")," ",""); + + // Add Per-Map Game Options + if(MapHistoryInfo.G != "") + OptionString = OptionString $ "?" $ MapHistoryInfo.G; + + //if _RO_ + // Remove the .rom off of the map name, if it exists + if ( Right(MapInfo.MapName, 4) == ".rom" ) + ReturnString = Left(MapInfo.MapName, Len(MapInfo.MapName) - 4); + else + ReturnString = MapInfo.MapName; + + MapsInRotation = Level.Game.MaplistHandler.GetCurrentMapRotation(); + for ( i = 0; i < MapsInRotation.Length; i++ ) + { + if ( InStr(MapsInRotation[i], ReturnString) != -1 ) + { + ReturnString = MapsInRotation[i]; + break; + } + } + + ReturnString = ReturnString $ "?Game=" $ GameConfig[GameIndex].GameClass; + + if( MutatorString=="" ) + MutatorString = "None"; // Don't allow previous mutator options to override this then. + ReturnString = ReturnString $ "?Mutator=" $ MutatorString; + + if(OptionString != "") + ReturnString = ReturnString $ "?" $ OptionString; + + return ReturnString; +} + +function AddMap(string MapName, string Mutators, string GameOptions) // called from the MapListLoader +{ + local MapHistoryInfo MapInfo; + local bool bUpdate; + local int i; + + if( Right(MapName,4)~=".rom" ) + MapName = Left(MapName,Len(MapName)-4); + + if( MapName~="KFintro" ) + return; // Unplayable map. + + for(i=0; i < MapList.Length; i++) // dont add duplicate map names + if(MapName ~= MapList[i].MapName) + return; + + RepArray.Length = MapCount + 1; + Class'MVMapRepHistory'.Static.GetMapHistoryRep(MapName,RepArray[MapCount].Positive,RepArray[MapCount].Negative); + + MapInfo = History.GetMapHistory(MapName); + + MapList.Length = MapCount + 1; + MapList[MapCount].MapName = MapName; + MapList[MapCount].PlayCount = MapInfo.P; + MapList[MapCount].Sequence = MapInfo.S; + if(MapInfo.S <= RepeatLimit && MapInfo.S != 0) + MapList[MapCount].bEnabled = false; // dont allow players to vote for this one + else + MapList[MapCount].bEnabled = true; + MapCount++; + + if(Mutators != "" && Mutators != MapInfo.U) + { + MapInfo.U = Mutators; + bUpdate = True; + } + + if(GameOptions != "" && GameOptions != MapInfo.G) + { + MapInfo.G = GameOptions; + bUpdate = True; + } + + if(MapInfo.M == "") // if map not found in MapVoteHistory then add it + { + MapInfo.M = MapName; + bUpdate = True; + } + + if(bUpdate) + History.AddMap(MapInfo); +} + +// Using this function to save map reputation aswell. +function CloseAllVoteWindows() +{ + local int i,Pos,Neg; + local KFVotingReplicationInfo R; + + for(i=0; i < MVRI.Length;i++) + { + R = KFVotingReplicationInfo(MVRI[i]); + if( R!=none ) + { + switch( R.MapRepVote ) + { + case 1: + ++Pos; + break; + case 2: + ++Neg; + break; + } + R.CloseWindow(); + } + } + if( Pos!=0 || Neg!=0 ) + Class'MVMapRepHistory'.Static.AddReputation(string(Outer.Name),Pos,Neg); +} + +defaultproperties +{ +} \ No newline at end of file diff --git a/Classes/KFVotingReplicationInfo.uc b/Classes/KFVotingReplicationInfo.uc new file mode 100644 index 0000000..fa7519c --- /dev/null +++ b/Classes/KFVotingReplicationInfo.uc @@ -0,0 +1,155 @@ +// ==================================================================== +// KFVotingReplicationInfo - Modification by Marco +// ==================================================================== +class KFVotingReplicationInfo extends VotingReplicationInfo + DependsOn(KFVotingHandler); + +#exec obj load file="KFAnnounc.uax" package="KFMapVoteV2" + +var array RepArray; // Displayed rep string + +var sound AnnounceSnds[13]; +var byte MapRepVote; +var bool bClientHasInit; + +replication +{ + reliable if( Role==ROLE_Authority ) + ReceiveMapInfoRep; + reliable if( Role=0; --i ) + if( ViewportOwner.LocalInteractions[i]==Self ) + ViewportOwner.LocalInteractions.Remove(i,1); +} + +static final function AddVotingReplacement( PlayerController PC ) +{ + local int i; + local MVLevelCleanup C; + + for( i=(PC.Player.LocalInteractions.Length-1); i>=0; --i ) + if( PC.Player.LocalInteractions[i].Class==Default.Class ) + return; + C = new(None) Class'MVLevelCleanup'; + C.ViewportOwner = PC.Player; + C.Master = PC.Player.InteractionMaster; + i = PC.Player.LocalInteractions.Length; + PC.Player.LocalInteractions.Length = i+1; + PC.Player.LocalInteractions[i] = C; + C.Initialize(); + GUIController(PC.Player.GUIController).MapVotingMenu = string(Class'KFMapVotingPageX'); +} diff --git a/Classes/MVLikePage.uc b/Classes/MVLikePage.uc new file mode 100644 index 0000000..630fb13 --- /dev/null +++ b/Classes/MVLikePage.uc @@ -0,0 +1,67 @@ +// Created by Marco +class MVLikePage extends LargeWindow; + +var automated GUILabel l_Text; +var automated GUIButton b_Like,b_Dislike; + +function InitComponent(GUIController MyController, GUIComponent MyOwner) +{ + Super.InitComponent(MyController, MyOwner); + b_Like.Caption = MakeColorCode(Class'Canvas'.Static.MakeColor(64,255,64))$b_Like.Caption; + b_Dislike.Caption = MakeColorCode(Class'Canvas'.Static.MakeColor(255,64,64))$b_Dislike.Caption; +} + +function bool LikeClick(GUIComponent Sender) +{ + KFVotingReplicationInfo(PlayerOwner().VoteReplicationInfo).SendMapLike(Sender==b_Like); + Controller.CloseMenu(); + return false; +} + +defaultproperties +{ + Begin Object Class=GUILabel Name=LikeInfo + WinLeft=0.1 + WinTop=0.2 + WinWidth=0.8 + WinHeight=0.4 + Caption="Did you like this map?" + TextColor=(R=255,G=255,B=64,A=255) + TextAlign=TXTA_Center + End Object + l_Text=LikeInfo + + Begin Object Class=GUIButton Name=LikeButton + WinLeft=0.38 + WinTop=0.53 + WinWidth=0.11 + WinHeight=0.075 + Caption="Like" + OnClick=LikeClick + End Object + b_Like=LikeButton + + Begin Object Class=GUIButton Name=DislikeButton + WinLeft=0.51 + WinTop=0.53 + WinWidth=0.11 + WinHeight=0.075 + Caption="Dislike" + OnClick=LikeClick + End Object + b_Dislike=DislikeButton + + bAcceptsInput=false + bPauseIfPossible=false + + WinLeft=0.3 + WinTop=0.35 + WinWidth=0.4 + WinHeight=0.3 + + bRenderWorld=true + bRequire640x480=false + bAllowedAsLast=false + bMoveAllowed=False + WindowName="Map review" +} \ No newline at end of file diff --git a/Classes/MVMapInfoPage.uc b/Classes/MVMapInfoPage.uc new file mode 100644 index 0000000..d1b240d --- /dev/null +++ b/Classes/MVMapInfoPage.uc @@ -0,0 +1,70 @@ +//==================================================================== +// Modified by Marco +// ==================================================================== +class MVMapInfoPage extends MapInfoPage; + +function ReadMapInfo(string MapName) +{ + local string mDesc; + local int Index; + local Material Screenie; + local LevelSummary LS; + + if(MapName == "") + return; + + if (!Controller.bCurMenuInitialized) + return; + + MapName = StripMapName(MapName); + + Index = FindCacheRecordIndex(MapName); + + if( Index==-1 ) + { + LS = LevelSummary(DynamicLoadObject(MapName$".LevelSummary",Class'LevelSummary')); + + if( LS==None ) + { + sb_Main.Caption = MapName; + l_NoPreview.SetVisibility(true); + i_MapImage.SetVisibility(false); + lb_MapDesc.SetContent("Map not found."); + l_MapAuthor.Caption = ""; + return; + } + sb_Main.Caption = LS.Title; + Screenie = LS.Screenshot; + l_MapPlayers.Caption = LS.IdealPlayerCountMin@"-"@LS.IdealPlayerCountMax; + mDesc = LS.Description; + l_MapAuthor.Caption = AuthorText$":"@LS.Author; + } + else + { + if (Maps[Index].FriendlyName != "") + sb_Main.Caption = Maps[Index].FriendlyName; + else sb_Main.Caption = MapName; + + if ( Maps[Index].ScreenshotRef != "" ) + Screenie = Material(DynamicLoadObject(Maps[Index].ScreenshotRef, class'Material')); + + l_MapPlayers.Caption = Maps[Index].PlayerCountMin@"-"@Maps[Index].PlayerCountMax@PlayerText; + mDesc = Maps[Index].Description; + } + i_MapImage.Image = Screenie; + + l_NoPreview.SetVisibility( Screenie == None ); + i_MapImage.SetVisibility( Screenie != None ); + + if (mDesc == "") + mDesc = MessageNoInfo; + + lb_MapDesc.SetContent( mDesc ); + if (Maps[Index].Author != "") + l_MapAuthor.Caption = AuthorText$":"@Maps[Index].Author; + else l_MapAuthor.Caption = ""; +} + +defaultproperties +{ +} \ No newline at end of file diff --git a/Classes/MVMapRepHistory.uc b/Classes/MVMapRepHistory.uc new file mode 100644 index 0000000..0f57e0b --- /dev/null +++ b/Classes/MVMapRepHistory.uc @@ -0,0 +1,112 @@ +//==================================================================== +// Modification by Marco. +//==================================================================== +class MVMapRepHistory extends Object + Config(KFMapVoteHistory); + +struct RepHistory +{ + var config string M; + var config int P,N; +}; +var config array H; // array used to store map data + +//------------------------------------------------------------------------------------------------ +static final function int AddMap( string MapName ) +{ + local int x; + + MapName = Caps(MapName); + + if( Default.H.Length==0 ) // brand new list + { + Default.H.Length = 1; + Default.H[0].M = MapName; + return 0; + } + + // search list for map + for(x=0; xMapName ) // MapName is not in array and should be inserted here + { + Default.H.Insert(x,1); + Default.H[x].M = MapName; + return x; + } + } + + // didnt find insertion point so add at end + Default.H.Length = x+1; + Default.H[x].M = MapName; + return x; +} +//------------------------------------------------------------------------------------------------ +static final function GetMapHistoryRep( string MapName, out int Positive, out int Negative ) +{ + local int i; + + i = FindIndex(MapName); + if( i>=0 ) + { + Positive = Default.H[i].P; + Negative = Default.H[i].N; + } + else + { + Positive = 0; + Negative = 0; + } +} + +static final function AddReputation( string MapName, int Positive, int Negative ) +{ + local int i; + + i = FindIndex(MapName); + if( i==-1 ) + i = AddMap(MapName); + + Default.H[i].P+=Positive; + Default.H[i].N+=Negative; + StaticSaveConfig(); +} +//------------------------------------------------------------------------------------------------ +static final function int FindIndex(string MapName) +{ + local int a,b,i; + + if( Default.H.Length==0 ) + return -1; + + a = 0; + b = Default.H.Length-1; + MapName = Caps(MapName); + + while(true) + { + if( a==b ) + i = a; + else i = ((b-a)/2)+a; + + if( Default.H[i].M==MapName ) + return i; + + if( a==b ) + return -1; + + // check mid-way + if( Default.H[i].M>MapName ) + b = i; // too high + else if( a==i ) + a = b; + else a = i; // too low + } +} + +defaultproperties +{ +} \ No newline at end of file diff --git a/Classes/MVMultiColumnList.uc b/Classes/MVMultiColumnList.uc new file mode 100644 index 0000000..3ffdabc --- /dev/null +++ b/Classes/MVMultiColumnList.uc @@ -0,0 +1,70 @@ +// ==================================================================== +// Modified by Marco +// ==================================================================== +class MVMultiColumnList extends MapVoteMultiColumnList; + +//------------------------------------------------------------------------------------------------ +function DrawItem(Canvas Canvas, int i, float X, float Y, float W, float H, bool bSelected, bool bPending) +{ + local float CellLeft, CellWidth; + local eMenuState MState; + local GUIStyles DrawStyle; + + if( VRI == none ) + return; + + // Draw the selection border + if( bSelected ) + { + SelectedStyle.Draw(Canvas,MenuState, X, Y-2, W, H+2 ); + DrawStyle = SelectedStyle; + } + else DrawStyle = Style; + + if( !VRI.MapList[MapVoteData[SortData[i].SortItem]].bEnabled ) + MState = MSAT_Disabled; + else MState = MenuState; + + GetCellLeftWidth( 0, CellLeft, CellWidth ); + DrawStyle.DrawText( Canvas, MState, CellLeft, Y, CellWidth, H, TXTA_Left, + VRI.MapList[MapVoteData[SortData[i].SortItem]].MapName, FontScale ); + + GetCellLeftWidth( 1, CellLeft, CellWidth ); + DrawStyle.DrawText( Canvas, MState, CellLeft, Y, CellWidth, H, TXTA_Left, + string(VRI.MapList[MapVoteData[SortData[i].SortItem]].PlayCount), FontScale ); + + GetCellLeftWidth( 2, CellLeft, CellWidth ); + DrawStyle.DrawText( Canvas, MState, CellLeft, Y, CellWidth, H, TXTA_Left, + string(VRI.MapList[MapVoteData[SortData[i].SortItem]].Sequence), FontScale ); + + GetCellLeftWidth( 3, CellLeft, CellWidth ); + DrawStyle.DrawText( Canvas, MState, CellLeft, Y, CellWidth, H, TXTA_Left, + KFVotingReplicationInfo(VRI).RepArray[MapVoteData[SortData[i].SortItem]], FontScale ); +} +//------------------------------------------------------------------------------------------------ +function string GetSortString( int i ) +{ + local string ColumnData[5]; + + ColumnData[0] = left(Caps(VRI.MapList[MapVoteData[i]].MapName),20); + ColumnData[1] = right("000000" $ VRI.MapList[MapVoteData[i]].PlayCount,6); + ColumnData[2] = right("000000" $ VRI.MapList[MapVoteData[i]].Sequence,6); + ColumnData[3] = KFVotingReplicationInfo(VRI).RepArray[MapVoteData[i]]; + if( Left(ColumnData[3],1)==Chr(0x1B) ) + ColumnData[3] = Mid(ColumnData[3],4); // Remove color code from sorting. + + return ColumnData[SortColumn] $ ColumnData[PrevSortColumn]; +} + +defaultproperties +{ + ColumnHeadings(3)="Rating" + + InitColumnPerc(0)=0.5 + InitColumnPerc(1)=0.15 + InitColumnPerc(2)=0.15 + InitColumnPerc(3)=0.2 + + ColumnHeadingHints(3)="User rating for the maps." +} + diff --git a/Classes/MVMultiColumnListBox.uc b/Classes/MVMultiColumnListBox.uc new file mode 100644 index 0000000..bd0ac8a --- /dev/null +++ b/Classes/MVMultiColumnListBox.uc @@ -0,0 +1,54 @@ +// ==================================================================== +// Modified by Marco. +// ==================================================================== +class MVMultiColumnListBox extends MapVoteMultiColumnListBox; + +function InternalOnClick(GUIContextMenu Sender, int Index) +{ + if (Sender != None) + { + if ( NotifyContextSelect(Sender, Index) ) + return; + + switch (Index) + { + case 0: + if( MapVotingPage(MenuOwner) != none ) + MapVotingPage(MenuOwner).SendVote(self); + break; + + case 1: + Controller.OpenMenu( string(Class'MVMapInfoPage'), MapVoteMultiColumnList(List).GetSelectedMapName() ); + break; + case 2: + if( KFMapVotingPageX(MenuOwner) != none ) + KFMapVotingPageX(MenuOwner).SendAdminSwitch(self); + break; + } + } +} +function InitComponent(GUIController MyController, GUIComponent MyOwner) +{ + DefaultListClass = string(Class'MVMultiColumnList'); + Super.InitComponent(MyController, MyOwner); + if( PlayerOwner().PlayerReplicationInfo.bAdmin ) + ContextMenu.AddItem("Admin Force Map"); +} +function LoadList(VotingReplicationInfo LoadVRI) +{ + local int i; + + ListArray.Length = LoadVRI.GameConfig.Length; + for( i=0; i