Prepare fixtures

This commit is contained in:
dkanus 2026-07-14 20:27:09 +07:00
commit 9c94356263
6021 changed files with 722805 additions and 22 deletions

View file

@ -0,0 +1,101 @@
//-----------------------------------------------------------
// 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=MVMultiColumnListBox Name=MapListBox
HeaderColumnPerc(0)=0.500000
HeaderColumnPerc(1)=0.150000
HeaderColumnPerc(2)=0.150000
HeaderColumnPerc(3)=0.200000
bVisibleWhenEmpty=True
OnCreateComponent=MapListBox.InternalOnCreateComponent
StyleName="ServerBrowserGrid"
WinTop=0.371020
WinLeft=0.020000
WinWidth=0.960000
WinHeight=0.293104
bBoundToParent=True
bScaleToParent=True
OnRightClick=MapListBox.InternalOnRightClick
End Object
lb_MapListBox=MVMultiColumnListBox'KFMapVoteV2.KFMapVotingPageX.MapListBox'
Begin Object Class=MVCountColumnListBox Name=VoteCountListBox
HeaderColumnPerc(0)=0.300000
HeaderColumnPerc(1)=0.300000
HeaderColumnPerc(2)=0.200000
HeaderColumnPerc(3)=0.200000
bVisibleWhenEmpty=True
OnCreateComponent=VoteCountListBox.InternalOnCreateComponent
WinTop=0.052930
WinLeft=0.020000
WinWidth=0.960000
WinHeight=0.223770
bBoundToParent=True
bScaleToParent=True
OnRightClick=VoteCountListBox.InternalOnRightClick
End Object
lb_VoteCountListBox=MVCountColumnListBox'KFMapVoteV2.KFMapVotingPageX.VoteCountListBox'
Begin Object Class=moComboBox Name=GameTypeCombo
CaptionWidth=0.350000
Caption="Select Game Type:"
OnCreateComponent=GameTypeCombo.InternalOnCreateComponent
WinTop=0.334309
WinLeft=0.199219
WinWidth=0.757809
WinHeight=0.037500
bScaleToParent=True
End Object
co_GameType=moComboBox'KFMapVoteV2.KFMapVotingPageX.GameTypeCombo'
}

View file

@ -0,0 +1,33 @@
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
{
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!"
bIsConsoleMessage=False
DrawColor=(B=50,G=50,R=255)
PosY=0.040000
FontSize=2
}

View file

