[Scummvm-cvs-logs] SF.net SVN: scummvm:[33969] scummvm/branches/gsoc2008-vkeybd/backends

kenny-d at users.sourceforge.net kenny-d at users.sourceforge.net
Sun Aug 17 14:11:35 CEST 2008


Revision: 33969
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33969&view=rev
Author:   kenny-d
Date:     2008-08-17 12:11:34 +0000 (Sun, 17 Aug 2008)

Log Message:
-----------
Various virtual keyboard bug fixes

Modified Paths:
--------------
    scummvm/branches/gsoc2008-vkeybd/backends/events/default/default-events.cpp
    scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.cpp
    scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.h
    scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-parser.cpp
    scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.cpp
    scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.h

Modified: scummvm/branches/gsoc2008-vkeybd/backends/events/default/default-events.cpp
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/events/default/default-events.cpp	2008-08-17 12:01:26 UTC (rev 33968)
+++ scummvm/branches/gsoc2008-vkeybd/backends/events/default/default-events.cpp	2008-08-17 12:11:34 UTC (rev 33969)
@@ -423,11 +423,17 @@
 				if (_vk->isDisplaying()) {
 					_vk->close(true);
 				} else {
-					bool isPaused = (g_engine) ? g_engine->isPaused() : true;
-					if (!isPaused) g_engine->pauseEngine(true);
-					_vk->show();
-					if (!isPaused) g_engine->pauseEngine(false);
-					result = false;
+					static bool enabled = true;
+					if (enabled && _vk->isLoaded() == false) {
+						enabled = _vk->loadKeyboardPack("vkeybd");
+					}
+					if (enabled) {
+						bool isPaused = (g_engine) ? g_engine->isPaused() : true;
+						if (!isPaused) g_engine->pauseEngine(true);
+						_vk->show();
+						if (!isPaused) g_engine->pauseEngine(false);
+						result = false;
+					}
 				}
 			} else if (event.kbd.keycode == Common::KEYCODE_F7 && event.kbd.flags == 0) {
 				if (!_remap) {

Modified: scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.cpp
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.cpp	2008-08-17 12:01:26 UTC (rev 33968)
+++ scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.cpp	2008-08-17 12:11:34 UTC (rev 33969)
@@ -54,8 +54,6 @@
 	_kbdBound.setWidth(_kbdSurface->w);
 	_kbdBound.setHeight(_kbdSurface->h);
 
-	_dispSurface.free();
-	_displayEnabled = false;
 	if (mode->displayArea)
 		setupDisplayArea(*(mode->displayArea), mode->displayFontColor);
 
@@ -66,12 +64,14 @@
 }
 
 void VirtualKeyboardGUI::setupDisplayArea(Rect& r, OverlayColor forecolor) {
-	// choose font
+
 	_dispFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
 	if (!fontIsSuitable(_dispFont, r)) {
 		_dispFont = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
-		if (!fontIsSuitable(_dispFont, r))
+		if (!fontIsSuitable(_dispFont, r)) {
+			_displayEnabled = false;
 			return;
+		}
 	}
 	_dispX = _kbdBound.left + r.left;
 	_dispY = _kbdBound.top + r.top + (r.height() - _dispFont->getFontHeight()) / 2;
@@ -79,7 +79,7 @@
 	_dispForeColor = forecolor;
 	_dispBackColor = _dispForeColor + 0xFF;
 	_dispSurface.create(r.width(), _dispFont->getFontHeight(), sizeof(OverlayColor));
-	_dispSurface.fillRect(r, _dispBackColor);
+	_dispSurface.fillRect(Rect(_dispSurface.w, _dispSurface.h), _dispBackColor);
 	_displayEnabled = true;
 }
 
@@ -88,11 +88,12 @@
 			font->getFontHeight() < rect.height());
 }
 
