From dab894fdd49eef7a34f9f9f1c17c7c22741a1add Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 17 Jan 2005 20:17:06 +0000 Subject: First batch of converse implementation in scripts. To see it type 'scene_change 33' in debugger. svn-id: r16588 --- saga/interface.cpp | 30 ++++++++++++++++++++++++++++-- saga/interface.h | 2 +- saga/saga.cpp | 2 ++ saga/script.cpp | 1 + saga/script.h | 30 +++++++++++++++++++++--------- saga/sthread.cpp | 42 +++++++++++++++++++++++++++--------------- 6 files changed, 80 insertions(+), 27 deletions(-) (limited to 'saga') diff --git a/saga/interface.cpp b/saga/interface.cpp index 8012b2d9f3..30b4f751a1 100644 --- a/saga/interface.cpp +++ b/saga/interface.cpp @@ -252,6 +252,29 @@ bool Interface::processKeyCode(int keyCode) { } } break; + case kPanelConverse: + switch (keyCode) { + case 'x': + setMode(kPanelInventory); + // FIXME: puzzle + break; + + case 'u': + converseChangePos(-1); + break; + + case 'd': + converseChangePos(1); + break; + + case '1': + case '2': + case '3': + case '4': + converseSetPos(keyCode); + break; + + } } return false; } @@ -324,6 +347,7 @@ int Interface::draw() { bufToSurface(backBuffer, _conversePanel.image, _conversePanel.imageWidth, _conversePanel.imageHeight, NULL, &origin); + converseDisplayText(0); } if (_panelMode == kPanelMain || _panelMode == kPanelConverse || @@ -904,9 +928,9 @@ void Interface::converseChangePos(int chg) { } } -void Interface::converseSetPos(void) { +void Interface::converseSetPos(int key) { Converse *ct; - int selection = 1; // = keyStroke - '1'; // FIXME + int selection = key - '1'; if (selection >= _converseTextCount) return; @@ -915,6 +939,8 @@ void Interface::converseSetPos(void) { converseSetTextLines(selection, kColorBrightWhite, false); ct = &_converseText[_conversePos]; + + //finishDialog( ct->replyID, ct->replyFlags, ct->replyBit ); // FIXME: TODO: finish dialog thread // FIXME: TODO: Puzzle diff --git a/saga/interface.h b/saga/interface.h index fa0558e134..5ff4c31e1d 100644 --- a/saga/interface.h +++ b/saga/interface.h @@ -137,7 +137,7 @@ public: void converseDisplayText(int pos); void converseSetTextLines(int row, int textcolor, bool btnDown); void converseChangePos(int chg); - void converseSetPos(void); + void converseSetPos(int key); private: void converseDisplayTextLine(int textcolor, bool btnUp, bool rebuild); diff --git a/saga/saga.cpp b/saga/saga.cpp index 1d934a2752..f0bd952de3 100644 --- a/saga/saga.cpp +++ b/saga/saga.cpp @@ -262,6 +262,8 @@ int SagaEngine::init(GameDetector &detector) { debug(0, "Sound disabled."); } + _interface->converseClear(); + return 0; } diff --git a/saga/script.cpp b/saga/script.cpp index 8310049b35..81f7410e8a 100644 --- a/saga/script.cpp +++ b/saga/script.cpp @@ -62,6 +62,7 @@ Script::Script() { _currentScript = 0; _abortEnabled = true; _skipSpeeches = false; + _conversingThread = NULL; _firstObjectSet = false; _secondObjectNeeded = false; diff --git a/saga/script.h b/saga/script.h index 3f195f6df7..b1389cfe18 100644 --- a/saga/script.h +++ b/saga/script.h @@ -110,21 +110,30 @@ enum OpCodes { opReturn = 0x1B, opReturnV = 0x1C, //... - opSpeak = 0x53 + opSpeak = 0x53, + opDialogBegin = 0x54, + opDialogEnd = 0x55, + opReply = 0x56 }; enum CycleFlags { - kCyclePong = (1 << 0), - kCycleOnce = (1 << 1), - kCycleRandom = (1 << 2), - kCycleReverse = (1 << 3) + kCyclePong = 1 << 0, + kCycleOnce = 1 << 1, + kCycleRandom = 1 << 2, + kCycleReverse = 1 << 3 }; enum WalkFlags { - kWalkBackPedal = (1<<0), - kWalkAsync = (1<<1), - kWalkUseAngle = (1<<2), - kWalkFace = (1<<5) + kWalkBackPedal = 1 << 0, + kWalkAsync = 1 << 1, + kWalkUseAngle = 1 << 2, + kWalkFace = 1 << 5 +}; + +enum ReplyFlags { + kReplyOnce = 1 << 0, + kReplySummary = 1 << 1, + kReplyCondition = 1 << 2 }; struct ScriptThread { @@ -332,6 +341,9 @@ private: void runThread(ScriptThread *thread, int instr_limit); void setThreadEntrypoint(ScriptThread *thread, int entrypointNumber); +private: + ScriptThread *_conversingThread; + private: typedef int (Script::*ScriptFunctionType)(SCRIPTFUNC_PARAMS); diff --git a/saga/sthread.cpp b/saga/sthread.cpp index 1222e19439..cdd679ab3e 100644 --- a/saga/sthread.cpp +++ b/saga/sthread.cpp @@ -771,28 +771,40 @@ void Script::runThread(ScriptThread *thread, int instr_limit) { } } break; - // (DLGS): Initialize dialogue interface - case 0x54: - warning("dialog_begin opcode: stub"); + + case opDialogBegin: // (DLGS): Initialize dialogue interface + if (_conversingThread) { + thread->wait(kWaitTypeDialogBegin); + return; + } + _conversingThread = thread; + _vm->_interface->converseClear(); break; - // (DLGX): Run dialogue interface - case 0x55: - if (0) { + + case opDialogEnd: // (DLGX): Run dialogue interface + if (thread == _conversingThread) { _vm->_interface->activate(); _vm->_interface->setMode(kPanelConverse); + thread->wait(kWaitTypeDialogEnd); + return; } - warning("dialog_end opcode: stub"); break; - // (DLGO): Add a dialogue option to interface - case 0x56: + + case opReply: // (DLGO): Add a dialogue option to interface { - ScriptDataWord param3 = 0; - param1 = scriptS.readByte(); - param2 = scriptS.readByte(); - if (param2 & 1) { - param3 = scriptS.readUint16LE(); + ScriptDataWord n = 0; + const char *str; + int replyNum = scriptS.readByte(); + int flags = scriptS.readByte(); + + if (flags & kReplyOnce) { + n = scriptS.readUint16LE(); + // TODO: } - debug(2, "DLGO | %02X %02X %04X", param1, param2, param3); + + str = getScriptString(thread->pop()); + if (_vm->_interface->converseAddText(str, replyNum, flags, n)) + warning("Error adding ConverseText (%s, %d, %d, %d)", str, replyNum, flags, n); } break; case 0x57: // animate -- cgit v1.2.3