summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2007-12-14 23:03:00 +0100
committerneoraider <devnull@localhost>2007-12-14 23:03:00 +0100
commitd25becbaceab79809cb57fafaece151cecee3f69 (patch)
treea0d3973343ccd658e8d73f64dcb402b193c424c3
parent9a1bbf4b9ae00bfe6ef7c5c251bae0da9b624d9c (diff)
downloadzoomedit-d25becbaceab79809cb57fafaece151cecee3f69.tar
zoomedit-d25becbaceab79809cb57fafaece151cecee3f69.zip
zoomedit: Generalized Tool objects.
-rw-r--r--LevelObject.h9
-rw-r--r--Object.h18
-rw-r--r--Renderer.cpp15
-rw-r--r--Tool.h8
-rw-r--r--ToolAddPolygon.cpp7
-rw-r--r--ToolAddPolygon.h14
-rw-r--r--ToolSelector.cpp7
-rw-r--r--ToolSelector.h14
8 files changed, 55 insertions, 37 deletions
diff --git a/LevelObject.h b/LevelObject.h
index d7dbf4f..c8d4d47 100644
--- a/LevelObject.h
+++ b/LevelObject.h
@@ -1,21 +1,16 @@
#ifndef LEVELOBJECT_H_
#define LEVELOBJECT_H_
+#include "Object.h"
#include "Vertex.h"
-#include <cstring>
-class LevelObject {
+class LevelObject : public Object {
public:
virtual ~LevelObject() {}
- virtual const char* getType() const = 0;
virtual bool hit(const Vertex &v) const = 0;
virtual int getPriority() const = 0;
-
- bool isOfType(const char *type) const {
- return (std::strcmp(getType(), type) == 0);
- }
};
#endif /*LEVELOBJECT_H_*/
diff --git a/Object.h b/Object.h
new file mode 100644
index 0000000..bdec9ca
--- /dev/null
+++ b/Object.h
@@ -0,0 +1,18 @@
+#ifndef OBJECT_H_
+#define OBJECT_H_
+
+#include <cstring>
+
+
+class Object {
+ public:
+ virtual ~Object() {}
+
+ virtual const char* getType() const = 0;
+
+ bool isOfType(const char *type) const {
+ return (std::strcmp(getType(), type) == 0);
+ }
+};
+
+#endif /*OBJECT_H_*/
diff --git a/Renderer.cpp b/Renderer.cpp
index 3f7d99b..1c3255b 100644
--- a/Renderer.cpp
+++ b/Renderer.cpp
@@ -139,11 +139,18 @@ void Renderer::renderRoom(const Room &room, bool selected, bool hovered, float s
}
void Renderer::renderPlayerStart(const PlayerStart &start, bool selected, bool hovered, float scale) {
- glLineWidth((hovered || selected) ? 2.0f : 1.0f);
- if(selected)
- glColor4f(1.0f, 1.7f, 1.0f, 1.9f);
- else
+ if(selected) {
+ glColor4f(1.0f, 1.0f, 1.0f, 0.9f);
+ glLineWidth(2.0f);
+ }
+ else if(hovered && editManager->getMode() == EditManager::VIEW) {
glColor4f(0.0f, 0.7f, 0.7f, 0.7f);
+ glLineWidth(2.0f);
+ }
+ else {
+ glColor4f(0.0f, 0.7f, 0.7f, 0.7f);
+ glLineWidth(1.0f);
+ }
drawCircle(Vertex(start.getX(), start.getZ()), 0.3f, 128);
glLineWidth(2.0f);
diff --git a/Tool.h b/Tool.h
index b958ddf..b1e3731 100644
--- a/Tool.h
+++ b/Tool.h
@@ -1,17 +1,21 @@
#ifndef TOOL_H_
#define TOOL_H_
+#include "Object.h"
#include <gtk/gtk.h>
-class Tool {
+class Tool : public Object {
public:
virtual ~Tool() {}
virtual void activate() {};
virtual void deactivate() {};
- virtual const gchar *getName() = 0;
+ virtual const char *getName() const {
+ return getType();
+ }
+
virtual GtkWidget *getImage() = 0;
virtual bool isSensitive() = 0;
};
diff --git a/ToolAddPolygon.cpp b/ToolAddPolygon.cpp
index a958665..37613bf 100644
--- a/ToolAddPolygon.cpp
+++ b/ToolAddPolygon.cpp
@@ -1,9 +1,6 @@
#include "ToolAddPolygon.h"
-const gchar *ToolAddPolygon::name = (const gchar*)"Add polygonal room";
-
-
ToolAddPolygon::ToolAddPolygon(EditManager *editManager) {
this->editManager = editManager;
@@ -22,7 +19,3 @@ void ToolAddPolygon::activate() {
void ToolAddPolygon::deactivate() {
editManager->finishRoom();
}
-
-GtkWidget *ToolAddPolygon::getImage() {
- return image;
-}
diff --git a/ToolAddPolygon.h b/ToolAddPolygon.h
index d3ec2d3..b3c7856 100644
--- a/ToolAddPolygon.h
+++ b/ToolAddPolygon.h
@@ -10,8 +10,6 @@ class ToolAddPolygon : public Tool {
EditManager *editManager;
- static const gchar* name;
-
// prevent shallow copy
ToolAddPolygon(const ToolAddPolygon &t);
const ToolAddPolygon& operator=(const ToolAddPolygon &t);
@@ -23,15 +21,21 @@ class ToolAddPolygon : public Tool {
virtual void activate();
virtual void deactivate();
- virtual const gchar *getName() {
- return name;
+ virtual const char *getType() const {
+ return "ToolAddPolygon";
+ }
+
+ virtual const char *getName() const {
+ return "Add polygonal room";
}
bool isSensitive() {
return TRUE;
}
- virtual GtkWidget *getImage();
+ virtual GtkWidget *getImage() {
+ return image;
+ }
};
#endif /*TOOLADDPOLYGON_H_*/
diff --git a/ToolSelector.cpp b/ToolSelector.cpp
index aa19e65..2b61dee 100644
--- a/ToolSelector.cpp
+++ b/ToolSelector.cpp
@@ -1,9 +1,6 @@
#include "ToolSelector.h"
-const gchar *ToolSelector::name = (const gchar*)"Select";
-
-
ToolSelector::ToolSelector(EditManager *editManager) {
this->editManager = editManager;
@@ -14,7 +11,3 @@ ToolSelector::ToolSelector(EditManager *editManager) {
ToolSelector::~ToolSelector() {
g_object_unref(G_OBJECT(image));
}
-
-GtkWidget *ToolSelector::getImage() {
- return image;
-}
diff --git a/ToolSelector.h b/ToolSelector.h
index 1692bf3..b88c861 100644
--- a/ToolSelector.h
+++ b/ToolSelector.h
@@ -10,8 +10,6 @@ class ToolSelector : public Tool {
EditManager *editManager;
- static const gchar* name;
-
// prevent shallow copy
ToolSelector(const ToolSelector &t);
const ToolSelector& operator=(const ToolSelector &t);
@@ -20,15 +18,21 @@ class ToolSelector : public Tool {
ToolSelector(EditManager *editManager);
virtual ~ToolSelector();
- virtual const gchar *getName() {
- return name;
+ virtual const char *getType() const {
+ return "ToolSelector";
+ }
+
+ virtual const char *getName() const {
+ return "Select";
}
bool isSensitive() {
return TRUE;
}
- virtual GtkWidget *getImage();
+ virtual GtkWidget *getImage() {
+ return image;
+ }
};
#endif /*TOOLSELECTOR_H_*/