diff options
Diffstat (limited to 'src/properties.h')
-rw-r--r-- | src/properties.h | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/src/properties.h b/src/properties.h new file mode 100644 index 0000000..472d4b4 --- /dev/null +++ b/src/properties.h @@ -0,0 +1,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__
\ No newline at end of file |