mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Adds console toggle hotkeys to the console welcome message.
Patch By: nwtour Differential Revision: https://code.wildfiregames.com/D4347 This was SVN commit r26035.
This commit is contained in:
+24
-3
@@ -80,7 +80,9 @@ CConsole::CConsole()
|
||||
m_bCursorVisState = true;
|
||||
m_cursorBlinkRate = 0.5;
|
||||
|
||||
InsertMessage("[ 0 A.D. Console v0.14 ]");
|
||||
m_QuitHotkeyWasShown = false;
|
||||
|
||||
InsertMessage("[ 0 A.D. Console v0.15 ]");
|
||||
InsertMessage("");
|
||||
}
|
||||
|
||||
@@ -121,6 +123,22 @@ void CConsole::UpdateScreenSize(int w, int h)
|
||||
m_fHeight = height / g_VideoMode.GetScale();
|
||||
}
|
||||
|
||||
void CConsole::ShowQuitHotkeys()
|
||||
{
|
||||
if (m_QuitHotkeyWasShown)
|
||||
return;
|
||||
|
||||
std::string str;
|
||||
for (const std::pair<const SDL_Scancode_, KeyMapping>& key : g_HotkeyMap)
|
||||
if (key.second.front().name == "console.toggle")
|
||||
str += (str.empty() ? "Press " : " / ") + FindScancodeName(static_cast<SDL_Scancode>(key.first));
|
||||
|
||||
if (!str.empty())
|
||||
InsertMessage(str + " to quit.");
|
||||
|
||||
m_QuitHotkeyWasShown = true;
|
||||
}
|
||||
|
||||
void CConsole::ToggleVisible()
|
||||
{
|
||||
m_bToggle = true;
|
||||
@@ -128,9 +146,12 @@ void CConsole::ToggleVisible()
|
||||
|
||||
// TODO: this should be based on input focus, not visibility
|
||||
if (m_bVisible)
|
||||
{
|
||||
ShowQuitHotkeys();
|
||||
SDL_StartTextInput();
|
||||
else
|
||||
SDL_StopTextInput();
|
||||
return;
|
||||
}
|
||||
SDL_StopTextInput();
|
||||
}
|
||||
|
||||
void CConsole::SetVisible(bool visible)
|
||||
|
||||
@@ -110,6 +110,7 @@ private:
|
||||
bool m_bToggle; // show/hide animation is currently active
|
||||
double m_prevTime; // the previous time the cursor draw state changed (used for blinking cursor)
|
||||
bool m_bCursorVisState; // if the cursor should be drawn or not
|
||||
bool m_QuitHotkeyWasShown; // show console.toggle hotkey values at first time
|
||||
double m_cursorBlinkRate; // cursor blink rate in seconds, if greater than 0.0
|
||||
|
||||
void DrawWindow(CCanvas2D& canvas);
|
||||
@@ -128,6 +129,7 @@ private:
|
||||
|
||||
void LoadHistory();
|
||||
void SaveHistory();
|
||||
void ShowQuitHotkeys();
|
||||
};
|
||||
|
||||
extern CConsole* g_Console;
|
||||
|
||||
Reference in New Issue
Block a user