Changes

Jump to navigation Jump to search
remove {{SMAPI upcoming|4.0.0}}
Line 17: Line 17:  
<syntaxhighlight lang="c#">
 
<syntaxhighlight lang="c#">
 
/// <summary>The main entry point for the mod.</summary>
 
/// <summary>The main entry point for the mod.</summary>
public class ModEntry : Mod
+
internal sealed class ModEntry : Mod
 
{
 
{
 
     /**********
 
     /**********
Line 33: Line 33:  
     /// <param name="sender">The event sender.</param>
 
     /// <param name="sender">The event sender.</param>
 
     /// <param name="e">The event arguments.</param>
 
     /// <param name="e">The event arguments.</param>
     private void OnDayStarted(object sender, DayStartedEventArgs e)
+
     private void OnDayStarted(object? sender, DayStartedEventArgs e)
 
     {
 
     {
       this.Monitor.Log("A new day dawns!");
+
       this.Monitor.Log("A new day dawns!", LogLevel.Info);
 
     }
 
     }
 
}
 
}
Line 41: Line 41:     
Tip: you don't need to memorise the method arguments. In Visual Studio, type <code>helper.Events.GameLoop.SaveLoaded +=</code> and press {{key|TAB}} to auto-create a method. (There doesn't seem to be an equivalent feature in MonoDevelop.)
 
Tip: you don't need to memorise the method arguments. In Visual Studio, type <code>helper.Events.GameLoop.SaveLoaded +=</code> and press {{key|TAB}} to auto-create a method. (There doesn't seem to be an equivalent feature in MonoDevelop.)
 +
 +
<samp>sender</samp> is part of the C# event pattern, and is unused by SMAPI.
    
===How do events fit into the game?===
 
===How do events fit into the game?===
Line 64: Line 66:     
===Content===
 
===Content===
{{SMAPI upcoming|4.0.0|content=
  −
   
<samp>this.Helper.Events.Content</samp> has events related to assets loaded from the content pipeline.
 
<samp>this.Helper.Events.Content</samp> has events related to assets loaded from the content pipeline.
   −
{{{!}} class="wikitable"
+
{| class="wikitable"
{{!}}-
+
|-
 
! event
 
! event
 
! summary
 
! summary
Line 93: Line 93:  
  |arg desc 3 = Call this method to provide the initial instance for the asset, instead of trying to load it from the game's <samp>Content</samp> folder. For example:
 
  |arg desc 3 = Call this method to provide the initial instance for the asset, instead of trying to load it from the game's <samp>Content</samp> folder. For example:
 
<syntaxhighlight lang="c#">
 
<syntaxhighlight lang="c#">
e.LoadFrom(() => this.Helper.Content.Load<Texture2D>("assets/portraits.png"));
+
e.LoadFrom(() => this.Helper.Content.Load<Texture2D>("assets/portraits.png"), AssetLoadPriority.Medium);
 
</syntaxhighlight>
 
</syntaxhighlight>
   Line 104: Line 104:  
  |arg desc 4 = Call this method to provide the initial instance for the asset by loading a file from your mod folder. For example:
 
  |arg desc 4 = Call this method to provide the initial instance for the asset by loading a file from your mod folder. For example:
 
<syntaxhighlight lang="c#">
 
<syntaxhighlight lang="c#">
e.LoadFromModFile<Texture2D>("assets/portraits.png");
+
e.LoadFromModFile<Texture2D>("assets/portraits.png", AssetLoadPriority.Medium);
 
</syntaxhighlight>
 
</syntaxhighlight>
   Line 175: Line 175:  
  |arg desc 4 = The previous value for the locale code. See notes on <samp>OldLocale</samp>.
 
  |arg desc 4 = The previous value for the locale code. See notes on <samp>OldLocale</samp>.
 
}}
 
}}
{{!}}}
+
|}
}}
      
===Display===
 
===Display===
Line 210: Line 209:  
  |group = Display
 
  |group = Display
 
  |name  = Rendered
 
  |name  = Rendered
  |desc  = Raised after the game draws to the sprite patch in a draw tick, just before the final sprite batch is rendered to the screen. Since the game may open/close the sprite batch multiple times in a draw tick, the sprite batch may not contain everything being drawn and some things may already be rendered to the screen. Content drawn to the sprite batch at this point will be drawn over all vanilla content (including menus, HUD, and cursor).
+
  |desc  = Raised after the game draws to the sprite batch in a draw tick, just before the final sprite batch is rendered to the screen. Since the game may open/close the sprite batch multiple times in a draw tick, the sprite batch may not contain everything being drawn and some things may already be rendered to the screen. Content drawn to the sprite batch at this point will be drawn over all vanilla content (including menus, HUD, and cursor).
    
  |arg name 1 = <samp>e.SpriteBatch</samp>
 
  |arg name 1 = <samp>e.SpriteBatch</samp>
Line 228: Line 227:  
  |group = Display
 
  |group = Display
 
  |name  = RenderedWorld
 
  |name  = RenderedWorld
  |desc  = Raised after the game world is drawn to the sprite patch, before it's rendered to the screen. Content drawn to the sprite batch at this point will be drawn over the world, but under any active menu, HUD elements, or cursor.
+
  |desc  = Raised after the game world is drawn to the sprite batch, before it's rendered to the screen. Content drawn to the sprite batch at this point will be drawn over the world, but under any active menu, HUD elements, or cursor.
    
  |arg name 1 = <samp>e.SpriteBatch</samp>
 
  |arg name 1 = <samp>e.SpriteBatch</samp>
Line 282: Line 281:  
  |arg type 2 = <samp>Point</samp>
 
  |arg type 2 = <samp>Point</samp>
 
  |arg desc 2 = The new window width (<samp>e.NewSize.X</samp>) and height (<samp>e.NewSize.Y</samp>).
 
  |arg desc 2 = The new window width (<samp>e.NewSize.X</samp>) and height (<samp>e.NewSize.Y</samp>).
 +
}}
 +
{{/event
 +
|group = Display
 +
|name  = RenderingStep
 +
|desc  = ''(Specialized)'' Raised before the game draws a specific step in the rendering cycle. This gives more granular control over render logic, but is more vulnerable to changes in game updates. Consider using one of the other render events if possible.
 +
 +
|arg name 1 = <samp>e.SpriteBatch</samp>
 +
|arg type 1 = <samp>SpriteBatch</samp>
 +
|arg desc 1 = The sprite batch being drawn. Add anything you want to appear on-screen to this sprite batch.
 +
 +
|arg name 2 = <samp>e.Step</samp>
 +
|arg type 2 = <samp>RenderSteps</samp>
 +
|arg desc 2 = The step being rendered in the draw cycle.
 +
}}
 +
{{/event
 +
|group = Display
 +
|name  = RenderedStep
 +
|desc  = ''(Specialized)'' Raised after the game draws a specific step in the rendering cycle.  This gives more granular control over render logic, but is more vulnerable to changes in game updates. Consider using one of the other render events if possible.
 +
 +
|arg name 1 = <samp>e.SpriteBatch</samp>
 +
|arg type 1 = <samp>SpriteBatch</samp>
 +
|arg desc 1 = The sprite batch being drawn. Add anything you want to appear on-screen to this sprite batch.
 +
 +
|arg name 2 = <samp>e.Step</samp>
 +
|arg type 2 = <samp>RenderSteps</samp>
 +
|arg desc 2 = The step being rendered in the draw cycle.
 
}}
 
}}
 
|}
 
|}
Line 871: Line 896:  
<syntaxhighlight lang="c#">
 
<syntaxhighlight lang="c#">
 
/// <summary>The main entry point for the mod.</summary>
 
/// <summary>The main entry point for the mod.</summary>
public class ModEntry : Mod
+
internal sealed class ModEntry : Mod
 
{
 
{
 
     /*********
 
     /*********
Line 914: Line 939:  
<syntaxhighlight lang="c#">
 
<syntaxhighlight lang="c#">
 
/// <summary>The main entry point for the mod.</summary>
 
/// <summary>The main entry point for the mod.</summary>
public class ModEntry : Mod
+
internal sealed class ModEntry : Mod
 
{
 
{
 
     /*********
 
     /*********
translators
8,446

edits

Navigation menu