aboutsummaryrefslogtreecommitdiff
path: root/engines/macventure
diff options
context:
space:
mode:
authorBorja Lorente2016-07-07 19:50:30 +0200
committerBorja Lorente2016-08-14 18:48:35 +0200
commit528283fbe1abb33e61131f7372cda6e2192dbf70 (patch)
tree76f6c45077b72aac56e785fb2f9423dffaccd7db /engines/macventure
parent9905cd24d3335c6dab612b5a8c0e3682856020d9 (diff)
downloadscummvm-rg350-528283fbe1abb33e61131f7372cda6e2192dbf70.tar.gz
scummvm-rg350-528283fbe1abb33e61131f7372cda6e2192dbf70.tar.bz2
scummvm-rg350-528283fbe1abb33e61131f7372cda6e2192dbf70.zip
MACVENTURE: First version of working drag
Diffstat (limited to 'engines/macventure')
-rw-r--r--engines/macventure/gui.cpp31
-rw-r--r--engines/macventure/gui.h3
-rw-r--r--engines/macventure/macventure.cpp29
-rw-r--r--engines/macventure/macventure.h5
4 files changed, 40 insertions, 28 deletions
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index 0012335584..9671dc0f5f 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -243,6 +243,7 @@ void Gui::setWindowTitle(WindowReference winID, Common::String string) {
}
void Gui::updateWindowInfo(WindowReference ref, ObjID objID, const Common::Array<ObjID> &children) {
+ if (ref == kNoWindow) return;
WindowData &data = findWindowData(ref);
data.children.clear();
data.objRef = objID;
@@ -603,7 +604,6 @@ void Gui::drawSelfWindow() {
void Gui::drawInventories() {
-
Graphics::ManagedSurface *srf;
for (uint i = 0; i < _inventoryWindows.size(); i++) {
const WindowData &data = getWindowData((WindowReference)(kInventoryStart + i));
@@ -667,7 +667,7 @@ void Gui::drawObjectsInWindow(WindowReference target, Graphics::ManagedSurface *
pos = _engine->getObjPosition(child);
pos += Common::Point(border.leftOffset, border.topOffset);
- if (child < 600) { // Small HACK until I figre out where the last garbage child in main game window comes from
+ if (child < 650) { // Small HACK until I figre out where the last garbage child in main game window comes from
if (!_assets.contains(child)) {
_assets[child] = new ImageAsset(child, _graphics);
}
@@ -738,6 +738,7 @@ void Gui::drawDraggedObject() {
void Gui::updateWindow(WindowReference winID, bool containerOpen) {
+ if (winID == kNoWindow) return;
if (winID == kSelfWindow || containerOpen) {
WindowData &data = findWindowData(winID);
if (winID == kCommandsWindow) {
@@ -880,6 +881,32 @@ Graphics::MacWindow * Gui::findWindow(WindowReference reference) {
return nullptr;
}
+WindowReference Gui::getObjWindow(ObjID objID) {
+ switch (objID) {
+ case 0xfffc: return kExitsWindow;
+ case 0xfffd: return kSelfWindow;
+ case 0xfffe: return kOutConsoleWindow;
+ case 0xffff: return kCommandsWindow;
+ }
+
+ return findObjWindow(objID);
+}
+
+WindowReference Gui::findObjWindow(ObjID objID) {
+ // This is a bit of a HACK, we take advantage of the consecutive nature of references
+ for (uint i = kCommandsWindow; i <= kDiplomaWindow; i++) {
+ const WindowData &data = getWindowData((WindowReference)i);
+ if (data.objRef == objID) { return data.refcon; }
+ }
+
+ for (uint i = kInventoryStart; i < _inventoryWindows.size() + kInventoryStart; i++) {
+ const WindowData &data = getWindowData((WindowReference)i);
+ if (data.objRef == objID) { return data.refcon; }
+ }
+
+ return kNoWindow;
+}
+
void Gui::checkSelect(ObjID obj, const Common::Event &event, const Common::Rect & clickRect, WindowReference ref) {
if (_engine->isObjVisible(obj) &&
_engine->isObjClickable(obj) &&
diff --git a/engines/macventure/gui.h b/engines/macventure/gui.h
index 54e7b66945..cd0799d66d 100644
--- a/engines/macventure/gui.h
+++ b/engines/macventure/gui.h
@@ -208,6 +208,9 @@ public:
uint getObjWidth(ObjID obj);
uint getObjHeight(ObjID obj);
+ WindowReference getObjWindow(ObjID objID);
+ WindowReference findObjWindow(ObjID objID);
+
// Event processors
bool processCommandEvents(WindowClick click, Common::Event &event);
bool processMainGameEvents(WindowClick click, Common::Event &event);
diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp
index b9c46da8e4..061438207b 100644
--- a/engines/macventure/macventure.cpp
+++ b/engines/macventure/macventure.cpp
@@ -665,11 +665,9 @@ void MacVentureEngine::checkObject(QueuedObject old) {
bool hasChanged = false;
debug("Check Object[%d] parent[%d] x[%d] y[%d]",
old.object,
- _world->getObjAttr(old.object, kAttrParentObject),
- _world->getObjAttr(old.object, kAttrPosX),
- _world->getObjAttr(old.object, kAttrPosY));
- //bool incoming = isIncomingObj(objID);
- //if (incoming) removeIncoming(objID);
+ old.parent,
+ old.x,
+ old.y);
ObjID id = old.object;
if (id == 1) {
if (old.parent != _world->getObjAttr(id, kAttrParentObject)) {
@@ -688,7 +686,7 @@ void MacVentureEngine::checkObject(QueuedObject old) {
hasChanged = true;
}
- WindowReference newWin = getObjWindow(id);
+ WindowReference newWin = findParentWindow(id);
if (newWin) {
_gui->addChild(newWin, id);
hasChanged = true;
@@ -887,28 +885,13 @@ uint MacVentureEngine::getOverlapPercent(ObjID one, ObjID other) {
}
WindowReference MacVentureEngine::getObjWindow(ObjID objID) {
- switch (objID) {
- case 0xfffc: return kExitsWindow;
- case 0xfffd: return kSelfWindow;
- case 0xfffe: return kOutConsoleWindow;
- case 0xffff: return kCommandsWindow;
- }
-
- return findObjWindow(objID);
-}
-
-WindowReference MacVentureEngine::findObjWindow(ObjID objID) {
- // This is a bit of a hack, we take advantage of the consecutive nature of references
- for (uint i = kCommandsWindow; i <= kDiplomaWindow; i++) {
- const WindowData &data = _gui->getWindowData((WindowReference)i);
- if (data.objRef == objID) { return data.refcon; }
- }
- return kNoWindow;
+ return _gui->getObjWindow(objID);
}
WindowReference MacVentureEngine::findParentWindow(ObjID objID) {
if (objID == 1) return kSelfWindow;
ObjID parent = _world->getObjAttr(objID, kAttrParentObject);
+ if (parent == 0) return kNoWindow;
return getObjWindow(parent);
}
diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h
index 043218c8a0..735dda51cc 100644
--- a/engines/macventure/macventure.h
+++ b/engines/macventure/macventure.h
@@ -196,7 +196,7 @@ public:
void enqueueObject(ObjectQueueID type, ObjID objID, ObjID target = 0);
void enqueueText(TextQueueID type, ObjID target, ObjID source, ObjID text);
-
+
void runObjQueue();
bool printTexts();
@@ -239,7 +239,6 @@ public:
uint getOverlapPercent(ObjID one, ObjID other);
WindowReference getObjWindow(ObjID objID);
- WindowReference findObjWindow(ObjID objID);
WindowReference findParentWindow(ObjID objID);
Common::Point getDeltaPoint();
@@ -275,7 +274,7 @@ private:
// Data loading
bool loadGlobalSettings();
bool loadTextHuffman();
-
+
const char* getGameFileName() const;
private: // Attributes