diff options
37 files changed, 408 insertions, 318 deletions
diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp index 1c28256778..72db1812be 100644 --- a/engines/xeen/combat.cpp +++ b/engines/xeen/combat.cpp @@ -136,12 +136,13 @@ void Combat::giveCharDamage(int damage, DamageType attackType, int charIndex) { Screen &screen = *_vm->_screen; Scripts &scripts = *_vm->_scripts; Sound &sound = *_vm->_sound; + Windows &windows = *_vm->_windows; int charIndex1 = charIndex + 1; int selectedIndex1 = 0; int selectedIndex2 = 0; bool breakFlag = false; - screen.closeWindows(); + windows.closeAll(); int idx = (int)party._activeParty.size(); if (!scripts._v2) { @@ -222,7 +223,7 @@ void Combat::giveCharDamage(int damage, DamageType attackType, int charIndex) { sound.playFX(fx); _powSprites.draw(screen, frame, Common::Point(Res.CHAR_FACES_X[selectedIndex1], 150)); - screen._windows[33].update(); + windows[33].update(); // Reduce damage if power shield active, and set it zero // if the damage amount has become negative.. you wouldn't @@ -266,6 +267,7 @@ void Combat::doCharDamage(Character &c, int charNum, int monsterDataIndex) { Party &party = *_vm->_party; Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; + Windows &windows = *_vm->_windows; MonsterStruct &monsterData = map._monsterData[monsterDataIndex]; // Attacked characters are automatically woken up @@ -321,7 +323,7 @@ void Combat::doCharDamage(Character &c, int charNum, int monsterDataIndex) { sound.playFX(fx); intf._charPowSprites.draw(screen, frame, Common::Point(Res.CHAR_FACES_X[charNum], 150)); - screen._windows[33].update(); + windows[33].update(); damage -= party._powerShield; if (damage > 0 && monsterData._specialAttack && !c.charSavingThrow(DT_PHYSICAL)) { diff --git a/engines/xeen/cutscenes.cpp b/engines/xeen/cutscenes.cpp index 3c49d12816..0627519ad8 100644 --- a/engines/xeen/cutscenes.cpp +++ b/engines/xeen/cutscenes.cpp @@ -36,6 +36,7 @@ void Cutscenes::resetSubtitles(uint lineNum, uint defaultSize) { void Cutscenes::showSubtitles(uint windowIndex) { Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; + Windows &windows = *_vm->_windows; if (sound._soundOn || _vm->shouldQuit()) { // Sound is on, so subtitles aren't needed @@ -62,7 +63,7 @@ void Cutscenes::showSubtitles(uint windowIndex) { _boxSprites->draw(screen, 0, Common::Point(36, 189)); // Write the subtitle line - screen._windows[windowIndex].writeString(_subtitleLine); + windows[windowIndex].writeString(_subtitleLine); } screen.update(); diff --git a/engines/xeen/dialogs.cpp b/engines/xeen/dialogs.cpp index 2f07b812f8..9141b89296 100644 --- a/engines/xeen/dialogs.cpp +++ b/engines/xeen/dialogs.cpp @@ -64,6 +64,7 @@ void ButtonContainer::addPartyButtons(XeenEngine *vm) { bool ButtonContainer::checkEvents(XeenEngine *vm) { EventsManager &events = *vm->_events; Screen &screen = *vm->_screen; + Windows &windows = *_vm->_windows; _buttonValue = 0; if (events._leftButton) { @@ -100,7 +101,7 @@ bool ButtonContainer::checkEvents(XeenEngine *vm) { if (_buttonValue) { // Check for a button matching the selected _buttonValue - Window &win = screen._windows[39]; + Window &win = windows[39]; for (uint btnIndex = 0; btnIndex < _buttons.size(); ++btnIndex) { UIButton &btn = _buttons[btnIndex]; if (btn._draw && btn._value == _buttonValue) { @@ -169,18 +170,19 @@ void CreditsScreen::show(XeenEngine *vm) { void CreditsScreen::execute() { Screen &screen = *_vm->_screen; + Windows &windows = *_vm->_windows; EventsManager &events = *_vm->_events; // Handle drawing the credits screen doScroll(true, false); - screen._windows[GAME_WINDOW].close(); + windows[GAME_WINDOW].close(); screen.loadBackground("marb.raw"); - screen._windows[0].writeString(Res.CREDITS); + windows[0].writeString(Res.CREDITS); doScroll(false, false); events.setCursor(0); - screen._windows[0].update(); + windows[0].update(); clearButtons(); // Wait for keypress @@ -193,8 +195,10 @@ void CreditsScreen::execute() { /*------------------------------------------------------------------------*/ void PleaseWait::show(XeenEngine *vm) { + Windows &windows = *vm->_windows; + Window &w = windows[9]; + if (vm->_mode != MODE_0) { - Window &w = vm->_screen->_windows[9]; w.open(); w.writeString(Res.PLEASE_WAIT); w.update(); diff --git a/engines/xeen/dialogs_automap.cpp b/engines/xeen/dialogs_automap.cpp index 079b3e65d7..0138f3e340 100644 --- a/engines/xeen/dialogs_automap.cpp +++ b/engines/xeen/dialogs_automap.cpp @@ -39,6 +39,7 @@ void AutoMapDialog::execute() { Interface &intf = *_vm->_interface; Map &map = *_vm->_map; Party &party = *_vm->_party; + Windows &windows = *_vm->_windows; int frame2 = intf._overallFrame * 2; bool frameEndFlag = false; @@ -72,7 +73,7 @@ void AutoMapDialog::execute() { arrowPt.y = 69; } - screen._windows[5].open(); + windows[5].open(); // MazeData &mazeData = map.mazeDataCurrent(); bool drawFlag = true; int v; @@ -81,7 +82,7 @@ void AutoMapDialog::execute() { do { if (drawFlag) intf.draw3d(false); - screen._windows[5].writeString("\n"); + windows[5].writeString("\n"); if (map._isOutdoors) { // Draw outdoors map @@ -396,7 +397,7 @@ void AutoMapDialog::execute() { } } - screen._windows[5].frame(); + windows[5].frame(); if (!map._isOutdoors) { map._tileSprites.draw(screen, 52, Common::Point(76, 30)); } else if (frameEndFlag) { @@ -410,18 +411,18 @@ void AutoMapDialog::execute() { events.updateGameCounter(); } - screen._windows[5].writeString(Common::String::format(Res.MAP_TEXT, + windows[5].writeString(Common::String::format(Res.MAP_TEXT, map._mazeName.c_str(), party._mazePosition.x, party._mazePosition.y, Res.DIRECTION_TEXT[party._mazeDirection])); - screen._windows[5].update(); - screen._windows[3].update(); + windows[5].update(); + windows[3].update(); events.pollEvents(); drawFlag = false; } while (!_vm->shouldQuit() && !events.isKeyMousePressed()); events.clearEvents(); - screen._windows[5].close(); + windows[5].close(); } } // End of namespace Xeen diff --git a/engines/xeen/dialogs_char_info.cpp b/engines/xeen/dialogs_char_info.cpp index 619382bb84..36ed32a2e8 100644 --- a/engines/xeen/dialogs_char_info.cpp +++ b/engines/xeen/dialogs_char_info.cpp @@ -41,6 +41,7 @@ void CharacterInfo::execute(int charIndex) { Interface &intf = *_vm->_interface; Party &party = *_vm->_party; Screen &screen = *_vm->_screen; + Windows &windows = *_vm->_windows; bool redrawFlag = true; Mode oldMode = _vm->_mode; @@ -50,7 +51,7 @@ void CharacterInfo::execute(int charIndex) { Character *c = (oldMode != MODE_COMBAT) ? &party._activeParty[charIndex] : combat._combatParty[charIndex]; intf.highlightChar(charIndex); - Window &w = screen._windows[24]; + Window &w = windows[24]; w.open(); do { @@ -342,6 +343,7 @@ bool CharacterInfo::expandStat(int attrib, const Character &c) { Common::Rect bounds(STAT_POS[0][attrib], STAT_POS[1][attrib], STAT_POS[0][attrib] + 143, STAT_POS[1][attrib] + 52); Party &party = *_vm->_party; + Windows &windows = *_vm->_windows; uint stat1, stat2; uint idx; Common::String msg; @@ -551,7 +553,7 @@ bool CharacterInfo::expandStat(int attrib, const Character &c) { } // Write the data for the stat display - Window &w = _vm->_screen->_windows[28]; + Window &w = windows[28]; w.setBounds(bounds); w.open(); w.writeString(msg); diff --git a/engines/xeen/dialogs_char_info.h b/engines/xeen/dialogs_char_info.h index cddd4ec89c..5f538700f9 100644 --- a/engines/xeen/dialogs_char_info.h +++ b/engines/xeen/dialogs_char_info.h @@ -25,7 +25,7 @@ #include "xeen/dialogs.h" #include "xeen/party.h" -#include "xeen/screen.h" +#include "xeen/window.h" namespace Xeen { diff --git a/engines/xeen/dialogs_dismiss.cpp b/engines/xeen/dialogs_dismiss.cpp index 58936bdc39..9eb47bdcac 100644 --- a/engines/xeen/dialogs_dismiss.cpp +++ b/engines/xeen/dialogs_dismiss.cpp @@ -38,9 +38,10 @@ void Dismiss::execute() { EventsManager &events = *_vm->_events; Interface &intf = *_vm->_interface; Party &party = *_vm->_party; + Windows &windows = *_vm->_windows; loadButtons(); - Window &w = screen._windows[31]; + Window &w = windows[31]; w.open(); _iconSprites.draw(w, 0, Common::Point(225, 120)); w.update(); @@ -53,7 +54,7 @@ void Dismiss::execute() { w.frame(); w.writeString("\r"); _iconSprites.draw(w, 0, Common::Point(225, 120)); - screen._windows[3].update(); + windows[3].update(); w.update(); do { diff --git a/engines/xeen/dialogs_error.cpp b/engines/xeen/dialogs_error.cpp index cd29433820..d8697b05d9 100644 --- a/engines/xeen/dialogs_error.cpp +++ b/engines/xeen/dialogs_error.cpp @@ -36,7 +36,8 @@ void ErrorDialog::show(XeenEngine *vm, const Common::String &msg, ErrorWaitType void ErrorDialog::execute(const Common::String &msg, ErrorWaitType waitType) { Screen &screen = *_vm->_screen; EventsManager &events = *_vm->_events; - Window &w = screen._windows[6]; + Windows &windows = *_vm->_windows; + Window &w = windows[6]; w.open(); w.writeString(msg); @@ -94,7 +95,8 @@ void CantCast::execute(int spellId, int componentNum) { EventsManager &events = *_vm->_events; Sound &sound = *_vm->_sound; Spells &spells = *_vm->_spells; - Window &w = _vm->_screen->_windows[6]; + Windows &windows = *_vm->_windows; + Window &w = windows[6]; Mode oldMode = _vm->_mode; _vm->_mode = MODE_FF; diff --git a/engines/xeen/dialogs_exchange.cpp b/engines/xeen/dialogs_exchange.cpp index 03195523e4..d8b4ba27ff 100644 --- a/engines/xeen/dialogs_exchange.cpp +++ b/engines/xeen/dialogs_exchange.cpp @@ -37,9 +37,10 @@ void ExchangeDialog::execute(Character *&c, int &charIndex) { EventsManager &events = *_vm->_events; Interface &intf = *_vm->_interface; Party &party = *_vm->_party; + Windows &windows = *_vm->_windows; loadButtons(); - Window &w = screen._windows[31]; + Window &w = windows[31]; w.open(); w.writeString(Res.EXCHANGE_WITH_WHOM); _iconSprites.draw(w, 0, Common::Point(225, 120)); diff --git a/engines/xeen/dialogs_info.cpp b/engines/xeen/dialogs_info.cpp index 5d28df355a..2d32ec4de5 100644 --- a/engines/xeen/dialogs_info.cpp +++ b/engines/xeen/dialogs_info.cpp @@ -33,10 +33,10 @@ void InfoDialog::show(XeenEngine *vm) { } void InfoDialog::execute() { - Screen &screen = *_vm->_screen; EventsManager &events = *_vm->_events; Interface &intf = *_vm->_interface; Party &party = *_vm->_party; + Windows &windows = *_vm->_windows; protectionText(); Common::String statusText = ""; @@ -61,7 +61,7 @@ void InfoDialog::execute() { party._minutes % 60, (hour > 11) ? 'p' : 'a', party._day, party._year, statusText.c_str()); - Window &w = screen._windows[28]; + Window &w = windows[28]; w.setBounds(Common::Rect(88, 20, 248, 112)); w.open(); diff --git a/engines/xeen/dialogs_input.cpp b/engines/xeen/dialogs_input.cpp index b31a72b9b0..c18b964e73 100644 --- a/engines/xeen/dialogs_input.cpp +++ b/engines/xeen/dialogs_input.cpp @@ -75,14 +75,14 @@ int Input::getString(Common::String &line, uint maxLen, int maxWidth, bool isNum Common::KeyCode Input::waitForKey(const Common::String &msg) { EventsManager &events = *_vm->_events; Interface &intf = *_vm->_interface; - Screen &screen = *_vm->_screen; + Windows &windows = *_vm->_windows; bool oldUpDoorText = intf._upDoorText; byte oldTillMove = intf._tillMove; intf._upDoorText = false; intf._tillMove = 0; - bool flag = !_vm->_startupWindowActive && !screen._windows[25]._enabled + bool flag = !_vm->_startupWindowActive && !windows[25]._enabled && _vm->_mode != MODE_FF && _vm->_mode != MODE_17; Common::KeyCode ch = Common::KEYCODE_INVALID; @@ -96,7 +96,7 @@ Common::KeyCode Input::waitForKey(const Common::String &msg) { _window->update(); if (flag) - screen._windows[3].update(); + windows[3].update(); events.wait(1); @@ -135,7 +135,7 @@ void Input::animateCursor() { /*------------------------------------------------------------------------*/ -StringInput::StringInput(XeenEngine *vm): Input(vm, &vm->_screen->_windows[6]) { +StringInput::StringInput(XeenEngine *vm): Input(vm, &(*vm->_windows)[6]) { } int StringInput::show(XeenEngine *vm, bool type, const Common::String &msg1, @@ -150,9 +150,9 @@ int StringInput::show(XeenEngine *vm, bool type, const Common::String &msg1, int StringInput::execute(bool type, const Common::String &expected, const Common::String &title, int opcode) { Interface &intf = *_vm->_interface; - Screen &screen = *_vm->_screen; Scripts &scripts = *_vm->_scripts; - Window &w = screen._windows[6]; + Windows &windows = *_vm->_windows; + Window &w = windows[6]; Sound &sound = *_vm->_sound; int result = 0; @@ -193,7 +193,7 @@ int StringInput::execute(bool type, const Common::String &expected, /*------------------------------------------------------------------------*/ -NumericInput::NumericInput(XeenEngine *vm, int window) : Input(vm, &vm->_screen->_windows[window]) { +NumericInput::NumericInput(XeenEngine *vm, int window) : Input(vm, &(*vm->_windows)[window]) { } int NumericInput::show(XeenEngine *vm, int window, int maxLength, int maxWidth) { @@ -229,6 +229,7 @@ int Choose123::execute(int numOptions) { Interface &intf = *_vm->_interface; Screen &screen = *_vm->_screen; Town &town = *_vm->_town; + Windows &windows = *_vm->_windows; Mode oldMode = _vm->_mode; _vm->_mode = MODE_DIALOG_123; @@ -236,7 +237,7 @@ int Choose123::execute(int numOptions) { loadButtons(numOptions); _iconSprites.draw(screen, 7, Common::Point(232, 74)); drawButtons(&screen); - screen._windows[34].update(); + windows[34].update(); int result = -1; while (result == -1) { @@ -301,8 +302,8 @@ int HowMuch::show(XeenEngine *vm) { } int HowMuch::execute() { - Screen &screen = *_vm->_screen; - Window &w = screen._windows[6]; + Windows &windows = *_vm->_windows; + Window &w = windows[6]; Common::String num; w.open(); diff --git a/engines/xeen/dialogs_items.cpp b/engines/xeen/dialogs_items.cpp index 1fcea012d1..41ba1e635e 100644 --- a/engines/xeen/dialogs_items.cpp +++ b/engines/xeen/dialogs_items.cpp @@ -42,6 +42,7 @@ Character *ItemsDialog::execute(Character *c, ItemsMode mode) { Interface &intf = *_vm->_interface; Party &party = *_vm->_party; Screen &screen = *_vm->_screen; + Windows &windows = *_vm->_windows; Character *startingChar = c; ItemCategory category = mode == ITEMMODE_RECHARGE || mode == ITEMMODE_COMBAT ? @@ -58,8 +59,8 @@ Character *ItemsDialog::execute(Character *c, ItemsMode mode) { events.setCursor(0); loadButtons(mode, c); - screen._windows[29].open(); - screen._windows[30].open(); + windows[29].open(); + windows[30].open(); enum { REDRAW_NONE, REDRAW_TEXT, REDRAW_FULL } redrawFlag = REDRAW_FULL; for (;;) { @@ -98,7 +99,7 @@ Character *ItemsDialog::execute(Character *c, ItemsMode mode) { msg = Common::String::format(Res.ITEMS_DIALOG_TEXT2, Res.BTN_GOLD); } - screen._windows[29].writeString(msg); + windows[29].writeString(msg); drawButtons(&screen); Common::fill(&arr[0], &arr[40], 0); @@ -213,7 +214,7 @@ Character *ItemsDialog::execute(Character *c, ItemsMode mode) { switch (mode) { case ITEMMODE_CHAR_INFO: case ITEMMODE_8: - screen._windows[30].writeString(Common::String::format(Res.X_FOR_THE_Y, + windows[30].writeString(Common::String::format(Res.X_FOR_THE_Y, category == CATEGORY_MISC ? "\x3l" : "\x3c", Res.CATEGORY_NAMES[category], c->_name.c_str(), Res.CLASS_NAMES[c->_class], category == CATEGORY_MISC ? Res.FMT_CHARGES : " ", @@ -224,7 +225,7 @@ Character *ItemsDialog::execute(Character *c, ItemsMode mode) { break; case ITEMMODE_BLACKSMITH: - screen._windows[30].writeString(Common::String::format(Res.AVAILABLE_GOLD_COST, + windows[30].writeString(Common::String::format(Res.AVAILABLE_GOLD_COST, Res.CATEGORY_NAMES[category], party._gold, lines[0].c_str(), lines[1].c_str(), lines[2].c_str(), lines[3].c_str(), lines[4].c_str(), lines[5].c_str(), lines[6].c_str(), lines[7].c_str(), @@ -238,7 +239,7 @@ Character *ItemsDialog::execute(Character *c, ItemsMode mode) { case ITEMMODE_REPAIR: case ITEMMODE_IDENTIFY: case ITEMMODE_TO_GOLD: - screen._windows[30].writeString(Common::String::format(Res.X_FOR_Y, + windows[30].writeString(Common::String::format(Res.X_FOR_Y, Res.CATEGORY_NAMES[category], startingChar->_name.c_str(), (mode == ITEMMODE_RECHARGE || mode == ITEMMODE_ENCHANT) ? Res.CHARGES : Res.COST, lines[0].c_str(), lines[1].c_str(), lines[2].c_str(), lines[3].c_str(), @@ -249,7 +250,7 @@ Character *ItemsDialog::execute(Character *c, ItemsMode mode) { case ITEMMODE_3: case ITEMMODE_5: - screen._windows[30].writeString(Common::String::format(Res.X_FOR_Y_GOLD, + windows[30].writeString(Common::String::format(Res.X_FOR_Y_GOLD, Res.CATEGORY_NAMES[category], c->_name.c_str(), party._gold, Res.CHARGES, lines[0].c_str(), lines[1].c_str(), lines[2].c_str(), lines[3].c_str(), lines[4].c_str(), lines[5].c_str(), lines[6].c_str(), lines[7].c_str(), @@ -262,8 +263,8 @@ Character *ItemsDialog::execute(Character *c, ItemsMode mode) { } // Draw the glyphs for the items - screen._windows[0].drawList(_itemsDrawList, INV_ITEMS_TOTAL); - screen._windows[0].update(); + windows[0].drawList(_itemsDrawList, INV_ITEMS_TOTAL); + windows[0].update(); } redrawFlag = REDRAW_NONE; @@ -296,8 +297,8 @@ Character *ItemsDialog::execute(Character *c, ItemsMode mode) { break; } else if (result == 2) { // Close dialogs and finish dialog with original starting character - screen._windows[30].close(); - screen._windows[29].close(); + windows[30].close(); + windows[29].close(); c = startingChar; break; } @@ -778,6 +779,7 @@ int ItemsDialog::doItemOptions(Character &c, int actionIndex, int itemIndex, Ite Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; Spells &spells = *_vm->_spells; + Windows &windows = *_vm->_windows; bool isDarkCc = _vm->_files->_isDarkCc; XeenItem *itemCategories[4] = { &c._weapons[0], &c._armor[0], &c._accessories[0], &c._misc[0] }; @@ -786,7 +788,7 @@ int ItemsDialog::doItemOptions(Character &c, int actionIndex, int itemIndex, Ite // Inventory is empty return category == CATEGORY_MISC ? 0 : 2; - Window &w = screen._windows[11]; + Window &w = windows[11]; SpriteResource escSprites; if (itemIndex < 0 || itemIndex > 8) { saveButtons(); @@ -872,9 +874,9 @@ int ItemsDialog::doItemOptions(Character &c, int actionIndex, int itemIndex, Ite i._bonusFlags = charges; _oldCharacter = &c; - screen._windows[30].close(); - screen._windows[29].close(); - screen._windows[24].close(); + windows[30].close(); + windows[29].close(); + windows[24].close(); spells.castItemSpell(i._id); if (!charges) { @@ -1009,7 +1011,7 @@ int ItemsDialog::doItemOptions(Character &c, int actionIndex, int itemIndex, Ite Common::String str = Common::String::format(Res.IDENTIFY_ITEM_MSG, desc.c_str(), details.c_str()); - Window &win = screen._windows[14]; + Window &win = windows[14]; win.open(); win.writeString(str); win.update(); diff --git a/engines/xeen/dialogs_items.h b/engines/xeen/dialogs_items.h index cfa6818843..f35ef883b8 100644 --- a/engines/xeen/dialogs_items.h +++ b/engines/xeen/dialogs_items.h @@ -25,7 +25,7 @@ #include "xeen/dialogs.h" #include "xeen/party.h" -#include "xeen/screen.h" +#include "xeen/window.h" namespace Xeen { diff --git a/engines/xeen/dialogs_party.cpp b/engines/xeen/dialogs_party.cpp index 3dc47d1e9b..02be827078 100644 --- a/engines/xeen/dialogs_party.cpp +++ b/engines/xeen/dialogs_party.cpp @@ -49,6 +49,7 @@ void PartyDialog::execute() { Party &party = *_vm->_party; Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; + Windows &windows = *_vm->_windows; bool modeFlag = false; int startingChar = 0; @@ -69,7 +70,7 @@ void PartyDialog::execute() { _charList.push_back(i); } - Window &w = screen._windows[11]; + Window &w = windows[11]; w.open(); setupFaces(startingChar, false); w.writeString(Common::String::format(Res.PARTY_DIALOG_TEXT, _partyDetails.c_str())); @@ -84,13 +85,13 @@ void PartyDialog::execute() { screen.loadPalette("mm4.pal"); if (modeFlag) { - screen._windows[0].update(); + windows[0].update(); events.setCursor(0); screen.fadeIn(); } else { if (_vm->getGameID() == GType_DarkSide) { screen.fadeOut(); - screen._windows[0].update(); + windows[0].update(); } doScroll(false, false); @@ -353,7 +354,8 @@ void PartyDialog::setupFaces(int firstDisplayChar, bool updateFlag) { } void PartyDialog::startingCharChanged(int firstDisplayChar) { - Window &w = _vm->_screen->_windows[11]; + Windows &windows = *_vm->_windows; + Window &w = windows[11]; setupFaces(firstDisplayChar, true); w.writeString(Common::String::format(Res.PARTY_DIALOG_TEXT, _partyDetails.c_str())); @@ -373,7 +375,8 @@ void PartyDialog::createChar() { EventsManager &events = *_vm->_events; Party &party = *_vm->_party; Screen &screen = *_vm->_screen; - Window &w = screen._windows[0]; + Windows &windows = *_vm->_windows; + Window &w = windows[0]; SpriteResource dice, icons; Common::Array<int> freeCharList; int classId; @@ -694,7 +697,8 @@ int PartyDialog::selectCharacter(bool isDelete, int firstDisplayChar) { EventsManager &events = *_vm->_events; Party &party = *_vm->_party; Screen &screen = *_vm->_screen; - Window &w = screen._windows[28]; + Windows &windows = *_vm->_windows; + Window &w = windows[28]; SpriteResource iconSprites; iconSprites.load("esc.icn"); @@ -850,7 +854,8 @@ int PartyDialog::newCharDetails(const uint attribs[TOTAL_ATTRIBUTES], } void PartyDialog::printSelectionArrow(SpriteResource &icons, int selectedClass) { - Window &w = _vm->_screen->_windows[0]; + Windows &windows = *_vm->_windows; + Window &w = windows[0]; icons.draw(w, 61, Common::Point(220, 19)); icons.draw(w, 63, Common::Point(220, selectedClass * 11 + 21)); w.update(); @@ -858,7 +863,8 @@ void PartyDialog::printSelectionArrow(SpriteResource &icons, int selectedClass) void PartyDialog::drawDice(SpriteResource &dice) { EventsManager &events = *_vm->_events; - Window &w = _vm->_screen->_windows[32]; + Windows &windows = *_vm->_windows; + Window &w = windows[32]; dice.draw(w, 7, Common::Point(12, 11)); for (int diceNum = 0; diceNum < 3; ++diceNum) { @@ -894,6 +900,7 @@ void PartyDialog::drawDice(SpriteResource &dice) { int PartyDialog::exchangeAttribute(int srcAttr) { EventsManager &events = *_vm->_events; Screen &screen = *_vm->_screen; + Windows &windows = *_vm->_windows; SpriteResource icons; icons.load("create2.icn"); @@ -907,7 +914,7 @@ int PartyDialog::exchangeAttribute(int srcAttr) { addButton(Common::Rect(168, 139, 192, 159), Common::KEYCODE_a); addButton(Common::Rect(168, 163, 192, 183), Common::KEYCODE_l); - Window &w = screen._windows[26]; + Window &w = windows[26]; w.open(); w.writeString(Common::String::format(Res.EXCHANGE_ATTR_WITH, Res.STAT_NAMES[srcAttr - 1])); icons.draw(w, 0, Common::Point(118, 58)); @@ -976,7 +983,8 @@ bool PartyDialog::saveCharacter(Character &c, int classId, Map &map = *_vm->_map; Party &party = *_vm->_party; Screen &screen = *_vm->_screen; - Window &w = screen._windows[6]; + Windows &windows = *_vm->_windows; + Window &w = windows[6]; Common::String name; int result; bool isDarkCc = _vm->_files->_isDarkCc; diff --git a/engines/xeen/dialogs_query.cpp b/engines/xeen/dialogs_query.cpp index 76083a8170..bd20da262b 100644 --- a/engines/xeen/dialogs_query.cpp +++ b/engines/xeen/dialogs_query.cpp @@ -36,6 +36,7 @@ bool Confirm::show(XeenEngine *vm, const Common::String &msg, int mode) { bool Confirm::execute(const Common::String &msg, int mode) { Screen &screen = *_vm->_screen; EventsManager &events = *_vm->_events; + Windows &windows = *_vm->_windows; SpriteResource confirmSprites; bool result = false; @@ -43,7 +44,7 @@ bool Confirm::execute(const Common::String &msg, int mode) { addButton(Common::Rect(129, 112, 153, 122), Common::KEYCODE_y, &confirmSprites); addButton(Common::Rect(185, 112, 209, 122), Common::KEYCODE_n, &confirmSprites); - Window &w = screen._windows[mode ? 22 : 21]; + Window &w = windows[mode ? 22 : 21]; w.open(); if (!mode) { @@ -104,8 +105,8 @@ bool YesNo::execute(bool type, bool townFlag) { Resources &res = *_vm->_resources; Screen &screen = *_vm->_screen; Town &town = *_vm->_town; + Windows &windows = *_vm->_windows; SpriteResource confirmSprites; - //int numFrames; bool result = false; Mode oldMode = _vm->_mode; @@ -116,7 +117,7 @@ bool YesNo::execute(bool type, bool townFlag) { res._globalSprites.draw(screen, 7, Common::Point(232, 74)); confirmSprites.draw(screen, 0, Common::Point(235, 75)); confirmSprites.draw(screen, 2, Common::Point(260, 75)); - screen._windows[34].update(); + windows[34].update(); addButton(Common::Rect(235, 75, 259, 95), Common::KEYCODE_y, &confirmSprites); addButton(Common::Rect(260, 75, 284, 95), Common::KEYCODE_n, &confirmSprites); diff --git a/engines/xeen/dialogs_quests.cpp b/engines/xeen/dialogs_quests.cpp index 0ca9f9d4b5..75b44669c8 100644 --- a/engines/xeen/dialogs_quests.cpp +++ b/engines/xeen/dialogs_quests.cpp @@ -40,6 +40,7 @@ void Quests::execute() { EventsManager &events = *_vm->_events; Party &party = *_vm->_party; Screen &screen = *_vm->_screen; + Windows &windows = *_vm->_windows; Mode oldMode = _vm->_mode; int count = 0; bool headerShown = false; @@ -50,15 +51,15 @@ void Quests::execute() { enum { QUEST_ITEMS, CURRENT_QUESTS, AUTO_NOTES } mode = QUEST_ITEMS; bool windowFlag; - if (screen._windows[29]._enabled) { + if (windows[29]._enabled) { windowFlag = false; } else { - screen._windows[29].open(); - screen._windows[30].open(); + windows[29].open(); + windows[30].open(); windowFlag = true; } - screen._windows[29].writeString(Res.QUESTS_DIALOG_TEXT); + windows[29].writeString(Res.QUESTS_DIALOG_TEXT); drawButtons(&screen); while (!_vm->shouldQuit()) { @@ -102,9 +103,9 @@ void Quests::execute() { } if (count == 0) { - screen._windows[30].writeString(Res.NO_QUEST_ITEMS); + windows[30].writeString(Res.NO_QUEST_ITEMS); } else { - screen._windows[30].writeString(Common::String::format(Res.QUEST_ITEMS_DATA, + windows[30].writeString(Common::String::format(Res.QUEST_ITEMS_DATA, lines[topRow].c_str(), lines[topRow + 1].c_str(), lines[topRow + 2].c_str(), lines[topRow + 3].c_str(), lines[topRow + 4].c_str(), lines[topRow + 5].c_str(), @@ -137,7 +138,7 @@ void Quests::execute() { if (count == 0) lines[1] = Res.NO_CURRENT_QUESTS; - screen._windows[30].writeString(Common::String::format(Res.CURRENT_QUESTS_DATA, + windows[30].writeString(Common::String::format(Res.CURRENT_QUESTS_DATA, lines[topRow].c_str(), lines[topRow + 1].c_str(), lines[topRow + 2].c_str())); break; @@ -164,7 +165,7 @@ void Quests::execute() { if (count == 0) lines[1] = Res.NO_AUTO_NOTES; - screen._windows[30].writeString(Common::String::format(Res.AUTO_NOTES_DATA, + windows[30].writeString(Common::String::format(Res.AUTO_NOTES_DATA, lines[topRow].c_str(), lines[topRow + 1].c_str(), lines[topRow + 2].c_str(), lines[topRow + 3].c_str(), lines[topRow + 4].c_str(), lines[topRow + 5].c_str(), @@ -174,8 +175,8 @@ void Quests::execute() { break; } - screen._windows[30].writeString("\v000\t000"); - screen._windows[24].update(); + windows[30].writeString("\v000\t000"); + windows[24].update(); // Key handling _buttonValue = 0; @@ -226,8 +227,8 @@ void Quests::execute() { } if (windowFlag) { - screen._windows[30].close(); - screen._windows[29].close(); + windows[30].close(); + windows[29].close(); } _vm->_mode = oldMode; } diff --git a/engines/xeen/dialogs_quick_ref.cpp b/engines/xeen/dialogs_quick_ref.cpp index eb516959d6..118db09e84 100644 --- a/engines/xeen/dialogs_quick_ref.cpp +++ b/engines/xeen/dialogs_quick_ref.cpp @@ -37,6 +37,7 @@ void QuickReferenceDialog::execute() { EventsManager &events = *_vm->_events; Party &party = *_vm->_party; Screen &screen = *_vm->_screen; + Windows &windows = *_vm->_windows; Common::String lines[8]; events.setCursor(0); @@ -68,7 +69,7 @@ void QuickReferenceDialog::execute() { food, food == 1 ? "" : "s" ); - Window &w = screen._windows[24]; + Window &w = windows[24]; bool windowOpen = w._enabled; if (!windowOpen) w.open(); diff --git a/engines/xeen/dialogs_spells.cpp b/engines/xeen/dialogs_spells.cpp index 1a347aff8e..ed0857a152 100644 --- a/engines/xeen/dialogs_spells.cpp +++ b/engines/xeen/dialogs_spells.cpp @@ -46,6 +46,7 @@ Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; Spells &spells = *_vm->_spells; + Windows &windows = *_vm->_windows; bool isDarkCc = _vm->_files->_isDarkCc; loadButtons(); @@ -54,7 +55,7 @@ Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int int selection = -1; int topIndex = 0; int newSelection; - screen._windows[25].open(); + windows[25].open(); do { if (!isCasting) { @@ -68,14 +69,14 @@ Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int Common::String title = Common::String::format(Res.BUY_SPELLS, c->_name.c_str()); Common::String msg = Common::String::format(Res.GUILD_OPTIONS, title.c_str(), XeenEngine::printMil(party._gold).c_str()); - screen._windows[10].writeString(msg); + windows[10].writeString(msg); warning("TODO: Sprite draw using previously used button sprites"); } _spells.clear(); const char *errorMsg = setSpellText(c, castingCopy); - screen._windows[25].writeString(Common::String::format(Res.SPELLS_FOR, + windows[25].writeString(Common::String::format(Res.SPELLS_FOR, errorMsg == nullptr ? Res.SPELL_LINES_0_TO_9 : "", c->_name.c_str())); @@ -98,7 +99,7 @@ Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int if (_spells.size() == 0) names[0] = errorMsg; - screen._windows[37].writeString(Common::String::format(Res.SPELLS_DIALOG_SPELLS, + windows[37].writeString(Common::String::format(Res.SPELLS_DIALOG_SPELLS, colors[0], names[0], colors[1], names[1], colors[2], names[2], colors[3], names[3], colors[4], names[4], colors[5], names[5], colors[6], names[6], colors[7], names[7], colors[8], names[8], @@ -111,9 +112,9 @@ Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int _scrollSprites.draw(screen, 0, Common::Point(187, 26)); _scrollSprites.draw(screen, 2, Common::Point(187, 111)); if (isCasting) - _scrollSprites.draw(screen._windows[25], 5, Common::Point(132, 123)); + _scrollSprites.draw(windows[25], 5, Common::Point(132, 123)); - screen._windows[25].update(); + windows[25].update(); do { events.pollEventsAndWait(); @@ -135,7 +136,7 @@ Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int intf.highlightChar(_buttonValue); if (_vm->_mode == MODE_17) { - screen._windows[10].writeString(Common::String::format(Res.GUILD_OPTIONS, + windows[10].writeString(Common::String::format(Res.GUILD_OPTIONS, XeenEngine::printMil(party._gold).c_str(), Res.GUILD_TEXT, c->_name.c_str())); } else { int category; @@ -155,7 +156,7 @@ Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int int spellIndex = (c->_currentSpell == -1) ? 39 : c->_currentSpell; int spellId = Res.SPELLS_ALLOWED[category][spellIndex]; - screen._windows[10].writeString(Common::String::format(Res.CAST_SPELL_DETAILS, + windows[10].writeString(Common::String::format(Res.CAST_SPELL_DETAILS, c->_name.c_str(), spells._spellNames[spellId].c_str(), spells.calcSpellPoints(spellId, c->getCurrentLevel()), Res.SPELL_GEM_COST[spellId], c->_currentSp)); @@ -163,7 +164,7 @@ Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int if (priorDialog != nullptr) priorDialog->drawButtons(&screen); - screen._windows[10].update(); + windows[10].update(); } } break; @@ -273,7 +274,7 @@ Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int } } while (!_vm->shouldQuit() && _buttonValue != Common::KEYCODE_ESCAPE); - screen._windows[25].close(); + windows[25].close(); if (_vm->shouldQuit()) selection = -1; @@ -480,7 +481,8 @@ int CastSpell::execute(Character *&c) { Party &party = *_vm->_party; Screen &screen = *_vm->_screen; Spells &spells = *_vm->_spells; - Window &w = screen._windows[10]; + Windows &windows = *_vm->_windows; + Window &w = windows[10]; Mode oldMode = _vm->_mode; _vm->_mode = MODE_3; @@ -598,9 +600,9 @@ int SpellOnWho::execute(int spellId) { EventsManager &events = *_vm->_events; Interface &intf = *_vm->_interface; Party &party = *_vm->_party; - Screen &screen = *_vm->_screen; Spells &spells = *_vm->_spells; - Window &w = screen._windows[16]; + Windows &windows = *_vm->_windows; + Window &w = windows[16]; Mode oldMode = _vm->_mode; _vm->_mode = MODE_3; int result = 999; @@ -666,7 +668,8 @@ int SelectElement::execute(int spellId) { Interface &intf = *_vm->_interface; Screen &screen = *_vm->_screen; Spells &spells = *_vm->_spells; - Window &w = screen._windows[15]; + Windows &windows = *_vm->_windows; + Window &w = windows[15]; Mode oldMode = _vm->_mode; _vm->_mode = MODE_3; int result = 999; @@ -744,7 +747,8 @@ void NotWhileEngaged::execute(int spellId) { EventsManager &events = *_vm->_events; Screen &screen = *_vm->_screen; Spells &spells = *_vm->_spells; - Window &w = screen._windows[6]; + Windows &windows = *_vm->_windows; + Window &w = windows[6]; Mode oldMode = _vm->_mode; _vm->_mode = MODE_3; @@ -779,7 +783,8 @@ bool LloydsBeacon::execute() { Party &party = *_vm->_party; Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; - Window &w = screen._windows[10]; + Windows &windows = *_vm->_windows; + Window &w = windows[10]; bool isDarkCc = _vm->_files->_isDarkCc; Character &c = *combat._oldCharacter; @@ -882,7 +887,8 @@ int Teleport::execute() { Map &map = *_vm->_map; Party &party = *_vm->_party; Screen &screen = *_vm->_screen; - Window &w = screen._windows[6]; + Windows &windows = *_vm->_windows; + Window &w = windows[6]; Common::String num; w.open(); @@ -938,8 +944,8 @@ int TownPortal::show(XeenEngine *vm) { int TownPortal::execute() { Map &map = *_vm->_map; - Screen &screen = *_vm->_screen; - Window &w = screen._windows[20]; + Windows &windows = *_vm->_windows; + Window &w = windows[20]; Common::String townNames[5]; Mode oldMode = _vm->_mode; _vm->_mode = MODE_FF; @@ -989,7 +995,8 @@ void IdentifyMonster::execute() { Map &map = *_vm->_map; Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; - Window &w = screen._windows[17]; + Windows &windows = *_vm->_windows; + Window &w = windows[17]; Common::String monsterDesc[3]; for (int monIndex = 0; monIndex < 3; ++monIndex) { @@ -1017,7 +1024,7 @@ void IdentifyMonster::execute() { events.updateGameCounter(); intf.draw3d(false); w.frame(); - screen._windows[3].update(); + windows[3].update(); events.wait(1, false); } while (!events.isKeyMousePressed()); diff --git a/engines/xeen/dialogs_whowill.cpp b/engines/xeen/dialogs_whowill.cpp index 4192ea8a4a..27c2fa0ba0 100644 --- a/engines/xeen/dialogs_whowill.cpp +++ b/engines/xeen/dialogs_whowill.cpp @@ -39,25 +39,25 @@ int WhoWill::execute(int message, int action, bool type) { Interface &intf = *_vm->_interface; Map &map = *_vm->_map; Party &party = *_vm->_party; - Screen &screen = *_vm->_screen; Scripts &scripts = *_vm->_scripts; Town &town = *_vm->_town; + Windows &windows = *_vm->_windows; int numFrames; if (party._activeParty.size() <= 1) // Unless there's at least two characters, just return the first one return 1; - screen._windows[38].close(); - screen._windows[12].close(); + windows[38].close(); + windows[12].close(); Common::String actionStr = type ? map._events._text[action] : Res.WHO_WILL_ACTIONS[action]; Common::String msg = Common::String::format(Res.WHO_WILL, actionStr.c_str(), Res.WHO_ACTIONS[message], party._activeParty.size()); - screen._windows[36].open(); - screen._windows[36].writeString(msg); - screen._windows[36].update(); + windows[36].open(); + windows[36].writeString(msg); + windows[36].update(); intf._face1State = map._headData[party._mazePosition.y][party._mazePosition.x]._left; intf._face2State = map._headData[party._mazePosition.y][party._mazePosition.x]._right; @@ -65,14 +65,14 @@ int WhoWill::execute(int message, int action, bool type) { while (!_vm->shouldQuit()) { events.updateGameCounter(); - if (screen._windows[11]._enabled) { + if (windows[11]._enabled) { town.drawTownAnim(0); - screen._windows[36].frame(); + windows[36].frame(); numFrames = 3; } else { intf.draw3d(false); - screen._windows[36].frame(); - screen._windows[3].update(); + windows[36].frame(); + windows[3].update(); numFrames = 1; } @@ -98,7 +98,7 @@ int WhoWill::execute(int message, int action, bool type) { } intf._face1State = intf._face2State = 2; - screen._windows[36].close(); + windows[36].close(); return _buttonValue; } diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp index d3face1986..21073bad5d 100644 --- a/engines/xeen/interface.cpp +++ b/engines/xeen/interface.cpp @@ -51,6 +51,7 @@ void PartyDrawer::drawParty(bool updateFlag) { Party &party = *_vm->_party; Resources &res = *_vm->_resources; Screen &screen = *_vm->_screen; + Windows &windows = *_vm->_windows; bool inCombat = _vm->_mode == MODE_COMBAT; _restoreSprites.draw(screen, 0, Common::Point(8, 149)); @@ -92,12 +93,13 @@ void PartyDrawer::drawParty(bool updateFlag) { res._globalSprites.draw(screen, 8, Common::Point(Res.CHAR_FACES_X[_hiliteChar] - 1, 149)); if (updateFlag) - screen._windows[33].update(); + windows[33].update(); } void PartyDrawer::highlightChar(int charId) { Resources &res = *_vm->_resources; Screen &screen = *_vm->_screen; + Windows &windows = *_vm->_windows; if (charId != _hiliteChar && _hiliteChar != HILIGHT_CHAR_DISABLED) { // Handle deselecting any previusly selected char @@ -109,19 +111,20 @@ void PartyDrawer::highlightChar(int charId) { // Highlight new character res._globalSprites.draw(screen, 8, Common::Point(Res.CHAR_FACES_X[charId] - 1, 149)); _hiliteChar = charId; - screen._windows[33].update(); + windows[33].update(); } } void PartyDrawer::unhighlightChar() { Resources &res = *_vm->_resources; Screen &screen = *_vm->_screen; + Windows &windows = *_vm->_windows; if (_hiliteChar != HILIGHT_CHAR_NONE) { res._globalSprites.draw(screen, _hiliteChar + 9, Common::Point(Res.CHAR_FACES_X[_hiliteChar] - 1, 149)); _hiliteChar = HILIGHT_CHAR_NONE; - screen._windows[33].update(); + windows[33].update(); } } @@ -188,7 +191,7 @@ void Interface::setup() { void Interface::startup() { Resources &res = *_vm->_resources; - Screen &screen = *_vm->_screen; + Windows &windows = *_vm->_windows; _iconSprites.load("main.icn"); animate3d(); @@ -201,7 +204,7 @@ void Interface::startup() { } draw3d(false); - res._globalSprites.draw(screen._windows[1], 5, Common::Point(232, 9)); + res._globalSprites.draw(windows[1], 5, Common::Point(232, 9)); drawParty(false); _mainList[0]._sprites = &res._globalSprites; @@ -214,11 +217,11 @@ void Interface::startup() { } void Interface::mainIconsPrint() { - Screen &screen = *_vm->_screen; - screen._windows[38].close(); - screen._windows[12].close(); - screen._windows[0].drawList(_mainList, 16); - screen._windows[34].update(); + Windows &windows = *_vm->_windows; + windows[38].close(); + windows[12].close(); + windows[0].drawList(_mainList, 16); + windows[34].update(); } void Interface::setMainButtons(bool combatMode) { @@ -1028,6 +1031,7 @@ void Interface::rest() { Party &party = *_vm->_party; Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; + Windows &windows = *_vm->_windows; map.cellFlagLookup(party._mazePosition); @@ -1081,7 +1085,7 @@ void Interface::rest() { events.hideCursor(); screen.loadBackground("scene1.raw"); - screen._windows[0].update(); + windows[0].update(); screen.fadeIn(); events.updateGameCounter(); @@ -1103,7 +1107,7 @@ void Interface::rest() { screen.fadeOut(); events.setCursor(0); screen.restoreBackground(); - screen._windows[0].update(); + windows[0].update(); screen.fadeIn(); } @@ -1153,8 +1157,8 @@ void Interface::bash(const Common::Point &pt, Direction direction) { EventsManager &events = *_vm->_events; Map &map = *_vm->_map; Party &party = *_vm->_party; - Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; + Windows &windows = *_vm->_windows; if (map._isOutdoors) return; @@ -1178,15 +1182,15 @@ void Interface::bash(const Common::Point &pt, Direction direction) { } party._activeParty[charNum1 - 1].subtractHitPoints(2); - _charPowSprites.draw(screen._windows[0], 0, + _charPowSprites.draw(windows[0], 0, Common::Point(Res.CHAR_FACES_X[charNum1 - 1], 150)); - screen._windows[0].update(); + windows[0].update(); if (charNum2) { party._activeParty[charNum2 - 1].subtractHitPoints(2); - _charPowSprites.draw(screen._windows[0], 0, + _charPowSprites.draw(windows[0], 0, Common::Point(Res.CHAR_FACES_X[charNum2 - 1], 150)); - screen._windows[0].update(); + windows[0].update(); } int cell = map.mazeLookup(Common::Point(pt.x + Res.SCREEN_POSITIONING_X[direction][7], @@ -1246,9 +1250,10 @@ void Interface::draw3d(bool updateFlag, bool skipDelay) { Party &party = *_vm->_party; Screen &screen = *_vm->_screen; Scripts &scripts = *_vm->_scripts; + Windows &windows = *_vm->_windows; events.updateGameCounter(); - if (screen._windows[11]._enabled) + if (windows[11]._enabled) return; _flipUIFrame = (_flipUIFrame + 1) % 4; @@ -1277,12 +1282,12 @@ void Interface::draw3d(bool updateFlag, bool skipDelay) { // Draw any on-screen text if flagged to do so if (_upDoorText && combat._attackMonsters[0] == -1) { - screen._windows[3].writeString(_screenText); + windows[3].writeString(_screenText); } if (updateFlag) { - screen._windows[1].update(); - screen._windows[3].update(); + windows[1].update(); + windows[3].update(); } if (combat._attackMonsters[0] != -1 || combat._attackMonsters[1] != -1 @@ -1306,17 +1311,17 @@ void Interface::draw3d(bool updateFlag, bool skipDelay) { void Interface::handleFalling() { Party &party = *_vm->_party; - Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; - Window &w = screen._windows[3]; + Windows &windows = *_vm->_windows; + Window &w = windows[3]; saveFall(); for (uint idx = 0; idx < party._activeParty.size(); ++idx) { - party._activeParty[idx]._faceSprites->draw(screen._windows[0], 4, + party._activeParty[idx]._faceSprites->draw(windows[0], 4, Common::Point(Res.CHAR_FACES_X[idx], 150)); } - screen._windows[33].update(); + windows[33].update(); sound.playFX(11); sound.playSound("scream.voc"); @@ -1369,10 +1374,10 @@ void Interface::drawMiniMap() { Map &map = *_vm->_map; Party &party = *_vm->_party; Resources &res = *_vm->_resources; - Screen &screen = *_vm->_screen; - Window &window1 = screen._windows[1]; + Windows &windows = *_vm->_windows; + Window &window1 = windows[1]; - if (screen._windows[2]._enabled || screen._windows[10]._enabled) + if (windows[2]._enabled || windows[10]._enabled) return; if (!party._automapOn && !party._wizardEyeActive) { // Draw the Might & Magic logo @@ -1745,13 +1750,14 @@ void Interface::assembleBorder() { Combat &combat = *_vm->_combat; Resources &res = *_vm->_resources; Screen &screen = *_vm->_screen; + Windows &windows = *_vm->_windows; // Draw the outer frame - res._globalSprites.draw(screen._windows[0], 0, Common::Point(8, 8)); + res._globalSprites.draw(windows[0], 0, Common::Point(8, 8)); // Draw the animating bat character on the left screen edge to indicate // that the party is being levitated - _borderSprites.draw(screen._windows[0], _vm->_party->_levitateCount ? _levitateUIFrame + 16 : 16, + _borderSprites.draw(windows[0], _vm->_party->_levitateCount ? _levitateUIFrame + 16 : 16, Common::Point(0, 82)); _levitateUIFrame = (_levitateUIFrame + 1) % 12; @@ -1787,13 +1793,13 @@ void Interface::assembleBorder() { _borderSprites.draw(screen, _face1UIFrame, Common::Point(0, 32)); _borderSprites.draw(screen, - screen._windows[10]._enabled || screen._windows[2]._enabled ? + windows[10]._enabled || windows[2]._enabled ? 52 : _face2UIFrame, Common::Point(215, 32)); // Draw resistence indicators - if (!screen._windows[10]._enabled && !screen._windows[2]._enabled - && screen._windows[38]._enabled) { + if (!windows[10]._enabled && !windows[2]._enabled + && windows[38]._enabled) { _fecpSprites.draw(screen, _vm->_party->_fireResistence ? 1 : 0, Common::Point(2, 2)); _fecpSprites.draw(screen, _vm->_party->_electricityResistence ? 3 : 2, @@ -1844,12 +1850,12 @@ void Interface::assembleBorder() { const char *dirText = Res.DIRECTION_TEXT_UPPER[_vm->_party->_mazeDirection]; Common::String msg = Common::String::format( "\002""08\003""c\013""139\011""116%c\014""d\001", *dirText); - screen._windows[0].writeString(msg); + windows[0].writeString(msg); } // Draw view frame - if (screen._windows[12]._enabled) - screen._windows[12].frame(); + if (windows[12]._enabled) + windows[12].frame(); } void Interface::doCombat() { @@ -1861,6 +1867,7 @@ void Interface::doCombat() { Scripts &scripts = *_vm->_scripts; Spells &spells = *_vm->_spells; Sound &sound = *_vm->_sound; + Windows &windows = *_vm->_windows; bool upDoorText = _upDoorText; bool reloadMap = false; @@ -1909,7 +1916,7 @@ void Interface::doCombat() { draw3d(true); } - Window &w = screen._windows[2]; + Window &w = windows[2]; w.open(); bool breakFlag = false; @@ -2239,6 +2246,7 @@ void Interface::spellFX(Character *c) { Party &party = *_vm->_party; Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; + Windows &windows = *_vm->_windows; // Ensure there's no alraedy running effect for the given character uint charIndex; @@ -2249,8 +2257,8 @@ void Interface::spellFX(Character *c) { if (charIndex == party._activeParty.size() || _charFX[charIndex]) return; - if (screen._windows[12]._enabled) - screen._windows[12].close(); + if (windows[12]._enabled) + windows[12].close(); if (combat._combatMode == COMBATMODE_2) { for (uint idx = 0; idx < combat._combatParty.size(); ++idx) { @@ -2270,11 +2278,11 @@ void Interface::spellFX(Character *c) { _spellFxSprites.draw(screen, frameNum, Common::Point( Res.CHAR_FACES_X[charIndex], 150)); - if (!screen._windows[11]._enabled) + if (!windows[11]._enabled) draw3d(false); - screen._windows[0].update(); - events.wait(screen._windows[11]._enabled ? 2 : 1,false); + windows[0].update(); + events.wait(windows[11]._enabled ? 2 : 1,false); } drawParty(true); diff --git a/engines/xeen/interface.h b/engines/xeen/interface.h index ce887d2ae9..f2abfd5c39 100644 --- a/engines/xeen/interface.h +++ b/engines/xeen/interface.h @@ -27,7 +27,7 @@ #include "xeen/dialogs.h" #include "xeen/interface_map.h" #include "xeen/party.h" -#include "xeen/screen.h" +#include "xeen/window.h" namespace Xeen { diff --git a/engines/xeen/interface_map.cpp b/engines/xeen/interface_map.cpp index 249a877690..21064b309f 100644 --- a/engines/xeen/interface_map.cpp +++ b/engines/xeen/interface_map.cpp @@ -3525,6 +3525,7 @@ void InterfaceMap::setOutdoorsObjects() { void InterfaceMap::drawIndoors() { Map &map = *_vm->_map; + Windows &windows = *_vm->_windows; int surfaceId; // Draw any surface tiles on top of the default ground @@ -4357,7 +4358,7 @@ void InterfaceMap::drawIndoors() { _indoorList._horizon._frame = 7; // Finally draw the darn indoor scene - _vm->_screen->_windows[3].drawList(&_indoorList[0], _indoorList.size()); + windows[3].drawList(&_indoorList[0], _indoorList.size()); // Check for any character shooting _isAttacking = false; @@ -4372,7 +4373,7 @@ void InterfaceMap::drawIndoors() { void InterfaceMap::drawOutdoors() { Map &map = *_vm->_map; Party &party = *_vm->_party; - Screen &screen = *_vm->_screen; + Windows &windows = *_vm->_windows; int surfaceId; // Draw any surface tiles on top of the default ground @@ -4433,7 +4434,7 @@ void InterfaceMap::drawOutdoors() { _outdoorList._groundSprite._flags = _flipWater ? SPRFLAG_HORIZ_FLIPPED : 0; // Finally render the outdoor scene - screen._windows[3].drawList(&_outdoorList[0], _outdoorList.size()); + windows[3].drawList(&_outdoorList[0], _outdoorList.size()); // Check for any character shooting _isAttacking = false; diff --git a/engines/xeen/interface_map.h b/engines/xeen/interface_map.h index 47a7bad963..aaa5478c94 100644 --- a/engines/xeen/interface_map.h +++ b/engines/xeen/interface_map.h @@ -25,7 +25,7 @@ #include "common/scummsys.h" #include "xeen/map.h" -#include "xeen/screen.h" +#include "xeen/window.h" namespace Xeen { diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp index 9916c86130..1a33f1d840 100644 --- a/engines/xeen/map.cpp +++ b/engines/xeen/map.cpp @@ -907,13 +907,13 @@ Map::Map(XeenEngine *vm) : _vm(vm), _mobData(vm) { void Map::load(int mapId) { Interface &intf = *_vm->_interface; - Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; + Windows &windows = *_vm->_windows; IndoorDrawList &indoorList = _vm->_interface->_indoorList; OutdoorDrawList &outdoorList = _vm->_interface->_outdoorList; if (intf._falling) { - Window &w = screen._windows[9]; + Window &w = windows[9]; w.open(); w.writeString(Res.OOPS); } else { diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp index 5ed2ea89cb..e392c2e060 100644 --- a/engines/xeen/party.cpp +++ b/engines/xeen/party.cpp @@ -571,7 +571,8 @@ void Party::giveTreasure() { Screen &screen = *_vm->_screen; Scripts &scripts = *_vm->_scripts; Sound &sound = *_vm->_sound; - Window &w = screen._windows[10]; + Windows &windows = *_vm->_windows; + Window &w = windows[10]; if (!_treasure._gold && !_treasure._gems) return; @@ -705,7 +706,8 @@ void Party::giveTreasureToCharacter(Character &c, ItemCategory category, int ite EventsManager &events = *_vm->_events; Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; - Window &w = screen._windows[10]; + Windows &windows = *_vm->_windows; + Window &w = windows[10]; XeenItem &treasureItem = _treasure._categories[category][itemIndex]; sound.playFX(20); diff --git a/engines/xeen/screen.cpp b/engines/xeen/screen.cpp index bcf7f0d722..b8cf1786b0 100644 --- a/engines/xeen/screen.cpp +++ b/engines/xeen/screen.cpp @@ -31,7 +31,6 @@ namespace Xeen { Screen::Screen(XeenEngine *vm) : _vm(vm) { - Window::init(vm); _fadeIn = false; create(SCREEN_WIDTH, SCREEN_HEIGHT); Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0); @@ -48,58 +47,6 @@ Screen::~Screen() { delete[] _fontData; } -void Screen::setupWindows() { - Window windows[40] = { - Window(Common::Rect(0, 0, 320, 200), 0, 0, 0, 0, 320, 200), - Window(Common::Rect(237, 9, 317, 74), 0, 0, 237, 12, 307, 68), - Window(Common::Rect(225, 1, 319, 73), 1, 8, 225, 1, 319, 73), - Window(Common::Rect(0, 0, 230, 149), 0, 0, 9, 8, 216, 140), - Window(Common::Rect(235, 148, 309, 189), 2, 8, 0, 0, 0, 0), - Window(Common::Rect(70, 20, 250, 183), 3, 8, 80, 38, 240, 166), - Window(Common::Rect(52, 149, 268, 197), 4, 8, 0, 0, 0, 0), - Window(Common::Rect(108, 0, 200, 200), 5, 0, 0, 0, 0, 0), - Window(Common::Rect(232, 9, 312, 74), 0, 0, 0, 0, 0, 0), - Window(Common::Rect(103, 156, 217, 186), 6, 8, 0, 0, 0, 0), - Window(Common::Rect(226, 0, 319, 146), 7, 8, 0, 0, 0, 0), - Window(Common::Rect(8, 8, 224, 140), 8, 8, 8, 8, 224, 200), - Window(Common::Rect(0, 143, 320, 199), 9, 8, 0, 0, 0, 0), - Window(Common::Rect(50, 103, 266, 139), 10, 8, 0, 0, 0, 0), - Window(Common::Rect(0, 7, 320, 138), 11, 8, 0, 0, 0, 0), - Window(Common::Rect(50, 71, 182, 129), 12, 8, 0, 0, 0, 0), - Window(Common::Rect(228, 106, 319, 146), 13, 8, 0, 0, 0, 0), - Window(Common::Rect(20, 142, 290, 199), 14, 8, 0, 0, 0, 0), - Window(Common::Rect(0, 20, 320, 180), 15, 8, 0, 0, 0, 0), - Window(Common::Rect(231, 48, 317, 141), 16, 8, 0, 0, 0, 0), - Window(Common::Rect(72, 37, 248, 163), 17, 8, 0, 0, 0, 0), - Window(Common::Rect(99, 59, 237, 141), 18, 8, 99, 59, 237, 0), - Window(Common::Rect(65, 23, 250, 163), 19, 8, 75, 36, 245, 141), - Window(Common::Rect(80, 28, 256, 148), 20, 8, 80, 28, 256, 172), - Window(Common::Rect(0, 0, 320, 146), 21, 8, 0, 0, 320, 148), - Window(Common::Rect(27, 6, 207, 142), 22, 8, 0, 0, 0, 146), - Window(Common::Rect(15, 15, 161, 91), 23, 8, 0, 0, 0, 0), - Window(Common::Rect(90, 45, 220, 157), 24, 8, 0, 0, 0, 0), - Window(Common::Rect(0, 0, 320, 200), 25, 8, 0, 0, 0, 0), - Window(Common::Rect(0, 101, 320, 146), 26, 8, 0, 101, 320, 0), - Window(Common::Rect(0, 0, 320, 108), 27, 8, 0, 0, 0, 45), - Window(Common::Rect(50, 112, 266, 148), 28, 8, 0, 0, 0, 0), - Window(Common::Rect(12, 11, 164, 94), 0, 0, 0, 0, 52, 0), - Window(Common::Rect(8, 147, 224, 192), 0, 8, 0, 0, 0, 94), - Window(Common::Rect(232, 74, 312, 138), 29, 8, 0, 0, 0, 0), - Window(Common::Rect(226, 26, 319, 146), 30, 8, 0, 0, 0, 0), - Window(Common::Rect(225, 74, 319, 154), 31, 8, 0, 0, 0, 0), - Window(Common::Rect(27, 6, 195, 142), 0, 8, 0, 0, 0, 0), - Window(Common::Rect(225, 140, 319, 199), 0, 8, 0, 0, 0, 0) - }; - - _windows = Common::Array<Window>(windows, 40); -} - -void Screen::closeWindows() { - for (int i = (int)_windowStack.size() - 1; i >= 0; --i) - _windowStack[i]->close(); - assert(_windowStack.size() == 0); -} - void Screen::update() { // Merge the dirty rects mergeDirtyRects(); diff --git a/engines/xeen/screen.h b/engines/xeen/screen.h index 032c2654dc..8e72e723c9 100644 --- a/engines/xeen/screen.h +++ b/engines/xeen/screen.h @@ -30,7 +30,6 @@ #include "common/rect.h" #include "xeen/font.h" #include "xeen/sprites.h" -#include "xeen/window.h" namespace Xeen { @@ -38,7 +37,6 @@ namespace Xeen { #define SCREEN_HEIGHT 200 #define PALETTE_COUNT 256 #define PALETTE_SIZE (256 * 3) -#define GAME_WINDOW 28 class XeenEngine; @@ -72,18 +70,10 @@ public: */ virtual void addDirtyRect(const Common::Rect &r); public: - Common::Array<Window> _windows; - - Common::Array<Window *> _windowStack; -public: Screen(XeenEngine *vm); virtual ~Screen(); - void setupWindows(); - - void closeWindows(); - void update(); /** diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp index 413e877e2d..9b28a0cc5e 100644 --- a/engines/xeen/scripts.cpp +++ b/engines/xeen/scripts.cpp @@ -139,6 +139,7 @@ int Scripts::checkEvents() { Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; Town &town = *_vm->_town; + Windows &windows = *_vm->_windows; bool isDarkCc = _vm->_files->_isDarkCc; _refreshIcons = false; @@ -204,7 +205,7 @@ int Scripts::checkEvents() { intf._face1State = intf._face2State = 2; if (_refreshIcons) { - screen.closeWindows(); + windows.closeAll(); intf.drawParty(true); } @@ -238,14 +239,14 @@ int Scripts::checkEvents() { _animCounter = 0; _vm->_mode = oldMode; - screen.closeWindows(); + windows.closeAll(); if (_scriptExecuted || !intf._objNumber || _var50) { if (_var50 && !_scriptExecuted && intf._objNumber && !map._currentIsEvent) { sound.playFX(21); } } else { - Window &w = screen._windows[38]; + Window &w = windows[38]; w.open(); w.writeString(Res.NOTHING_HERE); w.update(); @@ -388,15 +389,15 @@ bool Scripts::cmdDoNothing(ParamsIterator ¶ms) { } bool Scripts::cmdDisplay1(ParamsIterator ¶ms) { - Screen &screen = *_vm->_screen; + Windows &windows = *_vm->_windows; Common::String paramText = _vm->_map->_events._text[params.readByte()]; Common::String msg = Common::String::format("\r\x03""c%s", paramText.c_str()); - screen._windows[12].close(); - if (screen._windows[38]._enabled) - screen._windows[38].open(); - screen._windows[38].writeString(msg); - screen._windows[38].update(); + windows[12].close(); + if (windows[38]._enabled) + windows[38].open(); + windows[38].writeString(msg); + windows[38].update(); return true; } @@ -466,10 +467,10 @@ bool Scripts::cmdTeleport(ParamsIterator ¶ms) { Interface &intf = *_vm->_interface; Map &map = *_vm->_map; Party &party = *_vm->_party; - Screen &screen = *_vm->_screen; + Windows &windows = *_vm->_windows; Sound &sound = *_vm->_sound; - screen.closeWindows(); + windows.closeAll(); int mapId = params.readByte(); Common::Point pt; @@ -591,7 +592,7 @@ bool Scripts::cmdMoveObj(ParamsIterator ¶ms) { bool Scripts::cmdTakeOrGive(ParamsIterator ¶ms) { Party &party = *_vm->_party; - Screen &screen = *_vm->_screen; + Windows &windows = *_vm->_windows; int mode1, mode2, mode3, param2; uint32 val1, val2, val3; @@ -650,7 +651,7 @@ bool Scripts::cmdTakeOrGive(ParamsIterator ¶ms) { } if (mode2 == 67) - screen.closeWindows(); + windows.closeAll(); switch (_event->_opcode) { case OP_TakeOrGive_2: @@ -779,7 +780,7 @@ bool Scripts::cmdTakeOrGive(ParamsIterator ¶ms) { } else { if (!party.giveTake(mode1, val1, mode2, val2, _charIndex - 1)) { if (mode2 == 79) - screen.closeWindows(); + windows.closeAll(); } } break; @@ -1144,7 +1145,8 @@ bool Scripts::cmdAlterHed(ParamsIterator ¶ms) { bool Scripts::cmdDisplayStat(ParamsIterator ¶ms) { Party &party = *_vm->_party; - Window &w = _vm->_screen->_windows[12]; + Windows &windows = *_vm->_windows; + Window &w = windows[12]; Character &c = party._activeParty[_charIndex - 1]; if (!w._enabled) @@ -1304,7 +1306,8 @@ bool Scripts::cmdChooseNumeric(ParamsIterator ¶ms) { bool Scripts::cmdDisplayBottomTwoLines(ParamsIterator ¶ms) { Map &map = *_vm->_map; - Window &w = _vm->_screen->_windows[12]; + Windows &windows = *_vm->_windows; + Window &w = windows[12]; params.readByte(); int textId = params.readByte(); @@ -1817,13 +1820,14 @@ void Scripts::display(bool justifyFlag, int var46) { EventsManager &events = *_vm->_events; Interface &intf = *_vm->_interface; Screen &screen = *_vm->_screen; - Window &w = screen._windows[_windowIndex]; + Windows &windows = *_vm->_windows; + Window &w = windows[_windowIndex]; if (!_redrawDone) { intf.draw3d(true); _redrawDone = true; } - screen._windows[38].close(); + windows[38].close(); if (!justifyFlag) _displayMessage = Common::String::format("\r\x3""c%s", _message.c_str()); diff --git a/engines/xeen/spells.cpp b/engines/xeen/spells.cpp index 2f9fe46329..4e40c01761 100644 --- a/engines/xeen/spells.cpp +++ b/engines/xeen/spells.cpp @@ -430,9 +430,9 @@ void Spells::detectMonster() { Interface &intf = *_vm->_interface; Map &map = *_vm->_map; Party &party = *_vm->_party; - Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; - Window &w = screen._windows[19]; + Windows &windows = *_vm->_windows; + Window &w = windows[19]; bool isDarkCc = _vm->_files->_isDarkCc; int grid[7][7]; @@ -753,6 +753,7 @@ void Spells::insectSpray() { } void Spells::itemToGold() { + Windows &windows = *_vm->_windows; Character *c = SpellOnWho::show(_vm, MS_ItemToGold); if (!c) return; @@ -760,7 +761,7 @@ void Spells::itemToGold() { Mode oldMode = _vm->_mode; _vm->_mode = MODE_FF; - _vm->_screen->_windows[11].close(); + windows[11].close(); ItemsDialog::show(_vm, c, ITEMMODE_TO_GOLD); _vm->_mode = oldMode; diff --git a/engines/xeen/town.cpp b/engines/xeen/town.cpp index 0e2f2e71d3..d4877381dd 100644 --- a/engines/xeen/town.cpp +++ b/engines/xeen/town.cpp @@ -70,6 +70,7 @@ int Town::townAction(TownAction actionId) { Party &party = *_vm->_party; Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; + Windows &windows = *_vm->_windows; bool isDarkCc = _vm->_files->_isDarkCc; if (actionId == ACTION12) { @@ -228,11 +229,11 @@ int Town::townAction(TownAction actionId) { intf.assembleBorder(); // Open up the window and write the string - screen._windows[10].open(); - screen._windows[10].writeString(title); + windows[10].open(); + windows[10].writeString(title); drawButtons(&screen); - screen._windows[0].update(); + windows[0].update(); intf.highlightChar(0); drawTownAnim(1); @@ -248,7 +249,7 @@ int Town::townAction(TownAction actionId) { return 0; title = createTownText(*charP); - screen._windows[10].writeString(title); + windows[10].writeString(title); drawButtons(&screen); } while (_buttonValue != Common::KEYCODE_ESCAPE); @@ -294,6 +295,7 @@ int Town::townAction(TownAction actionId) { int Town::townWait() { EventsManager &events = *_vm->_events; + Windows &windows = *_vm->_windows; _buttonValue = 0; while (!_vm->shouldQuit() && !_buttonValue) { @@ -303,7 +305,7 @@ int Town::townWait() { checkEvents(_vm); } if (!_buttonValue) - drawTownAnim(!_vm->_screen->_windows[11]._enabled); + drawTownAnim(!windows[11]._enabled); } return _buttonValue; @@ -596,8 +598,9 @@ Character *Town::doTavernOptions(Character *c) { Interface &intf = *_vm->_interface; Map &map = *_vm->_map; Party &party = *_vm->_party; - Sound &sound = *_vm->_sound; Screen &screen = *_vm->_screen; + Sound &sound = *_vm->_sound; + Windows &windows = *_vm->_windows; bool isDarkCc = _vm->_files->_isDarkCc; int idx = 0; @@ -624,11 +627,11 @@ Character *Town::doTavernOptions(Character *c) { sound.playSound("gulp.voc"); _v21 = 1; - screen._windows[10].writeString(Common::String::format(Res.TAVERN_TEXT, + windows[10].writeString(Common::String::format(Res.TAVERN_TEXT, c->_name.c_str(), Res.GOOD_STUFF, XeenEngine::printMil(party._gold).c_str())); - drawButtons(&screen._windows[0]); - screen._windows[10].update(); + drawButtons(&windows[0]); + windows[10].update(); if (_vm->getRandomNumber(100) < 26) { ++c->_conditions[DRUNK]; @@ -669,10 +672,10 @@ Character *Town::doTavernOptions(Character *c) { } Common::String msg = _textStrings[(isDarkCc ? 60 : 75) + idx]; - screen._windows[10].close(); - screen._windows[12].open(); - screen._windows[12].writeString(msg); - screen._windows[12].update(); + windows[10].close(); + windows[12].open(); + windows[12].writeString(msg); + windows[12].update(); if (YesNo::show(_vm, false, true)) { if (party._food >= _v22) { @@ -684,8 +687,8 @@ Character *Town::doTavernOptions(Character *c) { } } - screen._windows[12].close(); - screen._windows[10].open(); + windows[12].close(); + windows[10].open(); _buttonValue = 0; break; } @@ -702,7 +705,7 @@ Character *Town::doTavernOptions(Character *c) { Common::String msg = Common::String::format("\x03""c\x0B""012%s", _textStrings[(party._day % 10) + idx].c_str()); - Window &w = screen._windows[12]; + Window &w = windows[12]; w.open(); w.writeString(msg); w.update(); @@ -741,20 +744,20 @@ Character *Town::doTavernOptions(Character *c) { case Common::KEYCODE_t: if (!c->noActions()) { if (!_v21) { - screen._windows[10].writeString(Common::String::format(Res.TAVERN_TEXT, + windows[10].writeString(Common::String::format(Res.TAVERN_TEXT, c->_name.c_str(), Res.HAVE_A_DRINK, XeenEngine::printMil(party._gold).c_str())); drawButtons(&screen); - screen._windows[10].update(); + windows[10].update(); townWait(); } else { _v21 = 0; if (c->_conditions[DRUNK]) { - screen._windows[10].writeString(Common::String::format(Res.TAVERN_TEXT, + windows[10].writeString(Common::String::format(Res.TAVERN_TEXT, c->_name.c_str(), Res.YOURE_DRUNK, XeenEngine::printMil(party._gold).c_str())); drawButtons(&screen); - screen._windows[10].update(); + windows[10].update(); townWait(); } else if (party.subtract(0, 1, 0, WT_2)) { sound.stopSound(); @@ -776,7 +779,7 @@ Character *Town::doTavernOptions(Character *c) { map.mazeData()._tavernTips = (map.mazeData()._tavernTips + 1) / (isDarkCc ? 10 : 15); - Window &w = screen._windows[12]; + Window &w = windows[12]; w.open(); w.writeString(Common::String::format("\x03""c\x0B""012%s", msg.c_str())); w.update(); @@ -958,8 +961,8 @@ Character *Town::doTrainingOptions(Character *c) { void Town::depositWithdrawl(int choice) { Party &party = *_vm->_party; - Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; + Windows &windows = *_vm->_windows; int gold, gems; if (choice) { @@ -981,10 +984,10 @@ void Town::depositWithdrawl(int choice) { XeenEngine::printMil(gold).c_str(), XeenEngine::printMil(gems).c_str()); - screen._windows[35].open(); - screen._windows[35].writeString(msg); - drawButtons(&screen._windows[35]); - screen._windows[35].update(); + windows[35].open(); + windows[35].writeString(msg); + drawButtons(&windows[35]); + windows[35].update(); sound.stopSound(); File voc("coina.voc"); @@ -1010,7 +1013,7 @@ void Town::depositWithdrawl(int choice) { (!choice && !party._gold && !flag)) { party.notEnough(flag, choice, 1, WT_2); } else { - screen._windows[35].writeString(Res.AMOUNT); + windows[35].writeString(Res.AMOUNT); int amount = NumericInput::show(_vm, 35, 10, 77); if (amount) { @@ -1044,8 +1047,8 @@ void Town::depositWithdrawl(int choice) { sound.playSound(voc); msg = Common::String::format(Res.GOLD_GEMS_2, Res.DEPOSIT_WITHDRAWL[choice], XeenEngine::printMil(gold).c_str(), XeenEngine::printMil(gems).c_str()); - screen._windows[35].writeString(msg); - screen._windows[35].update(); + windows[35].writeString(msg); + windows[35].update(); } // TODO } while (!_vm->shouldQuit() && _buttonValue != Common::KEYCODE_ESCAPE); @@ -1061,6 +1064,7 @@ void Town::drawTownAnim(bool flag) { Interface &intf = *_vm->_interface; Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; + Windows &windows = *_vm->_windows; bool isDarkCc = _vm->_files->_isDarkCc; if (_townActionId == 1) { @@ -1160,7 +1164,7 @@ void Town::drawTownAnim(bool flag) { intf.assembleBorder(); } - if (screen._windows[11]._enabled) { + if (windows[11]._enabled) { _drawCtr1 = (_drawCtr1 + 1) % 2; if (!_drawCtr1 || !_drawCtr2) { _drawFrameIndex = 0; @@ -1188,7 +1192,7 @@ void Town::drawTownAnim(bool flag) { sound.playFX(45); } - screen._windows[3].update(); + windows[3].update(); } bool Town::isActive() const { @@ -1219,7 +1223,8 @@ bool TownMessage::execute(int portrait, const Common::String &name, const Common Resources &res = *_vm->_resources; Screen &screen = *_vm->_screen; Town &town = *_vm->_town; - Window &w = screen._windows[11]; + Windows &windows = *_vm->_windows; + Window &w = windows[11]; town._townMaxId = 4; town._townActionId = NO_ACTION; @@ -1262,7 +1267,7 @@ bool TownMessage::execute(int portrait, const Common::String &name, const Common res._globalSprites.draw(screen, 7, Common::Point(232, 74)); res._globalSprites.draw(screen, 0, Common::Point(235, 75)); res._globalSprites.draw(screen, 2, Common::Point(260, 75)); - screen._windows[34].update(); + windows[34].update(); intf._face1State = map._headData[party._mazePosition.y][party._mazePosition.x]._left; intf._face2State = map._headData[party._mazePosition.y][party._mazePosition.x]._right; diff --git a/engines/xeen/window.cpp b/engines/xeen/window.cpp index 3bb929fc88..aeb8328d56 100644 --- a/engines/xeen/window.cpp +++ b/engines/xeen/window.cpp @@ -25,12 +25,73 @@ namespace Xeen { -XeenEngine *Window::_vm; +Windows::Windows() { + Window windows[40] = { + Window(Common::Rect(0, 0, 320, 200), 0, 0, 0, 0, 320, 200), + Window(Common::Rect(237, 9, 317, 74), 0, 0, 237, 12, 307, 68), + Window(Common::Rect(225, 1, 319, 73), 1, 8, 225, 1, 319, 73), + Window(Common::Rect(0, 0, 230, 149), 0, 0, 9, 8, 216, 140), + Window(Common::Rect(235, 148, 309, 189), 2, 8, 0, 0, 0, 0), + Window(Common::Rect(70, 20, 250, 183), 3, 8, 80, 38, 240, 166), + Window(Common::Rect(52, 149, 268, 197), 4, 8, 0, 0, 0, 0), + Window(Common::Rect(108, 0, 200, 200), 5, 0, 0, 0, 0, 0), + Window(Common::Rect(232, 9, 312, 74), 0, 0, 0, 0, 0, 0), + Window(Common::Rect(103, 156, 217, 186), 6, 8, 0, 0, 0, 0), + Window(Common::Rect(226, 0, 319, 146), 7, 8, 0, 0, 0, 0), + Window(Common::Rect(8, 8, 224, 140), 8, 8, 8, 8, 224, 200), + Window(Common::Rect(0, 143, 320, 199), 9, 8, 0, 0, 0, 0), + Window(Common::Rect(50, 103, 266, 139), 10, 8, 0, 0, 0, 0), + Window(Common::Rect(0, 7, 320, 138), 11, 8, 0, 0, 0, 0), + Window(Common::Rect(50, 71, 182, 129), 12, 8, 0, 0, 0, 0), + Window(Common::Rect(228, 106, 319, 146), 13, 8, 0, 0, 0, 0), + Window(Common::Rect(20, 142, 290, 199), 14, 8, 0, 0, 0, 0), + Window(Common::Rect(0, 20, 320, 180), 15, 8, 0, 0, 0, 0), + Window(Common::Rect(231, 48, 317, 141), 16, 8, 0, 0, 0, 0), + Window(Common::Rect(72, 37, 248, 163), 17, 8, 0, 0, 0, 0), + Window(Common::Rect(99, 59, 237, 141), 18, 8, 99, 59, 237, 0), + Window(Common::Rect(65, 23, 250, 163), 19, 8, 75, 36, 245, 141), + Window(Common::Rect(80, 28, 256, 148), 20, 8, 80, 28, 256, 172), + Window(Common::Rect(0, 0, 320, 146), 21, 8, 0, 0, 320, 148), + Window(Common::Rect(27, 6, 207, 142), 22, 8, 0, 0, 0, 146), + Window(Common::Rect(15, 15, 161, 91), 23, 8, 0, 0, 0, 0), + Window(Common::Rect(90, 45, 220, 157), 24, 8, 0, 0, 0, 0), + Window(Common::Rect(0, 0, 320, 200), 25, 8, 0, 0, 0, 0), + Window(Common::Rect(0, 101, 320, 146), 26, 8, 0, 101, 320, 0), + Window(Common::Rect(0, 0, 320, 108), 27, 8, 0, 0, 0, 45), + Window(Common::Rect(50, 112, 266, 148), 28, 8, 0, 0, 0, 0), + Window(Common::Rect(12, 11, 164, 94), 0, 0, 0, 0, 52, 0), + Window(Common::Rect(8, 147, 224, 192), 0, 8, 0, 0, 0, 94), + Window(Common::Rect(232, 74, 312, 138), 29, 8, 0, 0, 0, 0), + Window(Common::Rect(226, 26, 319, 146), 30, 8, 0, 0, 0, 0), + Window(Common::Rect(225, 74, 319, 154), 31, 8, 0, 0, 0, 0), + Window(Common::Rect(27, 6, 195, 142), 0, 8, 0, 0, 0, 0), + Window(Common::Rect(225, 140, 319, 199), 0, 8, 0, 0, 0, 0) + }; + + _windows = Common::Array<Window>(windows, 40); +} + +void Windows::closeAll() { + for (int i = (int)_windowStack.size() - 1; i >= 0; --i) + _windowStack[i]->close(); + assert(_windowStack.size() == 0); +} + +void Windows::addToStack(Window *win) { + _windowStack.push_back(win); +} -void Window::init(XeenEngine *vm) { - _vm = vm; +void Windows::removeFromStack(Window *win) { + for (uint i = 0; i < _windowStack.size(); ++i) { + if (_windowStack[i] == win) { + _windowStack.remove_at(i); + break; + } + } } +/*------------------------------------------------------------------------*/ + Window::Window() : XSurface(), _enabled(false), _a(0), _border(0), _xLo(0), _xHi(0), _ycL(0), _ycH(0) { } @@ -40,7 +101,7 @@ Window::Window(const Window &src) : XSurface(), _enabled(src._enabled), _xHi(src._xHi), _ycH(src._ycH) { setBounds(src._bounds); - create(*_vm->_screen, Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + create(*g_vm->_screen, Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); } Window::Window(const Common::Rect &bounds, int a, int border, @@ -48,7 +109,7 @@ Window::Window(const Common::Rect &bounds, int a, int border, _enabled(false), _a(a), _border(border), _xLo(xLo), _ycL(ycL), _xHi(xHi), _ycH(ycH) { setBounds(bounds); - create(*_vm->_screen, Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + create(*g_vm->_screen, Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); } void Window::setBounds(const Common::Rect &r) { @@ -60,17 +121,17 @@ void Window::setBounds(const Common::Rect &r) { void Window::open() { if (!_enabled) { _enabled = true; - _vm->_screen->_windowStack.push_back(this); + g_vm->_windows->addToStack(this); open2(); } - if (_vm->_mode == MODE_9) { + if (g_vm->_mode == MODE_9) { warning("TODO: copyFileToMemory"); } } void Window::open2() { - Screen &screen = *_vm->_screen; + Screen &screen = *g_vm->_screen; // Save a copy of the area under the window _savedArea.create(_bounds.width(), _bounds.height()); @@ -91,7 +152,7 @@ void Window::open2() { } void Window::frame() { - Screen &screen = *_vm->_screen; + Screen &screen = *g_vm->_screen; int xCount = (_bounds.width() - 9) / FONT_WIDTH; int yCount = (_bounds.height() - 9) / FONT_HEIGHT; @@ -146,7 +207,7 @@ void Window::frame() { } void Window::close() { - Screen &screen = *_vm->_screen; + Screen &screen = *g_vm->_screen; if (_enabled) { // Update the window @@ -158,15 +219,11 @@ void Window::close() { addDirtyRect(_bounds); // Remove the window from the stack and flag it as now disabled - for (uint i = 0; i < _vm->_screen->_windowStack.size(); ++i) { - if (_vm->_screen->_windowStack[i] == this) - _vm->_screen->_windowStack.remove_at(i); - } - + g_vm->_windows->removeFromStack(this); _enabled = false; } - if (_vm->_mode == MODE_9) { + if (g_vm->_mode == MODE_9) { warning("TODO: copyFileToMemory"); } } @@ -177,15 +234,15 @@ void Window::update() { } void Window::addDirtyRect(const Common::Rect &r) { - _vm->_screen->addDirtyRect(r); + g_vm->_screen->addDirtyRect(r); } void Window::fill() { - fillRect(_innerBounds, _vm->_screen->_bgColor); + fillRect(_innerBounds, g_vm->_screen->_bgColor); } const char *Window::writeString(const Common::String &s) { - return _vm->_screen->writeString(s, _innerBounds); + return g_vm->_screen->writeString(s, _innerBounds); } void Window::drawList(DrawStruct *items, int count) { diff --git a/engines/xeen/window.h b/engines/xeen/window.h index 72bbf30afa..ad447072cd 100644 --- a/engines/xeen/window.h +++ b/engines/xeen/window.h @@ -30,7 +30,10 @@ namespace Xeen { +#define GAME_WINDOW 28 + class XeenEngine; +class Window; struct DrawStruct { SpriteResource *_sprites; @@ -45,9 +48,37 @@ struct DrawStruct { DrawStruct(): _sprites(nullptr), _frame(0), _x(0), _y(0), _scale(0), _flags(0) {} }; +class Windows { + friend class Window; +private: + Common::Array<Window> _windows; + Common::Array<Window *> _windowStack; +private: + /** + * Adds a window to the stack of currently open ones + */ + void addToStack(Window *win); + + /** + * Removes a window from the currently active stack + */ + void removeFromStack(Window *win); +public: + Windows(); + + /** + * Returns a specified window + */ + Window &operator[](int index) { return _windows[index]; } + + /** + * Close all currently open windows + */ + void closeAll(); +}; + class Window: public XSurface { private: - static XeenEngine *_vm; Common::Rect _bounds; Common::Rect _innerBounds; XSurface _savedArea; @@ -60,8 +91,6 @@ private: public: bool _enabled; public: - static void init(XeenEngine *vm); -public: Window(); Window(const Window &src); Window(const Common::Rect &bounds, int a, int border, diff --git a/engines/xeen/worldofxeen/clouds_cutscenes.cpp b/engines/xeen/worldofxeen/clouds_cutscenes.cpp index b827e5135b..30795c199f 100644 --- a/engines/xeen/worldofxeen/clouds_cutscenes.cpp +++ b/engines/xeen/worldofxeen/clouds_cutscenes.cpp @@ -88,6 +88,8 @@ bool CloudsCutscenes::showCloudsIntro() { EventsManager &events = *_vm->_events; Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; + Windows &windows = *_vm->_windows; + SpriteResource stars("stars.vga"), intro1("intro1.vga"), lake("lake.vga"), xeen("xeen.vga"), wizTower("wiztower.vga"), wizTower2("wiztwer2.vga"), lake2("lake2.vga"), lake3("lake3.vga"), @@ -216,7 +218,7 @@ bool CloudsCutscenes::showCloudsIntro() { groupo.draw(screen, 0); groupo.draw(screen, 1, Common::Point(160, 0)); crodo.draw(screen, 0, Common::Point(0, -5)); - screen._windows[0].writeString(Res.CLOUDS_INTRO1); + windows[0].writeString(Res.CLOUDS_INTRO1); // Unroll a scroll if (doScroll(false, true)) @@ -284,7 +286,7 @@ bool CloudsCutscenes::showCloudsIntro() { case 12: case 13: { crodo.draw(screen, 0, Common::Point(0, -5)); - screen._windows[0].writeString(Res.CLOUDS_INTRO1); + windows[0].writeString(Res.CLOUDS_INTRO1); ctr5 = (ctr5 + 1) % 19; WAIT(1); @@ -297,7 +299,7 @@ bool CloudsCutscenes::showCloudsIntro() { if (lookup > 30) lookup = 30; frameCtr = _INTRO_FRAMES_VALS[_INTRO_FRAMES_LOOKUP[lineCtr]][lookup]; - screen._windows[0].writeString(Res.CLOUDS_INTRO1); + windows[0].writeString(Res.CLOUDS_INTRO1); ctr5 = (ctr5 + 1) % 19; WAIT(1); diff --git a/engines/xeen/worldofxeen/darkside_cutscenes.cpp b/engines/xeen/worldofxeen/darkside_cutscenes.cpp index 83d9323f31..b3029463b9 100644 --- a/engines/xeen/worldofxeen/darkside_cutscenes.cpp +++ b/engines/xeen/worldofxeen/darkside_cutscenes.cpp @@ -1182,6 +1182,7 @@ void DarkSideCutscenes::showPharaohEndText(const char *msg1, const char *msg2, c }; Screen &screen = *_vm->_screen; EventsManager &events = *_vm->_events; + Windows &windows = *_vm->_windows; SpriteResource claw("claw.int"); SpriteResource dragon1("dragon1.int"); int numPages = 0 + (msg1 ? 1 : 0) + (msg2 ? 1 : 0) + (msg3 ? 1 : 0); @@ -1213,11 +1214,11 @@ void DarkSideCutscenes::showPharaohEndText(const char *msg1, const char *msg2, c // Form the text string to display the text Common::String str1 = Common::String::format(Res.PHAROAH_ENDING_TEXT1, text[pageNum]); - screen._windows[39].writeString(str1); + windows[39].writeString(str1); Common::String str2 = Common::String::format(Res.PHAROAH_ENDING_TEXT2, text[pageNum]); - screen._windows[39].writeString(str2); + windows[39].writeString(str2); idx = (idx + 1) % 32; screen.update(); diff --git a/engines/xeen/worldofxeen/worldofxeen_menu.cpp b/engines/xeen/worldofxeen/worldofxeen_menu.cpp index fb25ba1757..919b003b1c 100644 --- a/engines/xeen/worldofxeen/worldofxeen_menu.cpp +++ b/engines/xeen/worldofxeen/worldofxeen_menu.cpp @@ -53,12 +53,13 @@ void WorldOfXeenMenu::show(XeenEngine *vm) { void WorldOfXeenMenu::execute() { SpriteResource special("special.icn"); Screen &screen = *_vm->_screen; + Windows &windows = *_vm->_windows; EventsManager &events = *_vm->_events; File newBright("newbrigh.m"); _vm->_sound->playSong(newBright); - screen._windows[GAME_WINDOW].setBounds(Common::Rect(72, 25, 248, 175)); + windows[GAME_WINDOW].setBounds(Common::Rect(72, 25, 248, 175)); Common::String title1, title2; startup(title1, title2); @@ -129,6 +130,7 @@ void WorldOfXeenMenu::showTitles2() { Screen &screen = *_vm->_screen; EventsManager &events = *_vm->_events; Sound &sound = *_vm->_sound; + Windows &windows = *_vm->_windows; SpriteResource titleSprites("title2b.raw"); SpriteResource kludgeSprites("kludge.int"); @@ -147,7 +149,7 @@ void WorldOfXeenMenu::showTitles2() { events.updateGameCounter(); screen.restoreBackground(); title2Sprites[i / 4].draw(screen, i % 4); - screen._windows[0].update(); + windows[0].update(); if (i == 19) sound.stopSound(); @@ -157,7 +159,7 @@ void WorldOfXeenMenu::showTitles2() { } screen.restoreBackground(); - screen._windows[0].update(); + windows[0].update(); } void WorldOfXeenMenu::setupButtons(SpriteResource *buttons) { @@ -208,23 +210,25 @@ void WorldOptionsMenu::setBackground(bool doFade) { } void WorldOptionsMenu::openWindow() { - _vm->_screen->_windows[GAME_WINDOW].open(); + Windows &windows = *_vm->_windows; + windows[GAME_WINDOW].open(); } void WorldOptionsMenu::showContents(SpriteResource &title1, bool waitFlag) { - Screen &screen = *_vm->_screen; EventsManager &events = *_vm->_events; + Screen &screen = *_vm->_screen; + Windows &windows = *_vm->_windows; events.updateGameCounter(); // Draw the background frame in a continous cycle _bgFrame = (_bgFrame + 1) % 5; - title1.draw(screen._windows[0], _bgFrame); + title1.draw(windows[0], _bgFrame); // Draw the basic frame for the optitons menu and title text - screen._windows[GAME_WINDOW].frame(); - screen._windows[GAME_WINDOW].writeString(Res.OPTIONS_TITLE); + windows[GAME_WINDOW].frame(); + windows[GAME_WINDOW].writeString(Res.OPTIONS_TITLE); - drawButtons(&screen._windows[0]); + drawButtons(&windows[0]); screen.update(); if (waitFlag) { diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp index d2b5cfa333..9218f6c5d5 100644 --- a/engines/xeen/xeen.cpp +++ b/engines/xeen/xeen.cpp @@ -57,6 +57,7 @@ XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc) _sound = nullptr; _spells = nullptr; _town = nullptr; + _windows = nullptr; _eventData = nullptr; _noDirectionSense = false; _startupWindowActive = false; @@ -80,6 +81,7 @@ XeenEngine::~XeenEngine() { delete _sound; delete _spells; delete _town; + delete _windows; delete _eventData; delete _resources; delete _files; @@ -99,10 +101,10 @@ void XeenEngine::initialize() { _saves = new SavesManager(this, *_party); _screen = new Screen(this); _scripts = new Scripts(this); - _screen->setupWindows(); _sound = new Sound(this, _mixer); _spells = new Spells(this); _town = new Town(this); + _windows = new Windows(); File f("029.obj"); _eventData = f.readStream(f.size()); @@ -294,9 +296,9 @@ void XeenEngine::play() { // _screen->fadeOut(); } - _screen->_windows[0].update(); + (*_windows)[0].update(); _interface->mainIconsPrint(); - _screen->_windows[0].update(); + (*_windows)[0].update(); _events->setCursor(0); _combat->_moveMonsters = true; diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h index 5cd30aaf7a..51845d78ce 100644 --- a/engines/xeen/xeen.h +++ b/engines/xeen/xeen.h @@ -46,6 +46,7 @@ #include "xeen/sound.h" #include "xeen/spells.h" #include "xeen/town.h" +#include "xeen/window.h" /** * This is the namespace of the Xeen engine. @@ -152,6 +153,7 @@ public: Sound *_sound; Spells *_spells; Town *_town; + Windows *_windows; Mode _mode; GameEvent _gameEvent; Common::SeekableReadStream *_eventData; |