diff options
author | jacopograndi <jak.sk8@hotmail.it> | 2021-08-30 14:48:06 +0200 |
---|---|---|
committer | jacopograndi <jak.sk8@hotmail.it> | 2021-08-30 14:48:06 +0200 |
commit | fb5a98b72ab79949d1da7f75a3d6150c2906ef40 (patch) | |
tree | 9097b4e1f31e530874df9ab85be03f763fc4ef1b /game/view.cpp | |
parent | ace5c3f3093c50ff7fa6f8b281a377e3788abbd5 (diff) |
gui: tech representation, menu, tile & unit info, attack info
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; |