File: EntitySettings.h

package info (click to toggle)
darkradiant 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 41,080 kB
  • sloc: cpp: 264,743; ansic: 10,659; python: 1,852; xml: 1,650; sh: 92; makefile: 21
file content (162 lines) | stat: -rw-r--r-- 3,608 bytes parent folder | download | duplicates (4)
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#pragma once

#include "ientity.h"
#include "iregistry.h"
#include <sigc++/connection.h>
#include <sigc++/signal.h>
#include <memory>
#include "math/Vector3.h"

namespace entity {

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 IEntitySettings
{
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
	std::vector<Vector3> _lightVertexColours;

	std::vector<sigc::connection> _registryConnections;

	sigc::signal<void> _signalSettingsChanged;

	// Private constructor
	EntitySettings();
public:
	const Vector3& getLightVertexColour(LightEditVertexType type) const override
	{
		assert(type != LightEditVertexType::NumberOfVertexTypes);
		return _lightVertexColours[static_cast<std::size_t>(type)];
	}

	void setLightVertexColour(LightEditVertexType type, const Vector3& value) override
	{
		assert(type != LightEditVertexType::NumberOfVertexTypes);
		_lightVertexColours[static_cast<std::size_t>(type)] = value;

		onSettingsChanged();
	}

	bool getRenderEntityNames() const override
	{
		return _renderEntityNames;
	}

	void setRenderEntityNames(bool value) override
	{
		_renderEntityNames = value;
		onSettingsChanged();
	}

	bool getShowAllSpeakerRadii() const override
	{
		return _showAllSpeakerRadii;
	}

	void setShowAllSpeakerRadii(bool value) override
	{
		_showAllSpeakerRadii = value;
		onSettingsChanged();
	}

	bool getShowAllLightRadii() const override
	{
		return _showAllLightRadii;
	}

	void setShowAllLightRadii(bool value) override
	{
		_showAllLightRadii = value;
		onSettingsChanged();
	}

	bool getDragResizeEntitiesSymmetrically() const override
	{
		return _dragResizeEntitiesSymmetrically;
	}

	void setDragResizeEntitiesSymmetrically(bool value) override
	{
		_dragResizeEntitiesSymmetrically = value;
		onSettingsChanged();
	}

	bool getAlwaysShowLightVertices() const override
	{
		return _alwaysShowLightVertices;
	}

	void setAlwaysShowLightVertices(bool value) override
	{
		_alwaysShowLightVertices = value;
		onSettingsChanged();
	}

	bool getFreeObjectRotation() const override
	{
		return _freeObjectRotation;
	}

	void setFreeObjectRotation(bool value) override
	{
		_freeObjectRotation = value;
		onSettingsChanged();
	}

	bool getShowEntityAngles() const override
	{
		return _showEntityAngles;
	}

	void setShowEntityAngles(bool value) override
	{
		_showEntityAngles = value;
		onSettingsChanged();
	}

	sigc::signal<void>& signal_settingsChanged() override
	{
		return _signalSettingsChanged;
	}

	// 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);
};

} // namespace entity