add support for read/writing SDate to JSON

This commit is contained in:
Jesse Plamondon-Willard 2020-08-09 19:10:54 -04:00
parent 066f1857a1
commit 48eb5e6be0
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
2 changed files with 8 additions and 0 deletions

View File

@ -11,6 +11,9 @@
* For players: * For players:
* Fixed rare error when a mod adds/removes event handlers asynchronously. * 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: * For the web UI:
* Updated the JSON validator/schema for Content Patcher 1.16. * Updated the JSON validator/schema for Content Patcher 1.16.

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Linq; using System.Linq;
using Newtonsoft.Json;
using StardewModdingAPI.Framework; using StardewModdingAPI.Framework;
using StardewValley; using StardewValley;
@ -35,15 +36,18 @@ namespace StardewModdingAPI.Utilities
/// <summary>The index of the season (where 0 is spring, 1 is summer, 2 is fall, and 3 is winter).</summary> /// <summary>The index of the season (where 0 is spring, 1 is summer, 2 is fall, and 3 is winter).</summary>
/// <remarks>This is used in some game calculations (e.g. seasonal game sprites) and methods (e.g. <see cref="Utility.getSeasonNameFromNumber"/>).</remarks> /// <remarks>This is used in some game calculations (e.g. seasonal game sprites) and methods (e.g. <see cref="Utility.getSeasonNameFromNumber"/>).</remarks>
[JsonIgnore]
public int SeasonIndex { get; } public int SeasonIndex { get; }
/// <summary>The year.</summary> /// <summary>The year.</summary>
public int Year { get; } public int Year { get; }
/// <summary>The day of week.</summary> /// <summary>The day of week.</summary>
[JsonIgnore]
public DayOfWeek DayOfWeek { get; } public DayOfWeek DayOfWeek { get; }
/// <summary>The number of days since the game began (starting at 1 for the first day of spring in Y1).</summary> /// <summary>The number of days since the game began (starting at 1 for the first day of spring in Y1).</summary>
[JsonIgnore]
public int DaysSinceStart { get; } public int DaysSinceStart { get; }
@ -62,6 +66,7 @@ namespace StardewModdingAPI.Utilities
/// <param name="season">The season name.</param> /// <param name="season">The season name.</param>
/// <param name="year">The year.</param> /// <param name="year">The year.</param>
/// <exception cref="ArgumentException">One of the arguments has an invalid value (like day 35).</exception> /// <exception cref="ArgumentException">One of the arguments has an invalid value (like day 35).</exception>
[JsonConstructor]
public SDate(int day, string season, int year) public SDate(int day, string season, int year)
: this(day, season, year, allowDayZero: false) { } : this(day, season, year, allowDayZero: false) { }