Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 472d4b4950f7b67bca0e1445379df4a09d6295b1 (plain)
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
/*
   properties.h
   This file is part of the Project::OSiRiON world editor 
   and is distributed under the terms and conditions of 
   the GNU General Public License version 2
*/

#ifndef __INCLUDED_EDITOR_PROPERTIES__
#define __INCLUDED_EDITOR_PROPERTIES__

#include "vector3f.h"

#include <QColor>
#include <QString>

namespace editor
{

/**
 * @brief abstract base class to hold properties for game objects
 * */
class Properties
{
public:
	Properties();
	
	virtual ~Properties();
	
	/* ---- inspectors ---- */
	
	/**
	 * @brief returns the label of this object
	 * */
	inline const QString &label() const {
		return properties_label;
	}
	
	/**
	 * @brief returns the name of this object
	 * */
	inline const QString &name() const {
		return properties_name;
	}
	
	/**
	 * @brief returns the location of this object
	 * */
	inline const Vector3f &location() const {
		return properties_location;
	}
	
	/**
	 * @brief returns the color of this object
	 * */
	inline const QColor &color() const {
		return properties_color;
	}

		
	/**
	 * @brief returns the info string of this object
	 * */
	inline const QString & info() const {
		return properties_info;
	}

	/**
	 * @brief returns the values string of this object
	 * */
	inline const QString & values() const {
		return properties_values;
	}
	
	/* ---- mutators ---- */
	
	/**
	 * @brief set the info string of this object
	 * */
	void set_info(const QString &text);
	
	/**
	 * @brief add a line of text to the info string of this object
	 * */
	void add_info(const QString &text);
	
	/**
	 * @brief add a value key pair to the values string
	 * */
	void add_value(const QString &key, const QString &value);
	
	
	/**
	 * @brief set the object label
	 * */
	inline void set_label(const QString &label) {
		properties_label = label;
	}
	
	/**
	 * @brief set the object name
	 * */
	inline void set_name(const QString &name) {
		properties_name = name;
	}
	
	/**
	 * @brief set the object location
	 * */
	inline void set_location(const Vector3f &location) {
		properties_location = location;
	}
	
	/**
	 * @brief set the object location
	 * */
	inline void set_location(const float x, const float y, const float z) {
		properties_location.assign(x, y, z);
	}
	
	/**
	 * @brief set the object color
	 * */
	inline void set_color(const QColor &color) {
		properties_color = color;
	}
		
	/**
	 * @brief set the object color
	 * */
	inline void set_color(const float r, const float g, const float b) {
		float cr = r;
		float cg = g;
		float cb = b;

		// Qt RGB colors are in the 0-255 range
		if ((r <= 1) && (g <= 1) && (b <= 1)) {
			cr *= 255;
			cg *= 255;
			cg *= 255;
		}
		
		properties_color.setRgb(r, g, b);
	}
	
private:
	QString			properties_label;
	QString			properties_name;
	
	Vector3f		properties_location;
	QColor			properties_color;
	
	QString			properties_info;
	QString			properties_values;
};

} // namespace editor

#endif // __INCLUDED_EDITOR_PROPERTIES__