fixed menu behavior

This commit is contained in:
ZappoMan 2013-05-10 12:04:52 -07:00
parent 2f8a0b0c09
commit e84d2696f9
2 changed files with 30 additions and 4 deletions

View file

@ -1899,12 +1899,37 @@ glm::vec3 getGravity(glm::vec3 pos) {
}
}
bool menuDisplayed = false;
void mouseFunc(int button, int state, int x, int y) {
//catch mouse actions on the menu
bool menuClickedOrUnclicked = menu.mouseClick(x, y);
bool menuFound = menu.mouseClick(x, y);
if (!menuClickedOrUnclicked) {
// If we didn't previously have the menu displayed, and we did just click on the menu, then
// go into menuDisplayed mode....
if (!::menuDisplayed && menuFound) {
::menuDisplayed = true;
}
// If the menu was displayed, and we're not over a menu, then leave menu mode
if (::menuDisplayed && !menuFound) {
::menuDisplayed = false;
menu.hidePopupMenu();
//menu.render(WIDTH,HEIGHT); // will hide the menu
}
// In menu displayed mode use old logic
if (::menuDisplayed) {
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN ) {
if (state == GLUT_DOWN && !menu.mouseClick(x, y)) {
mouseX = x;
mouseY = y;
mousePressed = 1;
} else if (state == GLUT_UP) {
mouseX = x;
mouseY = y;
mousePressed = 0;
}
}
} else {
if (button == GLUT_LEFT_BUTTON) {
mouseX = x;
mouseY = y;

View file

@ -24,6 +24,7 @@ public:
void render(int screenwidth, int screenheight);
void renderColumn(int i);
MenuColumn* addColumn(const char *columnName);
void hidePopupMenu() { currentColumn = -1; };
private:
std::vector<MenuColumn> columns;
int currentColumn;