From 698f901a6d983f3f44b07f6560b1370850483fa0 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 18 Feb 2012 22:13:02 +0000 Subject: Added map entities, added ini file reader. --- src/editorwindow.cc | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) (limited to 'src/editorwindow.cc') 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 +#include +#include +#include + 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) +{ + + +} + } -- cgit v1.2.3