diff --git a/source/ui.adb b/source/ui.adb index fb45cbd..ba0680f 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -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_height : constant natural := (if height < core.base then monoheight * core.string_height (text) else height); begin diff --git a/source/ui.ads b/source/ui.ads index 3b3711c..ba92d8e 100644 --- a/source/ui.ads +++ b/source/ui.ads @@ -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_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); diff --git a/source/world.adb b/source/world.adb index defe077..02a8c01 100644 --- a/source/world.adb +++ b/source/world.adb @@ -1050,79 +1050,46 @@ package body world 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; - width : constant integer := 640; more : constant natural := 10; less : constant natural := 5; - height : constant integer := chad.view_height + 4 * core.icon + 2 * core.base + 3 * ui.monoheight + 2 * more + 2 * offset; - at_x : integer := core.center_x (width) + offset; - at_y : integer := core.center_y (height) + offset; + boxy : constant natural := 3 * ui.monoheight + 2 * more; + width : constant integer := chad.view_width + 3 * 2 * core.icon + 2 * offset; + height : constant integer := chad.view_height + 8 * core.icon + 2 * core.base + boxy + 2 * offset; begin - ui.draw_frame (core.center_x (width), core.center_y (height), width, height); - -- - ui.draw_sprite (unit.view (show_unit_data), data.name.all, at_x, at_y, 0); - -- - 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); + 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.write (data.name.all, core.center_x (width) + offset + unit.view_width + less, core.center_y (height) + offset + less); -- for index in attribute.enumeration loop - if attribute.enumeration'pos (index) = attribute.count / 2 or attribute.enumeration'pos (index) = 0 then -- hack - at_y := at_y + core.icon; - at_x := core.center_x (width) + offset + unit.view_width; - end if; - -- - 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; + ui.draw_icon_and_text (data => attribute.icon (index), + text => data.attributes (index)'image, + x => core.center_x (width) + offset + unit.view_width + (attribute.enumeration'pos (index) / 2) * 2 * core.icon, + y => core.center_y (height) + offset + core.icon + core.icon * (attribute.enumeration'pos (index) mod 2), + width => 2 * core.icon); end loop; -- - at_x := core.center_x (width) + offset; - at_y := core.center_y (height) + offset + unit.view_height; + ui.draw_separator (core.center_x (width) + offset, core.center_y (height) + offset + unit.view_height, width - 2 * offset); -- - 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_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; + ui.draw_separator (core.center_x (width) + offset, core.center_y (height) + offset + unit.view_height + core.base + boxy, width - 2 * offset); -- 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)), 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; + x => core.center_x (width) + offset, + y => core.center_y (height) + offset + unit.view_height + 2 * core.base + boxy + equipment.kind'pos (index) * (core.icon), + width => width - 2 * offset); end loop; end show_unit;