更改

文本替换 - 替换“tt>”为“samp>”
第56行: 第56行:  
# 创建一个空的 C#类库 项目
 
# 创建一个空的 C#类库 项目
 
# 目标框架选择 .NET Framework 4.5 或者 4.5.1, 建议使用 4.5.2
 
# 目标框架选择 .NET Framework 4.5 或者 4.5.1, 建议使用 4.5.2
# 参考 [https://smapi.io/package/readme <tt>Pathoschild.Stardew.ModBuildConfig</tt> NuGet package] 根据要在其上编译模组的平台自动添加正确的引用。
+
# 参考 [https://smapi.io/package/readme <samp>Pathoschild.Stardew.ModBuildConfig</samp> NuGet package] 根据要在其上编译模组的平台自动添加正确的引用。
# 创建一个 <tt>ModEntry</tt> 类,该类将 <tt>StardewModdingAPI.Mod</tt> 子类化
+
# 创建一个 <samp>ModEntry</samp> 类,该类将 <samp>StardewModdingAPI.Mod</samp> 子类化
# 覆写 <tt>Entry</tt> 方法,并使用 [[#Mod APIs|SMAPI events and APIs]] 编写代码
+
# 覆写 <samp>Entry</samp> 方法,并使用 [[#Mod APIs|SMAPI events and APIs]] 编写代码
# 创建一个 [[#添加你的清单|<tt>manifest.json</tt> 文件]] 来描述了你的 SMAPI 模组
+
# 创建一个 [[#添加你的清单|<samp>manifest.json</samp> 文件]] 来描述了你的 SMAPI 模组
 
# 创建 [[#发布你的模组|一个包含模组文件的zip压缩包]] 来发布
 
# 创建 [[#发布你的模组|一个包含模组文件的zip压缩包]] 来发布
 
}}
 
}}
第69行: 第69行:  
# 创建 类库 项目,选择 .NET Framework 框架 (参阅 [[模组:IDE 参考#创建项目|如何创建一个项目]])。确保你选择的是 .NET Framework 而不是 .NET Core 或者 .NET Standard
 
# 创建 类库 项目,选择 .NET Framework 框架 (参阅 [[模组:IDE 参考#创建项目|如何创建一个项目]])。确保你选择的是 .NET Framework 而不是 .NET Core 或者 .NET Standard
 
# 选择目标框架版本为 .NET Framework 4.5 或 4.5.1,使用 4.5.2 最佳 (参阅 [[模组:IDE 参考#选择目标框架|如何改变目标框架]])
 
# 选择目标框架版本为 .NET Framework 4.5 或 4.5.1,使用 4.5.2 最佳 (参阅 [[模组:IDE 参考#选择目标框架|如何改变目标框架]])
# 添加 [https://www.nuget.org/packages/Pathoschild.Stardew.ModBuildConfig <tt>Pathoschild.Stardew.ModBuildConfig</tt> NuGet 包] (参阅 [[模组:IDE 参考#添加 NuGet 包|如何添加 NuGet 包]]).
+
# 添加 [https://www.nuget.org/packages/Pathoschild.Stardew.ModBuildConfig <samp>Pathoschild.Stardew.ModBuildConfig</samp> NuGet 包] (参阅 [[模组:IDE 参考#添加 NuGet 包|如何添加 NuGet 包]]).
 
# 安装完包之后重新启动 Visual Studio 或者 MonoDevelop
 
# 安装完包之后重新启动 Visual Studio 或者 MonoDevelop
   第76行: 第76行:     
<ol>
 