@ -0,0 +1,379 @@
// ====================================================================
// KFVotingHandler - Modification by Marco
// ====================================================================
class KFVotingHandler extends xVotingHandler
Config(KFMapVote);
struct FMapRepType
{
var int Positive,Negative;
};
var array<FMapRepType> 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; i++)
{
if(GameConfig[i].GameClass ~= string(Level.Game.Class))
{
CurrentGameConfig = i;
break;
}
}
}
}
else
CurrentGameConfig = 0;
LoadMapList();
}
else
log("Map Voting Disabled",'MapVote');
if(bMatchSetup)
{
log("MatchSetup Enabled",'MapVote');
MatchProfile = CreateMatchProfile();
MatchProfile.Init(Level);
MatchProfile.LoadCurrentSettings();
}
else
log("MatchSetup Disabled",'MapVote');
}
function SubmitMapVote(int MapIndex, int GameIndex, Actor Voter)
{
local int Index, VoteCount, PrevMapVote, PrevGameVote;
local MapHistoryInfo MapInfo;
local bool bAdminForce;
if(bLevelSwitchPending)
return;
Index = GetMVRIIndex(PlayerController(Voter));
if( GameIndex<0 )
{
bAdminForce = true;
GameIndex = (-GameIndex) - 1;
}
if( GameIndex>=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(MapIndex < 0 ||
MapIndex >= MapCount ||
GameIndex >= GameConfig.Length ||
(MVRI[Index].GameVote == GameIndex && MVRI[Index].MapVote == MapIndex) ||
!MapList[MapIndex].bEnabled)
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<MVRI.Length; i++)
if(MVRI[i] != none && MVRI[i].PlayerOwner != none )
MVRI[i].PlayCountDown(TimeLeft);
}
if(TimeLeft == -1) // force level switch if time limit is up
TallyVotes(true); // if no-one has voted a random map will be choosen
}
function string SetupGameMap(MapVoteMapList MapInfo, int GameIndex, MapHistoryInfo MapHistoryInfo)
{
local string ReturnString;
local string MutatorString;
local string OptionString;
local array<string> 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
{
}

View file

@ -0,0 +1,155 @@
// ====================================================================
// KFVotingReplicationInfo - Modification by Marco
// ====================================================================
class KFVotingReplicationInfo extends VotingReplicationInfo
DependsOn(KFVotingHandler);
#exec obj load file="KFAnnounc.uax" package="KFMapVoteV2"
var array<string> RepArray; // Displayed rep string
var sound AnnounceSnds[13];
var byte MapRepVote;
var bool bClientHasInit;
replication
{
reliable if( Role==ROLE_Authority )
ReceiveMapInfoRep;
reliable if( Role<ROLE_Authority )
SendMapLike;
}
simulated final function InitClient()
{
local PlayerController PC;
bClientHasInit = true;
PC = Level.GetLocalPlayerController();
if( PC!=None )
Class'MVLevelCleanup'.Static.AddVotingReplacement(PC);
}
simulated function Tick(float DeltaTime)
{
if( !bClientHasInit )
InitClient();
Super.Tick(DeltaTime);
}
simulated function PlayCountDown(int Count)
{
local byte Idx;
if( PlayerOwner==None )
return;
switch( Count )
{
case 60:
Idx = 12;
break;
case 30:
Idx = 11;
break;
case 20:
Idx = 10;
break;
default:
Idx = Min(Count-1,9);
break;
}
PlayerOwner.ClientPlaySound(AnnounceSnds[Idx],true,2.f,SLOT_Talk);
PlayerOwner.ReceiveLocalizedMessage(Class'KFVoteTimeMessage',Idx);
}
simulated function OpenWindow()
{
if( GetController().FindMenuByClass(Class'KFMapVotingPageX')==None ) // Only open when aren't already open.
{
GetController().OpenMenu(string(Class'KFMapVotingPageX'));
GetController().OpenMenu(string(Class'MVLikePage'));
}
}
function TickedReplication_MapList(int Index, bool bDedicated)
{
local VotingHandler.MapVoteMapList MapInfo;
MapInfo = VH.GetMapList(Index);
DebugLog("___Sending " $ Index $ " - " $ MapInfo.MapName);
if( bDedicated )
{
ReceiveMapInfoRep(MapInfo,KFVotingHandler(VH).RepArray[Index]); // replicate one map each tick until all maps are replicated.
bWaitingForReply = True;
}
else
{
MapList[MapList.Length] = MapInfo;
InitRepStr(MapList.Length-1,KFVotingHandler(VH).RepArray[Index]);
}
}
simulated function ReceiveMapInfoRep( VotingHandler.MapVoteMapList MapInfo, KFVotingHandler.FMapRepType Rep )
{
MapList[MapList.Length] = MapInfo;
InitRepStr(MapList.Length-1,Rep);
ReplicationReply();
}
simulated final function InitRepStr( int i, KFVotingHandler.FMapRepType Rep )
{
local float Rating;
local byte R,G;
RepArray.Length = i+1;
// Map not yet rated.
if( Rep.Positive==0 && Rep.Negative==0 )
{
// Map never played.
if( MapList[i].PlayCount==0 )
RepArray[i] = "**NEW**";
else RepArray[i] = "N/A";
}
else
{
Rating = float(Rep.Positive) / float(Rep.Positive + Rep.Negative); // Scaled 0-1 (0 = negative, 1 = positive)
if( Rating<0.5f )
{
R = 255;
G = 510.f*Rating;
if( G==0 || G==10 )
++G;
}
else
{
R = 510.f*(1.f-Rating);
G = 255;
if( R==0 || R==10 )
++R;
}
RepArray[i] = Chr(0x1B)$Chr(R)$Chr(G)$Chr(1)$(Rating*100.f)@"% ("$Rep.Positive$"/"$(Rep.Positive+Rep.Negative)@"likes)";
}
}
function SendMapLike( bool bLiked )
{
if( bLiked )
MapRepVote = 1;
else MapRepVote = 2;
}
defaultproperties
{
AnnounceSnds(0)=Sound'KFMapVoteV2.KFAnnounc.one'
AnnounceSnds(1)=Sound'KFMapVoteV2.KFAnnounc.two'
AnnounceSnds(2)=Sound'KFMapVoteV2.KFAnnounc.three'
AnnounceSnds(3)=Sound'KFMapVoteV2.KFAnnounc.four'
AnnounceSnds(4)=Sound'KFMapVoteV2.KFAnnounc.five'
AnnounceSnds(5)=Sound'KFMapVoteV2.KFAnnounc.six'
AnnounceSnds(6)=Sound'KFMapVoteV2.KFAnnounc.seven'
AnnounceSnds(7)=Sound'KFMapVoteV2.KFAnnounc.eight'
AnnounceSnds(8)=Sound'KFMapVoteV2.KFAnnounc.nine'
AnnounceSnds(9)=Sound'KFMapVoteV2.KFAnnounc.ten'
AnnounceSnds(10)=Sound'KFMapVoteV2.KFAnnounc.20_seconds'
AnnounceSnds(11)=Sound'KFMapVoteV2.KFAnnounc.30_seconds_remain'
AnnounceSnds(12)=Sound'KFMapVoteV2.KFAnnounc.1_minute_remains'
}

View file

@ -0,0 +1,61 @@
// ====================================================================
// Modified by Marco
// ====================================================================
class MVCountColumnList extends MapVoteCountMultiColumnList;
//------------------------------------------------------------------------------------------------
function DrawItem(Canvas Canvas, int i, float X, float Y, float W, float H, bool bSelected, bool bPending)
{
local float CellLeft, CellWidth;
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;
GetCellLeftWidth( 0, CellLeft, CellWidth );
DrawStyle.DrawText( Canvas, MenuState, CellLeft, Y, CellWidth, H, TXTA_Left,
VRI.GameConfig[VRI.MapVoteCount[SortData[i].SortItem].GameConfigIndex].GameName, FontScale );
GetCellLeftWidth( 1, CellLeft, CellWidth );
DrawStyle.DrawText( Canvas, MenuState, CellLeft, Y, CellWidth, H, TXTA_Left,
VRI.MapList[VRI.MapVoteCount[SortData[i].SortItem].MapIndex].MapName, FontScale );
GetCellLeftWidth( 2, CellLeft, CellWidth );
DrawStyle.DrawText( Canvas, MenuState, CellLeft, Y, CellWidth, H, TXTA_Left,
string(VRI.MapVoteCount[SortData[i].SortItem].VoteCount), FontScale );
GetCellLeftWidth( 3, CellLeft, CellWidth );
DrawStyle.DrawText( Canvas, MenuState, CellLeft, Y, CellWidth, H, TXTA_Left,
KFVotingReplicationInfo(VRI).RepArray[VRI.MapVoteCount[SortData[i].SortItem].MapIndex], FontScale );
}
//------------------------------------------------------------------------------------------------
function string GetSortString( int i )
{
local string ColumnData[5];
ColumnData[0] = left(Caps(VRI.GameConfig[VRI.MapVoteCount[i].GameConfigIndex].GameName),15);
ColumnData[1] = left(Caps(VRI.MapList[VRI.MapVoteCount[i].MapIndex].MapName),20);
ColumnData[2] = right("0000" $ VRI.MapVoteCount[i].VoteCount,4);
ColumnData[3] = KFVotingReplicationInfo(VRI).RepArray[VRI.MapVoteCount[i].MapIndex];
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(1)=0.300000
InitColumnPerc(2)=0.200000
InitColumnPerc(3)=0.200000
ColumnHeadingHints(3)="User rating of the map."
}

View file

@ -0,0 +1,41 @@
// ====================================================================
// Modified by Marco
// ====================================================================
class MVCountColumnListBox extends MapVoteCountMultiColumnListBox;
function InitComponent(GUIController MyController, GUIComponent MyOwner)
{
DefaultListClass = string(Class'MVCountColumnList');
Super.InitComponent(MyController, MyOwner);
if( PlayerOwner().PlayerReplicationInfo.bAdmin )
ContextMenu.AddItem("Admin Force Map");
}
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'), MapVoteCountMultiColumnList(List).GetSelectedMapName() );
break;
case 2:
if( KFMapVotingPageX(MenuOwner) != none )
KFMapVotingPageX(MenuOwner).SendAdminSwitch(self);
break;
}
}
}
defaultproperties
{
}

