From d6045f3c3334d291db7fb032a0322c9287b18009 Mon Sep 17 00:00:00 2001 From: Anna Date: Wed, 28 Apr 2021 10:41:34 -0400 Subject: [PATCH] feat: pull strings into resources file --- Peeping Tom/Peeping Tom.csproj | 11 + Peeping Tom/PluginUi.cs | 99 ++--- Peeping Tom/Resources/Language.Designer.cs | 468 +++++++++++++++++++++ Peeping Tom/Resources/Language.resx | 156 +++++++ Peeping Tom/TargetWatcher.cs | 6 +- Peeping Tom/Targeting.cs | 6 - 6 files changed, 690 insertions(+), 56 deletions(-) create mode 100755 Peeping Tom/Resources/Language.Designer.cs create mode 100755 Peeping Tom/Resources/Language.resx diff --git a/Peeping Tom/Peeping Tom.csproj b/Peeping Tom/Peeping Tom.csproj index de7ad32..220487f 100755 --- a/Peeping Tom/Peeping Tom.csproj +++ b/Peeping Tom/Peeping Tom.csproj @@ -11,6 +11,10 @@ + + ResXFileCodeGenerator + Language.Designer.cs + @@ -46,4 +50,11 @@ + + + True + True + Language.resx + + diff --git a/Peeping Tom/PluginUi.cs b/Peeping Tom/PluginUi.cs index f2ffe02..1c5d080 100644 --- a/Peeping Tom/PluginUi.cs +++ b/Peeping Tom/PluginUi.cs @@ -10,6 +10,7 @@ using Dalamud.Game.Text; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Interface; +using PeepingTom.Resources; namespace PeepingTom { internal class PluginUi : IDisposable { @@ -34,7 +35,7 @@ namespace PeepingTom { } public PluginUi(PeepingTomPlugin plugin) { - this.Plugin = plugin ?? throw new ArgumentNullException(nameof(plugin), "PeepingTomPlugin cannot be null"); + this.Plugin = plugin; } public void Dispose() { @@ -120,27 +121,28 @@ namespace PeepingTom { private void ShowSettings() { ImGui.SetNextWindowSize(new Vector2(700, 250)); - if (!ImGui.Begin($"{this.Plugin.Name} settings", ref this._settingsOpen, ImGuiWindowFlags.NoResize)) { + var windowTitle = string.Format(Language.SettingsTitle, this.Plugin.Name); + if (!ImGui.Begin(windowTitle, ref this._settingsOpen, ImGuiWindowFlags.NoResize)) { ImGui.End(); return; } if (ImGui.BeginTabBar("##settings-tabs")) { - if (ImGui.BeginTabItem("Markers")) { + if (ImGui.BeginTabItem(Language.SettingsMarkersTab)) { var markTargeted = this.Plugin.Config.MarkTargeted; - if (ImGui.Checkbox("Mark your target", ref markTargeted)) { + if (ImGui.Checkbox(Language.SettingsMarkersMarkTarget, ref markTargeted)) { this.Plugin.Config.MarkTargeted = markTargeted; this.Plugin.Config.Save(); } var targetedColour = this.Plugin.Config.TargetedColour; - if (ImGui.ColorEdit4("Target mark colour", ref targetedColour)) { + if (ImGui.ColorEdit4(Language.SettingsMarkersMarkTargetColour, ref targetedColour)) { this.Plugin.Config.TargetedColour = targetedColour; this.Plugin.Config.Save(); } var targetedSize = this.Plugin.Config.TargetedSize; - if (ImGui.DragFloat("Target mark size", ref targetedSize, 0.01f, 0f, 15f)) { + if (ImGui.DragFloat(Language.SettingsMarkersMarkTargetSize, ref targetedSize, 0.01f, 0f, 15f)) { targetedSize = Math.Max(0f, targetedSize); this.Plugin.Config.TargetedSize = targetedSize; this.Plugin.Config.Save(); @@ -149,19 +151,19 @@ namespace PeepingTom { ImGui.Spacing(); var markTargeting = this.Plugin.Config.MarkTargeting; - if (ImGui.Checkbox("Mark targeting you", ref markTargeting)) { + if (ImGui.Checkbox(Language.SettingsMarkersMarkTargeting, ref markTargeting)) { this.Plugin.Config.MarkTargeting = markTargeting; this.Plugin.Config.Save(); } var targetingColour = this.Plugin.Config.TargetingColour; - if (ImGui.ColorEdit4("Targeting mark colour", ref targetingColour)) { + if (ImGui.ColorEdit4(Language.SettingsMarkersMarkTargetingColour, ref targetingColour)) { this.Plugin.Config.TargetingColour = targetingColour; this.Plugin.Config.Save(); } var targetingSize = this.Plugin.Config.TargetingSize; - if (ImGui.DragFloat("Targeting mark size", ref targetingSize, 0.01f, 0f, 15f)) { + if (ImGui.DragFloat(Language.SettingsMarkersMarkTargetingSize, ref targetingSize, 0.01f, 0f, 15f)) { targetingSize = Math.Max(0f, targetingSize); this.Plugin.Config.TargetingSize = targetingSize; this.Plugin.Config.Save(); @@ -170,27 +172,27 @@ namespace PeepingTom { ImGui.EndTabItem(); } - if (ImGui.BeginTabItem("Filters")) { + if (ImGui.BeginTabItem(Language.SettingsFilterTab)) { var showParty = this.Plugin.Config.LogParty; - if (ImGui.Checkbox("Log party members", ref showParty)) { + if (ImGui.Checkbox(Language.SettingsFilterLogParty, ref showParty)) { this.Plugin.Config.LogParty = showParty; this.Plugin.Config.Save(); } var logAlliance = this.Plugin.Config.LogAlliance; - if (ImGui.Checkbox("Log alliance members", ref logAlliance)) { + if (ImGui.Checkbox(Language.SettingsFilterLogAlliance, ref logAlliance)) { this.Plugin.Config.LogAlliance = logAlliance; this.Plugin.Config.Save(); } var logInCombat = this.Plugin.Config.LogInCombat; - if (ImGui.Checkbox("Log targeters engaged in combat", ref logInCombat)) { + if (ImGui.Checkbox(Language.SettingsFilterLogCombat, ref logInCombat)) { this.Plugin.Config.LogInCombat = logInCombat; this.Plugin.Config.Save(); } var logSelf = this.Plugin.Config.LogSelf; - if (ImGui.Checkbox("Log yourself", ref logSelf)) { + if (ImGui.Checkbox(Language.SettingsFilterLogSelf, ref logSelf)) { this.Plugin.Config.LogSelf = logSelf; this.Plugin.Config.Save(); } @@ -198,15 +200,15 @@ namespace PeepingTom { ImGui.EndTabItem(); } - if (ImGui.BeginTabItem("Behaviour")) { + if (ImGui.BeginTabItem(Language.SettingsBehaviourTab)) { var focusTarget = this.Plugin.Config.FocusTargetOnHover; - if (ImGui.Checkbox("Focus target on hover", ref focusTarget)) { + if (ImGui.Checkbox(Language.SettingsBehaviourFocusHover, ref focusTarget)) { this.Plugin.Config.FocusTargetOnHover = focusTarget; this.Plugin.Config.Save(); } var openExamine = this.Plugin.Config.OpenExamine; - if (ImGui.Checkbox("Open examine window on Alt-click", ref openExamine)) { + if (ImGui.Checkbox(Language.SettingsBehaviourExamineEnabled, ref openExamine)) { this.Plugin.Config.OpenExamine = openExamine; this.Plugin.Config.Save(); } @@ -214,24 +216,24 @@ namespace PeepingTom { ImGui.EndTabItem(); } - if (ImGui.BeginTabItem("Sound")) { + if (ImGui.BeginTabItem(Language.SettingsSoundTab)) { var playSound = this.Plugin.Config.PlaySoundOnTarget; - if (ImGui.Checkbox("Play sound when targeted", ref playSound)) { + if (ImGui.Checkbox(Language.SettingsSoundEnabled, ref playSound)) { this.Plugin.Config.PlaySoundOnTarget = playSound; this.Plugin.Config.Save(); } var path = this.Plugin.Config.SoundPath ?? ""; - if (ImGui.InputText("Path to audio file", ref path, 1_000)) { + if (ImGui.InputText(Language.SettingsSoundPath, ref path, 1_000)) { path = path.Trim(); this.Plugin.Config.SoundPath = path.Length == 0 ? null : path; this.Plugin.Config.Save(); } - ImGui.Text("Leave this blank to use a built-in sound."); + ImGui.Text(Language.SettingsSoundPathHelp); var volume = this.Plugin.Config.SoundVolume * 100f; - if (ImGui.DragFloat("Volume of sound", ref volume, .1f, 0f, 100f, "%.1f%%")) { + if (ImGui.DragFloat(Language.SettingsSoundVolume, ref volume, .1f, 0f, 100f, "%.1f%%")) { this.Plugin.Config.SoundVolume = Math.Max(0f, Math.Min(1f, volume / 100f)); this.Plugin.Config.Save(); } @@ -239,16 +241,16 @@ namespace PeepingTom { var soundDevice = this.Plugin.Config.SoundDevice; string name; if (soundDevice == -1) { - name = "Default"; + name = Language.SettingsSoundDefaultDevice; } else if (soundDevice > -1 && soundDevice < WaveOut.DeviceCount) { var caps = WaveOut.GetCapabilities(soundDevice); name = caps.ProductName; } else { - name = "Invalid device"; + name = Language.SettingsSoundInvalidDevice; } - if (ImGui.BeginCombo("Output device", name)) { - if (ImGui.Selectable("Default")) { + if (ImGui.BeginCombo(Language.SettingsSoundOutputDevice, name)) { + if (ImGui.Selectable(Language.SettingsSoundDefaultDevice)) { this.Plugin.Config.SoundDevice = -1; this.Plugin.Config.Save(); } @@ -269,14 +271,14 @@ namespace PeepingTom { } var soundCooldown = this.Plugin.Config.SoundCooldown; - if (ImGui.DragFloat("Cooldown for sound (seconds)", ref soundCooldown, .01f, 0f, 30f)) { + if (ImGui.DragFloat(Language.SettingsSoundCooldown, ref soundCooldown, .01f, 0f, 30f)) { soundCooldown = Math.Max(0f, soundCooldown); this.Plugin.Config.SoundCooldown = soundCooldown; this.Plugin.Config.Save(); } var playWhenClosed = this.Plugin.Config.PlaySoundWhenClosed; - if (ImGui.Checkbox("Play sound when window is closed", ref playWhenClosed)) { + if (ImGui.Checkbox(Language.SettingsSoundPlayWhenClosed, ref playWhenClosed)) { this.Plugin.Config.PlaySoundWhenClosed = playWhenClosed; this.Plugin.Config.Save(); } @@ -284,21 +286,21 @@ namespace PeepingTom { ImGui.EndTabItem(); } - if (ImGui.BeginTabItem("Window")) { + if (ImGui.BeginTabItem(Language.SettingsWindowTab)) { var openOnLogin = this.Plugin.Config.OpenOnLogin; - if (ImGui.Checkbox("Open on login", ref openOnLogin)) { + if (ImGui.Checkbox(Language.SettingsWindowOpenLogin, ref openOnLogin)) { this.Plugin.Config.OpenOnLogin = openOnLogin; this.Plugin.Config.Save(); } var allowMovement = this.Plugin.Config.AllowMovement; - if (ImGui.Checkbox("Allow moving the main window", ref allowMovement)) { + if (ImGui.Checkbox(Language.SettingsWindowAllowMovement, ref allowMovement)) { this.Plugin.Config.AllowMovement = allowMovement; this.Plugin.Config.Save(); } var allowResizing = this.Plugin.Config.AllowResize; - if (ImGui.Checkbox("Allow resizing the main window", ref allowResizing)) { + if (ImGui.Checkbox(Language.SettingsWindowAllowResize, ref allowResizing)) { this.Plugin.Config.AllowResize = allowResizing; this.Plugin.Config.Save(); } @@ -306,19 +308,19 @@ namespace PeepingTom { ImGui.Spacing(); var showInCombat = this.Plugin.Config.ShowInCombat; - if (ImGui.Checkbox("Show window while in combat", ref showInCombat)) { + if (ImGui.Checkbox(Language.SettingsWindowShowCombat, ref showInCombat)) { this.Plugin.Config.ShowInCombat = showInCombat; this.Plugin.Config.Save(); } var showInInstance = this.Plugin.Config.ShowInInstance; - if (ImGui.Checkbox("Show window while in instance", ref showInInstance)) { + if (ImGui.Checkbox(Language.SettingsWindowShowInstance, ref showInInstance)) { this.Plugin.Config.ShowInInstance = showInInstance; this.Plugin.Config.Save(); } var showInCutscenes = this.Plugin.Config.ShowInCutscenes; - if (ImGui.Checkbox("Show window while in cutscenes", ref showInCutscenes)) { + if (ImGui.Checkbox(Language.SettingsWindowShowCutscene, ref showInCutscenes)) { this.Plugin.Config.ShowInCutscenes = showInCutscenes; this.Plugin.Config.Save(); } @@ -326,28 +328,28 @@ namespace PeepingTom { ImGui.EndTabItem(); } - if (ImGui.BeginTabItem("History")) { + if (ImGui.BeginTabItem(Language.SettingsHistoryTab)) { var keepHistory = this.Plugin.Config.KeepHistory; - if (ImGui.Checkbox("Show previous targeters", ref keepHistory)) { + if (ImGui.Checkbox(Language.SettingsHistoryEnabled, ref keepHistory)) { this.Plugin.Config.KeepHistory = keepHistory; this.Plugin.Config.Save(); } var historyWhenClosed = this.Plugin.Config.HistoryWhenClosed; - if (ImGui.Checkbox("Record history when window is closed", ref historyWhenClosed)) { + if (ImGui.Checkbox(Language.SettingsHistoryRecordClosed, ref historyWhenClosed)) { this.Plugin.Config.HistoryWhenClosed = historyWhenClosed; this.Plugin.Config.Save(); } var numHistory = this.Plugin.Config.NumHistory; - if (ImGui.InputInt("Number of previous targeters to keep", ref numHistory)) { + if (ImGui.InputInt(Language.SettingsHistoryAmount, ref numHistory)) { numHistory = Math.Max(0, Math.Min(50, numHistory)); this.Plugin.Config.NumHistory = numHistory; this.Plugin.Config.Save(); } var showTimestamps = this.Plugin.Config.ShowTimestamps; - if (ImGui.Checkbox("Show timestamps", ref showTimestamps)) { + if (ImGui.Checkbox(Language.SettingsHistoryTimestamps, ref showTimestamps)) { this.Plugin.Config.ShowTimestamps = showTimestamps; this.Plugin.Config.Save(); } @@ -355,9 +357,9 @@ namespace PeepingTom { ImGui.EndTabItem(); } - if (ImGui.BeginTabItem("Advanced")) { + if (ImGui.BeginTabItem(Language.SettingsAdvancedTab)) { var pollFrequency = this.Plugin.Config.PollFrequency; - if (ImGui.DragInt("Poll frequency in milliseconds", ref pollFrequency, .1f, 1, 1600)) { + if (ImGui.DragInt(Language.SettingsAdvancedPollFrequency, ref pollFrequency, .1f, 1, 1600)) { this.Plugin.Config.PollFrequency = pollFrequency; this.Plugin.Config.Save(); } @@ -365,6 +367,7 @@ namespace PeepingTom { ImGui.EndTabItem(); } + #if DEBUG if (ImGui.BeginTabItem("Debug")) { if (ImGui.Button("Log targeting you")) { var player = this.Plugin.Interface.ClientState.LocalPlayer; @@ -397,6 +400,7 @@ namespace PeepingTom { ImGui.EndTabItem(); } + #endif ImGui.EndTabBar(); } @@ -440,9 +444,11 @@ namespace PeepingTom { } { - ImGui.Text("Targeting you"); + ImGui.Text(Language.MainTargetingYou); ImGui.SameLine(); - HelpMarker(this.Plugin.Config.OpenExamine ? "Click to link, Alt-click to examine, or right click to target." : "Click to link or right click to target."); + HelpMarker(this.Plugin.Config.OpenExamine + ? Language.MainHelpExamine + : Language.MainHelpNoExamine); var height = ImGui.GetContentRegionAvail().Y; height -= ImGui.GetStyle().ItemSpacing.Y; @@ -558,10 +564,7 @@ namespace PeepingTom { if (actor != null) { this.Plugin.Common.Functions.Examine.OpenExamineWindow(actor); } else { - var error = new SeString(new Payload[] { - new PlayerPayload(this.Plugin.Interface.Data, targeter.Name, targeter.HomeWorld.Id), - new TextPayload(" is not close enough to examine."), - }); + var error = string.Format(Language.ExamineErrorToast, targeter.Name); this.Plugin.Interface.Framework.Gui.Toast.ShowError(error); } } else { diff --git a/Peeping Tom/Resources/Language.Designer.cs b/Peeping Tom/Resources/Language.Designer.cs new file mode 100755 index 0000000..4d6ba3d --- /dev/null +++ b/Peeping Tom/Resources/Language.Designer.cs @@ -0,0 +1,468 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace PeepingTom.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Language { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Language() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PeepingTom.Resources.Language", typeof(Language).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to {0} is not close enough to examine.. + /// + internal static string ExamineErrorToast { + get { + return ResourceManager.GetString("ExamineErrorToast", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Click to link, Alt-click to examine, or right click to target.. + /// + internal static string MainHelpExamine { + get { + return ResourceManager.GetString("MainHelpExamine", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Click to link or right click to target.. + /// + internal static string MainHelpNoExamine { + get { + return ResourceManager.GetString("MainHelpNoExamine", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Targeting you. + /// + internal static string MainTargetingYou { + get { + return ResourceManager.GetString("MainTargetingYou", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Poll frequency in milliseconds. + /// + internal static string SettingsAdvancedPollFrequency { + get { + return ResourceManager.GetString("SettingsAdvancedPollFrequency", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Advanced. + /// + internal static string SettingsAdvancedTab { + get { + return ResourceManager.GetString("SettingsAdvancedTab", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Open examine window on Alt-click. + /// + internal static string SettingsBehaviourExamineEnabled { + get { + return ResourceManager.GetString("SettingsBehaviourExamineEnabled", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Focus target on hover. + /// + internal static string SettingsBehaviourFocusHover { + get { + return ResourceManager.GetString("SettingsBehaviourFocusHover", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Behaviour. + /// + internal static string SettingsBehaviourTab { + get { + return ResourceManager.GetString("SettingsBehaviourTab", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Log alliance members. + /// + internal static string SettingsFilterLogAlliance { + get { + return ResourceManager.GetString("SettingsFilterLogAlliance", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Log targeters engaged in combat. + /// + internal static string SettingsFilterLogCombat { + get { + return ResourceManager.GetString("SettingsFilterLogCombat", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Log party members. + /// + internal static string SettingsFilterLogParty { + get { + return ResourceManager.GetString("SettingsFilterLogParty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Log yourself. + /// + internal static string SettingsFilterLogSelf { + get { + return ResourceManager.GetString("SettingsFilterLogSelf", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Filters. + /// + internal static string SettingsFilterTab { + get { + return ResourceManager.GetString("SettingsFilterTab", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Number of previous targeters to keep. + /// + internal static string SettingsHistoryAmount { + get { + return ResourceManager.GetString("SettingsHistoryAmount", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show previous targeters. + /// + internal static string SettingsHistoryEnabled { + get { + return ResourceManager.GetString("SettingsHistoryEnabled", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Record history when window is closed. + /// + internal static string SettingsHistoryRecordClosed { + get { + return ResourceManager.GetString("SettingsHistoryRecordClosed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to History. + /// + internal static string SettingsHistoryTab { + get { + return ResourceManager.GetString("SettingsHistoryTab", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show timestamps. + /// + internal static string SettingsHistoryTimestamps { + get { + return ResourceManager.GetString("SettingsHistoryTimestamps", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Mark your target. + /// + internal static string SettingsMarkersMarkTarget { + get { + return ResourceManager.GetString("SettingsMarkersMarkTarget", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Target mark colour. + /// + internal static string SettingsMarkersMarkTargetColour { + get { + return ResourceManager.GetString("SettingsMarkersMarkTargetColour", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Mark targeting you. + /// + internal static string SettingsMarkersMarkTargeting { + get { + return ResourceManager.GetString("SettingsMarkersMarkTargeting", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Targeting mark colour. + /// + internal static string SettingsMarkersMarkTargetingColour { + get { + return ResourceManager.GetString("SettingsMarkersMarkTargetingColour", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Targeting mark size. + /// + internal static string SettingsMarkersMarkTargetingSize { + get { + return ResourceManager.GetString("SettingsMarkersMarkTargetingSize", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Target mark size. + /// + internal static string SettingsMarkersMarkTargetSize { + get { + return ResourceManager.GetString("SettingsMarkersMarkTargetSize", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Markers. + /// + internal static string SettingsMarkersTab { + get { + return ResourceManager.GetString("SettingsMarkersTab", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Cooldown for sound (seconds). + /// + internal static string SettingsSoundCooldown { + get { + return ResourceManager.GetString("SettingsSoundCooldown", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Default. + /// + internal static string SettingsSoundDefaultDevice { + get { + return ResourceManager.GetString("SettingsSoundDefaultDevice", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Play sound when targeted. + /// + internal static string SettingsSoundEnabled { + get { + return ResourceManager.GetString("SettingsSoundEnabled", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Invalid device. + /// + internal static string SettingsSoundInvalidDevice { + get { + return ResourceManager.GetString("SettingsSoundInvalidDevice", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Output device. + /// + internal static string SettingsSoundOutputDevice { + get { + return ResourceManager.GetString("SettingsSoundOutputDevice", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Path to audio file. + /// + internal static string SettingsSoundPath { + get { + return ResourceManager.GetString("SettingsSoundPath", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Leave this blank to use a built-in sound.. + /// + internal static string SettingsSoundPathHelp { + get { + return ResourceManager.GetString("SettingsSoundPathHelp", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Play sound when window is closed. + /// + internal static string SettingsSoundPlayWhenClosed { + get { + return ResourceManager.GetString("SettingsSoundPlayWhenClosed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sound. + /// + internal static string SettingsSoundTab { + get { + return ResourceManager.GetString("SettingsSoundTab", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Volume of sound. + /// + internal static string SettingsSoundVolume { + get { + return ResourceManager.GetString("SettingsSoundVolume", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} settings. + /// + internal static string SettingsTitle { + get { + return ResourceManager.GetString("SettingsTitle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Allow moving the main window. + /// + internal static string SettingsWindowAllowMovement { + get { + return ResourceManager.GetString("SettingsWindowAllowMovement", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Allow resizing the main window. + /// + internal static string SettingsWindowAllowResize { + get { + return ResourceManager.GetString("SettingsWindowAllowResize", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Open on login. + /// + internal static string SettingsWindowOpenLogin { + get { + return ResourceManager.GetString("SettingsWindowOpenLogin", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show window while in combat. + /// + internal static string SettingsWindowShowCombat { + get { + return ResourceManager.GetString("SettingsWindowShowCombat", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show window while in cutscenes. + /// + internal static string SettingsWindowShowCutscene { + get { + return ResourceManager.GetString("SettingsWindowShowCutscene", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show window while in instance. + /// + internal static string SettingsWindowShowInstance { + get { + return ResourceManager.GetString("SettingsWindowShowInstance", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Window. + /// + internal static string SettingsWindowTab { + get { + return ResourceManager.GetString("SettingsWindowTab", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Could not play sound file: {0}. + /// + internal static string SoundChatError { + get { + return ResourceManager.GetString("SoundChatError", resourceCulture); + } + } + } +} diff --git a/Peeping Tom/Resources/Language.resx b/Peeping Tom/Resources/Language.resx new file mode 100755 index 0000000..6aca7b8 --- /dev/null +++ b/Peeping Tom/Resources/Language.resx @@ -0,0 +1,156 @@ + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + {0} settings + + + Markers + + + Mark your target + + + Target mark colour + + + Target mark size + + + Mark targeting you + + + Targeting mark colour + + + Targeting mark size + + + Filters + + + Log party members + + + Log alliance members + + + Log targeters engaged in combat + + + Log yourself + + + Behaviour + + + Focus target on hover + + + Open examine window on Alt-click + + + Sound + + + Play sound when targeted + + + Path to audio file + + + Leave this blank to use a built-in sound. + + + Volume of sound + + + Default + + + Invalid device + + + Output device + + + Cooldown for sound (seconds) + + + Play sound when window is closed + + + Window + + + Open on login + + + Allow moving the main window + + + Allow resizing the main window + + + Show window while in combat + + + Show window while in instance + + + Show window while in cutscenes + + + History + + + Show previous targeters + + + Record history when window is closed + + + Number of previous targeters to keep + + + Show timestamps + + + Advanced + + + Poll frequency in milliseconds + + + {0} is not close enough to examine. + + + Targeting you + + + Click to link, Alt-click to examine, or right click to target. + + + Click to link or right click to target. + + + Could not play sound file: {0} + + \ No newline at end of file diff --git a/Peeping Tom/TargetWatcher.cs b/Peeping Tom/TargetWatcher.cs index dc9db72..a1703a2 100644 --- a/Peeping Tom/TargetWatcher.cs +++ b/Peeping Tom/TargetWatcher.cs @@ -12,6 +12,7 @@ using System.Threading; using Dalamud.Game.Text; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling.Payloads; +using PeepingTom.Resources; namespace PeepingTom { internal class TargetWatcher : IDisposable { @@ -52,7 +53,7 @@ namespace PeepingTom { } public TargetWatcher(PeepingTomPlugin plugin) { - this.Plugin = plugin ?? throw new ArgumentNullException(nameof(plugin), "PeepingTomPlugin cannot be null"); + this.Plugin = plugin; } public void ClearPrevious() { @@ -202,7 +203,8 @@ namespace PeepingTom { reader = new AudioFileReader(this.Plugin.Config.SoundPath); } } catch (Exception e) { - this.SendError($"Could not play sound file: {e.Message}"); + var error = string.Format(Language.SoundChatError, e.Message); + this.SendError(error); return; } diff --git a/Peeping Tom/Targeting.cs b/Peeping Tom/Targeting.cs index 649ca13..3a9cb39 100644 --- a/Peeping Tom/Targeting.cs +++ b/Peeping Tom/Targeting.cs @@ -12,9 +12,6 @@ namespace PeepingTom { public DateTime When { get; } public Targeter(PlayerCharacter character) { - if (character == null) { - throw new ArgumentNullException(nameof(character), "PlayerCharacter cannot be null"); - } this.Name = character.Name; this.HomeWorld = character.HomeWorld; this.ActorId = character.ActorId; @@ -22,9 +19,6 @@ namespace PeepingTom { } public PlayerCharacter? GetPlayerCharacter(DalamudPluginInterface pi) { - if (pi == null) { - throw new ArgumentNullException(nameof(pi), "DalamudPluginInterface cannot be null"); - } return pi.ClientState.Actors.FirstOrDefault(actor => actor.ActorId == this.ActorId && actor is PlayerCharacter) as PlayerCharacter; } }