Skip to content

Commit 7a81d2d

Browse files
committed
add more (map)vote related toggles; actually fix voting issue
1 parent eb73d3d commit 7a81d2d

2 files changed

Lines changed: 27 additions & 53 deletions

File tree

src/engine/shared/config_variables.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,9 @@ MACRO_CONFIG_INT(ClDemoShowPause, cl_demo_show_pause, 1, 0, 1, CFGFLAG_SAVE | CF
734734
MACRO_CONFIG_INT(ClDemoKeyboardShortcuts, cl_demo_keyboard_shortcuts, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Enable keyboard shortcuts in demo player")
735735

736736
// Pointer31's additions
737+
MACRO_CONFIG_INT(ClMapVotes, cl_mapvotes, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Whether to enable map voting screen")
737738
MACRO_CONFIG_INT(ClMapVotesItemsPerRow, cl_mapvotes_items_per_row, 1, 1, 4, CFGFLAG_SAVE | CFGFLAG_CLIENT, "How many maps per row are displayed in the vote screen")
739+
MACRO_CONFIG_INT(ClVotesItemsPerRow, cl_votes_items_per_row, 1, 1, 4, CFGFLAG_SAVE | CFGFLAG_CLIENT, "How many votes per row are displayed in the vote screen")
738740
MACRO_CONFIG_STR(ClLocalServerRconpwd, cl_local_server_rconpwd, 128, "", CFGFLAG_CLIENT, "potentially the rcon password for local server")
739741
MACRO_CONFIG_INT(ClExtraParticles, cl_extra_particles, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Whether to enable more particles")
740742
MACRO_CONFIG_INT(ClConfirmKillTime, cl_confirm_kill_time, 5, -1, 1440, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Confirmation message before killing self after game time (in minutes, -1 to turn off, 0 to always turn on)")

src/game/client/components/menus_ingame.cpp

Lines changed: 25 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -858,70 +858,40 @@ bool CMenus::RenderServerControlServer(CUIRect MainView, bool UpdateScroll, bool
858858
if (maps)
859859
s_ListBox.DoStart(19.0f, TotalShown, g_Config.m_ClMapVotesItemsPerRow, 3, s_CurVoteOption, &List);
860860
else
861-
s_ListBox.DoStart(19.0f, TotalShown, 1, 3, s_CurVoteOption, &List);
861+
s_ListBox.DoStart(19.0f, TotalShown, g_Config.m_ClVotesItemsPerRow, 3, s_CurVoteOption, &List);
862862

863-
i = -1;
863+
i = 0;
864864
for(CVoteOptionClient *pOption = GameClient()->m_Voting.m_pFirst; pOption; pOption = pOption->m_pNext, i++)
865865
{
866866
if(!m_FilterInput.IsEmpty() && !str_utf8_find_nocase(pOption->m_aDescription, m_FilterInput.GetString()))
867867
continue;
868868

869-
bool is_map_vote = (str_startswith_nocase(pOption->m_aDescription, "Map: ") ||
870-
str_startswith_nocase(pOption->m_aDescription, "(XS) ") ||
871-
str_startswith_nocase(pOption->m_aDescription, "(S) ") ||
872-
str_startswith_nocase(pOption->m_aDescription, "(M) ") ||
873-
str_startswith_nocase(pOption->m_aDescription, "(L) ") ||
874-
str_startswith_nocase(pOption->m_aDescription, "(XL) ") ||
875-
str_utf8_find_nocase(pOption->m_aDescription, "  "));
876-
if (!maps && is_map_vote)
877-
continue;
878-
if (maps && !is_map_vote)
879-
continue;
869+
if (g_Config.m_ClMapVotes) {
870+
bool is_map_vote = (str_startswith_nocase(pOption->m_aDescription, "Map: ") ||
871+
str_startswith_nocase(pOption->m_aDescription, "(XS) ") ||
872+
str_startswith_nocase(pOption->m_aDescription, "(S) ") ||
873+
str_startswith_nocase(pOption->m_aDescription, "(M) ") ||
874+
str_startswith_nocase(pOption->m_aDescription, "(L) ") ||
875+
str_startswith_nocase(pOption->m_aDescription, "(XL) ") ||
876+
str_utf8_find_nocase(pOption->m_aDescription, "  "));
877+
if (!maps && is_map_vote)
878+
continue;
879+
if (maps && !is_map_vote)
880+
continue;
881+
}
880882

881883
if(NumVoteOptions < Total) {
882884
aIndices[NumVoteOptions] = i;
883885
}
884886
NumVoteOptions++;
885-
// aIndices[NumVoteOptions] = i;
886887

887888
const CListboxItem Item = s_ListBox.DoNextItem(pOption);
888889
if(!Item.m_Visible)
889890
continue;
890891

891-
if (is_map_vote) {
892-
CUIRect left; CUIRect right;
893-
Item.m_Rect.VSplitMid(&left, &right);
894-
895-
CUIRect Label1;
896-
left.VMargin(-2.0f, &Label1);
897-
Ui()->DoLabel(&Label1, pOption->m_aDescription, 13.0f, TEXTALIGN_ML);
898-
899-
CUIRect Label2;
900-
right.VMargin(-2.0f, &Label2);
901-
902-
TextRender()->TextColor(0.0, 0.0, 0.0, 0); // none/unknown
903-
char* temp_text = "Theme";
904-
if (str_utf8_find_nocase(pOption->m_aDescription, "   ")) // dark
905-
{TextRender()->TextColor(0.2, 0, 0.2, 1); temp_text = "Dark";}
906-
else if (str_utf8_find_nocase(pOption->m_aDescription, "   ")) // sky
907-
{TextRender()->TextColor(0.6, 0.6, 0.7, 1); temp_text = "Sky";}
908-
else if (str_utf8_find_nocase(pOption->m_aDescription, "   ")) // desert
909-
{TextRender()->TextColor(1, 0.7, 0.5, 1); temp_text = "Desert";}
910-
else if (str_utf8_find_nocase(pOption->m_aDescription, "   ")) // snow
911-
{TextRender()->TextColor(0.9, 0.9, 1, 1); temp_text = "Snow";}
912-
else if (str_utf8_find_nocase(pOption->m_aDescription, "   ")) // jungle
913-
{TextRender()->TextColor(0.2, 0.7, 0.2, 1); temp_text = "Jungle";}
914-
else if (str_utf8_find_nocase(pOption->m_aDescription, "   ")) // grass
915-
{TextRender()->TextColor(0.5, 1, 0.5, 1); temp_text = "Grass";}
916-
917-
const char* text = temp_text;
918-
Ui()->DoLabel(&Label2, text, 13.0f, TEXTALIGN_ML);
919-
TextRender()->TextColor(TextRender()->DefaultTextColor());
920-
} else {
921-
CUIRect Label;
922-
Item.m_Rect.VMargin(2.0f, &Label);
923-
Ui()->DoLabel(&Label, pOption->m_aDescription, 13.0f, TEXTALIGN_ML);
924-
}
892+
CUIRect Label;
893+
Item.m_Rect.VMargin(2.0f, &Label);
894+
Ui()->DoLabel(&Label, pOption->m_aDescription, 13.0f, TEXTALIGN_ML);
925895
}
926896

927897
Selected = s_ListBox.DoEnd();
@@ -1011,15 +981,17 @@ void CMenus::RenderServerControl(CUIRect MainView)
1011981
MainView.HSplitBottom(90.0f, &MainView, &RconExtension);
1012982

1013983
// tab bar
1014-
TabBar.VSplitLeft(TabBar.w / 4, &Button, &TabBar);
984+
TabBar.VSplitLeft(TabBar.w / (3 + g_Config.m_ClMapVotes), &Button, &TabBar);
1015985
static CButtonContainer s_Button0;
1016986
if(DoButton_MenuTab(&s_Button0, Localize("Change settings"), s_ControlPage == EServerControlTab::SETTINGS, &Button, IGraphics::CORNER_NONE))
1017987
s_ControlPage = EServerControlTab::SETTINGS;
1018988

1019-
TabBar.VSplitLeft(TabBar.w / 3, &Button, &TabBar);
1020-
static CButtonContainer s_Button3;
1021-
if(DoButton_MenuTab(&s_Button3, Localize("Change map"), s_ControlPage == EServerControlTab::SETTINGS_MAPS, &Button, IGraphics::CORNER_NONE))
1022-
s_ControlPage = EServerControlTab::SETTINGS_MAPS;
989+
if (g_Config.m_ClMapVotes) {
990+
TabBar.VSplitLeft(TabBar.w / 3, &Button, &TabBar);
991+
static CButtonContainer s_Button3;
992+
if(DoButton_MenuTab(&s_Button3, Localize("Change map"), s_ControlPage == EServerControlTab::SETTINGS_MAPS, &Button, IGraphics::CORNER_NONE))
993+
s_ControlPage = EServerControlTab::SETTINGS_MAPS;
994+
}
1023995

1024996
TabBar.VSplitMid(&Button, &TabBar);
1025997
static CButtonContainer s_Button1;

0 commit comments

Comments
 (0)