View file

@ -0,0 +1,39 @@
Class MVLevelCleanup extends Interaction;
function NotifyLevelChange()
{
local int i;
// Reset the voting menu back.
GUIController(ViewportOwner.GUIController).MapVotingMenu = "KFGUI.KFMapVotingPage";
// Make sure GUI controller leaves no menus referenced.
GUIController(ViewportOwner.GUIController).ResetFocus();
GUIController(ViewportOwner.GUIController).FocusedControl = None;
for( i=(ViewportOwner.LocalInteractions.Length-1); i>=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');
}
defaultproperties
{
}

View file

@ -0,0 +1,63 @@
// 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
Caption="Did you like this map?"
TextAlign=TXTA_Center
TextColor=(G=255,R=255)
WinTop=0.200000
WinLeft=0.100000
WinWidth=0.800000
WinHeight=0.400000
End Object
l_Text=GUILabel'KFMapVoteV2.MVLikePage.LikeInfo'
Begin Object Class=GUIButton Name=LikeButton
Caption="Like"
WinTop=0.530000
WinLeft=0.380000
WinWidth=0.110000
WinHeight=0.075000
OnClick=MVLikePage.LikeClick
OnKeyEvent=LikeButton.InternalOnKeyEvent
End Object
b_Like=GUIButton'KFMapVoteV2.MVLikePage.LikeButton'
Begin Object Class=GUIButton Name=DislikeButton
Caption="Dislike"
WinTop=0.530000
WinLeft=0.510000
WinWidth=0.110000
WinHeight=0.075000
OnClick=MVLikePage.LikeClick
OnKeyEvent=DislikeButton.InternalOnKeyEvent
End Object
b_Dislike=GUIButton'KFMapVoteV2.MVLikePage.DislikeButton'
WindowName="Map review"
bRequire640x480=False
WinTop=0.350000
WinLeft=0.300000
WinWidth=0.400000
WinHeight=0.300000
bAcceptsInput=False
}

