/
EntitySettings.h
126 lines (98 loc) · 2.99 KB
/
EntitySettings.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
122
123
124
125
126
#pragma once
#include "iregistry.h"
#include <sigc++/connection.h>
#include <memory>
#include "math/Vector3.h"
namespace entity {
namespace
{
const char* const RKEY_SHOW_ENTITY_NAMES("user/ui/xyview/showEntityNames");
const char* const RKEY_SHOW_ALL_SPEAKER_RADII = "user/ui/showAllSpeakerRadii";
const char* const RKEY_SHOW_ALL_LIGHT_RADII = "user/ui/showAllLightRadii";
const char* const RKEY_DRAG_RESIZE_SYMMETRICALLY = "user/ui/dragResizeEntitiesSymmetrically";
const char* const RKEY_ALWAYS_SHOW_LIGHT_VERTICES = "user/ui/alwaysShowLightVertices";
const char* const RKEY_FREE_OBJECT_ROTATION = "user/ui/rotateObjectsIndependently";
const char* const RKEY_SHOW_ENTITY_ANGLES = "user/ui/xyview/showEntityAngles";
}
class EntitySettings;
typedef std::shared_ptr<EntitySettings> EntitySettingsPtr;
/**
* greebo: A class managing the various settings for entities. It observes
* the corresponding keyvalues in the registry and updates the internal
* variables accordingly. This can be used as some sort of "cache"
* to avoid slow registry queries during rendering, for instance.
*/
class EntitySettings
{
public:
enum LightEditVertexType
{
VERTEX_START_END_DESELECTED,
VERTEX_START_END_SELECTED,
VERTEX_INACTIVE,
VERTEX_DESELECTED,
VERTEX_SELECTED,
NUM_LIGHT_VERTEX_COLOURS,
};
private:
// TRUE if entity names should be drawn
bool _renderEntityNames;
// TRUE if speaker radii should be drawn
bool _showAllSpeakerRadii;
// TRUE if light radii should be drawn even when not selected
bool _showAllLightRadii;
// TRUE if entities should resize symmetrically on drag-resize operations
bool _dragResizeEntitiesSymmetrically;
// TRUE if lights should always render their components
bool _alwaysShowLightVertices;
bool _freeObjectRotation;
// true if GenericEntities should render their direction arrows
bool _showEntityAngles;
// Cached colour values
Vector3 _lightVertexColours[NUM_LIGHT_VERTEX_COLOURS];
bool _lightVertexColoursLoaded;
std::vector<sigc::connection> _registryConnections;
// Private constructor
EntitySettings();
public:
const Vector3& getLightVertexColour(LightEditVertexType type)
{
if (!_lightVertexColoursLoaded)
{
loadLightVertexColours();
}
return _lightVertexColours[type];
}
bool renderEntityNames() {
return _renderEntityNames;
}
bool showAllSpeakerRadii() {
return _showAllSpeakerRadii;
}
bool showAllLightRadii() {
return _showAllLightRadii;
}
bool dragResizeEntitiesSymmetrically() {
return _dragResizeEntitiesSymmetrically;
}
bool alwaysShowLightVertices() {
return _alwaysShowLightVertices;
}
bool freeObjectRotation()
{
return _freeObjectRotation;
}
bool showEntityAngles()
{
return _showEntityAngles;
}
// Container for the singleton (ptr)
static EntitySettingsPtr& InstancePtr();
// Releases the singleton pointer
static void destroy();
private:
void onSettingsChanged();
void initialiseAndObserveKey(const std::string& key, bool& targetBool);
void loadLightVertexColours();
};
} // namespace entity