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;
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
@ -22,22 +32,22 @@ package body menu is
--
for index in attribute.codex
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;
--
for index in skill.codex
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;
--
for index in resource.codex
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;
--
for index in 0 .. 1
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 configure;

View File

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