From 3379596de4dd86461ec2b949e73fc0b1a66c6798 Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Sun, 14 Aug 2022 14:17:50 +0300 Subject: [PATCH] add VoteTime setting --- CVC/Classes/BaseVote.uc | 11 ++++++++++ CVC/Classes/CVC.uc | 4 +++- CVC/Classes/CVCMut.uc | 4 +--- CVC/Classes/CVC_VoteCollector.uc | 34 ++++++++++++++++++++++++------ PublicationContent/description.txt | 11 ++++++---- README.md | 1 - 6 files changed, 50 insertions(+), 15 deletions(-) diff --git a/CVC/Classes/BaseVote.uc b/CVC/Classes/BaseVote.uc index 762498f..07a02be 100644 --- a/CVC/Classes/BaseVote.uc +++ b/CVC/Classes/BaseVote.uc @@ -7,6 +7,7 @@ var public config String NegativeColorHex; var public config bool bChatNotifications; var public config bool bHudNotifications; var public config float DefferedClearHUD; +var public config int VoteTime; public static function InitConfig(int Version, int LatestVersion, E_LogLevel LogLevel) { @@ -17,6 +18,9 @@ public static function InitConfig(int Version, int LatestVersion, E_LogLevel Log case `NO_CONFIG: ApplyDefault(LogLevel); + case 1: + default.VoteTime = class'KFVoteCollector'.default.VoteTime; + default: break; } @@ -47,6 +51,12 @@ public static function Load(E_LogLevel LogLevel) `Log_Error("DefferedClearHUD" @ "(" $ default.DefferedClearHUD $ ")" @ "must be greater than 0"); default.DefferedClearHUD = 0.0f; } + + if (default.VoteTime <= 0 || default.VoteTime > 255) + { + `Log_Error("VoteTime" @ "(" $ default.VoteTime $ ")" @ "must be in range 1-255"); + default.VoteTime = class'KFVoteCollector'.default.VoteTime; + } } protected static function ApplyDefault(E_LogLevel LogLevel) @@ -58,6 +68,7 @@ protected static function ApplyDefault(E_LogLevel LogLevel) default.PositiveColorHex = class'KFLocalMessage'.default.EventColor; default.NegativeColorHex = class'KFLocalMessage'.default.InteractionColor; default.DefferedClearHUD = 1.0f; + default.VoteTime = class'KFVoteCollector'.default.VoteTime; } protected static function bool IsValidHexColor(String HexColor, E_LogLevel LogLevel) diff --git a/CVC/Classes/CVC.uc b/CVC/Classes/CVC.uc index 5ea38a1..ce45d9e 100644 --- a/CVC/Classes/CVC.uc +++ b/CVC/Classes/CVC.uc @@ -2,7 +2,7 @@ class CVC extends Info dependson(CVC_LocalMessage) config(CVC); -const LatestVersion = 1; +const LatestVersion = 2; const CfgKickProtected = class'KickProtected'; const CfgKickVote = class'KickVote'; @@ -78,6 +78,8 @@ private function PreInit() { case `NO_CONFIG: `Log_Info("Config created"); + + case 1: case MaxInt: `Log_Info("Config updated to version"@LatestVersion); diff --git a/CVC/Classes/CVCMut.uc b/CVC/Classes/CVCMut.uc index 60f42c9..e682a27 100644 --- a/CVC/Classes/CVCMut.uc +++ b/CVC/Classes/CVCMut.uc @@ -15,19 +15,17 @@ public event PreBeginPlay() foreach WorldInfo.DynamicActors(class'CVC', CVC) { - `Log_Base("Found 'CVC'"); break; } if (CVC == None) { - `Log_Base("Spawn 'CVC'"); CVC = WorldInfo.Spawn(class'CVC'); } if (CVC == None) { - `Log_Base("Can't Spawn 'CVC', Destroy..."); + `Log_Base("FATAL: Can't Spawn 'CVC'"); SafeDestroy(); } } diff --git a/CVC/Classes/CVC_VoteCollector.uc b/CVC/Classes/CVC_VoteCollector.uc index a7b2153..626260c 100644 --- a/CVC/Classes/CVC_VoteCollector.uc +++ b/CVC/Classes/CVC_VoteCollector.uc @@ -163,7 +163,7 @@ public function ServerStartVoteKick(PlayerReplicationInfo PRI_Kickee, PlayerRepl GetKFPRIArray(KFPRIs); foreach KFPRIs(KFPRI) { - KFPRI.ShowKickVote(PRI_Kickee, VoteTime, !(KFPRI == PRI_Kicker || KFPRI == PRI_Kickee)); + KFPRI.ShowKickVote(PRI_Kickee, CfgKickVote.default.VoteTime, !(KFPRI == PRI_Kicker || KFPRI == PRI_Kickee)); } if (CfgKickVote.default.bChatNotifications) @@ -197,7 +197,7 @@ public function ServerStartVoteKick(PlayerReplicationInfo PRI_Kickee, PlayerRepl AllowHudNotification = bTraderIsOpen; } - SetTimer(VoteTime, false, nameof(ConcludeVoteKick), Self); + SetTimer(CfgKickVote.default.VoteTime, false, nameof(ConcludeVoteKick), Self); RecieveVoteKick(PRI_Kicker, true); } @@ -382,7 +382,7 @@ public reliable server function RecieveVoteKick(PlayerReplicationInfo PRI, bool { CVC.BroadcastHUDLocalized( CVC_KickVoteStartedHUD, - float(VoteTime), + float(CfgKickVote.default.VoteTime), KickerName, KickeeName, YesVotesPlayers); @@ -391,7 +391,7 @@ public reliable server function RecieveVoteKick(PlayerReplicationInfo PRI, bool { CVC.BroadcastHUDLocalized( CVC_KickVoteReceivedHUD, - float(VoteTime), + float(CfgKickVote.default.VoteTime), YesVotesPlayers, NoVotesPlayers); } @@ -568,6 +568,17 @@ private function String LogVotePlayer(S_KickVote KV) return KV.Name @ "(UniqueID:" @ KV.UniqueID $ (KV.SteamID == "" ? "" : (", SteamID:" @ KV.SteamID $ ", Profile:" @ "https://steamcommunity.com/profiles/" $ KV.SteamID)) $ ")" @ "Perk:" @ Repl(String(KV.Perk), "KFPerk_", "", false) @ "Level:" @ String(KV.Level); } +public function ServerStartVoteSkipTrader(PlayerReplicationInfo PRI) +{ + `Log_Trace(); + + VoteTime = CfgSkipTraderVote.default.VoteTime; + + Super.ServerStartVoteSkipTrader(PRI); + + VoteTime = default.VoteTime; +} + public reliable server function RecieveVoteSkipTrader(PlayerReplicationInfo PRI, bool bSkip) { local bool MustNotify; @@ -592,7 +603,7 @@ public reliable server function RecieveVoteSkipTrader(PlayerReplicationInfo PRI, { CVC.BroadcastHUDLocalized( CVC_VoteProgressHUD, - float(VoteTime), + float(CfgSkipTraderVote.default.VoteTime), VotedPlayers(), DidntVotedPlayers()); } @@ -619,6 +630,17 @@ public reliable server function ConcludeVoteSkipTrader() Super.ConcludeVoteSkipTrader(); } +public function ServerStartVotePauseGame(PlayerReplicationInfo PRI) +{ + `Log_Trace(); + + VoteTime = CfgPauseVote.default.VoteTime; + + Super.ServerStartVotePauseGame(PRI); + + VoteTime = default.VoteTime; +} + public reliable server function ReceiveVotePauseGame(PlayerReplicationInfo PRI, bool bSkip) { local bool MustNotify; @@ -643,7 +665,7 @@ public reliable server function ReceiveVotePauseGame(PlayerReplicationInfo PRI, { CVC.BroadcastHUDLocalized( CVC_VoteProgressHUD, - float(VoteTime), + float(CfgPauseVote.default.VoteTime), VotedPlayers(), DidntVotedPlayers()); } diff --git a/PublicationContent/description.txt b/PublicationContent/description.txt index 9e12c08..16cd894 100644 --- a/PublicationContent/description.txt +++ b/PublicationContent/description.txt @@ -1,4 +1,4 @@ -[img]https://img.shields.io/static/v1?logo=GitHub&labelColor=gray&color=blue&logoColor=white&label=&message=Open Source[/img] [img]https://img.shields.io/github/license/GenZmeY/KF2-ControlledVoteCollector[/img] [img]https://img.shields.io/steam/subscriptions/2847465899[/img] [img]https://img.shields.io/steam/favorites/2847465899[/img] [img]https://img.shields.io/steam/update-date/2847465899[/img] [url=https://steamcommunity.com/sharedfiles/filedetails/changelog/2847465899][img]https://img.shields.io/github/v/tag/GenZmeY/KF2-ControlledVoteCollector[/img][/url] +[img]https://img.shields.io/static/v1?logo=GitHub&labelColor=gray&color=blue&logoColor=white&label=&message=Open Source[/img] [img]https://img.shields.io/github/license/GenZmeY/KF2-ControlledVoteCollector[/img] [img]https://img.shields.io/steam/favorites/2847465899[/img] [img]https://img.shields.io/steam/update-date/2847465899[/img] [url=https://steamcommunity.com/sharedfiles/filedetails/changelog/2847465899][img]https://img.shields.io/github/v/tag/GenZmeY/KF2-ControlledVoteCollector[/img][/url] [h1]Description[/h1] New vote collector with improvements and features. @@ -69,7 +69,8 @@ This section sets the next map when no one voted for the map. [*][b]PositiveColorHex[/b] - hex color for yes vote in chat; [*][b]NegativeColorHex[/b] - hex color for no vote in chat; [*][b]bHudNotifications[/b] - set to [b]True[/b] to see player votes in HUD; -[*][b]DefferedClearHUD[/b] - HUD notification will remain on the screen for the specified number of seconds after voting ends. +[*][b]DefferedClearHUD[/b] - HUD notification will remain on the screen for the specified number of seconds after voting ends; +[*][b]VoteTime[/b] - time in seconds for voting (will be automatically reduced if it exceeds the trader's remaining time). [/list] [b][CVC.PauseVote][/b] @@ -78,7 +79,8 @@ This section sets the next map when no one voted for the map. [*][b]PositiveColorHex[/b] - hex color for yes vote in chat; [*][b]NegativeColorHex[/b] - hex color for no vote in chat; [*][b]bHudNotifications[/b] - set to [b]True[/b] to see player votes in HUD; -[*][b]DefferedClearHUD[/b] - HUD notification will remain on the screen for the specified number of seconds after voting ends. +[*][b]DefferedClearHUD[/b] - HUD notification will remain on the screen for the specified number of seconds after voting ends; +[*][b]VoteTime[/b] - time in seconds for voting (will be automatically reduced if it exceeds the trader's remaining time). [/list] [b][CVC.KickVote][/b] @@ -92,7 +94,8 @@ This section sets the next map when no one voted for the map. [*][b]DefferedClearHUD[/b] - HUD notification will remain on the screen for the specified number of seconds after voting ends. [*][b]bLogKickVote[/b] - set to [b]True[/b] to log information about every kick vote; [*][b]MinVotingPlayersToStartKickVote[/b] - minimum number of voting players to start kick voting; -[*][b]MaxKicks[/b] - maximum number of kicks per game. +[*][b]MaxKicks[/b] - maximum number of kicks per game; +[*][b]VoteTime[/b] - time in seconds for voting. [/list] [b][CVC.KickProtected][/b] diff --git a/README.md b/README.md index c27c58c..e68f162 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Controlled Vote Collector [![Steam Workshop](https://img.shields.io/static/v1?message=workshop&logo=steam&labelColor=gray&color=blue&logoColor=white&label=steam%20)](https://steamcommunity.com/sharedfiles/filedetails/?id=2847465899) -[![Steam Subscriptions](https://img.shields.io/steam/subscriptions/2847465899)](https://steamcommunity.com/sharedfiles/filedetails/?id=2847465899) [![Steam Favorites](https://img.shields.io/steam/favorites/2847465899)](https://steamcommunity.com/sharedfiles/filedetails/?id=2847465899) [![Steam Update Date](https://img.shields.io/steam/update-date/2847465899)](https://steamcommunity.com/sharedfiles/filedetails/?id=2847465899) [![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/GenZmeY/KF2-ControlledVoteCollector)](https://github.com/GenZmeY/KF2-ControlledVoteCollector/tags)