xhads/source/menu.adb

65 lines
3.1 KiB
Ada

with core, ui, effect, attribute, skill, resource, faction, might, magic, item, unit, construction, world, menu;
use menu;
package body menu is
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
procedure configure is
begin
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;
end configure;
------------------------------------------------------------------------------------------
procedure draw (index : in codex; x, y : in integer) is
icon_offset : constant integer := 8;
icon_size : constant integer := 32;
width : constant integer := 300;
height : constant integer := trait (index).length * (icon_size + 2 * icon_offset) + 4 * icon_offset;
begin
if index = none then
return;
end if;
--
ui.draw_tiny_menu (x - 2 * icon_offset, y - 2 * icon_offset, width, height, true);
--
for offset in 0 .. trait (index).length - 1
loop
ui.draw_frame (x, y + offset * (icon_size + 2 * icon_offset), icon_size + 2 * icon_offset, icon_size + 2 * icon_offset);
--
core.draw (trait (index).elements (offset).icon, x + icon_offset, y + icon_offset + offset * (icon_size + 2 * icon_offset));
core.write (trait (index).elements (offset).text, x + icon_offset + (icon_size + 2 * icon_offset), y + icon_offset + offset * (icon_size + 2 * icon_offset));
end loop;
end draw;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end menu;