Skip to content

Commit

Permalink
Save current selection to client config
Browse files Browse the repository at this point in the history
  • Loading branch information
peterekepeter committed Sep 18, 2023
1 parent ce0b9fc commit a8aab13
Show file tree
Hide file tree
Showing 3 changed files with 484 additions and 626 deletions.
55 changes: 39 additions & 16 deletions MVE2dev/Classes/ConfigWindow.uc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var UMenuLabelControl lblMenuKey;
var UMenuRaisedButton ButMenuKey;
var string OldMenuKey;
var bool bMenu;
var float ConfigChangeTime;

var UWindowHSliderControl RSlider, GSlider, BSlider, RBSlider, GBSlider, BBSlider;
var UWindowHSliderControl BXT, Title1, Title2, Title3, Title4, Title5, Title6;
Expand Down Expand Up @@ -397,55 +398,55 @@ function Notify(UWindowDialogControl C, byte E)
if(RSlider != None)
{
Config.BackgroundColor.R = RSlider.GetValue();
Config.SaveConfig();
SaveConfigWithDebounce();
}
break;

case GSlider:
if(GSlider != None)
{
Config.BackgroundColor.G = GSlider.GetValue();
Config.SaveConfig();
SaveConfigWithDebounce();
}
break;

case BSlider:
if(BSlider != None)
{
Config.BackgroundColor.B = BSlider.GetValue();
Config.SaveConfig();
SaveConfigWithDebounce();
}
break;

case RBSlider:
if(RBSlider != None)
{
Config.BoxesColor.R = RBSlider.GetValue();
Config.SaveConfig();
SaveConfigWithDebounce();
}
break;

case GBSlider:
if(GBSlider != None)
{
Config.BoxesColor.G = GBSlider.GetValue();
Config.SaveConfig();
SaveConfigWithDebounce();
}
break;

case BBSlider:
if(BBSlider != None)
{
Config.BoxesColor.B = BBSlider.GetValue();
Config.SaveConfig();
SaveConfigWithDebounce();
}
break;

case BXT:
if(BXT != None && BXTL != None && lblBXT != None)
{
Config.BoxesTextColor = int(BXT.GetValue());
Config.SaveConfig();
SaveConfigWithDebounce();
BXTL.SetText(Config.GetNameOfBoxesTextColor());
lblBXT.SetTextColor(Config.GetColorOfBoxesTextColor());
}
Expand All @@ -455,7 +456,7 @@ function Notify(UWindowDialogControl C, byte E)
if(Title1 != None && TitleText1 != None && lblMLT1 != None)
{
Config.GameModTitleColor = int(Title1.GetValue());
Config.SaveConfig();
SaveConfigWithDebounce();
TitleText1.SetText(Config.GetNameOfGameModTitleColor());
lblMLT1.SetTextColor(Config.GetColorOfGameModTitleColor());
}
Expand All @@ -465,7 +466,7 @@ function Notify(UWindowDialogControl C, byte E)
if(Title2 != None && TitleText2 != None && lblMLT2 != None)
{
Config.RuleTitleColor = int(Title2.GetValue());
Config.SaveConfig();
SaveConfigWithDebounce();
TitleText2.SetText(Config.GetNameOfRuleTitleColor());
lblMLT2.SetTextColor(Config.GetColorOfRuleTitleColor());
}
Expand All @@ -475,7 +476,7 @@ function Notify(UWindowDialogControl C, byte E)
if(Title3 != None && TitleText3 != None && lblMLT3 != None)
{
Config.MapTitleColor = int(Title3.GetValue());
Config.SaveConfig();
SaveConfigWithDebounce();
TitleText3.SetText(Config.GetNameOfMapTitleColor());
lblMLT3.SetTextColor(Config.GetColorOfMapTitleColor());
}
Expand All @@ -485,7 +486,7 @@ function Notify(UWindowDialogControl C, byte E)
if(Title4 != None && TitleText4 != None && lblMLT4 != None)
{
Config.KickVoteTitleColor = int(Title4.GetValue());
Config.SaveConfig();
SaveConfigWithDebounce();
TitleText4.SetText(Config.GetNameOfKickVoteTitleColor());
lblMLT4.SetTextColor(Config.GetColorOfKickVoteTitleColor());
}
Expand All @@ -495,7 +496,7 @@ function Notify(UWindowDialogControl C, byte E)
if(Title5 != None && TitleText5 != None && lblMLT5 != None)
{
Config.PlayerTitleColor = int(Title5.GetValue());
Config.SaveConfig();
SaveConfigWithDebounce();
TitleText5.SetText(Config.GetNameOfPlayerTitleColor());
lblMLT5.SetTextColor(Config.GetColorOfPlayerTitleColor());
}
Expand All @@ -505,7 +506,7 @@ function Notify(UWindowDialogControl C, byte E)
if(Title6 != None && TitleText6 != None && lblMLT6 != None)
{
Config.MapVoteTitleColor = int(Title6.GetValue());
Config.SaveConfig();
SaveConfigWithDebounce();
TitleText6.SetText(Config.GetNameOfMapVoteTitleColor());
lblMLT6.SetTextColor(Config.GetColorOfMapVoteTitleColor());
}
Expand All @@ -516,7 +517,7 @@ function Notify(UWindowDialogControl C, byte E)
{
lblMsgTimeOut.SetText(string(int(sldMsgTimeOut.Value)) $ " sec");
Config.MsgTimeOut = sldMsgTimeOut.GetValue();
Config.SaveConfig();
SaveConfigWithDebounce();
}
break;
}
Expand Down Expand Up @@ -590,6 +591,7 @@ function SetMenuKey(int KeyNo, string KeyName)
function Close (optional bool bByParent)
{
SaveMapVoteConfig();
SaveClientConfigPendingChanges();
Super.Close(bByParent);
}

