Close console when it loses focus but it is still on screen

master
Esteban I. Ruiz Moreno 2013-06-04 23:26:52 -03:00 committed by Kahrl
parent 4f6bec19bc
commit 7cb5217255
3 changed files with 12 additions and 0 deletions

View File

@ -1684,6 +1684,10 @@ void the_game(
{ {
input->clear(); input->clear();
} }
if (!guienv->hasFocus(gui_chat_console) && gui_chat_console->isOpen())
{
gui_chat_console->closeConsoleAtOnce();
}
// Input handler step() (used by the random input generator) // Input handler step() (used by the random input generator)
input->step(dtime); input->step(dtime);

View File

@ -134,6 +134,11 @@ void GUIChatConsole::openConsole(f32 height)
reformatConsole(); reformatConsole();
} }
bool GUIChatConsole::isOpen() const
{
return m_open;
}
bool GUIChatConsole::isOpenInhibited() const bool GUIChatConsole::isOpenInhibited() const
{ {
return m_open_inhibited > 0; return m_open_inhibited > 0;

View File

@ -39,6 +39,9 @@ public:
// This doesn't open immediately but initiates an animation. // This doesn't open immediately but initiates an animation.
// You should call isOpenInhibited() before this. // You should call isOpenInhibited() before this.
void openConsole(f32 height); void openConsole(f32 height);
bool isOpen() const;
// Check if the console should not be opened at the moment // Check if the console should not be opened at the moment
// This is to avoid reopening the console immediately after closing // This is to avoid reopening the console immediately after closing
bool isOpenInhibited() const; bool isOpenInhibited() const;