aboutsummaryrefslogtreecommitdiff
path: root/engines/macventure
diff options
context:
space:
mode:
authorBorja Lorente2016-06-23 00:24:39 +0200
committerBorja Lorente2016-08-14 18:34:53 +0200
commitec7eb7cb5bec5174f7fd3446824280ab44050f5e (patch)
treecc4452b57ae0809eef9b04ecef83958161b59ed7 /engines/macventure
parent0fb344dfeda53e81a70e89be45bda6d5c0614e7e (diff)
downloadscummvm-rg350-ec7eb7cb5bec5174f7fd3446824280ab44050f5e.tar.gz
scummvm-rg350-ec7eb7cb5bec5174f7fd3446824280ab44050f5e.tar.bz2
scummvm-rg350-ec7eb7cb5bec5174f7fd3446824280ab44050f5e.zip
MACVENTURE: Game window object selection and some more opcodes
Diffstat (limited to 'engines/macventure')
-rw-r--r--engines/macventure/gui.cpp36
-rw-r--r--engines/macventure/image.cpp14
-rw-r--r--engines/macventure/image.h2
-rw-r--r--engines/macventure/macventure.cpp42
-rw-r--r--engines/macventure/macventure.h4
-rw-r--r--engines/macventure/script.cpp21
6 files changed, 81 insertions, 38 deletions
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index 1ac1d0b0f8..f1eb8b63e6 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -104,7 +104,6 @@ void Gui::draw() {
_wm.setFullRefresh(true);
drawWindows();
- drawTitle();
_wm.draw();
}
@@ -121,14 +120,6 @@ void Gui::drawExit(ObjID id) {
warning("Unimplemented method: drawExit");
}
-bool Gui::processEvent(Common::Event &event) {
- bool processed = false;
- if (event.type == Common::EVENT_LBUTTONDOWN) {
- debug("Click on the ui");
- }
- return (processed || _wm.processEvent(event));
-}
-
const WindowData& Gui::getWindowData(WindowReference reference) {
return findWindowData(reference);
}
@@ -736,6 +727,13 @@ bool Gui::tryCloseWindow(WindowReference winID) {
return true;
}
+bool Gui::processEvent(Common::Event &event) {
+ bool processed = false;
+ if (event.type == Common::EVENT_LBUTTONDOWN) {
+ debug("Click on the ui");
+ }
+ return (processed || _wm.processEvent(event));
+}
bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
if (event.type == Common::EVENT_LBUTTONUP) {
@@ -764,7 +762,25 @@ bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
}
bool MacVenture::Gui::processMainGameEvents(WindowClick click, Common::Event & event) {
- return getWindowData(kMainGameWindow).visible;
+ if (click == kBorderInner && event.type == Common::EVENT_LBUTTONUP) {
+ WindowData &data = findWindowData(kMainGameWindow);
+ ObjID child;
+ BlitMode mode;
+ Common::Point pos;
+ for (Common::Array<DrawableObject>::const_iterator it = data.children.begin(); it != data.children.end(); it++) {
+ child = (*it).obj;
+ mode = (BlitMode)(*it).mode;
+ pos = _engine->getObjPosition(child);
+ pos.x += data.bounds.left;
+ pos.y += data.bounds.top;
+ if (_assets[child]->isPointInside(pos, event.mouse)) {
+ // select the first object clicked
+ _engine->selectObject(child);
+ return true;
+ }
+ }
+ }
+ return false;
}
bool MacVenture::Gui::processOutConsoleEvents(WindowClick click, Common::Event & event) {
return getWindowData(kOutConsoleWindow).visible;
diff --git a/engines/macventure/image.cpp b/engines/macventure/image.cpp
index 60f491cf55..de4e3ba12e 100644
--- a/engines/macventure/image.cpp
+++ b/engines/macventure/image.cpp
@@ -65,10 +65,6 @@ ImageAsset::ImageAsset(ObjID original, Container * container) {
_mask = (original * 2) + 1;
_container = container;
-
- //_imgData = nullptr;
- //_maskData = nullptr;
-
decodePPIC(_id, _imgData);
if (_container->getItemByteSize(_mask)) // Has mask
@@ -76,11 +72,6 @@ ImageAsset::ImageAsset(ObjID original, Container * container) {
}
ImageAsset::~ImageAsset() {
- //if (_imgData)
- // delete[] _imgData;
-
- //if (_maskData)
- // delete[] _maskData;
}
void ImageAsset::decodePPIC(ObjID id, Common::Array<byte> &data) {
@@ -348,6 +339,11 @@ void ImageAsset::blitInto(Graphics::ManagedSurface *target, uint32 x, uint32 y,
}
}
+bool ImageAsset::isPointInside(Common::Point myPos, Common::Point click) {
+ Common::Rect bounds(myPos.x, myPos.y, myPos.x + _bitWidth, myPos.y + _bitHeight);
+ return bounds.contains(click);
+}
+
void ImageAsset::blitDirect(Graphics::ManagedSurface * target, uint32 ox, uint32 oy, const Common::Array<byte>& data) {
if (_bitWidth == 0 || _bitHeight == 0) return;
uint w = _bitWidth;
diff --git a/engines/macventure/image.h b/engines/macventure/image.h
index eb52da83ad..0a3ea50ef1 100644
--- a/engines/macventure/image.h
+++ b/engines/macventure/image.h
@@ -59,6 +59,8 @@ public:
void blitInto(Graphics::ManagedSurface *target, uint32 x, uint32 y, BlitMode mode);
+ bool isPointInside(Common::Point myPos, Common::Point click);
+
private:
void decodePPIC(ObjID id, Common::Array<byte> &data);
diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp
index 87b5d51327..8d367c7174 100644
--- a/engines/macventure/macventure.cpp
+++ b/engines/macventure/macventure.cpp
@@ -204,15 +204,17 @@ void MacVentureEngine::loseGame() {
void MacVentureEngine::enqueueObject(ObjectQueueID type, ObjID objID) {
QueuedObject obj;
obj.id = type;
- obj.object = objID;
- obj.parent = _world->getObjAttr(objID, kAttrParentObject);
- obj.x = _world->getObjAttr(objID, kAttrPosX);
- obj.y = _world->getObjAttr(objID, kAttrPosY);
- obj.exitx = _world->getObjAttr(objID, kAttrExitX);
- obj.exity = _world->getObjAttr(objID, kAttrExitY);
- obj.hidden = _world->getObjAttr(objID, kAttrHiddenExit);
- obj.offscreen = _world->getObjAttr(objID, kAttrInvisible);
- obj.invisible = _world->getObjAttr(objID, kAttrUnclickable);
+ if (type != kHightlightExits) {
+ obj.object = objID;
+ obj.parent = _world->getObjAttr(objID, kAttrParentObject);
+ obj.x = _world->getObjAttr(objID, kAttrPosX);
+ obj.y = _world->getObjAttr(objID, kAttrPosY);
+ obj.exitx = _world->getObjAttr(objID, kAttrExitX);
+ obj.exity = _world->getObjAttr(objID, kAttrExitY);
+ obj.hidden = _world->getObjAttr(objID, kAttrHiddenExit);
+ obj.offscreen = _world->getObjAttr(objID, kAttrInvisible);
+ obj.invisible = _world->getObjAttr(objID, kAttrUnclickable);
+ }
_objQueue.push_back(obj);
}
@@ -247,6 +249,26 @@ bool MacVentureEngine::printTexts() {
}
}
+void MacVentureEngine::selectObject(ObjID objID) {
+ bool found = false;
+ uint i = 0;
+ while (i < _currentSelection.size() && !found) {
+ if (_currentSelection[i] == objID) found = true;
+ else i++;
+ }
+
+ if (!found) _currentSelection.push_back(objID);
+
+ found = false;
+ i = 0;
+ while (i < _selectedObjs.size() && !found) {
+ if (_selectedObjs[i] == objID) found = true;
+ else i++;
+ }
+
+ if (!found) _selectedObjs.push_back(objID);
+}
+
void MacVentureEngine::focusObjWin(ObjID objID) {
_gui->bringToFront(getObjWindow(objID));
}
@@ -301,7 +323,7 @@ bool MacVenture::MacVentureEngine::runScriptEngine() {
while (!_currentSelection.empty()) {
ObjID obj = _currentSelection.front();
- _currentSelection.pop_front();
+ _currentSelection.remove_at(0);
if ((_gameState == kGameStateInit || _gameState == kGameStatePlaying) && _world->isObjActive(obj)) {
if (_scriptEngine->runControl(_selectedControl, obj, _destObject, _deltaPoint)) {
_haltedInSelection = true;
diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h
index 7e6f362a8c..c45069c06c 100644
--- a/engines/macventure/macventure.h
+++ b/engines/macventure/macventure.h
@@ -177,6 +177,7 @@ public:
void runObjQueue();
bool printTexts();
+ void selectObject(ObjID objID);
void focusObjWin(ObjID objID);
void updateWindow(WindowReference winID);
@@ -264,7 +265,8 @@ private: // Attributes
ObjID _destObject;
ControlAction _selectedControl;
ControlAction _activeControl;
- Common::List<ObjID> _currentSelection;
+ Common::Array<ObjID> _currentSelection;
+ Common::Array<ObjID> _selectedObjs;
Common::Point _deltaPoint;
};
diff --git a/engines/macventure/script.cpp b/engines/macventure/script.cpp
index 64f94af16d..f7550360c8 100644
--- a/engines/macventure/script.cpp
+++ b/engines/macventure/script.cpp
@@ -905,15 +905,22 @@ void ScriptEngine::opbdFOOB(EngineState * state, EngineFrame * frame) {
}
void ScriptEngine::opbeSWOB(EngineState * state, EngineFrame * frame) {
- op00NOOP(0xbe);
+ ObjID from = state->pop();
+ ObjID to = state->pop();
+ _engine->enqueueObject(kUpdateWindow, to);
+ _world->setObjAttr(to, kAttrContainerOpen, _world->getObjAttr(from, 6));
+ _world->setObjAttr(from, kAttrContainerOpen, 0);
+ Common::Array<ObjID> children = _world->getChildren(from, true);
+ for (uint i = 0; i < children.size(); i++)
+ _world->setObjAttr(children[i], 0, to);
}
void ScriptEngine::opbfSNOB(EngineState * state, EngineFrame * frame) {
- op00NOOP(0xbf);
+ _engine->enqueueObject(kAnimateBack, frame->src);
}
void ScriptEngine::opc0TEXI(EngineState * state, EngineFrame * frame) {
- op00NOOP(0xc0);
+ _engine->enqueueObject(kHightlightExits, 0);
}
void ScriptEngine::opc1PTXT(EngineState * state, EngineFrame * frame) {
@@ -1049,9 +1056,8 @@ void ScriptEngine::opd9SLEEP(EngineState * state, EngineFrame * frame) {
}
void ScriptEngine::opdaCLICK(EngineState * state, EngineFrame * frame) {
- //_engine->updateScreen(false);
- //clickToContinue();
- op00NOOP(0xda);
+ _engine->updateState();
+ //_engine->clickToContinue();
}
void ScriptEngine::opdbROBQ(EngineState * state, EngineFrame * frame) {
@@ -1067,8 +1073,7 @@ void ScriptEngine::opddRTQ(EngineState * state, EngineFrame * frame) {
}
void ScriptEngine::opdeUPSC(EngineState * state, EngineFrame * frame) {
- //_engine->updateScreen(false);
- op00NOOP(0xde);
+ _engine->updateState();
}
void ScriptEngine::opdfFMAI(EngineState * state, EngineFrame * frame) {