implemented sfGetNumber
now use MagicHat (be carefull not to exceed overall scene number) svn-id: r18410
This commit is contained in:
parent
04eba089f6
commit
97337c4623
8 changed files with 102 additions and 19 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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:
|
||||
|
@ -224,6 +230,15 @@ public:
|
|||
|
||||
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;
|
||||
};
|
||||
|
|
|
@ -424,6 +424,8 @@ void Scene::loadScene(LoadSceneParams *loadSceneParams) {
|
|||
break;
|
||||
}
|
||||
|
||||
debug(0, "Loading scene number %u:", _sceneNumber);
|
||||
|
||||
// Load scene descriptor and resource list resources
|
||||
if (_loadDescription) {
|
||||
debug(0, "Loading scene resource %u:", _sceneResourceId);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
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);
|
||||
}
|
||||
|
||||
error("STUB: SF_getNumber(), %d args", nArgs);
|
||||
_vm->_interface->_statusTextInputState = kStatusTextInputFirstRun;
|
||||
}
|
||||
}
|
||||
|
||||
// Script function #21 (0x15)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue