Refactored some UI code...

This commit is contained in:
Ognjen Milan Robovic 2024-05-16 10:43:39 -04:00
parent 20e1c6a91c
commit f06b32f8ae
4 changed files with 33 additions and 12 deletions

View File

@ -31,10 +31,8 @@ package body magic is
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
procedure view (index : in enumeration; x, y : in integer) is procedure view (index : in enumeration; x, y : in integer) is
offset : constant integer := 8;
begin begin
ui.draw_frame (trait (index).text, x, y, view_width + 2 * offset, view_height + 2 * offset); ui.draw_sprite (view_sprite (index), trait (index).text, x, y, 8);
core.draw (view_sprite (index), x + offset, y + offset);
end view; end view;
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------

View File

@ -316,6 +316,26 @@ package body ui is
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
procedure draw_sprite (data : in core.sprite; text : in string; x, y, offset : in integer; action : core.pointer := core.idle_skip'access) is
begin
core.draw (data, x + offset, y + offset, factor => 1);
--
draw_icon_menu (x, y, data.width + 2 * offset, data.height + 2 * offset);
--
if core.cursor_inside (x, y, data.width + 2 * offset, data.height + 2 * offset) then
prioritize := true;
--
core.write_help_box (text);
--
if core.cursor_mode = 1 then
action.all;
core.cursor_mode := 0;
end if;
end if;
end draw_sprite;
------------------------------------------------------------------------------------------
procedure draw_help_box (x, y, width, height : in integer; action : core.pointer := core.idle_skip'access) is 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; offset : constant integer := sprite (active, text_middle).width;
begin begin

View File

@ -62,6 +62,8 @@ 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_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_overicon (data : in core.sprite; text : in string; x, y : in integer; action : core.pointer := core.idle_skip'access);
procedure draw_sprite (data : in core.sprite; text : in string; x, y, offset : in integer; action : core.pointer := core.idle_skip'access);
procedure draw_help_box (x, y, width, height : in integer; action : core.pointer := core.idle_skip'access); 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); procedure draw_frame (description : in string; x, y, width, height : in integer; action : core.pointer := core.idle_skip'access);

View File

@ -185,15 +185,16 @@ package body world is
v => v, v => v,
width => core.base, width => core.base,
height => core.base); height => core.base);
if core.cursor.x > offset.x + (horizontal - core.camera.x ) * core.base * core.zoom - 6 --~if core.cursor.x > offset.x + (horizontal - core.camera.x ) * core.base * core.zoom - 6
and core.cursor.x < offset.x + (horizontal - core.camera.x + 1) * core.base * core.zoom + 6 --~and core.cursor.x < offset.x + (horizontal - core.camera.x + 1) * core.base * core.zoom + 6
and core.cursor.y > offset.y + (vertical - core.camera.y ) * core.base * core.zoom - 6 --~and core.cursor.y > offset.y + (vertical - core.camera.y ) * core.base * core.zoom - 6
and core.cursor.y < offset.y + (vertical - core.camera.y + 1) * core.base * core.zoom + 6 --~and core.cursor.y < offset.y + (vertical - core.camera.y + 1) * core.base * core.zoom + 6
and core.cursor_mode = 1 and not ui.prioritize then --~and core.cursor_mode = 1
core.camera.x := horizontal; --~and not ui.prioritize then
core.camera.y := vertical; --~core.camera.x := horizontal;
core.cursor_mode := 0; --~core.camera.y := vertical;
end if; --~core.cursor_mode := 0;
--~end if;
end if; end if;
end loop; end loop;
end loop; end loop;