WAGE: Implement API to enable/disable menu items

This commit is contained in:
Eugene Sandulenko 2016-02-05 11:05:00 +01:00
parent c02c36ce88
commit 7e8c1028d3
3 changed files with 27 additions and 19 deletions

View File

@ -707,6 +707,8 @@ Designed *Gui::mouseUp(int x, int y) {
(_selectionEndX == _selectionStartX && _selectionEndY == _selectionStartY)) {
_selectionStartY = _selectionEndY = -1;
_consoleFullRedraw = true;
} else {
}
}

View File

@ -79,25 +79,6 @@ struct MenuItem {
MenuItem(const char *n) : name(n) {}
};
enum {
kMenuActionAbout,
kMenuActionNew,
kMenuActionOpen,
kMenuActionClose,
kMenuActionSave,
kMenuActionSaveAs,
kMenuActionRevert,
kMenuActionQuit,
kMenuActionUndo,
kMenuActionCut,
kMenuActionCopy,
kMenuActionPaste,
kMenuActionClear,
kMenuActionCommand
};
struct MenuData {
int menunum;
const char *title;
@ -568,5 +549,10 @@ void Menu::processMenuShortCut(byte flags, uint16 ascii) {
}
}
void Menu::enableCommand(int menunum, int action, bool state) {
for (int i = 0; i < _items[menunum]->subitems.size(); i++)
if (_items[menunum]->subitems[i]->action == action)
_items[menunum]->subitems[i]->enabled = state;
}
} // End of namespace Wage

View File

@ -63,6 +63,25 @@ enum {
kFontStyleExtended = 64
};
enum {
kMenuActionAbout,
kMenuActionNew,
kMenuActionOpen,
kMenuActionClose,
kMenuActionSave,
kMenuActionSaveAs,
kMenuActionRevert,
kMenuActionQuit,
kMenuActionUndo,
kMenuActionCut,
kMenuActionCopy,
kMenuActionPaste,
kMenuActionClear,
kMenuActionCommand
};
class Menu {
public:
Menu(Gui *gui);
@ -76,6 +95,7 @@ public:
void regenCommandsMenu();
void regenWeaponsMenu();
void processMenuShortCut(byte flags, uint16 ascii);
void enableCommand(int menunum, int action, bool state);
bool _menuActivated;
Common::Rect _bbox;