Skip to content

Commit

Permalink
Fix controls rectangle overlapping topbar and being clickable outside…
Browse files Browse the repository at this point in the history
… of scope
  • Loading branch information
def- committed Jul 22, 2017
1 parent 9b582cf commit d50b39c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
9 changes: 5 additions & 4 deletions src/game/client/components/menus.cpp
Expand Up @@ -1009,16 +1009,13 @@ int CMenus::Render()

if(m_Popup == POPUP_NONE)
{
// do tab bar
#if defined(__ANDROID__)
Screen.HSplitTop(100.0f, &TabBar, &MainView);
#else
Screen.HSplitTop(24.0f, &TabBar, &MainView);
#endif
TabBar.VMargin(20.0f, &TabBar);
RenderMenubar(TabBar);

// news is not implemented yet
// render news
if(g_Config.m_UiPage < PAGE_NEWS || g_Config.m_UiPage > PAGE_SETTINGS || (Client()->State() == IClient::STATE_OFFLINE && g_Config.m_UiPage >= PAGE_GAME && g_Config.m_UiPage <= PAGE_CALLVOTE))
{
ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET);
Expand Down Expand Up @@ -1060,6 +1057,10 @@ int CMenus::Render()
RenderServerbrowser(MainView);
else if(g_Config.m_UiPage == PAGE_SETTINGS)
RenderSettings(MainView);

// do tab bar
TabBar.VMargin(20.0f, &TabBar);
RenderMenubar(TabBar);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/components/menus.h
Expand Up @@ -73,7 +73,7 @@ class CMenus : public CComponent
int DoKeyReader(void *pID, const CUIRect *pRect, int Key);

//static int ui_do_key_reader(void *id, const CUIRect *rect, int key);
void UiDoGetButtons(int Start, int Stop, CUIRect View);
void UiDoGetButtons(int Start, int Stop, CUIRect View, CUIRect ScopeView);

struct CListboxItem
{
Expand Down
17 changes: 10 additions & 7 deletions src/game/client/components/menus_settings.cpp
Expand Up @@ -703,15 +703,18 @@ static CKeyInfo gs_aKeys[] =

const int g_KeyCount = sizeof(gs_aKeys) / sizeof(CKeyInfo);

void CMenus::UiDoGetButtons(int Start, int Stop, CUIRect View)
void CMenus::UiDoGetButtons(int Start, int Stop, CUIRect View, CUIRect ScopeView)
{
for (int i = Start; i < Stop; i++)
for(int i = Start; i < Stop; i++)
{
CKeyInfo &Key = gs_aKeys[i];
CUIRect Button, Label;
View.HSplitTop(20.0f, &Button, &View);
Button.VSplitLeft(135.0f, &Label, &Button);

if(Button.y < ScopeView.y || Button.y + Button.h > ScopeView.y + ScopeView.h)
continue;

char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%s:", (const char *)Key.m_Name);

Expand Down Expand Up @@ -783,7 +786,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView)
MovementSettings.HSplitTop(20.0f, 0, &MovementSettings);
}

UiDoGetButtons(0, 17, MovementSettings);
UiDoGetButtons(0, 17, MovementSettings, MainView);

}

Expand All @@ -797,7 +800,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView)
TextRender()->Text(0, WeaponSettings.x, WeaponSettings.y, 14.0f*UI()->Scale(), Localize("Weapon"), -1);

WeaponSettings.HSplitTop(14.0f+5.0f+10.0f, 0, &WeaponSettings);
UiDoGetButtons(17, 24, WeaponSettings);
UiDoGetButtons(17, 24, WeaponSettings, MainView);
}

// defaults
Expand All @@ -823,7 +826,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView)
TextRender()->Text(0, VotingSettings.x, VotingSettings.y, 14.0f*UI()->Scale(), Localize("Voting"), -1);

VotingSettings.HSplitTop(14.0f+5.0f+10.0f, 0, &VotingSettings);
UiDoGetButtons(24, 26, VotingSettings);
UiDoGetButtons(24, 26, VotingSettings, MainView);
}

// chat settings
Expand All @@ -836,7 +839,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView)
TextRender()->Text(0, ChatSettings.x, ChatSettings.y, 14.0f*UI()->Scale(), Localize("Chat"), -1);

ChatSettings.HSplitTop(14.0f+5.0f+10.0f, 0, &ChatSettings);
UiDoGetButtons(26, 30, ChatSettings);
UiDoGetButtons(26, 30, ChatSettings, MainView);
}

// misc settings
Expand All @@ -849,7 +852,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView)
TextRender()->Text(0, MiscSettings.x, MiscSettings.y, 14.0f*UI()->Scale(), Localize("Miscellaneous"), -1);

MiscSettings.HSplitTop(14.0f+5.0f+10.0f, 0, &MiscSettings);
UiDoGetButtons(30, 42, MiscSettings);
UiDoGetButtons(30, 42, MiscSettings, MainView);
}

UiDoListboxEnd(&s_ScrollValue, 0);
Expand Down

0 comments on commit d50b39c

Please sign in to comment.