Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/editorwindow.cc')
-rw-r--r--src/editorwindow.cc50
1 files changed, 37 insertions, 13 deletions
diff --git a/src/editorwindow.cc b/src/editorwindow.cc
index a15ed43..ae7d024 100644
--- a/src/editorwindow.cc
+++ b/src/editorwindow.cc
@@ -50,7 +50,7 @@ bool EditorWindow::loadFile(const QString &filename)
{
QFile file(filename);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
- QMessageBox::warning(this, tr("Open Zone"),
+ QMessageBox::warning(this, tr("Open file"),
tr("Could not open file %1:\n%2.")
.arg(filename)
.arg(file.errorString()));
@@ -101,6 +101,12 @@ bool EditorWindow::loadFile(const QString &filename)
} else if (ini.got_section("planet")) {
in_entity = true;
+ } else if (ini.got_section("racetrack")) {
+ in_entity = true;
+
+ } else if (ini.got_section("checkpoint")) {
+ in_entity = true;
+
} else if (ini.got_section("cargo")) {
in_entity = false;
in_subsection = true;
@@ -129,19 +135,26 @@ bool EditorWindow::loadFile(const QString &filename)
// read entity properties into the MapWidget instance
if (ini.got_key_vector3f("location" , x, y, z)) {
+ entity->properties()->set_comment("location", ini.comment());
entity->properties()->set_location(x, y, z);
//qDebug() << "got location " << x << " " << y << " " << z;
} else if (ini.got_key_string("label", str)) {
+ entity->properties()->set_comment("label", ini.comment());
entity->properties()->set_label(str);
} else if (ini.got_key_string("name", str)) {
+ entity->properties()->set_comment("name", ini.comment());
entity->properties()->set_name(str);
} else if (ini.got_key_float("radius", f)) {
+ entity->properties()->set_comment("radius", ini.comment());
entity->properties()->set_radius(f);
} else if (ini.got_key_string("info", str)) {
+ QString comment = entity->properties()->comment("info");
+ comment += ini.comment();
+ entity->properties()->set_comment("info", comment);
entity->properties()->add_info(str);
} else if (ini.got_key()) {
@@ -154,10 +167,14 @@ bool EditorWindow::loadFile(const QString &filename)
} else if (ini.in_section("zone")) {
if (ini.got_key_string("name", str)) {
+ editorwindow_zoneproperties.set_comment("name", ini.comment());
editorwindow_zoneproperties.set_name(str);
editorwindow_sidebar->setZoneName(str);
} else if (ini.got_key_string("info", str)) {
+ QString comment = editorwindow_zoneproperties.comment("info");
+ comment += ini.comment();
+ editorwindow_zoneproperties.set_comment("info", comment);
editorwindow_zoneproperties.add_info(str);
} else if (ini.got_key()) {
@@ -169,27 +186,34 @@ bool EditorWindow::loadFile(const QString &filename)
}
QApplication::restoreOverrideCursor();
- editorwindow_filename = QFileInfo(filename).canonicalFilePath();
+ editorwindow_filename = filename;
return true;
}
bool EditorWindow::saveFile(const QString &filename)
{
- QString buffer;
- QTextStream textstream(&buffer);
-
+ QFile file(filename);
+ if (!file.open(QFile::WriteOnly | QFile::Text)) {
+ QMessageBox::warning(this, tr("Save file"),
+ tr("Cannot write file %1:\n%2.")
+ .arg(filename)
+ .arg(file.errorString()));
+ return false;
+ }
+
+ QTextStream textstream(&file);
+
+ QApplication::setOverrideCursor(Qt::WaitCursor);
+
editorwindow_zoneproperties.save(textstream);
editorwindow_mapwidget->save(textstream);
-
- // debug output
- QTextStream out(&buffer);
- QString line;
- while (!out.atEnd()) {
- line = out.readLine(1024);
- qDebug() << line;
- }
+ QApplication::restoreOverrideCursor();
+
+ editorwindow_filename = filename;
+ return true;
+
}