xhads/source/equipment.adb

60 lines
2.6 KiB
Ada
Raw Normal View History

-- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic
--
-- GNU General Public Licence (version 3 or later)
2024-05-11 06:01:07 -04:00
with core, ui;
2024-02-15 21:03:09 -05:00
2024-05-11 03:38:33 -04:00
package body equipment is
2024-02-15 21:03:09 -05:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function "=" (a, b : in enumeration) return boolean is begin return natural (enumeration'pos (a)) = natural (enumeration'pos (b)); end "=";
function "/" (a, b : in enumeration) return boolean is begin return natural (enumeration'pos (a)) /= natural (enumeration'pos (b)); end "/";
------------------------------------------------------------------------------------------
2024-02-15 21:03:09 -05:00
procedure configure is
time : float := 0.0;
2024-02-15 21:03:09 -05:00
begin
time := core.time;
--
core.echo (core.comment, "Configuring" & count'image & " equipment components...");
--
for index in enumeration loop
declare folder : constant string := core.lowercase (slot'image (description (index).kind));
file : constant string := core.lowercase (enumeration'image (index));
2024-02-16 05:52:11 -05:00
begin
sprite (index) := core.import_sprite (core.folder & "/game/equipment/" & folder & "/" & file & ".png", 4, 6);
icon (index) := core.import_sprite (core.folder & "/icon/equipment/" & folder & "/" & file & ".png", 1, 1);
2024-02-16 05:52:11 -05:00
end;
2024-02-15 21:03:09 -05:00
end loop;
--
core.echo (core.success, "Successfully configured equipment information in" & natural'image (natural (1_000_000.0 * (core.time - time))) & " microseconds.");
2024-02-15 21:03:09 -05:00
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;
2024-05-11 06:01:07 -04:00
------------------------------------------------------------------------------------------
procedure draw_plus (index : in enumeration; state : in core.animation; x, y : in integer) is
use type core.cursor_code;
2024-05-11 06:01:07 -04:00
begin
draw (index, state, x, y);
--
if core.cursor_inside (x, y, sprite (index).width, sprite (index).height)
2024-05-22 21:05:19 -04:00
and core.cursor_mode = core.cursor_middle
and index / none
and not ui.prioritize then
2024-06-01 15:36:15 -04:00
core.write_text_box (core.bound (description (index).name));
2024-05-11 06:01:07 -04:00
end if;
end draw_plus;
2024-02-15 21:03:09 -05:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2024-05-11 03:38:33 -04:00
end equipment;