aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorAndrew Kurushin2005-06-19 14:06:20 +0000
committerAndrew Kurushin2005-06-19 14:06:20 +0000
commit97337c46238d3e6ebd2a792d03bd6990c5775d03 (patch)
tree2456acf6d42e11f464f18c4871c25762e6a9e081 /saga
parent04eba089f6af536b311c51753700a65d09fc9fb7 (diff)
downloadscummvm-rg350-97337c46238d3e6ebd2a792d03bd6990c5775d03.tar.gz
scummvm-rg350-97337c46238d3e6ebd2a792d03bd6990c5775d03.tar.bz2
scummvm-rg350-97337c46238d3e6ebd2a792d03bd6990c5775d03.zip
implemented sfGetNumber
now use MagicHat (be carefull not to exceed overall scene number) svn-id: r18410
Diffstat (limited to 'saga')
-rw-r--r--saga/actor.cpp4
-rw-r--r--saga/input.cpp2
-rw-r--r--saga/interface.cpp46
-rw-r--r--saga/interface.h20
-rw-r--r--saga/scene.cpp2
-rw-r--r--saga/script.h9
-rw-r--r--saga/sfuncs.cpp21
-rw-r--r--saga/sthread.cpp17
8 files changed, 102 insertions, 19 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp
index 6b029ec47d..12d657e2f2 100644
--- a/saga/actor.cpp
+++ b/saga/actor.cpp
@@ -1184,6 +1184,10 @@ void Actor::direct(int msec) {
return;
}
+ if (_vm->_interface->_statusTextInput) {
+ return;
+ }
+
// FIXME: HACK. This should be turned into cycle event.
_lastTickMsec += msec;
diff --git a/saga/input.cpp b/saga/input.cpp
index 7d2a2664c5..9dd1a566a4 100644
--- a/saga/input.cpp
+++ b/saga/input.cpp
@@ -47,7 +47,7 @@ int SagaEngine::processInput() {
if (event.kbd.keycode == 'd')
_console->attach();
}
- if (_interface->_textInput) {
+ if (_interface->_textInput || _interface->_statusTextInput) {
_interface->processAscii(event.kbd.ascii);
return SUCCESS;
}
diff --git a/saga/interface.cpp b/saga/interface.cpp
index edd2e4ef51..c00b5b2cd1 100644
--- a/saga/interface.cpp
+++ b/saga/interface.cpp
@@ -207,6 +207,8 @@ Interface::Interface(SagaEngine *vm) : _vm(vm), _initialized(false) {
_textInputRepeatPhase = 0;
_textInput = false;
+ _statusTextInput = false;
+ _statusTextInputState = kStatusTextInputFirstRun;
_initialized = true;
}
@@ -315,6 +317,10 @@ void Interface::setMode(int mode) {
bool Interface::processAscii(uint16 ascii) {
int i;
PanelButton *panelButton;
+ if (_statusTextInput) {
+ processStatusTextInput(ascii);
+ return true;
+ }
switch (_panelMode) {
case kPanelNull:
if (ascii == 27) {// Esc
@@ -344,6 +350,7 @@ bool Interface::processAscii(uint16 ascii) {
case kPanelSave:
if (_textInput) {
processTextInput(ascii);
+ return true;
} else {
if (ascii == 27) {// Esc
ascii = 'c'; //cancel
@@ -810,6 +817,41 @@ void Interface::setLoad(PanelButton *panelButton) {
}
}
+void Interface::processStatusTextInput(uint16 ascii) {
+
+ textInputStartRepeat(ascii);
+ switch (ascii) {
+ case(27): // esc
+ _statusTextInputState = kStatusTextInputAborted;
+ _statusTextInput = false;
+ _vm->_script->wakeUpThreads(kWaitTypeStatusTextInput);
+ break;
+ case(13): // return
+ _statusTextInputState = kStatusTextInputEntered;
+ _statusTextInput = false;
+ _vm->_script->wakeUpThreads(kWaitTypeStatusTextInput);
+ break;
+ case(8): // backspace
+ if (_statusTextInputPos == 0) {
+ break;
+ }
+ _statusTextInputPos--;
+ _statusTextInputString[_statusTextInputPos] = 0;
+ default:
+ if (_statusTextInputPos >= STATUS_TEXT_INPUT_MAX) {
+ break;
+ }
+ if (((ascii >= 'a') && (ascii <='z')) ||
+ ((ascii >= '0') && (ascii <='9')) ||
+ ((ascii >= 'A') && (ascii <='Z')) ||
+ (ascii == ' ')) {
+ _statusTextInputString[_statusTextInputPos++] = ascii;
+ _statusTextInputString[_statusTextInputPos] = 0;
+ }
+ }
+ setStatusText(_statusTextInputString);
+}
+
void Interface::processTextInput(uint16 ascii) {
char ch[2];
char tempString[SAVE_TITLE_SIZE];
@@ -1131,6 +1173,10 @@ void Interface::update(const Point& mousePoint, int updateFlag) {
return;
}
+ if (_statusTextInput) {
+ return;
+ }
+
if (_panelMode == kPanelMain) {
if (updateFlag & UPDATE_MOUSEMOVE) {
bool lastWasPlayfield = _lastMousePoint.y < _vm->getSceneHeight();
diff --git a/saga/interface.h b/saga/interface.h
index 3f214d6055..c8b990b147 100644
--- a/saga/interface.h
+++ b/saga/interface.h
@@ -46,6 +46,7 @@ enum InterfaceUpdateFlags {
#define VERB_STRLIMIT 32
#define STATUS_TEXT_LEN 128
+#define STATUS_TEXT_INPUT_MAX 256
// Converse-specific stuff
#define CONVERSE_MAX_TEXTS 64
@@ -174,6 +175,11 @@ enum ITEColors {
kITEColorLightBlue96 = 0x96
};
+enum StatusTextInputState {
+ kStatusTextInputFirstRun,
+ kStatusTextInputEntered,
+ kStatusTextInputAborted
+};
class Interface {
public:
@@ -223,7 +229,16 @@ public:
void processKeyUp(uint16 ascii);
bool _textInput;
-
+
+ bool _statusTextInput;
+ StatusTextInputState _statusTextInputState;
+ char _statusTextInputString[STATUS_TEXT_INPUT_MAX];
+ void enterStatusString() {
+ _statusTextInput = true;
+ _statusTextInputPos = 0;
+ _statusTextInputString[0] = 0;
+ setStatusText(_statusTextInputString);
+ }
private:
static void textInputRepeatCallback(void *refCon);
@@ -314,6 +329,7 @@ private:
void drawVerbPanel(SURFACE *backBuffer, PanelButton* panelButton);
void calcOptionSaveSlider();
void processTextInput(uint16 ascii);
+ void processStatusTextInput(uint16 ascii);
void textInputStartRepeat(uint16 ascii);
void textInputRepeat(void);
@@ -414,6 +430,8 @@ private:
uint _textInputPos;
uint _textInputMaxWidth;
+ uint _statusTextInputPos;
+
int _textInputRepeatPhase;
uint16 _textInputRepeatChar;
};
diff --git a/saga/scene.cpp b/saga/scene.cpp
index 512d959abe..b313623096 100644
--- a/saga/scene.cpp
+++ b/saga/scene.cpp
@@ -423,6 +423,8 @@ void Scene::loadScene(LoadSceneParams *loadSceneParams) {
_resListEntries = loadSceneParams->sceneDescription->resListCnt;
break;
}
+
+ debug(0, "Loading scene number %u:", _sceneNumber);
// Load scene descriptor and resource list resources
if (_loadDescription) {
diff --git a/saga/script.h b/saga/script.h
index 5969664be7..3a3cafe9bd 100644
--- a/saga/script.h
+++ b/saga/script.h
@@ -108,7 +108,8 @@ enum ThreadWaitTypes {
kWaitTypeWalk = 5, // waiting to finish walking
kWaitTypeRequest = 6, // a request is up
kWaitTypePause = 7,
- kWaitTypePlacard = 8
+ kWaitTypePlacard = 8,
+ kWaitTypeStatusTextInput = 9
};
enum OpCodes {
@@ -336,7 +337,7 @@ public:
typedef SortedList<ScriptThread> ScriptThreadList;
-#define SCRIPTFUNC_PARAMS ScriptThread *thread, int nArgs
+#define SCRIPTFUNC_PARAMS ScriptThread *thread, int nArgs, bool &disContinue
class Script {
public:
@@ -428,7 +429,7 @@ public:
public:
ScriptThread *createThread(uint16 scriptModuleNumber, uint16 scriptEntryPointNumber);
int executeThread(ScriptThread *thread, int entrypointNumber);
- int executeThreads(uint msec);
+ void executeThreads(uint msec);
int SThreadDebugStep();
void completeThread(void);
void abortAllThreads(void);
@@ -482,7 +483,7 @@ private:
void sfSetObjImage(SCRIPTFUNC_PARAMS);
void sfSetObjName(SCRIPTFUNC_PARAMS);
void sfGetObjImage(SCRIPTFUNC_PARAMS);
- void SF_getNumber(SCRIPTFUNC_PARAMS);
+ void sfGetNumber(SCRIPTFUNC_PARAMS);
void sfScriptOpenDoor(SCRIPTFUNC_PARAMS);
void sfScriptCloseDoor(SCRIPTFUNC_PARAMS);
void sfSetBgdAnimSpeed(SCRIPTFUNC_PARAMS);
diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp
index 51b8cb9a94..cd09a4fd07 100644
--- a/saga/sfuncs.cpp
+++ b/saga/sfuncs.cpp
@@ -71,7 +71,7 @@ void Script::setupScriptFuncList(void) {
OPCODE(sfSetObjImage),
OPCODE(sfSetObjName),
OPCODE(sfGetObjImage),
- OPCODE(SF_getNumber),
+ OPCODE(sfGetNumber),
OPCODE(sfScriptOpenDoor),
OPCODE(sfScriptCloseDoor),
OPCODE(sfSetBgdAnimSpeed),
@@ -578,11 +578,20 @@ void Script::sfGetObjImage(SCRIPTFUNC_PARAMS) {
}
// Script function #20 (0x14)
-void Script::SF_getNumber(SCRIPTFUNC_PARAMS) {
- for (int i = 0; i < nArgs; i++)
- thread->pop();
-
- error("STUB: SF_getNumber(), %d args", nArgs);
+void Script::sfGetNumber(SCRIPTFUNC_PARAMS) {
+ if (_vm->_interface->_statusTextInputState == kStatusTextInputFirstRun) {
+ _vm->_interface->enterStatusString();
+ thread->wait(kWaitTypeStatusTextInput);
+ disContinue = true;
+ } else {
+ if (_vm->_interface->_statusTextInputState == kStatusTextInputAborted) {
+ thread->_returnValue = -1;
+ } else {
+ thread->_returnValue = atoi(_vm->_interface->_statusTextInputString);
+ }
+
+ _vm->_interface->_statusTextInputState = kStatusTextInputFirstRun;
+ }
}
// Script function #21 (0x15)
diff --git a/saga/sthread.cpp b/saga/sthread.cpp
index 24815040d5..fc221d7a29 100644
--- a/saga/sthread.cpp
+++ b/saga/sthread.cpp
@@ -99,12 +99,13 @@ void Script::wakeUpThreadsDelayed(int waitType, int sleepTime) {
}
}
-int Script::executeThreads(uint msec) {
+void Script::executeThreads(uint msec) {
ScriptThread *thread;
ScriptThreadList::iterator threadIterator;
- if (!isInitialized()) {
- return FAILURE;
+
+ if (_vm->_interface->_statusTextInput) {
+ return;
}
threadIterator = _threadList.begin();
@@ -151,7 +152,6 @@ int Script::executeThreads(uint msec) {
++threadIterator;
}
- return SUCCESS;
}
void Script::abortAllThreads(void) {
@@ -192,6 +192,7 @@ bool Script::runThread(ScriptThread *thread, uint instructionLimit) {
int16 iparam2;
int16 iparam3;
+ bool disContinue;
byte argumentsCount;
uint16 functionNumber;
uint16 checkStackTopIndex;
@@ -344,9 +345,11 @@ bool Script::runThread(ScriptThread *thread, uint instructionLimit) {
debug(8, "Calling 0x%X %s argCount=%i", functionNumber, _scriptFunctionsList[functionNumber].scriptFunctionName, argumentsCount);
scriptFunction = _scriptFunctionsList[functionNumber].scriptFunction;
checkStackTopIndex = thread->_stackTopIndex + argumentsCount;
-
- (this->*scriptFunction)(thread, argumentsCount);
-
+ disContinue = false;
+ (this->*scriptFunction)(thread, argumentsCount, disContinue);
+ if (disContinue) {
+ return true;
+ }
if (scriptFunction == &Saga::Script::sfScriptGotoScene) {
return true; // cause abortAllThreads called and _this_ thread destroyed
}