diff options
Diffstat (limited to 'src/StardewModdingAPI/Events')
-rw-r--r-- | src/StardewModdingAPI/Events/ContentEvents.cs | 12 | ||||
-rw-r--r-- | src/StardewModdingAPI/Events/EventArgsIntChanged.cs | 5 | ||||
-rw-r--r-- | src/StardewModdingAPI/Events/EventArgsValueChanged.cs | 31 |
3 files changed, 45 insertions, 3 deletions
diff --git a/src/StardewModdingAPI/Events/ContentEvents.cs b/src/StardewModdingAPI/Events/ContentEvents.cs index cc07f242..558fc070 100644 --- a/src/StardewModdingAPI/Events/ContentEvents.cs +++ b/src/StardewModdingAPI/Events/ContentEvents.cs @@ -24,6 +24,9 @@ namespace StardewModdingAPI.Events /********* ** Events *********/ + /// <summary>Raised after the content language changes.</summary> + public static event EventHandler<EventArgsValueChanged<string>> AfterLocaleChanged; + /// <summary>Raised when an XNB file is being read into the cache. Mods can change the data here before it's cached.</summary> public static event EventHandler<IContentEventHelper> AssetLoading; @@ -40,6 +43,15 @@ namespace StardewModdingAPI.Events ContentEvents.Monitor = monitor; } + /// <summary>Raise an <see cref="AfterLocaleChanged"/> event.</summary> + /// <param name="monitor">Encapsulates monitoring and logging.</param> + /// <param name="oldLocale">The previous locale.</param> + /// <param name="newLocale">The current locale.</param> + internal static void InvokeAfterLocaleChanged(IMonitor monitor, string oldLocale, string newLocale) + { + monitor.SafelyRaiseGenericEvent($"{nameof(ContentEvents)}.{nameof(ContentEvents.AfterLocaleChanged)}", ContentEvents.AfterLocaleChanged?.GetInvocationList(), null, new EventArgsValueChanged<string>(oldLocale, newLocale)); + } + /// <summary>Raise an <see cref="AssetLoading"/> event.</summary> /// <param name="monitor">Encapsulates monitoring and logging.</param> /// <param name="contentHelper">Encapsulates access and changes to content being read from a data file.</param> diff --git a/src/StardewModdingAPI/Events/EventArgsIntChanged.cs b/src/StardewModdingAPI/Events/EventArgsIntChanged.cs index 31079730..0c742d12 100644 --- a/src/StardewModdingAPI/Events/EventArgsIntChanged.cs +++ b/src/StardewModdingAPI/Events/EventArgsIntChanged.cs @@ -9,11 +9,10 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// <summary>The previous value.</summary> - public int NewInt { get; } - - /// <summary>The current value.</summary> public int PriorInt { get; } + /// <summary>The current value.</summary> + public int NewInt { get; } /********* ** Public methods diff --git a/src/StardewModdingAPI/Events/EventArgsValueChanged.cs b/src/StardewModdingAPI/Events/EventArgsValueChanged.cs new file mode 100644 index 00000000..1d25af49 --- /dev/null +++ b/src/StardewModdingAPI/Events/EventArgsValueChanged.cs @@ -0,0 +1,31 @@ +using System; + +namespace StardewModdingAPI.Events +{ + /// <summary>Event arguments for a field that changed value.</summary> + /// <typeparam name="T">The value type.</typeparam> + public class EventArgsValueChanged<T> : EventArgs + { + /********* + ** Accessors + *********/ + /// <summary>The previous value.</summary> + public T PriorValue { get; } + + /// <summary>The current value.</summary> + public T NewValue { get; } + + + /********* + ** Public methods + *********/ + /// <summary>Construct an instance.</summary> + /// <param name="priorValue">The previous value.</param> + /// <param name="newValue">The current value.</param> + public EventArgsValueChanged(T priorValue, T newValue) + { + this.PriorValue = priorValue; + this.NewValue = newValue; + } + } +}
\ No newline at end of file |