Linha 81: |
Linha 81: |
| <li>Adicione um arquivo C# class Chamado <tt>ModEntry.cs</tt> ao seu projeto (Veja [[Modding:IDE reference#Add a file|como adicionar um arquivo]]).</li> | | <li>Adicione um arquivo C# class Chamado <tt>ModEntry.cs</tt> ao seu projeto (Veja [[Modding:IDE reference#Add a file|como adicionar um arquivo]]).</li> |
| <li>Coloque este código no arquivo (replace <tt>YourProjectName</tt> with the name of your project): | | <li>Coloque este código no arquivo (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; |
Linha 122: |
Linha 122: |
| } | | } |
| } | | } |
− | </source></li> | + | </syntaxhighlight></li> |
| </ol> | | </ol> |
| | | |
Linha 139: |
Linha 139: |
| <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 (replacing the <tt><...></tt> placeholders): | | <li>Paste this code into the file (replacing the <tt><...></tt> placeholders): |
− | <source lang="json"> | + | <syntaxhighlight lang="json"> |
| { | | { |
| "Name": "<your project name>", | | "Name": "<your project name>", |
Linha 150: |
Linha 150: |
| "UpdateKeys": [] | | "UpdateKeys": [] |
| } | | } |
− | </source></li> | + | </syntaxhighlight></li> |
| </ol> | | </ol> |
| | | |
Linha 183: |
Linha 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 = Helper.DirectoryPath + "\assets\asset.xnb"; | | string path = Helper.DirectoryPath + "\assets\asset.xnb"; |
Linha 189: |
Linha 189: |
| // ✓ This is OK | | // ✓ This is OK |
| string path = Path.Combine(Helper.DirectoryPath, "assets", "asset.xnb"); | | string path = Path.Combine(Helper.DirectoryPath, "assets", "asset.xnb"); |
− | </source></li> | + | </syntaxhighlight></li> |
| | | |
| <li>Use <tt>Helper.DirectoryPath</tt>, don't try to determine the mod path yourself. | | <li>Use <tt>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; |
Linha 199: |
Linha 199: |
| // ✓ This is OK | | // ✓ This is OK |
| string modFolder = Helper.DirectoryPath; | | string modFolder = Helper.DirectoryPath; |
− | </source></li> | + | </syntaxhighlight></li> |
| </ol> | | </ol> |
| | | |