Fixed small stupid bug...

This commit is contained in:
Ognjen Milan Robovic 2024-06-08 04:49:33 -04:00
parent 788c821605
commit 19d3e1efa2
4 changed files with 22 additions and 16 deletions

View File

@ -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;

View File

@ -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;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -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;

View File

@ -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);