aboutsummaryrefslogtreecommitdiff
path: root/engines/mads
diff options
context:
space:
mode:
authorPaul Gilbert2014-03-24 22:34:09 -0400
committerPaul Gilbert2014-03-24 22:34:09 -0400
commit3c504f4d028efdec39b6b250948eb41522de18e2 (patch)
treebf4fb0f20bcf2f33aa712f76223b25f39f9459e7 /engines/mads
parentd958f509241714f140c95e7afa0005b1fe5c8352 (diff)
downloadscummvm-rg350-3c504f4d028efdec39b6b250948eb41522de18e2.tar.gz
scummvm-rg350-3c504f4d028efdec39b6b250948eb41522de18e2.tar.bz2
scummvm-rg350-3c504f4d028efdec39b6b250948eb41522de18e2.zip
MADS: Cleanup of user interface selection code
Diffstat (limited to 'engines/mads')
-rw-r--r--engines/mads/game.cpp2
-rw-r--r--engines/mads/screen.cpp23
-rw-r--r--engines/mads/user_interface.cpp54
-rw-r--r--engines/mads/user_interface.h6
4 files changed, 65 insertions, 20 deletions
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 4b907d1880..f155bc81c2 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -199,7 +199,7 @@ void Game::sectionLoop() {
}
_vm->_events->initVars();
- _scene._userInterface._v1A = -1;
+ _scene._userInterface._highlightedActionIndex = -1;
_scene._userInterface._v1C = -1;
_scene._userInterface._v1E = -1;
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 5b0d4422ce..ba6875205f 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -437,7 +437,7 @@ void ScreenObjects::checkScroller() {
if (userInterface._inventoryChanged) {
int dummy;
- userInterface.drawInventory(2, 0, &dummy);
+ userInterface.updateSelection(CAT_INV_LIST, 0, &dummy);
}
}
}
@@ -457,7 +457,7 @@ void ScreenObjects::elementHighlighted() {
MADSAction &action = scene._action;
int varA;
int topIndex;
- int *var6;
+ int *idxP;
int var4;
int index;
int indexEnd = -1;
@@ -470,10 +470,11 @@ void ScreenObjects::elementHighlighted() {
indexEnd = 9;
varA = 5;
topIndex = 0;
- var6 = !_v7FECA ? &userInterface._v1A : &userInterface._selectedActionIndex;
+ idxP = !_v7FECA ? &userInterface._highlightedActionIndex :
+ &userInterface._selectedActionIndex;
if (_v7FECA && userInterface._selectedItemVocabIdx >= 0)
- userInterface.drawInventory(3, -1, &userInterface._selectedItemVocabIdx);
+ userInterface.updateSelection(CAT_INV_VOCAB, -1, &userInterface._selectedItemVocabIdx);
var4 = _released && !_v7FECA ? 1 : 0;
break;
@@ -485,7 +486,7 @@ void ScreenObjects::elementHighlighted() {
indexEnd = invList.size() - 1;
varA = 0;
topIndex = userInterface._inventoryTopIndex;
- var6 = &userInterface._v1C;
+ idxP = &userInterface._v1C;
var4 = (!_released || (_vm->_events->_mouseButtons && action._v83338 == 1)) ? 0 : 1;
break;
@@ -501,10 +502,10 @@ void ScreenObjects::elementHighlighted() {
varA = 0;
topIndex = 0;
- var6 = _v7FECA ? &userInterface._selectedItemVocabIdx : &userInterface._v1E;
+ idxP = _v7FECA ? &userInterface._selectedItemVocabIdx : &userInterface._v1E;
if (_v7FECA && userInterface._selectedActionIndex >= 0)
- userInterface.drawInventory(1, -1, &userInterface._selectedActionIndex);
+ userInterface.updateSelection(CAT_ACTION, -1, &userInterface._selectedActionIndex);
var4 = _released && !_v7FECA ? 1 : 0;
break;
@@ -514,7 +515,7 @@ void ScreenObjects::elementHighlighted() {
indexEnd = invList.size() - 1;
varA = 0;
topIndex = userInterface._selectedInvIndex;
- var6 = &var8;
+ idxP = &var8;
var4 = -1;
break;
@@ -528,7 +529,7 @@ void ScreenObjects::elementHighlighted() {
indexEnd = index - 1;
varA = 0;
topIndex = 0;
- var6 = &userInterface._v1A;
+ idxP = &userInterface._highlightedActionIndex;
var4 = -1;
break;
@@ -538,7 +539,7 @@ void ScreenObjects::elementHighlighted() {
indexEnd = index - 1;
varA = 0;
topIndex = 0;
- var6 = &var8;
+ idxP = &var8;
var4 = -1;
break;
}
@@ -606,7 +607,7 @@ void ScreenObjects::elementHighlighted() {
newIndex = -1;
if (_category != CAT_HOTSPOT && _category != CAT_INV_ANIM)
- userInterface.drawInventory(_category, newIndex, var6);
+ userInterface.updateSelection(_category, newIndex, idxP);
}
void ScreenObjects::setActive(ScrCategory category, int descId, bool active) {
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 28fc5a6e55..67fb50e4ac 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -199,7 +199,7 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm),
_selectedActionIndex = -1;
_selectedItemVocabIdx = -1;
_scrollerY = 0;
- _v1A = -1;
+ _highlightedActionIndex = -1;
_v1C = -1;
_v1E = -1;
_dirtyAreas.resize(50);
@@ -264,7 +264,7 @@ void UserInterface::setup(int id) {
scene._userInterface._uiSlots.clear();
scene._userInterface._uiSlots.fullRefresh();
_vm->_game->_ticksExpiry = _vm->_events->getFrameCounter();
- _v1A = -1;
+ _highlightedActionIndex = -1;
_v1E = -1;
_v1C = -1;
@@ -331,7 +331,7 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
case CAT_ACTION:
font = _vm->_font->getFont(FONT_INTERFACE);
vocabId = scene._verbList[id]._id;
- if (_v1A) {
+ if (_highlightedActionIndex) {
_vm->_font->setColorMode(1);
} else {
_vm->_font->setColorMode(id == _selectedActionIndex ? 2 : 0);
@@ -642,8 +642,50 @@ void UserInterface::selectObject(int invIndex) {
warning("TODO: selectObject");
}
-void UserInterface::drawInventory(int v1, int v2, int *v3) {
- warning("TODO: drawInventory");
+void UserInterface::updateSelection(ScrCategory category, int newIndex, int *idx) {
+ Game &game = *_vm->_game;
+ Common::Rect bounds;
+
+ if (category == CAT_INV_LIST && _inventoryChanged) {
+ *idx = newIndex;
+ bounds = Common::Rect(90, 3, 90 + 69, 3 + 40);
+ _uiSlots.add(Common::Point(90, 3), 69, 40);
+ _uiSlots.draw(false, false);
+ drawInventoryList();
+ updateRect(bounds);
+ _inventoryChanged = false;
+
+ if (game._objects._inventoryList.size() > 1) {
+ _objectY = 0;
+ } else {
+ int v = _inventoryTopIndex * 18 / (game._objects._inventoryList.size() - 1);
+ _objectY = MIN(v, 17);
+ }
+ } else {
+ int oldIndex = *idx;
+ *idx = newIndex;
+
+ if (oldIndex >= 0) {
+ Common::Rect bounds;
+ writeVocab(category, oldIndex);
+
+ if (getBounds(category, oldIndex, bounds))
+ updateRect(bounds);
+ }
+
+ if (newIndex >= 0) {
+ writeVocab(category, newIndex);
+
+ if (getBounds(category, newIndex, bounds))
+ updateRect(bounds);
+ }
+ }
+}
+
+void UserInterface::updateRect(const Common::Rect &bounds) {
+ _vm->_screen.setPointer(&_surface);
+ setBounds(Common::Rect(0, MADS_SCENE_HEIGHT, MADS_SCREEN_WIDTH - 1, MADS_SCREEN_HEIGHT));
+ _vm->_screen.copyRectToScreen(bounds);
}
void UserInterface::scrollerChanged() {
@@ -665,7 +707,7 @@ void UserInterface::scrollInventory() {
_scrollFlag = true;
if (yp == (MADS_SCREEN_HEIGHT - 1)) {
- if (_inventoryTopIndex < (int)(invList.size() - 1)) {
+ if (_inventoryTopIndex < ((int)invList.size() - 1)) {
++_inventoryTopIndex;
_inventoryChanged = true;
}
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index abb4619cf5..ee5bc7aa0d 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -128,6 +128,8 @@ private:
void writeVocab(ScrCategory category, int id);
void refresh();
+
+ void updateRect(const Common::Rect &bounds);
public:
MSurface _surface;
UISlots _uiSlots;
@@ -141,7 +143,7 @@ public:
int _selectedActionIndex;
int _selectedItemVocabIdx;
int _scrollerY;
- int _v1A;
+ int _highlightedActionIndex;
int _v1C;
int _v1E;
bool _inventoryChanged;
@@ -191,7 +193,7 @@ public:
*/
void selectObject(int invIndex);
- void drawInventory(int v1, int v2, int *v3);
+ void updateSelection(ScrCategory category, int newIndex, int *idx);
void scrollerChanged();