A lot of minor UI fixes...

This commit is contained in:
Ognjen Milan Robovic 2024-05-11 06:01:07 -04:00
parent 67c8197ba7
commit e19220d15a
9 changed files with 85 additions and 59 deletions

View File

@ -2,7 +2,7 @@
--
-- GNU General Public Licence (version 3 or later)
with core, effect, resource, faction;
with core, ui, effect, resource, faction;
package body construction is
@ -28,6 +28,17 @@ package body construction is
core.draw (sprite (index), x, y);
end draw;
------------------------------------------------------------------------------------------
procedure draw_plus (index : in enumeration; x, y : in integer) is
begin
draw (index, x, y);
--
if core.cursor_inside (x, y, sprite (index).width, sprite (index).height) and core.cursor_mode = 2 and not ui.prioritize then
core.write_text_box (trait (index).name);
end if;
end draw_plus;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end construction;

View File

@ -42,6 +42,7 @@ package construction is
procedure configure;
procedure draw (index : in enumeration; x, y : in integer);
procedure draw_plus (index : in enumeration; x, y : in integer);
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -141,7 +141,7 @@ package body core is
function cursor_inside (x, y, width, height : in integer) return boolean is
begin
return cursor.x > x and cursor.x < x + width and cursor.y > y and cursor.y < y + height;
return cursor.x > x and cursor.x < x + width * zoom and cursor.y > y and cursor.y < y + height * zoom;
end cursor_inside;
------------------------------------------------------------------------------------------
@ -325,17 +325,13 @@ package body core is
------------------------------------------------------------------------------------------
function read_text_box return string is
begin
return to_string (text_box.text);
end read_text_box;
function read_help_box return string is begin return to_string (help_box.text); end read_help_box;
function read_text_box return string is begin return to_string (text_box.text); end read_text_box;
------------------------------------------------------------------------------------------
procedure write_text_box (text : in string) is
begin
text_box.text := to_unbounded_string (text);
end write_text_box;
procedure write_help_box (text : in string) is begin help_box.text := to_unbounded_string (text); end write_help_box;
procedure write_text_box (text : in string) is begin text_box.text := to_unbounded_string (text); end write_text_box;
------------------------------------------------------------------------------------------

View File

@ -58,7 +58,7 @@ package core is
action : access procedure := null;
end record;
type text_box_data is record
type string_box_data is record
data : access string := null;
text : unbounded_string := null_unbounded_string;
size : vector := (0, 0);
@ -98,7 +98,8 @@ package core is
block_array : array (0 .. block_limit - 1) of block := (others => (0, 0, 0, 0, 0, null));
text_box : text_box_data;
help_box : string_box_data;
text_box : string_box_data;
global_mapshot : ray.image;
@ -160,8 +161,10 @@ package core is
procedure block_queue (data : in block);
function read_help_box return string;
function read_text_box return string;
procedure write_help_box (text : in string);
procedure write_text_box (text : in string);
procedure increment (value : in out integer);

View File

