[Scummvm-cvs-logs] CVS: residual lua.cpp,1.163,1.164 engine.cpp,1.98,1.99 engine.h,1.39,1.40
Erich Edgar Hoover
compholio at users.sourceforge.net
Mon Dec 26 11:27:05 CET 2005
Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24252
Modified Files:
lua.cpp engine.cpp engine.h
Log Message:
Menu support for hotkeys and 'text entry' box, savegame support for the name from the text entry
Index: lua.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/lua.cpp,v
retrieving revision 1.163
retrieving revision 1.164
diff -u -d -r1.163 -r1.164
--- lua.cpp 26 Dec 2005 06:46:58 -0000 1.163
+++ lua.cpp 26 Dec 2005 19:26:46 -0000 1.164
@@ -2883,9 +2883,6 @@
if (lua_isnil(table2))
break;
str = lua_getstring(table2);
- // Leave out an apparently bogus option
- if (!strcmp(str, "000000000000000000000000000000000000000000000000000000000000"))
- continue;
int len = strlen(str) + 1;
savedState->writeBlock(&len, sizeof(int));
savedState->writeBlock(str, len);
@@ -2912,12 +2909,6 @@
int strSize;
int count = 0;
- // Get the name of the saved game
- lua_pushobject(result);
- lua_pushnumber(count++);
- lua_pushstring(filename); // TODO: Use an actual stored name
- lua_settable();
-
for (;;) {
if (dataSize <= 0)
break;
@@ -3053,6 +3044,9 @@
if (g_engine->getFlipEnable()) {
g_driver->flipBuffer();
}
+ // refreshDrawMode ensures that the blinking cursor
+ // for the "text entry" renders correctly
+ g_engine->refreshDrawMode();
}
static void EngineDisplay() {
Index: engine.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.cpp,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -d -r1.98 -r1.99
--- engine.cpp 26 Dec 2005 02:36:00 -0000 1.98
+++ engine.cpp 26 Dec 2005 19:26:46 -0000 1.99
@@ -32,6 +32,12 @@
#include <SDL_timer.h>
#include <assert.h>
+// CHAR_KEY tests to see whether a keycode is for
+// a "character" handler or a "button" handler
+#define CHAR_KEY(k) (k >= SDLK_a && k <= SDLK_z) || (k >= SDLK_0 && k <= SDLK_9) || k == SDLK_SPACE
+// numupper provides conversion between number keys and their "upper case"
+const char numupper[] = {')', '!', '@', '#', '$', '%', '^', '&', '*', '('};
+
Engine *g_engine = NULL;
extern Imuse *g_imuse;
@@ -97,21 +103,60 @@
printLineDefaults.justify = 2;
}
-void Engine::handleButton(int operation, int key) {
+void Engine::handleButton(int operation, int key, int keyModifier) {
+ lua_Object handler, system_table, userPaintHandler;
+
// If we're not supposed to handle the key then don't
if (!_controlsEnabled[key])
return;
lua_beginblock();
- lua_Object handler = getEventHandler("buttonHandler");
- if (handler != LUA_NOOBJECT) {
- lua_pushnumber(key);
- if (operation == SDL_KEYDOWN)
- lua_pushnumber(1);
- else
+ system_table = lua_getglobal("system");
+ userPaintHandler = getTableValue(system_table, "userPaintHandler");
+ if (userPaintHandler != LUA_NOOBJECT && CHAR_KEY(key)) {
+ handler = getTableFunction(userPaintHandler, "characterHandler");
+ // Ignore SDL_KEYUP so there are not duplicate keystrokes, but
+ // don't pass on to the normal buttonHandler since it doesn't
+ // recognize character codes
+ if (handler != LUA_NOOBJECT && operation == SDL_KEYDOWN) {
+ char keychar[2];
+
+ lua_beginblock();
+ lua_pushobject(userPaintHandler);
+ if (keyModifier & KMOD_SHIFT)
+ if (isalpha(key))
+ keychar[0] = toupper(key);
+ else
+ keychar[0] = numupper[key - SDLK_0];
+ else
+ keychar[0] = key;
+ keychar[1] = '\0';
+ lua_pushstring(keychar);
lua_pushnil();
- lua_pushnil();
- lua_callfunction(handler);
+ lua_callfunction(handler);
+ lua_endblock();
+ }
+ } else {
+ // Only allow the "Q" safe-exit when in-game, otherwise
+ // it interferes with menu operation
+ if (key == SDLK_q) {
+ lua_beginblock();
+ lua_Object handler = getEventHandler("exitHandler");
+ if (handler != LUA_NOOBJECT)
+ lua_callfunction(handler);
+ lua_endblock();
+ } else {
+ handler = getEventHandler("buttonHandler");
+ if (handler != LUA_NOOBJECT) {
+ lua_pushnumber(key);
+ if (operation == SDL_KEYDOWN)
+ lua_pushnumber(1);
+ else
+ lua_pushnil();
+ lua_pushnil();
+ lua_callfunction(handler);
+ }
+ }
}
lua_endblock();
}
@@ -355,7 +400,7 @@
while (SDL_PollEvent(&event)) {
// Handle any button operations
if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP)
- handleButton(event.type, event.key.keysym.sym);
+ handleButton(event.type, event.key.keysym.sym, event.key.keysym.mod);
// Check for "Hard" quit"
if (event.type == SDL_QUIT)
return;
@@ -371,13 +416,6 @@
(event.key.keysym.mod & KMOD_ALT)) {
g_driver->toggleFullscreenMode();
}
- if (event.key.keysym.sym == SDLK_q) {
- lua_beginblock();
- lua_Object handler = getEventHandler("exitHandler");
- if (handler != LUA_NOOBJECT)
- lua_callfunction(handler);
- lua_endblock();
- }
}
}
Index: engine.h
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- engine.h 26 Dec 2005 02:36:00 -0000 1.39
+++ engine.h 26 Dec 2005 19:26:46 -0000 1.40
@@ -213,7 +213,7 @@
private:
- void handleButton(int operation, int key);
+ void handleButton(int operation, int key, int keyModifier);
Scene *_currScene;
int _mode, _previousMode;
More information about the Scummvm-git-logs
mailing list