[Scummvm-cvs-logs] scummvm master -> 12d1a9d37f716d8aae4e373705d7f8beec1b8842

tsoliman tarek at bashasoliman.com
Sun Jan 8 05:21:55 CET 2012


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
37d77253cf KEYMAPPER: Add failsafe code for popping into Keymapper itself
12d1a9d37f KYRA: Fix LoL/EoB savegame typing issue with keymapper


Commit: 37d77253cfd5cc1c7bef635d4d5bd05eb53ac02c
    https://github.com/scummvm/scummvm/commit/37d77253cfd5cc1c7bef635d4d5bd05eb53ac02c
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-01-07T20:08:57-08:00

Commit Message:
KEYMAPPER: Add failsafe code for popping into Keymapper itself

Thanks LordHoto

Changed paths:
    backends/keymapper/keymapper.cpp
    backends/keymapper/keymapper.h
    gui/gui-manager.cpp



diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp
index f950b1f..3871134 100644
--- a/backends/keymapper/keymapper.cpp
+++ b/backends/keymapper/keymapper.cpp
@@ -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) {
diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h
index cd060a4..d2aa89c 100644
--- a/backends/keymapper/keymapper.h
+++ b/backends/keymapper/keymapper.h
@@ -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);
diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp
index a9b8085..64853b5 100644
--- a/gui/gui-manager.cpp
+++ b/gui/gui-manager.cpp
@@ -132,15 +132,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
 


Commit: 12d1a9d37f716d8aae4e373705d7f8beec1b8842
    https://github.com/scummvm/scummvm/commit/12d1a9d37f716d8aae4e373705d7f8beec1b8842
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-01-07T20:20:48-08:00

Commit Message:
KYRA: Fix LoL/EoB savegame typing issue with keymapper

If you bind letters (e.g. WSAD) using the keymapper and then try to
save using the in-engine dialog, the letters would get captured and
make it impossible to name a save using those letters.

Thanks LordHoto

Changed paths:
    engines/kyra/gui_eob.cpp
    engines/kyra/gui_lol.cpp



diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp
index d60fa47..611eab1 100644
--- a/engines/kyra/gui_eob.cpp
+++ b/engines/kyra/gui_eob.cpp
@@ -29,6 +29,7 @@
 #include "kyra/timer.h"
 #include "kyra/util.h"
 
+#include "backends/keymapper/keymapper.h"
 #include "common/system.h"
 #include "common/savefile.h"
 #include "graphics/scaler.h"
@@ -2419,6 +2420,11 @@ void GUI_EoB::updateBoxFrameHighLight(int box) {
 }
 
 int GUI_EoB::getTextInput(char *dest, int x, int y, int destMaxLen, int textColor1, int textColor2, int cursorColor) {
+#ifdef ENABLE_KEYMAPPER
+	Common::Keymapper *const keymapper = _vm->getEventManager()->getKeymapper();
+	keymapper->pushKeymap(Common::kGlobalKeymapName);
+#endif
+
 	uint8 cursorState = 1;
 	char sufx[] = " ";
 
@@ -2533,6 +2539,10 @@ int GUI_EoB::getTextInput(char *dest, int x, int y, int destMaxLen, int textColo
 
 	} while (_keyPressed.keycode != Common::KEYCODE_RETURN && _keyPressed.keycode != Common::KEYCODE_ESCAPE && !_vm->shouldQuit());
 
+#ifdef ENABLE_KEYMAPPER
+	keymapper->popKeymap(Common::kGlobalKeymapName);
+#endif
+
 	return _keyPressed.keycode == Common::KEYCODE_ESCAPE ? -1 : len;
 }
 
diff --git a/engines/kyra/gui_lol.cpp b/engines/kyra/gui_lol.cpp
index 80052c7..b025aef 100644
--- a/engines/kyra/gui_lol.cpp
+++ b/engines/kyra/gui_lol.cpp
@@ -35,6 +35,8 @@
 
 #include "graphics/scaler.h"
 
+#include "backends/keymapper/keymapper.h"
+
 #include "base/version.h"
 
 namespace Kyra {
@@ -2549,6 +2551,11 @@ int GUI_LoL::getInput() {
 	if (!_displayMenu)
 		return 0;
 
+#ifdef ENABLE_KEYMAPPER
+	Common::Keymapper *const keymapper = _vm->getEventManager()->getKeymapper();
+	keymapper->pushKeymap(Common::kGlobalKeymapName);
+#endif
+
 	Common::Point p = _vm->getMousePos();
 	_vm->_mouseX = p.x;
 	_vm->_mouseY = p.y;
@@ -2585,6 +2592,11 @@ int GUI_LoL::getInput() {
 		_displayMenu = false;
 
 	_vm->delay(8);
+
+#ifdef ENABLE_KEYMAPPER
+	keymapper->popKeymap(Common::kGlobalKeymapName);
+#endif
+
 	return inputFlag & 0x8000 ? 1 : 0;
 }
 






More information about the Scummvm-git-logs mailing list