aboutsummaryrefslogtreecommitdiff
path: root/gui/gui-manager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/gui-manager.cpp')
-rw-r--r--gui/gui-manager.cpp71
1 files changed, 36 insertions, 35 deletions
diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp
index 98840e6daf..ffecd928bc 100644
--- a/gui/gui-manager.cpp
+++ b/gui/gui-manager.cpp
@@ -103,27 +103,31 @@ GuiManager::~GuiManager() {
void GuiManager::initKeymap() {
using namespace Common;
- bool tmp;
Keymapper *mapper = _system->getEventManager()->getKeymapper();
// Do not try to recreate same keymap over again
- if (mapper->getKeymap(kGuiKeymapName, tmp) != 0)
+ if (mapper->getKeymap(kGuiKeymapName) != 0)
return;
Action *act;
Keymap *guiMap = new Keymap(kGuiKeymapName);
- act = new Action(guiMap, "CLOS", _("Close"), kGenericActionType, kStartKeyType);
+ act = new Action(guiMap, "CLOS", _("Close"));
act->addKeyEvent(KeyState(KEYCODE_ESCAPE, ASCII_ESCAPE, 0));
act = new Action(guiMap, "CLIK", _("Mouse click"));
act->addLeftClickEvent();
- act = new Action(guiMap, "VIRT", _("Display keyboard"), kVirtualKeyboardActionType);
- act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, 0));
+#ifdef ENABLE_VKEYBD
+ act = new Action(guiMap, "VIRT", _("Display keyboard"));
+ act->addEvent(EVENT_VIRTUAL_KEYBOARD);
+#endif
+
+ act = new Action(guiMap, "REMP", _("Remap keys"));
+ act->addEvent(EVENT_KEYMAPPER_REMAP);
- act = new Action(guiMap, "REMP", _("Remap keys"), kKeyRemapActionType);
- act->addKeyEvent(KeyState(KEYCODE_F8, ASCII_F8, 0));
+ act = new Action(guiMap, "FULS", _("Toggle FullScreen"));
+ act->addKeyEvent(KeyState(KEYCODE_RETURN, ASCII_RETURN, KBD_ALT));
mapper->addGlobalKeymap(guiMap);
}
@@ -133,15 +137,7 @@ void GuiManager::pushKeymap() {
}
void GuiManager::popKeymap() {
- Common::Keymapper *keymapper = _system->getEventManager()->getKeymapper();
- if (!keymapper->getActiveStack().empty()) {
- Common::Keymapper::MapRecord topKeymap = keymapper->getActiveStack().top();
- // TODO: Don't use the keymap name as a way to discriminate GUI maps
- if(topKeymap.keymap->getName().equals(Common::kGuiKeymapName))
- keymapper->popKeymap();
- else
- warning("An attempt to pop non-gui keymap %s was blocked", topKeymap.keymap->getName().c_str());
- }
+ _system->getEventManager()->getKeymapper()->popKeymap(Common::kGuiKeymapName);
}
#endif
@@ -192,7 +188,7 @@ bool GuiManager::loadNewTheme(Common::String id, ThemeEngine::GraphicsMode gfx,
}
// refresh all dialogs
- for (int i = 0; i < _dialogStack.size(); ++i)
+ for (DialogStack::size_type i = 0; i < _dialogStack.size(); ++i)
_dialogStack[i]->reflowLayout();
// We need to redraw immediately. Otherwise
@@ -206,7 +202,6 @@ bool GuiManager::loadNewTheme(Common::String id, ThemeEngine::GraphicsMode gfx,
}
void GuiManager::redraw() {
- int i;
ThemeEngine::ShadingStyle shading;
if (_redrawStatus == kRedrawDisabled || _dialogStack.empty())
@@ -227,7 +222,7 @@ void GuiManager::redraw() {
_theme->clearAll();
_theme->openDialog(true, ThemeEngine::kShadingNone);
- for (i = 0; i < _dialogStack.size() - 1; i++)
+ for (DialogStack::size_type i = 0; i < _dialogStack.size() - 1; i++)
_dialogStack[i]->drawDialog();
_theme->finishBuffering();
@@ -286,18 +281,9 @@ 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();
- pushKeymap();
-#endif
-
bool tooltipCheck = false;
- while (!_dialogStack.empty() && activeDialog == getTopDialog()) {
+ while (!_dialogStack.empty() && activeDialog == getTopDialog() && !eventMan->shouldQuit()) {
redraw();
// Don't "tickle" the dialog until the theme has had a chance
@@ -376,12 +362,13 @@ void GuiManager::runLoop() {
case Common::EVENT_WHEELDOWN:
activeDialog->handleMouseWheel(mouse.x, mouse.y, 1);
break;
- case Common::EVENT_QUIT:
- return;
case Common::EVENT_SCREEN_CHANGED:
screenChange();
break;
default:
+#ifdef ENABLE_KEYMAPPER
+ activeDialog->handleOtherEvent(event);
+#endif
break;
}
@@ -406,9 +393,16 @@ void GuiManager::runLoop() {
_system->delayMillis(10);
}
-#ifdef ENABLE_KEYMAPPER
- popKeymap();
-#endif
+ // WORKAROUND: When quitting we might not properly close the dialogs on
+ // the dialog stack, thus we do this here to avoid any problems.
+ // This is most noticable in bug #3481395 "LAUNCHER: Can't quit from unsupported game dialog".
+ // It seems that Dialog::runModal never removes the dialog from the dialog
+ // stack, thus if the dialog does not call Dialog::close to close itself
+ // it will never be removed. Since we can have multiple run loops being
+ // called we cannot rely on catching EVENT_QUIT in the event loop above,
+ // since it would only catch it for the top run loop.
+ if (eventMan->shouldQuit() && activeDialog == getTopDialog())
+ getTopDialog()->close();
if (didSaveState) {
_theme->disable();
@@ -420,6 +414,10 @@ void GuiManager::runLoop() {
#pragma mark -
void GuiManager::saveState() {
+#ifdef ENABLE_KEYMAPPER
+ initKeymap();
+ pushKeymap();
+#endif
// Backup old cursor
_lastClick.x = _lastClick.y = 0;
_lastClick.time = 0;
@@ -429,6 +427,9 @@ void GuiManager::saveState() {
}
void GuiManager::restoreState() {
+#ifdef ENABLE_KEYMAPPER
+ popKeymap();
+#endif
if (_useStdCursor) {
CursorMan.popCursor();
CursorMan.popCursorPalette();
@@ -516,7 +517,7 @@ void GuiManager::screenChange() {
_theme->refresh();
// refresh all dialogs
- for (int i = 0; i < _dialogStack.size(); ++i) {
+ for (DialogStack::size_type i = 0; i < _dialogStack.size(); ++i) {
_dialogStack[i]->reflowLayout();
}
// We need to redraw immediately. Otherwise