Skip to content

Commit

Permalink
Add Setting MultiRoundGameModes (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
Deaod committed Dec 31, 2023
1 parent 48c41e5 commit 318839f
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 10 deletions.
20 changes: 20 additions & 0 deletions Classes/MutVoteSys.uc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ enum EGameState {
var EGameState GameState;
var int TimeCounter;
var int IdleTime;
var bool bIsMultiRound;
var bool bChangeMapImmediately;
var bool bIsDefaultMap;
var class<CriticalEventPlus> TimeMessageClass;
Expand Down Expand Up @@ -85,6 +86,22 @@ event PostBeginPlay() {
ChatObserver = Level.Spawn(class'VS_ChatObserver');
ChatObserver.VoteSys = self;

ConfigureGameMode();
}

function ConfigureGameMode() {
local string GameClass, GameName;
local int i;

GameClass = string(Level.Game.Class);
GameName = string(Level.Game.Class.Name);
for (i = 0; i < Settings.MultiRoundGameModes.Length; i++)
if (GameClass ~= Settings.MultiRoundGameModes[i] || GameName ~= Settings.MultiRoundGameModes[i])
bIsMultiRound = true;

if (bIsMultiRound)
return;

Level.Game.SetPropertyText("bDontRestart", "True"); // Botpack.DeathMatchPlus and UnrealShare.DeathMatchGame
}

Expand Down Expand Up @@ -520,6 +537,9 @@ function CheckGameEnded() {
// mid-game voting or not ended yet
return;

if (bIsMultiRound && Level.Game.GetPropertyText("bDontRestart") ~= "False")
return;

GameState = GS_GameEnded;
TimeCounter = Settings.GameEndedVoteDelay;
}
Expand Down
1 change: 1 addition & 0 deletions Classes/VS_DataClient.uc
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ function SaveServerSettings(VS_ServerSettings S) {
SendServerSetting(S, "VoteTimeLimit");
SendServerSetting(S, "VoteEndCondition");
SendServerSetting(S, "bRetainCandidates");
SendServerSetting(S, "MultiRoundGameModes");
SendServerSetting(S, "KickVoteThreshold");
SendServerSetting(S, "DefaultPreset");
SendServerSetting(S, "DefaultMap");
Expand Down
1 change: 1 addition & 0 deletions Classes/VS_DataLink.uc
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ Begin:
SendServerSetting("VoteTimeLimit");
SendServerSetting("VoteEndCondition");
SendServerSetting("bRetainCandidates");
SendServerSetting("MultiRoundGameModes");
SendServerSetting("KickVoteThreshold");
SendServerSetting("DefaultPreset");
SendServerSetting("DefaultMap");
Expand Down
5 changes: 4 additions & 1 deletion Classes/VS_ServerSettings.uc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ var config int MidGameVoteTimeLimit;
var config int GameEndedVoteDelay;
var config int VoteTimeLimit;
var config EVoteEndCond VoteEndCondition;
var config bool bRetainCandidates;
var config bool bRetainCandidates;
var config array<string> MultiRoundGameModes;

var config float KickVoteThreshold;

Expand Down Expand Up @@ -75,6 +76,8 @@ defaultproperties {
GameEndedVoteDelay=5
VoteTimeLimit=30
VoteEndCondition=VEC_TimerOnly
bRetainCandidates=False
MultiRoundGameModes="Botpack.Assault"

KickVoteThreshold=0.6

Expand Down
30 changes: 21 additions & 9 deletions Classes/VS_UI_ServerSettingsPage.uc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ var localized string Text_VoteEndCondition_TimerOrResultDetermined;
var UWindowCheckbox Chk_RetainCandidates;
var localized string Text_RetainCandidates;

var VS_UI_ArrayEditControl Adt_MultiRoundGameModes;
var localized string Text_MultiRoundGameModes;

var VS_UI_EditControl Edt_KickVoteThreshold;
var localized string Text_KickVoteThreshold;

Expand Down Expand Up @@ -109,6 +112,7 @@ function EnableInteraction(bool bEnable) {
Edt_VoteTimeLimit.EditBox.SetEditable(bEnable);
Cmb_VoteEndCondition.SetEnabled(bEnable);
Chk_RetainCandidates.bDisabled = !bEnable;
Adt_MultiRoundGameModes.SetEnabled(bEnable);
Edt_KickVoteThreshold.EditBox.SetEditable(bEnable);
Edt_DefaultPreset.EditBox.SetEditable(bEnable);
Chk_AlwaysUseDefaultPreset.bDisabled = !bEnable;
Expand Down Expand Up @@ -141,6 +145,7 @@ function LoadServerSettings() {
Edt_VoteTimeLimit.SetValue(string(Settings.VoteTimeLimit));
Cmb_VoteEndCondition.SetSelectedIndex(int(Settings.VoteEndCondition));
Chk_RetainCandidates.bChecked = Settings.bRetainCandidates;
Adt_MultiRoundGameModes.SetValue(Settings.GetPropertyText("MultiRoundGameModes"));
Edt_KickVoteThreshold.SetValue(string(Settings.KickVoteThreshold));
Edt_DefaultPreset.SetValue(Settings.DefaultPreset);
Chk_AlwaysUseDefaultPreset.bChecked = Settings.bAlwaysUseDefaultPreset;
Expand Down Expand Up @@ -173,6 +178,7 @@ function SaveSettings() {
Settings.VoteTimeLimit = int(Edt_VoteTimeLimit.GetValue());
Settings.VoteEndCondition = Settings.IntToVoteEndCond(Cmb_VoteEndCondition.GetSelectedIndex());
Settings.bRetainCandidates = Chk_RetainCandidates.bChecked;
Settings.SetPropertyText("MultiRoundGameModes", Adt_MultiRoundGameModes.GetValue());
Settings.KickVoteThreshold = float(Edt_KickVoteThreshold.GetValue());
Settings.DefaultPreset = Edt_DefaultPreset.GetValue();
Settings.bAlwaysUseDefaultPreset = Chk_AlwaysUseDefaultPreset.bChecked;
Expand Down Expand Up @@ -239,41 +245,45 @@ function Created() {
Chk_RetainCandidates = UWindowCheckbox(CreateControl(class'UWindowCheckbox', 4, 108, 188, 16));
Chk_RetainCandidates.SetText(Text_RetainCandidates);

Edt_KickVoteThreshold = VS_UI_EditControl(CreateControl(class'VS_UI_EditControl', 4, 128, 188, 16));
Adt_MultiRoundGameModes = VS_UI_ArrayEditControl(CreateControl(class'VS_UI_ArrayEditControl', 4, 128, 188, 16));
Adt_MultiRoundGameModes.SetText(Text_MultiRoundGameModes);
Adt_MultiRoundGameModes.EditBoxWidth = 100;

Edt_KickVoteThreshold = VS_UI_EditControl(CreateControl(class'VS_UI_EditControl', 4, 148, 188, 16));
Edt_KickVoteThreshold.SetText(Text_KickVoteThreshold);
Edt_KickVoteThreshold.EditBoxWidth = 60;
Edt_KickVoteThreshold.SetNumericOnly(true);
Edt_KickVoteThreshold.SetNumericFloat(true);

Edt_DefaultPreset = VS_UI_EditControl(CreateControl(class'VS_UI_EditControl', 4, 148, 188, 16));
Edt_DefaultPreset = VS_UI_EditControl(CreateControl(class'VS_UI_EditControl', 4, 168, 188, 16));
Edt_DefaultPreset.SetText(Text_DefaultPreset);
Edt_DefaultPreset.EditBoxWidth = 100;

Chk_AlwaysUseDefaultPreset = UWindowCheckbox(CreateControl(class'UWindowCheckbox', 4, 168, 188, 16));
Chk_AlwaysUseDefaultPreset = UWindowCheckbox(CreateControl(class'UWindowCheckbox', 4, 188, 188, 16));
Chk_AlwaysUseDefaultPreset.SetText(Text_AlwaysUseDefaultPreset);

Edt_DefaultMap = VS_UI_EditControl(CreateControl(class'VS_UI_EditControl', 4, 188, 188, 16));
Edt_DefaultMap = VS_UI_EditControl(CreateControl(class'VS_UI_EditControl', 4, 208, 188, 16));
Edt_DefaultMap.SetText(Text_DefaultMap);
Edt_DefaultMap.EditBoxWidth = 100;

Chk_AlwaysUseDefaultMap = UWindowCheckbox(CreateControl(class'UWindowCheckbox', 4, 208, 188, 16));
Chk_AlwaysUseDefaultMap = UWindowCheckbox(CreateControl(class'UWindowCheckbox', 4, 228, 188, 16));
Chk_AlwaysUseDefaultMap.SetText(Text_AlwaysUseDefaultMap);

Edt_DefaultTimeMessageClass = VS_UI_EditControl(CreateControl(class'VS_UI_EditControl', 4, 228, 188, 16));
Edt_DefaultTimeMessageClass = VS_UI_EditControl(CreateControl(class'VS_UI_EditControl', 4, 248, 188, 16));
Edt_DefaultTimeMessageClass.SetText(Text_DefaultTimeMessageClass);
Edt_DefaultTimeMessageClass.EditBoxWidth = 100;

Edt_IdleTimeout = VS_UI_EditControl(CreateControl(class'VS_UI_EditControl', 4, 248, 188, 16));
Edt_IdleTimeout = VS_UI_EditControl(CreateControl(class'VS_UI_EditControl', 4, 268, 188, 16));
Edt_IdleTimeout.SetText(Text_IdleTimeout);
Edt_IdleTimeout.EditBoxWidth = 60;
Edt_IdleTimeout.SetNumericOnly(true);

Edt_MinimumMapRepeatDistance = VS_UI_EditControl(CreateControl(class'VS_UI_EditControl', 4, 268, 188, 16));
Edt_MinimumMapRepeatDistance = VS_UI_EditControl(CreateControl(class'VS_UI_EditControl', 4, 288, 188, 16));
Edt_MinimumMapRepeatDistance.SetText(Text_MinimumMapRepeatDistance);
Edt_MinimumMapRepeatDistance.EditBoxWidth = 60;
Edt_MinimumMapRepeatDistance.SetNumericOnly(true);

Edt_PresetProbeDepth = VS_UI_EditControl(CreateControl(class'VS_UI_EditControl', 4, 288, 188, 16));
Edt_PresetProbeDepth = VS_UI_EditControl(CreateControl(class'VS_UI_EditControl', 4, 308, 188, 16));
Edt_PresetProbeDepth.SetText(Text_PresetProbeDepth);
Edt_PresetProbeDepth.EditBoxWidth = 60;
Edt_PresetProbeDepth.SetNumericOnly(true);
Expand Down Expand Up @@ -351,6 +361,7 @@ function ApplyTheme() {
Edt_VoteTimeLimit.Theme = Theme;
Cmb_VoteEndCondition.Theme = Theme;
//Chk_RetainCandidates // not themed
Adt_MultiRoundGameModes.SetTheme(Theme);
Edt_KickVoteThreshold.Theme = Theme;
Edt_DefaultPreset.Theme = Theme;
//Chk_AlwaysUseDefaultPreset // not themed
Expand Down Expand Up @@ -401,6 +412,7 @@ defaultproperties {
Text_VoteEndCondition_TimerOrAllVotesIn="Everyone Voted"
Text_VoteEndCondition_TimerOrResultDetermined="Result Certain"
Text_RetainCandidates="Retain Candidates"
Text_MultiRoundGameModes="Multi-Round Games"
Text_KickVoteThreshold="Kick Vote Threshold"
Text_DefaultPreset="Default Preset"
Text_AlwaysUseDefaultPreset="Always Use Default Preset"
Expand Down
Binary file modified Docs/ServerSettings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ MidGameVoteThreshold=0.5
MidGameVoteTimeLimit=30
VoteEndCondition=VEC_TimerOnly
bRetainCandidates=False
MultiRoundGameModes=Botpack.Assault
MinimumMapRepeatDistance=0
KickVoteThreshold=0.6
DefaultTimeMessageClass=Botpack.TimeMessage
Expand Down Expand Up @@ -98,6 +99,7 @@ DefaultActors=IpServer.UdpServerUplink MasterServerAddress=unreal.epicgames.com
1. [MidGameVoteTimeLimit](#midgamevotetimelimit)
1. [VoteEndCondition](#voteendcondition)
1. [bRetainCandidates](#bretaincandidates)
1. [MultiRoundGameModes](#multiroundgamemodes)
1. [MinimumRepeatDistance](#minimumrepeatdistance)
1. [KickVoteThreshold](#kickvotethreshold)
1. [DefaultTimeMessageClass](#defaulttimemessageclass)
Expand Down Expand Up @@ -160,6 +162,14 @@ If true, candidates that no longer have any votes for them get retained. If fals

Defaults to false.

#### MultiRoundGameModes

List of game modes that are played over multiple rounds with restarts in between. You can specify either the full name of the gamemode class (Package.ClassName), or just the name of the class.

VoteSys will not detect end of game until `bDontRestart` is set to `True` on the GameInfo object.

List contains "Botpack.Assault" by default.

#### MinimumRepeatDistance

Number of different maps that must be played before being able to play the current map again.
Expand Down
1 change: 1 addition & 0 deletions System/VoteSys.int
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Text_VoteEndCondition_TimerOnly="Timer Only"
Text_VoteEndCondition_TimerOrAllVotesIn="Everyone Voted"
Text_VoteEndCondition_TimerOrResultDetermined="Result Certain"
Text_RetainCandidates="Retain Candidates"
Text_MultiRoundGameModes="Multi-Round Games"
Text_KickVoteThreshold="Kick Vote Threshold"
Text_DefaultPreset="Default Preset"
Text_AlwaysUseDefaultPreset="Always Use Default Preset"
Expand Down

0 comments on commit 318839f

Please sign in to comment.