Refactored internal functions...
This commit is contained in:
parent
ecc6e0ba68
commit
5acfa08d93
@ -38,11 +38,7 @@ package body core is
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure terminal (colour : in terminal_colour := white;
|
||||
effect : in terminal_effect := normal) is
|
||||
format : string := character'val (27) & "[" & character'val (terminal_effect'pos (effect) + 48) & ";3" & character'val (terminal_colour'pos (colour) + 48) & "m";
|
||||
begin
|
||||
put (format);
|
||||
end terminal;
|
||||
effect : in terminal_effect := normal);
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
@ -573,4 +569,13 @@ package body core is
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
procedure terminal (colour : in terminal_colour := white;
|
||||
effect : in terminal_effect := normal) is
|
||||
format : string := character'val (27) & "[" & character'val (terminal_effect'pos (effect) + 48) & ";3" & character'val (terminal_colour'pos (colour) + 48) & "m";
|
||||
begin
|
||||
put (format);
|
||||
end terminal;
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
end core;
|
||||
|
@ -427,7 +427,7 @@ begin
|
||||
--
|
||||
for index in resource.enumeration loop
|
||||
ui.draw_icon (resource.icon (index), resource.description (index).text.all, (preview_width - 6 * core.icon * resource.count) / 2 + (6 * core.icon) * resource.enumeration'pos (index), core.base);
|
||||
ui.draw_frame (resource.description (index).text.all, (preview_width - 6 * core.icon * resource.count) / 2 + (6 * core.icon) * resource.enumeration'pos (index) + core.icon, core.base, 6 * core.icon, core.icon);
|
||||
ui.draw_frame (resource.description (index).text.all, (preview_width - 6 * core.icon * resource.count) / 2 + (6 * core.icon) * resource.enumeration'pos (index) + core.icon, core.base, 5 * core.icon, core.icon);
|
||||
--
|
||||
ui.write (text => world.map.chads (1).resources (index).value'image & " /" & world.map.chads (1).resources (index).limit'image,
|
||||
x => (preview_width - 6 * core.icon * resource.count) / 2 + (6 * core.icon) * resource.enumeration'pos (index) + core.icon - 1,
|
||||
|
149
source/ui.adb
149
source/ui.adb
@ -84,76 +84,14 @@ package body ui is
|
||||
x : in integer := 0;
|
||||
y : in integer := 0;
|
||||
width : in integer := 0;
|
||||
height : in integer := 0) is
|
||||
begin
|
||||
core.draw (sprite (active, index), x, y, 0, 0, width, height, factor => 1);
|
||||
end draw;
|
||||
height : in integer := 0);
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
procedure draw_horizontally (index : in element; x, y, width : in integer; action : core.pointer := core.idle_skip'access; tint : in core.colour := (others => 255));
|
||||
procedure draw_vertically (index : in element; x, y, height : in integer; action : core.pointer := core.idle_skip'access; tint : in core.colour := (others => 255));
|
||||
|
||||
procedure draw_horizontally (index : in element; x, y, width : in integer; action : core.pointer := core.idle_skip'access; tint : in core.colour := (others => 255)) is
|
||||
begin
|
||||
core.draw_horizontally (sprite (active, index), x, y, width, 1, tint);
|
||||
end draw_horizontally;
|
||||
procedure draw_background (index : in element; x, y, width, height : in integer; action : core.pointer := core.idle_skip'access);
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure draw_vertically (index : in element; x, y, height : in integer; action : core.pointer := core.idle_skip'access; tint : in core.colour := (others => 255)) is
|
||||
begin
|
||||
core.draw_vertically (sprite (active, index), x, y, height, 1, tint);
|
||||
end draw_vertically;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure draw_background (index : in element; x, y, width, height : in integer; action : core.pointer := core.idle_skip'access) is
|
||||
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;
|
||||
begin
|
||||
for move_y in 0 .. height / base_height - 1 loop
|
||||
for move_x in 0 .. width / base_width - 1 loop
|
||||
draw (index, x + move_x * base_width, y + move_y * base_height);
|
||||
end loop;
|
||||
--
|
||||
if width mod base_width > 0 then
|
||||
draw (index, x + width - crop_width, y + move_y * base_height, crop_width, base_height);
|
||||
end if;
|
||||
end loop;
|
||||
--
|
||||
for move_x in 0 .. width / base_width - 1 loop
|
||||
if height mod base_height > 0 then
|
||||
draw (index, x + move_x * base_width, y + height - crop_height, base_width, crop_height);
|
||||
end if;
|
||||
end loop;
|
||||
--
|
||||
if width mod base_width > 0 and height mod base_height > 0 then
|
||||
draw (index, x + width - crop_width, y + height - crop_height, crop_width, crop_height);
|
||||
end if;
|
||||
end draw_background;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure draw_popup_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);
|
||||
--
|
||||
ui.write (core.read_text_box, core.cursor.x + 4 + offset, core.cursor.y + 6 + offset);
|
||||
end draw_popup_box;
|
||||
procedure draw_popup_box;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
@ -657,4 +595,81 @@ package body ui is
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
procedure draw (index : in element := none;
|
||||
x : in integer := 0;
|
||||
y : in integer := 0;
|
||||
width : in integer := 0;
|
||||
height : in integer := 0) is
|
||||
begin
|
||||
core.draw (sprite (active, index), x, y, 0, 0, width, height, factor => 1);
|
||||
end draw;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure draw_horizontally (index : in element; x, y, width : in integer; action : core.pointer := core.idle_skip'access; tint : in core.colour := (others => 255)) is
|
||||
begin
|
||||
core.draw_horizontally (sprite (active, index), x, y, width, 1, tint);
|
||||
end draw_horizontally;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure draw_vertically (index : in element; x, y, height : in integer; action : core.pointer := core.idle_skip'access; tint : in core.colour := (others => 255)) is
|
||||
begin
|
||||
core.draw_vertically (sprite (active, index), x, y, height, 1, tint);
|
||||
end draw_vertically;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure draw_background (index : in element; x, y, width, height : in integer; action : core.pointer := core.idle_skip'access) is
|
||||
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;
|
||||
begin
|
||||
for move_y in 0 .. height / base_height - 1 loop
|
||||
for move_x in 0 .. width / base_width - 1 loop
|
||||
draw (index, x + move_x * base_width, y + move_y * base_height);
|
||||
end loop;
|
||||
--
|
||||
if width mod base_width > 0 then
|
||||
draw (index, x + width - crop_width, y + move_y * base_height, crop_width, base_height);
|
||||
end if;
|
||||
end loop;
|
||||
--
|
||||
for move_x in 0 .. width / base_width - 1 loop
|
||||
if height mod base_height > 0 then
|
||||
draw (index, x + move_x * base_width, y + height - crop_height, base_width, crop_height);
|
||||
end if;
|
||||
end loop;
|
||||
--
|
||||
if width mod base_width > 0 and height mod base_height > 0 then
|
||||
draw (index, x + width - crop_width, y + height - crop_height, crop_width, crop_height);
|
||||
end if;
|
||||
end draw_background;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure draw_popup_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);
|
||||
--
|
||||
ui.write (core.read_text_box, core.cursor.x + 4 + offset, core.cursor.y + 6 + offset);
|
||||
end draw_popup_box;
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
end ui;
|
||||
|
1191
source/world.adb
1191
source/world.adb
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user