Some basic work on the vkeybd code

svn-id: r35931
This commit is contained in:
Max Horn 2009-01-20 00:03:35 +00:00
parent 57d118e930
commit a27e456ace
5 changed files with 34 additions and 22 deletions

View file

@ -36,7 +36,12 @@ MODULE_OBJS := \
saves/compressed/compressed-saves.o \ saves/compressed/compressed-saves.o \
saves/posix/posix-saves.o \ saves/posix/posix-saves.o \
saves/psp/psp-saves.o \ saves/psp/psp-saves.o \
timer/default/default-timer.o timer/default/default-timer.o \
vkeybd/image-map.o \
vkeybd/polygon.o \
vkeybd/virtual-keyboard.o \
vkeybd/virtual-keyboard-gui.o \
vkeybd/virtual-keyboard-parser.o
# Include common rules # Include common rules
include $(srcdir)/rules.mk include $(srcdir)/rules.mk

View file

@ -28,7 +28,7 @@
#ifdef ENABLE_VKEYBD #ifdef ENABLE_VKEYBD
#include "graphics/cursorman.h" #include "graphics/cursorman.h"
#include "gui/newgui.h" #include "gui/GuiManager.h"
namespace Common { namespace Common {

View file

@ -28,8 +28,8 @@
#ifdef ENABLE_VKEYBD #ifdef ENABLE_VKEYBD
#include "common/keyboard.h" #include "common/keyboard.h"
#include "graphics/imageman.h"
#include "common/util.h" #include "common/util.h"
#include "common/system.h"
namespace Common { namespace Common {
@ -261,21 +261,26 @@ bool VirtualKeyboardParser::parserCallback_layout(ParserNode *node) {
return parserError("Error loading bitmap '%s'", _mode->bitmapName.c_str()); return parserError("Error loading bitmap '%s'", _mode->bitmapName.c_str());
} }
if (node->values.contains("transparent_color")) { const Graphics::PixelFormat format = g_system->getOverlayFormat();
int r, g, b; int r, g, b;
if (node->values.contains("transparent_color")) {
if (!parseIntegerKey(node->values["transparent_color"].c_str(), 3, &r, &g, &b)) if (!parseIntegerKey(node->values["transparent_color"].c_str(), 3, &r, &g, &b))
return parserError("Could not parse color value"); return parserError("Could not parse color value");
_mode->transparentColor = g_system->RGBToColor(r, g, b); } else {
} else // default to purple // default to purple
_mode->transparentColor = g_system->RGBToColor(255, 0, 255); r = 255;
g = 0;
b = 255;
}
_mode->transparentColor = Graphics::RGBToColor(r, g, b, format);
if (node->values.contains("display_font_color")) { if (node->values.contains("display_font_color")) {
int r, g, b;
if (!parseIntegerKey(node->values["display_font_color"].c_str(), 3, &r, &g, &b)) if (!parseIntegerKey(node->values["display_font_color"].c_str(), 3, &r, &g, &b))
return parserError("Could not parse color value"); return parserError("Could not parse color value");
_mode->displayFontColor = g_system->RGBToColor(r, g, b); } else {
} else r = g = b = 0; // default to black
_mode->displayFontColor = g_system->RGBToColor(0, 0, 0); // default to black }
_mode->displayFontColor = Graphics::RGBToColor(r, g, b, format);
_layoutParsed = true; _layoutParsed = true;

View file

@ -32,7 +32,6 @@
#include "backends/vkeybd/keycode-descriptions.h" #include "backends/vkeybd/keycode-descriptions.h"
#include "common/config-manager.h" #include "common/config-manager.h"
#include "common/fs.h" #include "common/fs.h"
#include "graphics/imageman.h"
#include "common/unzip.h" #include "common/unzip.h"
#define KEY_START_CHAR ('[') #define KEY_START_CHAR ('[')
@ -81,25 +80,25 @@ bool VirtualKeyboard::loadKeyboardPack(String packName) {
_kbdGUI->initSize(_system->getOverlayWidth(), _system->getOverlayHeight()); _kbdGUI->initSize(_system->getOverlayWidth(), _system->getOverlayHeight());
FilesystemNode *vkDir = 0; FSNode vkDir;
if (ConfMan.hasKey("vkeybdpath")) { if (ConfMan.hasKey("vkeybdpath")) {
vkDir = new FilesystemNode(ConfMan.get("vkeybdpath")); vkDir = FSNode(ConfMan.get("vkeybdpath"));
} else if (ConfMan.hasKey("extrapath")) { } else if (ConfMan.hasKey("extrapath")) {
vkDir = new FilesystemNode(ConfMan.get("extrapath")); vkDir = FSNode(ConfMan.get("extrapath"));
} else { // use current directory } else { // use current directory
vkDir = new FilesystemNode("."); vkDir = FSNode(".");
} }
if (vkDir->getChild(packName + ".xml").exists()) { if (vkDir.getChild(packName + ".xml").exists()) {
// uncompressed keyboard pack // uncompressed keyboard pack
if (!_parser->loadFile(vkDir->getChild(packName + ".xml"))) if (!_parser->loadFile(vkDir.getChild(packName + ".xml")))
return false; return false;
} else if (vkDir->getChild(packName + ".zip").exists()) { } else if (vkDir.getChild(packName + ".zip").exists()) {
// compressed keyboard pack // compressed keyboard pack
#ifdef USE_ZLIB #ifdef USE_ZLIB
ZipArchive arch(vkDir->getChild(packName + ".zip").getPath().c_str()); ZipArchive arch(vkDir.getChild(packName + ".zip").getPath().c_str());
if (arch.hasFile(packName + ".xml")) { if (arch.hasFile(packName + ".xml")) {
if (!_parser->loadStream(arch.openFile(packName + ".xml"))) if (!_parser->loadStream(arch.openFile(packName + ".xml")))
return false; return false;
@ -107,7 +106,7 @@ bool VirtualKeyboard::loadKeyboardPack(String packName) {
warning("Could not find %s.xml file in %s.zip keyboard pack", packName.c_str(), packName.c_str()); warning("Could not find %s.xml file in %s.zip keyboard pack", packName.c_str(), packName.c_str());
return false; return false;
} }
ImageMan.addArchive(vkDir->getChild(packName + ".zip").getPath().c_str()); ImageMan.addArchive(vkDir.getChild(packName + ".zip").getPath().c_str());
#else #else
return false; return false;
#endif #endif

View file

@ -35,11 +35,14 @@ class OSystem;
#include "common/events.h" #include "common/events.h"
#include "common/hashmap.h" #include "common/hashmap.h"
#include "common/hash-str.h" #include "common/hash-str.h"
#include "backends/vkeybd/image-map.h"
#include "common/keyboard.h" #include "common/keyboard.h"
#include "common/list.h" #include "common/list.h"
#include "common/str.h" #include "common/str.h"
#include "backends/vkeybd/image-map.h"
#include "graphics/surface.h"
namespace Common { namespace Common {
class VirtualKeyboardGUI; class VirtualKeyboardGUI;