summaryrefslogtreecommitdiffstats
path: root/src/Instance.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Instance.cpp')
-rw-r--r--src/Instance.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/Instance.cpp b/src/Instance.cpp
index 6d01d99..b54fb32 100644
--- a/src/Instance.cpp
+++ b/src/Instance.cpp
@@ -17,18 +17,20 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "Instance.h"
#include <iostream>
#include <libxml++/validators/dtdvalidator.h>
#include <libxml/tree.h>
-#include "Instance.h"
-#include "Gui/Window.h"
-#include "Data/Level.h"
+#include <Gui/Window.h>
+#include <Gui/RenderArea.h>
+#include <Data/Level.h>
+#include <View/TopView.h>
namespace ZoomEdit {
guint Instance::instances = 0;
-Instance::Instance(const Glib::ustring &file) : window(0), levelXml(0), level(0) {
+Instance::Instance(const Glib::ustring &file) : window(0), levelXml(0), level(0), view(0) {
instances++;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
@@ -59,6 +61,9 @@ Instance::Instance(const Glib::ustring &file) : window(0), levelXml(0), level(0)
window->signal_hide().connect(sigc::mem_fun(this, &Instance::destroy));
+ view = new View::TopView();
+ window->getRenderArea()->setView(view);
+
if(file.empty())
createLevel();
else
@@ -71,6 +76,9 @@ Instance::~Instance() {
if(window)
delete window;
+ if(view)
+ delete view;
+
if(level)
delete level;
@@ -83,8 +91,10 @@ Instance::~Instance() {
}
void Instance::createLevel() {
- if(level)
+ if(level) {
+ view->setLevel(0);
delete level;
+ }
if(levelXml)
delete levelXml;
@@ -109,10 +119,13 @@ void Instance::createLevel() {
root->add_child("textures");
level = new Data::Level(root);
+
+ view->setLevel(level);
}
bool Instance::loadLevel(const Glib::ustring &file) {
if(level) {
+ view->setLevel(0);
delete level;
level = 0;
}
@@ -131,7 +144,9 @@ bool Instance::loadLevel(const Glib::ustring &file) {
level = new Data::Level(doc->get_root_node());
- return (level != 0);
+ view->setLevel(level);
+
+ return true;
}
bool Instance::saveLevel(const Glib::ustring &file) {