2024-04-25 00:27:13 -04:00
|
|
|
-- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic
|
|
|
|
--
|
|
|
|
-- GNU General Public Licence (version 3 or later)
|
|
|
|
|
2024-05-08 15:43:44 -04:00
|
|
|
with core, ui, effect;
|
2024-02-15 21:03:09 -05:00
|
|
|
|
|
|
|
package body magic is
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-13 15:43:06 -04:00
|
|
|
view_width : constant natural := 64;
|
|
|
|
view_height : constant natural := 64;
|
2024-02-15 21:03:09 -05:00
|
|
|
|
2024-05-19 03:18:31 -04:00
|
|
|
view : 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...");
|
|
|
|
--
|
2024-04-27 10:01:54 -04:00
|
|
|
for index in enumeration loop
|
2024-06-01 11:27:59 -04:00
|
|
|
declare folder : constant string := core.lowercase (school'image (description (index).kind));
|
2024-04-27 10:01:54 -04:00
|
|
|
file : constant string := core.lowercase (enumeration'image (index));
|
2024-02-15 21:03:09 -05:00
|
|
|
begin
|
2024-05-19 03:18:31 -04:00
|
|
|
view (index) := core.import_sprite (core.folder & "/view/magic/" & folder & "/" & file & ".png", 1, 1);
|
2024-02-15 21:03:09 -05:00
|
|
|
end;
|
|
|
|
end loop;
|
|
|
|
end configure;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-19 03:18:31 -04:00
|
|
|
procedure draw (index : in enumeration; x, y : in integer) is
|
2024-03-11 16:47:28 -04:00
|
|
|
begin
|
2024-06-01 11:27:59 -04:00
|
|
|
ui.draw_sprite (view (index), description (index).text, x, y, 0);
|
2024-05-19 03:18:31 -04:00
|
|
|
end draw;
|
2024-03-11 16:47:28 -04:00
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-13 15:43:06 -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-05-19 03:18:31 -04:00
|
|
|
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);
|
2024-03-11 16:47:28 -04:00
|
|
|
begin
|
2024-05-19 03:18:31 -04:00
|
|
|
ui.draw_tiny_menu (x => move_x,
|
|
|
|
y => move_y,
|
2024-05-13 15:43:06 -04:00
|
|
|
width => width,
|
|
|
|
height => height);
|
|
|
|
--
|
|
|
|
for index in enumeration loop
|
2024-05-19 03:18:31 -04:00
|
|
|
draw (index, move_x + offset + enumeration'pos (index) * (offset + view_width), move_y + offset);
|
2024-05-13 15:43:06 -04:00
|
|
|
end loop;
|
|
|
|
end menu;
|
2024-03-11 16:47:28 -04:00
|
|
|
|
2024-02-15 21:03:09 -05:00
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
end magic;
|