From d3043bce736bcba4e92852a689e4a80f5d8720fe Mon Sep 17 00:00:00 2001 From: xolatile Date: Sun, 9 Jun 2024 12:57:11 -0400 Subject: [PATCH] Finishing very soon... --- source/core.adb | 5 +++++ source/core.ads | 3 +++ source/main.adb | 28 +++++++--------------------- source/ui.adb | 23 ++++++++++++++++++----- source/ui.ads | 4 +++- source/world.adb | 7 +++++++ source/world.ads | 3 +++ 7 files changed, 46 insertions(+), 27 deletions(-) diff --git a/source/core.adb b/source/core.adb index 8a5172c..2b29e58 100644 --- a/source/core.adb +++ b/source/core.adb @@ -164,6 +164,11 @@ package body core is ------------------------------------------------------------------------------------------ + procedure zoom_in is begin core.zoom := 2; end zoom_in; + procedure zoom_out is begin core.zoom := 1; end zoom_out; + + ------------------------------------------------------------------------------------------ + function c_string (ada_string : string) return string is begin return (ada_string & character'val (0)); diff --git a/source/core.ads b/source/core.ads index 0b0907e..6e07df1 100644 --- a/source/core.ads +++ b/source/core.ads @@ -138,6 +138,9 @@ package core is --~procedure compress_file (file_path : in string); --~procedure decompress_file (file_path : in string); + procedure zoom_in; + procedure zoom_out; + function c_string (ada_string : in string) return string; function string_width (data : in string) return natural; diff --git a/source/main.adb b/source/main.adb index f0cb7b3..8df9186 100644 --- a/source/main.adb +++ b/source/main.adb @@ -27,20 +27,17 @@ procedure main is procedure swap_status_preview_panel; procedure swap_text_box_panel; procedure swap_fullscreen; - procedure ui_main_style; - procedure zoom_in; - procedure zoom_out; ------------------------------------------------------------------------------------------ - signal_list : constant array (core.signal_code) of access procedure := ( + signal_list : constant array (core.signal_code) of core.pointer := ( core.signal_up => world.player_up'access, core.signal_down => world.player_down'access, core.signal_left => world.player_left'access, core.signal_right => world.player_right'access, - core.signal_v => ui_main_style'access, - core.signal_kp_add => zoom_in'access, - core.signal_kp_subtract => zoom_out'access, + core.signal_v => ui.iterate_style'access, + core.signal_kp_add => core.zoom_in'access, + core.signal_kp_subtract => core.zoom_out'access, core.signal_f1 => world.resource_cheat_1'access, core.signal_f2 => world.resource_cheat_2'access, core.signal_f3 => world.resource_cheat_3'access, @@ -134,18 +131,6 @@ procedure main is ------------------------------------------------------------------------------------------ - procedure ui_main_style is - begin - ui.active := ui.style'val ((ui.style'pos (ui.active) + 1) mod ui.style_count); - end ui_main_style; - - ------------------------------------------------------------------------------------------ - - procedure zoom_in is begin core.zoom := 2; end zoom_in; - procedure zoom_out is begin core.zoom := 1; end zoom_out; - - ------------------------------------------------------------------------------------------ - procedure player_information (x, y : in integer) is player_1 : chad.information renames world.map.chads (1); -- @@ -248,8 +233,9 @@ procedure main is at_y := at_y + core.base; -- for index in 0 .. unit.limit - 1 loop - world.draw_unit (player_1.units (index).index, core.walk, at_x + index * core.icon + 8, at_y + 8); - ui.draw_icon_menu (at_x + index * core.icon, at_y, core.icon, 3 * core.icon); + world.draw_unit (player_1.units (index).index, core.walk, at_x + index * core.icon + 8, at_y + 8); + world.show_unit_data := player_1.units (index).index; + ui.draw_icon_menu (at_x + index * core.icon, at_y, core.icon, 3 * core.icon, unit.description (player_1.units (index).index).name.all, world.show_unit'access); end loop; end player_information; diff --git a/source/ui.adb b/source/ui.adb index fbb1e63..4c4e193 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -459,14 +459,10 @@ package body ui is ------------------------------------------------------------------------------------------ - procedure draw_icon_menu (x, y, width, height : in integer) is + procedure draw_icon_menu (x, y, width, height : in integer; text : in string := "--"; action : in core.pointer := core.idle_skip'access) is offset_x : constant integer := sprite (active, icon_upper_left).width; offset_y : constant integer := sprite (active, icon_upper_left).height; begin - if core.cursor_inside (x, y, width / core.zoom, height / core.zoom) then - prioritize := true; - end if; - -- if height < 2 * sprite (active, icon_upper_left).height or width < 2 * sprite (active, icon_upper_left).width then return; @@ -481,6 +477,16 @@ package body ui is 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); + -- + if core.cursor_inside (x, y, width / core.zoom, height / core.zoom) then + prioritize := true; + -- + core.write_help_box (text); + -- + if core.cursor_mode = core.cursor_left then + action.all; + end if; + end if; end draw_icon_menu; ------------------------------------------------------------------------------------------ @@ -537,6 +543,13 @@ package body ui is ------------------------------------------------------------------------------------------ + procedure iterate_style is + begin + active := style'val ((style'pos (active) + 1) mod style_count); + end iterate_style; + + ------------------------------------------------------------------------------------------ + --~procedure write_ada_code (text : in core.string_box_data; x, y : in integer) is --~word : core.unstring := core.unbound (""); --~-- diff --git a/source/ui.ads b/source/ui.ads index 16a205a..c9cf44e 100644 --- a/source/ui.ads +++ b/source/ui.ads @@ -56,13 +56,15 @@ package ui is procedure draw_menu (x, y, width, height : in integer); procedure draw_tiny_menu (x, y, width, height : in integer); - procedure draw_icon_menu (x, y, width, height : in integer); + procedure draw_icon_menu (x, y, width, height : in integer; text : in string := "--"; action : in core.pointer := core.idle_skip'access); procedure draw_end_turn_button (x, y : in integer); procedure draw_state_box (x, y : in integer); procedure draw_console_box (x, y, width, height : in integer); + procedure iterate_style; + --~procedure write_ada_code (text : in core.string_box_data; x, y : in integer); ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/world.adb b/source/world.adb index ef83c4a..4229ef3 100644 --- a/source/world.adb +++ b/source/world.adb @@ -1042,6 +1042,13 @@ package body world is ------------------------------------------------------------------------------------------ + procedure show_unit is + begin + ui.draw_text ("Heyo world", 600, 600, 0, 0); + end show_unit; + + ------------------------------------------------------------------------------------------ + procedure draw_units (offset, view_from, view_to : in core.vector) is time : float := 0.0; begin diff --git a/source/world.ads b/source/world.ads index 6adf038..1ac43b0 100644 --- a/source/world.ads +++ b/source/world.ads @@ -210,6 +210,8 @@ package world is map : definition; + show_unit_data : unit.enumeration := unit.none; + ------------------------------------------------------------------------------------------ procedure configure; @@ -230,6 +232,7 @@ package world is procedure add_chad (data : in chad.information); procedure draw_unit (data : in unit.enumeration; state : in core.animation; x, y : in integer); + procedure show_unit; procedure resource_cheat_1; procedure resource_cheat_2;