diff options
author | Paul Gilbert | 2015-02-13 23:48:02 -0500 |
---|---|---|
committer | Paul Gilbert | 2015-02-13 23:48:02 -0500 |
commit | 9b0b0cd9e747780ec32a3589343f0172c0237aa0 (patch) | |
tree | 91bb9140b2188acb1112551cc948305dd1457193 /engines/xeen | |
parent | d225bc4cb3364b2cc8fc0fcab96347cc91e93866 (diff) | |
download | scummvm-rg350-9b0b0cd9e747780ec32a3589343f0172c0237aa0.tar.gz scummvm-rg350-9b0b0cd9e747780ec32a3589343f0172c0237aa0.tar.bz2 scummvm-rg350-9b0b0cd9e747780ec32a3589343f0172c0237aa0.zip |
XEEN: Implemented exchangeAttribute
Diffstat (limited to 'engines/xeen')
-rw-r--r-- | engines/xeen/dialogs.h | 3 | ||||
-rw-r--r-- | engines/xeen/dialogs_party.cpp | 77 | ||||
-rw-r--r-- | engines/xeen/resources.cpp | 2 | ||||
-rw-r--r-- | engines/xeen/resources.h | 1 |
4 files changed, 80 insertions, 3 deletions
diff --git a/engines/xeen/dialogs.h b/engines/xeen/dialogs.h index ba27fe97ec..02e945b665 100644 --- a/engines/xeen/dialogs.h +++ b/engines/xeen/dialogs.h @@ -66,7 +66,8 @@ public: void restoreButtons(); - void addButton(const Common::Rect &bounds, int val, SpriteResource *sprites, bool draw = true); + void addButton(const Common::Rect &bounds, int val, + SpriteResource *sprites = nullptr, bool draw = true); void addPartyButtons(XeenEngine *vm); }; diff --git a/engines/xeen/dialogs_party.cpp b/engines/xeen/dialogs_party.cpp index 058ead4edc..b570612ff4 100644 --- a/engines/xeen/dialogs_party.cpp +++ b/engines/xeen/dialogs_party.cpp @@ -874,9 +874,83 @@ void PartyDialog::drawDice(SpriteResource &dice) { * Exchanging two attributes for the character being rolled */ int PartyDialog::exchangeAttribute(int srcAttr) { - error("TODO: exchangeAttribute"); + EventsManager &events = *_vm->_events; + Screen &screen = *_vm->_screen; + SpriteResource icons; + icons.load("create2.icn"); + + saveButtons(); + addButton(Common::Rect(118, 58, 142, 78), Common::KEYCODE_ESCAPE, &icons); + addButton(Common::Rect(168, 19, 192, 39), Common::KEYCODE_m); + addButton(Common::Rect(168, 43, 192, 63), Common::KEYCODE_i); + addButton(Common::Rect(168, 67, 192, 87), Common::KEYCODE_p); + addButton(Common::Rect(168, 91, 192, 111), Common::KEYCODE_e); + addButton(Common::Rect(168, 115, 192, 135), Common::KEYCODE_s); + 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]; + w.open(); + w.writeString(Common::String::format(EXCHANGE_ATTR_WITH, STAT_NAMES[srcAttr - 1])); + icons.draw(w, 0, Common::Point(118, 58)); + w.update(); + + int result = 0; + bool breakFlag = false; + while (!_vm->shouldQuit() && !breakFlag) { + // Wait for an action + do { + events.pollEventsAndWait(); + checkEvents(_vm); + } while (!_vm->shouldQuit() && !_buttonValue); + + Attribute destAttr; + switch (_buttonValue) { + case Common::KEYCODE_m: + destAttr = MIGHT; + break; + case Common::KEYCODE_i: + destAttr = INTELLECT; + break; + case Common::KEYCODE_p: + destAttr = PERSONALITY; + break; + case Common::KEYCODE_e: + destAttr = ENDURANCE; + break; + case Common::KEYCODE_s: + destAttr = SPEED; + break; + case Common::KEYCODE_a: + destAttr = ACCURACY; + break; + case Common::KEYCODE_l: + destAttr = LUCK; + break; + case Common::KEYCODE_ESCAPE: + result = 0; + breakFlag = true; + continue; + default: + continue; + } + + if ((srcAttr - 1) != destAttr) { + result = destAttr + 1; + break; + } + } + + w.close(); + _buttonValue = 0; + restoreButtons(); + + return result; } +/** + * Saves the rolled character into the roster + */ bool PartyDialog::saveCharacter(Character &c, CharacterClass classId, Race race, Sex sex, uint attribs[TOTAL_ATTRIBUTES]) { if (classId == -1) { @@ -953,5 +1027,4 @@ bool PartyDialog::saveCharacter(Character &c, CharacterClass classId, return true; } - } // End of namespace Xeen diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp index c9c377d3a6..7dca04fd03 100644 --- a/engines/xeen/resources.cpp +++ b/engines/xeen/resources.cpp @@ -1471,6 +1471,8 @@ const char *const NAME_FOR_NEW_CHARACTER = "\x3""cEnter a Name for this Character"; const char *const SELECT_CLASS_BEFORE_SAVING = "\v006\x3""cSelect a Class before saving.\x3l"; +const char *const EXCHANGE_ATTR_WITH = "Exchange %s with..."; + const int NEW_CHAR_SKILLS[10] = { 1, 5, -1, -1, 4, 0, 0, -1, 6, 11 }; const int NEW_CHAR_SKILLS_LEN[10] = { 11, 8, 0, 0, 12, 8, 8, 0, 9, 11 }; const int NEW_CHAR_RACE_SKILLS[10] = { 14, -1, 17, 16, -1, 0, 0, 0, 0, 0 }; diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h index 3c6df78a8f..53c548fbf5 100644 --- a/engines/xeen/resources.h +++ b/engines/xeen/resources.h @@ -509,6 +509,7 @@ extern const char *const CREATE_CHAR_DETAILS; extern const char *const NEW_CHAR_STATS; extern const char *const NAME_FOR_NEW_CHARACTER; extern const char *const SELECT_CLASS_BEFORE_SAVING; +extern const char *const EXCHANGE_ATTR_WITH; extern const int NEW_CHAR_SKILLS[10]; extern const int NEW_CHAR_SKILLS_LEN[10]; extern const int NEW_CHAR_RACE_SKILLS[10]; |