diff options
Diffstat (limited to 'game/view.cpp')
-rw-r--r-- | game/view.cpp | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/game/view.cpp b/game/view.cpp index d00fd2a..095a99a 100644 --- a/game/view.cpp +++ b/game/view.cpp @@ -11,6 +11,36 @@ void View::process (Gst &gst, vec2 cam, vec2 mouse, int *mheld) { cursor_entity = -1; back = -1; opt = -1; + hover_ground = -1; + + bool hfound = false; + for (int y=0; y<gr.sizey && !hfound; y++) { + for (int x=0; x<gr.sizex && !hfound; x++) { + vec2 pos { (float)x*32, (float)y*32 }; + if (pos.x < absmouse.x && absmouse.x <= pos.x+32 + && pos.y < absmouse.y && absmouse.y <= pos.y+32) + { + hover_ground = x+y*gr.sizex; + hfound = true; + } + } + } + + if (menu_train.active) { + menu_train.over = menu_train.mouse_option(mouse); + } + if (menu_build.active) { + menu_build.over = menu_build.mouse_option(mouse); + } + if (menu_unit.active) { + menu_unit.over = menu_unit.mouse_option(mouse); + } + if (menu_day.active) { + menu_day.over = menu_day.mouse_option(mouse); + } + if (menu_tech.active) { + menu_tech.over = menu_tech.mouse_option(mouse); + } if (mheld[0] == 1) { bool found = false; @@ -27,8 +57,8 @@ void View::process (Gst &gst, vec2 cam, vec2 mouse, int *mheld) { } if (!valid) continue; vec2 pos { (float)x*32, (float)y*32 }; - if (pos.x < absmouse.x && absmouse.x < pos.x+32 - && pos.y < absmouse.y && absmouse.y < pos.y+32) + if (pos.x < absmouse.x && absmouse.x <= pos.x+32 + && pos.y < absmouse.y && absmouse.y <= pos.y+32) { cursor_ground = moves[i]; } @@ -41,8 +71,8 @@ void View::process (Gst &gst, vec2 cam, vec2 mouse, int *mheld) { int x = attacks[i] % gr.sizex; int y = attacks[i] / gr.sizex; vec2 pos { (float)x*32, (float)y*32 }; - if (pos.x < absmouse.x && absmouse.x < pos.x+32 - && pos.y < absmouse.y && absmouse.y < pos.y+32) + if (pos.x < absmouse.x && absmouse.x <= pos.x+32 + && pos.y < absmouse.y && absmouse.y <= pos.y+32) { cursor_ground = attacks[i]; } @@ -85,13 +115,22 @@ void View::process (Gst &gst, vec2 cam, vec2 mouse, int *mheld) { back = 1; found = 1; } } + + if (menu_tech.active && !found) { + int selected = menu_tech.mouse_option(mouse); + if (selected != -1) { + opt = selected; found = true; + } else { + back = 1; found = 1; + } + } for (int i=0; i<entities.size() && !found; i++) { if (entities[i].done) continue; if (entities[i].owner != gst.turn) continue; vec2 pos { (float)entities[i].x*32, (float)entities[i].y*32 }; - if (pos.x < absmouse.x && absmouse.x < pos.x+32 - && pos.y < absmouse.y && absmouse.y < pos.y+32) + if (pos.x < absmouse.x && absmouse.x <= pos.x+32 + && pos.y < absmouse.y && absmouse.y <= pos.y+32) { cursor_entity = i; if (entities[i].info->unit == 1) { @@ -104,8 +143,8 @@ void View::process (Gst &gst, vec2 cam, vec2 mouse, int *mheld) { for (int y=0; y<gr.sizey && !found; y++) { for (int x=0; x<gr.sizex && !found; x++) { vec2 pos { (float)x*32, (float)y*32 }; - if (pos.x < absmouse.x && absmouse.x < pos.x+32 - && pos.y < absmouse.y && absmouse.y < pos.y+32) + if (pos.x < absmouse.x && absmouse.x <= pos.x+32 + && pos.y < absmouse.y && absmouse.y <= pos.y+32) { cursor_ground = x+y*gr.sizex; found = true; |