Line 80: |
Line 80: |
| <li>Add a C# class file called <tt>ModEntry.cs</tt> to your project (see [[Modding:IDE reference#Add a file|how to add a file]]).</li> | | <li>Add a C# class file called <tt>ModEntry.cs</tt> to your project (see [[Modding:IDE reference#Add a file|how to add a file]]).</li> |
| <li>Put this code in the file (replace <tt>YourProjectName</tt> with the name of your project): | | <li>Put this code in the file (replace <tt>YourProjectName</tt> with the name of your project): |
− | <source lang="c#"> | + | <syntaxhighlight lang="c#"> |
| using System; | | using System; |
| using Microsoft.Xna.Framework; | | using Microsoft.Xna.Framework; |
Line 121: |
Line 121: |
| } | | } |
| } | | } |
− | </source></li> | + | </syntaxhighlight></li> |
| </ol> | | </ol> |
| | | |
Line 138: |
Line 138: |
| <li>Add a file named <tt>manifest.json</tt> to your project.</li> | | <li>Add a file named <tt>manifest.json</tt> to your project.</li> |
| <li>Paste this code into the file: | | <li>Paste this code into the file: |
− | <source lang="json"> | + | <syntaxhighlight lang="json"> |
| { | | { |
| "Name": "<your project name>", | | "Name": "<your project name>", |
Line 149: |
Line 149: |
| "UpdateKeys": [] | | "UpdateKeys": [] |
| } | | } |
− | </source></li> | + | </syntaxhighlight></li> |
| <li>Replace the <tt><...></tt> placeholders with the correct info. Don't leave any <tt><></tt> symbols!</li> | | <li>Replace the <tt><...></tt> placeholders with the correct info. Don't leave any <tt><></tt> symbols!</li> |
| </ol> | | </ol> |
Line 183: |
Line 183: |
| <li>Use <tt>Path.Combine</tt> to build file paths, don't hardcode path separators since they won't work on all platforms. | | <li>Use <tt>Path.Combine</tt> to build file paths, don't hardcode path separators since they won't work on all platforms. |
| | | |
− | <source lang="c#"> | + | <syntaxhighlight lang="c#"> |
| // ✘ Don't do this! It will crash on Linux/Mac. | | // ✘ Don't do this! It will crash on Linux/Mac. |
| string path = this.Helper.DirectoryPath + "\assets\asset.xnb"; | | string path = this.Helper.DirectoryPath + "\assets\asset.xnb"; |
Line 189: |
Line 189: |
| // ✓ This is OK | | // ✓ This is OK |
| string path = Path.Combine(this.Helper.DirectoryPath, "assets", "asset.xnb"); | | string path = Path.Combine(this.Helper.DirectoryPath, "assets", "asset.xnb"); |
− | </source></li> | + | </syntaxhighlight></li> |
| | | |
| <li>Use <tt>this.Helper.DirectoryPath</tt>, don't try to determine the mod path yourself. | | <li>Use <tt>this.Helper.DirectoryPath</tt>, don't try to determine the mod path yourself. |
| | | |
− | <source lang="c#"> | + | <syntaxhighlight lang="c#"> |
| // ✘ Don't do this! It will crash if SMAPI rewrites the assembly (e.g. to update or crossplatform it). | | // ✘ Don't do this! It will crash if SMAPI rewrites the assembly (e.g. to update or crossplatform it). |
| string modFolder = Assembly.GetCallingAssembly().Location; | | string modFolder = Assembly.GetCallingAssembly().Location; |
Line 199: |
Line 199: |
| // ✓ This is OK | | // ✓ This is OK |
| string modFolder = this.Helper.DirectoryPath; | | string modFolder = this.Helper.DirectoryPath; |
− | </source></li> | + | </syntaxhighlight></li> |
| </ol> | | </ol> |
| | | |