Expand All @@ -606,7 +608,7 @@ function SaveMapVoteConfig ()
{
Config.MsgTimeOut=int(sldMsgTimeOut.Value);
Config.bUseMsgTimeout=cbUseMsgTimeout.bChecked;
Config.SaveConfig();
SaveConfigWithDebounce();
}
if ( Config.bUseMsgTimeout )
{
Expand All @@ -615,10 +617,31 @@ function SaveMapVoteConfig ()
Class'RedSayMessagePlus'.Default.Lifetime=Config.MsgTimeOut;
Class'TeamSayMessagePlus'.Default.Lifetime=Config.MsgTimeOut;
Class'StringMessagePlus'.Default.Lifetime=Config.MsgTimeOut;
Class'DeathMessagePlus'.Default.Lifetime=Config.MsgTimeOut;
Class'DeathMessagePlus'.Default.Lifetime=Config.M
Log("SaveConfigWithDebounce");sgTimeOut;
}
}

function SaveConfigWithDebounce()
{
ConfigChangeTime = GetPlayerOwner().Level.TimeSeconds;
}

function Tick(float DeltaTime)
{
if ( (ConfigChangeTime != 0) && (GetPlayerOwner().Level.TimeSeconds > ConfigChangeTime + 1) )
{
SaveClientConfigPendingChanges();
}
Super.Tick(DeltaTime);
}

function SaveClientConfigPendingChanges()
{
Config.SaveClientConfig();
ConfigChangeTime = 0;
}

defaultproperties
{
RealKeyName(0)=""
Expand Down
22 changes: 21 additions & 1 deletion MVE2dev/Classes/MapVoteClientConfig.uc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ var() config int MapTitleColor;
var() config int KickVoteTitleColor;
var() config int PlayerTitleColor;
var() config int MapVoteTitleColor;
var() config string SelectedGameMode;
var() config string SelectedGameRule;
var() config string SelectedMap;

var config float MsgTimeOut;
var config bool bUseMsgTimeout;
Expand All @@ -27,6 +30,11 @@ static function MapVoteClientConfig GetInstance()
return new (class'MVE_ClientConfig', 'MapVoteClientConfig') class'MapVoteClientConfig';
}

function SaveClientConfig()
{
SaveConfig();
}

defaultproperties
{
BackgroundColor=(R=75,G=0,B=0,A=0)
Expand Down Expand Up @@ -119,4 +127,16 @@ function MapVoteClientConfigColors GetColorUtil()
Util = new class'MapVoteClientConfigColors';
}
return Util;
}
}

function SetSelectedGameMode(string value){
SelectedGameMode = value;
}

function SetSelectedGameRule(string value){
SelectedGameRule = value;
}

function SetSelectedMap(string value){
SelectedMap = value;
}
Loading

0 comments on commit a8aab13

Please sign in to comment.