<ol>
<li>删除 <tt>Class1.cs</tt> 或者 <tt>MyClass.cs</tt> 文件 (参阅 [[模组:IDE 参考#删除文件|如何删除文件]]).</li>
+
<li>删除 <samp>Class1.cs</samp> 或者 <samp>MyClass.cs</samp> 文件 (参阅 [[模组:IDE 参考#删除文件|如何删除文件]]).</li>
<li>在项目中添加一个 C# 类文件,取名为 <tt>ModEntry.cs</tt> (参阅 [[模组:IDE 参考#添加文件|如何添加文件]]).</li>
+
<li>在项目中添加一个 C# 类文件,取名为 <samp>ModEntry.cs</samp> (参阅 [[模组:IDE 参考#添加文件|如何添加文件]]).</li>
<li>在此文件中输入代码 (把 <tt>YourProjectName</tt> 换成你的解决方案的名字):
+
<li>在此文件中输入代码 (把 <samp>YourProjectName</samp> 换成你的解决方案的名字):
 
<syntaxhighlight lang="c#">
 
<syntaxhighlight lang="c#">
 
using System;
 
using System;
第129行: 第129行:  
# <code>using X;</code> (参阅 [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-directive using directive]) 使该命名空间中的类在你的代码中可用
 
# <code>using X;</code> (参阅 [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-directive using directive]) 使该命名空间中的类在你的代码中可用
 
# <code>namespace YourProjectName</code> (参阅 [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/namespace namespace keyword]) 定义代码的范围,入门时不必担心,因为在新建类文件时 Visual Studio 或 MonoDevelop 会自动添加它
 
# <code>namespace YourProjectName</code> (参阅 [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/namespace namespace keyword]) 定义代码的范围,入门时不必担心,因为在新建类文件时 Visual Studio 或 MonoDevelop 会自动添加它
# <code>public class ModEntry : Mod</code> (参阅 [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/class class keyword]) 创建你的模组的主类文件,并继承 SMAPI 的 <tt>Mod</tt> 类。SMAPI 将自动检测你的 <tt>Mod</tt> 子类,而 <tt>Mod</tt> 使你可访问 SMAPI 的接口
+
# <code>public class ModEntry : Mod</code> (参阅 [https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/class class keyword]) 创建你的模组的主类文件,并继承 SMAPI 的 <samp>Mod</samp> 类。SMAPI 将自动检测你的 <samp>Mod</samp> 子类,而 <samp>Mod</samp> 使你可访问 SMAPI 的接口
 
# <code>public override void Entry(IModHelper helper)</code> 是将模组加载到游戏中时 SMAPI 将调用的方法。这里的 <code>helper</code> 对象提供了对许多 SMAPI 接口的便捷访问
 
# <code>public override void Entry(IModHelper helper)</code> 是将模组加载到游戏中时 SMAPI 将调用的方法。这里的 <code>helper</code> 对象提供了对许多 SMAPI 接口的便捷访问
# <code>helper.Events.Input.ButtonPressed += this.OnButtonPressed;</code> 添加了一个 '事件绑定' (i.e. a method to call) 到当按下按钮的事件发生时. 换句话说,当一个按钮被按下 (也就是 <tt>helper.Events.Input.ButtonPressed</tt> 事件触发了), SMAPI 会调用你的 <tt>this.OnButtonPressed</tt> 方法。参阅 [[模组:Modder Guide/APIs/Events|SMAPI 中的事件]] 获取更多信息
+
# <code>helper.Events.Input.ButtonPressed += this.OnButtonPressed;</code> 添加了一个 '事件绑定' (i.e. a method to call) 到当按下按钮的事件发生时. 换句话说,当一个按钮被按下 (也就是 <samp>helper.Events.Input.ButtonPressed</samp> 事件触发了), SMAPI 会调用你的 <samp>this.OnButtonPressed</samp> 方法。参阅 [[模组:Modder Guide/APIs/Events|SMAPI 中的事件]] 获取更多信息
    
===添加你的清单===
 
===添加你的清单===
第137行: 第137行:     
<ol>
 
<ol>
<li>向你的解决方案添加一个名为 <tt>manifest.json</tt> 的文本文件</li>
+
<li>向你的解决方案添加一个名为 <samp>manifest.json</samp> 的文本文件</li>
 
<li>将这些代码复制到文件中:(注意要区分键值的大小写,避免出现意外情况)
 
<li>将这些代码复制到文件中:(注意要区分键值的大小写,避免出现意外情况)
 
<syntaxhighlight lang="json">
 
<syntaxhighlight lang="json">
第157行: 第157行:     
===构建你的模组===
 
===构建你的模组===
# 构建项目<br \>如果你不知道怎么构建:在开发工具的菜单栏中选择 '''项目''',然后选择 '''生成'''<br \>如果你已经做了 [[#创建解决方案|创建解决方案]] 这一步,在构建时你的模组会自动安装到游戏的 <tt>Mods</tt> 文件夹中
+
# 构建项目<br \>如果你不知道怎么构建:在开发工具的菜单栏中选择 '''项目''',然后选择 '''生成'''<br \>如果你已经做了 [[#创建解决方案|创建解决方案]] 这一步,在构建时你的模组会自动安装到游戏的 <samp>Mods</samp> 文件夹中
 
# 通过 SMAPI 启动游戏
 
# 通过 SMAPI 启动游戏
   第182行: 第182行:  
<li>使用 [https://smapi.io/package/readme 跨平台构建配置] 包以自动设置您的项目引用,这使跨平台兼容性变得更容易,并使代码可以在任何平台上进行编译。(如果遵循上述指南,那么就没问题了)</li>
 
<li>使用 [https://smapi.io/package/readme 跨平台构建配置] 包以自动设置您的项目引用,这使跨平台兼容性变得更容易,并使代码可以在任何平台上进行编译。(如果遵循上述指南,那么就没问题了)</li>
   −
<li>使用 <tt>Path.Combine</tt> 构建文件路径,请不要对路径分隔符进行硬编码,因为它们不能在所有平台上都可使用
+
<li>使用 <samp>Path.Combine</samp> 构建文件路径,请不要对路径分隔符进行硬编码,因为它们不能在所有平台上都可使用
    
<syntaxhighlight lang="c#">
 
<syntaxhighlight lang="c#">
第192行: 第192行:  
</syntaxhighlight></li>
 
</syntaxhighlight></li>
   −
<li>使用 <tt>this.Helper.DirectoryPath</tt>,请勿尝试自行确定模组路径
+
<li>使用 <samp>this.Helper.DirectoryPath</samp>,请勿尝试自行确定模组路径
    
<syntaxhighlight lang="c#">
 
<syntaxhighlight lang="c#">
第204行: 第204行:     
===如何反编译游戏代码?===
 
===如何反编译游戏代码?===
 观察游戏代码的工作方式通常对开发很有用。游戏的代码都编译在 <tt>StardewValley.exe</tt> 文件中,但是可以对其进行反编译,以获得原始代码的近似可读性。(由于反编译器的限制,此功能可能无法完全发挥作用,但是能够看到它在做什么。)
+
 观察游戏代码的工作方式通常对开发很有用。游戏的代码都编译在 <samp>StardewValley.exe</samp> 文件中,但是可以对其进行反编译,以获得原始代码的近似可读性。(由于反编译器的限制,此功能可能无法完全发挥作用,但是能够看到它在做什么。)
    
 要反编译游戏代码...
 
 要反编译游戏代码...
第213行: 第213行:  
:## 打开 ILSpy
 
:## 打开 ILSpy
 
:## 点击 ''视图 > 选项''滑动至底部的 "其他" 选项, 并启用“始终限定成员引用”
 
:## 点击 ''视图 > 选项''滑动至底部的 "其他" 选项, 并启用“始终限定成员引用”
:# 在 ILSpy 打开 <tt>StardewValley.exe</tt>
+
:# 在 ILSpy 打开 <samp>StardewValley.exe</samp>
 
:# 右键 ''Stardew Valley'' 并选择 ''保存代码'' 创建反编译的项目,可以在 Visual Studio 中打开
 
:# 右键 ''Stardew Valley'' 并选择 ''保存代码'' 创建反编译的项目,可以在 Visual Studio 中打开
   第220行: 第220行:  
:# Get the [https://marketplace.visualstudio.com/items?itemName=icsharpcode.ilspy-vscode ILSpy .NET Decompiler] plugin for VSCode.
 
:# Get the [https://marketplace.visualstudio.com/items?itemName=icsharpcode.ilspy-vscode ILSpy .NET Decompiler] plugin for VSCode.
 
:# Open the Visual Studio Code Command Palette (<code>Command+Shift+P</code>), then type <code>ilspy</code> to show the two commands.
 
:# Open the Visual Studio Code Command Palette (<code>Command+Shift+P</code>), then type <code>ilspy</code> to show the two commands.
:# Choose ''Decompile IL Assembly (pick file)'', then choose the <tt>StardewValley.exe</tt> in your [[Modding:Player Guide/Getting Started#Find your game folder|game folder]].
+
:# Choose ''Decompile IL Assembly (pick file)'', then choose the <samp>StardewValley.exe</samp> in your [[Modding:Player Guide/Getting Started#Find your game folder|game folder]].
:# A tree view named <tt>ILSPY DECOMPILED MEMBERS</tt> should appear in the Explorer view. This lets you expand and select various nodes to see the decompiled C# code in the editor.
+
:# A tree view named <samp>ILSPY DECOMPILED MEMBERS</samp> should appear in the Explorer view. This lets you expand and select various nodes to see the decompiled C# code in the editor.
    
 要解包 XNB 数据或图像文件,请参阅 [[模组:编辑 XNB 文件]]
 
 要解包 XNB 数据或图像文件,请参阅 [[模组:编辑 XNB 文件]]
界面管理员、patroller、结构式讨论监督员管理员、translators
105,955

个编辑