diff options
Diffstat (limited to 'engines/xeen')
-rw-r--r-- | engines/xeen/character.cpp | 13 | ||||
-rw-r--r-- | engines/xeen/dialogs_confirm.cpp | 85 | ||||
-rw-r--r-- | engines/xeen/dialogs_confirm.h | 43 | ||||
-rw-r--r-- | engines/xeen/dialogs_query.cpp (renamed from engines/xeen/dialogs_yesno.cpp) | 65 | ||||
-rw-r--r-- | engines/xeen/dialogs_query.h (renamed from engines/xeen/dialogs_yesno.h) | 17 | ||||
-rw-r--r-- | engines/xeen/dialogs_spells.cpp | 4 | ||||
-rw-r--r-- | engines/xeen/module.mk | 3 | ||||
-rw-r--r-- | engines/xeen/resources.cpp | 2 | ||||
-rw-r--r-- | engines/xeen/resources.h | 2 | ||||
-rw-r--r-- | engines/xeen/scripts.cpp | 2 | ||||
-rw-r--r-- | engines/xeen/town.cpp | 2 |
11 files changed, 97 insertions, 141 deletions
diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp index 20cbfbd0fc..8fd7a35c5f 100644 --- a/engines/xeen/character.cpp +++ b/engines/xeen/character.cpp @@ -21,6 +21,7 @@ */ #include "xeen/character.h" +#include "xeen/dialogs_query.h" #include "xeen/dialogs_error.h" #include "xeen/resources.h" #include "xeen/xeen.h" @@ -128,13 +129,19 @@ bool InventoryItems::discardItem(int itemIndex) { if (item._bonusFlags & ITEMFLAG_CURSED) { ErrorScroll::show(vm, CANNOT_DISCARD_CURSED_ITEM); - return false; } else { Common::String itemDesc = getFullDescription(itemIndex, 4); + Common::String msg = Common::String::format(PERMANENTLY_DISCARD, itemDesc.c_str()); + + if (Confirm::show(vm, msg)) { + operator[](itemIndex).clear(); + sort(); - error("TODO: discardItem - %s", itemDesc.c_str()); + return true; + } } - error("TODO"); + + return true; } /** diff --git a/engines/xeen/dialogs_confirm.cpp b/engines/xeen/dialogs_confirm.cpp deleted file mode 100644 index 13a41e76ca..0000000000 --- a/engines/xeen/dialogs_confirm.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* 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_confirm.h" -#include "xeen/xeen.h" - -namespace Xeen { - -bool ConfirmDialog::show(XeenEngine *vm, const Common::String &msg, int v2) { - ConfirmDialog *dlg = new ConfirmDialog(vm); - bool result = dlg->execute(msg, v2); - delete dlg; - - return result; -} - -bool ConfirmDialog::execute(const Common::String &msg, int v2) { - Screen &screen = *_vm->_screen; - EventsManager &events = *_vm->_events; - SpriteResource confirmSprites; - confirmSprites.load("confirm.icn"); - - addButton(Common::Rect(129, 112, 153, 132), Common::KEYCODE_y, &confirmSprites); - addButton(Common::Rect(185, 112, 209, 132), Common::KEYCODE_n, &confirmSprites); - - Window &w = screen._windows[v2 ? 21 : 22]; - w.open(); - - if (v2) { - confirmSprites.draw(screen._windows[21], 0, Common::Point(129, 112)); - confirmSprites.draw(screen._windows[21], 2, Common::Point(185, 112)); - - _buttons[0]._bounds.moveTo(129, 112); - _buttons[1]._bounds.moveTo(185, 112); - } else if (v2 & 0x80) { - clearButtons(); - } else { - confirmSprites.draw(screen._windows[22], 0, Common::Point(120, 133)); - confirmSprites.draw(screen._windows[22], 2, Common::Point(176, 133)); - - _buttons[0]._bounds.moveTo(120, 133); - _buttons[1]._bounds.moveTo(176, 133); - } - - w.writeString(msg); - w.update(); - - bool result = false; - while (!_vm->shouldQuit()) { - while (!events.isKeyMousePressed()) - events.pollEventsAndWait(); - - if ((v2 & 0x80) || _buttonValue == Common::KEYCODE_ESCAPE || - _buttonValue == Common::KEYCODE_y) - break; - else if (_buttonValue == Common::KEYCODE_y) { - result = true; - break; - } - } - - w.close(); - return result; -} - -} // End of namespace Xeen diff --git a/engines/xeen/dialogs_confirm.h b/engines/xeen/dialogs_confirm.h deleted file mode 100644 index 825be5e764..0000000000 --- a/engines/xeen/dialogs_confirm.h +++ /dev/null @@ -1,43 +0,0 @@ -/* 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_CONFIRM_H -#define XEEN_DIALOGS_CONFIRM_H - -#include "xeen/dialogs.h" - -namespace Xeen { - -class ConfirmDialog : public ButtonContainer { -private: - XeenEngine *_vm; - - ConfirmDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {} - - bool execute(const Common::String &msg, int v2); -public: - static bool show(XeenEngine *vm, const Common::String &msg, int v2); -}; - -} // End of namespace Xeen - -#endif /* XEEN_DIALOGS_CONFIRM_H */ diff --git a/engines/xeen/dialogs_yesno.cpp b/engines/xeen/dialogs_query.cpp index 17ca9a0c3e..f226521a94 100644 --- a/engines/xeen/dialogs_yesno.cpp +++ b/engines/xeen/dialogs_query.cpp @@ -20,11 +20,74 @@ * */ -#include "xeen/dialogs_yesno.h" +#include "xeen/dialogs_query.h" #include "xeen/xeen.h" namespace Xeen { +bool Confirm::show(XeenEngine *vm, const Common::String &msg, int mode) { + Confirm *dlg = new Confirm(vm); + bool result = dlg->execute(msg, mode); + delete dlg; + + return result; +} + +bool Confirm::execute(const Common::String &msg, int mode) { + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + SpriteResource confirmSprites; + bool result = false; + + confirmSprites.load("confirm.icn"); + 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]; + w.open(); + + if (!mode) { + confirmSprites.draw(w, 0, Common::Point(129, 112)); + confirmSprites.draw(w, 2, Common::Point(185, 112)); + _buttons[0]._bounds.moveTo(129, 112); + _buttons[1]._bounds.moveTo(185, 112); + } else { + if (mode & 0x80) { + clearButtons(); + } else { + confirmSprites.draw(w, 0, Common::Point(120, 133)); + confirmSprites.draw(w, 2, Common::Point(176, 133)); + _buttons[0]._bounds.moveTo(120, 133); + _buttons[1]._bounds.moveTo(176, 133); + } + } + + w.writeString(msg); + w.update(); + + events.clearEvents(); + while (!_vm->shouldQuit()) { + while (!_vm->shouldQuit() && !_buttonValue) { + events.pollEvents(); + checkEvents(_vm); + } + + if ((mode & 0x80) || _buttonValue == Common::KEYCODE_ESCAPE + || _buttonValue == Common::KEYCODE_n) + break; + + if (_buttonValue == Common::KEYCODE_y) { + result = true; + break; + } + } + + w.close(); + return result; +} + +/*------------------------------------------------------------------------*/ + bool YesNo::show(XeenEngine *vm, bool type, bool townFlag) { YesNo *dlg = new YesNo(vm); bool result = dlg->execute(type, townFlag); diff --git a/engines/xeen/dialogs_yesno.h b/engines/xeen/dialogs_query.h index 96c3592d9d..96ae488b97 100644 --- a/engines/xeen/dialogs_yesno.h +++ b/engines/xeen/dialogs_query.h @@ -20,13 +20,24 @@ * */ -#ifndef XEEN_DIALOGS_YESNO_H -#define XEEN_DIALOGS_YESNO_H +#ifndef XEEN_DIALOGS_QUERY_H +#define XEEN_DIALOGS_QUERY_H #include "xeen/dialogs.h" namespace Xeen { +class Confirm : public ButtonContainer { +private: + XeenEngine *_vm; + + Confirm(XeenEngine *vm) : ButtonContainer(), _vm(vm) {} + + bool execute(const Common::String &msg, int mode); +public: + static bool show(XeenEngine *vm, const Common::String &msg, int mode = 0); +}; + class YesNo : public ButtonContainer { private: XeenEngine *_vm; @@ -40,4 +51,4 @@ public: } // End of namespace Xeen -#endif /* XEEN_DIALOGS_YESNO_H */ +#endif /* XEEN_DIALOGS_QUERY_H */ diff --git a/engines/xeen/dialogs_spells.cpp b/engines/xeen/dialogs_spells.cpp index 714e881128..4f86707554 100644 --- a/engines/xeen/dialogs_spells.cpp +++ b/engines/xeen/dialogs_spells.cpp @@ -21,7 +21,7 @@ */ #include "xeen/dialogs_spells.h" -#include "xeen/dialogs_confirm.h" +#include "xeen/dialogs_query.h" #include "xeen/resources.h" #include "xeen/spells.h" #include "xeen/sprites.h" @@ -216,7 +216,7 @@ Character *SpellsScroll::execute(Character *c, int v2) { Common::String::format(SPELLS_PRESS_A_KEY, msg.c_str()) : Common::String::format(SPELLS_PURCHASE, msg.c_str(), spellCost); - if (ConfirmDialog::show(_vm, msg, v2Copy + 1)) { + if (Confirm::show(_vm, msg, v2Copy + 1)) { if (party.subtract(0, spellCost, 0, WT_FREEZE_WAIT)) { ++c->_spells[spellIndex]; sound.playSample(nullptr, 0); diff --git a/engines/xeen/module.mk b/engines/xeen/module.mk index 25568523cd..6a36f91bf8 100644 --- a/engines/xeen/module.mk +++ b/engines/xeen/module.mk @@ -12,17 +12,16 @@ MODULE_OBJS := \ automap.o \ dialogs_automap.o \ dialogs_char_info.o \ - dialogs_confirm.o \ dialogs_error.o \ dialogs_exchange.o \ dialogs_options.o \ dialogs_info.o \ dialogs_input.o \ dialogs_items.o \ + dialogs_query.o \ dialogs_quick_ref.o \ dialogs_spells.o \ dialogs_whowill.o \ - dialogs_yesno.o \ events.o \ files.o \ font.o \ diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp index 5cd09cf422..0f6588af9a 100644 --- a/engines/xeen/resources.cpp +++ b/engines/xeen/resources.cpp @@ -1144,4 +1144,6 @@ const char *const CANNOT_REMOVE_CURSED_ITEM = "\x3""You cannot remove a cursed i const char *const CANNOT_DISCARD_CURSED_ITEM = "\3x""cYou cannot discard a cursed item!"; +const char *const PERMANENTLY_DISCARD = "\v000\t000\x03lPermanently discard %s\fd?"; + } // End of namespace Xeen diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h index 8be195f34e..87b9468064 100644 --- a/engines/xeen/resources.h +++ b/engines/xeen/resources.h @@ -418,6 +418,8 @@ extern const char *const CANNOT_REMOVE_CURSED_ITEM; extern const char *const CANNOT_DISCARD_CURSED_ITEM; +extern const char *const PERMANENTLY_DISCARD; + } // End of namespace Xeen #endif /* XEEN_RESOURCES_H */ diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp index 12fe2f1257..4859e93405 100644 --- a/engines/xeen/scripts.cpp +++ b/engines/xeen/scripts.cpp @@ -23,7 +23,7 @@ #include "xeen/scripts.h" #include "xeen/dialogs_input.h" #include "xeen/dialogs_whowill.h" -#include "xeen/dialogs_yesno.h" +#include "xeen/dialogs_query.h" #include "xeen/party.h" #include "xeen/resources.h" #include "xeen/xeen.h" diff --git a/engines/xeen/town.cpp b/engines/xeen/town.cpp index 3df26859d4..3a07d2a9e0 100644 --- a/engines/xeen/town.cpp +++ b/engines/xeen/town.cpp @@ -23,7 +23,7 @@ #include "xeen/town.h" #include "xeen/dialogs_input.h" #include "xeen/dialogs_items.h" -#include "xeen/dialogs_yesno.h" +#include "xeen/dialogs_query.h" #include "xeen/dialogs_spells.h" #include "xeen/resources.h" #include "xeen/xeen.h" |