From 8162483026ec52476a1106e72259c84e5476fd2d Mon Sep 17 00:00:00 2001 From: Borja Lorente Date: Thu, 14 Jul 2016 00:18:08 +0200 Subject: MACVENTURE: Add text input logic --- engines/macventure/gui.cpp | 5 +---- engines/macventure/macventure.cpp | 12 +++++++++++- engines/macventure/macventure.h | 25 ++++--------------------- engines/macventure/script.cpp | 6 +++++- engines/macventure/script.h | 21 ++++++++++----------- engines/macventure/world.cpp | 5 ++++- 6 files changed, 35 insertions(+), 39 deletions(-) (limited to 'engines/macventure') diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp index 91df455318..02f603659e 100644 --- a/engines/macventure/gui.cpp +++ b/engines/macventure/gui.cpp @@ -460,7 +460,7 @@ bool Gui::loadWindows() { data.title = Common::String(newTitle); } - debug(4, "Window loaded: %s", data.title); + debug(4, "Window loaded: %s", data.title.c_str()); _windowData->push_back(data); } @@ -1163,7 +1163,6 @@ bool Gui::processCommandEvents(WindowClick click, Common::Event &event) { } } - _engine->selectControl(data.getData().refcon); _engine->activateCommand(data.getData().refcon); _engine->refreshReady(); @@ -1178,7 +1177,6 @@ bool MacVenture::Gui::processMainGameEvents(WindowClick click, Common::Event & e if (click == kBorderInner && event.type == Common::EVENT_LBUTTONDOWN) { WindowData &data = findWindowData(kMainGameWindow); - ObjID child = 0; Common::Point pos; // Click rect to local coordinates. We assume the click is inside the window ^ Common::Rect clickRect = calculateClickRect(event.mouse, _mainGameWindow->getDimensions()); @@ -1254,7 +1252,6 @@ bool Gui::processInventoryEvents(WindowClick click, Common::Event & event) { if (ref == kNoWindow) return false; Graphics::MacWindow *win = findWindow(ref); WindowData &data = findWindowData((WindowReference) ref); - ObjID child; Common::Point pos; // Click rect to local coordinates. We assume the click is inside the window ^ Common::Rect clickRect = calculateClickRect(event.mouse, win->getDimensions()); diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp index 211ba43971..b6db45c93a 100644 --- a/engines/macventure/macventure.cpp +++ b/engines/macventure/macventure.cpp @@ -370,11 +370,17 @@ void MacVentureEngine::updateWindow(WindowReference winID) { _gui->updateWindow(winID, true); } +bool MacVentureEngine::showTextEntry(ObjID text, ObjID srcObj, ObjID destObj) { + debug("Showing speech dialog, asset %d from %d to %d", text, srcObj, destObj); + _userInput = Common::String("epor"); + warning("Show text entry: not fully implemented"); + return true; +} + const GlobalSettings& MacVentureEngine::getGlobalSettings() const { return _globalSettings; } - // Private engine methods void MacVentureEngine::processEvents() { Common::Event event; @@ -585,6 +591,10 @@ Common::String MacVentureEngine::getNoun(ObjID ndx) { return _decodingIndirectArticles->getString(ndx); } +Common::String MacVentureEngine::getUserInput() { + return _userInput; +} + void MacVentureEngine::highlightExit(ObjID objID) { //ObjID ctl = _gui->getWinChild(obj); /*if (ctl) { diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h index 735dda51cc..71c3cbea8b 100644 --- a/engines/macventure/macventure.h +++ b/engines/macventure/macventure.h @@ -71,27 +71,6 @@ enum { kClickToContinueTextID = 0x84, kStartGameFilenameID = 0x85 }; -/* -enum ControlAction { - kNoCommand = 0, - kStartOrResume = 1, - kClose = 2, - kTick = 3, - kActivateObject = 4, - kMoveObject = 5, - kConsume = 6, - kExamine = 7, - kGo = 8, - kHit = 9, - kOpen = 10, - kOperate = 11, - kSpeak = 12, - kBabble = 13, - kTargetName = 14, - kDebugObject = 15, - kClickToContinue = 16 -}; -*/ enum FilePathID { kMCVID = 1, @@ -206,6 +185,8 @@ public: void focusObjWin(ObjID objID); void updateWindow(WindowReference winID); + bool showTextEntry(ObjID text, ObjID srcObj, ObjID destObj); + // Data retrieval bool isPaused(); bool needsClickToContinue(); @@ -220,6 +201,7 @@ public: uint getPrefixNdx(ObjID obj); Common::String getPrefixString(uint flag, ObjID obj); Common::String getNoun(ObjID ndx); + Common::String getUserInput(); // Attributes consult Common::Point getObjPosition(ObjID objID); @@ -317,6 +299,7 @@ private: // Attributes Common::Array _currentSelection; Common::Array _selectedObjs; Common::Point _deltaPoint; + Common::String _userInput; }; diff --git a/engines/macventure/script.cpp b/engines/macventure/script.cpp index 5b86c31e84..794bbdde60 100644 --- a/engines/macventure/script.cpp +++ b/engines/macventure/script.cpp @@ -1073,7 +1073,11 @@ void ScriptEngine::opd4RELC(EngineState * state, EngineFrame * frame) { void ScriptEngine::opd5DLOG(EngineState * state, EngineFrame * frame) { word txt = state->pop(); - op00NOOP(0xd5); + if (_engine->showTextEntry(txt, frame->src, frame->dest)) { + state->push(0xFFFF); + } else { + state->push(0x0000); + } } void ScriptEngine::opd6ACMD(EngineState * state, EngineFrame * frame) { diff --git a/engines/macventure/script.h b/engines/macventure/script.h index 8aee88fd66..49b69874e6 100644 --- a/engines/macventure/script.h +++ b/engines/macventure/script.h @@ -27,21 +27,20 @@ #include "macventure/world.h" namespace MacVenture { - + class Container; class World; - typedef uint32 ObjID; typedef int16 word; class ScriptAsset { public: - ScriptAsset(ObjID id, Container *container); + ScriptAsset(ObjID id, Container *container); ~ScriptAsset() {} void reset(); - uint8 fetch(); + uint8 fetch(); bool hasNext(); void branch(word amount); @@ -66,7 +65,7 @@ public: } void push(word data) { - sp--; + sp--; stack[sp] = unneg16(data); } @@ -97,7 +96,7 @@ public: private: word unneg16(word data) { - if (data < 0) + if (data < 0) data = ((-data) ^ 0xFFFF) + 1; return data; @@ -141,17 +140,17 @@ public: ~ScriptEngine(); public: - bool runControl(ControlAction action, ObjID source, ObjID destination, Common::Point delta); - bool resume(bool execAll); + bool runControl(ControlAction action, ObjID source, ObjID destination, Common::Point delta); + bool resume(bool execAll); void reset(); private: bool execFrame(bool execAll); bool loadScript(EngineFrame * frame, uint32 scriptID); - bool resumeFunc(EngineFrame * frame); + bool resumeFunc(EngineFrame * frame); bool runFunc(EngineFrame * frame); -private: +private: // Aux word neg16(word val); @@ -208,7 +207,7 @@ private: void opacEQ(EngineState *state, EngineFrame *frame); //eq? void opadEQS(EngineState *state, EngineFrame *frame); //eq string? void opaeCONT(EngineState *state, EngineFrame *frame); //contains - void opafCONTW(EngineState *state, EngineFrame *frame); //contains word + void opafCONTW(EngineState *state, EngineFrame *frame); //contains word void opb0BRA(EngineState *state, EngineFrame *frame, ScriptAsset *script); //bra void opb1BRAB(EngineState *state, EngineFrame *frame, ScriptAsset *script); //bra.b diff --git a/engines/macventure/world.cpp b/engines/macventure/world.cpp index ec20ba6b20..e247404eb6 100644 --- a/engines/macventure/world.cpp +++ b/engines/macventure/world.cpp @@ -156,6 +156,9 @@ void World::releaseChildren(ObjID objID) { } Common::String World::getText(ObjID objID, ObjID source, ObjID target) { + if (objID & 0x8000){ + return _engine->getUserInput(); + } TextAsset text = TextAsset(_engine, objID, source, target, _gameText, _engine->isOldText(), _engine->getDecodingHuffman()); return *text.decode(); @@ -169,7 +172,7 @@ bool World::isObjDraggable(ObjID objID) { } bool World::intersects(ObjID objID, Common::Rect rect) { - return _engine->getObjBounds(objID).intersects(rect); + return _engine->getObjBounds(objID).intersects(rect); } bool World::loadStartGameFileName() { -- cgit v1.2.3