1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef ULTIMA_ULTIMA1_U1DIALOGS_STATS_H 24 #define ULTIMA_ULTIMA1_U1DIALOGS_STATS_H 25 26 #include "ultima/ultima1/u1dialogs/full_screen_dialog.h" 27 #include "common/array.h" 28 29 namespace Ultima { 30 namespace Ultima1 { 31 namespace U1Dialogs { 32 33 using Shared::CShowMsg; 34 using Shared::CCharacterInputMsg; 35 36 /** 37 * Implements the stats/inventory dialog 38 */ 39 class Stats : public FullScreenDialog { 40 DECLARE_MESSAGE_MAP; 41 bool ShowMsg(CShowMsg *msg); 42 bool CharacterInputMsg(CCharacterInputMsg *msg); 43 public: 44 /** 45 * Contains the data for a single stat entry to display 46 */ 47 struct StatEntry { 48 Common::String _line; 49 byte _color; 50 StatEntryStatEntry51 StatEntry() : _color(0) {} StatEntryStatEntry52 StatEntry(const Common::String &line, byte color) : _line(line), _color(color) {} 53 }; 54 55 /** 56 * Format a name/value text with dots between them 57 * @param name Stat/item name 58 * @param value The value/quantity 59 * @returns The formatted display of name dots value 60 */ 61 static Common::String formatStat(const char *name, uint value); 62 private: 63 Common::Array<StatEntry> _stats; 64 uint _startingIndex; 65 private: 66 /** 67 * Loads the list of stats to display into an array 68 */ 69 void load(); 70 71 /** 72 * Add a range of values into the stats list 73 * @param names Stat names 74 * @param values Values 75 * @param start Starting index 76 * @param end Ending index 77 * @param equippedIndex Equipped item index, if applicable 78 * @param row Starting text row 79 * @returns Ending text row 80 */ 81 void addStats(const char *const *names, const uint *values, int start, int end, int equippedIndex = -1); 82 public: 83 CLASSDEF; 84 85 /** 86 * Constructor 87 */ Stats(Ultima1Game * game)88 Stats(Ultima1Game *game) : FullScreenDialog(game), _startingIndex(0) { 89 load(); 90 } 91 92 /** 93 * Draws the visual item on the screen 94 */ 95 void draw() override; 96 }; 97 98 } // End of namespace U1Dialogs 99 } // End of namespace Ultima1 100 } // End of namespace Ultima 101 102 #endif 103