xhads/source/magic.adb

59 lines
2.4 KiB
Ada
Raw Normal View History

-- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic
--
-- GNU General Public Licence (version 3 or later)
with core, ui, effect;
2024-02-15 21:03:09 -05:00
package body magic is
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
view_width : constant natural := 64;
view_height : constant natural := 64;
2024-02-15 21:03:09 -05:00
view_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 magic components...");
--
for index in enumeration 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/magic/" & folder & "/" & file & ".png", 1, 1);
2024-02-15 21:03:09 -05:00
end;
end loop;
end configure;
------------------------------------------------------------------------------------------
procedure view (index : in enumeration; x, y : in integer) is
2024-03-11 16:47:28 -04:00
begin
ui.draw_sprite (view_sprite (index), trait (index).text, x, y, 0);
end view;
2024-03-11 16:47:28 -04:00
------------------------------------------------------------------------------------------
procedure menu (x, y : in integer; center : in boolean) is
offset : constant integer := core.icon;
width : constant integer := count * view_width + (count + 1) * offset + offset / 2;
height : constant integer := view_height + 2 * offset + offset / 2;
2024-03-11 16:47:28 -04:00
begin
ui.draw_tiny_menu (x => (if center then (core.window_width - width) / 2 else x),
y => (if center then (core.window_height - height) / 2 else y),
width => width,
height => height);
--
for index in enumeration loop
view (index, (if center then (core.window_width - width) / 2 else x) + offset + enumeration'pos (index) * (offset + view_width),
(if center then (core.window_height - height) / 2 else y) + offset);
end loop;
end menu;
2024-03-11 16:47:28 -04:00
2024-02-15 21:03:09 -05:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end magic;