From 48eb5e6be02feae26a6e374992cfeed9d60a5757 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 9 Aug 2020 19:10:54 -0400 Subject: add support for read/writing SDate to JSON --- docs/release-notes.md | 3 +++ src/SMAPI/Utilities/SDate.cs | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/docs/release-notes.md b/docs/release-notes.md index 7f522ce0..2e1e050e 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -11,6 +11,9 @@ * For players: * Fixed rare error when a mod adds/removes event handlers asynchronously. +* For modders: + * You can now read/write `SDate` values to JSON (e.g. for `config.json`, network mod messages, etc). + * For the web UI: * Updated the JSON validator/schema for Content Patcher 1.16. diff --git a/src/SMAPI/Utilities/SDate.cs b/src/SMAPI/Utilities/SDate.cs index 03230334..165667a4 100644 --- a/src/SMAPI/Utilities/SDate.cs +++ b/src/SMAPI/Utilities/SDate.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using Newtonsoft.Json; using StardewModdingAPI.Framework; using StardewValley; @@ -35,15 +36,18 @@ namespace StardewModdingAPI.Utilities /// The index of the season (where 0 is spring, 1 is summer, 2 is fall, and 3 is winter). /// This is used in some game calculations (e.g. seasonal game sprites) and methods (e.g. ). + [JsonIgnore] public int SeasonIndex { get; } /// The year. public int Year { get; } /// The day of week. + [JsonIgnore] public DayOfWeek DayOfWeek { get; } /// The number of days since the game began (starting at 1 for the first day of spring in Y1). + [JsonIgnore] public int DaysSinceStart { get; } @@ -62,6 +66,7 @@ namespace StardewModdingAPI.Utilities /// The season name. /// The year. /// One of the arguments has an invalid value (like day 35). + [JsonConstructor] public SDate(int day, string season, int year) : this(day, season, year, allowDayZero: false) { } -- cgit