Even worse code due to Adas limitations...

This commit is contained in:
Ognjen Milan Robovic 2024-05-13 09:20:16 -04:00
parent 482e43deac
commit 53a4179c40
6 changed files with 100 additions and 14 deletions

View File

@ -197,12 +197,9 @@ package body core is
------------------------------------------------------------------------------------------
function import_text (file_path : in string) return string_box_data is
this : string_box_data;
procedure import_text (data : in out string_box_data; file_path : in string) is
begin
this.text := to_unbounded_string (to_ada (ray.load_text (c_string (file_path)))) & character'val (0);
--
return this;
data.text := to_unbounded_string (to_ada (ray.load_text (c_string (file_path)))) & character'val (0);
end import_text;
------------------------------------------------------------------------------------------

View File

@ -128,7 +128,8 @@ package core is
function import_sprite (file_path : in string; frames, states : in integer) return sprite;
function import_font (file_path : in string; scale, space : in integer) return font;
function import_song (file_path : in string) return song;
function import_text (file_path : in string) return string_box_data;
procedure import_text (data : in out string_box_data; file_path : in string);
procedure create_image (width, height : in integer);
procedure render_image (data : in sprite; x, y, u, v, width, height : in integer);

View File

@ -7,11 +7,11 @@ pragma ada_2012;
--~with core, ui, effect, attribute, skill, resource, faction, might, magic, equipment, unit, construction, chad, deity, world, ai;
with core, ui, effect, attribute, skill, resource, faction, material, equipment, unit, construction, chad, world;
use core;
with ada.strings.unbounded;
use ada.strings.unbounded;
use core;
procedure main is
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@ -130,7 +130,46 @@ procedure main is
ui.draw_check_box (0, 96, view_list (text_box_panel), "text_box_panel");
end main_menu;
xxx : string_box_data;
view_source_code : natural := 25;
source_code : array (0 .. 35) of unbounded_string := (
to_unbounded_string ("./source/ai.adb"),
to_unbounded_string ("./source/ai.ads"),
to_unbounded_string ("./source/attribute.adb"),
to_unbounded_string ("./source/attribute.ads"),
to_unbounded_string ("./source/chad.adb"),
to_unbounded_string ("./source/chad.ads"),
to_unbounded_string ("./source/construction.adb"),
to_unbounded_string ("./source/construction.ads"),
to_unbounded_string ("./source/core.adb"),
to_unbounded_string ("./source/core.ads"),
to_unbounded_string ("./source/deity.adb"),
to_unbounded_string ("./source/deity.ads"),
to_unbounded_string ("./source/effect.adb"),
to_unbounded_string ("./source/effect.ads"),
to_unbounded_string ("./source/equipment.adb"),
to_unbounded_string ("./source/equipment.ads"),
to_unbounded_string ("./source/faction.adb"),
to_unbounded_string ("./source/faction.ads"),
to_unbounded_string ("./source/magic.adb"),
to_unbounded_string ("./source/magic.ads"),
to_unbounded_string ("./source/main.adb"),
to_unbounded_string ("./source/material.adb"),
to_unbounded_string ("./source/material.ads"),
to_unbounded_string ("./source/might.adb"),
to_unbounded_string ("./source/might.ads"),
to_unbounded_string ("./source/ray.ads"),
to_unbounded_string ("./source/resource.adb"),
to_unbounded_string ("./source/resource.ads"),
to_unbounded_string ("./source/skill.adb"),
to_unbounded_string ("./source/skill.ads"),
to_unbounded_string ("./source/ui.adb"),
to_unbounded_string ("./source/ui.ads"),
to_unbounded_string ("./source/unit.adb"),
to_unbounded_string ("./source/unit.ads"),
to_unbounded_string ("./source/world.adb"),
to_unbounded_string ("./source/world.ads")
);
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@ -166,6 +205,52 @@ begin
world.make (world.grass, 240, 180);
--~source_code := import_text ("./source/ai.adb");
--~source_code := new string_box_data_array (0 .. 35);
--~source_code := new string_box_data_array (0 .. 2);
--~for index in 0 .. 35 loop
--~source_code (index) := (null, ada.strings.unbounded.null_unbounded_string, (0, 0));
--~end loop;
--~import_text (source_code (0), "./source/ai.adb");
--~import_text (source_code (1), "./source/ai.ads");
--~import_text (source_code (2), "./source/attribute.adb");
--~import_text (source_code (3), "./source/attribute.ads");
--~import_text (source_code (4), "./source/chad.adb");
--~import_text (source_code (5), "./source/chad.ads");
--~import_text (source_code (6), "./source/construction.adb");
--~import_text (source_code (7), "./source/construction.ads");
--~import_text (source_code (8), "./source/core.adb");
--~import_text (source_code (9), "./source/core.ads");
--~import_text (source_code (10), "./source/deity.adb");
--~import_text (source_code (11), "./source/deity.ads");
--~import_text (source_code (12), "./source/effect.adb");
--~import_text (source_code (13), "./source/effect.ads");
--~import_text (source_code (14), "./source/equipment.adb");
--~import_text (source_code (15), "./source/equipment.ads");
--~import_text (source_code (16), "./source/faction.adb");
--~import_text (source_code (17), "./source/faction.ads");
--~import_text (source_code (18), "./source/magic.adb");
--~import_text (source_code (19), "./source/magic.ads");
--~import_text (source_code (20), "./source/main.adb");
--~import_text (source_code (21), "./source/material.adb");
--~import_text (source_code (22), "./source/material.ads");
--~import_text (source_code (23), "./source/might.adb");
--~import_text (source_code (24), "./source/might.ads");
--~import_text (source_code (25), "./source/ray.ads");
--~import_text (source_code (26), "./source/resource.adb");
--~import_text (source_code (27), "./source/resource.ads");
--~import_text (source_code (28), "./source/skill.adb");
--~import_text (source_code (29), "./source/skill.ads");
--~import_text (source_code (30), "./source/ui.adb");
--~import_text (source_code (31), "./source/ui.ads");
--~import_text (source_code (32), "./source/unit.adb");
--~import_text (source_code (33), "./source/unit.ads");
--~import_text (source_code (34), "./source/world.adb");
--~import_text (source_code (35), "./source/world.ads");
dash;
echo (success, "Successfully initialized game data, entering main gameplay loop.");
dash;
@ -202,8 +287,6 @@ begin
cursor_mode := 0;
xxx := import_text ("./source/attribute.adb");
main_menu_loop: loop
synchronize;
--
@ -211,7 +294,12 @@ begin
--
--~main_menu;
--
ui.write_ada_code (xxx, 0, 0);
declare source_code_data : string_box_data;
begin
import_text (source_code_data, to_string (source_code (view_source_code)));
if cursor_mode = 1 then view_source_code := (view_source_code + 1) mod 36; cursor_mode := 0; end if;
ui.write_ada_code (source_code_data, 0, 0);
end;
end loop main_menu_loop;
cursor_mode := 0;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB