allow getting all active values from a PerScreen<T> field

This commit is contained in:
Jesse Plamondon-Willard 2021-01-15 18:48:31 -05:00
parent a9b99c1206
commit 812251e7ae
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
2 changed files with 8 additions and 1 deletions

View File

@ -9,7 +9,7 @@
## Upcoming release ## Upcoming release
* For modders: * 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. * 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: * For the Error Handler mod:

View File

@ -47,6 +47,13 @@ namespace StardewModdingAPI.Utilities
this.CreateNewState = createNewState ?? (() => default); 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> /// <summary>Get the value for a given screen ID, creating it if needed.</summary>
/// <param name="screenId">The screen ID to check.</param> /// <param name="screenId">The screen ID to check.</param>
public T GetValueForScreen(int screenId) public T GetValueForScreen(int screenId)