更改

跳到导航 跳到搜索
第174行: 第174行:  
# 如果其他所有方法均失败,请到 [[Modding:Community#Discord|#modding in the Stardew Valley Discord]] 寻求帮助 :)
 
# 如果其他所有方法均失败,请到 [[Modding:Community#Discord|#modding in the Stardew Valley Discord]] 寻求帮助 :)
   −
==FAQs==
+
== 常见问题==
===Where's the SMAPI documentation?===
+
===SMAPI 的文档在哪里?===
This is just the 'getting started' tutorial. For more documentation, see the [[Modding:Modder Guide/APIs|SMAPI reference]] and the [[Modding:Index|topics listed on the index page]].
+
这只是“入门”教程。更多信息请参阅 [[Modding:Modder Guide/APIs|SMAPI reference]] [[Modding:Index|topics listed on the index page]].
   −
===How do I make my mod work crossplatform?===
+
=== 我如何使我的模组跨平台工作?===
SMAPI will automatically adjust your mod so it works on Linux, MacOS, and Windows. However, there are a few things you should do to avoid problems:
+
SMAPI 将自动调整模组使其可以在 Linux 、MacOS 和W indows 上运行。但是你也应该采取一些措施来避免出现问题:
    
<ol>
 
<ol>
<li>Use the [https://smapi.io/package/readme crossplatform build config] package to automatically set up your project references. This makes crossplatform compatibility easier and lets your code compile on any platform. (If you followed the above guide, you already have this.)</li>
+
<li> 使用 [https://smapi.io/package/readme 跨平台构建配置] 包以自动设置您的项目引用,这使跨平台兼容性变得更容易,并使代码可以在任何平台上进行编译。(如果遵循上述指南,那么就没问题了)</li>
   −
<li>Use <tt>Path.Combine</tt> to build file paths, don't hardcode path separators since they won't work on all platforms.
+
<li> 使用 <tt>Path.Combine</tt> 要构建文件路径,请不要对路径分隔符进行硬编码,因为它们不能在所有平台上都可使用
    
<syntaxhighlight lang="c#">
 
<syntaxhighlight lang="c#">
// ✘ Don't do this! It won't work on Linux/Mac.
+
// ✘ 不要这样做!这在 Linux Mac 上不会起作用
 
string path = this.Helper.DirectoryPath + "\assets\image.png";
 
string path = this.Helper.DirectoryPath + "\assets\image.png";
   −
// ✓ This is OK
+
// ✓ 这样才是对的
 
string path = Path.Combine(this.Helper.DirectoryPath, "assets", "image.png");
 
string path = Path.Combine(this.Helper.DirectoryPath, "assets", "image.png");
 
</syntaxhighlight></li>
 
</syntaxhighlight></li>
   −
<li>Use <tt>this.Helper.DirectoryPath</tt>, don't try to determine the mod path yourself.
+
<li> 使用 <tt>this.Helper.DirectoryPath</tt> ,请勿尝试自行确定模组路径
    
<syntaxhighlight lang="c#">
 
<syntaxhighlight lang="c#">
// ✘ Don't do this! It will crash if SMAPI rewrites the assembly (e.g. to update or crossplatform it).
+
// ✘ 不要这样做!如果 SMAPI 重写了程序集(例如对其进行了更新或跨平台),它将崩溃
string modFolder = Assembly.GetCallingAssembly().Location;
+
string modFolder = Assembly .GetCallingAssembly().Location;
   −
// ✓ This is OK
+
// ✓ 这样就没问题
 
string modFolder = this.Helper.DirectoryPath;
 
string modFolder = this.Helper.DirectoryPath;
 
</syntaxhighlight></li>
 
</syntaxhighlight></li>
 
</ol>
 
</ol>
   −
===How do I decompile the game code?===
+
=== 如何反编译游戏代码?===
It's often useful to see how the game code works. The game code is compiled into <tt>StardewValley.exe</tt> (i.e. converted to a machine-readable format), but you can decompile it get a mostly-readable approximation of the original code. (This might not be fully functional due to decompiler limitations, but you'll be able to see what it's doing.)
+
观察游戏代码的工作方式通常对开发很有用。游戏的代码都编译在 <tt>StardewValley.exe</tt> 文件中,但是可以对其进行反编译,以获得原始代码的近似可读性。(由于反编译器的限制,此功能可能无法完全发挥作用,但是能够看到它在做什么。)
   −
To decompile the game code...
+
要反编译游戏代码...
   −
; On Windows&#58;
+
; Windows &#58;
:# First-time setup:
+
:# 第一步:
:## Install the latest {{github|icsharpcode/ILSpy/releases|ILSpy}} release (get the "ILSpy_binaries" file under assets).
+
:## 安装最新版本的 {{github|icsharpcode/ILSpy/releases|ILSpy}}
:## Open ILSpy.
+
:## 打开 ILSpy
:## Click ''View > Options'', scroll to the "Other" section at the bottom, and enable "Always qualify member references".
+
:## 点击 '' 视图 > 选项'' 滑动至底部的 " 其他" 选项, 并启用“始终限定成员引用”
:# Open <tt>StardewValley.exe</tt> in ILSpy.
+
:# 在 ILSpy 打开 <tt>StardewValley.exe</tt>
:# Right-click on ''Stardew Valley'' and choose ''Save Code'' to create a decompiled project you can open in Visual Studio.
+
:# 右键 ''Stardew Valley'' 并选择 '' 保存代码'' 创建反编译的项目,可以在 Visual Studio 中打开
    
; On Linux/MacOS&#58;
 
; On Linux/MacOS&#58;
第225行: 第225行:  
:# 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 <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.
   −
To unpack the XNB data/image files, see [[Modding:Editing XNB files]].
+
要解包 XNB 数据或图像文件,请参阅 [[ 模组: 编辑 XNB 文件]]
    
[[Category:模组]]
 
[[Category:模组]]
203

个编辑

导航菜单