@@ -140,6 +140,7 @@ begin | |||
gameplay: loop | |||
core.synchronize; | |||
ui.synchronize; | |||
-- | |||
exit when core.engine_active = false; | |||
-- | |||
@@ -163,7 +164,7 @@ begin | |||
-- | |||
menu_render; | |||
-- | |||
ui.draw_text_box (0, core.window_height - text_box_height, core.window_width, text_box_height); | |||
ui.draw_help_box (0, core.window_height - text_box_height, core.window_width, text_box_height); | |||
end loop gameplay; | |||
------------------------------------------------------------------------------------------ | |||
@@ -10,19 +10,30 @@ package body skill is | |||
sprite : array (enumeration) of core.sprite; | |||
menu_data : ui.structure := ("Skill Menu ", core.signal_o, false, true, false, 0, 0, 320, 160); | |||
------------------------------------------------------------------------------------------ | |||
procedure archery_menu is | |||
begin | |||
ui.draw_text_box ("Heyo world!"); | |||
end archery_menu; | |||
------------------------------------------------------------------------------------------ | |||
procedure configure is | |||
begin | |||
core.echo (core.comment, "Configuring skill components..."); | |||
-- | |||
ui.add_structure (menu_data); | |||
-- | |||
for index in enumeration loop | |||
sprite (index) := core.import_sprite ("./sprite/skill/" & core.lowercase (enumeration'image (index)) & ".png", 1, 1); | |||
end loop; | |||
end configure; | |||
------------------------------------------------------------------------------------------ | |||
procedure e is begin core.echo (core.warning, "Heyo world!"); end e; | |||
procedure menu (x, y : in integer; center : in boolean) is | |||
column : constant integer := 2; | |||
offset : constant integer := 32; | |||
@@ -35,7 +46,7 @@ procedure e is begin core.echo (core.warning, "Heyo world!"); end e; | |||
ui.draw_title_bar (move_x, move_y, width, "Skills"); | |||
-- | |||
for index in enumeration loop | |||
ui.draw_icon (sprite (index), trait (index).text, move_x + 216 * (enumeration'pos (index) mod column) + offset, move_y + core.icon * (enumeration'pos (index) / column) + offset, e'access); | |||
ui.draw_icon (sprite (index), trait (index).text, move_x + 216 * (enumeration'pos (index) mod column) + offset, move_y + core.icon * (enumeration'pos (index) / column) + offset, archery_menu'access); | |||
ui.write (trait (index).name, move_x + 216 * (enumeration'pos (index) mod column) + offset + core.icon, move_y + core.icon * (enumeration'pos (index) / column) + offset); | |||
end loop; | |||
end menu; | |||
@@ -28,18 +28,18 @@ package skill is | |||
count : constant natural := enumeration'pos (enumeration'last) + 1; | |||
trait : constant array (enumeration) of information := ( | |||
("Archery ", 0, "Archery skill determines effectiveness and range or your ranged units. "), | |||
("Diplomacy ", 0, "- "), | |||
("Estates ", 0, "- "), | |||
("Exploration ", 0, "- "), | |||
("Leadership ", 0, "- "), | |||
("Logistics ", 0, "- "), | |||
("Medicine ", 0, "- "), | |||
("Mercantile ", 0, "- "), | |||
("Mysticism ", 0, "- "), | |||
("Necromancy ", 0, "- "), | |||
("Sorcery ", 0, "- "), | |||
("Tactics ", 0, "- ") | |||
("Archery ", 0, "Archery skill determines effectiveness and range or your archers. "), | |||
("Diplomacy ", 0, "Diplomacy helps you to avoid starting a battle you can't win. "), | |||
("Estates ", 0, "Estates makes you the ultimate crypto-bro, establishing a blockchain. "), | |||
("Exploration ", 0, "Exploration is quite self-explanatory... "), | |||
("Leadership ", 0, "Leadership is the default skill for any true chad, like God intended. "), | |||
("Logistics ", 0, "Logistics is a nightmare in real life, but this is only a game. "), | |||
("Medicine ", 0, "Medicine skill makes you swallow pills like a kid in a drugstore. "), | |||
("Mercantile ", 0, "Mercantile is the skill of any true-born nosy person, otherwise useless."), | |||
("Mysticism ", 0, "Mysticism allows you to have 60 cats, drink wine and talk weird. "), | |||
("Necromancy ", 0, "Necromancy lets you not to waste the bones after every battle. "), | |||
("Sorcery ", 0, "Sorcery skill is appropriately named useless skill to have in real life."), | |||
("Tactics ", 0, "Tactics is the opposite of skirmish, master it and lose in every battle.") | |||
); | |||
------------------------------------------------------------------------------------------ | |||
@@ -46,6 +46,10 @@ package body ui is | |||
sprite : array (style, element) of core.sprite; | |||
font : array (style) of core.font; | |||
structure_array : array (0 .. 12) of structure; | |||
structure_count : natural := 0; | |||
------------------------------------------------------------------------------------------ | |||
procedure select_text_box (text : in string; x, y, width, height : in integer) is | |||
@@ -143,6 +147,22 @@ package body ui is | |||
------------------------------------------------------------------------------------------ | |||
procedure draw_structure (data : in out structure) is | |||
new_width : constant integer := (if data.resize then 640 else data.width); | |||
new_height : constant integer := (if data.resize then 480 else data.height); | |||
new_x : constant integer := (if data.center then (core.window_width - new_width) / 2 else data.x); | |||
new_y : constant integer := (if data.center then (core.window_height - new_height) / 2 else data.y); | |||
begin | |||
draw_tiny_menu (new_x, new_y, new_width, new_height); | |||
draw_title_bar (new_x, new_y, new_width, data.title); | |||
-- | |||
if core.signal_mode = core.signal_code'pos (data.toggle) then | |||
data.show := (if data.show then false else true); | |||
end if; | |||
end draw_structure; | |||
------------------------------------------------------------------------------------------ | |||
procedure configure is | |||
procedure load_ui (index : in style; folder_path : in string) is | |||
begin | |||
@@ -162,6 +182,26 @@ package body ui is | |||
------------------------------------------------------------------------------------------ | |||
procedure synchronize is | |||
begin | |||
for index in 0 .. 12 loop | |||
exit when index = structure_count; | |||
-- | |||
if structure_array (index).show then | |||
draw_structure (structure_array (index)); | |||
end if; | |||
end loop; | |||
end synchronize; | |||
------------------------------------------------------------------------------------------ | |||
procedure write (text : in string; x, y : in integer) is | |||
begin | |||
core.write (text, x, y, font (active)); | |||
end write; | |||
------------------------------------------------------------------------------------------ | |||
procedure draw_icon (data : in core.sprite; description : in string; x, y : in integer; action : core.pointer := core.idle'access) is | |||
save_zoom : natural := core.zoom; | |||
begin | |||
@@ -198,7 +238,31 @@ package body ui is | |||
------------------------------------------------------------------------------------------ | |||
procedure draw_text_box (x, y, width, height : in integer; action : core.pointer := core.idle'access) is | |||
procedure draw_text_box (text : in string) is | |||
width : constant integer := 144; | |||
height : constant integer := 72; | |||
x : constant integer := (core.window_width - width) / 2; | |||
y : constant integer := (core.window_height - height) / 2; | |||
offset : constant integer := sprite (active, text_middle).width; | |||
begin | |||
draw_background (text_middle, x + offset, y + offset, width - 2 * offset, height - 2 * offset); | |||
-- | |||
draw_horizontally (text_upper, x + offset, y, width - 2 * offset); | |||
draw_horizontally (text_lower, x + offset, y + height - offset, width - 2 * offset); | |||
draw_vertically (text_left, x, y + offset, height - 2 * offset); | |||
draw_vertically (text_right, x + width - offset, y + offset, height - 2 * offset); | |||
-- | |||
draw (text_upper_left, x, y); | |||
draw (text_upper_right, x + width - offset, y); | |||
draw (text_lower_left, x, y + height - offset); | |||
draw (text_lower_right, x + width - offset, y + height - offset); | |||
-- | |||
write (text, x, y); | |||
end draw_text_box; | |||
------------------------------------------------------------------------------------------ | |||
procedure draw_help_box (x, y, width, height : in integer; action : core.pointer := core.idle'access) is | |||
offset : constant integer := sprite (active, text_middle).width; | |||
begin | |||
draw_background (text_middle, x + offset, y + offset, width - 2 * offset, height - 2 * offset); | |||
@@ -216,7 +280,7 @@ package body ui is | |||
core.write (core.read_text_box, x, y, font (active)); | |||
-- | |||
select_text_box ("", x, y, width, height); | |||
end draw_text_box; | |||
end draw_help_box; | |||
------------------------------------------------------------------------------------------ | |||
@@ -360,10 +424,12 @@ package body ui is | |||
------------------------------------------------------------------------------------------ | |||
procedure write (text : in string; x, y : in integer) is | |||
procedure add_structure (data : in structure) is | |||
begin | |||
core.write (text, x, y, font (active)); | |||
end write; | |||
structure_array (structure_count) := data; | |||
-- | |||
structure_count := structure_count + 1; | |||
end add_structure; | |||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | |||
@@ -13,6 +13,30 @@ package ui is | |||
fairy, dwarf, gnoll, kobold, goblin, imp | |||
); | |||
type enumeration is ( | |||
gui_button, gui_line, gui_text, gui_icon, gui_sprite, gui_list | |||
); | |||
------------------------------------------------------------------------------------------ | |||
--~type gui_data is record | |||
--~text : string; | |||
--~number : integer; | |||
--~image : core.sprite; | |||
--~end record; | |||
type structure is record | |||
title : core.short_string := "- "; | |||
toggle : core.signal_code := core.signal_space; | |||
show : boolean := false; | |||
center : boolean := false; | |||
resize : boolean := false; | |||
x : integer := 0; | |||
y : integer := 0; | |||
width : integer := 0; | |||
height : integer := 0; | |||
end record; | |||
------------------------------------------------------------------------------------------ | |||
active : style := main; | |||
@@ -20,11 +44,16 @@ package ui is | |||
------------------------------------------------------------------------------------------ | |||
procedure configure; | |||
procedure synchronize; | |||
procedure write (text : in string; x, y : in integer); | |||
procedure draw_icon (data : in core.sprite; description : in string; x, y : in integer; action : core.pointer := core.idle'access); | |||
procedure draw_overicon (data : in core.sprite; description : in string; x, y : in integer; action : core.pointer := core.idle'access); | |||
procedure draw_text_box (x, y, width, height : in integer; action : core.pointer := core.idle'access); | |||
procedure draw_text_box (text : in string); | |||
procedure draw_help_box (x, y, width, height : in integer; action : core.pointer := core.idle'access); | |||
procedure draw_frame (description : in string; x, y, width, height : in integer; action : core.pointer := core.idle'access); | |||
@@ -38,7 +67,7 @@ package ui is | |||
procedure draw_state_box (x, y : in integer); | |||
procedure write (text : in string; x, y : in integer); | |||
procedure add_structure (data : in structure); | |||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | |||