aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2013-01-10 23:15:52 +0100
committerStrangerke2013-01-10 23:15:52 +0100
commitd1378dd594704a6c6ef5f0fcae66d849f8b86682 (patch)
tree6fb5fe9666e19b03eef683eb33a7b48e722f1244 /engines
parent9f153a3cbd47da66da6e2f03b909e20fc993d4c0 (diff)
downloadscummvm-rg350-d1378dd594704a6c6ef5f0fcae66d849f8b86682.tar.gz
scummvm-rg350-d1378dd594704a6c6ef5f0fcae66d849f8b86682.tar.bz2
scummvm-rg350-d1378dd594704a6c6ef5f0fcae66d849f8b86682.zip
HOPKINS: Refactor inventory code
Diffstat (limited to 'engines')
-rw-r--r--engines/hopkins/dialogs.cpp2
-rw-r--r--engines/hopkins/lines.cpp63
-rw-r--r--engines/hopkins/lines.h4
3 files changed, 37 insertions, 32 deletions
diff --git a/engines/hopkins/dialogs.cpp b/engines/hopkins/dialogs.cpp
index b2477c2bb0..9c7347f5f7 100644
--- a/engines/hopkins/dialogs.cpp
+++ b/engines/hopkins/dialogs.cpp
@@ -375,7 +375,7 @@ LABEL_7:
int mousePosY = _vm->_eventsManager.getMouseY();
int mouseButton = _vm->_eventsManager.getMouseButton();
int oldInventoryItem = newInventoryItem;
- newInventoryItem = _vm->_linesManager.ZONE_OBJET(mousePosX, mousePosY);
+ newInventoryItem = _vm->_linesManager.checkInventoryHotspots(mousePosX, mousePosY);
if (newInventoryItem != oldInventoryItem)
_vm->_objectsManager.initBorder(newInventoryItem);
if (_vm->_eventsManager._mouseCursorId != 1 && _vm->_eventsManager._mouseCursorId != 2 && _vm->_eventsManager._mouseCursorId != 3 && _vm->_eventsManager._mouseCursorId != 16) {
diff --git a/engines/hopkins/lines.cpp b/engines/hopkins/lines.cpp
index 5ebc762fbc..cf1794189b 100644
--- a/engines/hopkins/lines.cpp
+++ b/engines/hopkins/lines.cpp
@@ -59,51 +59,57 @@ void LinesManager::CLEAR_ZONE() {
next_ligne = 0;
}
-// Object Zone
-int LinesManager::ZONE_OBJET(int posX, int posY) {
- int v2 = 0;
- if ((uint)(posY - 120) <= 33)
- v2 = OPTI_ZONE(posX, 1, false);
- if ((uint)(posY - 154) <= 37)
- v2 = OPTI_ZONE(posX, 7, false);
- if ((uint)(posY - 192) <= 37)
- v2 = OPTI_ZONE(posX, 13, false);
- if ((uint)(posY - 230) <= 37)
- v2 = OPTI_ZONE(posX, 19, false);
- if ((uint)(posY - 268) <= 37)
- v2 = OPTI_ZONE(posX, 25, true);
- if ((uint)(posY - 268) <= 20 && posX >= _vm->_graphicsManager._scrollOffset + 424 && posX <= _vm->_graphicsManager._scrollOffset + 478)
- v2 = 30;
- if ((uint)(posY - 290) <= 16 && posX >= _vm->_graphicsManager._scrollOffset + 424 && posX <= _vm->_graphicsManager._scrollOffset + 478)
- v2 = 31;
- if (posX < _vm->_graphicsManager._scrollOffset + 152 || posX > _vm->_graphicsManager._scrollOffset + 484)
- v2 = 32;
- if ((uint)(posY - 114) > 192)
- v2 = 32;
- return v2;
+/**
+ * Check Hotspots in Inventory screen
+ * Returns the ID of the hotspot under mouse
+ */
+int LinesManager::checkInventoryHotspots(int posX, int posY) {
+ int hotspotId = 0;
+ if (posY >= 120 && posY <= 153)
+ hotspotId = checkInventoryHostpotsRow(posX, 1, false);
+ if (posY >= 154 && posY <= 191)
+ hotspotId = checkInventoryHostpotsRow(posX, 7, false);
+ if (posY >= 192 && posY <= 229)
+ hotspotId = checkInventoryHostpotsRow(posX, 13, false);
+ if (posY >= 230 && posY <= 267)
+ hotspotId = checkInventoryHostpotsRow(posX, 19, false);
+ if (posY >= 268 && posY <= 306)
+ hotspotId = checkInventoryHostpotsRow(posX, 25, true);
+ if (posY >= 268 && posY <= 288 && posX >= _vm->_graphicsManager._scrollOffset + 424 && posX <= _vm->_graphicsManager._scrollOffset + 478)
+ hotspotId = 30;
+ if (posY >= 290 && posY <= 306 && posX >= _vm->_graphicsManager._scrollOffset + 424 && posX <= _vm->_graphicsManager._scrollOffset + 478)
+ hotspotId = 31;
+ if (posY < 114 || posY > 306 || posX < _vm->_graphicsManager._scrollOffset + 152 || posX > _vm->_graphicsManager._scrollOffset + 484)
+ hotspotId = 32;
+
+ return hotspotId;
}
-int LinesManager::OPTI_ZONE(int posX, int minZoneNum, bool lastRow) {
+/**
+ * Check the hotspots in an inventory line
+ * Returns the hotspot Id under the mouse, if any.
+ */
+int LinesManager::checkInventoryHostpotsRow(int posX, int minZoneNum, bool lastRow) {
int result = minZoneNum;
- if (posX >= _vm->_graphicsManager._scrollOffset + 158 && posX <= _vm->_graphicsManager._scrollOffset + 208)
+ if (posX >= _vm->_graphicsManager._scrollOffset + 158 && posX < _vm->_graphicsManager._scrollOffset + 208)
return result;
- if (posX >= _vm->_graphicsManager._scrollOffset + 208 && posX <= _vm->_graphicsManager._scrollOffset + 266) {
+ if (posX >= _vm->_graphicsManager._scrollOffset + 208 && posX < _vm->_graphicsManager._scrollOffset + 266) {
result += 1;
return result;
}
- if (posX >= _vm->_graphicsManager._scrollOffset + 266 && posX <= _vm->_graphicsManager._scrollOffset + 320) {
+ if (posX >= _vm->_graphicsManager._scrollOffset + 266 && posX < _vm->_graphicsManager._scrollOffset + 320) {
result += 2;
return result;
}
- if (posX >= _vm->_graphicsManager._scrollOffset + 320 && posX <= _vm->_graphicsManager._scrollOffset + 370) {
+ if (posX >= _vm->_graphicsManager._scrollOffset + 320 && posX < _vm->_graphicsManager._scrollOffset + 370) {
result += 3;
return result;
}
- if (posX >= _vm->_graphicsManager._scrollOffset + 370 && posX <= _vm->_graphicsManager._scrollOffset + 424) {
+ if (posX >= _vm->_graphicsManager._scrollOffset + 370 && posX < _vm->_graphicsManager._scrollOffset + 424) {
result += 4;
return result;
}
@@ -179,7 +185,6 @@ void LinesManager::addZoneLine(int idx, int a2, int a3, int a4, int a5, int bobZ
}
}
-
void LinesManager::resetLines() {
for (int idx = 0; idx < MAX_LINES; ++idx) {
removeLine(idx);
diff --git a/engines/hopkins/lines.h b/engines/hopkins/lines.h
index 67b5fa44a0..279ed29373 100644
--- a/engines/hopkins/lines.h
+++ b/engines/hopkins/lines.h
@@ -71,8 +71,8 @@ public:
void setParent(HopkinsEngine *vm);
void CLEAR_ZONE();
- int ZONE_OBJET(int posX, int posY);
- int OPTI_ZONE(int posX, int minZoneNum, bool lastRow);
+ int checkInventoryHotspots(int posX, int posY);
+ int checkInventoryHostpotsRow(int posX, int minZoneNum, bool lastRow);
void removeZoneLine(int idx);
void addZoneLine(int idx, int a2, int a3, int a4, int a5, int bobZoneIdx);
void resetLines();