@ -2,7 +2,7 @@
--
-- GNU General Public Licence (version 3 or later)
with core;
with core, ui;
package body equipment is
@ -28,6 +28,17 @@ package body equipment is
core.draw (sprite (index), x, y, state => core.animation'pos (state));
end draw;
------------------------------------------------------------------------------------------
procedure draw_plus (index : in enumeration; state : in core.animation; x, y : in integer) is
begin
draw (index, state, x, y);
--
if core.cursor_inside (x, y, sprite (index).width, sprite (index).height) and core.cursor_mode = 2 and not ui.prioritize then
core.write_text_box (trait (index).name);
end if;
end draw_plus;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end equipment;

View File

@ -177,6 +177,7 @@ package equipment is
procedure configure;
procedure draw (index : in enumeration; state : in core.animation; x, y : in integer);
procedure draw_plus (index : in enumeration; state : in core.animation; x, y : in integer);
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -93,7 +93,7 @@ package body ui is
core.draw_horizontally (sprite (active, index), x, y, width);
core.zoom := save_zoom;
--
--~if core.cursor_mode = 1 and cursor_inside (x, y, width, sprite (active, index).height) then
--~if core.cursor_mode = 1 and cursor_inside (x, y, width / core.zoom, sprite (active, index).height / core.zoom) then
--~action.all;
--~core.cursor_mode := 0;
--~end if;
@ -108,7 +108,7 @@ package body ui is
core.draw_vertically (sprite (active, index), x, y, height);
core.zoom := save_zoom;
--
--~if core.cursor_mode = 1 and cursor_inside (x, y, sprite (active, index).width, height) then
--~if core.cursor_mode = 1 and cursor_inside (x, y, sprite (active, index).width / core.zoom, height / core.zoom) then
--~action.all;
--~core.cursor_mode := 0;
--~end if;
@ -145,6 +145,29 @@ package body ui is
------------------------------------------------------------------------------------------
procedure draw_text_box is
width : constant integer := 320;
height : constant integer := core.icon;
middle : constant integer := sprite (active, text_middle).width;
offset : constant integer := 16;
begin
draw_background (text_middle, core.cursor.x + middle + offset, core.cursor.y + middle + offset, width - 2 * middle, height - 2 * middle);
--
draw_horizontally (text_upper, core.cursor.x + middle + offset, core.cursor.y + offset, width - 2 * middle);
draw_horizontally (text_lower, core.cursor.x + middle + offset, core.cursor.y + height - middle + offset, width - 2 * middle);
draw_vertically (text_left, core.cursor.x + offset, core.cursor.y + middle + offset, height - 2 * middle);
draw_vertically (text_right, core.cursor.x + width - middle + offset, core.cursor.y + middle + offset, height - 2 * middle);
--
draw (text_upper_left, core.cursor.x + offset, core.cursor.y + offset);
draw (text_upper_right, core.cursor.x + width - middle + offset, core.cursor.y + offset);
draw (text_lower_left, core.cursor.x + offset, core.cursor.y + height - middle + offset);
draw (text_lower_right, core.cursor.x + width - middle + offset, core.cursor.y + height - middle + offset);
--
write (core.read_text_box, core.cursor.x + 4 + offset, core.cursor.y + 6 + offset);
end draw_text_box;
------------------------------------------------------------------------------------------
procedure draw_structure (data : in structure) is
offset : constant integer := core.icon / 4;
orients : natural := 0;
@ -231,6 +254,12 @@ package body ui is
prioritize := true;
end if;
end loop;
--
if read_text_box /= "--" then
draw_text_box;
end if;
--
core.write_text_box ("--");
end synchronize;
------------------------------------------------------------------------------------------
@ -251,10 +280,10 @@ package body ui is
core.draw (data, x, y);
core.zoom := save_zoom;
--
if core.cursor_inside (x, y, core.icon, core.icon) then
if core.cursor_inside (x, y, core.icon / core.zoom, core.icon / core.zoom) then
draw (icon_selected, x, y);
--
core.write_text_box (text);
core.write_help_box (text);
--
if core.cursor_mode = 1 then
action.all;
@ -277,30 +306,6 @@ package body ui is
------------------------------------------------------------------------------------------
procedure draw_text_box (text : in string) is
width : constant integer := 144;
height : constant integer := 72;
x : constant integer := (core.window_width - width) / 2;
y : constant integer := (core.window_height - height) / 2;
offset : constant integer := sprite (active, text_middle).width;
begin
draw_background (text_middle, x + offset, y + offset, width - 2 * offset, height - 2 * offset);
--
draw_horizontally (text_upper, x + offset, y, width - 2 * offset);
draw_horizontally (text_lower, x + offset, y + height - offset, width - 2 * offset);
draw_vertically (text_left, x, y + offset, height - 2 * offset);
draw_vertically (text_right, x + width - offset, y + offset, height - 2 * offset);
--
draw (text_upper_left, x, y);
draw (text_upper_right, x + width - offset, y);
draw (text_lower_left, x, y + height - offset);
draw (text_lower_right, x + width - offset, y + height - offset);
--
write (text, x, y);
end draw_text_box;
------------------------------------------------------------------------------------------
procedure draw_help_box (x, y, width, height : in integer; action : core.pointer := core.idle_skip'access) is
offset : constant integer := sprite (active, text_middle).width;
begin
@ -316,9 +321,9 @@ package body ui is
draw (text_lower_left, x, y + height - offset);
draw (text_lower_right, x + width - offset, y + height - offset);
--
write (core.read_text_box, (core.icon - font (active).scale) / 2 + x + 4, (core.icon - font (active).scale) / 2 + y);
write (core.read_help_box, (core.icon - font (active).scale) / 2 + x + 4, (core.icon - font (active).scale) / 2 + y);
--
core.write_text_box ("--");
core.write_help_box ("--");
end draw_help_box;
------------------------------------------------------------------------------------------
@ -343,8 +348,8 @@ package body ui is
draw (frame_lower_left, x, y + height - sprite (active, frame_lower_left).height);
draw (frame_lower_right, x + width - sprite (active, frame_lower_right).width, y + height - sprite (active, frame_lower_right).height);
--
if core.cursor_inside (x, y, width, height) then
core.write_text_box (description);
if core.cursor_inside (x, y, width / core.zoom, height / core.zoom) then
core.write_help_box (description);
--
if core.cursor_mode = 1 then
action.all;
@ -364,9 +369,9 @@ package body ui is
write (text,
x + offset + (core.icon - font (active).scale) / 2 + core.icon,
y + offset + (core.icon - font (active).scale) / 2,
(if core.cursor_inside (x, y, width, height) then font_tint (active) else (others => 255)));
(if core.cursor_inside (x, y, width / core.zoom, height / core.zoom) then font_tint (active) else (others => 255)));
--
if core.cursor_inside (x, y, width, height) then
if core.cursor_inside (x, y, width / core.zoom, height / core.zoom) then
if core.cursor_mode = 1 then
action.all;
core.cursor_mode := 0;
@ -382,7 +387,7 @@ package body ui is
--
write (text, x + sprite (active, check_box_on).width, y);
--
if core.cursor_mode = 1 and core.cursor_inside (x, y, sprite (active, check_box_on).width, sprite (active, check_box_on).height) then
if core.cursor_mode = 1 and core.cursor_inside (x, y, sprite (active, check_box_on).width / core.zoom, sprite (active, check_box_on).height / core.zoom) then
on := not on;
core.cursor_mode := 0;
end if;

View File

@ -62,8 +62,6 @@ package ui is
procedure draw_icon (data : in core.sprite; text : in string; x, y : in integer; action : core.pointer := core.idle_skip'access);
procedure draw_overicon (data : in core.sprite; text : in string; x, y : in integer; action : core.pointer := core.idle_skip'access);
procedure draw_text_box (text : in string);
procedure draw_help_box (x, y, width, height : in integer; action : core.pointer := core.idle_skip'access);
procedure draw_frame (description : in string; x, y, width, height : in integer; action : core.pointer := core.idle_skip'access);

View File

@ -208,7 +208,7 @@ package body world is
--
for index in 1 .. construction_limit loop
if map.views (map.constructions (index).x, map.constructions (index).y) then
construction.draw (construction.enumeration'val (map.constructions (index).index),
construction.draw_plus (construction.enumeration'val (map.constructions (index).index),
offset.x + (map.constructions (index).x - core.camera.x) * core.base * core.zoom,
offset.y + (map.constructions (index).y - core.camera.y) * core.base * core.zoom);
end if;
@ -216,7 +216,7 @@ package body world is
--
for index in 1 .. equipment_limit loop
if map.views (map.equipments (index).x, map.equipments (index).y) then
equipment.draw (equipment.enumeration'val (map.equipments (index).index),
equipment.draw_plus (equipment.enumeration'val (map.equipments (index).index),
core.idle,
offset.x + (map.equipments (index).x - core.camera.x) * core.base * core.zoom,
offset.y + (map.equipments (index).y - core.camera.y) * core.base * core.zoom);