From 48faba3fe0b19d07145c76d90d261d1d73dce718 Mon Sep 17 00:00:00 2001 From: xolatile Date: Fri, 14 Jun 2024 15:08:44 -0400 Subject: [PATCH] More rafactoring, done for today probably... --- source/main.adb | 14 +------------- source/ui.adb | 22 ++++++++++++++++++++-- source/ui.ads | 7 ++++--- source/world.adb | 35 ++++++++++++++++++++++++++++++----- 4 files changed, 55 insertions(+), 23 deletions(-) diff --git a/source/main.adb b/source/main.adb index 26a51df..e8bb26a 100644 --- a/source/main.adb +++ b/source/main.adb @@ -241,7 +241,7 @@ begin world.insert_chad (player); world.insert_chad (opponent); - --~world.load ("heyo"); + world.load ("heyo"); ui.active := ui.style'val (faction.enumeration'pos (chad.description (player.index).kind) + 1); @@ -293,18 +293,6 @@ begin (map_frame_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 := (map_frame_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 (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; - --~end loop; - --~end; - -- signal_list (core.signal_mode).all; -- core.camera.x := world.map.chads (1).x; diff --git a/source/ui.adb b/source/ui.adb index 6d36a49..1473787 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -194,8 +194,6 @@ package body ui is if core.cursor_inside (x, y, core.icon, core.icon) then prioritize := true; -- - draw (icon_selected, x, y); - -- core.write_help_box (text); -- if core.cursor_mode = core.cursor_left then @@ -207,6 +205,26 @@ package body ui is ------------------------------------------------------------------------------------------ + procedure draw_text_in_overicon (text : in string; x, y : in integer; action : core.pointer := core.idle_skip'access) is + begin + draw (overicon, x, y); + -- + write (text, x - 2, y + (core.icon - monoheight) / 2, code => true); + -- + if core.cursor_inside (x, y, core.icon, core.icon) then + prioritize := true; + -- + core.write_help_box (text); + -- + if core.cursor_mode = core.cursor_left then + action.all; + core.cursor_mode := core.cursor_none; + end if; + end if; + end draw_text_in_overicon; + + ------------------------------------------------------------------------------------------ + 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); diff --git a/source/ui.ads b/source/ui.ads index c614c22..9c0e77f 100644 --- a/source/ui.ads +++ b/source/ui.ads @@ -41,9 +41,10 @@ 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_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_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_text_in_overicon ( 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 d9ec742..9668ddc 100644 --- a/source/world.adb +++ b/source/world.adb @@ -1151,7 +1151,8 @@ package body world is -- for index in attribute.enumeration loop ui.draw_icon (attribute.icon (index), attribute.description (index).text.all, x + chad.view_width + skip, y + core.icon); - ui.draw_text (data.attributes (index).value'image, x + chad.view_width + skip, y + 2 * core.icon, core.icon, core.icon, core.more); + --~ui.draw_text (data.attributes (index).value'image, x + chad.view_width + skip, y + 2 * core.icon, core.icon, core.icon, core.more); + ui.draw_text_in_overicon (data.attributes (index).value'image, x + chad.view_width + skip, y + 2 * core.icon); -- skip := skip + core.icon; end loop; @@ -1217,6 +1218,11 @@ package body world is text => material.description (data.materials (8 * index_y + index_x).index).name.all, x => x + index_x * core.icon, y => y + index_y * core.icon); + -- + ui.write (text => (if data.materials (8 * index_y + index_x).value > 0 then data.materials (8 * index_y + index_x).value'image else ""), + x => x + index_x * core.icon + (if data.materials (8 * index_y + index_x).value < 10 then 14 else 5), + y => y + index_y * core.icon + 17, + code => true); end loop; end loop; -- @@ -1263,11 +1269,12 @@ package body world is declare player : chad.information renames world.map.chads (1); -- data : effect.information := location.description (map.locations (index).index).evoke; + done : boolean := false; -- attribute_index : attribute.enumeration; --~skill_index : skill.enumeration; resource_index : resource.enumeration; - --~material_index : material.enumeration; + material_index : material.enumeration; begin case data.kind is when effect.idle => null; @@ -1287,9 +1294,27 @@ package body world is ui.echo ("Player " & (if data.amount < 0 then "lost" else "gained") & integer'image (abs data.amount) & " " & resource.description (resource_index).name.all & " resource points."); -- - --~when effect.modify_material => material_index := material.enumeration'val (data.modifier); - --~player.materials (material_index) := player.materials (material_index) + data.amount; - --~ui.echo ("+" & data.amount'image & " " & material.description (material_index).name.all); + when effect.modify_material => material_index := material.enumeration'val (data.modifier); + -- + for this in material.limit loop + exit when done; + if material.enumeration'pos (player.materials (this).index) = material.enumeration'pos (material_index) then + player.materials (this).value := player.materials (this).value + data.amount; + done := true; + end if; + end loop; + -- + if not done then + for this in material.limit loop + if material.enumeration'pos (player.materials (this).index) = material.enumeration'pos (material.none) then + player.materials (this).index := material_index; + player.materials (this).value := data.amount; + exit; + end if; + end loop; + end if; + -- + ui.echo ("+" & data.amount'image & " " & material.description (material_index).name.all); when others => null; end case; end;