From a1f4786720743c18ce7fc2354ec03e4a9263b260 Mon Sep 17 00:00:00 2001 From: xolatile Date: Mon, 19 Feb 2024 19:46:37 -0500 Subject: [PATCH] New button function... --- source/menu.adb | 18 ++++++++++++++---- source/menu.ads | 12 ++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/source/menu.adb b/source/menu.adb index 0b9b959..ac9c813 100644 --- a/source/menu.adb +++ b/source/menu.adb @@ -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; diff --git a/source/menu.ads b/source/menu.ads index eb48cfb..433eb89 100644 --- a/source/menu.ads +++ b/source/menu.ads @@ -16,10 +16,14 @@ package menu is type element is record - kind : format; - data : integer; - text : core.short_string; - icon : core.sprite; + kind : format; + 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;