aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2016-01-14 18:05:09 +0100
committerEugene Sandulenko2016-02-14 17:12:44 +0100
commit72b95e639ee9fc270df05e8d1738774fd35ac4ca (patch)
treefb9960ca7f243c83d5c9a2243d74031eaa00f64f
parentd9187245680911442c30d9dee3bf1eb40f44db7c (diff)
downloadscummvm-rg350-72b95e639ee9fc270df05e8d1738774fd35ac4ca.tar.gz
scummvm-rg350-72b95e639ee9fc270df05e8d1738774fd35ac4ca.tar.bz2
scummvm-rg350-72b95e639ee9fc270df05e8d1738774fd35ac4ca.zip
WAGE: Create weapons menu
-rw-r--r--engines/wage/entities.h39
-rw-r--r--engines/wage/menu.cpp28
-rw-r--r--engines/wage/menu.h1
3 files changed, 48 insertions, 20 deletions
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 362e9b59c5..6a97abf39e 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -237,25 +237,7 @@ public:
void resetState();
};
-class Weapon {
-public:
- uint _accuracy;
- String _operativeVerb;
- int _type;
- int _damage;
- String _sound;
- int _numberOfUses;
-
- Weapon() : _numberOfUses(0) {}
-
- void decrementNumberOfUses() {
- if (_numberOfUses != -1) {
- _numberOfUses--;
- }
- }
-};
-
-class Obj : public Weapon, public Designed {
+class Obj : public Designed {
public:
Obj() : _currentOwner(NULL), _currentScene(NULL) {}
Obj(String name, Common::SeekableReadStream *data);
@@ -298,6 +280,12 @@ public:
Scene *_currentScene;
Chr *_currentOwner;
+ int _type;
+ uint _accuracy;
+ String _operativeVerb;
+ int _damage;
+ String _sound;
+
public:
void setCurrentOwner(Chr *currentOwner) {
_currentOwner = currentOwner;
@@ -315,6 +303,19 @@ public:
Designed *removeFromCharOrScene();
};
+class Weapon : public Obj {
+public:
+ int _numberOfUses;
+
+ Weapon() : _numberOfUses(0) {}
+
+ void decrementNumberOfUses() {
+ if (_numberOfUses != -1) {
+ _numberOfUses--;
+ }
+ }
+};
+
class Scene : public Designed {
public:
enum Directions {
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 559ace1c7c..2dde420fa4 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -146,7 +146,7 @@ Menu::Menu(Gui *gui) : _gui(gui) {
_items.push_back(commands);
if (!_gui->_engine->_world->_weaponMenuDisabled) {
- MenuItem *weapons = new MenuItem(_gui->_engine->_world->_weaponsMenuName.c_str());
+ MenuItem *weapons = createWeaponsMenu();
_items.push_back(weapons);
}
@@ -260,6 +260,32 @@ MenuItem *Menu::createCommandsMenu() {
return menu;
}
+MenuItem *Menu::createWeaponsMenu() {
+ Chr *player = _gui->_engine->_world->_player;
+ MenuItem *menu = new MenuItem(_gui->_engine->_world->_weaponsMenuName.c_str());
+ WeaponArray *weapons = player->getWeapons(true);
+
+ for (int i = 0; i < weapons->size(); i++) {
+ Weapon *obj = (*weapons)[i];
+ if (obj->_type == Obj::REGULAR_WEAPON ||
+ obj->_type == Obj::THROW_WEAPON ||
+ obj->_type == Obj::MAGICAL_OBJECT) {
+ Common::String command(obj->_operativeVerb);
+ command += " ";
+ command += obj->_name;
+
+ menu->subitems.push_back(new MenuSubItem(command.c_str(), kMenuActionCommand, 0, 0, true));
+
+ }
+ }
+ delete weapons;
+
+ if (menu->subitems.size() == 0)
+ menu->subitems.push_back(new MenuSubItem("You have no weapons", 0, 0, 0, false));
+
+ return menu;
+}
+
const Graphics::Font *Menu::getMenuFont() {
return _gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
}
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 67d061d212..62ad835b8e 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -88,6 +88,7 @@ private:
void calcMenuBounds(MenuItem *menu);
void renderSubmenu(MenuItem *menu);
MenuItem *createCommandsMenu();
+ MenuItem *createWeaponsMenu();
Common::Array<MenuItem *> _items;