xhads/source/menu.adb

67 lines
3.1 KiB
Ada
Raw Normal View History

2024-02-16 09:59:19 -05:00
with core, ui, effect, attribute, skill, resource, faction, might, magic, item, unit, construction, world, menu;
2024-02-15 21:03:09 -05:00
use menu;
package body menu is
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
procedure configure is
begin
2024-02-16 09:59:19 -05:00
trait (attribute_information).title := "Attribute Information ";
trait (skill_information).title := "Skill Information ";
trait (resource_information).title := "Resource Information ";
--
trait (attribute_information).elements := new element_array (0 .. attribute.codex'pos (attribute.codex'last));
trait (skill_information).elements := new element_array (0 .. skill.codex'pos (skill.codex'last));
trait (resource_information).elements := new element_array (0 .. resource.codex'pos (resource.codex'last));
--
trait (attribute_information).length := attribute.codex'pos (attribute.codex'last) + 1;
trait (skill_information).length := skill.codex'pos (skill.codex'last) + 1;
trait (resource_information).length := resource.codex'pos (resource.codex'last) + 1;
--
for index in 0 .. attribute.codex'pos (attribute.codex'last)
loop
trait (attribute_information).elements (index) := (button, index, attribute.trait (attribute.codex'val (index)).name, attribute.icon (attribute.codex'val (index)));
end loop;
--
for index in 0 .. skill.codex'pos (skill.codex'last)
loop
trait (skill_information).elements (index) := (button, index, skill.trait (skill.codex'val (index)).name, skill.icon (skill.codex'val (index)));
end loop;
--
for index in 0 .. resource.codex'pos (resource.codex'last)
loop
trait (resource_information).elements (index) := (button, index, resource.trait (resource.codex'val (index)).name, resource.icon (resource.codex'val (index)));
end loop;
2024-02-15 21:03:09 -05:00
end configure;
2024-02-16 09:59:19 -05:00
------------------------------------------------------------------------------------------
procedure draw (index : in codex; x, y : in integer) is
2024-02-16 11:12:54 -05:00
icon_offset : constant integer := 16;
2024-02-16 09:59:19 -05:00
icon_size : constant integer := 32;
2024-02-16 11:12:54 -05:00
offset : constant integer := icon_size + icon_offset;
2024-02-16 09:59:19 -05:00
width : constant integer := 300;
2024-02-16 11:12:54 -05:00
height : constant integer := trait (index).length * offset + 2 * icon_offset;
2024-02-15 21:03:09 -05:00
begin
2024-02-16 09:59:19 -05:00
if index = none then
return;
end if;
--
2024-02-16 14:58:54 -05:00
ui.draw_title_bar (x, y, width, trait (index).title);
2024-02-16 11:12:54 -05:00
ui.draw_tiny_menu (x, y, width, height, true);
2024-02-16 09:59:19 -05:00
--
2024-02-16 11:12:54 -05:00
for element_index in 0 .. trait (index).length - 1
2024-02-16 09:59:19 -05:00
loop
2024-02-16 11:12:54 -05:00
ui.draw_frame (x + icon_offset, y + icon_offset + element_index * offset, offset, offset);
2024-02-16 09:59:19 -05:00
--
2024-02-16 11:12:54 -05:00
core.draw (trait (index).elements (element_index).icon, x + 3 * icon_offset / 2, y + 3 * icon_offset / 2 + element_index * offset);
core.write (trait (index).elements (element_index).text, x + 3 * icon_offset / 2 + offset, y + 3 * icon_offset / 2 + element_index * offset);
2024-02-16 09:59:19 -05:00
end loop;
2024-02-15 21:03:09 -05:00
end draw;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end menu;