Refactored unit stat menu...

This commit is contained in:
Ognjen Milan Robovic 2024-06-09 17:45:44 -04:00
parent 83373bbda1
commit d48390bf22
3 changed files with 27 additions and 60 deletions

View File

@ -336,7 +336,7 @@ package body ui is
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
procedure draw_text (text : in string; x, y, width, height : in integer; offset, border : in natural := 0; tint : in core.colour := (others => 255)) is procedure draw_text (text : in string; x, y, width, height : in integer := 0; offset, border : in natural := 0; tint : in core.colour := (others => 255)) is
new_width : constant natural := (if width < core.base then monowidth * core.string_width (text) else width); new_width : constant natural := (if width < core.base then monowidth * core.string_width (text) else width);
new_height : constant natural := (if height < core.base then monoheight * core.string_height (text) else height); new_height : constant natural := (if height < core.base then monoheight * core.string_height (text) else height);
begin begin

View File

@ -49,7 +49,7 @@ package ui is
procedure draw_button (text, description : in string; icon : in core.sprite; x, y, width, height : in integer; action : core.pointer := core.idle_skip'access); procedure draw_button (text, description : in string; icon : in core.sprite; x, y, width, height : in integer; action : core.pointer := core.idle_skip'access);
procedure draw_text (text : in string; x, y, width, height : in integer; offset, border : in natural := 0; tint : in core.colour := (others => 255)); procedure draw_text (text : in string; x, y, width, height : in integer := 0; offset, border : in natural := 0; tint : in core.colour := (others => 255));
procedure draw_check_box (x, y : in integer; on : in out boolean; text : in string); procedure draw_check_box (x, y : in integer; on : in out boolean; text : in string);

View File

@ -1050,79 +1050,46 @@ package body world is
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
procedure show_unit is procedure show_unit is
data : unit.definition := unit.description (show_unit_data); data : unit.definition := unit.description (show_unit_data);
from : faction.definition := faction.description (data.kind);
-- --
offset : constant integer := 8; offset : constant integer := 8;
width : constant integer := 640;
more : constant natural := 10; more : constant natural := 10;
less : constant natural := 5; less : constant natural := 5;
height : constant integer := chad.view_height + 4 * core.icon + 2 * core.base + 3 * ui.monoheight + 2 * more + 2 * offset; boxy : constant natural := 3 * ui.monoheight + 2 * more;
at_x : integer := core.center_x (width) + offset; width : constant integer := chad.view_width + 3 * 2 * core.icon + 2 * offset;
at_y : integer := core.center_y (height) + offset; height : constant integer := chad.view_height + 8 * core.icon + 2 * core.base + boxy + 2 * offset;
begin begin
ui.draw_frame (core.center_x (width), core.center_y (height), width, height); ui.draw_frame (core.center_x (width), core.center_y (height), width, height);
-- ui.draw_sprite (unit.view (show_unit_data), data.name.all, core.center_x (width) + offset, core.center_y (height) + offset, 0);
ui.draw_sprite (unit.view (show_unit_data), data.name.all, at_x, at_y, 0); ui.write (data.name.all, core.center_x (width) + offset + unit.view_width + less, core.center_y (height) + offset + less);
--
at_x := at_x + unit.view_width;
--
ui.draw_text_box (at_x, at_y, width - unit.view_width - 2 * offset, core.icon);
ui.write (data.name.all, at_x + less, at_y + less);
-- --
for index in attribute.enumeration loop for index in attribute.enumeration loop
if attribute.enumeration'pos (index) = attribute.count / 2 or attribute.enumeration'pos (index) = 0 then -- hack ui.draw_icon_and_text (data => attribute.icon (index),
at_y := at_y + core.icon; text => data.attributes (index)'image,
at_x := core.center_x (width) + offset + unit.view_width; x => core.center_x (width) + offset + unit.view_width + (attribute.enumeration'pos (index) / 2) * 2 * core.icon,
end if; y => core.center_y (height) + offset + core.icon + core.icon * (attribute.enumeration'pos (index) mod 2),
-- width => 2 * core.icon);
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; end loop;
-- --
at_x := core.center_x (width) + offset; ui.draw_separator (core.center_x (width) + offset, core.center_y (height) + offset + unit.view_height, width - 2 * offset);
at_y := core.center_y (height) + offset + unit.view_height;
-- --
ui.draw_separator (at_x, at_y, width - 2 * offset); ui.draw_text (text => "Hiring fee:" & data.hiring_fee'image & character'val (10) &
"Weekly fee:" & data.weekly_fee'image & character'val (10) &
"Battle fee:" & data.battle_fee'image,
x => core.center_x (width) + offset,
y => core.center_y (height) + offset + unit.view_height + core.base,
width => width - 2 * (offset + more),
border => more);
-- --
at_y := at_y + core.base; ui.draw_separator (core.center_x (width) + offset, core.center_y (height) + offset + unit.view_height + core.base + boxy, width - 2 * offset);
--
ui.draw_text ("Hiring fee:" & data.hiring_fee'image & character'val (10) &
"Weekly fee:" & data.weekly_fee'image & character'val (10) &
"Battle fee:" & data.battle_fee'image,
at_x, at_y, (width - 3 * offset) / 2 - 2 * more, 0, 0, more);
ui.draw_text ("Faction: " & faction.description (data.kind).name.all & character'val (10) &
"Stack:" & data.limit'image & character'val (10) &
"Bonus: " & attribute.description (faction.description (data.kind).bonus_attribute).name.all,
at_x + (width - offset) / 2, at_y, (width - 3 * offset) / 2 - 2 * more, 0, 0, more);
--
at_y := at_y + 3 * ui.monoheight + 2 * more;
--
ui.draw_separator (at_x, at_y, width - 2 * offset);
--
at_y := at_y + core.base - core.icon;
-- --
for index in equipment.kind loop for index in equipment.kind loop
if equipment.kind'pos (index) mod 2 = 0 then -- hack
at_y := at_y + core.icon;
at_x := core.center_x (width) + offset;
end if;
--
ui.draw_icon_and_text (data => (if equipment_valid (data.equipments (index)) then equipment.icon (data.equipments (index)) else equipment.slot (index)), 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, text => equipment.description (data.equipments (index)).name.all,
x => at_x, x => core.center_x (width) + offset,
y => at_y, y => core.center_y (height) + offset + unit.view_height + 2 * core.base + boxy + equipment.kind'pos (index) * (core.icon),
width => (width - 2 * offset) / 2); width => width - 2 * offset);
--~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; end loop;
end show_unit; end show_unit;