-void VirtualKeyboardGUI::run() {
+void VirtualKeyboardGUI::checkScreenChanged() {
 	if (_lastScreenChanged != _system->getScreenChangeID())
-		screenChanged();
+		screenChanged(); 
+}
 
-	// TODO: set default position if position is somehow invalid (ie. after screen change)
+void VirtualKeyboardGUI::run() {
 	if (_firstRun) {
 		_firstRun = false;
 		moveToDefaultPosition();
@@ -195,8 +196,11 @@
 
 void VirtualKeyboardGUI::screenChanged() {
 	_lastScreenChanged = _system->getScreenChangeID();
-	if (!_kbd->checkModeResolutions())
+	if (!_kbd->checkModeResolutions()) {
 		_displaying = false;
+		return;
+	}
+	moveToDefaultPosition();
 }
 
 

Modified: scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.h
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.h	2008-08-17 12:01:26 UTC (rev 33968)
+++ scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-gui.h	2008-08-17 12:11:34 UTC (rev 33969)
@@ -42,6 +42,7 @@
 	~VirtualKeyboardGUI();
 	
 	void initMode(VirtualKeyboard::Mode *mode);
+	void checkScreenChanged();
 	void run();
 	void close();
 	bool isDisplaying() { return _displaying; }

Modified: scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-parser.cpp
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-parser.cpp	2008-08-17 12:01:26 UTC (rev 33968)
+++ scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard-parser.cpp	2008-08-17 12:11:34 UTC (rev 33969)
@@ -134,19 +134,17 @@
 
 	if (_parseMode == kParseFull) {
 		// if full parse then add new mode to keyboard
-
 		if (_keyboard->_modes.contains(name))
 			return parserError("Mode '%s' has already been defined", name.c_str());
 
 		VirtualKeyboard::Mode mode;
 		mode.name = name;
 		_keyboard->_modes[name] = mode;
-		_mode = &(_keyboard->_modes[name]);
+	}
 
-		if (name == _initialModeName)
-			_keyboard->_initialMode = _mode;
-	} else
-		_mode = &(_keyboard->_modes[name]);
+	_mode = &(_keyboard->_modes[name]);
+	if (name == _initialModeName)
+		_keyboard->_initialMode = _mode;
 
 	String resolutions = modeNode->values["resolutions"];
 	StringTokenizer tok (resolutions, " ,");
@@ -189,6 +187,8 @@
 			_mode->bitmapName.clear();
 			_mode->image = 0;
 			_mode->imageMap.removeAllAreas();
+			delete _mode->displayArea;
+			_mode->displayArea = 0;
 		}
 	}
 

Modified: scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.cpp
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.cpp	2008-08-17 12:01:26 UTC (rev 33968)
+++ scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.cpp	2008-08-17 12:11:34 UTC (rev 33969)
@@ -27,6 +27,8 @@
 #include "backends/vkeybd/virtual-keyboard-gui.h"
 #include "backends/vkeybd/virtual-keyboard-parser.h"
 #include "backends/vkeybd/keycode-descriptions.h"
+#include "common/config-manager.h"
+#include "common/fs.h"
 #include "graphics/imageman.h"
 
 #define KEY_START_CHAR ('[')
@@ -73,12 +75,25 @@
 }
 
 bool VirtualKeyboard::loadKeyboardPack(Common::String packName) {
-	if (Common::File::exists(packName + ".xml")) {
+	FilesystemNode *vkDir = 0;
+	if (ConfMan.hasKey("vkeybdpath")) {
+		vkDir = new FilesystemNode(ConfMan.get("vkeybdpath"));
+	} else if (ConfMan.hasKey("extrapath")) {
+		vkDir = new FilesystemNode(ConfMan.get("extrapath"));
+	} else { // use current directory
+		vkDir = new FilesystemNode(".");
+	}
+	
+	// TODO - make parser support FilesystemNode's
+	File::addDefaultDirectory(vkDir->getPath());
+
+	if (vkDir->getChild(packName + ".xml").exists()) {
 		// uncompressed keyboard pack
+		
 		if (!_parser->loadFile(packName + ".xml"))
 			return false;
 		
-	} else if (Common::File::exists(packName + ".zip")) {
+	} else if (vkDir->getChild(packName + ".zip").exists()) {
 		// compressed keyboard pack
 #ifdef USE_ZLIB
 		unzFile zipFile = unzOpen((packName + ".zip").c_str());
@@ -123,6 +138,7 @@
 {
 	_parser->setParseMode(kParseCheckResolutions);
 	_loaded = _parser->parse();
+	_kbdGUI->initMode(_currentMode);
 	return _loaded;
 }
 
@@ -197,15 +213,13 @@
 }
 
 void VirtualKeyboard::show() {
+	if (_loaded) _kbdGUI->checkScreenChanged();
 	if (!_loaded) {
-		// if not loaded then load default "vkeybd" pack
-		if (!loadKeyboardPack("vkeybd")) {
-			warning("Keyboard not loaded therefore can't be shown");
-			return;
-		}
+		warning("Virtual keyboard not loaded!");
+		return;
 	}
+
 	switchMode(_initialMode);
-
 	_kbdGUI->run();
 
 	if (_submitKeys) {

Modified: scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.h
===================================================================
--- scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.h	2008-08-17 12:01:26 UTC (rev 33968)
+++ scummvm/branches/gsoc2008-vkeybd/backends/vkeybd/virtual-keyboard.h	2008-08-17 12:11:34 UTC (rev 33969)
@@ -80,7 +80,7 @@
 		OverlayColor		displayFontColor;
 
 		Mode() : image(0), displayArea(0) {}
-		~Mode() { if (displayArea) delete displayArea; }
+		~Mode() { delete displayArea; }
 	};
 	
 	typedef Common::HashMap<Common::String, Mode, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ModeMap;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list