mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-12 19:18:20 +00:00
Fix key reader text flashing for one frame, refactoring
The key reader was displaying the old key for a frame. It now shows the new key immediately without flashing the old one after changing a bind. Refactoring: - The if-branches are restructured to be the same as on upstream. - The function `GetKeyBindModifiersName` can be called without an additional check, because it returns an empty string when no modifier is pressed. - The unused parameter `Checked` of the `DoButton_KeySelect` function is removed. From teeworlds/teeworlds#2877.
This commit is contained in:
parent
d76755db06
commit
0688355d7b
|
@ -184,7 +184,7 @@ int CMenus::DoButton_Menu(CButtonContainer *pButtonContainer, const char *pText,
|
||||||
return UI()->DoButtonLogic(pButtonContainer, Checked, pRect);
|
return UI()->DoButtonLogic(pButtonContainer, Checked, pRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMenus::DoButton_KeySelect(const void *pID, const char *pText, int Checked, const CUIRect *pRect)
|
void CMenus::DoButton_KeySelect(const void *pID, const char *pText, const CUIRect *pRect)
|
||||||
{
|
{
|
||||||
pRect->Draw(ColorRGBA(1, 1, 1, 0.5f * UI()->ButtonColorMul(pID)), IGraphics::CORNER_ALL, 5.0f);
|
pRect->Draw(ColorRGBA(1, 1, 1, 0.5f * UI()->ButtonColorMul(pID)), IGraphics::CORNER_ALL, 5.0f);
|
||||||
CUIRect Temp;
|
CUIRect Temp;
|
||||||
|
@ -644,22 +644,16 @@ int CMenus::DoKeyReader(void *pID, const CUIRect *pRect, int Key, int ModifierCo
|
||||||
|
|
||||||
// draw
|
// draw
|
||||||
if(UI()->CheckActiveItem(pID) && s_ButtonUsed == 0)
|
if(UI()->CheckActiveItem(pID) && s_ButtonUsed == 0)
|
||||||
DoButton_KeySelect(pID, "???", 0, pRect);
|
DoButton_KeySelect(pID, "???", pRect);
|
||||||
|
else if(NewKey == 0)
|
||||||
|
DoButton_KeySelect(pID, "", pRect);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(Key)
|
char aBuf[64];
|
||||||
{
|
str_format(aBuf, sizeof(aBuf), "%s%s", CBinds::GetKeyBindModifiersName(*pNewModifierCombination), Input()->KeyName(NewKey));
|
||||||
char aBuf[64];
|
DoButton_KeySelect(pID, aBuf, pRect);
|
||||||
if(*pNewModifierCombination)
|
|
||||||
str_format(aBuf, sizeof(aBuf), "%s%s", CBinds::GetKeyBindModifiersName(*pNewModifierCombination), Input()->KeyName(Key));
|
|
||||||
else
|
|
||||||
str_copy(aBuf, Input()->KeyName(Key));
|
|
||||||
|
|
||||||
DoButton_KeySelect(pID, aBuf, 0, pRect);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
DoButton_KeySelect(pID, "", 0, pRect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewKey;
|
return NewKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ class CMenus : public CComponent
|
||||||
int DoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, bool UseScroll, int Current, int Min, int Max, int Step, float Scale, bool IsHex, float Round, ColorRGBA *pColor);
|
int DoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, bool UseScroll, int Current, int Min, int Max, int Step, float Scale, bool IsHex, float Round, ColorRGBA *pColor);
|
||||||
int DoButton_GridHeader(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
|
int DoButton_GridHeader(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
|
||||||
|
|
||||||
void DoButton_KeySelect(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
|
void DoButton_KeySelect(const void *pID, const char *pText, const CUIRect *pRect);
|
||||||
int DoKeyReader(void *pID, const CUIRect *pRect, int Key, int ModifierCombination, int *pNewModifierCombination);
|
int DoKeyReader(void *pID, const CUIRect *pRect, int Key, int ModifierCombination, int *pNewModifierCombination);
|
||||||
|
|
||||||
void DoSettingsControlsButtons(int Start, int Stop, CUIRect View);
|
void DoSettingsControlsButtons(int Start, int Stop, CUIRect View);
|
||||||
|
|
Loading…
Reference in a new issue