MADS: Fixes for UI item selection, add added an enum for Font::setColorMode

This commit is contained in:
Paul Gilbert 2014-03-25 08:55:29 -04:00
parent 3c504f4d02
commit 2879b895bc
4 changed files with 21 additions and 16 deletions

View File

@ -118,15 +118,15 @@ void Font::setColors(uint8 v1, uint8 v2, uint8 v3, uint8 v4) {
_fontColors[2] = v3;
}
void Font::setColorMode(int mode) {
void Font::setColorMode(SelectionMode mode) {
switch (mode) {
case 0:
case SELMODE_UNSELECTED:
setColors(0xFF, 4, 4, 0);
break;
case 1:
case SELMODE_HIGHLIGHTED:
setColors(0xFF, 5, 5, 0);
break;
case 2:
case SELMODE_SELECTED:
setColors(0xFF, 6, 6, 0);
break;
default:

View File

@ -39,6 +39,10 @@ namespace MADS {
#define FONT_TELE "*FONTTELE.FF" // Not in Phantom
#define FONT_PHAN "*FONTPHAN.FF" // Phantom only
enum SelectionMode {
SELMODE_UNSELECTED = 0, SELMODE_HIGHLIGHTED = 1, SELMODE_SELECTED = 2
};
class MADSEngine;
class Font {
@ -77,7 +81,7 @@ public:
virtual ~Font();
void setColors(uint8 v1, uint8 v2, uint8 v3, uint8 v4);
void setColorMode(int mode);
void setColorMode(SelectionMode mode);
int maxWidth() const { return _maxWidth; }
int getWidth(const Common::String &msg, int spaceWidth = -1);

View File

@ -575,7 +575,7 @@ void ScreenObjects::elementHighlighted() {
if (currentPos.x > bounds.left)
newIndex = idx;
} else {
if (currentPos.x > bounds.right)
if (currentPos.x < bounds.right)
newIndex = idx;
}
}

View File

@ -331,10 +331,10 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
case CAT_ACTION:
font = _vm->_font->getFont(FONT_INTERFACE);
vocabId = scene._verbList[id]._id;
if (_highlightedActionIndex) {
_vm->_font->setColorMode(1);
if (id == _highlightedActionIndex) {
_vm->_font->setColorMode(SELMODE_HIGHLIGHTED);
} else {
_vm->_font->setColorMode(id == _selectedActionIndex ? 2 : 0);
_vm->_font->setColorMode(id == _selectedActionIndex ? SELMODE_SELECTED : SELMODE_UNSELECTED);
}
vocabStr = scene.getVocab(vocabId);
vocabStr.setChar(toupper(vocabStr[0]), 0);
@ -344,10 +344,10 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
case CAT_INV_LIST:
font = _vm->_font->getFont(FONT_INTERFACE);
vocabId = _vm->_game->_objects.getItem(id)._descId;
if (_v1C == id) {
_vm->_font->setColorMode(1);
if (id == _v1C) {
_vm->_font->setColorMode(SELMODE_HIGHLIGHTED);
} else {
_vm->_font->setColorMode(id == _selectedInvIndex ? 2 : 0);
_vm->_font->setColorMode(id == _selectedInvIndex ? SELMODE_SELECTED : SELMODE_UNSELECTED);
vocabStr = scene.getVocab(vocabId);
vocabStr.setChar(toupper(vocabStr[0]), 0);
font->writeString(this, vocabStr, Common::Point(bounds.left, bounds.top));
@ -378,16 +378,17 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
break;
}
font->setColorMode((id == 4) || (_scrollerY == 3) ? 1 : 0);
font->setColorMode((id == 4) || (_scrollerY == 3) ? SELMODE_HIGHLIGHTED : SELMODE_UNSELECTED);
font->writeString(this, vocabStr, Common::Point(bounds.left, bounds.top));
break;
default:
// Item specific verbs
font = _vm->_font->getFont(FONT_INTERFACE);
vocabId = _vm->_game->_objects.getItem(_selectedInvIndex)._vocabList[id]._vocabId;
if (_v1E == id) {
_vm->_font->setColorMode(1);
if (id == _v1E) {
_vm->_font->setColorMode(SELMODE_HIGHLIGHTED);
} else {
_vm->_font->setColorMode(id == _selectedInvIndex ? 2 : 0);
_vm->_font->setColorMode(id == _selectedInvIndex ? SELMODE_SELECTED : SELMODE_UNSELECTED);
vocabStr = scene.getVocab(vocabId);
vocabStr.setChar(toupper(vocabStr[0]), 0);
font->writeString(this, vocabStr, Common::Point(bounds.left, bounds.top));