KEYMAPPER: Add failsafe code for popping into Keymapper itself
Thanks LordHoto
This commit is contained in:
parent
d143872be6
commit
37d77253cf
3 changed files with 18 additions and 13 deletions
|
@ -163,9 +163,19 @@ void Keymapper::pushKeymap(Keymap *newMap, bool transparent, bool global) {
|
|||
_activeMaps.push(mr);
|
||||
}
|
||||
|
||||
void Keymapper::popKeymap() {
|
||||
if (!_activeMaps.empty())
|
||||
_activeMaps.pop();
|
||||
void Keymapper::popKeymap(const char *name) {
|
||||
if (!_activeMaps.empty()) {
|
||||
if (name) {
|
||||
String topKeymapName = _activeMaps.top().keymap->getName();
|
||||
if (topKeymapName.equals(name))
|
||||
_activeMaps.pop();
|
||||
else
|
||||
warning("An attempt to pop wrong keymap was blocked (expected %s but was %s)", name, topKeymapName.c_str());
|
||||
} else {
|
||||
_activeMaps.pop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool Keymapper::notifyEvent(const Common::Event &ev) {
|
||||
|
|
|
@ -131,8 +131,11 @@ public:
|
|||
|
||||
/**
|
||||
* Pop the top keymap off the active stack.
|
||||
* @param name (optional) name of keymap expected to be popped
|
||||
* if provided, will not pop unless name is the same
|
||||
* as the top keymap
|
||||
*/
|
||||
void popKeymap();
|
||||
void popKeymap(const char *name = 0);
|
||||
|
||||
// Implementation of the EventMapper interface
|
||||
bool notifyEvent(const Common::Event &ev);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue