[Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.143,1.144 input.cpp,1.46,1.47 interface.cpp,1.105,1.106 interface.h,1.58,1.59 scene.cpp,1.110,1.111 script.h,1.87,1.88 sfuncs.cpp,1.126,1.127 sthread.cpp,1.84,1.85

Andrew Kurushin h00ligan at users.sourceforge.net
Sun Jun 19 07:06:57 CEST 2005


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20585

Modified Files:
	actor.cpp input.cpp interface.cpp interface.h scene.cpp 
	script.h sfuncs.cpp sthread.cpp 
Log Message:
implemented sfGetNumber
now use MagicHat (be carefull not to exceed overall scene number)

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -d -r1.143 -r1.144
--- actor.cpp	15 Jun 2005 19:26:30 -0000	1.143
+++ actor.cpp	19 Jun 2005 14:06:19 -0000	1.144
@@ -1184,6 +1184,10 @@
 		return;
 	}
 
+	if (_vm->_interface->_statusTextInput) {
+		return;
+	}
+
 	// FIXME: HACK. This should be turned into cycle event.
 	_lastTickMsec += msec;
 

Index: input.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/input.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- input.cpp	31 May 2005 23:41:27 -0000	1.46
+++ input.cpp	19 Jun 2005 14:06:19 -0000	1.47
@@ -47,7 +47,7 @@
 				if (event.kbd.keycode == 'd')
 					_console->attach();
 			}
-			if (_interface->_textInput) {
+			if (_interface->_textInput || _interface->_statusTextInput) {
 				_interface->processAscii(event.kbd.ascii);
 				return SUCCESS;
 			}

Index: interface.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.cpp,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -d -r1.105 -r1.106
--- interface.cpp	10 Jun 2005 13:49:43 -0000	1.105
+++ interface.cpp	19 Jun 2005 14:06:19 -0000	1.106
@@ -207,6 +207,8 @@
 
 	_textInputRepeatPhase = 0;
 	_textInput = false;
+	_statusTextInput = false;
+	_statusTextInputState = kStatusTextInputFirstRun;
 
 	_initialized = true;
 }
@@ -315,6 +317,10 @@
 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 @@
 	case kPanelSave:
 		if (_textInput) {
 			processTextInput(ascii);
+			return true;
 		} else {
 			if (ascii == 27) {// Esc
 				ascii = 'c'; //cancel
@@ -810,6 +817,41 @@
 	}
 }
 
+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 @@
 		return;
 	}
 
+	if (_statusTextInput) {
+		return;
+	}
+
 	if (_panelMode == kPanelMain) {
 		if (updateFlag & UPDATE_MOUSEMOVE) {
 			bool lastWasPlayfield = _lastMousePoint.y < _vm->getSceneHeight();

Index: interface.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.h,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- interface.h	4 Jun 2005 15:50:23 -0000	1.58
+++ interface.h	19 Jun 2005 14:06:19 -0000	1.59
@@ -46,6 +46,7 @@
 #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 @@
 	kITEColorLightBlue96 = 0x96
 };
 
+enum StatusTextInputState {
+	kStatusTextInputFirstRun,
+	kStatusTextInputEntered,
+	kStatusTextInputAborted
+};
 
 class Interface {
 public:
@@ -223,7 +229,16 @@
 	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 @@
 	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 @@
 	uint _textInputPos;
 	uint _textInputMaxWidth;
 
+	uint _statusTextInputPos;
+
 	int _textInputRepeatPhase;
 	uint16 _textInputRepeatChar;
 };

Index: scene.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/scene.cpp,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- scene.cpp	16 Jun 2005 16:46:50 -0000	1.110
+++ scene.cpp	19 Jun 2005 14:06:19 -0000	1.111
@@ -423,6 +423,8 @@
 		_resListEntries = loadSceneParams->sceneDescription->resListCnt;
 		break;
 	}
+	
+	debug(0, "Loading scene number %u:", _sceneNumber);
 
 	// Load scene descriptor and resource list resources
 	if (_loadDescription) {

Index: script.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/script.h,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- script.h	15 Jun 2005 19:26:32 -0000	1.87
+++ script.h	19 Jun 2005 14:06:20 -0000	1.88
@@ -108,7 +108,8 @@
 	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 @@
 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:
 	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 @@
 	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);

Index: sfuncs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sfuncs.cpp,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -d -r1.126 -r1.127
--- sfuncs.cpp	16 Jun 2005 15:33:44 -0000	1.126
+++ sfuncs.cpp	19 Jun 2005 14:06:20 -0000	1.127
@@ -71,7 +71,7 @@
 		OPCODE(sfSetObjImage),
 		OPCODE(sfSetObjName),
 		OPCODE(sfGetObjImage),
-		OPCODE(SF_getNumber),
+		OPCODE(sfGetNumber),
 		OPCODE(sfScriptOpenDoor),
 		OPCODE(sfScriptCloseDoor),
 		OPCODE(sfSetBgdAnimSpeed),
@@ -578,11 +578,20 @@
 }
 
 // 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)

Index: sthread.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sthread.cpp,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- sthread.cpp	15 Jun 2005 20:07:56 -0000	1.84
+++ sthread.cpp	19 Jun 2005 14:06:20 -0000	1.85
@@ -99,12 +99,13 @@
 	}
 }
 
-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 @@
 		++threadIterator;
 	}
 
-	return SUCCESS;
 }
 
 void Script::abortAllThreads(void) {
@@ -192,6 +192,7 @@
 	int16 iparam2;
 	int16 iparam3;
 
+	bool disContinue;
 	byte argumentsCount;
 	uint16 functionNumber;
 	uint16 checkStackTopIndex;
@@ -344,9 +345,11 @@
 			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
 			}





More information about the Scummvm-git-logs mailing list