xhads/source/unit.adb

73 lines
3.0 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, attribute, faction;
2024-02-15 21:03:09 -05:00
package body unit is
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2024-03-11 15:35:56 -04:00
view_width : constant integer := 48;
view_height : constant integer := 64;
sprite : array (enumeration) of core.sprite;
icon_sprite : array (enumeration) of core.sprite;
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 unit components...");
--
for index in enumeration loop
declare folder : constant string := core.lowercase (faction.enumeration'image (trait (index).kind));
file : constant string := core.lowercase (enumeration'image (index));
2024-02-15 21:03:09 -05:00
begin
sprite (index) := core.import_sprite ("./sprite/unit/" & folder & "/" & file & ".png", 4, 6);
icon_sprite (index) := core.import_sprite ("./sprite/unit/icon/" & file & ".png", 1, 1);
view_sprite (index) := core.import_sprite ("./sprite/unit/view/" & file & ".png", 1, 1);
2024-02-15 21:03:09 -05:00
end;
end loop;
end configure;
------------------------------------------------------------------------------------------
procedure draw (index : in enumeration; state : in core.animation; x, y : in integer) is
2024-02-15 21:03:09 -05:00
begin
2024-05-16 14:52:41 -04:00
core.draw (sprite (index), x, y, state => state);
2024-02-15 21:03:09 -05:00
end draw;
------------------------------------------------------------------------------------------
procedure icon (index : in enumeration; x, y : in integer) is
begin
2024-04-27 12:34:16 -04:00
ui.draw_overicon (icon_sprite (index), trait (index).text, x, y);
end icon;
------------------------------------------------------------------------------------------
procedure view (index : in enumeration; x, y : in integer) is
2024-03-11 15:35:56 -04:00
offset : constant integer := 4;
begin
2024-03-11 15:35:56 -04:00
core.draw (view_sprite (index), x + offset, y + offset);
ui.draw_icon_menu (x, y, view_width + 2 * offset, view_height + 2 * offset);
end view;
------------------------------------------------------------------------------------------
2024-05-11 02:13:20 -04:00
procedure draw_full (index : in natural; x, y : in integer) is
2024-05-11 03:03:28 -04:00
limit : constant value_limit := value_limit (index);
2024-03-11 15:35:56 -04:00
begin
2024-05-11 02:13:20 -04:00
draw (values (limit).kind, values (limit).state, x, y);
2024-03-11 15:35:56 -04:00
--
2024-05-11 03:38:33 -04:00
for equipment_index in equipment.slot loop
equipment.draw (values (limit).equipments (equipment_index), values (limit).state, x, y);
2024-03-11 15:35:56 -04:00
end loop;
2024-05-11 02:13:20 -04:00
end draw_full;
2024-03-11 15:35:56 -04:00
2024-02-15 21:03:09 -05:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end unit;