From 53a4179c402c8c3b276bee7b6348773ce29af27f Mon Sep 17 00:00:00 2001 From: xolatile Date: Mon, 13 May 2024 09:20:16 -0400 Subject: [PATCH] Even worse code due to Adas limitations... --- source/core.adb | 7 +--- source/core.ads | 3 +- source/main.adb | 100 +++++++++++++++++++++++++++++++++++++++++++++--- source/world.adb | 2 +- source/world.ads | 2 +- sprite/ui/monospace.png | Bin 2017 -> 2015 bytes 6 files changed, 100 insertions(+), 14 deletions(-) diff --git a/source/core.adb b/source/core.adb index 549d40c..b289b19 100644 --- a/source/core.adb +++ b/source/core.adb @@ -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; ------------------------------------------------------------------------------------------ diff --git a/source/core.ads b/source/core.ads index 921f61c..2a15e70 100644 --- a/source/core.ads +++ b/source/core.ads @@ -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); diff --git a/source/main.adb b/source/main.adb index 8b7dfa4..deec30f 100644 --- a/source/main.adb +++ b/source/main.adb @@ -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; diff --git a/source/world.adb b/source/world.adb index dd87480..4e74040 100644 --- a/source/world.adb +++ b/source/world.adb @@ -69,7 +69,7 @@ package body world is map.views := new view_array (0 .. map.width - 1, 0 .. map.height - 1); map.landmarks := new entity_array (1 .. landmark_limit); map.constructions := new entity_array (1 .. construction_limit); - map.equipments := new entity_array (1 .. equipment_limit); + map.equipments := new entity_array (1 .. equipment_limit); map.units := new entity_array (1 .. unit_limit); -- for x in 0 .. width - 1 loop diff --git a/source/world.ads b/source/world.ads index 138ae4b..db2a72d 100644 --- a/source/world.ads +++ b/source/world.ads @@ -44,7 +44,7 @@ package world is views : access view_array; landmarks : access entity_array; constructions : access entity_array; - equipments : access entity_array; + equipments : access entity_array; units : access entity_array; end record; diff --git a/sprite/ui/monospace.png b/sprite/ui/monospace.png index 6a3e9ea9a8bb620dabb927b89105e623168e7d54..c26a258b0c04b5f31aeaa3865b24af2328bad83a 100644 GIT binary patch delta 664 zcmV;J0%!f<58n@vIRTNeIv)jp(QOv5TK2dr%_5h)RI7A(X-hBrNaz!;z_K<*H??Qm-lSY=wV+Y+_*GQk|)mQ#ejqe*WYhtDsbSdTD5?Y-40*_z$P zD1Aqw-jOplD>2mb3DBID#QD$@7RA&gj`=nFb0d6#lz5{a`G zBvNN0u%5h2@J=6*Ifq|C|Rx%ne~~ zIBOp2xw}Do=ZKeovw5^pv(-t11)c>Y@1f&ao4bq#Y}a%q`UD|~(@XZBm1>rmo!E;` z#2e$W@l%>w)L!>hIuTvElO=YC$aP&!L0Q^6ztLd%u4xTA3FnFRzP!Ect38sSH7^%L yNb9B+q;c~77KKu;0u4z7){~YXrWT|n=nw8*Mc+@?2(ADN0000qdR9(*+?8gLOJ4Hkc;PuRSKvr2_DCcn5m--R zL?)4jo3$W7o4hmg9-y45N6cgnufJ`UxD zI-D)TzqEKN?Uvb4sXjTLf_G(w~fQ+7f-B57@_vw>XdBF zZex_bBT?_j8Jm?D>iGm{*Yj#-En4Uxoef#3FL?C=h&L7Kd*~2GtWWd>os+yvIWmdF zSql=WGZ9!%-X(aakI0-uuD74`P;Qhg*N9B|rW2!&pY@Q-9GS#_Vvj_cDNRgnKGozq zlJA5#+>&gI9u`AMKZ|{?{k!&gCEnQ2SJIp_m+MF#puqx5H*|VmiM1kWu5a_kOh|DV z(0)VgcChklbnxPp>KogYAc@G9-3}Igb54TTd4lHE^qa(g&rzextSB{P#Ik_yX8_E5 z%xau95B1#LpuKZ{#LL+{+Njy;q`?Bu0+RR8@vO~VMgz8MIum_@ki_XF`_D=>%gj#f zMJM8o@!0q&O)YA#`zqbzEZxZxyF=u