From 9fba3c12667555958e2eb6ecf1d2ebe47fd77c58 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 10 Apr 2018 18:20:49 -0400 Subject: add context properties for multiplayer, update release notes (#453) --- docs/release-notes.md | 4 +++- src/SMAPI/Context.cs | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index 3406e735..c04b6bdf 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -3,12 +3,14 @@ ## 2.6 alpha * For players: * Added support for Stardew Valley 1.3+; no longer compatible with earlier versions. + * Added `Context.IsMultiplayer` and `Context.IsMainPlayer` flags. * Fixed SMAPI update alerts linking to the GitHub repository instead of [smapi.io](https://smapi.io). * Fixed SMAPI update checks not showing newer beta versions when using a beta version. * For modders: * Dropped some deprecated APIs. - * Fixed some assets not being editable. + * Fixed assets loaded by temporary content managers not being editable. + * Fixed issue where assets didn't reload correctly when the player switches language. * For SMAPI developers: * Added prerelease versions to the mod update-check API response where available (GitHub only). diff --git a/src/SMAPI/Context.cs b/src/SMAPI/Context.cs index 119e14c8..7ed9b052 100644 --- a/src/SMAPI/Context.cs +++ b/src/SMAPI/Context.cs @@ -1,4 +1,4 @@ -using StardewModdingAPI.Events; +using StardewModdingAPI.Events; using StardewValley; using StardewValley.Menus; @@ -25,6 +25,12 @@ namespace StardewModdingAPI /// Whether the game is currently running the draw loop. This isn't relevant to most mods, since you should use to draw to the screen. public static bool IsInDrawLoop { get; internal set; } + /// Whether and the player loaded the save in multiplayer mode (regardless of whether any other players are connected). + public static bool IsMultiplayer => Context.IsWorldReady && Game1.multiplayerMode != Game1.singlePlayer; + + /// Whether and the current player is the main player. This is always true in single-player, and true when hosting in multiplayer. + public static bool IsMainPlayer => Context.IsWorldReady && Game1.IsMasterGame; + /**** ** Internal ****/ -- cgit