mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 20:44:14 +02:00
fixed menu behavior
This commit is contained in:
parent
2f8a0b0c09
commit
e84d2696f9
2 changed files with 30 additions and 4 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue