Revised UI structure to use dynamic arrays, and revised menus.

This commit is contained in:
Ognjen Milan Robovic 2024-05-04 07:12:00 -04:00
parent 5d0a29f15a
commit 16fbf216da
8 changed files with 67 additions and 78 deletions

View File

@ -13,19 +13,20 @@ package body attribute is
------------------------------------------------------------------------------------------
procedure configure is
structure : ui.structure;
begin
core.echo (core.comment, "Configuring attribute components...");
--
ui.add_structure ((title => "Attribute Menu ",
toggle => core.signal_a,
show => false,
center => false,
resize => true,
x => 880,
y => (core.window_height - 320) / 2,
gui_n => 0,
gui_list => (others => ui.empty),
others => 0));
structure.title := "Attribute Menu ";
structure.toggle := core.signal_a;
structure.show := false;
structure.center := false;
structure.resize := true;
structure.x := 880;
structure.y := (core.window_height - 320) / 2;
structure.gui_n := count;
--
ui.add_structure (structure);
--
for index in enumeration loop
sprite (index) := core.import_sprite ("./sprite/attribute/" & core.lowercase (enumeration'image (index)) & ".png", 1, 1);

View File

@ -356,6 +356,11 @@ package body core is
------------------------------------------------------------------------------------------
procedure increment (value : in out integer) is begin value := value + 1; end increment;
procedure decrement (value : in out integer) is begin value := value - 1; end decrement;
------------------------------------------------------------------------------------------
procedure idle is begin null; end idle;
procedure move_camera_up is begin core.camera.y := core.camera.y - 1; end move_camera_up;

View File

@ -127,6 +127,9 @@ package core is
procedure move_camera_left;
procedure move_camera_right;
procedure increment (value : in out integer);
procedure decrement (value : in out integer);
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end core;

View File

@ -13,19 +13,20 @@ package body resource is
------------------------------------------------------------------------------------------
procedure configure is
structure : ui.structure;
begin
core.echo (core.comment, "Configuring resource components...");
--
ui.add_structure ((title => "Resource Menu ",
toggle => core.signal_r,
show => false,
center => false,
resize => true,
x => 480,
y => (core.window_height - 320) / 2,
gui_n => 0,
gui_list => (others => ui.empty),
others => 0));
structure.title := "Resource Menu ";
structure.toggle := core.signal_r;
structure.show := false;
structure.center := false;
structure.resize := true;
structure.x := 480;
structure.y := (core.window_height - 320) / 2;
structure.gui_n := count;
--
ui.add_structure (structure);
--
for index in enumeration loop
sprite (index) := core.import_sprite ("./sprite/resource/" & core.lowercase (enumeration'image (index)) & ".png", 1, 1);

View File

@ -13,23 +13,20 @@ package body skill is
------------------------------------------------------------------------------------------
procedure configure is
--~menu_data : ui.structure := (
--~"Skill Menu ", core.signal_s, false, true, true, 0, 0, 320, 160,
--~0, (others => (ui.gui_none, "- ", 0, (others => 0)))
--~);
structure : ui.structure;
begin
core.echo (core.comment, "Configuring skill components...");
--
ui.add_structure ((title => "Skill Menu ",
toggle => core.signal_s,
show => false,
center => false,
resize => true,
x => 80,
y => (core.window_height - 320) / 2,
gui_n => 0,
gui_list => (others => ui.empty),
others => 0));
structure.title := "Skill Menu ";
structure.toggle := core.signal_s;
structure.show := false;
structure.center := false;
structure.resize := true;
structure.x := 80;
structure.y := (core.window_height - 320) / 2;
structure.gui_n := count;
--
ui.add_structure (structure);
--
for index in enumeration loop
sprite (index) := core.import_sprite ("./sprite/skill/" & core.lowercase (enumeration'image (index)) & ".png", 1, 1);

View File

@ -453,11 +453,13 @@ package body ui is
------------------------------------------------------------------------------------------
procedure add_structure (data : in structure) is -- TODO: This is dumb, tho less error-prone...
procedure add_structure (data : in structure := no_structure) is -- TODO: This is dumb, tho less error-prone...
begin
structure_array (structure_count) := data;
structure_array (structure_count) := data;
structure_array (structure_count).gui_list := new gui_array (0 .. structure_array (structure_count).gui_n - 1);
structure_array (structure_count).gui_n := 0;
--
structure_count := structure_count + 1;
core.increment (structure_count);
end add_structure;
------------------------------------------------------------------------------------------
@ -469,7 +471,7 @@ package body ui is
structure_array (structure_count - 1).gui_list (structure_array (structure_count - 1).gui_n).number := 0;
structure_array (structure_count - 1).gui_list (structure_array (structure_count - 1).gui_n).image := icon;
--
structure_array (structure_count - 1).gui_n := structure_array (structure_count - 1).gui_n + 1;
core.increment (structure_array (structure_count - 1).gui_n);
end add_structure_button;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -19,8 +19,6 @@ package ui is
------------------------------------------------------------------------------------------
gui_size : constant := 24;
type gui_data is record
kind : enumeration := gui_none;
text : core.short_string := "- ";
@ -30,26 +28,27 @@ package ui is
empty : gui_data;
type gui_array is array (0 .. gui_size) of gui_data;
type gui_array is array (natural range <>) of gui_data;
type structure is record
title : core.short_string := "- ";
toggle : core.signal_code := core.signal_space;
show : boolean := false;
center : boolean := false;
resize : boolean := false;
x : integer := 0;
y : integer := 0;
width : integer := 0;
height : integer := 0;
gui_n : natural := 0;
gui_list : gui_array := (others => empty);
title : core.short_string := "- ";
toggle : core.signal_code := core.signal_space;
show : boolean := false;
center : boolean := false;
resize : boolean := false;
x : integer := 0;
y : integer := 0;
width : integer := 0;
height : integer := 0;
gui_n : natural := 0;
gui_list : access gui_array := null;
end record;
no_structure : structure;
------------------------------------------------------------------------------------------
active : style := main;
prioritize : boolean := false;
active : style := main;
------------------------------------------------------------------------------------------
@ -78,7 +77,7 @@ package ui is
procedure draw_state_box (x, y : in integer);
procedure add_structure (data : in structure);
procedure add_structure (data : in structure := no_structure);
procedure add_structure_button (icon : in core.sprite; text : in core.short_string);

View File

@ -71,7 +71,6 @@ package body world is
exit when offset.x + (horizontal - core.camera.x) * core.base * core.zoom > core.window_width;
--
u := core.base * biome'pos (map.kind) * 4;
--~v := core.base * map.tiles ((horizontal - core.camera.x) mod map.width, (vertical - core.camera.y) mod map.height);
v := core.base * map.tiles (horizontal, vertical);
--
core.draw (data => tiles,
@ -81,12 +80,12 @@ package body world is
v => v,
width => core.base,
height => core.base);
--
--~--MOVE PLAYER TO TILE WHERE YOU CLICKED
--~if core.cursor.x > offset.x + (horizontal - core.camera.x ) * core.base * core.zoom
--~and core.cursor.x < offset.x + (horizontal - core.camera.x + 1) * core.base * core.zoom
--~and core.cursor.y > offset.y + (vertical - core.camera.y ) * core.base * core.zoom
--~and core.cursor.y < offset.y + (vertical - core.camera.y + 1) * core.base * core.zoom
--~and core.cursor_mode = 1 and not ui.prioritize then
--~and core.cursor.y > offset.y + (vertical - core.camera.y ) * core.base * core.zoom
--~and core.cursor.y < offset.y + (vertical - core.camera.y + 1) * core.base * core.zoom
--~and core.cursor_mode = 1 then
--~core.camera.x := horizontal;
--~core.camera.y := vertical;
--~core.cursor_mode := 0;
@ -100,24 +99,6 @@ package body world is
y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom);
end loop;
end draw;
--~procedure draw is
--~u, v : integer;
--~begin
--~for move_y in 0 .. core.window_height / core.base / core.zoom + 1 loop
--~for move_x in 0 .. core.window_width / core.base / core.zoom + 1 loop
--~u := core.base * biome'pos (map.kind) * 4;
--~v := core.base * map.tiles (core.camera.x + move_x, core.camera.y + move_y);
--~--
--~core.draw (tiles, move_x * core.base * core.zoom, move_y * core.base * core.zoom, u, v, core.base, core.base);
--~end loop;
--~end loop;
--~--
--~for index in 1 .. landmark_limit loop
--~core.draw (data => landmarks (map.landmarks (index).index),
--~x => (map.landmarks (index).x - core.camera.x * core.base) * core.zoom,
--~y => (map.landmarks (index).y - core.camera.y * core.base) * core.zoom);
--~end loop;
--~end draw;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------