2024-04-25 00:27:13 -04:00
|
|
|
-- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic
|
|
|
|
--
|
|
|
|
-- GNU General Public Licence (version 3 or later)
|
|
|
|
|
2024-05-08 15:43:44 -04:00
|
|
|
with core;
|
2024-02-15 21:03:09 -05:00
|
|
|
|
2024-05-13 04:03:27 -04:00
|
|
|
with ada.strings.unbounded;
|
|
|
|
use ada.strings.unbounded;
|
|
|
|
|
2024-02-15 21:03:09 -05:00
|
|
|
package body ui is
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
2024-04-27 12:34:16 -04:00
|
|
|
type element is (
|
|
|
|
none,
|
|
|
|
main_background,
|
2024-04-27 13:57:30 -04:00
|
|
|
--
|
|
|
|
corner_upper_left, border_upper, corner_upper_right,
|
|
|
|
border_left, border_right,
|
|
|
|
corner_lower_left, border_lower, corner_lower_right,
|
|
|
|
--
|
|
|
|
tiny_corner_upper_left, tiny_border_upper, tiny_corner_upper_right,
|
|
|
|
tiny_border_left, tiny_border_right,
|
|
|
|
tiny_corner_lower_left, tiny_border_lower, tiny_corner_lower_right,
|
|
|
|
--
|
2024-04-27 12:34:16 -04:00
|
|
|
frame_upper_left, frame_upper, frame_upper_right,
|
|
|
|
frame_left, frame_middle, frame_right,
|
|
|
|
frame_lower_left, frame_lower, frame_lower_right,
|
2024-04-27 13:57:30 -04:00
|
|
|
--
|
2024-04-27 12:34:16 -04:00
|
|
|
icon_upper_left, icon_upper, icon_upper_right,
|
|
|
|
icon_left, icon_right,
|
|
|
|
icon_lower_left, icon_lower, icon_lower_right,
|
2024-04-27 13:57:30 -04:00
|
|
|
--
|
2024-04-27 12:34:16 -04:00
|
|
|
text_upper_left, text_upper, text_upper_right,
|
|
|
|
text_left, text_middle, text_right,
|
|
|
|
text_lower_left, text_lower, text_lower_right,
|
2024-04-27 13:57:30 -04:00
|
|
|
--
|
2024-05-04 08:40:03 -04:00
|
|
|
cursor, icon, overicon, icon_selected,
|
2024-04-27 13:57:30 -04:00
|
|
|
--
|
2024-04-27 12:34:16 -04:00
|
|
|
fill_bar_left, fill_bar_horizontal, fill_bar_right, fill_horizontal,
|
2024-05-16 10:13:08 -04:00
|
|
|
tiny_fill_bar_left, tiny_fill_bar_horizontal, tiny_fill_bar_right, tiny_fill_horizontal,
|
2024-04-27 13:57:30 -04:00
|
|
|
--
|
2024-04-27 12:34:16 -04:00
|
|
|
scroll_bar_lower, scroll_bar_middle, scroll_bar_upper,
|
2024-04-27 13:57:30 -04:00
|
|
|
--
|
2024-05-09 11:28:40 -04:00
|
|
|
title_bar_left, title_bar_middle, title_bar_right,
|
|
|
|
--
|
|
|
|
check_box_on, check_box_off
|
2024-04-27 12:34:16 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-07 09:59:26 -04:00
|
|
|
type rectangle is record
|
|
|
|
x, y, width, height : integer;
|
|
|
|
end record;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-01 09:55:56 -04:00
|
|
|
structure_limit : constant natural := 12;
|
|
|
|
|
2024-05-09 02:43:09 -04:00
|
|
|
font_tint : array (style) of core.colour := (
|
2024-05-13 13:20:33 -04:00
|
|
|
main => (127, 127, 127, 255),
|
|
|
|
fairy => ( 0, 127, 255, 255),
|
|
|
|
dwarf => (127, 255, 255, 255),
|
|
|
|
gnoll => (255, 255, 0, 255),
|
|
|
|
kobold => (255, 127, 255, 255),
|
|
|
|
goblin => ( 0, 255, 127, 255),
|
|
|
|
imp => (255, 127, 0, 255)
|
2024-05-09 02:43:09 -04:00
|
|
|
);
|
|
|
|
|
2024-04-27 12:34:16 -04:00
|
|
|
sprite : array (style, element) of core.sprite;
|
2024-04-30 23:17:05 -04:00
|
|
|
font : array (style) of core.font;
|
2024-04-23 16:19:29 -04:00
|
|
|
|
2024-05-01 09:55:56 -04:00
|
|
|
structure_array : array (0 .. structure_limit) of structure;
|
2024-05-01 09:15:38 -04:00
|
|
|
|
|
|
|
structure_count : natural := 0;
|
|
|
|
|
2024-05-12 11:12:52 -04:00
|
|
|
monospace : core.font;
|
|
|
|
|
2024-04-23 16:19:29 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-01 07:24:10 -04:00
|
|
|
procedure draw (index : in element := none;
|
|
|
|
x : in integer := 0;
|
|
|
|
y : in integer := 0;
|
|
|
|
width : in integer := 0;
|
2024-05-01 07:38:47 -04:00
|
|
|
height : in integer := 0) is
|
2024-02-15 21:03:09 -05:00
|
|
|
begin
|
2024-05-16 12:35:36 -04:00
|
|
|
core.draw (sprite (active, index), x, y, 0, 0, width, height, factor => 1);
|
2024-04-28 17:18:14 -04:00
|
|
|
end draw;
|
2024-02-15 21:03:09 -05:00
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-09 05:07:20 -04:00
|
|
|
procedure draw_horizontally (index : in element; x, y, width : in integer; action : core.pointer := core.idle_skip'access) is
|
2024-02-15 21:03:09 -05:00
|
|
|
begin
|
2024-05-16 12:35:36 -04:00
|
|
|
core.draw_horizontally (sprite (active, index), x, y, width, factor => 1);
|
2024-05-01 07:38:47 -04:00
|
|
|
--
|
2024-05-11 06:01:07 -04:00
|
|
|
--~if core.cursor_mode = 1 and cursor_inside (x, y, width / core.zoom, sprite (active, index).height / core.zoom) then
|
2024-05-03 06:49:12 -04:00
|
|
|
--~action.all;
|
|
|
|
--~core.cursor_mode := 0;
|
|
|
|
--~end if;
|
2024-02-15 21:03:09 -05:00
|
|
|
end draw_horizontally;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-09 05:07:20 -04:00
|
|
|
procedure draw_vertically (index : in element; x, y, height : in integer; action : core.pointer := core.idle_skip'access) is
|
2024-02-15 21:03:09 -05:00
|
|
|
begin
|
2024-05-16 12:35:36 -04:00
|
|
|
core.draw_vertically (sprite (active, index), x, y, height, factor => 1);
|
2024-05-01 07:38:47 -04:00
|
|
|
--
|
2024-05-11 06:01:07 -04:00
|
|
|
--~if core.cursor_mode = 1 and cursor_inside (x, y, sprite (active, index).width / core.zoom, height / core.zoom) then
|
2024-05-03 06:49:12 -04:00
|
|
|
--~action.all;
|
|
|
|
--~core.cursor_mode := 0;
|
|
|
|
--~end if;
|
2024-02-15 21:03:09 -05:00
|
|
|
end draw_vertically;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-09 05:07:20 -04:00
|
|
|
procedure draw_background (index : in element; x, y, width, height : in integer; action : core.pointer := core.idle_skip'access) is
|
2024-02-18 10:21:56 -05:00
|
|
|
base_width : integer := sprite (active, index).width;
|
|
|
|
base_height : integer := sprite (active, index).height;
|
|
|
|
crop_width : integer := width mod base_width;
|
|
|
|
crop_height : integer := height mod base_height;
|
2024-02-15 21:03:09 -05:00
|
|
|
begin
|
2024-04-27 10:01:54 -04:00
|
|
|
for move_y in 0 .. height / base_height - 1 loop
|
|
|
|
for move_x in 0 .. width / base_width - 1 loop
|
2024-05-01 07:38:47 -04:00
|
|
|
draw (index, x + move_x * base_width, y + move_y * base_height);
|
2024-02-15 21:03:09 -05:00
|
|
|
end loop;
|
|
|
|
--
|
2024-04-27 13:05:44 -04:00
|
|
|
if width mod base_width > 0 then
|
2024-05-01 07:38:47 -04:00
|
|
|
draw (index, x + width - crop_width, y + move_y * base_height, crop_width, base_height);
|
2024-04-27 13:05:44 -04:00
|
|
|
end if;
|
2024-02-15 21:03:09 -05:00
|
|
|
end loop;
|
|
|
|
--
|
2024-04-27 10:01:54 -04:00
|
|
|
for move_x in 0 .. width / base_width - 1 loop
|
2024-04-27 13:05:44 -04:00
|
|
|
if height mod base_height > 0 then
|
2024-05-01 07:38:47 -04:00
|
|
|
draw (index, x + move_x * base_width, y + height - crop_height, base_width, crop_height);
|
2024-04-27 13:05:44 -04:00
|
|
|
end if;
|
2024-02-15 21:03:09 -05:00
|
|
|
end loop;
|
|
|
|
--
|
2024-04-27 13:05:44 -04:00
|
|
|
if width mod base_width > 0 and height mod base_height > 0 then
|
2024-05-01 07:38:47 -04:00
|
|
|
draw (index, x + width - crop_width, y + height - crop_height, crop_width, crop_height);
|
2024-04-27 13:05:44 -04:00
|
|
|
end if;
|
2024-02-15 21:03:09 -05:00
|
|
|
end draw_background;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-11 06:01:07 -04:00
|
|
|
procedure draw_text_box is
|
|
|
|
width : constant integer := 320;
|
|
|
|
height : constant integer := core.icon;
|
|
|
|
middle : constant integer := sprite (active, text_middle).width;
|
|
|
|
offset : constant integer := 16;
|
|
|
|
begin
|
|
|
|
draw_background (text_middle, core.cursor.x + middle + offset, core.cursor.y + middle + offset, width - 2 * middle, height - 2 * middle);
|
|
|
|
--
|
|
|
|
draw_horizontally (text_upper, core.cursor.x + middle + offset, core.cursor.y + offset, width - 2 * middle);
|
|
|
|
draw_horizontally (text_lower, core.cursor.x + middle + offset, core.cursor.y + height - middle + offset, width - 2 * middle);
|
|
|
|
draw_vertically (text_left, core.cursor.x + offset, core.cursor.y + middle + offset, height - 2 * middle);
|
|
|
|
draw_vertically (text_right, core.cursor.x + width - middle + offset, core.cursor.y + middle + offset, height - 2 * middle);
|
|
|
|
--
|
|
|
|
draw (text_upper_left, core.cursor.x + offset, core.cursor.y + offset);
|
|
|
|
draw (text_upper_right, core.cursor.x + width - middle + offset, core.cursor.y + offset);
|
|
|
|
draw (text_lower_left, core.cursor.x + offset, core.cursor.y + height - middle + offset);
|
|
|
|
draw (text_lower_right, core.cursor.x + width - middle + offset, core.cursor.y + height - middle + offset);
|
|
|
|
--
|
|
|
|
write (core.read_text_box, core.cursor.x + 4 + offset, core.cursor.y + 6 + offset);
|
|
|
|
end draw_text_box;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-03 08:37:14 -04:00
|
|
|
procedure draw_structure (data : in structure) is
|
2024-05-07 09:59:26 -04:00
|
|
|
offset : constant integer := core.icon / 4;
|
|
|
|
orients : natural := 0;
|
|
|
|
--
|
|
|
|
frame_data : rectangle := (others => 0);
|
|
|
|
button_data : rectangle := (others => 0);
|
2024-05-01 09:15:38 -04:00
|
|
|
begin
|
2024-05-07 09:59:26 -04:00
|
|
|
for index in 0 .. data.gui_n - 1 loop
|
|
|
|
if data.gui_list (index).kind = gui_orient then
|
|
|
|
orients := orients + 1;
|
|
|
|
end if;
|
|
|
|
end loop;
|
|
|
|
--
|
|
|
|
frame_data.width := (if data.resize then 320 else data.width) * (orients + 1) - offset * orients;
|
|
|
|
frame_data.height := (if data.resize then data.gui_n * (core.icon + 2 * offset) + 2 * core.icon else data.height) / (orients + 1) + offset * orients;
|
|
|
|
frame_data.x := (if data.center then (core.window_width - frame_data.width) / 2 else data.x);
|
|
|
|
frame_data.y := (if data.center then (core.window_height - frame_data.height) / 2 else data.y);
|
|
|
|
button_data.width := frame_data.width / (orients + 1) - 2 * core.icon;
|
|
|
|
button_data.height := core.icon + 2 * offset;
|
|
|
|
button_data.x := frame_data.x + core.icon;
|
|
|
|
button_data.y := frame_data.y + core.icon;
|
|
|
|
--
|
|
|
|
draw_tiny_menu (frame_data.x, frame_data.y, frame_data.width, frame_data.height);
|
|
|
|
draw_title_bar (frame_data.x, frame_data.y, frame_data.width, data.title);
|
2024-05-03 07:55:17 -04:00
|
|
|
--
|
2024-05-03 08:16:50 -04:00
|
|
|
for x in 0 .. data.gui_n - 1 loop
|
2024-05-03 07:55:17 -04:00
|
|
|
case data.gui_list (x).kind is
|
|
|
|
when gui_button =>
|
2024-05-09 11:03:39 -04:00
|
|
|
draw_button (text => data.gui_list (x).text,
|
|
|
|
description => data.gui_list (x).info,
|
|
|
|
icon => data.gui_list (x).image,
|
|
|
|
x => button_data.x,
|
|
|
|
y => button_data.y,
|
|
|
|
width => button_data.width,
|
|
|
|
height => button_data.height);
|
2024-05-08 18:34:49 -04:00
|
|
|
--
|
2024-05-07 09:59:26 -04:00
|
|
|
button_data.y := button_data.y + button_data.height;
|
2024-05-07 09:06:08 -04:00
|
|
|
when gui_orient =>
|
2024-05-07 09:59:26 -04:00
|
|
|
button_data.x := button_data.x + frame_data.width / (orients + 1) - 2 * core.icon + offset;
|
|
|
|
button_data.y := frame_data.y + core.icon;
|
2024-05-03 08:37:14 -04:00
|
|
|
when others => null;
|
2024-05-03 07:55:17 -04:00
|
|
|
end case;
|
|
|
|
end loop;
|
2024-05-07 09:59:26 -04:00
|
|
|
--
|
|
|
|
if orients > 0 then
|
|
|
|
draw_scroll_bar (frame_data.x + frame_data.width - 2 * core.icon, frame_data.y + core.icon, frame_data.height - 2 * core.icon, 4);
|
|
|
|
end if;
|
2024-05-01 09:15:38 -04:00
|
|
|
end draw_structure;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-03-10 16:41:31 -04:00
|
|
|
procedure configure is
|
|
|
|
procedure load_ui (index : in style; folder_path : in string) is
|
|
|
|
begin
|
2024-04-30 23:17:05 -04:00
|
|
|
font (index) := core.import_font ("./sprite/ui/" & folder_path & "/font.png", 24, 0);
|
2024-03-14 14:40:05 -04:00
|
|
|
--
|
2024-04-27 12:34:16 -04:00
|
|
|
for this in element loop
|
2024-04-30 19:58:38 -04:00
|
|
|
sprite (index, this) := core.import_sprite ("./sprite/ui/" & folder_path & "/" & core.lowercase (element'image (this)) & ".png", 1, 1);
|
2024-03-10 16:41:31 -04:00
|
|
|
end loop;
|
|
|
|
end load_ui;
|
|
|
|
begin
|
2024-05-13 07:40:23 -04:00
|
|
|
monospace := core.import_font ("./sprite/ui/monospace.png", 15, 0);
|
2024-05-12 11:12:52 -04:00
|
|
|
--
|
2024-03-11 08:42:25 -04:00
|
|
|
core.echo (core.comment, "Configuring UI components...");
|
|
|
|
--
|
2024-04-30 19:58:38 -04:00
|
|
|
for index in style loop
|
|
|
|
load_ui (index, core.lowercase (style'image (index)));
|
|
|
|
end loop;
|
2024-03-10 16:41:31 -04:00
|
|
|
end configure;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-01 09:15:38 -04:00
|
|
|
procedure synchronize is
|
2024-05-08 16:45:08 -04:00
|
|
|
use core;
|
2024-05-01 09:15:38 -04:00
|
|
|
begin
|
2024-05-09 03:53:38 -04:00
|
|
|
prioritize := false;
|
|
|
|
--
|
2024-05-03 08:37:14 -04:00
|
|
|
for index in 0 .. structure_count - 1 loop
|
2024-05-08 16:45:08 -04:00
|
|
|
if signal_mode = structure_array (index).toggle then
|
|
|
|
structure_array (index).show := not structure_array (index).show;
|
2024-05-01 09:26:06 -04:00
|
|
|
end if;
|
|
|
|
--
|
2024-05-01 09:15:38 -04:00
|
|
|
if structure_array (index).show then
|
|
|
|
draw_structure (structure_array (index));
|
2024-05-09 03:53:38 -04:00
|
|
|
--
|
|
|
|
prioritize := true;
|
2024-05-01 09:15:38 -04:00
|
|
|
end if;
|
|
|
|
end loop;
|
2024-05-11 06:01:07 -04:00
|
|
|
--
|
|
|
|
if read_text_box /= "--" then
|
|
|
|
draw_text_box;
|
|
|
|
end if;
|
|
|
|
--
|
|
|
|
core.write_text_box ("--");
|
2024-05-01 09:15:38 -04:00
|
|
|
end synchronize;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-12 11:12:52 -04:00
|
|
|
procedure write (text : in string; x, y : in integer; tint : in core.colour := (others => 255); size : in natural := 0; code : in boolean := false) is
|
2024-05-01 09:15:38 -04:00
|
|
|
begin
|
2024-05-13 04:03:27 -04:00
|
|
|
core.write (text, x, y, tint, (if size = 0 then font (active).scale else size), (if code then monospace else font (active)));
|
2024-05-01 09:15:38 -04:00
|
|
|
end write;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-11 00:42:24 -04:00
|
|
|
procedure draw_icon (data : in core.sprite; text : in string; x, y : in integer; action : core.pointer := core.idle_skip'access) is
|
2024-04-27 13:57:30 -04:00
|
|
|
save_zoom : natural := core.zoom;
|
2024-03-10 16:41:31 -04:00
|
|
|
begin
|
2024-05-01 07:38:47 -04:00
|
|
|
draw (icon, x, y);
|
2024-04-27 12:34:16 -04:00
|
|
|
--
|
2024-04-27 03:49:02 -04:00
|
|
|
core.zoom := 1;
|
2024-04-25 09:26:08 -04:00
|
|
|
core.draw (data, x, y);
|
2024-04-27 13:57:30 -04:00
|
|
|
core.zoom := save_zoom;
|
2024-05-01 07:38:47 -04:00
|
|
|
--
|
2024-05-11 06:01:07 -04:00
|
|
|
if core.cursor_inside (x, y, core.icon / core.zoom, core.icon / core.zoom) then
|
2024-05-12 11:08:32 -04:00
|
|
|
prioritize := true;
|
|
|
|
--
|
2024-05-04 08:40:03 -04:00
|
|
|
draw (icon_selected, x, y);
|
2024-05-04 09:17:56 -04:00
|
|
|
--
|
2024-05-11 06:01:07 -04:00
|
|
|
core.write_help_box (text);
|
2024-05-04 09:17:56 -04:00
|
|
|
--
|
2024-05-04 08:40:03 -04:00
|
|
|
if core.cursor_mode = 1 then
|
|
|
|
action.all;
|
|
|
|
core.cursor_mode := 0;
|
|
|
|
end if;
|
2024-05-01 07:38:47 -04:00
|
|
|
end if;
|
2024-03-10 16:41:31 -04:00
|
|
|
end draw_icon;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
2024-03-11 12:50:29 -04:00
|
|
|
|
2024-05-11 00:42:24 -04:00
|
|
|
procedure draw_overicon (data : in core.sprite; text : in string; x, y : in integer; action : core.pointer := core.idle_skip'access) is
|
2024-04-27 13:57:30 -04:00
|
|
|
save_zoom : natural := core.zoom;
|
2024-03-11 12:50:29 -04:00
|
|
|
begin
|
2024-04-27 12:34:16 -04:00
|
|
|
core.zoom := 1;
|
|
|
|
core.draw (data, x, y);
|
2024-04-27 13:57:30 -04:00
|
|
|
core.zoom := save_zoom;
|
2024-04-27 12:34:16 -04:00
|
|
|
--
|
2024-05-01 07:38:47 -04:00
|
|
|
draw (overicon, x, y);
|
2024-03-11 12:50:29 -04:00
|
|
|
end draw_overicon;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
2024-03-10 16:41:31 -04:00
|
|
|
|
2024-05-16 10:43:39 -04:00
|
|
|
procedure draw_sprite (data : in core.sprite; text : in string; x, y, offset : in integer; action : core.pointer := core.idle_skip'access) is
|
|
|
|
begin
|
|
|
|
core.draw (data, x + offset, y + offset, factor => 1);
|
|
|
|
--
|
|
|
|
draw_icon_menu (x, y, data.width + 2 * offset, data.height + 2 * offset);
|
|
|
|
--
|
|
|
|
if core.cursor_inside (x, y, data.width + 2 * offset, data.height + 2 * offset) then
|
|
|
|
prioritize := true;
|
|
|
|
--
|
|
|
|
core.write_help_box (text);
|
|
|
|
--
|
|
|
|
if core.cursor_mode = 1 then
|
|
|
|
action.all;
|
|
|
|
core.cursor_mode := 0;
|
|
|
|
end if;
|
|
|
|
end if;
|
|
|
|
end draw_sprite;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-09 05:07:20 -04:00
|
|
|
procedure draw_help_box (x, y, width, height : in integer; action : core.pointer := core.idle_skip'access) is
|
2024-03-14 06:06:22 -04:00
|
|
|
offset : constant integer := sprite (active, text_middle).width;
|
2024-03-13 14:07:17 -04:00
|
|
|
begin
|
2024-05-12 11:08:32 -04:00
|
|
|
if core.cursor_inside (x, y, width, height) then
|
|
|
|
prioritize := true;
|
|
|
|
end if;
|
|
|
|
--
|
2024-05-01 07:38:47 -04:00
|
|
|
draw_background (text_middle, x + offset, y + offset, width - 2 * offset, height - 2 * offset);
|
2024-03-13 14:07:17 -04:00
|
|
|
--
|
2024-05-01 07:38:47 -04:00
|
|
|
draw_horizontally (text_upper, x + offset, y, width - 2 * offset);
|
|
|
|
draw_horizontally (text_lower, x + offset, y + height - offset, width - 2 * offset);
|
|
|
|
draw_vertically (text_left, x, y + offset, height - 2 * offset);
|
|
|
|
draw_vertically (text_right, x + width - offset, y + offset, height - 2 * offset);
|
2024-03-13 14:07:17 -04:00
|
|
|
--
|
2024-05-01 07:38:47 -04:00
|
|
|
draw (text_upper_left, x, y);
|
|
|
|
draw (text_upper_right, x + width - offset, y);
|
|
|
|
draw (text_lower_left, x, y + height - offset);
|
|
|
|
draw (text_lower_right, x + width - offset, y + height - offset);
|
2024-03-13 14:07:17 -04:00
|
|
|
--
|
2024-05-11 06:01:07 -04:00
|
|
|
write (core.read_help_box, (core.icon - font (active).scale) / 2 + x + 4, (core.icon - font (active).scale) / 2 + y);
|
2024-05-11 03:20:04 -04:00
|
|
|
--
|
2024-05-11 06:01:07 -04:00
|
|
|
core.write_help_box ("--");
|
2024-05-01 09:15:38 -04:00
|
|
|
end draw_help_box;
|
2024-03-13 14:07:17 -04:00
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-09 05:07:20 -04:00
|
|
|
procedure draw_frame (description : in string; x, y, width, height : in integer; action : core.pointer := core.idle_skip'access) is
|
2024-02-15 21:03:09 -05:00
|
|
|
offset_x : constant integer := sprite (active, frame_middle).width;
|
|
|
|
offset_y : constant integer := sprite (active, frame_middle).height;
|
|
|
|
begin
|
2024-03-10 16:41:31 -04:00
|
|
|
if height < core.icon or width < core.icon then
|
2024-02-16 09:59:19 -05:00
|
|
|
return;
|
|
|
|
end if;
|
2024-02-19 17:17:19 -05:00
|
|
|
--
|
2024-05-01 07:38:47 -04:00
|
|
|
draw_background (frame_middle, x + offset_x, y + offset_y, width - 2 * offset_x, height - 2 * offset_y);
|
2024-02-15 21:03:09 -05:00
|
|
|
--
|
2024-05-01 07:38:47 -04:00
|
|
|
draw_horizontally (frame_upper, x + offset_x, y, width - 2 * offset_x);
|
|
|
|
draw_horizontally (frame_lower, x + offset_x, y + height - offset_y, width - 2 * offset_x);
|
|
|
|
draw_vertically (frame_left, x, y + offset_y, height - 2 * offset_y);
|
|
|
|
draw_vertically (frame_right, x + width - offset_x, y + offset_y, height - 2 * offset_y);
|
2024-02-15 21:03:09 -05:00
|
|
|
--
|
2024-05-01 07:38:47 -04:00
|
|
|
draw (frame_upper_left, x, y);
|
|
|
|
draw (frame_upper_right, x + width - sprite (active, frame_upper_right).width, y);
|
|
|
|
draw (frame_lower_left, x, y + height - sprite (active, frame_lower_left).height);
|
|
|
|
draw (frame_lower_right, x + width - sprite (active, frame_lower_right).width, y + height - sprite (active, frame_lower_right).height);
|
2024-05-09 11:03:39 -04:00
|
|
|
--
|
2024-05-11 06:01:07 -04:00
|
|
|
if core.cursor_inside (x, y, width / core.zoom, height / core.zoom) then
|
2024-05-12 11:08:32 -04:00
|
|
|
prioritize := true;
|
|
|
|
--
|
2024-05-11 06:01:07 -04:00
|
|
|
core.write_help_box (description);
|
2024-05-09 11:03:39 -04:00
|
|
|
--
|
|
|
|
if core.cursor_mode = 1 then
|
|
|
|
action.all;
|
|
|
|
core.cursor_mode := 0;
|
|
|
|
end if;
|
|
|
|
end if;
|
2024-02-15 21:03:09 -05:00
|
|
|
end draw_frame;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-09 11:03:39 -04:00
|
|
|
procedure draw_button (text, description : in string; icon : in core.sprite; x, y, width, height : in integer; action : core.pointer := core.idle_skip'access) is
|
|
|
|
offset : constant integer := core.icon / 4;
|
|
|
|
begin
|
|
|
|
draw_frame (description, x, y, width, height);
|
|
|
|
draw_icon (icon, description, x + offset, y + offset);
|
|
|
|
--
|
|
|
|
write (text,
|
|
|
|
x + offset + (core.icon - font (active).scale) / 2 + core.icon,
|
|
|
|
y + offset + (core.icon - font (active).scale) / 2,
|
2024-05-11 06:01:07 -04:00
|
|
|
(if core.cursor_inside (x, y, width / core.zoom, height / core.zoom) then font_tint (active) else (others => 255)));
|
2024-05-09 11:03:39 -04:00
|
|
|
--
|
2024-05-11 06:01:07 -04:00
|
|
|
if core.cursor_inside (x, y, width / core.zoom, height / core.zoom) then
|
2024-05-12 11:08:32 -04:00
|
|
|
prioritize := true;
|
|
|
|
--
|
2024-05-09 11:03:39 -04:00
|
|
|
if core.cursor_mode = 1 then
|
|
|
|
action.all;
|
|
|
|
core.cursor_mode := 0;
|
|
|
|
end if;
|
|
|
|
end if;
|
|
|
|
end draw_button;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-09 11:28:40 -04:00
|
|
|
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);
|
|
|
|
--
|
|
|
|
write (text, x + sprite (active, check_box_on).width, y);
|
|
|
|
--
|
2024-05-11 06:01:07 -04:00
|
|
|
if core.cursor_mode = 1 and core.cursor_inside (x, y, sprite (active, check_box_on).width / core.zoom, sprite (active, check_box_on).height / core.zoom) then
|
2024-05-09 11:28:40 -04:00
|
|
|
on := not on;
|
|
|
|
core.cursor_mode := 0;
|
|
|
|
end if;
|
|
|
|
end draw_check_box;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-02-16 14:58:54 -05:00
|
|
|
procedure draw_title_bar (x, y, width : in integer; title : in string) is
|
|
|
|
middle_width : constant integer := width - sprite (active, title_bar_left).width - sprite (active, title_bar_right).width;
|
2024-05-09 02:43:09 -04:00
|
|
|
offset : constant integer := (sprite (active, title_bar_middle).height - font (active).scale) / 2;
|
2024-02-16 14:58:54 -05:00
|
|
|
begin
|
2024-05-12 11:08:32 -04:00
|
|
|
if core.cursor_inside (x, y, width / core.zoom, sprite (active, title_bar_left).height / core.zoom) then
|
|
|
|
prioritize := true;
|
|
|
|
end if;
|
|
|
|
--
|
2024-02-16 14:58:54 -05:00
|
|
|
draw (title_bar_left, x, y - sprite (active, title_bar_left).height);
|
|
|
|
draw (title_bar_right, x + middle_width + sprite (active, title_bar_left).width, y - sprite (active, title_bar_right).height);
|
|
|
|
--
|
|
|
|
draw_horizontally (title_bar_middle, x + sprite (active, title_bar_left).width, y - sprite (active, title_bar_middle).height, middle_width);
|
|
|
|
--
|
2024-05-09 03:53:38 -04:00
|
|
|
write (title, x + sprite (active, title_bar_left).width, y - font (active).scale - 4, tint => font_tint (active));
|
2024-02-16 14:58:54 -05:00
|
|
|
end draw_title_bar;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-01 09:55:56 -04:00
|
|
|
procedure draw_fill_bar (x, y, width : in integer; fill : in float) is
|
|
|
|
middle_width : constant integer := width - sprite (active, fill_bar_left).width - sprite (active, fill_bar_right).width;
|
|
|
|
fill_width : constant integer := integer (float (middle_width) * fill);
|
|
|
|
begin
|
|
|
|
draw (fill_bar_left, x, y - sprite (active, fill_bar_left).height);
|
|
|
|
draw (fill_bar_right, x + middle_width + sprite (active, fill_bar_left).width, y - sprite (active, fill_bar_right).height);
|
|
|
|
--
|
|
|
|
draw_horizontally (fill_bar_horizontal, x + sprite (active, fill_bar_left).width, y - sprite (active, fill_bar_horizontal).height, middle_width);
|
|
|
|
draw_horizontally (fill_horizontal, x + sprite (active, fill_bar_left).width, y - sprite (active, fill_bar_horizontal).height, fill_width);
|
|
|
|
end draw_fill_bar;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-16 10:13:08 -04:00
|
|
|
procedure draw_tiny_fill_bar (x, y, width : in integer; fill : in float) is
|
|
|
|
middle_width : constant integer := width - sprite (active, tiny_fill_bar_left).width - sprite (active, tiny_fill_bar_right).width;
|
|
|
|
fill_width : constant integer := integer (float (middle_width) * fill);
|
|
|
|
begin
|
|
|
|
draw (tiny_fill_bar_left, x, y - sprite (active, tiny_fill_bar_left).height);
|
|
|
|
draw (tiny_fill_bar_right, x + middle_width + sprite (active, tiny_fill_bar_left).width, y - sprite (active, tiny_fill_bar_right).height);
|
|
|
|
--
|
|
|
|
draw_horizontally (tiny_fill_bar_horizontal, x + sprite (active, tiny_fill_bar_left).width, y - sprite (active, tiny_fill_bar_horizontal).height, middle_width);
|
|
|
|
draw_horizontally (tiny_fill_horizontal, x + sprite (active, tiny_fill_bar_left).width, y - sprite (active, tiny_fill_bar_horizontal).height, fill_width);
|
|
|
|
end draw_tiny_fill_bar;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-07 09:59:26 -04:00
|
|
|
procedure draw_scroll_bar (x, y, height, offset : in integer) is
|
2024-02-19 21:52:43 -05:00
|
|
|
middle_height : constant integer := height - sprite (active, scroll_bar_upper).height - sprite (active, scroll_bar_lower).height;
|
|
|
|
begin
|
|
|
|
draw (scroll_bar_upper, x, y);
|
|
|
|
draw (scroll_bar_lower, x, y + middle_height + sprite (active, scroll_bar_upper).height);
|
|
|
|
--
|
|
|
|
draw_vertically (scroll_bar_middle, x, y + sprite (active, scroll_bar_upper).height, middle_height);
|
|
|
|
end draw_scroll_bar;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-04-27 12:34:16 -04:00
|
|
|
procedure draw_menu (x, y, width, height : in integer) is
|
2024-02-15 21:03:09 -05:00
|
|
|
offset : constant integer := sprite (active, none).width;
|
|
|
|
begin
|
2024-05-12 11:08:32 -04:00
|
|
|
if core.cursor_inside (x, y, width / core.zoom, height / core.zoom) then
|
|
|
|
prioritize := true;
|
|
|
|
end if;
|
|
|
|
--
|
2024-04-27 10:01:54 -04:00
|
|
|
declare upper : constant integer := width - sprite (active, corner_upper_left).width - sprite (active, corner_upper_right).width;
|
|
|
|
lower : constant integer := width - sprite (active, corner_lower_left).width - sprite (active, corner_lower_right).width;
|
|
|
|
left : constant integer := height - sprite (active, corner_upper_left).height - sprite (active, corner_lower_left).height;
|
|
|
|
right : constant integer := height - sprite (active, corner_upper_right).height - sprite (active, corner_lower_right).height;
|
2024-02-15 21:03:09 -05:00
|
|
|
begin
|
2024-05-01 07:24:10 -04:00
|
|
|
draw_horizontally (border_upper, x + sprite (active, corner_upper_left).width, y, upper, action => core.move_camera_up'access);
|
|
|
|
draw_horizontally (border_lower, x + sprite (active, corner_lower_left).width, y + height - sprite (active, border_lower).height, lower, action => core.move_camera_down'access);
|
|
|
|
draw_vertically (border_left, x, y + sprite (active, corner_upper_left).height, left, action => core.move_camera_left'access);
|
|
|
|
draw_vertically (border_right, x + width - sprite (active, border_right).width, y + sprite (active, corner_upper_right).height, right, action => core.move_camera_right'access);
|
2024-02-15 21:03:09 -05:00
|
|
|
end;
|
|
|
|
--
|
|
|
|
draw (corner_upper_left, x, y);
|
|
|
|
draw (corner_upper_right, x + width - sprite (active, corner_upper_right).width, y);
|
|
|
|
draw (corner_lower_left, x, y + height - sprite (active, corner_lower_left).height);
|
|
|
|
draw (corner_lower_right, x + width - sprite (active, corner_lower_right).width, y + height - sprite (active, corner_lower_right).height);
|
|
|
|
end draw_menu;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-04-27 12:34:16 -04:00
|
|
|
procedure draw_tiny_menu (x, y, width, height : in integer) is
|
2024-02-15 21:03:09 -05:00
|
|
|
offset : constant integer := sprite (active, none).width;
|
|
|
|
begin
|
2024-05-12 11:08:32 -04:00
|
|
|
if core.cursor_inside (x, y, width / core.zoom, height / core.zoom) then
|
|
|
|
prioritize := true;
|
|
|
|
end if;
|
|
|
|
--
|
2024-04-27 12:34:16 -04:00
|
|
|
draw_background (main_background, x + offset, y + offset, width - 2 * offset, height - 2 * offset);
|
2024-02-15 21:03:09 -05:00
|
|
|
--
|
2024-04-27 10:01:54 -04:00
|
|
|
declare upper : constant integer := width - sprite (active, tiny_corner_upper_left).width - sprite (active, tiny_corner_upper_right).width;
|
|
|
|
lower : constant integer := width - sprite (active, tiny_corner_lower_left).width - sprite (active, tiny_corner_lower_right).width;
|
|
|
|
left : constant integer := height - sprite (active, tiny_corner_upper_left).height - sprite (active, tiny_corner_lower_left).height;
|
|
|
|
right : constant integer := height - sprite (active, tiny_corner_upper_right).height - sprite (active, tiny_corner_lower_right).height;
|
2024-02-15 21:03:09 -05:00
|
|
|
begin
|
|
|
|
draw_horizontally (tiny_border_upper, x + sprite (active, tiny_corner_upper_left).width, y, upper);
|
|
|
|
draw_horizontally (tiny_border_lower, x + sprite (active, tiny_corner_lower_left).width, y + height - sprite (active, tiny_border_lower).height, lower);
|
|
|
|
draw_vertically (tiny_border_left, x, y + sprite (active, tiny_corner_upper_left).height, left);
|
|
|
|
draw_vertically (tiny_border_right, x + width - sprite (active, tiny_border_right).width, y + sprite (active, tiny_corner_upper_right).height, right);
|
|
|
|
end;
|
|
|
|
--
|
|
|
|
draw (tiny_corner_upper_left, x, y);
|
|
|
|
draw (tiny_corner_upper_right, x + width - sprite (active, tiny_corner_upper_right).width, y);
|
|
|
|
draw (tiny_corner_lower_left, x, y + height - sprite (active, tiny_corner_lower_left).height);
|
|
|
|
draw (tiny_corner_lower_right, x + width - sprite (active, tiny_corner_lower_right).width, y + height - sprite (active, tiny_corner_lower_right).height);
|
|
|
|
end draw_tiny_menu;
|
|
|
|
|
2024-03-13 14:07:17 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-09 04:07:25 -04:00
|
|
|
procedure draw_icon_menu (x, y, width, height : in integer) is
|
2024-03-11 15:35:56 -04:00
|
|
|
offset_x : constant integer := sprite (active, icon_upper_left).width;
|
|
|
|
offset_y : constant integer := sprite (active, icon_upper_left).height;
|
|
|
|
begin
|
2024-05-12 11:08:32 -04:00
|
|
|
if core.cursor_inside (x, y, width / core.zoom, height / core.zoom) then
|
|
|
|
prioritize := true;
|
|
|
|
end if;
|
|
|
|
--
|
2024-05-01 07:24:10 -04:00
|
|
|
if height < 2 * sprite (active, icon_upper_left).height
|
|
|
|
or width < 2 * sprite (active, icon_upper_left).width then
|
2024-03-11 15:35:56 -04:00
|
|
|
return;
|
|
|
|
end if;
|
|
|
|
--
|
2024-05-01 07:38:47 -04:00
|
|
|
draw_horizontally (icon_upper, x + offset_x, y, width - 2 * offset_x);
|
|
|
|
draw_horizontally (icon_lower, x + offset_x, y + height - offset_y, width - 2 * offset_x);
|
|
|
|
draw_vertically (icon_left, x, y + offset_y, height - 2 * offset_y);
|
|
|
|
draw_vertically (icon_right, x + width - offset_x, y + offset_y, height - 2 * offset_y);
|
2024-03-11 15:35:56 -04:00
|
|
|
--
|
2024-05-01 07:38:47 -04:00
|
|
|
draw (icon_upper_left, x, y);
|
|
|
|
draw (icon_upper_right, x + width - sprite (active, icon_upper_right).width, y);
|
|
|
|
draw (icon_lower_left, x, y + height - sprite (active, icon_lower_left).height);
|
|
|
|
draw (icon_lower_right, x + width - sprite (active, icon_lower_right).width, y + height - sprite (active, icon_lower_right).height);
|
2024-03-11 15:35:56 -04:00
|
|
|
end draw_icon_menu;
|
|
|
|
|
2024-03-14 14:40:05 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-04 08:26:51 -04:00
|
|
|
procedure draw_state_box (x, y : in integer) is
|
2024-03-14 14:40:05 -04:00
|
|
|
begin
|
2024-04-30 23:17:05 -04:00
|
|
|
ui.write ("Cursor X:" & core.cursor.x'image, x, y + 0);
|
|
|
|
ui.write ("Cursor Y:" & core.cursor.y'image, x, y + 32);
|
|
|
|
ui.write ("Cursor Mode:" & core.cursor_mode'image, x, y + 64);
|
|
|
|
ui.write ("Camera X:" & core.camera.x'image, x, y + 96);
|
|
|
|
ui.write ("Camera Y:" & core.camera.y'image, x, y + 128);
|
|
|
|
ui.write ("Global Time:" & core.global_time'image, x, y + 160);
|
|
|
|
ui.write ("Gameplay Time:" & core.gameplay_time'image, x, y + 192);
|
|
|
|
ui.write ("Animation Time:" & core.animation_time'image, x, y + 224);
|
|
|
|
ui.write ("Framerate:" & core.framerate'image, x, y + 256);
|
2024-03-14 14:40:05 -04:00
|
|
|
end draw_state_box;
|
|
|
|
|
2024-04-23 16:19:29 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-04 08:26:51 -04:00
|
|
|
procedure add_structure (data : in structure) is
|
2024-04-23 16:19:29 -04:00
|
|
|
begin
|
2024-05-04 07:12:00 -04:00
|
|
|
structure_array (structure_count) := data;
|
|
|
|
structure_array (structure_count).gui_list := new gui_array (0 .. structure_array (structure_count).gui_n - 1);
|
|
|
|
structure_array (structure_count).gui_n := 0;
|
2024-05-01 09:15:38 -04:00
|
|
|
--
|
2024-05-04 07:12:00 -04:00
|
|
|
core.increment (structure_count);
|
2024-05-01 09:15:38 -04:00
|
|
|
end add_structure;
|
2024-04-23 16:19:29 -04:00
|
|
|
|
2024-05-03 07:55:17 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-13 09:55:14 -04:00
|
|
|
procedure add_structure_button (icon : in core.sprite; name : in core.short_string; text : in core.long_string := "") is
|
2024-05-03 07:55:17 -04:00
|
|
|
begin
|
2024-05-03 10:13:49 -04:00
|
|
|
structure_array (structure_count - 1).gui_list (structure_array (structure_count - 1).gui_n).kind := gui_button;
|
2024-05-13 09:55:14 -04:00
|
|
|
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;
|
2024-05-03 10:13:49 -04:00
|
|
|
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;
|
2024-05-03 07:55:17 -04:00
|
|
|
--
|
2024-05-04 07:12:00 -04:00
|
|
|
core.increment (structure_array (structure_count - 1).gui_n);
|
2024-05-03 07:55:17 -04:00
|
|
|
end add_structure_button;
|
|
|
|
|
2024-05-07 09:06:08 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure add_structure_orient is
|
|
|
|
begin
|
|
|
|
structure_array (structure_count - 1).gui_list (structure_array (structure_count - 1).gui_n).kind := gui_orient;
|
|
|
|
--
|
|
|
|
core.increment (structure_array (structure_count - 1).gui_n);
|
|
|
|
end add_structure_orient;
|
|
|
|
|
2024-05-13 04:03:27 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure write_ada_code (text : in core.string_box_data; x, y : in integer) is
|
2024-05-13 06:41:21 -04:00
|
|
|
word : unbounded_string := to_unbounded_string ("");
|
|
|
|
--
|
2024-05-13 04:03:27 -04:00
|
|
|
buffer : character := ' ';
|
2024-05-13 07:40:23 -04:00
|
|
|
width : constant integer := 9;
|
|
|
|
height : constant integer := 15;
|
2024-05-13 04:03:27 -04:00
|
|
|
length : natural := 1;
|
|
|
|
offset : core.vector := (x, y);
|
2024-05-13 06:41:21 -04:00
|
|
|
subset : natural := 0;
|
2024-05-13 04:03:27 -04:00
|
|
|
begin
|
|
|
|
loop
|
|
|
|
buffer := ada.strings.unbounded.element (text.text, length);
|
2024-05-13 06:41:21 -04:00
|
|
|
offset.x := offset.x + width;
|
2024-05-13 04:03:27 -04:00
|
|
|
--
|
|
|
|
exit when buffer = character'val (0);
|
|
|
|
--
|
|
|
|
case buffer is
|
|
|
|
when character'val (9) => offset.x := offset.x + 2 * width;
|
|
|
|
when character'val (10) => offset.y := offset.y + 1 * height; offset.x := x;
|
2024-05-13 06:54:57 -04:00
|
|
|
when ':' | ';' | '.' | ',' | '=' | '<' | '>' =>
|
|
|
|
ui.write (buffer & "", offset.x, offset.y, (63, 127, 255, 255), height, code => true);
|
|
|
|
when '+' | '*' | '/' | '|' | '&' =>
|
|
|
|
ui.write (buffer & "", offset.x, offset.y, (63, 63, 255, 255), height, code => true);
|
|
|
|
when '(' | ')' | ''' =>
|
|
|
|
ui.write (buffer & "", offset.x, offset.y, (63, 255, 255, 255), height, code => true);
|
2024-05-13 06:41:21 -04:00
|
|
|
when '"' =>
|
2024-05-13 06:54:57 -04:00
|
|
|
ui.write (buffer & "", offset.x, offset.y, (127, 63, 127, 255), height, code => true);
|
2024-05-13 06:41:21 -04:00
|
|
|
offset.x := offset.x + width;
|
|
|
|
loop
|
|
|
|
core.increment (length);
|
|
|
|
buffer := ada.strings.unbounded.element (text.text, length);
|
2024-05-13 06:54:57 -04:00
|
|
|
ui.write (buffer & "", offset.x, offset.y, (127, 63, 127, 255), height, code => true);
|
2024-05-13 06:41:21 -04:00
|
|
|
offset.x := offset.x + width;
|
|
|
|
exit when buffer = '"';
|
|
|
|
end loop;
|
2024-05-13 06:54:57 -04:00
|
|
|
offset.x := offset.x - width;
|
2024-05-13 06:41:21 -04:00
|
|
|
when '-' =>
|
|
|
|
if ada.strings.unbounded.element (text.text, length + 1) = '-' then
|
|
|
|
ui.write (buffer & "", offset.x, offset.y, (127, 127, 127, 255), height, code => true);
|
|
|
|
offset.x := offset.x + width;
|
|
|
|
loop
|
|
|
|
core.increment (length);
|
|
|
|
buffer := ada.strings.unbounded.element (text.text, length);
|
|
|
|
ui.write (buffer & "", offset.x, offset.y, (127, 127, 127, 255), height, code => true);
|
|
|
|
offset.x := offset.x + width;
|
|
|
|
exit when buffer = character'val (10);
|
|
|
|
end loop;
|
|
|
|
core.decrement (length);
|
|
|
|
else
|
2024-05-13 06:54:57 -04:00
|
|
|
ui.write (buffer & "", offset.x, offset.y, (63, 63, 255, 255), height, code => true);
|
2024-05-13 06:41:21 -04:00
|
|
|
end if;
|
|
|
|
when '0' .. '9' =>
|
|
|
|
loop
|
2024-05-13 06:54:57 -04:00
|
|
|
ui.write (buffer & "", offset.x, offset.y, (127, 63, 255, 255), height, code => true);
|
2024-05-13 06:41:21 -04:00
|
|
|
core.increment (length);
|
|
|
|
buffer := ada.strings.unbounded.element (text.text, length);
|
|
|
|
exit when buffer = ' ' or buffer = ';' or buffer = ')' or buffer = ',';
|
|
|
|
offset.x := offset.x + width;
|
|
|
|
end loop;
|
|
|
|
core.decrement (length);
|
|
|
|
when 'a' .. 'z' | 'A' .. 'Z' =>
|
|
|
|
word := to_unbounded_string (buffer & "");
|
|
|
|
subset := 1;
|
|
|
|
loop
|
|
|
|
buffer := ada.strings.unbounded.element (text.text, length + subset);
|
2024-05-13 08:09:54 -04:00
|
|
|
exit when buffer = ' ' or buffer = '.' or buffer = '(' or buffer = ')' or buffer = ',' or buffer = ';' or buffer = '''
|
2024-05-13 06:41:21 -04:00
|
|
|
or buffer = character'val (9) or buffer = character'val (10);
|
|
|
|
word := word & 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"
|
|
|
|
or word = "package" or word = "body" or word = "if" or word = "then" or word = "else" or word = "elsif" or word = "case" or word = "is"
|
|
|
|
or word = "and" or word = "or" or word = "xor" or word = "exit" or word = "constant" or word = "access" or word = "range"
|
2024-05-13 06:54:57 -04:00
|
|
|
or word = "subtype" or word = "array" or word = "in" or word = "out" or word = "return" or word = "for" or word = "with"
|
2024-05-13 06:41:21 -04:00
|
|
|
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 = ""
|
|
|
|
--~or word = ""
|
|
|
|
--~or word = ""
|
|
|
|
--~or word = ""
|
|
|
|
--~or word = ""
|
|
|
|
--~or word = ""
|
|
|
|
--~or word = ""
|
|
|
|
--~or word = ""
|
|
|
|
--~or word = ""
|
|
|
|
or word = "aliased" then
|
|
|
|
ui.write (to_string (word), offset.x, offset.y, (255, 255, 0, 255), height, code => true);
|
|
|
|
else
|
|
|
|
ui.write (to_string (word), offset.x, offset.y, (255, 255, 255, 255), height, code => true);
|
|
|
|
end if;
|
|
|
|
offset.x := offset.x + (subset - 1) * width;
|
|
|
|
length := length + subset - 1;
|
|
|
|
when others =>
|
|
|
|
ui.write (buffer & "", offset.x, offset.y, (255, 255, 255, 255), height, code => true);
|
2024-05-13 04:03:27 -04:00
|
|
|
end case;
|
|
|
|
--
|
2024-05-13 06:41:21 -04:00
|
|
|
core.increment (length);
|
2024-05-13 04:03:27 -04:00
|
|
|
end loop;
|
|
|
|
end write_ada_code;
|
|
|
|
|
2024-02-15 21:03:09 -05:00
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
end ui;
|