Add focus callback to GUI engine
This commit is contained in:
parent
d3708ba798
commit
84821ad604
@ -311,6 +311,9 @@ namespace GUIEngine
|
|||||||
* Can be used to set focus for instance.
|
* Can be used to set focus for instance.
|
||||||
*/
|
*/
|
||||||
virtual void onDialogClose() {}
|
virtual void onDialogClose() {}
|
||||||
|
|
||||||
|
/** Callback called when focus changes */
|
||||||
|
virtual void onFocusChanged(Widget* previous, Widget* focus, int playerID) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class CutsceneScreen : public Screen
|
class CutsceneScreen : public Screen
|
||||||
|
@ -255,10 +255,11 @@ void Widget::setFocusForPlayer(const int playerID)
|
|||||||
assert(m_magic_number == 0xCAFEC001);
|
assert(m_magic_number == 0xCAFEC001);
|
||||||
|
|
||||||
// Unset focus flag on previous widget that had focus
|
// Unset focus flag on previous widget that had focus
|
||||||
if (GUIEngine::getFocusForPlayer(playerID) != NULL)
|
Widget* previous_focus = GUIEngine::getFocusForPlayer(playerID);
|
||||||
|
if (previous_focus != NULL)
|
||||||
{
|
{
|
||||||
GUIEngine::getFocusForPlayer(playerID)->unfocused(playerID, this);
|
previous_focus->unfocused(playerID, this);
|
||||||
GUIEngine::getFocusForPlayer(playerID)->m_player_focus[playerID] = false;
|
previous_focus->m_player_focus[playerID] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_player_focus[playerID] = true;
|
m_player_focus[playerID] = true;
|
||||||
@ -266,6 +267,9 @@ void Widget::setFocusForPlayer(const int playerID)
|
|||||||
|
|
||||||
// Callback
|
// Callback
|
||||||
this->focused(playerID);
|
this->focused(playerID);
|
||||||
|
|
||||||
|
Screen* screen = GUIEngine::getCurrentScreen();
|
||||||
|
screen->onFocusChanged(previous_focus, this, playerID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user