Make chat messages/errors consistent

rendering
Liza 2023-02-16 10:46:19 +01:00
parent e3459a0182
commit 3d560fad7f
7 changed files with 43 additions and 21 deletions

View File

@ -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))

View File

@ -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)
{

View File

@ -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());
}
}
}

View File

@ -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))

View File

@ -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<SplatoonElement>().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?");
}
}

View File

@ -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;
}

View File

@ -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}");
}
});
}