Skip to content

Commit 877ca9e

Browse files
committed
re-add infclass controls settings page
1 parent 084e06a commit 877ca9e

4 files changed

Lines changed: 175 additions & 4 deletions

File tree

src/game/client/components/menus.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,8 @@ class CMenus : public CComponent
560560
// TODO: Change PopupConfirm to avoid using a function pointer to a CMenus
561561
// member function, to move this function to CMenusSettingsControls
562562
void ResetSettingsControls();
563+
void ResetSettingsInfclassControls();
564+
void LoadPresetInfclassControls();
563565

564566
std::vector<CButtonContainer> m_vButtonContainersNamePlateShow = {{}, {}, {}, {}};
565567
std::vector<CButtonContainer> m_vButtonContainersNamePlateKeyPresses = {{}, {}, {}, {}};

src/game/client/components/menus_settings.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,27 @@ void CMenus::RenderSettings(CUIRect MainView)
15031503
else if(g_Config.m_UiSettingsPage == SETTINGS_CONTROLS)
15041504
{
15051505
GameClient()->m_MenuBackground.ChangePosition(CMenuBackground::POS_SETTINGS_CONTROLS);
1506-
m_MenusSettingsControls.Render(MainView);
1506+
1507+
static int s_CurControlsTab = 0;
1508+
1509+
CUIRect TabLabel1, TabLabel2;
1510+
1511+
MainView.HSplitTop(20, &TabLabel1, &MainView);
1512+
TabLabel1.VSplitMid(&TabLabel1, &TabLabel2);
1513+
1514+
static CButtonContainer s_PageTabs[2];
1515+
if(DoButton_MenuTab(&s_PageTabs[0], Localize("General"), s_CurControlsTab == 0, &TabLabel1, IGraphics::CORNER_L, NULL, NULL, NULL, NULL, 4))
1516+
s_CurControlsTab = 0;
1517+
if(DoButton_MenuTab(&s_PageTabs[1], Localize("InfClass"), s_CurControlsTab == 1, &TabLabel2, IGraphics::CORNER_R, NULL, NULL, NULL, NULL, 4))
1518+
s_CurControlsTab = 1;
1519+
1520+
MainView.HSplitTop(10.0f, 0x0, &MainView);
1521+
1522+
m_MenusSettingsControls.m_ControlsTab = s_CurControlsTab;
1523+
if(s_CurControlsTab == 0)
1524+
m_MenusSettingsControls.Render(MainView);
1525+
else
1526+
m_MenusSettingsControls.RenderInfclass(MainView);
15071527
}
15081528
else if(g_Config.m_UiSettingsPage == SETTINGS_GRAPHICS)
15091529
{

src/game/client/components/menus_settings_controls.cpp

Lines changed: 146 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,52 @@ void CMenusSettingsControls::OnInterfacesInit(CGameClient *pClient)
108108
{EBindOptionGroup::MISCELLANEOUS, Localizable("Lock team"), "say /lock"},
109109
{EBindOptionGroup::MISCELLANEOUS, Localizable("Show entities"), "toggle cl_overlay_entities 0 100"},
110110
{EBindOptionGroup::MISCELLANEOUS, Localizable("Show HUD"), "toggle cl_showhud 0 1"},
111+
112+
// Localize - these strings are localized within CLocConstString
113+
{EBindOptionGroup::INFC_REPORTLOCATION, Localizable("Bottom/left"), "say_team_location bottomleft"},
114+
{EBindOptionGroup::INFC_REPORTLOCATION, Localizable("Bottom"), "say_team_location bottom"},
115+
{EBindOptionGroup::INFC_REPORTLOCATION, Localizable("Bottom/right"), "say_team_location bottomright"},
116+
{EBindOptionGroup::INFC_REPORTLOCATION, Localizable("Left"), "say_team_location left"},
117+
{EBindOptionGroup::INFC_REPORTLOCATION, Localizable("Middle"), "say_team_location middle"},
118+
{EBindOptionGroup::INFC_REPORTLOCATION, Localizable("Right"), "say_team_location right"},
119+
{EBindOptionGroup::INFC_REPORTLOCATION, Localizable("Top/Left"), "say_team_location topleft"},
120+
{EBindOptionGroup::INFC_REPORTLOCATION, Localizable("Top"), "say_team_location top"},
121+
{EBindOptionGroup::INFC_REPORTLOCATION, Localizable("Top/Right"), "say_team_location topright"},
122+
123+
{EBindOptionGroup::INFC_REPORTLOCATION, Localizable("Bunker"), "say_team_location bunker"},
124+
{EBindOptionGroup::INFC_REPORTLOCATION, Localizable("Bonus zone"), "say_team_location bonuszone"},
125+
{EBindOptionGroup::INFC_REPORTLOCATION, Localizable("Spawn"), "say_team_location infspawn"},
126+
127+
{EBindOptionGroup::INFC_REPORTLOCATIONCLEAR, Localizable("Bottom/left is clear"), "say_team_location bottomleft clear"},
128+
{EBindOptionGroup::INFC_REPORTLOCATIONCLEAR, Localizable("Bottom is clear"), "say_team_location bottom clear"},
129+
{EBindOptionGroup::INFC_REPORTLOCATIONCLEAR, Localizable("Bottom/right is clear"), "say_team_location bottomright clear"},
130+
{EBindOptionGroup::INFC_REPORTLOCATIONCLEAR, Localizable("Left is clear"), "say_team_location left clear"},
131+
{EBindOptionGroup::INFC_REPORTLOCATIONCLEAR, Localizable("Middle is clear"), "say_team_location middle clear"},
132+
{EBindOptionGroup::INFC_REPORTLOCATIONCLEAR, Localizable("Right is clear"), "say_team_location right clear"},
133+
{EBindOptionGroup::INFC_REPORTLOCATIONCLEAR, Localizable("Top/Left is clear"), "say_team_location topleft clear"},
134+
{EBindOptionGroup::INFC_REPORTLOCATIONCLEAR, Localizable("Top is clear"), "say_team_location top clear"},
135+
{EBindOptionGroup::INFC_REPORTLOCATIONCLEAR, Localizable("Top/Right is clear"), "say_team_location topright clear"},
136+
137+
{EBindOptionGroup::INFC_REPORTLOCATIONCLEAR, Localizable("Bunker is clear"), "say_team_location bunker clear"},
138+
{EBindOptionGroup::INFC_REPORTLOCATIONCLEAR, Localizable("Bonus zone is clear"), "say_team_location bonuszone clear"},
139+
{EBindOptionGroup::INFC_REPORTLOCATIONCLEAR, Localizable("Spawn is clear"), "say_team_location infspawn clear"},
140+
141+
{EBindOptionGroup::INFC_TEAMCHAT, Localizable("\"RUN!\""), "say_message run"},
142+
{EBindOptionGroup::INFC_TEAMCHAT, Localizable("\"Ghost!\""), "say_message ghost"},
143+
{EBindOptionGroup::INFC_TEAMCHAT, Localizable("\"Help!\""), "say_message help"},
144+
{EBindOptionGroup::INFC_TEAMCHAT, Localizable("\"Boom (hammer) fly\""), "say_message bfhf"},
145+
{EBindOptionGroup::INFC_TEAMCHAT, Localizable("\"Where?\""), "say_message where"},
146+
{EBindOptionGroup::INFC_TEAMCHAT, Localizable("\"Clear!\""), "say_message clear"},
147+
{EBindOptionGroup::INFC_TEAMCHAT, Localizable("\"Call witch!\""), "say_message witch"},
148+
{EBindOptionGroup::INFC_TEAMCHAT, Localizable("\"Taxi!\""), "say_message taxi"},
149+
{EBindOptionGroup::INFC_TEAMCHAT, Localizable("\"Need a Taxi!\""), "say_message asktaxi"},
150+
{EBindOptionGroup::INFC_TEAMCHAT, Localizable("\"Anyone needs a Taxi?\""), "say_message suggesttaxi"},
151+
{EBindOptionGroup::INFC_TEAMCHAT, Localizable("\"Please find a flag!\""), "say_message askflag"},
152+
{EBindOptionGroup::INFC_TEAMCHAT, Localizable("\"Anyone needs a flag?\""), "say_message suggestflag"},
153+
{EBindOptionGroup::INFC_TEAMCHAT, Localizable("\"Medic!\""), "say_message askhealing"},
154+
{EBindOptionGroup::INFC_TEAMCHAT, Localizable("\"Who needs a healing?\""), "say_message suggesthealing"},
155+
156+
{EBindOptionGroup::INFC_EXTRA, Localizable("Call witch"), "witch"},
111157
};
112158
m_NumPredefinedBindOptions = m_vBindOptions.size();
113159

