KEYMAPPER: Skip GUI keymap when displaying active keymap in keymapper dialog

This fixes a problem where opening the keymapper dialog would cause the current game
keymap to be displayed as the active keymap but then changing the keymap selection
back to it would cause the GUI keymap to be displayed as the active one. The GUI keymap
was indeed at the top of the stack but that's not the desired effect.

Also move the pushing and popping of the keymap to Dialog::Open/Close
Also constantify the GUI keymap name
This commit is contained in:
Tarek Soliman 2011-10-21 22:54:33 -05:00
parent ac85d134b3
commit a5082ffa5d
5 changed files with 31 additions and 20 deletions

View file

@ -107,11 +107,11 @@ void GuiManager::initKeymap() {
Keymapper *mapper = _system->getEventManager()->getKeymapper();
// Do not try to recreate same keymap over again
if (mapper->getKeymap("gui", tmp) != 0)
if (mapper->getKeymap(kGuiKeymapName, tmp) != 0)
return;
Action *act;
Keymap *guiMap = new Keymap("gui");
Keymap *guiMap = new Keymap(kGuiKeymapName);
act = new Action(guiMap, "CLOS", _("Close"), kGenericActionType, kStartKeyType);
act->addKeyEvent(KeyState(KEYCODE_ESCAPE, ASCII_ESCAPE, 0));
@ -127,6 +127,14 @@ void GuiManager::initKeymap() {
mapper->addGlobalKeymap(guiMap);
}
void GuiManager::pushKeymap() {
_system->getEventManager()->getKeymapper()->pushKeymap(Common::kGuiKeymapName);
}
void GuiManager::popKeymap() {
_system->getEventManager()->getKeymapper()->popKeymap();
}
#endif
bool GuiManager::loadNewTheme(Common::String id, ThemeEngine::GraphicsMode gfx, bool forced) {
@ -270,16 +278,6 @@ void GuiManager::runLoop() {
uint32 lastRedraw = 0;
const uint32 waitTime = 1000 / 45;
#ifdef ENABLE_KEYMAPPER
// Due to circular reference with event manager and GUI
// we cannot init keymap on the GUI creation. Thus, let's
// try to do it on every launch, checking whether the
// map is already existing
initKeymap();
eventMan->getKeymapper()->pushKeymap("gui");
#endif
bool tooltipCheck = false;
while (!_dialogStack.empty() && activeDialog == getTopDialog()) {
@ -391,10 +389,6 @@ void GuiManager::runLoop() {
_system->delayMillis(10);
}
#ifdef ENABLE_KEYMAPPER
eventMan->getKeymapper()->popKeymap();
#endif
if (didSaveState) {
_theme->disable();
restoreState();