/
OrthoContextMenu.h
121 lines (91 loc) · 2.68 KB
/
OrthoContextMenu.h
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#pragma once
#include "ui/iorthocontextmenu.h"
#include "iradiant.h"
#include <map>
#include <list>
#include "math/Vector3.h"
#include <wx/event.h>
class wxMenu;
class wxWindow;
namespace ui
{
/** Displays a menu when the mouse is right-clicked in the ortho window.
* This is a singleton module which remains in existence once initialised,
* and is hidden and displayed as appropriate.
*/
class OrthoContextMenu :
public wxEvtHandler,
public IOrthoContextMenu,
public std::enable_shared_from_this<OrthoContextMenu>
{
// The wxWidget representing the menu
std::shared_ptr<wxMenu> _widget;
// Last provided 3D point for action
Vector3 _lastPoint;
// A list of menu items
typedef std::list<IMenuItemPtr> MenuItems;
// The menu sections, distinguished by section number
typedef std::map<int, MenuItems> MenuSections;
MenuSections _sections;
struct ExtendedSelectionInfo
{
bool anythingSelected;
bool onlyPrimitivesSelected;
bool onlyBrushesSelected;
bool onlyPatchesSelected;
bool singlePrimitiveSelected;
bool onlyEntitiesSelected;
bool onlyGroupsSelected;
bool singleGroupSelected;
bool onlyModelsSelected;
bool playerStartExists;
};
ExtendedSelectionInfo _selectionInfo;
public:
OrthoContextMenu();
/** Display the menu at the current mouse position, and act on the
* choice.
*
* @param point
* The point in 3D space at which the chosen operation should take
* place.
*/
void Show(wxWindow* parent, const Vector3& point);
// Retrieve the singleton instance
static OrthoContextMenu& Instance();
// RegisterableModule implementation
const std::string& getName() const;
const StringSet& getDependencies() const;
void initialiseModule(const IApplicationContext& ctx);
void shutdownModule();
// IOrthoContextMenu implementation
void addItem(const IMenuItemPtr& item, int section);
void removeItem(const IMenuItemPtr& item);
private:
static std::string getRegistryKeyWithDefault(const std::string&,
const std::string&);
void analyseSelection();
// Visibility/Sensitivity checks
bool checkConvertStatic();
bool checkRevertToWorldspawn();
bool checkMergeEntities();
bool checkReparentPrimitives();
bool checkRevertToWorldspawnPartial();
bool checkPlacePlayerStart();
bool checkMakeVisportal();
bool checkAddMonsterclip();
bool checkAddEntity();
bool checkAddModel();
void addEntity();
void placePlayerStart();
void callbackAddModel();
void callbackAddLight();
void callbackAddPrefab();
void callbackAddSpeaker();
void registerDefaultItems();
// Pack widgets
void constructMenu();
void addSectionItems(int section, bool noSpacer = false);
void onItemClick(wxCommandEvent& ev);
};
}