aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2016-01-15 11:25:50 +0100
committerEugene Sandulenko2016-02-14 17:12:45 +0100
commit5a887808aba3d3a496828549201f563f9ad70c6e (patch)
treeeadaf789bfa28fe16fcdcfe3362b433660f0e9af
parent61c4f2091b0e3d70c51223f50240ee9e822b3f78 (diff)
downloadscummvm-rg350-5a887808aba3d3a496828549201f563f9ad70c6e.tar.gz
scummvm-rg350-5a887808aba3d3a496828549201f563f9ad70c6e.tar.bz2
scummvm-rg350-5a887808aba3d3a496828549201f563f9ad70c6e.zip
WAGE: Regenerate weapons menu on demand
-rw-r--r--engines/wage/gui.cpp4
-rw-r--r--engines/wage/gui.h1
-rw-r--r--engines/wage/menu.cpp28
-rw-r--r--engines/wage/menu.h5
-rw-r--r--engines/wage/wage.cpp3
5 files changed, 32 insertions, 9 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 21ff005bc8..268e2dce8c 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -579,6 +579,10 @@ void Gui::loadFonts() {
delete dat;
}
+void Gui::regenWeaponsMenu() {
+ _menu->regenWeaponsMenu();
+}
+
void Gui::mouseMove(int x, int y) {
if (_menu->_menuActivated) {
if (_menu->mouseMove(x, y))
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index c1af13d8fe..53722d5cf8 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -97,6 +97,7 @@ public:
void drawInput();
void setSceneDirty() { _sceneDirty = true; }
const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
+ void regenWeaponsMenu();
private:
void paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowType);
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 5bf6fc766f..65bc30321c 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -126,6 +126,8 @@ Menu::Menu(Gui *gui) : _gui(gui) {
assert(_gui->_engine);
assert(_gui->_engine->_world);
+ _font = getMenuFont();
+
MenuItem *about = new MenuItem(_gui->_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
_items.push_back(about);
_items[0]->subitems.push_back(new MenuSubItem(_gui->_engine->_world->getAboutMenuItemName(), kMenuActionAbout));
@@ -146,12 +148,13 @@ Menu::Menu(Gui *gui) : _gui(gui) {
_items.push_back(commands);
if (!_gui->_engine->_world->_weaponMenuDisabled) {
- MenuItem *weapons = createWeaponsMenu();
- _items.push_back(weapons);
+ _weapons = new MenuItem(_gui->_engine->_world->_weaponsMenuName.c_str());
+ _items.push_back(_weapons);
+
+ regenWeaponsMenu();
}
// Calculate menu dimensions
- _font = getMenuFont();
int y = 1;
int x = 18;
@@ -260,9 +263,21 @@ MenuItem *Menu::createCommandsMenu() {
return menu;
}
-MenuItem *Menu::createWeaponsMenu() {
+void Menu::regenWeaponsMenu() {
+ if (_gui->_engine->_world->_weaponMenuDisabled)
+ return;
+
+ for (int j = 0; j < _weapons->subitems.size(); j++)
+ delete _weapons->subitems[j];
+
+ _weapons->subitems.clear();
+
+ createWeaponsMenu(_weapons);
+ calcMenuBounds(_weapons);
+}
+
+void Menu::createWeaponsMenu(MenuItem *menu) {
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++) {
@@ -275,15 +290,12 @@ MenuItem *Menu::createWeaponsMenu() {
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() {
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 41696978ff..91c996bf5f 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -73,6 +73,8 @@ public:
bool mouseRelease(int x, int y);
bool mouseMove(int x, int y);
+ void regenWeaponsMenu();
+
bool _menuActivated;
Common::Rect _bbox;
@@ -88,10 +90,11 @@ private:
void calcMenuBounds(MenuItem *menu);
void renderSubmenu(MenuItem *menu);
MenuItem *createCommandsMenu();
- MenuItem *createWeaponsMenu();
+ void createWeaponsMenu(MenuItem *menu);
void executeCommand(MenuSubItem *subitem);
Common::Array<MenuItem *> _items;
+ MenuItem *_weapons;
const Graphics::Font *_font;
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index ff92a6935b..960f155206 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -305,6 +305,9 @@ void WageEngine::onMove(Designed *what, Designed *from, Designed *to) {
(what->_classType == OBJ && ((Obj *)what)->_currentScene == currentScene))
_gui->setSceneDirty();
+ if ((from == player || to == player) && !_temporarilyHidden)
+ _gui->regenWeaponsMenu();
+
if (what != player && what->_classType == CHR) {
Chr *chr = (Chr *)what;
if (to == _world->_storageScene) {