Added entity count, menu centering, refactoring...

This commit is contained in:
Ognjen Milan Robovic 2024-02-19 16:20:38 -05:00
parent 603a5025fe
commit 2172a630b1
15 changed files with 52 additions and 32 deletions

View File

@ -25,6 +25,8 @@ package attribute is
icon : sprite_array; icon : sprite_array;
count : constant natural := codex'pos (codex'last) + 1;
trait : constant trait_array := ( trait : constant trait_array := (
("Attack ", 0), ("Attack ", 0),
("Defense ", 0), ("Defense ", 0),

View File

@ -58,6 +58,8 @@ package construction is
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
count : constant natural := codex'pos (codex'last) + 1;
trait : constant trait_array := ( trait : constant trait_array := (
-- Remove me later... Lv Gr Gold Wd Mr Or Sl Cr Gm -- Remove me later... Lv Gr Gold Wd Mr Or Sl Cr Gm
("Boar Glen ", faction.neutral, 1, 1, ( 90, 0, 0, 0, 0, 0, 0), 1, effect.none, menu.none), ("Boar Glen ", faction.neutral, 1, 1, ( 90, 0, 0, 0, 0, 0, 0), 1, effect.none, menu.none),

View File

@ -211,17 +211,11 @@ package body core is
loop loop
line ((x, offset_y + horizontal * base), (width, 0)); line ((x, offset_y + horizontal * base), (width, 0));
-- --
for vertical in 0 .. width / base for vertical in 0 .. width / base - 1
loop loop
line ((offset_x + vertical * base - base / 2, crop_offset + 2 * base * (horizontal / 2) + base), (0, base)); line ((offset_x + vertical * base - base / 2, crop_offset + 2 * base * (horizontal / 2) + base), (0, base));
line ((offset_x + vertical * base, crop_offset + 2 * base * (horizontal / 2)), (0, base));
end loop; end loop;
--
if horizontal > 1 then
for vertical in 0 .. width / base - 1
loop
line ((offset_x + vertical * base, crop_offset + 2 * base * (horizontal / 2)), (0, base));
end loop;
end if;
end loop; end loop;
-- --
for vertical in 0 .. width / base - 1 for vertical in 0 .. width / base - 1

View File

@ -23,6 +23,8 @@ package deity is
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
count : constant natural := codex'pos (codex'last) + 1;
trait : constant trait_array := ( trait : constant trait_array := (
("Svarog the Lawful ", 3), -- Serbia ("Svarog the Lawful ", 3), -- Serbia
("Dabog the Lonely ", -3), ("Dabog the Lonely ", -3),

View File

@ -20,6 +20,8 @@ package effect is
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
count : constant natural := codex'pos (codex'last) + 1;
trait : constant trait_array := ( trait : constant trait_array := (
("- ", true), ("- ", true),
("- ", true) ("- ", true)

View File

@ -23,6 +23,8 @@ package faction is
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
count : constant natural := codex'pos (codex'last) + 1;
trait : constant trait_array := ( trait : constant trait_array := (
("Neutral ", attribute.attack, skill.tactics, resource.gold), ("Neutral ", attribute.attack, skill.tactics, resource.gold),
("Castle ", attribute.attack, skill.archery, resource.ore), ("Castle ", attribute.attack, skill.archery, resource.ore),

View File

@ -51,6 +51,8 @@ package item is
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
count : constant natural := codex'pos (codex'last) + 1;
trait : constant trait_array := ( trait : constant trait_array := (
("Admiral's Hat ", head, 0, effect.none), ("Admiral's Hat ", head, 0, effect.none),
("Ambassador's Sash ", full_body, 0, effect.none), ("Ambassador's Sash ", full_body, 0, effect.none),

View File

@ -51,6 +51,8 @@ package magic is
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
count : constant natural := codex'pos (codex'last) + 1;
trait : constant trait_array := ( trait : constant trait_array := (
("Magic Arrow ", neutral, 0, effect.none), ("Magic Arrow ", neutral, 0, effect.none),
("Chain Magic Arrow ", neutral, 0, effect.none), ("Chain Magic Arrow ", neutral, 0, effect.none),

View File

@ -90,8 +90,8 @@ begin
--~construction.draw (this, 128 * (construction.codex'pos (this) mod 12) + 32, 128 * (construction.codex'pos (this) / 12) + 32); --~construction.draw (this, 128 * (construction.codex'pos (this) mod 12) + 32, 128 * (construction.codex'pos (this) / 12) + 32);
--~end loop; --~end loop;
-- --
core.draw_central_grid (preview_x, preview_y, preview_width - 2 * preview_x, preview_height - 2 * preview_y); --~core.draw_central_grid (preview_x, preview_y, preview_width - 2 * preview_x, preview_height - 2 * preview_y);
core.draw_squared_grid (preview_x, preview_y, preview_width - 2 * preview_x, preview_height - 2 * preview_y); --~core.draw_squared_grid (preview_x, preview_y, preview_width - 2 * preview_x, preview_height - 2 * preview_y);
-- --
ui.draw_menu (0, 0, preview_width, preview_height, false); ui.draw_menu (0, 0, preview_width, preview_height, false);
ui.draw_tiny_menu (preview_width, 0, side_panel, preview_height, true); ui.draw_tiny_menu (preview_width, 0, side_panel, preview_height, true);
@ -111,8 +111,9 @@ begin
-- --
core.draw_state_box (preview_width + 32, 32); core.draw_state_box (preview_width + 32, 32);
-- --
menu.draw (menu.attribute_information, 100, 100); menu.draw (menu.resource_information, 420, 100, false);
menu.draw (menu.resource_information, 600, 100); menu.draw (menu.skill_information, 740, 100, false);
menu.draw (menu.attribute_information, 100, 100, true);
end loop gameplay; end loop gameplay;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -12,53 +12,56 @@ package body menu is
trait (skill_information).title := "Skill Information "; trait (skill_information).title := "Skill Information ";
trait (resource_information).title := "Resource Information "; trait (resource_information).title := "Resource Information ";
-- --
trait (attribute_information).elements := new element_array (0 .. attribute.codex'pos (attribute.codex'last)); trait (attribute_information).elements := new element_array (0 .. attribute.count - 1);
trait (skill_information).elements := new element_array (0 .. skill.codex'pos (skill.codex'last)); trait (skill_information).elements := new element_array (0 .. skill.count - 1);
trait (resource_information).elements := new element_array (0 .. resource.codex'pos (resource.codex'last)); trait (resource_information).elements := new element_array (0 .. resource.count - 1);
-- --
trait (attribute_information).length := attribute.codex'pos (attribute.codex'last) + 1; trait (attribute_information).length := attribute.count;
trait (skill_information).length := skill.codex'pos (skill.codex'last) + 1; trait (skill_information).length := skill.count;
trait (resource_information).length := resource.codex'pos (resource.codex'last) + 1; trait (resource_information).length := resource.count;
-- --
for index in 0 .. attribute.codex'pos (attribute.codex'last) for index in attribute.codex
loop loop
trait (attribute_information).elements (index) := (button, index, attribute.trait (attribute.codex'val (index)).name, attribute.icon (attribute.codex'val (index))); trait (attribute_information).elements (attribute.codex'pos (index)) := (button, 0, attribute.trait (index).name, attribute.icon (index));
end loop; end loop;
-- --
for index in 0 .. skill.codex'pos (skill.codex'last) for index in skill.codex
loop loop
trait (skill_information).elements (index) := (button, index, skill.trait (skill.codex'val (index)).name, skill.icon (skill.codex'val (index))); trait (skill_information).elements (skill.codex'pos (index)) := (button, 0, skill.trait (index).name, skill.icon (index));
end loop; end loop;
-- --
for index in 0 .. resource.codex'pos (resource.codex'last) for index in resource.codex
loop loop
trait (resource_information).elements (index) := (button, index, resource.trait (resource.codex'val (index)).name, resource.icon (resource.codex'val (index))); trait (resource_information).elements (resource.codex'pos (index)) := (button, 0, resource.trait (index).name, resource.icon (index));
end loop; end loop;
end configure; end configure;
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
procedure draw (index : in codex; x, y : in integer) is procedure draw (index : in codex; x, y : in integer; center : in boolean) is
draw_offset : constant integer := 16; draw_offset : constant integer := 16;
icon_offset : constant integer := 4; icon_offset : constant integer := 4;
icon_size : constant integer := 32; icon_size : constant integer := 32;
offset : constant integer := icon_size + 2 * icon_offset; offset : constant integer := icon_size + 2 * icon_offset;
width : constant integer := 300; width : constant integer := 240;
height : constant integer := trait (index).length * offset + 2 * draw_offset; height : constant integer := trait (index).length * offset + 2 * draw_offset;
--
offset_x : constant integer := (if center then (core.window_width - width) / 2 else x);
offset_y : constant integer := (if center then (core.window_height - height) / 2 else y);
begin begin
if index = none then if index = none then
return; return;
end if; end if;
-- --
ui.draw_title_bar (x, y, width, trait (index).title); ui.draw_title_bar (offset_x, offset_y, width, trait (index).title);
ui.draw_tiny_menu (x, y, width, height, true); ui.draw_tiny_menu (offset_x, offset_y, width, height, true);
-- --
for element_index in 0 .. trait (index).length - 1 for element_index in 0 .. trait (index).length - 1
loop loop
ui.draw_frame (x + draw_offset, y + draw_offset + element_index * offset, offset, offset); ui.draw_frame (offset_x + draw_offset, offset_y + draw_offset + element_index * offset, offset, offset);
-- --
core.draw (trait (index).elements (element_index).icon, x + draw_offset + icon_offset, y + draw_offset + icon_offset + element_index * offset); core.draw (trait (index).elements (element_index).icon, offset_x + draw_offset + icon_offset, offset_y + draw_offset + icon_offset + element_index * offset);
core.write (trait (index).elements (element_index).text, x + draw_offset + icon_offset + offset, y + draw_offset + icon_offset + element_index * offset); core.write (trait (index).elements (element_index).text, offset_x + draw_offset + icon_offset + offset, offset_y + draw_offset + icon_offset + element_index * offset);
end loop; end loop;
end draw; end draw;

View File

@ -41,7 +41,7 @@ package menu is
procedure configure; procedure configure;
procedure draw (index : in codex; x, y : in integer); procedure draw (index : in codex; x, y : in integer; center : in boolean);
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -50,6 +50,8 @@ package might is
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
count : constant natural := codex'pos (codex'last) + 1;
trait : constant trait_array := ( trait : constant trait_array := (
("Cover ", archery, 0, effect.none), ("Cover ", archery, 0, effect.none),
("Evasive Maneuvers ", archery, 0, effect.none), ("Evasive Maneuvers ", archery, 0, effect.none),

View File

@ -28,6 +28,8 @@ package resource is
icon : sprite_array; icon : sprite_array;
count : constant natural := codex'pos (codex'last) + 1;
trait : constant trait_array := ( trait : constant trait_array := (
("Gold ", 1), ("Gold ", 1),
("Wood ", 3), ("Wood ", 3),

View File

@ -31,6 +31,8 @@ package skill is
icon : sprite_array; icon : sprite_array;
count : constant natural := codex'pos (codex'last) + 1;
trait : constant trait_array := ( trait : constant trait_array := (
("Archery ", 0, 0), ("Archery ", 0, 0),
("Offense ", 0, 0), ("Offense ", 0, 0),

View File

@ -72,6 +72,8 @@ package unit is
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
count : constant natural := codex'pos (codex'last) + 1;
trait : constant trait_array := ( trait : constant trait_array := (
("Azure Dragon ", faction.neutral, 1, 2, 1, 9, effect.none), ("Azure Dragon ", faction.neutral, 1, 2, 1, 9, effect.none),
("Boar ", faction.neutral, 1, 2, 1, 9, effect.none), ("Boar ", faction.neutral, 1, 2, 1, 9, effect.none),