From bc1c59448d998fcd45448b1f4708685481629f29 Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Tue, 30 Jun 2020 14:22:26 +0300 Subject: [PATCH] skip trader button is active only on trader time --- ServerExt/Classes/UI_MidGameMenu.uc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ServerExt/Classes/UI_MidGameMenu.uc b/ServerExt/Classes/UI_MidGameMenu.uc index 584e853..2523a29 100644 --- a/ServerExt/Classes/UI_MidGameMenu.uc +++ b/ServerExt/Classes/UI_MidGameMenu.uc @@ -8,7 +8,7 @@ struct FPageInfo var KFGUI_SwitchMenuBar PageSwitcher; var() array Pages; -var KFGUI_Button AdminButton,SpectateButton; +var KFGUI_Button AdminButton,SpectateButton,SkipTraderButton; var transient KFGUI_Button PrevButton; var transient int NumButtons,NumButtonRows; @@ -23,7 +23,7 @@ function InitMenu() Super(KFGUI_Page).InitMenu(); AddMenuButton('Mapvote',"Map Vote","Show mapvote menu"); AddMenuButton('Settings',"Settings","Enter the game settings"); - AddMenuButton('SkipTrader',"Skip Trader","start voting for skip trader"); + SkipTraderButton = AddMenuButton('SkipTrader',"Skip Trader","start voting for skip trader"); AddMenuButton('Disconnect',"Disconnect","Disconnect from this server"); SpectateButton = AddMenuButton('Spectate',"",""); AddMenuButton('Close',"Close","Close this menu"); @@ -45,6 +45,7 @@ function Timer() if( PRI==None ) return; AdminButton.SetDisabled(!PRI.bAdmin && PRI.WorldInfo.NetMode==NM_Client); + SkipTraderButton.SetDisabled(!SkipTraderIsAviable(PRI)); if( !bInitSpectate || bOldSpectate!=PRI.bOnlySpectator ) { bInitSpectate = true; @@ -54,10 +55,24 @@ function Timer() } } +function bool SkipTraderIsAviable(PlayerReplicationInfo PRI) +{ + local KFGameReplicationInfo KFGRI; + local KFPlayerReplicationInfo KFPRI; + + KFPRI = KFPlayerReplicationInfo(PRI); + if (KFPRI == none) + return false; + + KFGRI = KFGameReplicationInfo(KFPRI.WorldInfo.GRI); + return (KFGRI.bMatchHasBegun && KFGRI.bTraderIsOpen && KFPRI.bHasSpawnedIn); +} + function ShowMenu() { Super.ShowMenu(); AdminButton.SetDisabled(true); + SkipTraderButton.SetDisabled(false); if( GetPlayer().WorldInfo.GRI!=None ) WindowTitle = GetPlayer().WorldInfo.GRI.ServerName; //KFGFxHudWrapper(GetPlayer().MyHUD).SetVisible(false);