From 78234db2c02c95e1b9e88b4096b9a9c96fd95adf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 1 Feb 2015 19:04:28 -0500 Subject: XEEN: Add Quick Reference dialog --- engines/xeen/combat.cpp | 1 + engines/xeen/combat.h | 1 + engines/xeen/dialogs_char_info.cpp | 7 ++- engines/xeen/dialogs_quick_ref.cpp | 89 ++++++++++++++++++++++++++++++++++++++ engines/xeen/dialogs_quick_ref.h | 43 ++++++++++++++++++ engines/xeen/font.cpp | 10 +---- engines/xeen/interface.cpp | 6 +++ engines/xeen/module.mk | 1 + engines/xeen/party.cpp | 2 +- engines/xeen/party.h | 2 +- engines/xeen/resources.cpp | 17 +++++++- engines/xeen/resources.h | 6 ++- 12 files changed, 171 insertions(+), 14 deletions(-) create mode 100644 engines/xeen/dialogs_quick_ref.cpp create mode 100644 engines/xeen/dialogs_quick_ref.h (limited to 'engines') diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp index 4d3cb53bf9..6237e0c5ba 100644 --- a/engines/xeen/combat.cpp +++ b/engines/xeen/combat.cpp @@ -33,6 +33,7 @@ Combat::Combat(XeenEngine *vm): _vm(vm) { Common::fill(&_elemPow[0], &_elemPow[12], 0); Common::fill(&_elemScale[0], &_elemScale[12], 0); Common::fill(&_shooting[0], &_shooting[8], 0); + _globalCombat = 0; } void Combat::clear() { diff --git a/engines/xeen/combat.h b/engines/xeen/combat.h index 550b39fd2e..c2554d5bf9 100644 --- a/engines/xeen/combat.h +++ b/engines/xeen/combat.h @@ -58,6 +58,7 @@ public: int _elemPow[12]; int _elemScale[12]; bool _shooting[8]; + int _globalCombat; public: Combat(XeenEngine *vm); diff --git a/engines/xeen/dialogs_char_info.cpp b/engines/xeen/dialogs_char_info.cpp index 44ce73e541..985309aa8c 100644 --- a/engines/xeen/dialogs_char_info.cpp +++ b/engines/xeen/dialogs_char_info.cpp @@ -22,6 +22,7 @@ #include "xeen/dialogs_char_info.h" #include "xeen/dialogs_exchange.h" +#include "xeen/dialogs_quick_ref.h" #include "xeen/resources.h" #include "xeen/xeen.h" @@ -194,6 +195,11 @@ void CharacterInfo::execute(int charIndex) { _vm->_mode = MODE_CHARACTER_INFO; break; + case Common::KEYCODE_q: + QuickReferenceDialog::show(_vm); + redrawFlag = true; + break; + case Common::KEYCODE_ESCAPE: goto exit; } @@ -568,5 +574,4 @@ bool CharacterInfo::expandStat(int attrib, const Character &c) { return false; } - } // End of namespace Xeen diff --git a/engines/xeen/dialogs_quick_ref.cpp b/engines/xeen/dialogs_quick_ref.cpp new file mode 100644 index 0000000000..a54bb06025 --- /dev/null +++ b/engines/xeen/dialogs_quick_ref.cpp @@ -0,0 +1,89 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "xeen/dialogs_quick_ref.h" +#include "xeen/resources.h" +#include "xeen/xeen.h" + +namespace Xeen { + +void QuickReferenceDialog::show(XeenEngine *vm) { + QuickReferenceDialog *dlg = new QuickReferenceDialog(vm); + dlg->execute(); + delete dlg; +} + +void QuickReferenceDialog::execute() { + Combat &combat = *_vm->_combat; + EventsManager &events = *_vm->_events; + Interface &intf = *_vm->_interface; + Party &party = *_vm->_party; + Screen &screen = *_vm->_screen; + Common::String lines[8]; + + events.setCursor(0); + + for (uint idx = 0; idx < (combat._globalCombat == 2 ? party._combatParty.size() : + party._partyCount); ++idx) { + Character &c = combat._globalCombat == 2 ? *party._combatParty[idx] : + party._activeParty[idx]; + Condition condition = c.worstCondition(); + lines[idx] = Common::String::format(QUICK_REF_LINE, + idx * 10 + 24, idx + 1, c._name.c_str(), + CLASS_NAMES[c._class][0], CLASS_NAMES[c._class][1], CLASS_NAMES[c._class][2], + c.statColor(c.getCurrentLevel(), c._level._permanent), c._level._permanent, + c.statColor(c._currentHp, c.getMaxHP()), c._currentHp, + c.statColor(c._currentSp, c.getMaxSP()), c._currentSp, + c.statColor(c.getArmorClass(), c.getArmorClass(true)), c.getArmorClass(), + CONDITION_COLORS[condition], + CONDITION_NAMES[condition][0], CONDITION_NAMES[condition][1], + CONDITION_NAMES[condition][2], CONDITION_NAMES[condition][3] + ); + } + + int food = (party._food / party._partyCount) / 3; + Common::String msg = Common::String::format(QUICK_REFERENCE, + 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(), + party._gold, party._gems, + food, food == 1 ? "" : "s" + ); + + Window &w = screen._windows[24]; + bool windowOpen = w._enabled; + if (!windowOpen) + w.open(); + w.writeString(msg); + w.update(); + + // Wait for a key/mouse press + events.clearEvents(); + while (!_vm->shouldQuit() && !events.isKeyMousePressed()) + events.pollEventsAndWait(); + events.clearEvents(); + + if (!windowOpen) + w.close(); +} + +} // End of namespace Xeen diff --git a/engines/xeen/dialogs_quick_ref.h b/engines/xeen/dialogs_quick_ref.h new file mode 100644 index 0000000000..0c1b8e3f91 --- /dev/null +++ b/engines/xeen/dialogs_quick_ref.h @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef XEEN_DIALOGS_QUICK_REF_H +#define XEEN_DIALOGS_QUICK_REF_H + +#include "xeen/dialogs.h" + +namespace Xeen { + +class QuickReferenceDialog : public ButtonContainer { +private: + XeenEngine *_vm; + + QuickReferenceDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {} + + void execute(); +public: + static void show(XeenEngine *vm); +}; + +} // End of namespace Xeen + +#endif /* XEEN_DIALOGS_QUICK_REF_H */ diff --git a/engines/xeen/font.cpp b/engines/xeen/font.cpp index 1668ef5ae8..aca747e776 100644 --- a/engines/xeen/font.cpp +++ b/engines/xeen/font.cpp @@ -28,19 +28,13 @@ namespace Xeen { FontSurface::FontSurface() : XSurface(), _fontData(nullptr), _bgColor(DEFAULT_BG_COLOR), _fontReduced(false),_fontJustify(JUSTIFY_NONE), _msgWraps(false) { - _textColors[0] = 0; - _textColors[1] = 0x40; - _textColors[2] = 0x30; - _textColors[3] = 0x20; + setTextColor(0); } FontSurface::FontSurface(int wv, int hv) : XSurface(wv, hv), _fontData(nullptr), _msgWraps(false), _bgColor(DEFAULT_BG_COLOR), _fontReduced(false), _fontJustify(JUSTIFY_NONE) { create(w, h); - _textColors[0] = 0; - _textColors[1] = 0x40; - _textColors[2] = 0x30; - _textColors[3] = 0x20; + setTextColor(0); } /** diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp index a33c726fd3..520cad5c05 100644 --- a/engines/xeen/interface.cpp +++ b/engines/xeen/interface.cpp @@ -25,6 +25,7 @@ #include "xeen/dialogs_error.h" #include "xeen/dialogs_automap.h" #include "xeen/dialogs_info.h" +#include "xeen/dialogs_quick_ref.h" #include "xeen/resources.h" #include "xeen/xeen.h" @@ -704,6 +705,11 @@ void Interface::perform() { AutoMapDialog::show(_vm); break; + case Common::KEYCODE_q: + // Show the quick reference dialog + QuickReferenceDialog::show(_vm); + break; + default: break; } diff --git a/engines/xeen/module.mk b/engines/xeen/module.mk index 8d3a5e52bf..eef8d78455 100644 --- a/engines/xeen/module.mk +++ b/engines/xeen/module.mk @@ -17,6 +17,7 @@ MODULE_OBJS := \ dialogs_options.o \ dialogs_info.o \ dialogs_input.o \ + dialogs_quick_ref.o \ dialogs_spells.o \ dialogs_whowill.o \ dialogs_yesno.o \ diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp index d046595579..ce5ccd0bc1 100644 --- a/engines/xeen/party.cpp +++ b/engines/xeen/party.cpp @@ -309,7 +309,7 @@ int Character::statColor(int amount, int threshold) { return 32; } -int Character::statBonus(int statValue) const { +int Character::statBonus(uint statValue) const { int idx; for (idx = 0; STAT_VALUES[idx] <= statValue; ++idx) ; diff --git a/engines/xeen/party.h b/engines/xeen/party.h index 5adc9b1c7f..65e6608d71 100644 --- a/engines/xeen/party.h +++ b/engines/xeen/party.h @@ -151,7 +151,7 @@ public: static int statColor(int amount, int threshold); - int statBonus(int statValue) const; + int statBonus(uint statValue) const; bool charSavingThrow(DamageType attackType) const; diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp index 0847944147..eecc5b8027 100644 --- a/engines/xeen/resources.cpp +++ b/engines/xeen/resources.cpp @@ -543,9 +543,9 @@ const int AGE_RANGES_ADJUST[2][10] = { { -250, -50, -20, -10, 0, 2, 5, 10, 20, 50 } }; -const int STAT_VALUES[24] = { +const uint STAT_VALUES[24] = { 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 25, 30, 35, 40, - 50, 75, 100, 125, 150, 175, 200, 225, 250, 65535 + 50, 75, 100, 125, 150, 175, 200, 225, 250, }; const int STAT_BONUSES[24] = { @@ -971,4 +971,17 @@ const char *const FOOD_TEXT = const char *const EXCHANGE_WITH_WHOM = "\t010\v005Exchange with whom?"; +const char *const QUICK_REF_LINE = + "\xB%3d\x9""007%u)\x9""027%s\x9""110%c%c%c\x3r\x9""160\xC%02u%u\xC""d" + "\x3l\x9""170\xC%02u%d\xC""d\x9""208\xC%02u%u\xC""d\x9""247\xC" + "%02u%u\xC""d\x9""270\xC%02u%c%c%c%c\xC""d"; + +const char *const QUICK_REFERENCE = + "\xD\x3""cQuick Reference Chart\xB""012\x3l" + "\x9""007#\x9""027Name\x9""110Cls\x9""140Lvl\x9""176H.P." + "\x9""212S.P.\x9""241A.C.\x9""270Cond" + "%s%s%s%s%s%s%s%s" + "\xB""110\x9""064\x3""cGold\x9""144Gems\x9""224Food\xB""119" + "\x9""064\xC""15%lu\x9""144%lu\x9""224%u day%s\xC""d"; + } // End of namespace Xeen diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h index 64387e7f54..e8f5c31867 100644 --- a/engines/xeen/resources.h +++ b/engines/xeen/resources.h @@ -147,7 +147,7 @@ extern const int AGE_RANGES[10]; extern const int AGE_RANGES_ADJUST[2][10]; -extern const int STAT_VALUES[24]; +extern const uint STAT_VALUES[24]; extern const int STAT_BONUSES[24]; @@ -323,6 +323,10 @@ extern const char *const FOOD_TEXT; extern const char *const EXCHANGE_WITH_WHOM; +extern const char *const QUICK_REF_LINE; + +extern const char *const QUICK_REFERENCE; + } // End of namespace Xeen #endif /* XEEN_RESOURCES_H */ -- cgit v1.2.3