Просмотр исходного кода

Very stupid solution to simple problem right now...

master
Ognjen Milan Robovic 2 недель назад
Родитель
Сommit
675631f0e8
3 измененных файлов: 80 добавлений и 32 удалений
  1. +14
    -9
      source/skill.adb
  2. +51
    -21
      source/ui.adb
  3. +15
    -2
      source/ui.ads

+ 14
- 9
source/skill.adb Просмотреть файл

@@ -13,23 +13,28 @@ package body skill is
------------------------------------------------------------------------------------------

procedure configure is
menu_data : ui.structure := ("Skill Menu ", core.signal_s, false, true, false, 0, 0, 320, 160,
0, (others => (ui.gui_none, "- ", 0, (others => 0)))
);
--~menu_data : ui.structure := (
--~"Skill Menu ", core.signal_s, false, true, false, 0, 0, 320, 160,
--~0, (others => (ui.gui_none, "- ", 0, (others => 0)))
--~);
begin
core.echo (core.comment, "Configuring skill components...");
--
ui.add_structure (menu_data);
--~ui.add_structure (menu_data);
ui.add_structure (
"Skill Menu ", core.signal_s, false, true, true, 0, 0, 320, 160,
0, (others => (ui.gui_none, "- ", 0, (others => 0)))
);
--
for index in enumeration loop
sprite (index) := core.import_sprite ("./sprite/skill/" & core.lowercase (enumeration'image (index)) & ".png", 1, 1);
ui.add_structure_button (menu_data, sprite (index), trait (index).name);
ui.add_structure_button (0, sprite (index), trait (index).name);
end loop;
--
core.echo (core.export, ">" & menu_data.gui_n'image);
for x in 0 .. menu_data.gui_n - 1 loop
core.echo (core.export, ">" & x'image & " " & menu_data.gui_list (x).text);
end loop;
--~core.echo (core.export, ">" & menu_data.gui_n'image);
--~for x in 0 .. menu_data.gui_n - 1 loop
--~core.echo (core.export, ">" & x'image & " " & menu_data.gui_list (x).text);
--~end loop;
end configure;

------------------------------------------------------------------------------------------


+ 51
- 21
source/ui.adb Просмотреть файл

@@ -149,10 +149,10 @@ package body ui is

------------------------------------------------------------------------------------------

procedure draw_structure (data : in out structure) is
offset : constant integer := 16;
new_width : constant integer := (if data.resize then 640 else data.width);
new_height : constant integer := (if data.resize then 480 else data.height);
procedure draw_structure (data : in structure) is
offset : constant integer := core.icon;
new_width : constant integer := (if data.resize then 300 else data.width);
new_height : constant integer := (if data.resize then data.gui_n * core.icon + 2 * offset 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);
--
@@ -162,18 +162,15 @@ package body ui is
draw_tiny_menu (new_x, new_y, new_width, new_height);
draw_title_bar (new_x, new_y, new_width, data.title);
--
core.echo (core.import, "Almost rendering" & data.gui_n'image & " elements!");
--
for x in 0 .. data.gui_n - 1 loop
case data.gui_list (x).kind is
when gui_button =>
--~draw_frame ("", at_x, at_y, new_width - 2 * offset, core.icon + offset);
draw_icon (data.gui_list (x).image, "", at_x, at_y);
write (data.gui_list (x).text, at_x + core.icon, at_y);
at_y := at_y + x * core.icon;
core.echo (core.import, "Rendering!");
--~when others => null;
when others => core.echo (core.import, "Not rendering!");
at_y := at_y + core.icon;
when others => null;
--~when others => core.echo (core.import, "Not rendering!");
--~when others =>
--~draw_frame ("", at_x + offset, at_y, new_width - 2 * offset, core.icon + offset);
--~draw_icon (data.gui_list (x).image, "", at_x + 3 * offset / 2, at_y + offset / 2);
@@ -205,9 +202,7 @@ package body ui is

procedure synchronize is
begin
for index in 0 .. structure_limit loop
exit when index = structure_count;
--
for index in 0 .. structure_count - 1 loop
if core.signal_mode = core.signal_code'pos (structure_array (index).toggle) then
structure_array (index).show := (if structure_array (index).show then false else true);
end if;
@@ -463,23 +458,58 @@ 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) is -- TODO: This is dumb, tho less error-prone...
procedure add_structure (
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 => (gui_none, "- ", 0, (others => 0)))) is -- TODO: This is dumb, tho less error-prone...
begin
structure_array (structure_count) := data;
structure_array (structure_count).title := title ;
structure_array (structure_count).toggle := toggle ;
structure_array (structure_count).show := show ;
structure_array (structure_count).center := center ;
structure_array (structure_count).resize := resize ;
structure_array (structure_count).x := x ;
structure_array (structure_count).y := y ;
structure_array (structure_count).width := width ;
structure_array (structure_count).height := height ;
--
core.echo (core.export, "> " & structure_array (structure_count).gui_n'image);
core.echo (core.export, "> " & structure_array (structure_count).title);
core.echo (core.export, "> " & structure_array (structure_count).gui_list (0).text);
--~core.echo (core.export, "> " & );
--~core.echo (core.export, "> " & );
--~core.echo (core.export, "> " & );
--~core.echo (core.export, "> " & );
--~core.echo (core.export, "> " & );
--~core.echo (core.export, "> " & );
--~core.echo (core.export, "> " & );
--~core.echo (core.export, "> " & );
--~core.echo (core.export, "> " & );
--~core.echo (core.export, "> " & );
--~core.echo (core.export, "> " & );
--
structure_count := structure_count + 1;
end add_structure;

------------------------------------------------------------------------------------------

procedure add_structure_button (data : in out structure; icon : in core.sprite; text : in core.short_string) is
procedure add_structure_button (data : in integer; icon : in core.sprite; text : in core.short_string) is
begin
data.gui_list (data.gui_n).kind := gui_button;
data.gui_list (data.gui_n).text := text;
data.gui_list (data.gui_n).number := 0;
data.gui_list (data.gui_n).image := icon;
structure_array (data).gui_list (structure_array (data).gui_n).kind := gui_button;
structure_array (data).gui_list (structure_array (data).gui_n).text := text;
structure_array (data).gui_list (structure_array (data).gui_n).number := 0;
structure_array (data).gui_list (structure_array (data).gui_n).image := icon;
--
data.gui_n := data.gui_n + 1;
structure_array (data).gui_n := structure_array (data).gui_n + 1;
end add_structure_button;

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


+ 15
- 2
source/ui.ads Просмотреть файл

@@ -76,9 +76,22 @@ package ui is

procedure draw_state_box (x, y : in integer);

procedure add_structure (data : in structure);
--~procedure add_structure (data : in structure);
procedure add_structure (
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 => (gui_none, "- ", 0, (others => 0)))
);

procedure add_structure_button (data : in out structure; icon : in core.sprite; text : in core.short_string);
procedure add_structure_button (data : in integer; icon : in core.sprite; text : in core.short_string);

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



Загрузка…
Отмена
Сохранить