Changes

Jump to navigation Jump to search
→‎Changes for C# mods: move extensions into a "New extension methods" section
Line 252: Line 252:  
<syntaxhighlight lang="c#">Farmer? player = Game1.GetPlayer(id);</syntaxhighlight>
 
<syntaxhighlight lang="c#">Farmer? player = Game1.GetPlayer(id);</syntaxhighlight>
 
|}
 
|}
  −
===Case-insensitive string comparisons===
  −
1.6.9 adds several extension methods in the <samp>StardewValley.Extensions</samp> namespace for comparing strings case-insensitively. Specifically: <samp>ContainsIgnoreCase</samp>, <samp>EqualsIgnoreCase</samp>, <samp>IndexOfIgnoreCase</samp>, <samp>StartsWithIgnoreCase</samp>, and <samp>EndsWithIgnoreCase</samp>.
  −
  −
For example:
  −
<syntaxhighlight lang="c#">
  −
// before 1.6.9
  −
if (string.Equals(left, right, StringComparison.OrdinalIgnoreCase))
  −
  ...
  −
  −
// after 1.6.9
  −
if (left.EqualsIgnoreCase(right))
  −
  ...
  −
</syntaxhighlight>
  −
  −
The new methods also handle null as you'd expect. For example, <samp>left.EqualsIgnoreCase(right)</samp> will be true if both are null.
      
===Screen reader changes===
 
===Screen reader changes===
Line 301: Line 285:  
* Added code docs.
 
* Added code docs.
 
* Removed the <samp>TemporaryAnimatedSprite.light</samp> boolean field; the light is now enabled by setting the <samp>lightId</samp> field.
 
* Removed the <samp>TemporaryAnimatedSprite.light</samp> boolean field; the light is now enabled by setting the <samp>lightId</samp> field.
 +
 +
===New extension methods===
 +
The game has [https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods extension methods] in the <samp>StardewValley.Extensions</samp> namespace. These add utility methods to more general types like strings.
 +
 +
1.6.9 adds some new extension methods:
 +
 +
{| class="wikitable"
 +
|-
 +
! type
 +
! method
 +
! usage
 +
|-
 +
| <samp>string</samp>
 +
| <samp>ContainsIgnoreCase</samp><br /><samp>EqualsIgnoreCase</samp><br /><samp>IndexOfIgnoreCase</samp><br /><samp>StartsWithIgnoreCase</samp><br /><samp>EndsWithIgnoreCase</samp>
 +
| Compare two strings case-insensitively.
 +
 +
For example:
 +
<syntaxhighlight lang="c#">
 +
// before 1.6.9
 +
if (string.Equals(left, right, StringComparison.OrdinalIgnoreCase))
 +
  ...
 +
 +
// after 1.6.9
 +
if (left.EqualsIgnoreCase(right))
 +
  ...
 +
</syntaxhighlight>
 +
 +
The new methods also handle null as you'd expect. For example, <samp>left.EqualsIgnoreCase(right)</samp> will be true if both are null.
 +
|}
    
===New utility fields & methods===
 
===New utility fields & methods===
manager
8,549

edits

Navigation menu