From 6cedff3ff82abaec7154f064e836ac198948ea7d Mon Sep 17 00:00:00 2001 From: xolatile Date: Mon, 27 May 2024 14:38:56 -0400 Subject: [PATCH] Refactored UI package... --- source/main.adb | 2 -- source/ui.adb | 39 +++++++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/source/main.adb b/source/main.adb index be320d6..55c0356 100644 --- a/source/main.adb +++ b/source/main.adb @@ -313,8 +313,6 @@ begin --~magic.menu (0, 0, true); --~might.menu (0, 0, true); -- - --~chad.draw_alice; - -- --~deity.draw (deity.AEZORA, 300, 300); --~deity.draw (deity.ULDRAE, 500, 300); -- diff --git a/source/ui.adb b/source/ui.adb index 4c17240..4ca3a62 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -5,9 +5,9 @@ with core; with ada.strings.unbounded; -use ada.strings.unbounded; use type core.cursor_code; +use type ada.strings.unbounded.unbounded_string; package body ui is @@ -608,29 +608,36 @@ package body ui is ------------------------------------------------------------------------------------------ procedure add_structure_button (icon : in core.sprite; name : in core.short_string; text : in core.long_string := "") is + index : natural renames structure_array (structure_count - 1).gui_n; begin - structure_array (structure_count - 1).gui_list (structure_array (structure_count - 1).gui_n).kind := gui_button; - structure_array (structure_count - 1).gui_list (structure_array (structure_count - 1).gui_n).text := name; - structure_array (structure_count - 1).gui_list (structure_array (structure_count - 1).gui_n).info := text; - structure_array (structure_count - 1).gui_list (structure_array (structure_count - 1).gui_n).number := 0; - structure_array (structure_count - 1).gui_list (structure_array (structure_count - 1).gui_n).image := icon; + structure_array (structure_count - 1).gui_list (index).kind := gui_button; + structure_array (structure_count - 1).gui_list (index).text := name; + structure_array (structure_count - 1).gui_list (index).info := text; + structure_array (structure_count - 1).gui_list (index).number := 0; + structure_array (structure_count - 1).gui_list (index).image := icon; + --~structure_array (structure_count - 1).gui_list (structure_array (structure_count - 1).gui_n).kind := gui_button; + --~structure_array (structure_count - 1).gui_list (structure_array (structure_count - 1).gui_n).text := name; + --~structure_array (structure_count - 1).gui_list (structure_array (structure_count - 1).gui_n).info := text; + --~structure_array (structure_count - 1).gui_list (structure_array (structure_count - 1).gui_n).number := 0; + --~structure_array (structure_count - 1).gui_list (structure_array (structure_count - 1).gui_n).image := icon; -- - core.increment (structure_array (structure_count - 1).gui_n); + core.increment (index); end add_structure_button; ------------------------------------------------------------------------------------------ procedure add_structure_orient is + index : natural renames structure_array (structure_count - 1).gui_n; begin - structure_array (structure_count - 1).gui_list (structure_array (structure_count - 1).gui_n).kind := gui_orient; + structure_array (structure_count - 1).gui_list (index).kind := gui_orient; -- - core.increment (structure_array (structure_count - 1).gui_n); + core.increment (index); end add_structure_orient; ------------------------------------------------------------------------------------------ procedure write_ada_code (text : in core.string_box_data; x, y : in integer) is - word : unbounded_string := to_unbounded_string (""); + word : ada.strings.unbounded.unbounded_string := ada.strings.unbounded.to_unbounded_string (""); -- buffer : character := ' '; width : constant integer := 9; @@ -640,7 +647,7 @@ package body ui is subset : natural := 0; begin loop - buffer := ada.strings.unbounded.element (text.text, length); + buffer := ada.strings.unbounded.element (text.text, length); offset.x := offset.x + width; -- exit when buffer = character'val (0); @@ -690,13 +697,13 @@ package body ui is end loop; core.decrement (length); when 'a' .. 'z' | 'A' .. 'Z' => - word := to_unbounded_string (buffer & ""); + word := ada.strings.unbounded.to_unbounded_string (buffer & ""); subset := 1; loop buffer := ada.strings.unbounded.element (text.text, length + subset); exit when buffer = ' ' or buffer = '.' or buffer = '(' or buffer = ')' or buffer = ',' or buffer = ';' or buffer = ''' or buffer = character'val (9) or buffer = character'val (10); - word := word & to_unbounded_string (buffer & ""); + word := word & ada.strings.unbounded.to_unbounded_string (buffer & ""); core.increment (subset); end loop; if word = "type" or word = "begin" or word = "end" or word = "when" or word = "others" or word = "procedure" or word = "function" @@ -704,10 +711,10 @@ package body ui is or word = "and" or word = "or" or word = "xor" or word = "exit" or word = "constant" or word = "access" or word = "range" or word = "subtype" or word = "array" or word = "in" or word = "out" or word = "return" or word = "for" or word = "with" or word = "loop" or word = "while" or word = "of" or word = "null" or word = "record" or word = "use" or word = "mod" or word = "new" - or word = "aliased" then - ui.write (to_string (word), offset.x, offset.y, (255, 255, 0, 255), height, code => true); + or word = "aliased" or word = "all" then + ui.write (ada.strings.unbounded.to_string (word), offset.x, offset.y, (255, 255, 0, 255), height, code => true); else - ui.write (to_string (word), offset.x, offset.y, (others => 255), height, code => true); + ui.write (ada.strings.unbounded.to_string (word), offset.x, offset.y, (others => 255), height, code => true); end if; offset.x := offset.x + (subset - 1) * width; length := length + subset - 1;