diff --git a/Pal.Client/Commands/PalCommand.cs b/Pal.Client/Commands/PalCommand.cs index 4d9ff97..336623f 100644 --- a/Pal.Client/Commands/PalCommand.cs +++ b/Pal.Client/Commands/PalCommand.cs @@ -82,7 +82,7 @@ namespace Pal.Client.Commands #if DEBUG case "update-saves": LocalState.UpdateAll(); - Service.Chat.Print(Localization.Command_pal_updatesaves); + _chatGui.PalMessage(Localization.Command_pal_updatesaves); break; #endif @@ -124,7 +124,7 @@ namespace Pal.Client.Commands var playerPosition = _clientState.LocalPlayer?.Position; if (playerPosition == null) return; - _chatGui.Print($"[Palace Pal] {playerPosition}"); + _chatGui.PalMessage($"{playerPosition}"); var nearbyMarkers = state.Markers .Where(m => predicate(m)) diff --git a/Pal.Client/DependencyInjection/StatisticsService.cs b/Pal.Client/DependencyInjection/StatisticsService.cs index 23f2ba9..bdbbaac 100644 --- a/Pal.Client/DependencyInjection/StatisticsService.cs +++ b/Pal.Client/DependencyInjection/StatisticsService.cs @@ -54,7 +54,7 @@ namespace Pal.Client.DependencyInjection } catch (RpcException e) when (e.StatusCode == StatusCode.PermissionDenied) { - _chatGui.Print(Localization.Command_pal_stats_CurrentFloor); + _chatGui.PalError(Localization.Command_pal_stats_CurrentFloor); } catch (Exception e) { diff --git a/Pal.Client/Extensions/ChatExtensions.cs b/Pal.Client/Extensions/ChatExtensions.cs index 31b39ef..ff7cac4 100644 --- a/Pal.Client/Extensions/ChatExtensions.cs +++ b/Pal.Client/Extensions/ChatExtensions.cs @@ -1,4 +1,6 @@ using Dalamud.Game.Gui; +using Dalamud.Game.Text; +using Dalamud.Game.Text.SeStringHandling; using Pal.Client.Properties; namespace Pal.Client.Extensions @@ -6,6 +8,21 @@ namespace Pal.Client.Extensions public static class ChatExtensions { public static void PalError(this ChatGui chat, string e) - => chat.PrintError($"[{Localization.Palace_Pal}] {e}"); + { + chat.PrintChat(new XivChatEntry + { + Message = new SeStringBuilder() + .AddUiForeground($"[{Localization.Palace_Pal}] ", 16) + .AddText(e).Build(), + Type = XivChatType.Urgent + }); + } + + public static void PalMessage(this ChatGui chat, string message) + { + chat.Print(new SeStringBuilder() + .AddUiForeground($"[{Localization.Palace_Pal}] ", 57) + .AddText(message).Build()); + } } } diff --git a/Pal.Client/Hooks.cs b/Pal.Client/Hooks.cs index dbdcb4f..24aa439 100644 --- a/Pal.Client/Hooks.cs +++ b/Pal.Client/Hooks.cs @@ -72,7 +72,7 @@ namespace Pal.Client /* if (Service.Configuration.BetaKey == "VFX") - Service.Chat.Print($"{vfxPath} on {obj}"); + _chatGui.PalPrint($"{vfxPath} on {obj}"); */ if (obj is BattleChara bc && (bc.NameId == /* potd */ 5042 || bc.NameId == /* hoh */ 7395)) diff --git a/Pal.Client/Rendering/SplatoonRenderer.cs b/Pal.Client/Rendering/SplatoonRenderer.cs index 2fc5c02..4ebd659 100644 --- a/Pal.Client/Rendering/SplatoonRenderer.cs +++ b/Pal.Client/Rendering/SplatoonRenderer.cs @@ -14,6 +14,7 @@ using System.Reflection; using Dalamud.Game.ClientState; using Dalamud.Game.Gui; using Pal.Client.DependencyInjection; +using Pal.Client.Extensions; namespace Pal.Client.Rendering { @@ -25,7 +26,8 @@ namespace Pal.Client.Rendering private readonly ClientState _clientState; private readonly ChatGui _chatGui; - public SplatoonRenderer(DalamudPluginInterface pluginInterface, IDalamudPlugin dalamudPlugin, DebugState debugState, + public SplatoonRenderer(DalamudPluginInterface pluginInterface, IDalamudPlugin dalamudPlugin, + DebugState debugState, ClientState clientState, ChatGui chatGui) { _debugState = debugState; @@ -109,7 +111,7 @@ namespace Pal.Client.Rendering elements.Cast().Select(x => x.Delegate).ToArray(), new[] { Environment.TickCount64 + 10000 })) { - _chatGui.PrintError("Could not draw markers :("); + _chatGui.PalMessage("Could not draw markers :("); } } } @@ -129,10 +131,10 @@ namespace Pal.Client.Rendering string? pluginName = (string?)t.GetType().GetProperty("Name")?.GetValue(t); if (assemblyName?.Name == "Splatoon" && pluginName != "Splatoon") { - _chatGui.PrintError( - $"[Palace Pal] Splatoon is installed under the plugin name '{pluginName}', which is incompatible with the Splatoon API."); - _chatGui.Print( - "[Palace Pal] You need to install Splatoon from the official repository at https://github.com/NightmareXIV/MyDalamudPlugins."); + _chatGui.PalError( + $"Splatoon is installed under the plugin name '{pluginName}', which is incompatible with the Splatoon API."); + _chatGui.PalMessage( + "You need to install Splatoon from the official repository at https://github.com/NightmareXIV/MyDalamudPlugins."); return; } } @@ -142,7 +144,7 @@ namespace Pal.Client.Rendering // not relevant } - _chatGui.PrintError("Could not draw markers, is Splatoon installed and enabled?"); + _chatGui.PalError("Could not draw markers, is Splatoon installed and enabled?"); } } diff --git a/Pal.Client/Scheduled/QueuedImport.cs b/Pal.Client/Scheduled/QueuedImport.cs index d1e8dda..fe263b1 100644 --- a/Pal.Client/Scheduled/QueuedImport.cs +++ b/Pal.Client/Scheduled/QueuedImport.cs @@ -81,7 +81,7 @@ namespace Pal.Client.Scheduled }); _configurationManager.Save(_configuration); - _chatGui.Print(string.Format(Localization.ImportCompleteStatistics, import.ImportedTraps, + _chatGui.PalMessage(string.Format(Localization.ImportCompleteStatistics, import.ImportedTraps, import.ImportedHoardCoffers)); } catch (Exception e) @@ -95,13 +95,13 @@ namespace Pal.Client.Scheduled { if (import.Export.ExportVersion != ExportConfig.ExportVersion) { - _chatGui.PrintError(Localization.Error_ImportFailed_IncompatibleVersion); + _chatGui.PalError(Localization.Error_ImportFailed_IncompatibleVersion); return false; } if (!Guid.TryParse(import.Export.ExportId, out Guid exportId) || import.ExportId == Guid.Empty) { - _chatGui.PrintError(Localization.Error_ImportFailed_InvalidFile); + _chatGui.PalError(Localization.Error_ImportFailed_InvalidFile); return false; } @@ -110,7 +110,7 @@ namespace Pal.Client.Scheduled if (string.IsNullOrEmpty(import.Export.ServerUrl)) { // If we allow for backups as import/export, this should be removed - _chatGui.PrintError(Localization.Error_ImportFailed_InvalidFile); + _chatGui.PalError(Localization.Error_ImportFailed_InvalidFile); return false; } diff --git a/Pal.Client/Windows/ConfigWindow.cs b/Pal.Client/Windows/ConfigWindow.cs index e9fb03e..fd2118e 100644 --- a/Pal.Client/Windows/ConfigWindow.cs +++ b/Pal.Client/Windows/ConfigWindow.cs @@ -22,6 +22,7 @@ using Dalamud.Game.Gui; using Pal.Client.Properties; using Pal.Client.Configuration; using Pal.Client.DependencyInjection; +using Pal.Client.Extensions; namespace Pal.Client.Windows { @@ -351,7 +352,8 @@ namespace Pal.Client.Windows ImGui.Text(Localization.Config_Splatoon_Test); ImGui.BeginDisabled(!(_renderAdapter.Implementation is IDrawDebugItems)); if (ImGui.Button(Localization.Config_Splatoon_DrawCircles)) - (_renderAdapter.Implementation as IDrawDebugItems)?.DrawDebugItems(_trapConfig.Color, _hoardConfig.Color); + (_renderAdapter.Implementation as IDrawDebugItems)?.DrawDebugItems(_trapConfig.Color, + _hoardConfig.Color); ImGui.EndDisabled(); ImGui.EndTabItem(); @@ -385,7 +387,8 @@ namespace Pal.Client.Windows if (_silverConfig.Show) { - int silverCoffers = _floorService.EphemeralMarkers.Count(x => x.Type == Marker.EType.SilverCoffer); + int silverCoffers = + _floorService.EphemeralMarkers.Count(x => x.Type == Marker.EType.SilverCoffer); ImGui.Text( $"{silverCoffers} silver coffer{(silverCoffers == 1 ? "" : "s")} visible on current floor"); } @@ -475,17 +478,17 @@ namespace Pal.Client.Windows await using var output = File.Create(destinationPath); export.WriteTo(output); - _chatGui.Print($"Export saved as {destinationPath}."); + _chatGui.PalMessage($"Export saved as {destinationPath}."); } else { - _chatGui.PrintError("Export failed due to server error."); + _chatGui.PalError("Export failed due to server error."); } } catch (Exception e) { PluginLog.Error(e, "Export failed"); - _chatGui.PrintError($"Export failed: {e}"); + _chatGui.PalError($"Export failed: {e}"); } }); }