Adding draw_text procedure and text size...
This commit is contained in:
parent
6d775711a5
commit
788c821605
@ -53,6 +53,8 @@ package chad is
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
-- Knight Cleric Ranger Druid Alchemist Wizard Heretic Demoniac Necromancer Death-Knight Overlord Warlock Barbarian Battlemage Beast-Tamer Witch
|
||||
|
||||
count : constant natural := enumeration'pos (enumeration'last) + 1;
|
||||
|
||||
description : constant array (enumeration) of definition := (
|
||||
|
@ -171,6 +171,38 @@ package body core is
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
function string_width (data : in string) return natural is
|
||||
maximum_width : natural := 0;
|
||||
width : natural := 0;
|
||||
begin
|
||||
for index in data'range loop
|
||||
width := width + 1;
|
||||
--
|
||||
if data (index) = character'val (10) then
|
||||
maximum_width := (if width > maximum_width then width - 1 else maximum_width);
|
||||
width := 0;
|
||||
end if;
|
||||
end loop;
|
||||
--
|
||||
return maximum_width;
|
||||
end string_width;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
function string_height (data : in string) return natural is
|
||||
height : natural := 0;
|
||||
begin
|
||||
for index in data'range loop
|
||||
if data (index) = character'val (10) then
|
||||
height := height + 1;
|
||||
end if;
|
||||
end loop;
|
||||
--
|
||||
return height + 1;
|
||||
end string_height;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
function random (minimum, maximum : in integer) return integer is
|
||||
begin
|
||||
return ray.get_random (minimum, maximum);
|
||||
|
@ -140,7 +140,10 @@ package core is
|
||||
|
||||
function c_string (ada_string : in string) return string;
|
||||
|
||||
function random (minimum, maximum : in integer) return integer;
|
||||
function string_width (data : in string) return natural;
|
||||
function string_height (data : in string) return natural;
|
||||
|
||||
function random (minimum, maximum : in integer) return integer;
|
||||
|
||||
procedure clip (value : in out integer; minimum, maximum : in integer);
|
||||
|
||||
|
@ -259,6 +259,8 @@ procedure main is
|
||||
y => at_y + index_y * core.icon);
|
||||
end loop;
|
||||
end loop;
|
||||
--
|
||||
ui.draw_text ("Heyo world!" & character'val (10) & "Goodcyaa world!", 600, 600);
|
||||
end player_information;
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -324,6 +324,16 @@ 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;
|
||||
begin
|
||||
draw_text_box (x, y, 9 * core.string_width (text) + 2 * offset, 15 * core.string_height (text) + 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;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure draw_check_box (x, y : in integer; on : in out boolean; text : in string) is
|
||||
begin
|
||||
draw ((if on then check_box_on else check_box_off), x, y);
|
||||
|
@ -44,6 +44,8 @@ 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_check_box (x, y : in integer; on : in out boolean; text : in string);
|
||||
|
||||
procedure draw_title_bar (x, y, width : in integer; title : in string);
|
||||
|
Loading…
Reference in New Issue
Block a user