From e45b72a65501caebe31ae7c2b6b4dec2bc35af63 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Sun, 26 Feb 2023 17:31:37 +0100 Subject: [PATCH] Add gold coffers (#10) --- .../Configuration/IPalacePalConfiguration.cs | 8 ++++ Pal.Client/Floors/FrameworkService.cs | 25 ++++++++++-- Pal.Client/Floors/MemoryLocation.cs | 1 + .../Properties/Localization.Designer.cs | 39 ++++++++++++++++++- Pal.Client/Properties/Localization.resx | 16 +++++++- Pal.Client/Rendering/MarkerConfig.cs | 1 + Pal.Client/Scheduled/QueuedConfigUpdate.cs | 1 - Pal.Client/Windows/ConfigWindow.cs | 33 ++++++++++++++++ 8 files changed, 117 insertions(+), 7 deletions(-) diff --git a/Pal.Client/Configuration/IPalacePalConfiguration.cs b/Pal.Client/Configuration/IPalacePalConfiguration.cs index 848dc36..55dcab7 100644 --- a/Pal.Client/Configuration/IPalacePalConfiguration.cs +++ b/Pal.Client/Configuration/IPalacePalConfiguration.cs @@ -56,6 +56,14 @@ namespace Pal.Client.Configuration OnlyVisibleAfterPomander = false, Fill = true }; + + public MarkerConfiguration GoldCoffers { get; set; } = new() + { + Show = false, + Color = ImGui.ColorConvertFloat4ToU32(new Vector4(1, 1, 0, 0.4f)), + OnlyVisibleAfterPomander = false, + Fill = true + }; } public class MarkerConfiguration diff --git a/Pal.Client/Floors/FrameworkService.cs b/Pal.Client/Floors/FrameworkService.cs index 84fde6f..4e6216f 100644 --- a/Pal.Client/Floors/FrameworkService.cs +++ b/Pal.Client/Floors/FrameworkService.cs @@ -250,6 +250,12 @@ namespace Pal.Client.Floors CreateRenderElement(location, elements, DetermineColor(location), _configuration.DeepDungeons.SilverCoffers); } + else if (location.Type == MemoryLocation.EType.GoldCoffer && + _configuration.DeepDungeons.GoldCoffers.Show) + { + CreateRenderElement(location, elements, DetermineColor(location), + _configuration.DeepDungeons.GoldCoffers); + } } if (elements.Count == 0) @@ -279,10 +285,12 @@ namespace Pal.Client.Floors private uint DetermineColor(EphemeralLocation location) { - if (location.Type == MemoryLocation.EType.SilverCoffer) - return _configuration.DeepDungeons.SilverCoffers.Color; - - return RenderData.ColorInvisible; + return location.Type switch + { + MemoryLocation.EType.SilverCoffer => _configuration.DeepDungeons.SilverCoffers.Color, + MemoryLocation.EType.GoldCoffer => _configuration.DeepDungeons.GoldCoffers.Color, + _ => RenderData.ColorInvisible + }; } private void CreateRenderElement(MemoryLocation location, List elements, uint color, @@ -411,6 +419,15 @@ namespace Pal.Client.Floors Seen = true, }); break; + + case 2007358: + ephemeralLocations.Add(new EphemeralLocation + { + Type = MemoryLocation.EType.GoldCoffer, + Position = obj.Position, + Seen = true + }); + break; } } diff --git a/Pal.Client/Floors/MemoryLocation.cs b/Pal.Client/Floors/MemoryLocation.cs index 5b9a6ca..d197cce 100644 --- a/Pal.Client/Floors/MemoryLocation.cs +++ b/Pal.Client/Floors/MemoryLocation.cs @@ -26,6 +26,7 @@ namespace Pal.Client.Floors Hoard, SilverCoffer, + GoldCoffer, } public override bool Equals(object? obj) diff --git a/Pal.Client/Properties/Localization.Designer.cs b/Pal.Client/Properties/Localization.Designer.cs index 5811bd6..8de9b08 100644 --- a/Pal.Client/Properties/Localization.Designer.cs +++ b/Pal.Client/Properties/Localization.Designer.cs @@ -176,6 +176,43 @@ namespace Pal.Client.Properties { } } + /// + /// Looks up a localized string similar to Gold Coffer color. + /// + internal static string Config_GoldCoffer_Color { + get { + return ResourceManager.GetString("Config_GoldCoffer_Color", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Draw filled. + /// + internal static string Config_GoldCoffer_Filled { + get { + return ResourceManager.GetString("Config_GoldCoffer_Filled", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show gold coffers on current floor. + /// + internal static string Config_GoldCoffer_Show { + get { + return ResourceManager.GetString("Config_GoldCoffer_Show", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Shows nearby gold coffers (containing pomanders) on the current floor. + ///This is not synchronized with other players and not saved between floors/runs.. + /// + internal static string Config_GoldCoffers_ToolTip { + get { + return ResourceManager.GetString("Config_GoldCoffers_ToolTip", resourceCulture); + } + } + /// /// Looks up a localized string similar to Hoard Coffer color. /// @@ -357,7 +394,7 @@ namespace Pal.Client.Properties { } /// - /// Looks up a localized string similar to Shows all the silver coffers visible to you on the current floor. + /// Looks up a localized string similar to Shows nearby silver coffers (gear upgrades and magicites) on the current floor. ///This is not synchronized with other players and not saved between floors/runs.. /// internal static string Config_SilverCoffers_ToolTip { diff --git a/Pal.Client/Properties/Localization.resx b/Pal.Client/Properties/Localization.resx index 25c4a9c..40e6369 100644 --- a/Pal.Client/Properties/Localization.resx +++ b/Pal.Client/Properties/Localization.resx @@ -146,7 +146,7 @@ When using a Pomander of Safety, all traps are hidden. Show silver coffers on current floor - Shows all the silver coffers visible to you on the current floor. + Shows nearby silver coffers (gear upgrades and magicites) on the current floor. This is not synchronized with other players and not saved between floors/runs. @@ -156,6 +156,20 @@ This is not synchronized with other players and not saved between floors/runs.Draw filled Whether silver coffers should only be drawn with the circle outline or as filled circle. + + Show gold coffers on current floor + + + Shows nearby gold coffers (containing pomanders) on the current floor. +This is not synchronized with other players and not saved between floors/runs. + + + Gold Coffer color + + + Draw filled + Whether gold coffers should only be drawn with the circle outline or as filled circle. + diff --git a/Pal.Client/Rendering/MarkerConfig.cs b/Pal.Client/Rendering/MarkerConfig.cs index 0bc25cf..830ea4a 100644 --- a/Pal.Client/Rendering/MarkerConfig.cs +++ b/Pal.Client/Rendering/MarkerConfig.cs @@ -12,6 +12,7 @@ namespace Pal.Client.Rendering { MemoryLocation.EType.Trap, new MarkerConfig { Radius = 1.7f } }, { MemoryLocation.EType.Hoard, new MarkerConfig { Radius = 1.7f, OffsetY = -0.03f } }, { MemoryLocation.EType.SilverCoffer, new MarkerConfig { Radius = 1f } }, + { MemoryLocation.EType.GoldCoffer, new MarkerConfig { Radius = 1f } }, }; public float OffsetY { get; private init; } diff --git a/Pal.Client/Scheduled/QueuedConfigUpdate.cs b/Pal.Client/Scheduled/QueuedConfigUpdate.cs index 9810f94..485120c 100644 --- a/Pal.Client/Scheduled/QueuedConfigUpdate.cs +++ b/Pal.Client/Scheduled/QueuedConfigUpdate.cs @@ -22,7 +22,6 @@ namespace Pal.Client.Scheduled protected override void Run(QueuedConfigUpdate queued, ref bool recreateLayout) { - // TODO filter stuff if offline _renderAdapter.ConfigUpdated(); } } diff --git a/Pal.Client/Windows/ConfigWindow.cs b/Pal.Client/Windows/ConfigWindow.cs index a23b8d9..1f52913 100644 --- a/Pal.Client/Windows/ConfigWindow.cs +++ b/Pal.Client/Windows/ConfigWindow.cs @@ -47,6 +47,7 @@ namespace Pal.Client.Windows private ConfigurableMarker _trapConfig = new(); private ConfigurableMarker _hoardConfig = new(); private ConfigurableMarker _silverConfig = new(); + private ConfigurableMarker _goldConfig = new(); private string? _connectionText; private bool _switchToCommunityTab; @@ -124,6 +125,7 @@ namespace Pal.Client.Windows _trapConfig = new ConfigurableMarker(_configuration.DeepDungeons.Traps); _hoardConfig = new ConfigurableMarker(_configuration.DeepDungeons.HoardCoffers); _silverConfig = new ConfigurableMarker(_configuration.DeepDungeons.SilverCoffers); + _goldConfig = new ConfigurableMarker(_configuration.DeepDungeons.GoldCoffers); _connectionText = null; UpdateLastImport(); @@ -162,6 +164,7 @@ namespace Pal.Client.Windows _configuration.DeepDungeons.Traps = _trapConfig.Build(); _configuration.DeepDungeons.HoardCoffers = _hoardConfig.Build(); _configuration.DeepDungeons.SilverCoffers = _silverConfig.Build(); + _configuration.DeepDungeons.GoldCoffers = _goldConfig.Build(); _configurationManager.Save(_configuration); @@ -174,6 +177,7 @@ namespace Pal.Client.Windows { if (ImGui.BeginTabItem($"{Localization.ConfigTab_DeepDungeons}###TabDeepDungeons")) { + ImGui.PushID("trap"); ImGui.Checkbox(Localization.Config_Traps_Show, ref _trapConfig.Show); ImGui.Indent(); ImGui.BeginDisabled(!_trapConfig.Show); @@ -184,9 +188,11 @@ namespace Pal.Client.Windows ImGuiComponents.HelpMarker(Localization.Config_Traps_HideImpossible_ToolTip); ImGui.EndDisabled(); ImGui.Unindent(); + ImGui.PopID(); ImGui.Separator(); + ImGui.PushID("hoard"); ImGui.Checkbox(Localization.Config_HoardCoffers_Show, ref _hoardConfig.Show); ImGui.Indent(); ImGui.BeginDisabled(!_hoardConfig.Show); @@ -199,9 +205,11 @@ namespace Pal.Client.Windows ImGuiComponents.HelpMarker(Localization.Config_HoardCoffers_HideImpossible_ToolTip); ImGui.EndDisabled(); ImGui.Unindent(); + ImGui.PopID(); ImGui.Separator(); + ImGui.PushID("silver"); ImGui.Checkbox(Localization.Config_SilverCoffer_Show, ref _silverConfig.Show); ImGuiComponents.HelpMarker(Localization.Config_SilverCoffers_ToolTip); ImGui.Indent(); @@ -212,6 +220,22 @@ namespace Pal.Client.Windows ImGui.Checkbox(Localization.Config_SilverCoffer_Filled, ref _silverConfig.Fill); ImGui.EndDisabled(); ImGui.Unindent(); + ImGui.PopID(); + + ImGui.Separator(); + + ImGui.PushID("gold"); + ImGui.Checkbox(Localization.Config_GoldCoffer_Show, ref _goldConfig.Show); + ImGuiComponents.HelpMarker(Localization.Config_GoldCoffers_ToolTip); + ImGui.Indent(); + ImGui.BeginDisabled(!_goldConfig.Show); + ImGui.Spacing(); + ImGui.ColorEdit4(Localization.Config_GoldCoffer_Color, ref _goldConfig.Color, + ImGuiColorEditFlags.NoInputs); + ImGui.Checkbox(Localization.Config_GoldCoffer_Filled, ref _goldConfig.Fill); + ImGui.EndDisabled(); + ImGui.Unindent(); + ImGui.PopID(); ImGui.Separator(); @@ -408,6 +432,15 @@ namespace Pal.Client.Windows $"{silverCoffers} silver coffer{(silverCoffers == 1 ? "" : "s")} visible on current floor"); } + if (_goldConfig.Show) + { + int goldCoffers = + _floorService.EphemeralLocations.Count(x => + x.Type == MemoryLocation.EType.GoldCoffer); + ImGui.Text( + $"{goldCoffers} silver coffer{(goldCoffers == 1 ? "" : "s")} visible on current floor"); + } + ImGui.Text($"Pomander of Sight: {_territoryState.PomanderOfSight}"); ImGui.Text($"Pomander of Intuition: {_territoryState.PomanderOfIntuition}"); }