xhads/source/might.adb

78 lines
3.3 KiB
Ada
Raw Normal View History

-- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic
--
-- GNU General Public Licence (version 3 or later)
2024-03-11 16:36:42 -04:00
with core, ui, effect, might;
2024-02-15 21:03:09 -05:00
package body might is
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2024-03-11 16:36:42 -04:00
view_width : constant integer := 90;
view_height : constant integer := 90;
view_sprite : array (enumeration) of core.sprite;
icon_sprite : array (enumeration) of core.sprite;
2024-02-15 21:03:09 -05:00
------------------------------------------------------------------------------------------
procedure configure is
begin
2024-03-11 08:42:25 -04:00
core.echo (core.comment, "Configuring might components...");
--
for index in enumeration
2024-02-15 21:03:09 -05:00
loop
declare
folder : constant string := core.lowercase (school'image (trait (index).kind));
file : constant string := core.lowercase (enumeration'image (index));
2024-02-15 21:03:09 -05:00
begin
view_sprite (index) := core.import_sprite ("./sprite/might/" & folder & "/" & file & ".png", 1, 1);
icon_sprite (index) := core.import_sprite ("./sprite/might/icon/" & file & ".png", 1, 1);
2024-02-15 21:03:09 -05:00
end;
end loop;
end configure;
------------------------------------------------------------------------------------------
procedure icon (index : in enumeration; x, y : in integer) is
2024-03-11 16:36:42 -04:00
begin
core.draw (icon_sprite (index), x + 2, y + 2);
2024-03-13 19:55:53 -04:00
ui.draw_overicon (trait (index).text, x, y);
2024-03-11 16:36:42 -04:00
end icon;
------------------------------------------------------------------------------------------
procedure view (index : in enumeration; x, y : in integer) is
2024-03-11 16:36:42 -04:00
offset : constant integer := 4;
begin
core.draw (view_sprite (index), x + offset, y + offset);
2024-03-13 19:55:53 -04:00
ui.draw_icon_menu (trait (index).text, x, y, view_width + 2 * offset, view_height + 2 * offset);
2024-03-11 16:36:42 -04:00
end view;
------------------------------------------------------------------------------------------
procedure menu (x, y : in integer; center : in boolean) is
offset : constant integer := 16;
width : constant integer := 168 * 8 + 2 * offset;
height : constant integer := 12 * core.icon + 2 * offset;
move_x : constant integer := (if center then (core.window_width - width) / 2 else x);
move_y : constant integer := (if center then (core.window_height - height) / 2 else y);
--
next : array (0 .. 7) of integer := (others => 0);
2024-02-15 21:03:09 -05:00
begin
2024-03-11 16:36:42 -04:00
ui.draw_tiny_menu (move_x, move_y, width, height, true);
ui.draw_title_bar (move_x, move_y, width, "Might Abilities");
--
for index in enumeration
2024-03-11 16:36:42 -04:00
loop
2024-04-23 16:19:29 -04:00
icon (index, move_x + offset + school'pos (trait (index).kind) * 168, move_y + offset + next (school'pos (trait (index).kind)) * core.icon);
ui.write (trait (index).name, move_x + offset + school'pos (trait (index).kind) * 168 + core.icon, move_y + offset + next (school'pos (trait (index).kind)) * core.icon);
2024-03-11 16:36:42 -04:00
--
next (school'pos (trait (index).kind)) := next (school'pos (trait (index).kind)) + 1;
end loop;
end menu;
2024-02-15 21:03:09 -05:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end might;