From 2f09cb921689572ae47737c91256e3010ecb4fbe Mon Sep 17 00:00:00 2001 From: xolatile Date: Thu, 9 May 2024 02:08:01 -0400 Subject: [PATCH] Revised some Core and Ray code... --- source/core.adb | 36 +++++++++++++++++++++--------------- source/core.ads | 30 +++++++++++++++++++----------- source/main.adb | 2 +- source/ui.adb | 6 +++--- source/ui.ads | 2 +- 5 files changed, 45 insertions(+), 31 deletions(-) diff --git a/source/core.adb b/source/core.adb index 8b2d728..c535bea 100644 --- a/source/core.adb +++ b/source/core.adb @@ -183,23 +183,25 @@ package body core is ------------------------------------------------------------------------------------------ - procedure draw (data : in sprite; - x : in integer := 0; - y : in integer := 0; - u : in integer := 0; - v : in integer := 0; - width : in integer := 0; - height : in integer := 0; - state : in integer := 0; - factor : in integer := zoom; - tint : in ray.colour := (others => 255)) is + procedure draw (data : in sprite := (others => 0); + x : in integer := 0; + y : in integer := 0; + u : in integer := 0; + v : in integer := 0; + width : in integer := 0; + height : in integer := 0; + state : in integer := 0; + factor : in integer := zoom; + tint : in colour := (others => 255)) is new_width : constant float := float ((if width = 0 then data.width else width)); new_height : constant float := float ((if height = 0 then data.height else height)); + -- + new_tint : ray.colour := (ray.colour_range (tint.r), ray.colour_range (tint.g), ray.colour_range (tint.b), ray.colour_range (tint.a)); begin ray.draw_texture (data => texture_array (data.index), uv => (float (if u = 0 then (animation_time mod data.frames) * data.width else u), float (v), new_width, new_height), view => (float (x), float (y), new_width * float (factor), new_height * float (factor)), - tint => tint); + tint => new_tint); end draw; ------------------------------------------------------------------------------------------ @@ -207,13 +209,17 @@ package body core is procedure write (text : in string := ""; x : in integer := 0; y : in integer := 0; - data : in font) is + tint : in colour := (others => 255); + size : in integer := 0; + data : in font := (others => 0)) is + new_tint : ray.colour := (ray.colour_range (tint.r), ray.colour_range (tint.g), ray.colour_range (tint.b), ray.colour_range (tint.a)); begin ray.draw_text (data => font_array (data.index), text => c_string (text), - view => (float ((icon - data.scale) / 2 + x), float ((icon - data.scale) / 2 + y)), - scale => float (data.scale), - space => float (data.space)); + view => (float (x), float (y)), + scale => float ((if size = 0 then data.scale else size)), + space => float (data.space), + tint => new_tint); end write; ------------------------------------------------------------------------------------------ diff --git a/source/core.ads b/source/core.ads index eaa09a7..ea49379 100644 --- a/source/core.ads +++ b/source/core.ads @@ -27,6 +27,12 @@ package core is signal_left_control ); + type colour_range is range 0 .. 2 ** 8 - 1; + + for colour_range'size use 8; + + type colour is record r, g, b, a : colour_range; end record; + subtype short_string is string (1 .. 24); subtype long_string is string (1 .. 72); @@ -108,21 +114,23 @@ package core is function import_font (file_path : in string; scale, space : in integer) return font; function import_song (file_path : in string) return song; - procedure draw (data : in sprite; - x : in integer := 0; - y : in integer := 0; - u : in integer := 0; - v : in integer := 0; - width : in integer := 0; - height : in integer := 0; - state : in integer := 0; - factor : in integer := zoom; - tint : in ray.colour := (others => 255)); + procedure draw (data : in sprite := (others => 0); + x : in integer := 0; + y : in integer := 0; + u : in integer := 0; + v : in integer := 0; + width : in integer := 0; + height : in integer := 0; + state : in integer := 0; + factor : in integer := zoom; + tint : in colour := (others => 255)); procedure write (text : in string := ""; x : in integer := 0; y : in integer := 0; - data : in font); + tint : in colour := (others => 255); + size : in integer := 0; + data : in font := (others => 0)); procedure play (index : in integer); procedure stop (index : in integer); diff --git a/source/main.adb b/source/main.adb index 0a78501..33b709a 100644 --- a/source/main.adb +++ b/source/main.adb @@ -105,7 +105,7 @@ procedure main is procedure introduction is begin - ui.write ("[-- Please press Spacebar to continue]", 0, 0); + ui.write ("[-- Please press Spacebar to continue]", 0, 0, 14, (102, 102, 102, 255)); end introduction; ------------------------------------------------------------------------------------------ diff --git a/source/ui.adb b/source/ui.adb index ee7b236..78f9c21 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -230,9 +230,9 @@ package body ui is ------------------------------------------------------------------------------------------ - procedure write (text : in string; x, y : in integer) is + procedure write (text : in string; x, y : in integer; size : in natural := 0; tint : in core.colour := (others => 255)) is begin - core.write (text, x, y, font (active)); + core.write (text, x, y, tint, font (active).scale, font (active)); end write; ------------------------------------------------------------------------------------------ @@ -311,7 +311,7 @@ package body ui is draw (text_lower_left, x, y + height - offset); draw (text_lower_right, x + width - offset, y + height - offset); -- - core.write (core.read_text_box, x, y, font (active)); + write (core.read_text_box, x, y); end draw_help_box; ------------------------------------------------------------------------------------------ diff --git a/source/ui.ads b/source/ui.ads index ed8b8f4..6de346e 100644 --- a/source/ui.ads +++ b/source/ui.ads @@ -54,7 +54,7 @@ package ui is procedure configure; procedure synchronize; - procedure write (text : in string; x, y : in integer); + procedure write (text : in string; x, y : in integer; size : in natural := 0; tint : in core.colour := (others => 255)); procedure draw_icon (data : in core.sprite; description : in string; x, y : in integer; action : core.pointer := core.idle'access); procedure draw_overicon (data : in core.sprite; description : in string; x, y : in integer; action : core.pointer := core.idle'access);