Refactoring main procedure...

This commit is contained in:
Ognjen Milan Robovic 2024-06-14 05:00:54 -04:00
parent a1a7bf6024
commit a4bd20b015
3 changed files with 113 additions and 113 deletions

View File

@ -138,117 +138,6 @@ procedure main is
------------------------------------------------------------------------------------------
procedure player_information (x, y : in integer) is
player_1 : chad.information renames world.map.chads (1);
--
offset : constant integer := 8;
width : constant integer := side_panel - 2 * core.icon;
height : constant integer := chad.view_height + 11 * core.icon + 4 * core.base + 2 * offset;
side : constant integer := chad.view_width + attribute.count * core.icon;
at_x : integer := x + offset;
at_y : integer := y + offset;
begin
world.review_chad_data := player_1.index;
--
ui.draw_frame (x, y, width, height);
ui.draw_sprite (chad.view (player_1.index), chad.description (player_1.index).name.all, at_x, at_y, 0, world.review_chad'access);
ui.draw_text_box (at_x + chad.view_width, at_y, width - chad.view_width - 2 * offset, core.icon);
ui.write (chad.description (player_1.index).name.all, at_x + chad.view_width + core.less, at_y + core.less);
--
ui.draw_text (chad.description (player_1.index).title.all, at_x + side, at_y + 1 * core.icon, width - side - 2 * offset, core.icon, core.more);
ui.draw_text ("Level" & player_1.level'image, at_x + side, at_y + 2 * core.icon, width - side - 2 * offset, core.icon, core.more);
--
at_x := x + chad.view_width + offset;
at_y := y + core.icon + offset;
--
for index in attribute.enumeration loop
ui.draw_icon (attribute.icon (index), attribute.description (index).text.all, at_x, at_y);
ui.draw_text (player_1.attributes (index).value'image, at_x, at_y + core.icon, core.icon, core.icon, core.more);
--
at_x := at_x + core.icon;
end loop;
--
at_x := x + offset;
at_y := y + offset + chad.view_height;
--
ui.draw_separator (at_x, at_y, width - 2 * offset);
--
at_y := at_y + core.base + core.icon;
--
ui.draw_tiny_fill_bar (at_x, at_y + 0 * core.icon, side, float (player_1.health.value) / float (player_1.health.limit), (127, 0, 0, 255));
ui.draw_tiny_fill_bar (at_x, at_y + 1 * core.icon, side, float (player_1.mana.value) / float (player_1.mana.limit), (0, 0, 127, 255));
ui.draw_tiny_fill_bar (at_x, at_y + 2 * core.icon, side, float (player_1.stamina.value) / float (player_1.stamina.limit), (0, 127, 0, 255));
--
ui.draw_text ("Health", at_x + side, at_y - core.icon, width - side - 2 * offset, core.icon, core.more);
ui.draw_text ("Mana", at_x + side, at_y, width - side - 2 * offset, core.icon, core.more);
ui.draw_text ("Movement", at_x + side, at_y + core.icon, width - side - 2 * offset, core.icon, core.more);
--
ui.write (player_1.health.value'image & " /" & player_1.health.limit'image, at_x + core.icon, at_y - core.icon + core.more, code => true);
ui.write (player_1.mana.value'image & " /" & player_1.mana.limit'image, at_x + core.icon, at_y + core.more, code => true);
ui.write (player_1.stamina.value'image & " /" & player_1.stamina.limit'image, at_x + core.icon, at_y + core.icon + core.more, code => true);
--
at_y := at_y + 2 * core.icon;
--
ui.draw_separator (at_x, at_y, width - 2 * offset);
--
at_y := at_y + core.base;
--
for index in equipment.kind loop
if world.equipment_valid (player_1.equipments (index)) then
ui.draw_overicon (data => equipment.icon (player_1.equipments (index)),
text => equipment.description (player_1.equipments (index)).name.all,
x => at_x + equipment.kind'pos (index) * core.icon,
y => at_y);
else
ui.draw_overicon (data => equipment.slot (index),
text => "Slot '" & core.lowercase (equipment.kind (index)'image) & "' is empty.",
x => at_x + equipment.kind'pos (index) * core.icon,
y => at_y);
end if;
end loop;
--
ui.draw_text ("Equipment", at_x + 8 * core.icon, at_y, width - 8 * core.icon - 2 * offset, core.icon, core.more);
--
at_y := at_y + core.icon;
--
ui.draw_text ("Skills", at_x + side, at_y, width - side - 2 * offset, core.icon, core.more);
--
for index in 0 .. skill.limit - 1 loop
ui.draw_icon (skill.icon (player_1.skills (index).index), skill.description (player_1.skills (index).index).text.all, at_x + index * core.icon, at_y);
--~ui.write (player_1.points (index).value'image, at_x + index * core.icon + core.more, at_y + core.more, code => true);
end loop;
--
at_y := at_y + core.icon;
--
ui.draw_separator (at_x, at_y, width - 2 * offset);
--
at_y := at_y + core.base;
--
for index_y in 0 .. 2 loop
for index_x in 0 .. 7 loop
ui.draw_icon (data => equipment.icon (player_1.items (8 * index_y + index_x)),
text => equipment.description (player_1.items (8 * index_y + index_x)).name.all,
x => at_x + index_x * core.icon,
y => at_y + index_y * core.icon);
end loop;
end loop;
--
at_y := at_y + 3 * core.icon;
--
ui.draw_separator (at_x, at_y, width - 2 * offset);
--
at_y := at_y + core.base;
--
for index in 0 .. 7 loop
--~world.review_unit_data := player_1.units (index).index;
ui.draw_icon_menu (at_x + index * core.icon, at_y, core.icon, 3 * core.icon, "--");
--~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.review_unit'access);
--~world.draw_unit (player_1.units (index).index, core.walk, at_x + index * core.icon + 8, at_y + 8, 1);
end loop;
end player_information;
------------------------------------------------------------------------------------------
procedure time_information (x, y : in integer) is
offset : constant integer := 8;
width : constant integer := side_panel - 2 * core.icon;
@ -377,8 +266,8 @@ begin
if view_list (status_preview_panel) then
ui.draw_tiny_menu (preview_width, 0, side_panel, preview_height);
--
player_information (preview_width + core.icon, core.icon);
time_information (preview_width + core.icon, core.icon + chad.view_height + 11 * core.icon + 4 * core.base + 3 * 8);
world.view_chad_information (world.map.chads (1), preview_width + core.icon, core.icon, side_panel);
--~time_information (preview_width + core.icon, core.icon + chad.view_height + 11 * core.icon + 4 * core.base + 3 * 8);
--
ui.draw_console_box (x => core.window_width - core.icon - (side_panel - 2 * core.icon),
y => core.window_height - core.icon - text_box_height - 106,

View File

@ -487,6 +487,115 @@ package body world is
------------------------------------------------------------------------------------------
procedure view_chad_information (data : in chad.information; x, y, limit : in integer) is
offset : constant integer := 8;
width : constant integer := limit - 2 * core.icon;
height : constant integer := chad.view_height + 11 * core.icon + 4 * core.base + 2 * offset;
side : constant integer := chad.view_width + attribute.count * core.icon;
at_x : integer := x + offset;
at_y : integer := y + offset;
begin
world.review_chad_data := data.index;
--
ui.draw_frame (x, y, width, height);
ui.draw_sprite (chad.view (data.index), chad.description (data.index).name.all, at_x, at_y, 0, world.review_chad'access);
ui.draw_text_box (at_x + chad.view_width, at_y, width - chad.view_width - 2 * offset, core.icon);
ui.write (chad.description (data.index).name.all, at_x + chad.view_width + core.less, at_y + core.less);
--
ui.draw_text (chad.description (data.index).title.all, at_x + side, at_y + 1 * core.icon, width - side - 2 * offset, core.icon, core.more);
ui.draw_text ("Level" & data.level'image, at_x + side, at_y + 2 * core.icon, width - side - 2 * offset, core.icon, core.more);
--
at_x := x + chad.view_width + offset;
at_y := y + core.icon + offset;
--
for index in attribute.enumeration loop
ui.draw_icon (attribute.icon (index), attribute.description (index).text.all, at_x, at_y);
ui.draw_text (data.attributes (index).value'image, at_x, at_y + core.icon, core.icon, core.icon, core.more);
--
at_x := at_x + core.icon;
end loop;
--
at_x := x + offset;
at_y := y + offset + chad.view_height;
--
ui.draw_separator (at_x, at_y, width - 2 * offset);
--
at_y := at_y + core.base + core.icon;
--
ui.draw_tiny_fill_bar (at_x, at_y + 0 * core.icon, side, float (data.health.value) / float (data.health.limit), (127, 0, 0, 255));
ui.draw_tiny_fill_bar (at_x, at_y + 1 * core.icon, side, float (data.mana.value) / float (data.mana.limit), (0, 0, 127, 255));
ui.draw_tiny_fill_bar (at_x, at_y + 2 * core.icon, side, float (data.stamina.value) / float (data.stamina.limit), (0, 127, 0, 255));
--
ui.draw_text ("Health", at_x + side, at_y - core.icon, width - side - 2 * offset, core.icon, core.more);
ui.draw_text ("Mana", at_x + side, at_y, width - side - 2 * offset, core.icon, core.more);
ui.draw_text ("Movement", at_x + side, at_y + core.icon, width - side - 2 * offset, core.icon, core.more);
--
ui.write (data.health.value'image & " /" & data.health.limit'image, at_x + core.icon, at_y - core.icon + core.more, code => true);
ui.write (data.mana.value'image & " /" & data.mana.limit'image, at_x + core.icon, at_y + core.more, code => true);
ui.write (data.stamina.value'image & " /" & data.stamina.limit'image, at_x + core.icon, at_y + core.icon + core.more, code => true);
--
at_y := at_y + 2 * core.icon;
--
ui.draw_separator (at_x, at_y, width - 2 * offset);
--
at_y := at_y + core.base;
--
for index in equipment.kind loop
if world.equipment_valid (data.equipments (index)) then
ui.draw_overicon (data => equipment.icon (data.equipments (index)),
text => equipment.description (data.equipments (index)).name.all,
x => at_x + equipment.kind'pos (index) * core.icon,
y => at_y);
else
ui.draw_overicon (data => equipment.slot (index),
text => "Slot '" & core.lowercase (equipment.kind (index)'image) & "' is empty.",
x => at_x + equipment.kind'pos (index) * core.icon,
y => at_y);
end if;
end loop;
--
ui.draw_text ("Equipment", at_x + 8 * core.icon, at_y, width - 8 * core.icon - 2 * offset, core.icon, core.more);
--
at_y := at_y + core.icon;
--
ui.draw_text ("Skills", at_x + side, at_y, width - side - 2 * offset, core.icon, core.more);
--
for index in 0 .. skill.limit - 1 loop
ui.draw_icon (skill.icon (data.skills (index).index), skill.description (data.skills (index).index).text.all, at_x + index * core.icon, at_y);
--~ui.write (data.points (index).value'image, at_x + index * core.icon + core.more, at_y + core.more, code => true);
end loop;
--
at_y := at_y + core.icon;
--
ui.draw_separator (at_x, at_y, width - 2 * offset);
--
at_y := at_y + core.base;
--
for index_y in 0 .. 2 loop
for index_x in 0 .. 7 loop
ui.draw_icon (data => equipment.icon (data.items (8 * index_y + index_x)),
text => equipment.description (data.items (8 * index_y + index_x)).name.all,
x => at_x + index_x * core.icon,
y => at_y + index_y * core.icon);
end loop;
end loop;
--
at_y := at_y + 3 * core.icon;
--
ui.draw_separator (at_x, at_y, width - 2 * offset);
--
at_y := at_y + core.base;
--
for index in 0 .. 7 loop
--~world.review_unit_data := data.units (index).index;
ui.draw_icon_menu (at_x + index * core.icon, at_y, core.icon, 3 * core.icon, "--");
--~ui.draw_icon_menu (at_x + index * core.icon, at_y, core.icon, 3 * core.icon, unit.description (data.units (index).index).name.all, world.review_unit'access);
--~world.draw_unit (data.units (index).index, core.walk, at_x + index * core.icon + 8, at_y + 8, 1);
end loop;
end view_chad_information;
------------------------------------------------------------------------------------------
procedure make (index : in biome.enumeration; width, height, landmark_limit, location_limit, construction_limit, equipment_limit, unit_limit, chad_limit : in natural) is
begin
core.echo (core.comment, "-- Procedurally generating new map...");

View File

@ -72,6 +72,8 @@ package world is
procedure review_unit;
procedure review_chad;
procedure view_chad_information (data : in chad.information; x, y, limit : in integer);
procedure make (index : in biome.enumeration; width, height, landmark_limit, location_limit, construction_limit, equipment_limit, unit_limit, chad_limit : in natural);
procedure save (file_name : in string);