diff --git a/source/core.adb b/source/core.adb index f9ceed7..27bcbc9 100644 --- a/source/core.adb +++ b/source/core.adb @@ -197,6 +197,16 @@ package body core is ------------------------------------------------------------------------------------------ + function import_text (file_path : in string) return string_box_data is + this : string_box_data; + begin + this.text := to_unbounded_string (to_ada (ray.load_text (c_string (file_path)))); + -- + return this; + end import_text; + + ------------------------------------------------------------------------------------------ + procedure create_image (width, height : in integer) is begin global_mapshot := ray.image_colour (width * base, height * base, (0, 0, 0, 255)); diff --git a/source/core.ads b/source/core.ads index f5db15c..921f61c 100644 --- a/source/core.ads +++ b/source/core.ads @@ -2,8 +2,8 @@ -- -- GNU General Public Licence (version 3 or later) -with ada.text_io, ada.strings.unbounded, ray; -use ada.text_io, ada.strings.unbounded, ray; +with ada.text_io, ada.strings.unbounded, interfaces.c, ray; +use ada.text_io, ada.strings.unbounded, interfaces.c, ray; package core is @@ -128,6 +128,7 @@ 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 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 7b08213..1620ec8 100644 --- a/source/main.adb +++ b/source/main.adb @@ -9,6 +9,9 @@ with core, ui, effect, attribute, skill, resource, faction, material, equipment, use core; +with ada.strings.unbounded; +use ada.strings.unbounded; + procedure main is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -127,6 +130,8 @@ procedure main is ui.draw_check_box (0, 96, view_list (text_box_panel), "text_box_panel"); end main_menu; + xxx : string_box_data; + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ begin @@ -197,11 +202,15 @@ begin cursor_mode := 0; + xxx := import_text ("./source/material.ads"); + main_menu_loop: loop synchronize; -- exit when signal_mode = signal_space or cursor_mode = 2; -- + ui.write (to_string (xxx.text), 0, 0, code => true); + -- main_menu; end loop main_menu_loop; diff --git a/source/material.ads b/source/material.ads index 2a933ec..ff75ccd 100644 --- a/source/material.ads +++ b/source/material.ads @@ -24,7 +24,6 @@ package material is count : constant natural := enumeration'pos (enumeration'last) + 1; trait : constant array (enumeration) of information := ( - ("-- ", 0), ("Sulphur ", 7), ("Mercury ", 13), ("Mint ", 3), diff --git a/source/ray.ads b/source/ray.ads index cd50087..2626343 100644 --- a/source/ray.ads +++ b/source/ray.ads @@ -176,7 +176,7 @@ package ray is --~void HideCursor(void); --~double GetTime(void); --~void OpenURL(const char *url); - --~function load_text (file : in string) return access string with import => true, convention => c, external_name => "LoadFileText"; + function load_text (file : in string) return char_array with import => true, convention => c, external_name => "LoadFileText"; --~procedure unload_file (data : in access string) with import => true, convention => c, external_name => "UnloadFileText"; --~bool SaveFileText(const char *fileName, char *text); --~FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs);