From 2241ba8279a694806aae84e496b133a74584b5ce Mon Sep 17 00:00:00 2001 From: xolatile Date: Wed, 29 May 2024 09:26:10 -0400 Subject: [PATCH] Added prototype notifications, they are bad... --- source/effect.adb | 4 +++- source/effect.ads | 5 ++++- source/main.adb | 3 ++- source/notification.adb | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ source/notification.ads | 27 ++++++++++++++++++++++ source/world.adb | 8 +++---- source/world.ads | 28 +++++++++++------------ 7 files changed, 114 insertions(+), 21 deletions(-) create mode 100644 source/notification.adb create mode 100644 source/notification.ads diff --git a/source/effect.adb b/source/effect.adb index ef4cd3d..02a59f3 100644 --- a/source/effect.adb +++ b/source/effect.adb @@ -2,7 +2,7 @@ -- -- GNU General Public Licence (version 3 or later) -with core, attribute, skill, resource, deity, material, magic, equipment, unit, construction, chad, world; +with core, notification, attribute, skill, resource, deity, material, magic, equipment, unit, construction, chad, world; use type core.point; @@ -47,6 +47,8 @@ package body effect is -- when take_material => core.increment (world.map.chads (1).materials (material.enumeration'val (data.modifier)).value, data.amount); end case; + -- + notification.show (data.notify); end apply; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/effect.ads b/source/effect.ads index 88922c4..23a4e5a 100644 --- a/source/effect.ads +++ b/source/effect.ads @@ -2,6 +2,8 @@ -- -- GNU General Public Licence (version 3 or later) +with notification; + package effect is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -24,9 +26,10 @@ package effect is amount : natural; permanent : boolean; duration : natural; + notify : notification.enumeration; end record; - none : constant value := (idle, 0, 0, false, 0); + none : constant value := (idle, 0, 0, false, 0, notification.none); ------------------------------------------------------------------------------------------ diff --git a/source/main.adb b/source/main.adb index 23a6b54..20af772 100644 --- a/source/main.adb +++ b/source/main.adb @@ -4,7 +4,7 @@ pragma ada_2012; -with core, ui, effect, attribute, skill, resource, faction, deity, material, magic, equipment, unit, construction, chad, world; +with core, ui, notification, effect, attribute, skill, resource, faction, deity, material, magic, equipment, unit, construction, chad, world; with ada.strings.unbounded; use ada.strings.unbounded; @@ -340,6 +340,7 @@ begin core.camera.x := world.map.chads (1).x; core.camera.y := world.map.chads (1).y; -- + notification.synchronize; ui.synchronize; end loop gameplay_loop; diff --git a/source/notification.adb b/source/notification.adb new file mode 100644 index 0000000..cccd818 --- /dev/null +++ b/source/notification.adb @@ -0,0 +1,60 @@ +-- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic +-- +-- GNU General Public Licence (version 3 or later) + +with core, ui; + +package body notification is + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + + type information is record + name : core.short_string; + text : core.long_string; + end record; + + ------------------------------------------------------------------------------------------ + + shown : array (enumeration) of boolean := (others => false); + + trait : constant array (enumeration) of information := ( + none => ("-- ", "-- "), + well_of_strength => ("Gold ", "#1Gold#0 is precious yellowish shiny metal, valued since ancient times. "), + well_of_agility => ("Wood ", "#1Wood#0 is just bundle of lignin and cellulose, nothing more. "), + well_of_knowledge => ("Leather ", "#1Leather#0 is general purpose resource, used for decorations. ") + ); + + ------------------------------------------------------------------------------------------ + + procedure draw (index : in enumeration; x, y : in integer; center : in boolean := false) is + use type core.signal_code; + begin + ui.draw_tiny_menu (x, y, 960, 128); + -- + ui.write (trait (index).name, x + 32, y + 32); + ui.write (trait (index).text, x + 32, y + 64); + -- + if core.cursor_inside (x, y, 960, 128) and core.signal_mode = core.signal_space then + shown (index) := false; + end if; + end draw; + + ------------------------------------------------------------------------------------------ + + procedure show (index : in enumeration) is begin if index = none then return; end if; shown (index) := true; end show; + procedure hide (index : in enumeration) is begin if index = none then return; end if; shown (index) := false; end hide; + + ------------------------------------------------------------------------------------------ + + procedure synchronize is + begin + for index in enumeration loop + if shown (index) then + draw (index, core.center_x (960), core.center_y (128)); + end if; + end loop; + end synchronize; + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + +end notification; diff --git a/source/notification.ads b/source/notification.ads new file mode 100644 index 0000000..44cd170 --- /dev/null +++ b/source/notification.ads @@ -0,0 +1,27 @@ +-- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic +-- +-- GNU General Public Licence (version 3 or later) + +with core; + +package notification is + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + + type enumeration is ( + none, + well_of_strength, + well_of_agility, + well_of_knowledge + ); + + ------------------------------------------------------------------------------------------ + + procedure show (index : in enumeration); + procedure hide (index : in enumeration); + + procedure synchronize; + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + +end notification; diff --git a/source/world.adb b/source/world.adb index 97b21bb..5900148 100644 --- a/source/world.adb +++ b/source/world.adb @@ -15,10 +15,10 @@ package body world is lake_count : constant natural := 6; - landmark_limit : constant integer := 90; - location_limit : constant integer := 30; - construction_limit : constant natural := 60; - equipment_limit : constant natural := 600; + landmark_limit : constant integer := 480; + location_limit : constant integer := 240; + construction_limit : constant natural := 120; + equipment_limit : constant natural := 300; unit_limit : constant natural := 60; tiles : array (biome) of core.sprite; diff --git a/source/world.ads b/source/world.ads index 9f05585..b197539 100644 --- a/source/world.ads +++ b/source/world.ads @@ -2,7 +2,7 @@ -- -- GNU General Public Licence (version 3 or later) -with core, material, equipment, unit, construction, chad, effect; +with core, notification, material, equipment, unit, construction, chad, effect; package world is @@ -111,20 +111,20 @@ package world is ); location_trait : constant array (location_index) of location_stats := ( - well_of_agility => ("Well of Agility ", true, 4, 3, (effect.speed, 2, 0, false, 0)), - well_of_knowledge => ("Well of Knowledge ", true, 4, 3, (effect.wisdom, 2, 0, false, 0)), - well_of_strength => ("Well of Strength ", true, 4, 3, (effect.offense, 2, 0, false, 0)), - old_dwarven_grave => ("Old Dwarven Grave ", true, 1, 3, (effect.defense, 1, 0, false, 0)), - huge_ancient_urn => ("Huge Ancient Urn ", true, 1, 3, (effect.offense, 1, 0, false, 0)), + well_of_agility => ("Well of Agility ", true, 4, 3, (effect.speed, 2, 0, false, 0, notification.well_of_agility)), + well_of_knowledge => ("Well of Knowledge ", true, 4, 3, (effect.wisdom, 2, 0, false, 0, notification.well_of_knowledge)), + well_of_strength => ("Well of Strength ", true, 4, 3, (effect.offense, 2, 0, false, 0, notification.well_of_strength)), + old_dwarven_grave => ("Old Dwarven Grave ", true, 1, 3, (effect.defense, 1, 0, false, 0, notification.none)), + huge_ancient_urn => ("Huge Ancient Urn ", true, 1, 3, (effect.offense, 1, 0, false, 0, notification.none)), -- - banana_tree => ("Banana Tree ", true, 4, 3, (effect.take_material, material.enumeration'pos (material.banana), 4, true, 600)), - apple_tree => ("Apple Tree ", true, 4, 3, (effect.take_material, material.enumeration'pos (material.apple), 6, true, 600)), - cherry_tree => ("Cherry Tree ", true, 4, 3, (effect.take_material, material.enumeration'pos (material.cherry), 6, true, 600)), - lemon_tree => ("Lemon Tree ", true, 4, 3, (effect.take_material, material.enumeration'pos (material.lemon), 6, true, 600)), - orange_tree => ("Orange Tree ", true, 4, 3, (effect.take_material, material.enumeration'pos (material.orange), 6, true, 600)), - pear_tree => ("Pear Tree ", true, 4, 3, (effect.take_material, material.enumeration'pos (material.pear), 6, true, 600)), - peach_tree => ("Peach Tree ", true, 4, 3, (effect.take_material, material.enumeration'pos (material.peach), 6, true, 600)), - plum_tree => ("Plum Tree ", true, 4, 3, (effect.take_material, material.enumeration'pos (material.plum), 6, true, 600)) + banana_tree => ("Banana Tree ", true, 4, 3, (effect.take_material, material.enumeration'pos (material.banana), 4, true, 600, notification.none)), + apple_tree => ("Apple Tree ", true, 4, 3, (effect.take_material, material.enumeration'pos (material.apple), 6, true, 600, notification.none)), + cherry_tree => ("Cherry Tree ", true, 4, 3, (effect.take_material, material.enumeration'pos (material.cherry), 6, true, 600, notification.none)), + lemon_tree => ("Lemon Tree ", true, 4, 3, (effect.take_material, material.enumeration'pos (material.lemon), 6, true, 600, notification.none)), + orange_tree => ("Orange Tree ", true, 4, 3, (effect.take_material, material.enumeration'pos (material.orange), 6, true, 600, notification.none)), + pear_tree => ("Pear Tree ", true, 4, 3, (effect.take_material, material.enumeration'pos (material.pear), 6, true, 600, notification.none)), + peach_tree => ("Peach Tree ", true, 4, 3, (effect.take_material, material.enumeration'pos (material.peach), 6, true, 600, notification.none)), + plum_tree => ("Plum Tree ", true, 4, 3, (effect.take_material, material.enumeration'pos (material.plum), 6, true, 600, notification.none)) ); map : information;