zoomedit: Generalized Tool objects.

This commit is contained in:
neoraider 2007-12-14 22:03:00 +00:00
parent 9a1bbf4b9a
commit d25becbace
8 changed files with 55 additions and 37 deletions

View file

@ -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_*/

18
Object.h Normal file
View file

@ -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_*/

View file

@ -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);

8
Tool.h
View file

@ -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;
};

View file

@ -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;
}

View file

@ -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_*/

View file

@ -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;
}

View file

@ -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_*/