diff --git a/source/core.adb b/source/core.adb index 27bcbc9..549d40c 100644 --- a/source/core.adb +++ b/source/core.adb @@ -200,7 +200,7 @@ 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)))); + this.text := to_unbounded_string (to_ada (ray.load_text (c_string (file_path)))) & character'val (0); -- return this; end import_text; @@ -352,7 +352,7 @@ package body core is ------------------------------------------------------------------------------------------ - procedure idle_skip is begin null; end idle_skip; + procedure idle_skip is null; procedure move_camera_up is begin core.camera.y := core.camera.y - 1; end move_camera_up; procedure move_camera_down is begin core.camera.y := core.camera.y + 1; end move_camera_down; diff --git a/source/main.adb b/source/main.adb index 1620ec8..cfb78a6 100644 --- a/source/main.adb +++ b/source/main.adb @@ -202,16 +202,17 @@ begin cursor_mode := 0; - xxx := import_text ("./source/material.ads"); + xxx := import_text ("./source/attribute.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; + -- + --~ui.write (to_string (xxx.text), 0, 0, size => 11, code => true); + ui.write_ada_code (xxx, 0, 0); end loop main_menu_loop; cursor_mode := 0; diff --git a/source/ui.adb b/source/ui.adb index 22cc7ee..a963c5e 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -4,6 +4,9 @@ with core; +with ada.strings.unbounded; +use ada.strings.unbounded; + package body ui is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -270,7 +273,7 @@ package body ui is procedure write (text : in string; x, y : in integer; tint : in core.colour := (others => 255); size : in natural := 0; code : in boolean := false) is begin - core.write (text, x, y, tint, font (active).scale, (if code then monospace else font (active))); + core.write (text, x, y, tint, (if size = 0 then font (active).scale else size), (if code then monospace else font (active))); end write; ------------------------------------------------------------------------------------------ @@ -577,6 +580,33 @@ package body ui is core.increment (structure_array (structure_count - 1).gui_n); end add_structure_orient; + ------------------------------------------------------------------------------------------ + + procedure write_ada_code (text : in core.string_box_data; x, y : in integer) is + buffer : character := ' '; + width : constant integer := 13; + height : constant integer := 11; + length : natural := 1; + offset : core.vector := (x, y); + begin + loop + buffer := ada.strings.unbounded.element (text.text, length); + -- + exit when buffer = character'val (0); + --~exit when buffer = ';'; + -- + case buffer is + when character'val (9) => offset.x := offset.x + 2 * width; + when character'val (10) => offset.y := offset.y + 1 * height; offset.x := x; + when ':' => ui.write (buffer & "", offset.x, offset.y, ( 0, 255, 255, 255), height, code => true); + when others => ui.write (buffer & "", offset.x, offset.y, (255, 255, 255, 255), height, code => true); + end case; + -- + offset.x := offset.x + width; + length := length + 1; + end loop; + end write_ada_code; + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ end ui; diff --git a/source/ui.ads b/source/ui.ads index 0eaff7b..2c9eccf 100644 --- a/source/ui.ads +++ b/source/ui.ads @@ -85,6 +85,8 @@ package ui is procedure add_structure_button (icon : in core.sprite; text : in core.short_string; description : in core.long_string := ""); procedure add_structure_orient; + procedure write_ada_code (text : in core.string_box_data; x, y : in integer); + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ end ui;