aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2013-08-17 11:18:13 +0200
committerStrangerke2013-08-17 11:18:13 +0200
commitddb9f3862dae190b1e141c0d6ab88b34e49743ab (patch)
tree85c21d6b5dd00bccda59872a4474eea97f164048
parent0d6f6119638ae40a6e849a740452c67919eeb559 (diff)
downloadscummvm-rg350-ddb9f3862dae190b1e141c0d6ab88b34e49743ab.tar.gz
scummvm-rg350-ddb9f3862dae190b1e141c0d6ab88b34e49743ab.tar.bz2
scummvm-rg350-ddb9f3862dae190b1e141c0d6ab88b34e49743ab.zip
MORTEVIELLE: Fix verb highlighting in Action and Self menus. Refactor functions related to MenuItem
-rw-r--r--engines/mortevielle/menu.cpp113
-rw-r--r--engines/mortevielle/menu.h16
-rw-r--r--engines/mortevielle/utils.cpp24
3 files changed, 89 insertions, 64 deletions
diff --git a/engines/mortevielle/menu.cpp b/engines/mortevielle/menu.cpp
index 9e03e83127..d6b9d57141 100644
--- a/engines/mortevielle/menu.cpp
+++ b/engines/mortevielle/menu.cpp
@@ -155,30 +155,39 @@ void Menu::readVerbNums(Common::File &f, int dataSize) {
* Setup a menu's contents
* @remarks Originally called 'menut'
*/
-void Menu::setText(int menuId, int actionId, Common::String name) {
+void Menu::setText(MenuItem item, Common::String name) {
Common::String s = name;
- while (s.size() < 22)
- s += ' ';
-
- switch (menuId) {
+ switch (item._menuId) {
case MENU_INVENTORY:
- if (actionId != 7) {
- _inventoryStringArray[actionId] = s;
- _inventoryStringArray[actionId].insertChar(' ', 0);
+ if (item._actionId != 7) {
+ while (s.size() < 22)
+ s += ' ';
+
+ _inventoryStringArray[item._actionId] = s;
+ _inventoryStringArray[item._actionId].insertChar(' ', 0);
}
break;
case MENU_MOVE:
- _moveStringArray[actionId] = s;
+ while (s.size() < 22)
+ s += ' ';
+
+ _moveStringArray[item._actionId] = s;
break;
case MENU_ACTION:
- _actionStringArray[actionId] = s;
+ while (s.size() < 10)
+ s += ' ';
+
+ _actionStringArray[item._actionId] = s;
break;
case MENU_SELF:
- _selfStringArray[actionId] = s;
+ while (s.size() < 10)
+ s += ' ';
+
+ _selfStringArray[item._actionId] = s;
break;
case MENU_DISCUSS:
- _discussStringArray[actionId] = s;
+ _discussStringArray[item._actionId] = s;
break;
default:
break;
@@ -200,11 +209,11 @@ void Menu::setDestinationText(int roomId) {
nomp = _vm->getString(_vm->_destinationArray[destinationId][roomId] + kMenuPlaceStringIndex);
while (nomp.size() < 20)
nomp += ' ';
- setText(_moveMenu[destinationId + 1]._menuId, _moveMenu[destinationId + 1]._actionId, nomp);
+ setText(_moveMenu[destinationId + 1], nomp);
}
nomp = "* ";
for (int i = 7; i >= destinationId + 1; --i)
- setText(_moveMenu[i]._menuId, _moveMenu[i]._actionId, nomp);
+ setText(_moveMenu[i], nomp);
}
/**
@@ -212,26 +221,26 @@ void Menu::setDestinationText(int roomId) {
* @param menuId Menu number
* @param actionId Item index
*/
-void Menu::disableMenuItem(int menuId, int actionId) {
- switch (menuId) {
+void Menu::disableMenuItem(MenuItem item) {
+ switch (item._menuId) {
case MENU_INVENTORY:
- if (actionId > 6) {
- _inventoryStringArray[actionId].setChar('<', 0);
- _inventoryStringArray[actionId].setChar('>', 21);
+ if (item._actionId > 6) {
+ _inventoryStringArray[item._actionId].setChar('<', 0);
+ _inventoryStringArray[item._actionId].setChar('>', 21);
} else
- _inventoryStringArray[actionId].setChar('*', 0);
+ _inventoryStringArray[item._actionId].setChar('*', 0);
break;
case MENU_MOVE:
- _moveStringArray[actionId].setChar('*', 0);
+ _moveStringArray[item._actionId].setChar('*', 0);
break;
case MENU_ACTION:
- _actionStringArray[actionId].setChar('*', 0);
+ _actionStringArray[item._actionId].setChar('*', 0);
break;
case MENU_SELF:
- _selfStringArray[actionId].setChar('*', 0);
+ _selfStringArray[item._actionId].setChar('*', 0);
break;
case MENU_DISCUSS:
- _discussStringArray[actionId].setChar('*', 0);
+ _discussStringArray[item._actionId].setChar('*', 0);
break;
default:
break;
@@ -244,23 +253,23 @@ void Menu::disableMenuItem(int menuId, int actionId) {
* @param actionId Item index
* @remarks Originally called menu_enable
*/
-void Menu::enableMenuItem(int menuId, int actionId) {
- switch (menuId) {
+void Menu::enableMenuItem(MenuItem item) {
+ switch (item._menuId) {
case MENU_INVENTORY:
- _inventoryStringArray[actionId].setChar(' ', 0);
- _inventoryStringArray[actionId].setChar(' ', 21);
+ _inventoryStringArray[item._actionId].setChar(' ', 0);
+ _inventoryStringArray[item._actionId].setChar(' ', 21);
break;
case MENU_MOVE:
- _moveStringArray[actionId].setChar(' ', 0);
+ _moveStringArray[item._actionId].setChar(' ', 0);
break;
case MENU_ACTION:
- _actionStringArray[actionId].setChar(' ', 0);
+ _actionStringArray[item._actionId].setChar(' ', 0);
break;
case MENU_SELF:
- _selfStringArray[actionId].setChar(' ', 0);
+ _selfStringArray[item._actionId].setChar(' ', 0);
break;
case MENU_DISCUSS:
- _discussStringArray[actionId].setChar(' ', 0);
+ _discussStringArray[item._actionId].setChar(' ', 0);
break;
default:
break;
@@ -654,7 +663,7 @@ void Menu::initMenu() {
_inventoryMenu[i]._menuId = MENU_INVENTORY;
_inventoryMenu[i]._actionId = i;
if (i > 6)
- disableMenuItem(_inventoryMenu[i]._menuId, _inventoryMenu[i]._actionId);
+ disableMenuItem(_inventoryMenu[i]);
}
_msg3 = OPCODE_NONE;
_msg4 = OPCODE_NONE;
@@ -669,13 +678,21 @@ void Menu::initMenu() {
*/
void Menu::setSearchMenu() {
for (int i = 1; i <= 7; ++i)
- disableMenuItem(MENU_MOVE, _moveMenu[i]._actionId);
+ disableMenuItem(_moveMenu[i]);
for (int i = 1; i <= 11; ++i)
- disableMenuItem(_actionMenu[i]._menuId, _actionMenu[i]._actionId);
+ disableMenuItem(_actionMenu[i]);
+
+ MenuItem miSound;
+ miSound._menuId = _opcodeSound >> 8;
+ miSound._actionId = _opcodeSound & 0xFF;
- setText(_opcodeSound >> 8, _opcodeSound & 0xFF, _vm->getEngineString(S_SUITE));
- setText(_opcodeLift >> 8, _opcodeLift & 0xFF, _vm->getEngineString(S_STOP));
+ MenuItem miLift;
+ miLift._menuId = _opcodeLift >> 8;
+ miLift._actionId = _opcodeLift & 0xFF;
+
+ setText(miSound, _vm->getEngineString(S_SUITE));
+ setText(miLift, _vm->getEngineString(S_STOP));
}
/**
@@ -685,10 +702,18 @@ void Menu::setSearchMenu() {
void Menu::unsetSearchMenu() {
setDestinationText(_vm->_coreVar._currPlace);
for (int i = 1; i <= 11; ++i)
- enableMenuItem(_actionMenu[i]._menuId, _actionMenu[i]._actionId);
+ enableMenuItem(_actionMenu[i]);
+
+ MenuItem miSound;
+ miSound._menuId = _opcodeSound >> 8;
+ miSound._actionId = _opcodeSound & 0xFF;
+
+ MenuItem miLift;
+ miLift._menuId = _opcodeLift >> 8;
+ miLift._actionId = _opcodeLift & 0xFF;
- setText(_opcodeSound >> 8, _opcodeSound & 0xFF, _vm->getEngineString(S_PROBE));
- setText(_opcodeLift >> 8, _opcodeLift & 0xFF, _vm->getEngineString(S_RAISE));
+ setText(miSound, _vm->getEngineString(S_PROBE));
+ setText(miLift, _vm->getEngineString(S_RAISE));
}
/**
@@ -704,15 +729,15 @@ void Menu::setInventoryText() {
++cy;
int r = _vm->_coreVar._inventory[i] + 400;
nomp = _vm->getString(r - 501 + kInventoryStringIndex);
- setText(_inventoryMenu[cy]._menuId, _inventoryMenu[cy]._actionId, nomp);
- enableMenuItem(_inventoryMenu[i]._menuId, _inventoryMenu[i]._actionId);
+ setText(_inventoryMenu[cy], nomp);
+ enableMenuItem(_inventoryMenu[i]);
}
}
if (cy < 6) {
for (int i = cy + 1; i <= 6; ++i) {
- setText(_inventoryMenu[i]._menuId, _inventoryMenu[i]._actionId, " ");
- disableMenuItem(_inventoryMenu[i]._menuId, _inventoryMenu[i]._actionId);
+ setText(_inventoryMenu[i], " ");
+ disableMenuItem(_inventoryMenu[i]);
}
}
}
diff --git a/engines/mortevielle/menu.h b/engines/mortevielle/menu.h
index 9afa99cfa8..d1271bca2e 100644
--- a/engines/mortevielle/menu.h
+++ b/engines/mortevielle/menu.h
@@ -42,7 +42,7 @@ enum {
const int OPCODE_NONE = 0;
-struct menuItem {
+struct MenuItem {
int _menuId;
int _actionId;
};
@@ -71,9 +71,9 @@ public:
Common::String _actionStringArray[22];
Common::String _selfStringArray[7];
Common::String _discussStringArray[9];
- menuItem _discussMenu[9];
- menuItem _inventoryMenu[9];
- menuItem _moveMenu[8];
+ MenuItem _discussMenu[9];
+ MenuItem _inventoryMenu[9];
+ MenuItem _moveMenu[8];
int _opcodeAttach;
int _opcodeWait;
@@ -101,15 +101,15 @@ public:
int _opcodeSRead;
int _opcodeSPut;
int _opcodeSLook;
- menuItem _actionMenu[12];
+ MenuItem _actionMenu[12];
void setParent(MortevielleEngine *vm);
void readVerbNums(Common::File &f, int dataSize);
- void setText(int menuId, int actionId, Common::String name);
+ void setText(MenuItem item, Common::String name);
void setDestinationText(int roomId);
void setInventoryText();
- void disableMenuItem(int menuId, int actionId);
- void enableMenuItem(int menuId, int actionId);
+ void disableMenuItem(MenuItem item);
+ void enableMenuItem(MenuItem item);
void displayMenu();
void drawMenu();
void menuUp(int msgId);
diff --git a/engines/mortevielle/utils.cpp b/engines/mortevielle/utils.cpp
index 52e3b7c29b..cc3e879450 100644
--- a/engines/mortevielle/utils.cpp
+++ b/engines/mortevielle/utils.cpp
@@ -502,48 +502,48 @@ void MortevielleEngine::showPeoplePresent(int bitIndex) {
int xp = 580 - (_screenSurface.getStringWidth("LEO") / 2);
for (int i = 1; i <= 8; ++i)
- _menu.disableMenuItem(_menu._discussMenu[i]._menuId, _menu._discussMenu[i]._actionId);
+ _menu.disableMenuItem(_menu._discussMenu[i]);
clearUpperRightPart();
if ((bitIndex & 128) == 128) {
_screenSurface.putxy(xp, 24);
_screenSurface.drawString("LEO", 4);
- _menu.enableMenuItem(_menu._discussMenu[1]._menuId, _menu._discussMenu[1]._actionId);
+ _menu.enableMenuItem(_menu._discussMenu[1]);
}
if ((bitIndex & 64) == 64) {
_screenSurface.putxy(xp, 32);
_screenSurface.drawString("PAT", 4);
- _menu.enableMenuItem(_menu._discussMenu[2]._menuId, _menu._discussMenu[2]._actionId);
+ _menu.enableMenuItem(_menu._discussMenu[2]);
}
if ((bitIndex & 32) == 32) {
_screenSurface.putxy(xp, 40);
_screenSurface.drawString("GUY", 4);
- _menu.enableMenuItem(_menu._discussMenu[3]._menuId, _menu._discussMenu[3]._actionId);
+ _menu.enableMenuItem(_menu._discussMenu[3]);
}
if ((bitIndex & 16) == 16) {
_screenSurface.putxy(xp, 48);
_screenSurface.drawString("EVA", 4);
- _menu.enableMenuItem(_menu._discussMenu[4]._menuId, _menu._discussMenu[4]._actionId);
+ _menu.enableMenuItem(_menu._discussMenu[4]);
}
if ((bitIndex & 8) == 8) {
_screenSurface.putxy(xp, 56);
_screenSurface.drawString("BOB", 4);
- _menu.enableMenuItem(_menu._discussMenu[5]._menuId, _menu._discussMenu[5]._actionId);
+ _menu.enableMenuItem(_menu._discussMenu[5]);
}
if ((bitIndex & 4) == 4) {
_screenSurface.putxy(xp, 64);
_screenSurface.drawString("LUC", 4);
- _menu.enableMenuItem(_menu._discussMenu[6]._menuId, _menu._discussMenu[6]._actionId);
+ _menu.enableMenuItem(_menu._discussMenu[6]);
}
if ((bitIndex & 2) == 2) {
_screenSurface.putxy(xp, 72);
_screenSurface.drawString("IDA", 4);
- _menu.enableMenuItem(_menu._discussMenu[7]._menuId, _menu._discussMenu[7]._actionId);
+ _menu.enableMenuItem(_menu._discussMenu[7]);
}
if ((bitIndex & 1) == 1) {
_screenSurface.putxy(xp, 80);
_screenSurface.drawString("MAX", 4);
- _menu.enableMenuItem(_menu._discussMenu[8]._menuId, _menu._discussMenu[8]._actionId);
+ _menu.enableMenuItem(_menu._discussMenu[8]);
}
_currBitIndex = bitIndex;
}
@@ -697,7 +697,7 @@ int MortevielleEngine::getPresenceStatsRedRoom() {
*/
void MortevielleEngine::displayAloneText() {
for (int i = 1; i <= 8; ++i)
- _menu.disableMenuItem(_menu._discussMenu[i]._menuId, _menu._discussMenu[i]._actionId);
+ _menu.disableMenuItem(_menu._discussMenu[i]);
Common::String sYou = getEngineString(S_YOU);
Common::String sAre = getEngineString(S_ARE);
@@ -2663,8 +2663,8 @@ void MortevielleEngine::displayItemInHand(int objId) {
if (objId != 500)
strp = getString(objId - 501 + kInventoryStringIndex);
- _menu.setText(_menu._inventoryMenu[8]._menuId, _menu._inventoryMenu[8]._actionId, strp);
- _menu.disableMenuItem(_menu._inventoryMenu[8]._menuId, _menu._inventoryMenu[8]._actionId);
+ _menu.setText(_menu._inventoryMenu[8], strp);
+ _menu.disableMenuItem(_menu._inventoryMenu[8]);
}
/**