Refactoring yet again...

This commit is contained in:
Ognjen Milan Robovic 2024-06-14 14:28:37 -04:00
parent 4d36dcb5da
commit b2b79513b3
2 changed files with 31 additions and 39 deletions

View File

@ -96,13 +96,13 @@ procedure main is
--~new string'(core.folder & "/source/world.ads") --~new string'(core.folder & "/source/world.ads")
--~); --~);
side_panel : integer := 0; side_panel : integer := 0;
preview_width : integer := 0; text_box_height : integer := 0;
preview_height : integer := 0; map_frame_width : integer := 0;
text_box_height : integer := 0; map_frame_height : integer := 0;
player : chad.information := ( player : chad.information := (
skills => ((skill.archery, 1, 3), (skill.athletics, 1, 3), (skill.tactics, 1, 3), others => <>), skills => ((skill.archery, 1, 3), (skill.athletics, 3, 3), (skill.tactics, 1, 3), (skill.eremnokinesis, 2, 3), others => <>),
-- --
equipments => (equipment.chest => equipment.crystal_chestplate, equipments => (equipment.chest => equipment.crystal_chestplate,
equipment.head => equipment.crystal_helmet, equipment.head => equipment.crystal_helmet,
@ -241,7 +241,7 @@ begin
world.insert_chad (player); world.insert_chad (player);
world.insert_chad (opponent); world.insert_chad (opponent);
world.load ("heyo"); --~world.load ("heyo");
ui.active := ui.style'val (faction.enumeration'pos (chad.description (player.index).kind) + 1); ui.active := ui.style'val (faction.enumeration'pos (chad.description (player.index).kind) + 1);
@ -250,26 +250,21 @@ begin
-- --
exit when core.engine_active = false; exit when core.engine_active = false;
-- --
if not view_list (status_preview_panel) then side_panel := (if view_list (status_preview_panel) then 480 else 0);
side_panel := 0; text_box_height := core.icon;
else map_frame_width := core.window_width - side_panel;
side_panel := 480; map_frame_height := core.window_height - text_box_height;
end if;
--
preview_width := core.window_width - side_panel;
preview_height := core.window_height - text_box_height;
text_box_height := 32;
-- --
world.draw; world.draw;
-- --
if view_list (map_preview_panel) then if view_list (map_preview_panel) then
ui.draw_menu (0, 0, preview_width, preview_height); ui.draw_menu (0, 0, map_frame_width, map_frame_height);
end if; end if;
-- --
if view_list (status_preview_panel) then if view_list (status_preview_panel) then
ui.draw_tiny_menu (preview_width, 0, side_panel, preview_height); ui.draw_tiny_menu (map_frame_width, 0, side_panel, map_frame_height);
-- --
world.view_chad_information (world.map.chads (1), preview_width + core.icon, core.icon, side_panel - 2 * core.icon); world.view_chad_information (world.map.chads (1), map_frame_width + core.icon, core.icon, side_panel - 2 * core.icon);
-- --
ui.draw_console_box (x => core.window_width - core.icon - (side_panel - 2 * core.icon), 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, y => core.window_height - core.icon - text_box_height - 106,
@ -293,12 +288,12 @@ begin
-- --
for index in resource.enumeration loop for index in resource.enumeration loop
ui.draw_icon (resource.icon (index), resource.description (index).text.all, ui.draw_icon (resource.icon (index), resource.description (index).text.all,
(preview_width - 5 * core.icon * resource.count) / 2 + (5 * core.icon) * resource.enumeration'pos (index), core.base); (map_frame_width - 5 * core.icon * resource.count) / 2 + (5 * core.icon) * resource.enumeration'pos (index), core.base);
ui.draw_text (world.map.chads (1).resources (index).value'image & " /" & world.map.chads (1).resources (index).limit'image, ui.draw_text (world.map.chads (1).resources (index).value'image & " /" & world.map.chads (1).resources (index).limit'image,
(preview_width - 5 * core.icon * resource.count) / 2 + (5 * core.icon) * resource.enumeration'pos (index) + core.icon, core.base, 4 * core.icon, core.icon, 10); (map_frame_width - 5 * core.icon * resource.count) / 2 + (5 * core.icon) * resource.enumeration'pos (index) + core.icon, core.base, 4 * core.icon, core.icon, 10);
end loop; end loop;
-- --
--~declare move_x : integer := (preview_width - core.icon * material.count) / 2; --~declare move_x : integer := (map_frame_width - core.icon * material.count) / 2;
--~begin --~begin
--~for index in material.enumeration loop --~for index in material.enumeration loop
--~if world.map.chads (1).materials (index).value > 0 then --~if world.map.chads (1).materials (index).value > 0 then

View File

@ -495,7 +495,7 @@ package body world is
procedure view_chad_information (data : in chad.information; x, y, width : in integer) is procedure view_chad_information (data : in chad.information; x, y, width : in integer) is
offset : constant integer := 8; offset : constant integer := 8;
height : constant integer := chad.view_height + 12 * core.icon + 3 * core.base + 2 * offset; height : constant integer := chad.view_height + 12 * core.icon + 4 * core.base + 2 * offset;
-- --
orient : core.vector := (0, 0); orient : core.vector := (0, 0);
begin begin
@ -506,9 +506,10 @@ package body world is
orient := orient + view_chad_points (data, x + offset, y + offset + orient.y + 1 * core.base, width - 2 * offset); orient := orient + view_chad_points (data, x + offset, y + offset + orient.y + 1 * core.base, width - 2 * offset);
ui.draw_separator ( x + offset, y + offset + orient.y + 1 * core.base, width - 2 * offset); ui.draw_separator ( x + offset, y + offset + orient.y + 1 * core.base, width - 2 * offset);
orient := orient + view_chad_equipment (data, x + offset, y + offset + orient.y + 2 * core.base, width - 2 * offset); orient := orient + view_chad_equipment (data, x + offset, y + offset + orient.y + 2 * core.base, width - 2 * offset);
orient := orient + view_chad_skills (data, x + offset, y + offset + orient.y + 2 * core.base, width - 2 * offset);
ui.draw_separator ( x + offset, y + offset + orient.y + 2 * core.base, width - 2 * offset); ui.draw_separator ( x + offset, y + offset + orient.y + 2 * core.base, width - 2 * offset);
orient := orient + view_chad_inventory (data, x + offset, y + offset + orient.y + 3 * core.base, width - 2 * offset); orient := orient + view_chad_skills (data, x + offset, y + offset + orient.y + 3 * core.base, width - 2 * offset);
ui.draw_separator ( x + offset, y + offset + orient.y + 3 * core.base, width - 2 * offset);
orient := orient + view_chad_inventory (data, x + offset, y + offset + orient.y + 4 * core.base, width - 2 * offset);
end view_chad_information; end view_chad_information;
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
@ -1138,6 +1139,7 @@ package body world is
function view_chad_basics (data : in chad.information; x, y, width : in integer) return core.vector is function view_chad_basics (data : in chad.information; x, y, width : in integer) return core.vector is
side : constant integer := chad.view_width + attribute.count * core.icon; side : constant integer := chad.view_width + attribute.count * core.icon;
skip : integer := 0;
begin begin
ui.draw_sprite (chad.view (data.index), chad.description (data.index).name.all, x, y, 0, review_chad'access); ui.draw_sprite (chad.view (data.index), chad.description (data.index).name.all, x, y, 0, review_chad'access);
-- --
@ -1148,8 +1150,10 @@ package body world is
ui.draw_text ("Level" & data.level'image, x + side, y + 2 * core.icon, width - side, core.icon, core.more); ui.draw_text ("Level" & data.level'image, x + side, y + 2 * core.icon, width - side, core.icon, core.more);
-- --
for index in attribute.enumeration loop for index in attribute.enumeration loop
ui.draw_icon (attribute.icon (index), attribute.description (index).text.all, x + chad.view_width + attribute.enumeration'pos (index) * core.icon, y + core.icon); ui.draw_icon (attribute.icon (index), attribute.description (index).text.all, x + chad.view_width + skip, y + core.icon);
ui.draw_text (data.attributes (index).value'image, x + attribute.enumeration'pos (index) * core.icon + chad.view_width, y + 2 * core.icon, core.icon, core.icon, core.more); ui.draw_text (data.attributes (index).value'image, x + chad.view_width + skip, y + 2 * core.icon, core.icon, core.icon, core.more);
--
skip := skip + core.icon;
end loop; end loop;
-- --
return (width, chad.view_height); return (width, chad.view_height);
@ -1174,20 +1178,13 @@ package body world is
function view_chad_skills (data : in chad.information; x, y, width : in integer) return core.vector is function view_chad_skills (data : in chad.information; x, y, width : in integer) return core.vector is
count : constant natural := skill.limit'last + 1; count : constant natural := skill.limit'last + 1;
limit : constant natural := width / 2;
begin begin
for index in skill.limit loop for index in skill.limit loop
ui.draw_icon (data => skill.icon (data.skills (index).index), ui.draw_icon_and_text (data => skill.icon (data.skills (index).index),
text => skill.description (data.skills (index).index).text.all, text => skill.description (data.skills (index).index).name.all & data.skills (index).value'image,
x => x + (index mod 2) * limit, x => x + (index mod 2) * (width / 2),
y => y + (index / 2) * core.icon); y => y + (index / 2) * core.icon,
-- width => width / 2);
ui.draw_text (text => skill.description (data.skills (index).index).name.all & data.skills (index).value'image,
x => x + (index mod 2) * limit + core.icon,
y => y + (index / 2) * core.icon,
width => limit - core.icon,
height => core.icon,
offset => core.more);
end loop; end loop;
-- --
return (width, (count / 2) * core.icon); return (width, (count / 2) * core.icon);
@ -1216,7 +1213,7 @@ package body world is
begin begin
for index_y in 0 .. 3 loop for index_y in 0 .. 3 loop
for index_x in 0 .. 7 loop for index_x in 0 .. 7 loop
ui.draw_icon (data => material.icon (data.materials (8 * index_y + index_x).index), ui.draw_icon (data => material.icon (data.materials (8 * index_y + index_x).index),
text => material.description (data.materials (8 * index_y + index_x).index).name.all, text => material.description (data.materials (8 * index_y + index_x).index).name.all,
x => x + index_x * core.icon, x => x + index_x * core.icon,
y => y + index_y * core.icon); y => y + index_y * core.icon);