/
FiltersMainMenu.cpp
61 lines (48 loc) · 1.89 KB
/
FiltersMainMenu.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "FiltersMainMenu.h"
#include "i18n.h"
#include "ifilter.h"
#include "iuimanager.h"
namespace ui
{
namespace
{
// greebo: These are used for the DarkRadiant main menu
const std::string MENU_NAME = "main";
const std::string MENU_INSERT_BEFORE = MENU_NAME + "/map";
const std::string MENU_FILTERS_NAME = "filters";
const std::string MENU_PATH = MENU_NAME + "/" + MENU_FILTERS_NAME;
const std::string MENU_ICON = "iconFilter16.png";
}
// Construct menu items
void FiltersMenu::addItemsToMainMenu()
{
// Get the menu manager
IMenuManager& menuManager = GlobalUIManager().getMenuManager();
// remove any items first
removeItemsFromMainMenu();
// Create the toplevel menu item
menuManager.insert(MENU_INSERT_BEFORE, MENU_FILTERS_NAME,
ui::menuFolder, "Fi<er", "", ""); // empty icon, empty event
// Visit the filters in the FilterSystem to populate the menu
GlobalFilterSystem().forEachFilter([&](const std::string& filterName)
{
std::string eventName = GlobalFilterSystem().getFilterEventName(filterName);
// Create the menu item
menuManager.add(MENU_PATH, MENU_PATH + "_" + filterName,
menuItem, filterName,
MENU_ICON, eventName);
});
menuManager.add(MENU_PATH, "_FiltersSep1", menuSeparator, "", "", "");
menuManager.add(MENU_PATH, "ActivateAllFilters", menuItem, _("Activate &all Filters"), MENU_ICON, "ActivateAllFilters");
menuManager.add(MENU_PATH, "DeactivateAllFilters", menuItem, _("&Deactivate all Filters"), MENU_ICON, "DeactivateAllFilters");
menuManager.add(MENU_PATH, "_FiltersSep2", menuSeparator, "", "", "");
menuManager.add(MENU_PATH, "EditFilters", menuItem, _("Edit Filters..."), MENU_ICON, "EditFiltersDialog");
}
void FiltersMenu::removeItemsFromMainMenu()
{
// Get the menu manager
IMenuManager& menuManager = GlobalUIManager().getMenuManager();
// Remove the filters menu if there exists one
menuManager.remove(MENU_PATH);
}
} // namespace ui