Permalink
Browse files

Associate tiles with an overlay for selection

  • Loading branch information...
1 parent 53ba6b2 commit 159dacd94f7daf56898e533bbd76c8c0ab8a7ccc @arvind committed Apr 26, 2011
Showing with 19 additions and 4 deletions.
  1. +6 −4 main.cpp
  2. +8 −0 tile.cpp
  3. +5 −0 tile.h
View
@@ -128,15 +128,17 @@ void handleUpDown(Overlay * overlay, std::string pointID, GLint button, GLint bu
bool intersected = false;
for(it = obj_list.begin(); it != obj_list.end(); it++) {
if(it->intersects(posInOverlay[0], posInOverlay[1]) && button_state == GLUT_DOWN) {
- if(modifiers & GLUT_ACTIVE_CTRL)
- it->toggleSelected();
- else
+ it->setOverlayID(overlay->getID());
+// if(modifiers & GLUT_ACTIVE_CTRL)
+// it->toggleSelected();
+// else
it->setSelected(true);
intersected_tile = it;
intersected = true;
} else {
- if((modifiers & GLUT_ACTIVE_CTRL) == 0)
+ if(it->getOverlayID().compare(overlay->getID()) == 0)
+// if((modifiers & GLUT_ACTIVE_CTRL) == 0)
it->setSelected(false);
}
}
View
@@ -56,6 +56,14 @@ GLfloat Tile::getHeight() {
return this->height;
}
+std::string Tile::getOverlayID() {
+ return this->overlay_id;
+}
+
+void Tile::setOverlayID(std::string id) {
+ this->overlay_id = id;
+}
+
void Tile::setTileSize(GLfloat new_w, GLfloat new_h) {
this->width = new_w;
this->height = new_h;
View
@@ -13,10 +13,13 @@
#define ZOOM 2
#define ROTATE 3
+#include <string>
+
class Tile {
private:
GLuint texture;
char * filename;
+ std::string overlay_id;
GLfloat x, y, z; // Translation
GLfloat width, height; // Dimensions
@@ -32,6 +35,8 @@ class Tile {
GLfloat getZ();
GLfloat getWidth();
GLfloat getHeight();
+ std::string getOverlayID();
+ void setOverlayID(std::string overlay_id);
void setTileSize(GLfloat new_w, GLfloat new_h);

0 comments on commit 159dacd

Please sign in to comment.