Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/editorwindow.cc8
-rw-r--r--src/entityproperties.cc11
-rw-r--r--src/entityproperties.h37
-rw-r--r--src/sidebar.cc45
-rw-r--r--src/sidebar.h10
5 files changed, 110 insertions, 1 deletions
diff --git a/src/editorwindow.cc b/src/editorwindow.cc
index bd00189..6757745 100644
--- a/src/editorwindow.cc
+++ b/src/editorwindow.cc
@@ -143,6 +143,14 @@ bool EditorWindow::loadFile(const QString &filename)
entity->properties()->set_comment("label", ini.comment());
entity->properties()->set_label(str);
+ } else if (ini.got_key_string("template", str)) {
+ entity->properties()->set_comment("template", ini.comment());
+ entity->properties()->set_template(0, str);
+
+ } else if (ini.got_key_string("ship", str)) {
+ entity->properties()->set_comment("template", ini.comment());
+ entity->properties()->set_template(1, str);
+
} else if (ini.got_key_string("name", str)) {
entity->properties()->set_comment("name", ini.comment());
entity->properties()->set_name(str);
diff --git a/src/entityproperties.cc b/src/entityproperties.cc
index bdc2394..3a0dff6 100644
--- a/src/entityproperties.cc
+++ b/src/entityproperties.cc
@@ -13,6 +13,7 @@ namespace editor
EntityProperties::EntityProperties()
{
properties_radius = 0;
+ properties_template_type = 0;
}
EntityProperties::~EntityProperties()
@@ -62,6 +63,16 @@ void EntityProperties::save(QTextStream &textstream)
}
textstream << "[" << type() << "]" << '\n';
+
+ save_comment(textstream, "template");
+ if (template_label().size()) {
+ if (template_type() == 0) {
+ textstream << "template=" << template_label() << '\n';
+ } else if (template_type() == 1) {
+ textstream << "ship=" << template_label() << '\n';
+ }
+ }
+
save_comment(textstream, "label");
if (label().size())
textstream << "label=" << label() << '\n';
diff --git a/src/entityproperties.h b/src/entityproperties.h
index 9a276cb..6fc3d5b 100644
--- a/src/entityproperties.h
+++ b/src/entityproperties.h
@@ -63,6 +63,22 @@ public:
inline const QString & subsections() const {
return properties_subsections;
}
+
+ /**
+ * @brief returns the template type of this object
+ * 0 = normal template from templates.ini
+ * 1 = ship templatefrom ships.ini
+ * */
+ inline const int template_type() const {
+ return properties_template_type;
+ }
+
+ /**
+ * @brief returns the template label of this object
+ * */
+ inline const QString &template_label() const {
+ return properties_template_label;
+ }
/* ---- mutators ---- */
@@ -132,6 +148,24 @@ public:
properties_angles.assign(yaw, pitch, roll);
}
+ /**
+ * @brief set the object template
+ * @param template_type 0 = template, 1 = ship
+ * @param template_label label of the template to be used
+ * */
+ inline void set_template(const int template_type, const QString &template_label) {
+ properties_template_type = template_type;
+ properties_template_label = template_label;
+ }
+
+ inline void set_template_type(const int template_type) {
+ properties_template_type = template_type;
+ }
+
+ inline void set_template_label(const QString &template_label) {
+ properties_template_label = template_label;
+ }
+
private:
float properties_radius;
@@ -139,6 +173,9 @@ private:
QString properties_type;
Vector3f properties_angles;
+
+ int properties_template_type;
+ QString properties_template_label;
};
} // namespace editor
diff --git a/src/sidebar.cc b/src/sidebar.cc
index 1cdc590..ed757d4 100644
--- a/src/sidebar.cc
+++ b/src/sidebar.cc
@@ -5,10 +5,11 @@
the GNU General Public License version 2
*/
-#include <QVBoxLayout>
+#include <QComboBox>
#include <QLabel>
#include <QLineEdit>
#include <QTextEdit>
+#include <QVBoxLayout>
#include "sidebar.h"
#include "entitywidget.h"
@@ -78,6 +79,20 @@ SideBar::SideBar(QWidget *parent) : QWidget(parent)
box_entityradius->addWidget(edit_entityradius);
connect(edit_entityradius, SIGNAL(textChanged(const QString &)), this, SLOT(updateEntityRadius(const QString &)));
+ // template
+ QHBoxLayout *box_entitytemplate = new QHBoxLayout();
+ QLabel *label_entitytemplate = new QLabel(tr("template"));
+ combo_entitytemplate_type = new QComboBox();
+ combo_entitytemplate_type->addItem(tr("template"));
+ combo_entitytemplate_type->addItem(tr("ship"));
+ combo_entitytemplate_type->setEditable(false);
+ edit_entitytemplate = new QLineEdit();
+ box_entitytemplate->addWidget(label_entitytemplate);
+ box_entitytemplate->addWidget(combo_entitytemplate_type);
+ box_entitytemplate->addWidget(edit_entitytemplate);
+ connect(combo_entitytemplate_type, SIGNAL(activated(int)), this, SLOT(updateEntityTemplateType(int)));
+ connect(edit_entitytemplate, SIGNAL(textChanged(const QString &)), this, SLOT(updateEntityTemplateLabel(const QString &)));
+
// entity values
QLabel *label_entityproperties = new QLabel(tr("properties"));
text_entityvalues = new QTextEdit();
@@ -110,6 +125,8 @@ SideBar::SideBar(QWidget *parent) : QWidget(parent)
box_global->addLayout(box_entityangles);
box_global->addLayout(box_entityradius);
+ box_global->addLayout(box_entitytemplate);
+
box_global->addWidget(label_entityproperties);
box_global->addWidget(text_entityvalues,1);
@@ -226,6 +243,20 @@ void SideBar::updateEntityRadius(const QString &value)
}
}
+void SideBar::updateEntityTemplateType(int template_type)
+{
+ if (last_selected) {
+ last_selected->set_template_type(template_type);
+ }
+}
+
+void SideBar::UpdateEntityTemplateLabel(const QString &template_label)
+{
+ if (last_selected) {
+ last_selected->set_template_label(template_label);
+ }
+}
+
void SideBar::updateEntityValues()
{
if (last_selected) {
@@ -281,6 +312,12 @@ void SideBar::setProperties(EntityProperties *properties)
edit_entityradius->setEnabled(false);
edit_entityradius->clear();
+ combo_entitytemplate_type->setEnabled(false);
+ combo_entitytemplate_type->setCurrentIndex(0);
+
+ edit_entitytemplate->setEnabled(false);
+ edit_entitytemplate->clear();
+
text_entityvalues->setEnabled(false);
text_entityvalues->clear();
@@ -332,6 +369,12 @@ void SideBar::setProperties(EntityProperties *properties)
value.setNum(properties->radius());
edit_entityradius->setText(value);
+ combo_entitytemplate_type->setEnabled(true);
+ combo_entitytemplate_type->setCurrentIndex(properties->template_type());
+
+ edit_entitytemplate->setEnabled(true);
+ edit_entitytemplate->setText(properties->template_label());
+
text_entityvalues->setEnabled(true);
text_entityvalues->setPlainText(properties->values());
diff --git a/src/sidebar.h b/src/sidebar.h
index 0ed8d2a..644a733 100644
--- a/src/sidebar.h
+++ b/src/sidebar.h
@@ -15,6 +15,7 @@
class QLabel;
class QLineEdit;
class QTextEdit;
+class QComboBox;
namespace editor
{
@@ -65,6 +66,10 @@ private slots:
void updateEntityRadius(const QString &value);
+ void updateEntityTemplateType(int template_type);
+
+ void UpdateEntityTemplateLabel(const QString &template_label);
+
void updateEntityValues();
void updateEntitySubSections();
@@ -83,9 +88,14 @@ private:
QLineEdit *edit_entitylocation_x;
QLineEdit *edit_entitylocation_y;
QLineEdit *edit_entitylocation_z;
+
QLineEdit *edit_entityangles_yaw;
QLineEdit *edit_entityangles_pitch;
QLineEdit *edit_entityangles_roll;
+
+ QComboBox *combo_entitytemplate_type;
+ QLineEdit *edit_entitytemplate;
+
QLineEdit *edit_entityradius;
QTextEdit *text_entityvalues;
QTextEdit *text_subsections;