模组:IDE 參考

出自Stardew Valley Wiki
於 2021年4月14日 (三) 09:07 由 1059 Studio對話 | 貢獻 所做的修訂
跳至導覽 跳至搜尋

目錄

Robin building.png
“我這裏還有很多事情需要處理。”
— 羅賓

不完整的翻譯

本文或部分尚未完全翻譯成中文。 歡迎您通過編輯幫助其建設。
最後編輯1059 Studio於2021-04-14 09:07:33.

此頁面描述了如何使用 Visual Studio 2019 或 MonoDevelop/Visual Studio for Mac 來製作 SMAPI 模組。參閱在主頁面中的 創建 SMAPI 模組

在你開始之前

  • 安裝 Visual Studio Community (Windows)、MonoDevelop (Linux)、Visual Studio for Mac (Mac)
  • 你應該具備 C# 入門基礎
  • 以下是一些需要記住的基本術語:
    term definition
    IDE 開發環境,就是現在你的 Visual Studio 或 MonoDevelop
    DLL .dll 後綴的文件(全稱叫 動態連結庫,英文 Dynamic Link Library),文件包括了你的代碼,SMAPI 將加載的東西
    項目 每個項目在生成(編譯,或者說是構建)的時候都會生成獨立的文件
    解決方案 項目的集合,每一個工程可以包含多個項目。所謂的工程也稱為解決方案,可以理解為要解決問題的方案,可能聽起來有點奇怪,不過這是專業術語

創建一個模組項目

在編寫模組的代碼之前,需要創建一個解決方案和一個包含它的項目

Windows (Visual Studio 2019)

  1. 打開 Visual Studio 2019.
  2. 點擊 創建新項目
    File:Modding - IDE reference - create project (Visual Studio 1) - ZH.png
  3. 篩選器選擇語言 C#,然後選擇 類庫(.NET Framework),點擊 下一步。確保你選擇了正確的選項,否則是不會起作用的
    File:Modding - IDE reference - create project (Visual Studio 2) - ZH.png
  4. 配置新項目 窗口中:
    1. 輸入你的模組名稱。按照約定,名稱應該是一個由幾個單詞去除空格連起來的字符串(例如 MyNewMod,避免使用特殊字符,如果實在看不習慣可以用下劃線來代替空格。可以使用中文,不過這會讓其他國家的玩家感到困惑,所以為了便於在國際上交流請儘可能避免使用中文)。
    2. 取消勾選 將解決方案和項目放在同一目錄中
    3. 確保選擇的是 .NET Framework 4.5.2
    4. 點擊 創建 來創建項目
    File:Modding - IDE reference - create project (Visual Studio 3) - ZH.png

Set the target framework

The 'target framework' is the version of .NET Framework your code uses, which affects the version needed to run your mod. The recommended target framework is .NET Framework 4.5, which is the version SMAPI itself targets.

In Visual Studio 2017

  1. Open the Solution Explorer pane. If it's not visible, click View » Solution Explorer from the menu:
    Modding - IDE reference - show solution pane (Visual Studio).png
  2. From the Solution Explorer, right-click on the project and choose Properties:
    Modding - IDE reference - change target framework (Visual Studio 1).png
  3. On the Application tab, change the Target Framework dropdown to .NET Framework 4.5:
    Modding - IDE reference - change target framework (Visual Studio 2).png
  4. A dialogue may appear asking you to confirm the change. Click 'Yes' to confirm:
    Modding - IDE reference - change target framework (Visual Studio 3).png