@@ -203,6 +249,92 @@ void CMenusSettingsControls::Render(CUIRect MainView)
203249
m_SettingsScrollRegion.End();
204250
}
205251

252+
void CMenusSettingsControls::RenderInfclass(CUIRect MainView)
253+
{
254+
UpdateBindOptions();
255+
256+
CUIRect QuickSearch, SearchMatches, RectUnbind, RectLoadPreset;
257+
MainView.HSplitBottom(BUTTON_HEIGHT, &MainView, &QuickSearch);
258+
QuickSearch.VSplitRight(200.0f, &QuickSearch, &RectLoadPreset);
259+
QuickSearch.VSplitRight(MARGIN, &QuickSearch, nullptr);
260+
// QuickSearch.VSplitRight(200.0f, &QuickSearch, &RectUnbind);
261+
// QuickSearch.VSplitRight(MARGIN, &QuickSearch, nullptr);
262+
QuickSearch.VSplitRight(150.0f, &QuickSearch, &SearchMatches);
263+
QuickSearch.VSplitRight(MARGIN, &QuickSearch, nullptr);
264+
MainView.HSplitBottom(MARGIN, &MainView, nullptr);
265+
266+
// Quick search
267+
if(Ui()->DoEditBox_Search(&m_FilterInput, &QuickSearch, FONT_SIZE, !Ui()->IsPopupOpen() && !GameClient()->m_GameConsole.IsActive() && !GameClient()->m_KeyBinder.IsActive()))
268+
{
269+
m_CurrentSearchMatch = 0;
270+
UpdateSearchMatches();
271+
m_SearchMatchReveal = true;
272+
}
273+
else if(!m_vSearchMatches.empty() && (Ui()->ConsumeHotkey(CUi::EHotkey::HOTKEY_ENTER) || Ui()->ConsumeHotkey(CUi::EHotkey::HOTKEY_TAB)))
274+
{
275+
UpdateSearchMatches();
276+
m_CurrentSearchMatch += Input()->ShiftIsPressed() ? -1 : 1;
277+
if(m_CurrentSearchMatch >= (int)m_vSearchMatches.size())
278+
{
279+
m_CurrentSearchMatch = 0;
280+
}
281+
if(m_CurrentSearchMatch < 0)
282+
{
283+
m_CurrentSearchMatch = m_vSearchMatches.size() - 1;
284+
}
285+
m_SearchMatchReveal = true;
286+
}
287+
288+
if(!m_FilterInput.IsEmpty())
289+
{
290+
if(!m_vSearchMatches.empty())
291+
{
292+
char aSearchMatchLabel[64];
293+
str_format(aSearchMatchLabel, sizeof(aSearchMatchLabel), Localize("Match %d of %d"), m_CurrentSearchMatch + 1, (int)m_vSearchMatches.size());
294+
Ui()->DoLabel(&SearchMatches, aSearchMatchLabel, FONT_SIZE, TEXTALIGN_MC);
295+
}
296+
else
297+
{
298+
Ui()->DoLabel(&SearchMatches, Localize("No results"), FONT_SIZE, TEXTALIGN_MC);
299+
}
300+
}
301+
302+
// static CButtonContainer ContainerUnbind;
303+
// if(GameClient()->m_Menus.DoButton_Menu(&ContainerUnbind, Localize("Unbind all"), 0, &RectUnbind))
304+
// {
305+
// GameClient()->m_Menus.PopupConfirm(Localize("Unbind controls"), Localize("Are you sure that you want to unbind all infclass controls?"),
306+
// Localize("Unbind"), Localize("Cancel"), &CMenus::ResetSettingsInfclassControls);
307+
// }
308+
static CButtonContainer PresetUnbind;
309+
if(GameClient()->m_Menus.DoButton_Menu(&PresetUnbind, Localize("Load the preset"), 0, &RectLoadPreset))
310+
{
311+
GameClient()->m_Menus.PopupConfirm(Localize("Load preset"), Localize("Are you sure that you want to load the preset for infclass controls?"),
312+
Localize("Load Preset"), Localize("Cancel"), &CMenus::LoadPresetInfclassControls);
313+
}
314+
315+
vec2 ScrollOffset(0.0f, 0.0f);
316+
CScrollRegionParams ScrollParams;
317+
ScrollParams.m_ScrollUnit = 6.0f * BUTTON_HEIGHT;
318+
ScrollParams.m_Flags = CScrollRegionParams::FLAG_CONTENT_STATIC_WIDTH;
319+
m_SettingsScrollRegion.Begin(&MainView, &ScrollOffset, &ScrollParams);
320+
MainView.y += ScrollOffset.y;
321+
322+
CUIRect LeftColumn, RightColumn;
323+
MainView.VSplitMid(&LeftColumn, &RightColumn, MARGIN);
324+
325+
RenderSettingsBindsBlock(EBindOptionGroup::INFC_REPORTLOCATION, &LeftColumn, Localize("Report location"));
326+
RenderSettingsBindsBlock(EBindOptionGroup::INFC_TEAMCHAT, &LeftColumn, Localize("Report location is clear"));
327+
328+
RenderSettingsBindsBlock(EBindOptionGroup::INFC_REPORTLOCATIONCLEAR, &RightColumn, Localize("Team chat"));
329+
RenderSettingsBindsBlock(EBindOptionGroup::INFC_EXTRA, &RightColumn, Localize("Extra commands"));
330+
if(std::any_of(m_vBindOptions.begin(), m_vBindOptions.end(), [](const CBindOption &Option) { return Option.m_Group == EBindOptionGroup::CUSTOM; }))
331+
{
332+
RenderSettingsBindsBlock(EBindOptionGroup::CUSTOM, &RightColumn, Localize("Custom"));
333+
}
334+
335+
m_SettingsScrollRegion.End();
336+
}
337+
206338
void CMenusSettingsControls::UpdateBindOptions()
207339
{
208340
for(CBindOption &Option : m_vBindOptions)
@@ -221,7 +353,7 @@ void CMenusSettingsControls::UpdateBindOptions()
221353
for(int KeyId = KEY_FIRST; KeyId < KEY_LAST; KeyId++)
222354
{
223355
const CBindSlot BindSlot = CBindSlot(KeyId, Mod);
224-
const char *pBind = GameClient()->m_Binds.Get(BindSlot);
356+
const char *pBind = m_ControlsTab == 0 ? GameClient()->m_Binds.Get(BindSlot) : GameClient()->m_InfCBinds.Get(BindSlot);
225357
if(!pBind[0])
226358
{
227359
continue;
@@ -542,13 +674,14 @@ void CMenusSettingsControls::RenderSettingsBinds(EBindOptionGroup Group, CUIRect
542674
else if(KeyReaderResult.m_Bind != CurrentBind.m_Bind)
543675
{
544676
BindOption.m_AddNewBind = false;
677+
CBinds &Binds = m_ControlsTab == 0 ? GameClient()->m_Binds : GameClient()->m_InfCBinds;
545678
if(CurrentBind.m_Bind.m_Key != KEY_UNKNOWN || KeyReaderResult.m_Bind.m_Key == KEY_UNKNOWN)
546679
{
547-
GameClient()->m_Binds.Bind(CurrentBind.m_Bind.m_Key, "", false, CurrentBind.m_Bind.m_ModifierMask);
680+
Binds.Bind(CurrentBind.m_Bind.m_Key, "", false, CurrentBind.m_Bind.m_ModifierMask);
548681
}
549682
if(KeyReaderResult.m_Bind.m_Key != KEY_UNKNOWN)
550683
{
551-
GameClient()->m_Binds.Bind(KeyReaderResult.m_Bind.m_Key, BindOption.m_Command.c_str(), false, KeyReaderResult.m_Bind.m_ModifierMask);
684+
Binds.Bind(KeyReaderResult.m_Bind.m_Key, BindOption.m_Command.c_str(), false, KeyReaderResult.m_Bind.m_ModifierMask);
552685
}
553686
}
554687
}
@@ -793,3 +926,13 @@ void CMenus::ResetSettingsControls()
793926
g_Config.m_InpControllerTolerance = 5;
794927
g_Config.m_UiControllerSens = 100;
795928
}
929+
930+
void CMenus::ResetSettingsInfclassControls()
931+
{
932+
933+
}
934+
935+
void CMenus::LoadPresetInfclassControls()
936+
{
937+
GameClient()->m_InfCBinds.LoadPreset();
938+
}

src/game/client/components/menus_settings_controls.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ enum class EBindOptionGroup
2020
DUMMY,
2121
MISCELLANEOUS,
2222
CUSTOM,
23+
INFC_REPORTLOCATION,
24+
INFC_REPORTLOCATIONCLEAR,
25+
INFC_TEAMCHAT,
26+
INFC_EXTRA,
2327
NUM,
2428
};
2529

@@ -56,6 +60,8 @@ class CMenusSettingsControls : public CComponentInterfaces
5660
public:
5761
void OnInterfacesInit(CGameClient *pClient) override;
5862
void Render(CUIRect MainView);
63+
void RenderInfclass(CUIRect MainView);
64+
int m_ControlsTab;
5965

6066
private:
6167
bool m_aBindGroupExpanded[(int)EBindOptionGroup::NUM];

0 commit comments

Comments
 (0)