From 83373bbda1258e8e68bf451ea8ffb0ca86633368 Mon Sep 17 00:00:00 2001 From: xolatile Date: Sun, 9 Jun 2024 16:53:27 -0400 Subject: [PATCH] Saving changes before major refactoring... --- source/equipment.ads | 1 + source/main.adb | 2 +- source/ui.adb | 19 +++++++++++++++++++ source/ui.ads | 5 +++-- source/world.adb | 47 +++++++++++++++++++++++++++++------------------ source/world.ads | 2 +- 6 files changed, 54 insertions(+), 22 deletions(-) diff --git a/source/equipment.ads b/source/equipment.ads index cf2f90a..f3413f0 100644 --- a/source/equipment.ads +++ b/source/equipment.ads @@ -57,6 +57,7 @@ package equipment is ------------------------------------------------------------------------------------------ count : constant natural := enumeration'pos (enumeration'last) + 1; + error : constant natural := enumeration'pos (none); default : constant equip_array := (others => none); diff --git a/source/main.adb b/source/main.adb index 633349e..c53a047 100644 --- a/source/main.adb +++ b/source/main.adb @@ -233,7 +233,7 @@ 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); + world.draw_unit (player_1.units (index).index, core.walk, at_x + index * core.icon + 8, at_y + 8, 1); 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; diff --git a/source/ui.adb b/source/ui.adb index 983e977..fb45cbd 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -181,6 +181,25 @@ package body ui is ------------------------------------------------------------------------------------------ + procedure draw_icon_and_text (data : in core.sprite; text : in string; x, y, width : in integer; action : core.pointer := core.idle_skip'access) is + begin + draw_icon_menu (x, y, width, core.icon); + -- + core.draw (data, x, y, factor => 1); + write (text, x + core.icon + 10, y + 10, code => true); + -- + if core.cursor_inside (x, y, core.icon / core.zoom, core.icon / core.zoom) then + prioritize := true; + -- + if core.cursor_mode = core.cursor_left then + action.all; + core.cursor_mode := core.cursor_none; + end if; + end if; + end draw_icon_and_text; + + ------------------------------------------------------------------------------------------ + procedure draw_overicon (data : in core.sprite; text : in string; x, y : in integer; action : core.pointer := core.idle_skip'access) is begin core.draw (data, x, y, factor => 1); diff --git a/source/ui.ads b/source/ui.ads index c63c67c..3b3711c 100644 --- a/source/ui.ads +++ b/source/ui.ads @@ -36,8 +36,9 @@ package ui is procedure draw_separator (x, y, width : in integer); - procedure draw_icon (data : in core.sprite; text : in string; x, y : in integer; action : core.pointer := core.idle_skip'access); - procedure draw_overicon (data : in core.sprite; text : in string; x, y : in integer; action : core.pointer := core.idle_skip'access); + procedure draw_icon (data : in core.sprite; text : in string; x, y : in integer; action : core.pointer := core.idle_skip'access); + procedure draw_icon_and_text (data : in core.sprite; text : in string; x, y, width : in integer; action : core.pointer := core.idle_skip'access); + procedure draw_overicon (data : in core.sprite; text : in string; x, y : in integer; action : core.pointer := core.idle_skip'access); procedure draw_sprite (data : in core.sprite; text : in string; x, y, offset : in integer; action : core.pointer := core.idle_skip'access); diff --git a/source/world.adb b/source/world.adb index e9e8e52..defe077 100644 --- a/source/world.adb +++ b/source/world.adb @@ -123,6 +123,13 @@ package body world is ------------------------------------------------------------------------------------------ + function equipment_valid (data : in equipment.enumeration) return boolean is + begin + return equipment.enumeration'pos (data) /= equipment.error; + end equipment_valid; + + ------------------------------------------------------------------------------------------ + procedure make (index : in biome; width, height, chad_limit : in natural) is begin core.echo (core.comment, "-- Procedurally generating new map..."); @@ -1031,12 +1038,12 @@ package body world is ------------------------------------------------------------------------------------------ - procedure draw_unit (data : in unit.enumeration; state : in core.animation; x, y : in integer) is + procedure draw_unit (data : in unit.enumeration; state : in core.animation; x, y, factor : in integer) is begin - core.draw (unit.base (unit.description (data).kind), x, y, state => state); + core.draw (unit.base (unit.description (data).kind), x, y, state => state, factor => factor); -- for kind in equipment.kind loop - core.draw (equipment.sprite (unit.description (data).equipments (kind)), x, y, state => state); + core.draw (equipment.sprite (unit.description (data).equipments (kind)), x, y, state => state, factor => factor); end loop; end draw_unit; @@ -1068,9 +1075,7 @@ package body world is at_x := core.center_x (width) + offset + unit.view_width; end if; -- - ui.draw_icon_menu (at_x, at_y, core.icon * 3, core.icon, attribute.description (index).text.all); - core.draw (attribute.icon (index), at_x, at_y, factor => 1); - ui.write (data.attributes (index)'image, at_x + core.icon + more, at_y + more, code => true); + ui.draw_icon_and_text (attribute.icon (index), data.attributes (index)'image, at_x, at_y, 3 * core.icon); -- at_x := at_x + 3 * core.icon; end loop; @@ -1103,14 +1108,19 @@ package body world is at_x := core.center_x (width) + offset; end if; -- - ui.draw_icon_menu (at_x, at_y, (width - 2 * offset) / 2, core.icon, equipment.description (data.equipments (index)).name.all); - ui.write (equipment.description (data.equipments (index)).name.all, at_x + core.icon + more, at_y + more, code => true); - -- - if equipment.enumeration'pos (data.equipments (index)) /= equipment.enumeration'pos (equipment.none) then - core.draw (equipment.icon (data.equipments (index)), at_x, at_y, factor => 1); - else - core.draw (equipment.slot (index), at_x, at_y, factor => 1); - end if; + ui.draw_icon_and_text (data => (if equipment_valid (data.equipments (index)) then equipment.icon (data.equipments (index)) else equipment.slot (index)), + text => equipment.description (data.equipments (index)).name.all, + x => at_x, + y => at_y, + width => (width - 2 * offset) / 2); + --~ui.draw_icon_menu (at_x, at_y, (width - 2 * offset) / 2, core.icon, equipment.description (data.equipments (index)).name.all); + --~ui.write (equipment.description (data.equipments (index)).name.all, at_x + core.icon + more, at_y + more, code => true); + --~-- + --~if equipment.enumeration'pos (data.equipments (index)) /= equipment.enumeration'pos (equipment.none) then + --~core.draw (equipment.icon (data.equipments (index)), at_x, at_y, factor => 1); + --~else + --~core.draw (equipment.slot (index), at_x, at_y, factor => 1); + --~end if; -- at_x := at_x + (width - 2 * offset) / 2; end loop; @@ -1127,10 +1137,11 @@ package body world is if map.views (map.units (index).x, map.units (index).y) and map.units (index).x > view_from.x and map.units (index).x < view_from.x + view_to.x and map.units (index).y > view_from.y and map.units (index).y < view_from.y + view_to.y then - draw_unit (data => unit.enumeration'val (map.units (index).index), - state => core.animation'val (map.units (index).state), - x => offset.x + (map.units (index).x - core.camera.x) * core.base * core.zoom, - y => offset.y + (map.units (index).y - core.camera.y) * core.base * core.zoom); + draw_unit (data => unit.enumeration'val (map.units (index).index), + state => core.animation'val (map.units (index).state), + x => offset.x + (map.units (index).x - core.camera.x) * core.base * core.zoom, + y => offset.y + (map.units (index).y - core.camera.y) * core.base * core.zoom, + factor => core.zoom); -- core.increment (drawn_units); end if; diff --git a/source/world.ads b/source/world.ads index 1ac43b0..0372db5 100644 --- a/source/world.ads +++ b/source/world.ads @@ -231,7 +231,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 draw_unit (data : in unit.enumeration; state : in core.animation; x, y, factor : in integer); procedure show_unit; procedure resource_cheat_1;