mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 07:53:36 +00:00
WAGE: Refactor commands menu creation
This commit is contained in:
parent
0e34bff8ab
commit
c2341f3948
@ -144,8 +144,9 @@ Menu::Menu(Gui *gui) : _gui(gui) {
|
||||
_items[m->menunum]->subitems.push_back(new MenuSubItem(m->title, m->action, 0, m->shortcut, m->enabled));
|
||||
}
|
||||
|
||||
MenuItem *commands = createCommandsMenu();
|
||||
_items.push_back(commands);
|
||||
_commands = new MenuItem(_gui->_engine->_world->_commandsMenuName.c_str());
|
||||
_items.push_back(_commands);
|
||||
regenCommandsMenu();
|
||||
|
||||
if (!_gui->_engine->_world->_weaponMenuDisabled) {
|
||||
_weapons = new MenuItem(_gui->_engine->_world->_weaponsMenuName.c_str());
|
||||
@ -194,8 +195,17 @@ Menu::~Menu() {
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem *Menu::createCommandsMenu() {
|
||||
MenuItem *menu = new MenuItem(_gui->_engine->_world->_commandsMenuName.c_str());
|
||||
void Menu::regenCommandsMenu() {
|
||||
for (int j = 0; j < _commands->subitems.size(); j++)
|
||||
delete _commands->subitems[j];
|
||||
|
||||
_commands->subitems.clear();
|
||||
|
||||
createWeaponsMenu(_commands);
|
||||
calcMenuBounds(_commands);
|
||||
}
|
||||
|
||||
void Menu::createCommandsMenu(MenuItem *menu) {
|
||||
Common::String string(_gui->_engine->_world->_commandsMenu);
|
||||
|
||||
Common::String item;
|
||||
@ -259,8 +269,6 @@ MenuItem *Menu::createCommandsMenu() {
|
||||
|
||||
item = "";
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
void Menu::regenWeaponsMenu() {
|
||||
|
@ -89,12 +89,14 @@ private:
|
||||
int calculateMenuWidth(MenuItem *menu);
|
||||
void calcMenuBounds(MenuItem *menu);
|
||||
void renderSubmenu(MenuItem *menu);
|
||||
MenuItem *createCommandsMenu();
|
||||
void regenCommandsMenu();
|
||||
void createCommandsMenu(MenuItem *menu);
|
||||
void createWeaponsMenu(MenuItem *menu);
|
||||
void executeCommand(MenuSubItem *subitem);
|
||||
|
||||
Common::Array<MenuItem *> _items;
|
||||
MenuItem *_weapons;
|
||||
MenuItem *_commands;
|
||||
|
||||
const Graphics::Font *_font;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user