View file

@ -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
{
}

View file

@ -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<RepHistory> 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; x<Default.H.Length; x++)
{
if( MapName==Default.H[x].M ) // found map
return x;
if( Default.H[x].M>MapName ) // 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
{
}

View file

@ -0,0 +1,67 @@
// ====================================================================
// 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.500000
InitColumnPerc(1)=0.150000
InitColumnPerc(2)=0.150000
InitColumnPerc(3)=0.200000
ColumnHeadingHints(3)="User rating for the maps."
}

View file

@ -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<LoadVRI.GameConfig.Length; i++)
{
ListArray[i] = new class'MVMultiColumnList';
ListArray[i].LoadList(LoadVRI,i);
}
if( LoadVRI.CurrentGameConfig<ListArray.Length )
ChangeGameType(LoadVRI.CurrentGameConfig); // Fix for bug in initial maplist selection.
else ChangeGameType(0);
}
defaultproperties
{
}

View file

@ -0,0 +1,18 @@
<html>
<head><title>Index of /kf_sources/KFMapVoteV2/Classes/</title></head>
<body>
<h1>Index of /kf_sources/KFMapVoteV2/Classes/</h1><hr><pre><a href="../">../</a>
<a href="KFMapVotingPageX.uc">KFMapVotingPageX.uc</a> 06-Oct-2019 10:28 3474
<a href="KFVoteTimeMessage.uc">KFVoteTimeMessage.uc</a> 06-Oct-2019 10:28 854
<a href="KFVotingHandler.uc">KFVotingHandler.uc</a> 07-Mar-2023 19:22 11100
<a href="KFVotingReplicationInfo.uc">KFVotingReplicationInfo.uc</a> 07-Mar-2023 19:22 4066
<a href="MVCountColumnList.uc">MVCountColumnList.uc</a> 06-Oct-2019 10:28 2491
<a href="MVCountColumnListBox.uc">MVCountColumnListBox.uc</a> 06-Oct-2019 10:28 1098
<a href="MVLevelCleanup.uc">MVLevelCleanup.uc</a> 06-Oct-2019 10:28 1193
<a href="MVLikePage.uc">MVLikePage.uc</a> 06-Oct-2019 10:28 1908
<a href="MVMapInfoPage.uc">MVMapInfoPage.uc</a> 07-Mar-2023 19:37 1832
<a href="MVMapRepHistory.uc">MVMapRepHistory.uc</a> 06-Oct-2019 10:28 2352
<a href="MVMultiColumnList.uc">MVMultiColumnList.uc</a> 06-Oct-2019 10:28 2584
<a href="MVMultiColumnListBox.uc">MVMultiColumnListBox.uc</a> 06-Oct-2019 10:28 1516
</pre><hr></body>
</html>