diff options
author | uruk | 2013-09-04 20:57:25 +0200 |
---|---|---|
committer | uruk | 2013-09-04 20:57:25 +0200 |
commit | 90494e01fd89d9e5d7ea33e31664173590e0e250 (patch) | |
tree | 599189d664f5957aa57fe2a86621190be38e6d1a /engines | |
parent | 247bf3ca26a5e348f2a0c3cc584766a69a1472de (diff) | |
download | scummvm-rg350-90494e01fd89d9e5d7ea33e31664173590e0e250.tar.gz scummvm-rg350-90494e01fd89d9e5d7ea33e31664173590e0e250.tar.bz2 scummvm-rg350-90494e01fd89d9e5d7ea33e31664173590e0e250.zip |
AVALANCHE: Do renaming/refactoring in Acci, Avalanche and Dropdown. Unify drawing of menus' text in Dropdown in a single function: drawMenuText().
Diffstat (limited to 'engines')
-rw-r--r-- | engines/avalanche/acci2.cpp | 2 | ||||
-rw-r--r-- | engines/avalanche/acci2.h | 2 | ||||
-rw-r--r-- | engines/avalanche/avalanche.cpp | 2 | ||||
-rw-r--r-- | engines/avalanche/avalanche.h | 2 | ||||
-rw-r--r-- | engines/avalanche/dropdown2.cpp | 94 | ||||
-rw-r--r-- | engines/avalanche/dropdown2.h | 15 |
6 files changed, 33 insertions, 84 deletions
diff --git a/engines/avalanche/acci2.cpp b/engines/avalanche/acci2.cpp index 01c7d9a1a4..2123471fa3 100644 --- a/engines/avalanche/acci2.cpp +++ b/engines/avalanche/acci2.cpp @@ -46,8 +46,6 @@ #include <cstring> #include <cmath> - - namespace Avalanche { const Acci::VocabEntry Acci::kVocabulary[kParserWordsNum] = { diff --git a/engines/avalanche/acci2.h b/engines/avalanche/acci2.h index d881eab222..2f036630c4 100644 --- a/engines/avalanche/acci2.h +++ b/engines/avalanche/acci2.h @@ -33,8 +33,6 @@ #include "common/scummsys.h" #include "common/str.h" - - namespace Avalanche { class AvalancheEngine; diff --git a/engines/avalanche/avalanche.cpp b/engines/avalanche/avalanche.cpp index c82c83948a..b99090cbc5 100644 --- a/engines/avalanche/avalanche.cpp +++ b/engines/avalanche/avalanche.cpp @@ -41,8 +41,6 @@ #include "gui/saveload.h" #include "graphics/thumbnail.h" - - namespace Avalanche { AvalancheEngine *AvalancheEngine::s_Engine = 0; diff --git a/engines/avalanche/avalanche.h b/engines/avalanche/avalanche.h index 63f654f550..ddedb5a787 100644 --- a/engines/avalanche/avalanche.h +++ b/engines/avalanche/avalanche.h @@ -56,8 +56,6 @@ #include "graphics/cursorman.h" - - namespace Common { class RandomSource; } diff --git a/engines/avalanche/dropdown2.cpp b/engines/avalanche/dropdown2.cpp index e814ba846c..54727e7b8c 100644 --- a/engines/avalanche/dropdown2.cpp +++ b/engines/avalanche/dropdown2.cpp @@ -30,7 +30,6 @@ #include "avalanche/avalanche.h" #include "avalanche/dropdown2.h" - #include "avalanche/lucerna2.h" #include "avalanche/gyro2.h" #include "avalanche/acci2.h" @@ -39,8 +38,6 @@ #include "common/textconsole.h" - - namespace Avalanche { void HeadType::init(char trig, char altTrig, Common::String title, byte pos, DropdownFunc setupFunc, DropdownFunc chooseFunc, Dropdown *dr) { @@ -58,7 +55,7 @@ void HeadType::init(char trig, char altTrig, Common::String title, byte pos, Dro void HeadType::draw() { CursorMan.showMouse(false); - _dr->drawMenuItem(_xpos, 1, _trigger, _title, true); + _dr->drawMenuText(_xpos, 1, _trigger, _title, true, false); CursorMan.showMouse(true); } @@ -69,7 +66,7 @@ void HeadType::highlight() { //setactivepage(cp); warning("STUB: Dropdown::headytpe::highlight()"); - _dr->drawHighlightedMenuItem(_xpos, 1, _trigger, _title, true); + _dr->drawMenuText(_xpos, 1, _trigger, _title, true, true); _dr->_activeMenuItem._left = _xpos; _dr->_activeMenuItem._activeNow = true; @@ -122,15 +119,12 @@ void MenuItem::displayOption(byte y, bool highlit) { backgroundColor = 7; _dr->_vm->_graphics->_surface.fillRect(Common::Rect((_flx1 + 1) * 8, 3 + (y + 1) * 10, (_flx2 + 1) * 8, 13 + (y + 1) * 10), backgroundColor); - Common::String data = _options[y]._title; - while (data.size() + _options[y]._shortcut.size() < _width) - data += ' '; // Pad _options[y] with spaces. - data += _options[y]._shortcut; + Common::String text = _options[y]._title; + while (text.size() + _options[y]._shortcut.size() < _width) + text += ' '; // Pad _options[y] with spaces. + text += _options[y]._shortcut; - if (highlit) - _dr->drawHighlightedMenuItem(_left, 4 + (y + 1) * 10, _options[y]._trigger, data, _options[y]._valid); - else - _dr->drawMenuItem(_left, 4 + (y + 1) * 10, _options[y]._trigger, data, _options[y]._valid); + _dr->drawMenuText(_left, 4 + (y + 1) * 10, _options[y]._trigger, text, _options[y]._valid, highlit); } void MenuItem::display() { @@ -163,7 +157,7 @@ void MenuItem::wipe() { //setactivepage(cp); CursorMan.showMouse(false); - _dr->drawMenuItem(_dr->_menuBar._menuItems[_dr->_activeMenuItem._activeNum]._xpos, 1, _dr->_menuBar._menuItems[_dr->_activeMenuItem._activeNum]._trigger, _dr->_menuBar._menuItems[_dr->_activeMenuItem._activeNum]._title, true); + _dr->drawMenuText(_dr->_menuBar._menuItems[_dr->_activeMenuItem._activeNum]._xpos, 1, _dr->_menuBar._menuItems[_dr->_activeMenuItem._activeNum]._trigger, _dr->_menuBar._menuItems[_dr->_activeMenuItem._activeNum]._title, true, false); _activeNow = false; _dr->_vm->_gyro->ddmnow = false; @@ -324,7 +318,17 @@ void Dropdown::findWhatYouCanDoWithIt() { } } -void Dropdown::drawMenuItem(int16 x, int16 y, char t, Common::String z, bool valid) { +void Dropdown::drawMenuText(int16 x, int16 y, char trigger, Common::String text, bool valid, bool highlighted) { + byte fontColor; + byte backgroundColor; + if (highlighted) { + fontColor = white; + backgroundColor = black; + } else { + fontColor = black; + backgroundColor = lightgray; + } + byte ander; if (valid) ander = 255; @@ -332,61 +336,28 @@ void Dropdown::drawMenuItem(int16 x, int16 y, char t, Common::String z, bool val ander = 170; fontType font; - for (byte fv = 0; fv < z.size(); fv++) - for (byte ff = 0; ff < 8; ff++) { - font[z[fv]][ff] = _vm->_gyro->characters[z[fv]][ff] & ander; - for (byte i = 0; i < 8; i++) - *(byte *)_vm->_graphics->_surface.getBasePtr(x * 8 + fv * 8 + i, y + ff) = lightgray; + for (byte i = 0; i < text.size(); i++) + for (byte j = 0; j < 8; j++) { + font[text[i]][j] = _vm->_gyro->characters[text[i]][j] & ander; // Set the font. + // And set the background of the text to the desired color. + for (byte k = 0; k < 8; k++) + *(byte *)_vm->_graphics->_surface.getBasePtr(x * 8 + i * 8 + k, y + j) = backgroundColor; } - _vm->_graphics->drawText(_vm->_graphics->_surface, z, font, 8, x * 8, y, black); + _vm->_graphics->drawText(_vm->_graphics->_surface, text, font, 8, x * 8, y, fontColor); // Underline the selected character. - if (! z.contains(t)) + if (!text.contains(trigger)) return; else { - byte fv; - for (fv = 0; z[fv] != t; fv++); // Search for the character in the string. + byte i; + for (i = 0; text[i] != trigger; i++); // Search for the character in the string. byte pixel = ander; for (byte bit = 0; bit < 8; bit++) { byte pixelBit = (pixel >> bit) & 1; if (pixelBit) - *_vm->_graphics->getPixel(x * 8 + fv * 8 + 7 - bit, y + 8) = black; - } - } - - _vm->_graphics->refreshScreen(); -} - -void Dropdown::drawHighlightedMenuItem(int16 x, int16 y, char t, Common::String z, bool valid) { - byte ander; - if (valid) - ander = 255; - else - ander = 170; - - fontType font; - for (byte fv = 0; fv < z.size(); fv++) - for (byte ff = 0; ff < 8; ff++) { - font[z[fv]][ff] = _vm->_gyro->characters[z[fv]][ff] & ander; // Set the font. - // And set the background of the text to black. - for (byte i = 0; i < 8; i++) - *(byte *)_vm->_graphics->_surface.getBasePtr(x * 8 + fv * 8 + i, y + ff) = black; - } - - _vm->_graphics->drawText(_vm->_graphics->_surface, z, font, 8, x * 8, y, white); - - // Underline the selected character. - if (z.contains(t)) { - byte fv; - for (fv = 0; z[fv] != t; fv++); // Search for the character in the string. - - byte pixel = ander; - for (byte bit = 0; bit < 8; bit++) { - byte pixelBit = (pixel >> bit) & 1; - if (pixelBit) - *_vm->_graphics->getPixel(x * 8 + fv * 8 + 7 - bit, y + 8) = white; + *_vm->_graphics->getPixel(x * 8 + i * 8 + 7 - bit, y + 8) = fontColor; } } @@ -441,7 +412,7 @@ void Dropdown::parseKey(char r, char re) { // _activeMenuItem.parseKey(r); // } //} - warning("STUB: Dropdown::parseKey()"); + warning("STUB: Dropdown::parseKey()"); // To be implemented properly later! Don't remove the comment above! } Common::String Dropdown::selectGender(byte x) { @@ -501,12 +472,11 @@ void Dropdown::setupMenuAction() { void Dropdown::setupMenuPeople() { if (!people.empty()) people.clear(); - byte here = _vm->_gyro->dna.room; _activeMenuItem.reset(); for (byte i = 150; i <= 178; i++) - if (_vm->_gyro->whereis[i - 150] == here) { + if (_vm->_gyro->whereis[i - 150] == _vm->_gyro->dna.room) { _activeMenuItem.setupOption(_vm->_gyro->getname(i), _vm->_gyro->getnamechar(i), "", true); people = people + i; } diff --git a/engines/avalanche/dropdown2.h b/engines/avalanche/dropdown2.h index 35b4b56283..8912e60a75 100644 --- a/engines/avalanche/dropdown2.h +++ b/engines/avalanche/dropdown2.h @@ -135,14 +135,10 @@ public: Common::String people; - - Dropdown(AvalancheEngine *vm); void parseKey(char r, char re); - void updateMenu(); - void setupMenu(); // Standard menu bar. private: @@ -156,20 +152,11 @@ private: static const byte kHighlightFontColor = white; static const byte kDisabledColor = darkgray; - - AvalancheEngine *_vm; - - Common::String selectGender(byte x); // Returns "im" for boys, and "er" for girls. - void findWhatYouCanDoWithIt(); - - void drawMenuItem(int16 x, int16 y, char t, Common::String z, bool valid); - - void drawHighlightedMenuItem(int16 x, int16 y, char t, Common::String z, bool valid); // Highlighted. TODO: It's too similar to chalk! Unify these two!!! - + void drawMenuText(int16 x, int16 y, char trigger, Common::String text, bool valid, bool highlighted); void bleep(); void setupMenuGame(); |