From 19d3e1efa250e49ab0a52ce279caa03389743b3b Mon Sep 17 00:00:00 2001 From: xolatile Date: Sat, 8 Jun 2024 04:49:33 -0400 Subject: [PATCH] Fixed small stupid bug... --- source/core.adb | 2 ++ source/main.adb | 2 +- source/ui.adb | 32 ++++++++++++++++++-------------- source/ui.ads | 2 +- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/source/core.adb b/source/core.adb index 13bac0f..8a5172c 100644 --- a/source/core.adb +++ b/source/core.adb @@ -184,6 +184,8 @@ package body core is end if; end loop; -- + maximum_width := (if width > maximum_width then width else maximum_width); + -- return maximum_width; end string_width; diff --git a/source/main.adb b/source/main.adb index bd8f06b..dac4812 100644 --- a/source/main.adb +++ b/source/main.adb @@ -260,7 +260,7 @@ procedure main is end loop; end loop; -- - ui.draw_text ("Heyo world!" & character'val (10) & "Goodcyaa world!", 600, 600); + ui.draw_text ("Heyo world!" & character'val (10) & "Goodcyaa world!", 600, 600, 0, 0); end player_information; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/ui.adb b/source/ui.adb index 2ce86cc..59b4be5 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -72,7 +72,10 @@ package body ui is sprite : array (style, element) of core.sprite; - monospace : core.font; + monospace : core.font; + -- + monowidth : constant natural := 9; + monoheight : constant natural := 15; console_message_limit : constant natural := 6; console_message_count : natural := 0; @@ -106,7 +109,7 @@ package body ui is end loop; end load_ui; begin - monospace := core.import_font (core.folder & "/ui/monospace.png", 15, 0); + monospace := core.import_font (core.folder & "/ui/monospace.png", monoheight, 0); -- core.echo (core.comment, "Configuring UI components..."); -- @@ -143,7 +146,7 @@ package body ui is procedure write (text : in string; x, y : in integer; tint : in core.colour := (others => 255); size : in natural := font (active).scale; code : in boolean := false) is begin - core.write (text, x, y, tint, (if code then 15 else size), (if code then monospace else font (active))); + core.write (text, x, y, tint, (if code then monoheight else size), (if code then monospace else font (active))); end write; ------------------------------------------------------------------------------------------ @@ -324,12 +327,14 @@ package body ui is ------------------------------------------------------------------------------------------ - procedure draw_text (text : in string; x, y : in integer; tint : in core.colour := (others => 255)) is - offset : constant integer := 10; + procedure draw_text (text : in string; x, y, width, height : in integer; tint : in core.colour := (others => 255)) is + offset : constant integer := 8; + -- + new_width : constant natural := (if width < core.base then monowidth * core.string_width (text) else width); + new_height : constant natural := (if height < core.base then monoheight * core.string_height (text) else height); begin - draw_text_box (x, y, 9 * core.string_width (text) + 2 * offset, 15 * core.string_height (text) + 2 * offset); + draw_text_box (x, y, new_width + 2 * offset, new_height + 2 * offset); write (text, x + offset, y + offset, tint, code => true); - write (natural'image (core.string_width (text)) & natural'image (core.string_height (text)), x-20, y-20, tint, code => true); end draw_text; ------------------------------------------------------------------------------------------ @@ -520,19 +525,18 @@ package body ui is procedure draw_console_box (x, y, width, height : in integer) is offset : constant integer := 8; - font_width : constant integer := 9; - font_height : constant integer := 15; + font_width : constant integer := monowidth; + font_height : constant integer := monoheight; characters_per_width : constant integer := width / font_width; characters_per_height : constant integer := height / font_height; begin draw_text_box (x, y, width, height); -- for index in 0 .. console_message_limit - 1 loop - ui.write (text => core.bound (console_message_array ((index + console_message_count) mod console_message_limit)), - x => x + offset, - y => y + offset + index * font_height, - size => 15, - code => true); + write (text => core.bound (console_message_array ((index + console_message_count) mod console_message_limit)), + x => x + offset, + y => y + offset + index * font_height, + code => true); end loop; end draw_console_box; diff --git a/source/ui.ads b/source/ui.ads index 9d33903..7c89ed5 100644 --- a/source/ui.ads +++ b/source/ui.ads @@ -44,7 +44,7 @@ package ui is procedure draw_frame (description : in string; x, y, width, height : in integer; action : core.pointer := core.idle_skip'access); procedure draw_button (text, description : in string; icon : in core.sprite; x, y, width, height : in integer; action : core.pointer := core.idle_skip'access); - procedure draw_text (text : in string; x, y : in integer; tint : in core.colour := (others => 255)); + procedure draw_text (text : in string; x, y, width, height : in integer; tint : in core.colour := (others => 255)); procedure draw_check_box (x, y : in integer; on : in out boolean; text : in string);