summaryrefslogtreecommitdiff
path: root/src/SMAPI/Utilities
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-01-06 23:43:48 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-01-06 23:43:48 -0500
commit51de495ae4c1b9da13cce24dc15ac844b24f657e (patch)
treec44a6f0237a6c1b6a33d2cee227a70455441bca3 /src/SMAPI/Utilities
parentd5b00bec84fca94ebd94bea509af060928585cc8 (diff)
downloadSMAPI-51de495ae4c1b9da13cce24dc15ac844b24f657e.tar.gz
SMAPI-51de495ae4c1b9da13cce24dc15ac844b24f657e.tar.bz2
SMAPI-51de495ae4c1b9da13cce24dc15ac844b24f657e.zip
add a way to send console commands to a specific screen
Diffstat (limited to 'src/SMAPI/Utilities')
-rw-r--r--src/SMAPI/Utilities/PerScreen.cs33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/SMAPI/Utilities/PerScreen.cs b/src/SMAPI/Utilities/PerScreen.cs
index 55dae0d8..89d08e87 100644
--- a/src/SMAPI/Utilities/PerScreen.cs
+++ b/src/SMAPI/Utilities/PerScreen.cs
@@ -28,18 +28,8 @@ namespace StardewModdingAPI.Utilities
/// <remarks>The value is initialized the first time it's requested for that player, unless it's set manually first.</remarks>
public T Value
{
- get
- {
- this.RemoveDeadPlayers();
- return this.States.TryGetValue(Context.ScreenId, out T state)
- ? state
- : this.States[Context.ScreenId] = this.CreateNewState();
- }
- set
- {
- this.RemoveDeadPlayers();
- this.States[Context.ScreenId] = value;
- }
+ get => this.GetValueForScreen(Context.ScreenId);
+ set => this.SetValueForScreen(Context.ScreenId, value);
}
@@ -57,6 +47,25 @@ namespace StardewModdingAPI.Utilities
this.CreateNewState = createNewState ?? (() => default);
}
+ /// <summary>Get the value for a given screen ID, creating it if needed.</summary>
+ /// <param name="screenId">The screen ID to check.</param>
+ internal T GetValueForScreen(int screenId)
+ {
+ this.RemoveDeadPlayers();
+ return this.States.TryGetValue(screenId, out T state)
+ ? state
+ : this.States[screenId] = this.CreateNewState();
+ }
+
+ /// <summary>Set the value for a given screen ID, creating it if needed.</summary>
+ /// <param name="screenId">The screen ID whose value set.</param>
+ /// <param name="value">The value to set.</param>
+ internal void SetValueForScreen(int screenId, T value)
+ {
+ this.RemoveDeadPlayers();
+ this.States[screenId] = value;
+ }
+
/*********
** Private methods