From bb16c32bde58cba70e4877aa2d3ebd04332eb575 Mon Sep 17 00:00:00 2001 From: jacopograndi Date: Tue, 4 Jan 2022 13:35:02 +0100 Subject: linux compile and imgs --- game/menu.cpp | 152 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 76 insertions(+), 76 deletions(-) (limited to 'game/menu.cpp') diff --git a/game/menu.cpp b/game/menu.cpp index b5a91b9..6349f29 100644 --- a/game/menu.cpp +++ b/game/menu.cpp @@ -1,77 +1,77 @@ -#include - -#include "menu.h" - -void Menu::close () { - active = false; -} - -void Menu::open (vec2 res) { - over = -1; - active = true; - pos = vec2 { (float)res.x, (float)res.y }; - float height = options.size() * 20; - size = vec2 { 150, height+10 }; - pos *= 0.5f; - pos -= size/2; -} - -int Menu::mouse_option (vec2 mouse) { - int i=0; - for (Option opt : options) { - vec2 off { 0, 5.0f + i*20 }; - vec2 sizeopt { 150, 20 }; - off += pos; - if (off.x < mouse.x && mouse.x < off.x+sizeopt.x - && off.y < mouse.y && mouse.y < off.y+sizeopt.y ) { - return opt.id; - } - i++; - } - return -1; -} - - -void Menu_tech::open (vec2 res) { - over = -1; - active = true; - pos = vec2 { (float)res.x, (float)res.y }; - - tech_opt_ordered.clear(); - tech_opt_ordered.emplace_back(); - tech_opt_ordered.emplace_back(); - tech_opt_ordered.emplace_back(); - tech_opt_ordered.emplace_back(); - - for (OptionTech opt : tech_options) { - tech_opt_ordered[opt.tech->level].emplace_back(opt); - } - int maxsize = 0; - for (auto v : tech_opt_ordered) { - maxsize = maxsize < v.size() ? v.size() : maxsize; - } - - float width = 150 * tech_opt_ordered.size(); - float height = maxsize * 10; - size = vec2 { width, height+20 }; - pos *= 0.5f; - pos -= size/2; -} - -int Menu_tech::mouse_option (vec2 mouse) { - float x = 0, y = 0; - for (auto v : tech_opt_ordered) { - for (auto opt : v) { - vec2 off { x*150, 10.0f + y*10 }; - vec2 sizeopt { 150, 10 }; - off += pos; - if (off.x < mouse.x && mouse.x < off.x+sizeopt.x - && off.y < mouse.y && mouse.y < off.y+sizeopt.y ) { - return opt.tech->id; - } - y++; - } - x++; y=0; - } - return -1; +#include + +#include "menu.h" + +void Menu::close () { + active = false; +} + +void Menu::open (vec2 res) { + over = -1; + active = true; + pos = vec2 { (float)res.x, (float)res.y }; + float height = options.size() * 20; + size = vec2 { 150, height+10 }; + pos *= 0.5f; + pos -= size/2; +} + +int Menu::mouse_option (vec2 mouse) { + int i=0; + for (Option opt : options) { + vec2 off { 0, 5.0f + i*20 }; + vec2 sizeopt { 150, 20 }; + off += pos; + if (off.x < mouse.x && mouse.x < off.x+sizeopt.x + && off.y < mouse.y && mouse.y < off.y+sizeopt.y ) { + return opt.id; + } + i++; + } + return -1; +} + + +void Menu_tech::open (vec2 res) { + over = -1; + active = true; + pos = vec2 { (float)res.x, (float)res.y }; + + tech_opt_ordered.clear(); + tech_opt_ordered.emplace_back(); + tech_opt_ordered.emplace_back(); + tech_opt_ordered.emplace_back(); + tech_opt_ordered.emplace_back(); + + for (OptionTech opt : tech_options) { + tech_opt_ordered[opt.tech->level].emplace_back(opt); + } + int maxsize = 0; + for (auto v : tech_opt_ordered) { + maxsize = maxsize < v.size() ? v.size() : maxsize; + } + + float width = 150 * tech_opt_ordered.size(); + float height = maxsize * 10; + size = vec2 { width, height+20 }; + pos *= 0.5f; + pos -= size/2; +} + +int Menu_tech::mouse_option (vec2 mouse) { + float x = 0, y = 0; + for (auto v : tech_opt_ordered) { + for (auto opt : v) { + vec2 off { x*150, 10.0f + y*10 }; + vec2 sizeopt { 150, 10 }; + off += pos; + if (off.x < mouse.x && mouse.x < off.x+sizeopt.x + && off.y < mouse.y && mouse.y < off.y+sizeopt.y ) { + return opt.tech->id; + } + y++; + } + x++; y=0; + } + return -1; } \ No newline at end of file -- cgit v1.2.3-54-g00ecf