Refactored UI code a lot, more to come with new record...
This commit is contained in:
parent
2308d088b9
commit
5be8b6af53
@ -20,10 +20,10 @@ package body attribute is
|
|||||||
structure.title := "Attribute Menu ";
|
structure.title := "Attribute Menu ";
|
||||||
structure.toggle := core.signal_a;
|
structure.toggle := core.signal_a;
|
||||||
structure.show := false;
|
structure.show := false;
|
||||||
structure.center := true;
|
structure.center := false;
|
||||||
structure.resize := true;
|
structure.resize := true;
|
||||||
structure.x := 880;
|
structure.x := 60;
|
||||||
structure.y := (core.window_height - 320) / 2;
|
structure.y := 80;
|
||||||
structure.gui_n := count;
|
structure.gui_n := count;
|
||||||
--
|
--
|
||||||
ui.add_structure (structure);
|
ui.add_structure (structure);
|
||||||
|
@ -299,8 +299,6 @@ package body core is
|
|||||||
cursor.x := ray.get_mouse_x;
|
cursor.x := ray.get_mouse_x;
|
||||||
cursor.y := ray.get_mouse_y;
|
cursor.y := ray.get_mouse_y;
|
||||||
--
|
--
|
||||||
ray.draw_fps (window_width - 100, window_height - 100);
|
|
||||||
--
|
|
||||||
ray.end_drawing;
|
ray.end_drawing;
|
||||||
--
|
--
|
||||||
if ray.exit_key_is_pressed then
|
if ray.exit_key_is_pressed then
|
||||||
|
@ -20,10 +20,10 @@ package body resource is
|
|||||||
structure.title := "Resource Menu ";
|
structure.title := "Resource Menu ";
|
||||||
structure.toggle := core.signal_r;
|
structure.toggle := core.signal_r;
|
||||||
structure.show := false;
|
structure.show := false;
|
||||||
structure.center := true;
|
structure.center := false;
|
||||||
structure.resize := true;
|
structure.resize := true;
|
||||||
structure.x := 480;
|
structure.x := 60;
|
||||||
structure.y := (core.window_height - 320) / 2;
|
structure.y := 480;
|
||||||
structure.gui_n := count;
|
structure.gui_n := count;
|
||||||
--
|
--
|
||||||
ui.add_structure (structure);
|
ui.add_structure (structure);
|
||||||
|
@ -43,6 +43,12 @@ package body ui is
|
|||||||
|
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
type rectangle is record
|
||||||
|
x, y, width, height : integer;
|
||||||
|
end record;
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
structure_limit : constant natural := 12;
|
structure_limit : constant natural := 12;
|
||||||
|
|
||||||
sprite : array (style, element) of core.sprite;
|
sprite : array (style, element) of core.sprite;
|
||||||
@ -154,33 +160,49 @@ package body ui is
|
|||||||
|
|
||||||
procedure draw_structure (data : in structure) is
|
procedure draw_structure (data : in structure) is
|
||||||
offset : constant integer := core.icon / 4;
|
offset : constant integer := core.icon / 4;
|
||||||
new_width : constant integer := (if data.resize then 320 else data.width);
|
orients : natural := 0;
|
||||||
new_height : constant integer := (if data.resize then data.gui_n * (core.icon + 2 * offset) + 2 * core.icon else data.height);
|
|
||||||
new_x : constant integer := (if data.center then (core.window_width - new_width) / 2 else data.x);
|
|
||||||
new_y : constant integer := (if data.center then (core.window_height - new_height) / 2 else data.y);
|
|
||||||
--
|
--
|
||||||
at_x : integer := new_x + core.icon;
|
frame_data : rectangle := (others => 0);
|
||||||
at_y : integer := new_y + core.icon;
|
button_data : rectangle := (others => 0);
|
||||||
begin
|
begin
|
||||||
draw_tiny_menu (new_x, new_y, new_width, new_height);
|
for index in 0 .. data.gui_n - 1 loop
|
||||||
draw_title_bar (new_x, new_y, new_width, data.title);
|
if data.gui_list (index).kind = gui_orient then
|
||||||
|
orients := orients + 1;
|
||||||
|
end if;
|
||||||
|
end loop;
|
||||||
|
--
|
||||||
|
frame_data.width := (if data.resize then 320 else data.width) * (orients + 1) - offset * orients;
|
||||||
|
frame_data.height := (if data.resize then data.gui_n * (core.icon + 2 * offset) + 2 * core.icon else data.height) / (orients + 1) + offset * orients;
|
||||||
|
frame_data.x := (if data.center then (core.window_width - frame_data.width) / 2 else data.x);
|
||||||
|
frame_data.y := (if data.center then (core.window_height - frame_data.height) / 2 else data.y);
|
||||||
|
button_data.width := frame_data.width / (orients + 1) - 2 * core.icon;
|
||||||
|
button_data.height := core.icon + 2 * offset;
|
||||||
|
button_data.x := frame_data.x + core.icon;
|
||||||
|
button_data.y := frame_data.y + core.icon;
|
||||||
|
--
|
||||||
|
draw_tiny_menu (frame_data.x, frame_data.y, frame_data.width, frame_data.height);
|
||||||
|
draw_title_bar (frame_data.x, frame_data.y, frame_data.width, data.title);
|
||||||
--
|
--
|
||||||
for x in 0 .. data.gui_n - 1 loop
|
for x in 0 .. data.gui_n - 1 loop
|
||||||
case data.gui_list (x).kind is
|
case data.gui_list (x).kind is
|
||||||
when gui_button =>
|
when gui_button =>
|
||||||
draw_frame (data.gui_list (x).info, at_x, at_y, new_width - 2 * core.icon, core.icon + 2 * offset);
|
draw_frame (data.gui_list (x).info, button_data.x, button_data.y, button_data.width, button_data.height);
|
||||||
draw_icon (data.gui_list (x).image, data.gui_list (x).info, at_x + offset, at_y + offset);
|
draw_icon (data.gui_list (x).image, data.gui_list (x).info, button_data.x + offset, button_data.y + offset);
|
||||||
write (data.gui_list (x).text, at_x + core.icon + offset, at_y + offset + 2);
|
write (data.gui_list (x).text, button_data.x + offset + core.icon, button_data.y + offset + 2);
|
||||||
--~if cursor_inside (at_x, at_y, new_width - 2 * offset - core.icon - 2, 3 * core.icon / 2) then
|
--~if cursor_inside (at_x, at_y, new_width - 2 * offset - core.icon - 2, 3 * core.icon / 2) then
|
||||||
--~draw (cursor, at_x + new_width - 96, at_y);
|
--~draw (cursor, at_x + new_width - 96, at_y);
|
||||||
--~end if;
|
--~end if;
|
||||||
at_y := at_y + core.icon + 2 * offset;
|
button_data.y := button_data.y + button_data.height;
|
||||||
when gui_orient =>
|
when gui_orient =>
|
||||||
at_x := at_x + new_width - 2 * core.icon + offset;
|
button_data.x := button_data.x + frame_data.width / (orients + 1) - 2 * core.icon + offset;
|
||||||
at_y := new_y + core.icon;
|
button_data.y := frame_data.y + core.icon;
|
||||||
when others => null;
|
when others => null;
|
||||||
end case;
|
end case;
|
||||||
end loop;
|
end loop;
|
||||||
|
--
|
||||||
|
if orients > 0 then
|
||||||
|
draw_scroll_bar (frame_data.x + frame_data.width - 2 * core.icon, frame_data.y + core.icon, frame_data.height - 2 * core.icon, 4);
|
||||||
|
end if;
|
||||||
end draw_structure;
|
end draw_structure;
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
@ -357,7 +379,7 @@ package body ui is
|
|||||||
|
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
procedure draw_scroll_bar (x, y, height : in integer; offset : in integer) is
|
procedure draw_scroll_bar (x, y, height, offset : in integer) is
|
||||||
middle_height : constant integer := height - sprite (active, scroll_bar_upper).height - sprite (active, scroll_bar_lower).height;
|
middle_height : constant integer := height - sprite (active, scroll_bar_upper).height - sprite (active, scroll_bar_lower).height;
|
||||||
begin
|
begin
|
||||||
draw (scroll_bar_upper, x, y);
|
draw (scroll_bar_upper, x, y);
|
||||||
|
Loading…
Reference in New Issue
Block a user