Saving changes before major refactoring...

This commit is contained in:
Ognjen Milan Robovic 2024-06-09 16:53:27 -04:00
parent 52313927d1
commit 83373bbda1
6 changed files with 54 additions and 22 deletions

View File

@ -57,6 +57,7 @@ package equipment is
------------------------------------------------------------------------------------------
count : constant natural := enumeration'pos (enumeration'last) + 1;
error : constant natural := enumeration'pos (none);
default : constant equip_array := (others => none);

View File

@ -233,7 +233,7 @@ procedure main is
at_y := at_y + core.base;
--
for index in 0 .. unit.limit - 1 loop
world.draw_unit (player_1.units (index).index, core.walk, at_x + index * core.icon + 8, at_y + 8);
world.draw_unit (player_1.units (index).index, core.walk, at_x + index * core.icon + 8, at_y + 8, 1);
world.show_unit_data := player_1.units (index).index;
ui.draw_icon_menu (at_x + index * core.icon, at_y, core.icon, 3 * core.icon, unit.description (player_1.units (index).index).name.all, world.show_unit'access);
end loop;

View File

@ -181,6 +181,25 @@ package body ui is
------------------------------------------------------------------------------------------
procedure draw_icon_and_text (data : in core.sprite; text : in string; x, y, width : in integer; action : core.pointer := core.idle_skip'access) is
begin
draw_icon_menu (x, y, width, core.icon);
--
core.draw (data, x, y, factor => 1);
write (text, x + core.icon + 10, y + 10, code => true);
--
if core.cursor_inside (x, y, core.icon / core.zoom, core.icon / core.zoom) then
prioritize := true;
--
if core.cursor_mode = core.cursor_left then
action.all;
core.cursor_mode := core.cursor_none;
end if;
end if;
end draw_icon_and_text;
------------------------------------------------------------------------------------------
procedure draw_overicon (data : in core.sprite; text : in string; x, y : in integer; action : core.pointer := core.idle_skip'access) is
begin
core.draw (data, x, y, factor => 1);

View File

@ -36,8 +36,9 @@ package ui is
procedure draw_separator (x, y, width : in integer);
procedure draw_icon (data : in core.sprite; text : in string; x, y : in integer; action : core.pointer := core.idle_skip'access);
procedure draw_overicon (data : in core.sprite; text : in string; x, y : in integer; action : core.pointer := core.idle_skip'access);
procedure draw_icon (data : in core.sprite; text : in string; x, y : in integer; action : core.pointer := core.idle_skip'access);
procedure draw_icon_and_text (data : in core.sprite; text : in string; x, y, width : in integer; action : core.pointer := core.idle_skip'access);
procedure draw_overicon (data : in core.sprite; text : in string; x, y : in integer; action : core.pointer := core.idle_skip'access);
procedure draw_sprite (data : in core.sprite; text : in string; x, y, offset : in integer; action : core.pointer := core.idle_skip'access);

View File

@ -123,6 +123,13 @@ package body world is
------------------------------------------------------------------------------------------
function equipment_valid (data : in equipment.enumeration) return boolean is
begin
return equipment.enumeration'pos (data) /= equipment.error;
end equipment_valid;
------------------------------------------------------------------------------------------
procedure make (index : in biome; width, height, chad_limit : in natural) is
begin
core.echo (core.comment, "-- Procedurally generating new map...");
@ -1031,12 +1038,12 @@ package body world is
------------------------------------------------------------------------------------------
procedure draw_unit (data : in unit.enumeration; state : in core.animation; x, y : in integer) is
procedure draw_unit (data : in unit.enumeration; state : in core.animation; x, y, factor : in integer) is
begin
core.draw (unit.base (unit.description (data).kind), x, y, state => state);
core.draw (unit.base (unit.description (data).kind), x, y, state => state, factor => factor);
--
for kind in equipment.kind loop
core.draw (equipment.sprite (unit.description (data).equipments (kind)), x, y, state => state);
core.draw (equipment.sprite (unit.description (data).equipments (kind)), x, y, state => state, factor => factor);
end loop;
end draw_unit;
@ -1068,9 +1075,7 @@ package body world is
at_x := core.center_x (width) + offset + unit.view_width;
end if;
--
ui.draw_icon_menu (at_x, at_y, core.icon * 3, core.icon, attribute.description (index).text.all);
core.draw (attribute.icon (index), at_x, at_y, factor => 1);
ui.write (data.attributes (index)'image, at_x + core.icon + more, at_y + more, code => true);
ui.draw_icon_and_text (attribute.icon (index), data.attributes (index)'image, at_x, at_y, 3 * core.icon);
--
at_x := at_x + 3 * core.icon;
end loop;
@ -1103,14 +1108,19 @@ package body world is
at_x := core.center_x (width) + offset;
end if;
--
ui.draw_icon_menu (at_x, at_y, (width - 2 * offset) / 2, core.icon, equipment.description (data.equipments (index)).name.all);
ui.write (equipment.description (data.equipments (index)).name.all, at_x + core.icon + more, at_y + more, code => true);
--
if equipment.enumeration'pos (data.equipments (index)) /= equipment.enumeration'pos (equipment.none) then
core.draw (equipment.icon (data.equipments (index)), at_x, at_y, factor => 1);
else
core.draw (equipment.slot (index), at_x, at_y, factor => 1);
end if;
ui.draw_icon_and_text (data => (if equipment_valid (data.equipments (index)) then equipment.icon (data.equipments (index)) else equipment.slot (index)),
text => equipment.description (data.equipments (index)).name.all,
x => at_x,
y => at_y,
width => (width - 2 * offset) / 2);
--~ui.draw_icon_menu (at_x, at_y, (width - 2 * offset) / 2, core.icon, equipment.description (data.equipments (index)).name.all);
--~ui.write (equipment.description (data.equipments (index)).name.all, at_x + core.icon + more, at_y + more, code => true);
--~--
--~if equipment.enumeration'pos (data.equipments (index)) /= equipment.enumeration'pos (equipment.none) then
--~core.draw (equipment.icon (data.equipments (index)), at_x, at_y, factor => 1);
--~else
--~core.draw (equipment.slot (index), at_x, at_y, factor => 1);
--~end if;
--
at_x := at_x + (width - 2 * offset) / 2;
end loop;
@ -1127,10 +1137,11 @@ package body world is
if map.views (map.units (index).x, map.units (index).y)
and map.units (index).x > view_from.x and map.units (index).x < view_from.x + view_to.x
and map.units (index).y > view_from.y and map.units (index).y < view_from.y + view_to.y then
draw_unit (data => unit.enumeration'val (map.units (index).index),
state => core.animation'val (map.units (index).state),
x => offset.x + (map.units (index).x - core.camera.x) * core.base * core.zoom,
y => offset.y + (map.units (index).y - core.camera.y) * core.base * core.zoom);
draw_unit (data => unit.enumeration'val (map.units (index).index),
state => core.animation'val (map.units (index).state),
x => offset.x + (map.units (index).x - core.camera.x) * core.base * core.zoom,
y => offset.y + (map.units (index).y - core.camera.y) * core.base * core.zoom,
factor => core.zoom);
--
core.increment (drawn_units);
end if;

View File

@ -231,7 +231,7 @@ package world is
procedure add_chad (data : in chad.information);
procedure draw_unit (data : in unit.enumeration; state : in core.animation; x, y : in integer);
procedure draw_unit (data : in unit.enumeration; state : in core.animation; x, y, factor : in integer);
procedure show_unit;
procedure resource_cheat_1;