New button function...

This commit is contained in:
Ognjen Milan Robovic 2024-02-19 19:46:37 -05:00
parent 077aa6a5da
commit a1f4786720
2 changed files with 22 additions and 8 deletions

View File

@ -11,6 +11,16 @@ package body menu is
icon_size : constant integer := 32; icon_size : constant integer := 32;
offset : constant integer := icon_size + 2 * icon_offset; offset : constant integer := icon_size + 2 * icon_offset;
button_width : constant integer := 2 * draw_offset + offset + 24 * 8 - 2 * draw_offset;
button_height : constant integer := offset;
------------------------------------------------------------------------------------------
function make_button (element_index : in integer; text : in core.short_string; icon : in core.sprite) return element is
begin
return (button, 0, text, icon, draw_offset, draw_offset + element_index * offset, button_width, button_height);
end make_button;
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
procedure configure is procedure configure is
@ -22,22 +32,22 @@ package body menu is
-- --
for index in attribute.codex for index in attribute.codex
loop loop
trait (attribute_information).elements (attribute.codex'pos (index)) := (button, attribute.codex'pos (index), attribute.trait (index).name, attribute.icon (index)); trait (attribute_information).elements (attribute.codex'pos (index)) := make_button (attribute.codex'pos (index), attribute.trait (index).name, attribute.icon (index));
end loop; end loop;
-- --
for index in skill.codex for index in skill.codex
loop loop
trait (skill_information).elements (skill.codex'pos (index)) := (button, skill.codex'pos (index), skill.trait (index).name, skill.icon (index)); trait (skill_information).elements (skill.codex'pos (index)) := make_button (skill.codex'pos (index), skill.trait (index).name, skill.icon (index));
end loop; end loop;
-- --
for index in resource.codex for index in resource.codex
loop loop
trait (resource_information).elements (resource.codex'pos (index)) := (button, resource.codex'pos (index), resource.trait (index).name, resource.icon (index)); trait (resource_information).elements (resource.codex'pos (index)) := make_button (resource.codex'pos (index), resource.trait (index).name, resource.icon (index));
end loop; end loop;
-- --
for index in 0 .. 1 for index in 0 .. 1
loop loop
trait (none).elements (index) := (button, index, "-- ", resource.icon (resource.gold)); trait (none).elements (index) := make_button (index, "-- ", resource.icon (resource.gold));
end loop; end loop;
end configure; end configure;

View File

@ -20,6 +20,10 @@ package menu is
data : integer; data : integer;
text : core.short_string; text : core.short_string;
icon : core.sprite; icon : core.sprite;
x : integer;
y : integer;
width : integer;
height : integer;
end record; end record;
type element_array is array (natural range <>) of element; type element_array is array (natural range <>) of element;