diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-01-15 18:48:31 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-01-15 18:48:31 -0500 |
commit | 812251e7ae532d7a2f10d46ff366bf19e67e88d0 (patch) | |
tree | 88b88fc13c5b19dfa1a2742dda3e43bd1e2eee4a | |
parent | a9b99c12069bfabca81a74c83eda7f1325c2522a (diff) | |
download | SMAPI-812251e7ae532d7a2f10d46ff366bf19e67e88d0.tar.gz SMAPI-812251e7ae532d7a2f10d46ff366bf19e67e88d0.tar.bz2 SMAPI-812251e7ae532d7a2f10d46ff366bf19e67e88d0.zip |
allow getting all active values from a PerScreen<T> field
-rw-r--r-- | docs/release-notes.md | 2 | ||||
-rw-r--r-- | src/SMAPI/Utilities/PerScreen.cs | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md index deac0bc8..c36d80ed 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -9,7 +9,7 @@ ## Upcoming release * For modders: - * Expanded `PerScreen<T>` API: you can now get/set the value for any screen, or clear all values. + * Expanded `PerScreen<T>` API: you can now get/set the value for any screen, get all active values, or clear all values. * Added an option to disable rewriting mods for compatibility (thanks to Bpendragon!). This may prevent older mods from loading, but bypasses a Visual Studio crash when debugging. * For the Error Handler mod: diff --git a/src/SMAPI/Utilities/PerScreen.cs b/src/SMAPI/Utilities/PerScreen.cs index 60406d6b..20b8fbce 100644 --- a/src/SMAPI/Utilities/PerScreen.cs +++ b/src/SMAPI/Utilities/PerScreen.cs @@ -47,6 +47,13 @@ namespace StardewModdingAPI.Utilities this.CreateNewState = createNewState ?? (() => default); } + /// <summary>Get all active values by screen ID. This doesn't initialize the value for a screen ID if it's not created yet.</summary> + public IEnumerable<KeyValuePair<int, T>> GetActiveValues() + { + this.RemoveDeadScreens(); + return this.States.ToArray(); + } + /// <summary>Get the value for a given screen ID, creating it if needed.</summary> /// <param name="screenId">The screen ID to check.</param> public T GetValueForScreen(int screenId) |