Refactored menus again...
This commit is contained in:
parent
6cf54f7fac
commit
077aa6a5da
@ -129,6 +129,13 @@ package body core is
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure debug (text : in string) is
|
||||
begin
|
||||
put_line (text);
|
||||
end debug;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure hexagonal_grid (x, y, width, height : in integer; fill : in boolean) is
|
||||
crop_width : constant integer := width mod hexagon_grid_sprite.width;
|
||||
crop_height : constant integer := height mod hexagon_grid_sprite.height;
|
||||
|
@ -106,6 +106,7 @@ package core is
|
||||
procedure line (origin, offset : in vector_2);
|
||||
|
||||
procedure write (text : in string; x, y : in integer; colour : in integer := 16#CCCCCC#);
|
||||
procedure debug (text : in string);
|
||||
|
||||
procedure hexagonal_grid (x, y, width, height : in integer; fill : in boolean);
|
||||
|
||||
|
@ -116,8 +116,8 @@ begin
|
||||
menu.draw (menu.skill_information, 700, 100, false);
|
||||
menu.draw (menu.resource_information, 400, 100, false);
|
||||
--
|
||||
core.write ("Menu :" & menu.trait (menu.mouse_over_menu).title, preview_width + 32, 32 + 320, 16#CCCCCC#);
|
||||
--~core.write ("Menu Element :" & menu.trait (menu.mouse_over_menu_element).name, preview_width + 32, 32 + 352, 16#CCCCCC#);
|
||||
core.write ("Menu :" & menu.trait (menu.mouse_over_menu).title, preview_width + 32, 32 + 320, 16#CCCCCC#);
|
||||
core.write ("Menu Element :" & menu.trait (menu.mouse_over_menu).elements (menu.mouse_over_menu_element).text, preview_width + 32, 32 + 352, 16#CCCCCC#);
|
||||
end loop gameplay;
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -18,7 +18,7 @@ package body menu is
|
||||
trait (attribute_information) := ("Attribute Information ", attribute.count, 10, 100, 64, new element_array (0 .. attribute.count - 1));
|
||||
trait (skill_information) := ("Skill Information ", skill.count, 10, 700, 64, new element_array (0 .. skill.count - 1));
|
||||
trait (resource_information) := ("Resource Information ", resource.count, 10, 400, 64, new element_array (0 .. resource.count - 1));
|
||||
trait (none) := ("-- ", 0, 10, 0, 0, null);
|
||||
trait (none) := ("-- ", 2, 10, 0, 0, new element_array (0 .. 1));
|
||||
--
|
||||
for index in attribute.codex
|
||||
loop
|
||||
@ -34,6 +34,11 @@ package body menu is
|
||||
loop
|
||||
trait (resource_information).elements (resource.codex'pos (index)) := (button, resource.codex'pos (index), resource.trait (index).name, resource.icon (index));
|
||||
end loop;
|
||||
--
|
||||
for index in 0 .. 1
|
||||
loop
|
||||
trait (none).elements (index) := (button, index, "-- ", resource.icon (resource.gold));
|
||||
end loop;
|
||||
end configure;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
@ -41,6 +46,9 @@ package body menu is
|
||||
procedure synchronize is
|
||||
limitation : integer;
|
||||
begin
|
||||
mouse_over_menu := none;
|
||||
mouse_over_menu_element := 0;
|
||||
--
|
||||
for index in codex
|
||||
loop
|
||||
limitation := (if trait (index).length < trait (index).height then trait (index).length else trait (index).height);
|
||||
@ -50,9 +58,17 @@ package body menu is
|
||||
and core.cursor_y > trait (index).y
|
||||
and core.cursor_y < trait (index).y + limitation * offset + 2 * draw_offset then
|
||||
mouse_over_menu := index;
|
||||
end if;
|
||||
--
|
||||
if mouse_over_menu /= none then
|
||||
for element_index in 0 .. limitation - 1
|
||||
loop
|
||||
if core.cursor_y > trait (index).y + draw_offset + element_index * offset
|
||||
and core.cursor_y < trait (index).y + draw_offset + element_index * offset + offset then
|
||||
mouse_over_menu_element := element_index;
|
||||
end if;
|
||||
end loop;
|
||||
return;
|
||||
else
|
||||
mouse_over_menu := none;
|
||||
end if;
|
||||
end loop;
|
||||
end synchronize;
|
||||
|
@ -39,7 +39,7 @@ package menu is
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
mouse_over_menu : codex;
|
||||
mouse_over_menu_element : codex;
|
||||
mouse_over_menu_element : integer;
|
||||
|
||||
trait : trait_array;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user