From b4adc20ef08257124a01499436f2b8b447adcb33 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 9 Jan 2010 03:18:25 +0100 Subject: Use room list --- src/View/MapView.cpp | 13 ++++++++----- src/View/TopView.cpp | 14 +++++++++----- src/View/TopView.h | 17 +++++++---------- 3 files changed, 24 insertions(+), 20 deletions(-) (limited to 'src/View') diff --git a/src/View/MapView.cpp b/src/View/MapView.cpp index 224cd37..2569a3c 100644 --- a/src/View/MapView.cpp +++ b/src/View/MapView.cpp @@ -19,10 +19,13 @@ #include "MapView.h" #include "TopView.h" + +#include #include #include #include #include + #include #include #include @@ -96,7 +99,7 @@ void MapView::click(float x, float y, unsigned int button) { void MapView::render() { glClear(GL_COLOR_BUFFER_BIT); - if(!mainView || !mainView->getLevel()) + if(!mainView || !mainView->getInstance()->getLevel()) return; float minX, maxX, minY, maxY; @@ -116,10 +119,10 @@ void MapView::render() { glScalef(scale, scale, 1); glTranslatef(-xCenter, -yCenter, 0); - const std::list &rooms = mainView->getLevel()->getRooms(); + const std::list &rooms = mainView->getInstance()->getLevel()->getRooms(); for(std::list::const_iterator room = rooms.begin(); room != rooms.end(); ++room) - TopView::renderRoom(*room); + TopView::renderRoom(*room, (*room == mainView->getInstance()->getSelectedRoom())); float mainXCenter = mainView->getXCenter(), mainYCenter = mainView->getYCenter(); float mainScale = mainView->getScale(); @@ -163,10 +166,10 @@ void MapView::getBounds(float *minX, float *maxX, float *minY, float *maxY) { if(maxY) *maxY = 0; - if(!mainView || !mainView->getLevel()) + if(!mainView || !mainView->getInstance()->getLevel()) return; - const std::list &rooms = mainView->getLevel()->getRooms(); + const std::list &rooms = mainView->getInstance()->getLevel()->getRooms(); for(std::list::const_iterator room = rooms.begin(); room != rooms.end(); ++room) { const std::list &triangles = (*room)->getTriangles(); diff --git a/src/View/TopView.cpp b/src/View/TopView.cpp index 12bbe4a..7e649cc 100644 --- a/src/View/TopView.cpp +++ b/src/View/TopView.cpp @@ -18,11 +18,14 @@ */ #include "TopView.h" + +#include #include #include #include #include #include + #include #include #include @@ -218,13 +221,13 @@ void TopView::render() { drawGrid(); - if(!level) + if(!instance->getLevel()) return; - const std::list &rooms = level->getRooms(); + const std::list &rooms = instance->getLevel()->getRooms(); for(std::list::const_iterator room = rooms.begin(); room != rooms.end(); ++room) - renderRoom(*room, *room == selectedRoom); + renderRoom(*room, *room == instance->getSelectedRoom()); } void TopView::click(float x, float y, unsigned int button) { @@ -233,9 +236,9 @@ void TopView::click(float x, float y, unsigned int button) { vmml::vec2f v(xCenter + x/scale, yCenter + y/scale); - selectedRoom = 0; + Data::Room *selectedRoom = 0; - const std::list& rooms = level->getRooms(); + const std::list &rooms = instance->getLevel()->getRooms(); for(std::list::const_iterator room = rooms.begin(); room != rooms.end(); ++room) { const std::list& triangles = (*room)->getTriangles(); @@ -255,6 +258,7 @@ void TopView::click(float x, float y, unsigned int button) { break; } + instance->setSelectedRoom(selectedRoom); signalUpdate().emit(); } diff --git a/src/View/TopView.h b/src/View/TopView.h index c164f31..085d244 100644 --- a/src/View/TopView.h +++ b/src/View/TopView.h @@ -27,6 +27,8 @@ namespace ZoomEdit { +class Instance; + namespace Data { class Level; class Room; @@ -45,7 +47,7 @@ class TopView : public View { bool operator<(const Edge &e) const; }; - Data::Level *level; + Instance *instance; float viewWidth, viewHeight; @@ -54,14 +56,14 @@ class TopView : public View { int zoomLevel; float scale; - Data::Room *selectedRoom; - void drawGrid(); public: - TopView(Data::Level *level0 = 0) - : level(level0), viewWidth(0), viewHeight(0), xCenter(0), yCenter(0), zoomLevel(0), scale(100), selectedRoom(0) {} + TopView(Instance *instance0) + : instance(instance0), viewWidth(0), viewHeight(0), xCenter(0), yCenter(0), zoomLevel(0), scale(100) {} + Instance* getInstance() {return instance;} + float getWidth() const {return viewWidth;} float getHeight() const {return viewHeight;} @@ -72,11 +74,6 @@ class TopView : public View { float getScale() const {return scale;} - Data::Room* getSelectedRoom() {return selectedRoom;} - - Data::Level* getLevel() {return level;} - void setLevel(Data::Level *level0) {level = level0; signalUpdate().emit();} - virtual void init(); virtual void resize(float width, float height); -- cgit v1.2.3