More code refactoring, end turn things, time...

This commit is contained in:
Ognjen Milan Robovic 2024-06-08 07:11:40 -04:00
parent 8a5f80bdd4
commit e12120a3c2
4 changed files with 50 additions and 62 deletions

View File

@ -59,8 +59,8 @@ procedure main is
swap_fullscreen'access
);
view_icon : array (view) of core.sprite := (others => (others => 0));
view_list : array (view) of boolean := (fullscreen => false, others => true);
view_icon : array (view, boolean) of core.sprite := (others => (others => (others => 0)));
view_list : array (view) of boolean := (fullscreen => false, others => true);
view_text : constant array (view) of access string := (
new string'("Toggle map preview panel."),
@ -142,12 +142,10 @@ procedure main is
------------------------------------------------------------------------------------------
procedure player_information is
procedure player_information (x, y : in integer) is
player_1 : chad.information renames world.map.chads (1);
--
offset : constant integer := 8;
x : constant integer := preview_width + core.icon;
y : constant integer := core.icon;
width : constant integer := side_panel - 2 * core.icon;
height : constant integer := chad.view_height + 11 * core.icon + 4 * core.base + 2 * offset;
more : constant natural := 10;
@ -156,7 +154,7 @@ procedure main is
at_x : integer := x + offset;
at_y : integer := y + offset;
begin
ui.draw_frame ("--", x, y, width, height);
ui.draw_frame (x, y, width, height);
ui.draw_sprite (chad.view (player_1.index), chad.description (player_1.index).name.all, at_x, at_y, 0);
ui.draw_text_box (at_x + chad.view_width, at_y, width - chad.view_width - 2 * offset, core.icon);
ui.write (chad.description (player_1.index).name.all, at_x + chad.view_width + less, at_y + less);
@ -230,10 +228,6 @@ procedure main is
--
at_y := at_y + core.base;
--
ui.draw_text_box (at_x + side, at_y, width - side - 2 * offset, 3 * core.icon);
ui.draw_end_turn_button (at_x + side + (width - side - 2 * offset - 2 * core.icon) / 2, at_y + core.icon / 2);
ui.write ("End Turn", at_x + side + less, at_y + core.icon + less);
--
for index_y in 0 .. 2 loop
for index_x in 0 .. 7 loop
ui.draw_icon (data => equipment.icon (player_1.items (8 * index_y + index_x)),
@ -242,18 +236,25 @@ procedure main is
y => at_y + index_y * core.icon);
end loop;
end loop;
--
at_y := at_y + 3 * core.icon;
--
ui.draw_separator (at_x, at_y, width - 2 * offset);
--
at_y := at_y + core.base;
--
ui.draw_text (world.day_name (7).all, at_x, at_y + 0 * core.icon, width - 2 * offset, core.icon, more, 0);
ui.draw_text (world.week_name (52).all, at_x, at_y + 1 * core.icon, width - 2 * offset, core.icon, more, 0);
ui.draw_text (world.month_name (2).all, at_x, at_y + 2 * core.icon, width - 2 * offset, core.icon, more, 0);
end player_information;
------------------------------------------------------------------------------------------
procedure time_information (x, y : in integer) is
offset : constant integer := 8;
width : constant integer := side_panel - 2 * core.icon;
height : constant integer := 3 * core.icon + 2 * offset;
more : constant natural := 10;
begin
ui.draw_frame (x, y, width, height);
--
ui.draw_text (world.day_name (7).all, x + offset, y + 0 * core.icon + offset, width - 2 * offset - 64, core.icon, more, 0);
ui.draw_text (world.week_name (6).all, x + offset, y + 1 * core.icon + offset, width - 2 * offset - 64, core.icon, more, 0);
ui.draw_text (world.month_name (2).all, x + offset, y + 2 * core.icon + offset, width - 2 * offset - 64, core.icon, more, 0);
--
ui.draw_end_turn_button (x + width - offset - 64, y + offset + core.icon / 2);
end time_information;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
begin
@ -366,7 +367,8 @@ begin
core.dash;
for index in view loop
view_icon (index) := core.import_sprite (core.folder & "/icon/engine/" & core.lowercase (view'image (index)) & ".png", 1, 2);
view_icon (index, false) := core.import_sprite (core.folder & "/icon/engine/" & core.lowercase (view'image (index)) & "_off.png", 1, 2);
view_icon (index, true) := core.import_sprite (core.folder & "/icon/engine/" & core.lowercase (view'image (index)) & "_on.png", 1, 2);
end loop;
game_title := core.import_sprite (core.folder & "/ui/game_title.png", 1, 1);
@ -446,7 +448,8 @@ begin
if view_list (status_preview_panel) then
ui.draw_tiny_menu (preview_width, 0, side_panel, preview_height);
--
player_information;
player_information (preview_width + core.icon, core.icon);
time_information (preview_width + core.icon, core.icon + chad.view_height + 11 * core.icon + 4 * core.base + 3 * 8);
--
ui.draw_console_box (x => core.window_width - core.icon - (side_panel - 2 * core.icon),
y => core.window_height - core.icon - text_box_height - 106,
@ -462,39 +465,26 @@ begin
end if;
--
for index in view loop
ui.draw_frame (description => view_text (index).all,
x => core.window_width - core.icon * (view'pos (view'last) + 1) + core.icon * view'pos (index),
y => core.window_height - core.icon,
width => core.icon,
height => core.icon,
action => view_show (index));
--
core.draw (data => view_icon (index),
x => core.window_width - core.icon * (view'pos (view'last) + 1) + core.icon * view'pos (index),
y => core.window_height - core.icon,
ignore => true,
u => 0,
v => boolean'pos (view_list (index)) * core.icon,
factor => 1);
ui.draw_icon (data => view_icon (index, view_list (index)),
text => view_text (index).all,
x => core.window_width - core.icon * (view'pos (view'last) + 1) + core.icon * view'pos (index),
y => core.window_height - core.icon,
action => view_show (index));
end loop;
--
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, 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,
y => core.base + 7,
size => 18);
ui.draw_icon (resource.icon (index), resource.description (index).text.all,
(preview_width - 5 * core.icon * resource.count) / 2 + (5 * core.icon) * resource.enumeration'pos (index), core.base);
ui.draw_text (world.map.chads (1).resources (index).value'image & " /" & world.map.chads (1).resources (index).limit'image,
(preview_width - 5 * core.icon * resource.count) / 2 + (5 * core.icon) * resource.enumeration'pos (index) + core.icon, core.base, 4 * core.icon, core.icon, 10);
end loop;
--
declare move_x : integer := (preview_width - core.icon * material.count) / 2;
begin
for index in material.enumeration loop
if world.map.chads (1).materials (index).value > 0 then
ui.draw_icon (material.icon (index), material.description (index).name.all, move_x, core.base + core.icon);
ui.draw_text_box (move_x, core.base + core.icon + core.icon, core.icon, core.icon);
ui.write (world.map.chads (1).materials (index).value'image, move_x, core.base + core.icon + core.icon + 8, (255, 255, 255, 255), 15, true);
ui.draw_icon (material.icon (index), material.description (index).name.all, move_x, core.base + core.icon);
ui.draw_text (world.map.chads (1).materials (index).value'image, move_x, core.base + 2 * core.icon, core.icon, core.icon, 10);
--
move_x := move_x + core.icon;
end if;

View File

@ -270,7 +270,7 @@ package body ui is
------------------------------------------------------------------------------------------
procedure draw_frame (description : in string; x, y, width, height : in integer; action : core.pointer := core.idle_skip'access) is
procedure draw_frame (x, y, width, height : in integer) is
offset_x : constant integer := sprite (active, frame_middle).width;
offset_y : constant integer := sprite (active, frame_middle).height;
begin
@ -292,13 +292,6 @@ package body ui is
--
if core.cursor_inside (x, y, width / core.zoom, height / core.zoom) then
prioritize := true;
--
core.write_help_box (description);
--
if core.cursor_mode = core.cursor_left then
action.all;
core.cursor_mode := core.cursor_none;
end if;
end if;
end draw_frame;
@ -307,7 +300,7 @@ package body ui is
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_frame (x, y, width, height);
draw_icon (icon, description, x + offset, y + offset);
--
ui.write (text,
@ -496,11 +489,15 @@ package body ui is
begin
draw (end_turn_button, x, y);
--
if core.cursor_inside (x, y, sprite (active, end_turn_button).width, sprite (active, end_turn_button).height) and core.cursor_mode = core.cursor_left then
core.end_turn := true;
core.cursor_mode := core.cursor_none;
if core.cursor_inside (x, y, sprite (active, end_turn_button).width, sprite (active, end_turn_button).height) then
if core.cursor_mode = core.cursor_left then
core.end_turn := true;
core.cursor_mode := core.cursor_none;
--
echo ("-- Turn --");
end if;
--
echo ("-- Turn --");
core.write_help_box ("End your turn, it's time for other players to try to do something...");
end if;
end draw_end_turn_button;

View File

@ -41,7 +41,8 @@ package ui is
procedure draw_text_box (x, y, width, height : in integer);
procedure draw_help_box (x, y, width, height : in integer; action : core.pointer := core.idle_skip'access);
procedure draw_frame (description : in string; x, y, width, height : in integer; action : core.pointer := core.idle_skip'access);
procedure draw_frame (x, y, width, height : in integer);
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, width, height : in integer; offset, border : in natural := 0; tint : in core.colour := (others => 255));

View File

@ -128,8 +128,8 @@ package world is
);
month_name : constant array (1 .. 13) of access string := (
new string'("I <> Month of Life"),
new string'("II <> Month of Red-Haired Goddess"),
new string'("I <> Month of Genesis"),
new string'("II <> Month of Life"),
new string'("III <> Month of Xorana"),
new string'("IV <> Month of Heneal"),
new string'("V <> Month of Evelor"),