xhads/source/menu.adb

68 lines
3.2 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
draw_offset : constant integer := 16;
icon_offset : constant integer := 4;
icon_size : constant integer := 32;
offset : constant integer := icon_size + 2 * icon_offset;
width : constant integer := 300;
height : constant integer := trait (index).length * offset + 2 * draw_offset;
begin
if index = none then
return;
end if;
--
ui.draw_title_bar (x, y, width, trait (index).title);
ui.draw_tiny_menu (x, y, width, height, true);
--
for element_index in 0 .. trait (index).length - 1
loop
ui.draw_frame (x + draw_offset, y + draw_offset + element_index * offset, offset, offset);
--
core.draw (trait (index).elements (element_index).icon, x + draw_offset + icon_offset, y + draw_offset + icon_offset + element_index * offset);
core.write (trait (index).elements (element_index).text, x + draw_offset + icon_offset + offset, y + draw_offset + icon_offset + element_index * offset);
end loop;
end draw;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end menu;