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.cc99
1 files changed, 98 insertions, 1 deletions
diff --git a/src/editorwindow.cc b/src/editorwindow.cc
index 6a72654..20e8403 100644
--- a/src/editorwindow.cc
+++ b/src/editorwindow.cc
@@ -1,14 +1,21 @@
/*
editorwindow.h
- This file is part of the Project::OSiRiON zone editor
+ 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
*/
#include "editorwindow.h"
+#include "inistream.h"
#include "mapwidget.h"
+#include "mapentity.h"
#include "sidebar.h"
+#include <QtGui>
+#include <QFile>
+#include <QTextStream>
+#include <QDebug>
+
namespace editor
{
@@ -27,4 +34,94 @@ void EditorWindow::resizeEvent (QResizeEvent *event)
);
}
+bool EditorWindow::loadFile(const QString &filename)
+{
+ QFile file(filename);
+ if (!file.open(QFile::ReadOnly | QFile::Text)) {
+ QMessageBox::warning(this, tr("Open Zone"),
+ tr("Could not open file %1:\n%2.")
+ .arg(filename)
+ .arg(file.errorString()));
+ return false;
+ }
+
+ QTextStream textstream(&file);
+ QApplication::setOverrideCursor(Qt::WaitCursor);
+
+ IniStream ini;
+
+ MapEntity *entity = 0;
+ bool in_entity = false;
+ float x, y, z;
+ QString str;
+
+ while (ini.getline(textstream)) {
+
+ if (ini.got_section()) {
+
+ qDebug() << "got section" << ini.section();
+
+ if (ini.got_section("zone")) {
+ in_entity = false;
+
+ } else if (ini.got_section("entity")) {
+ in_entity = true;
+
+ } else if (ini.got_section("jumpgate")) {
+ in_entity = true;
+
+ } else if (ini.got_section("jumpoint")) {
+ in_entity = true;
+
+ } else if (ini.got_section("navpoint")) {
+ in_entity = true;
+
+ } else if (ini.got_section("station")) {
+ in_entity = true;
+
+ } else if (ini.got_section("star")) {
+ in_entity = true;
+
+ } else if (ini.got_section("planet")) {
+ in_entity = true;
+ } else {
+ entity = 0;
+ in_entity = false;
+ }
+
+ if (in_entity) {
+ entity = editorwindow_mapwidget->addEntity();
+ }
+
+ } else if(ini.got_key()) {
+
+ if (in_entity) {
+ if (ini.got_key_vector3f("location" , x, y, z)) {
+ entity->set_location(x, y, z);
+ //qDebug() << "got location " << x << " " << y << " " << z;
+ }
+ } else if (ini.in_section("zone")) {
+
+ if (ini.got_key_string("name", str)) {
+ editorwindow_sidebar->setZoneName(str);
+ }
+ }
+
+ }
+ }
+
+ QApplication::restoreOverrideCursor();
+
+ //setCurrentFile(fileName);
+ //connect(document(), SIGNAL(contentsChanged()),this, SLOT(documentWasModified()));
+
+ return true;
+}
+
+bool EditorWindow::saveFile(const QString &filename)
+{
+
+
+}
+
}