Zero Sievertv1.2.24-1.2.22026年12月4日 更新

UiPatchLib

为其他模组提供动态修改游戏 UI 文件的函数集合,旨在避免破坏模组兼容性。本模组本身不提供独立功能,供其他模组调用;需要 GMLoader。

UiPatchLib 提供一组函数,可动态修改游戏 UI 文件,同时避免破坏模组兼容性。本模组本身不执行独立功能,仅供其他模组使用。

示例模组

创建模组文件 ZS_vanilla\mods\config\code_patch\New Game Greeting.yaml,并写入以下内容:

gml_Object_obj_logo_screen_Create_0:
- type: append
  code: |-
    ui_patch_add_replace_all("ZS_vanilla/ui/mm_sidebar_main.ui", "label = \"New Game\"", "label = \"Wheeee New Game!\"");

函数文档

简单字符串替换

ui_patch_add_replace_all(ui_file, find, replace, name = "");

对 UI 文件执行简单的字符串替换。

  • ui_file:UI 文件的相对路径,例如 ZS_vanilla/ui/pda_hunter_skills_select.ui。
  • find:要查找的子字符串。
  • replace:用于替换的字符串。
  • name:可选的补丁名称。

示例:

ui_patch_add_replace_all("ZS_vanilla/ui/mm_sidebar_main.ui", "label = \"New Game\"", "label = \"Wheeee\"", "MyFirstPatch");

带游戏内警告的字符串替换

如果未找到目标字符串,则显示游戏内警告信息。

ui_patch_add_replace_all_verbose(ui_file, find, replace, name = "");

参数含义与 ui_patch_add_replace_all 相同。示例:

ui_patch_add_replace_all_verbose("ZS_vanilla/ui/pda_hunter_skills_select.ui", "find this string", "replace with this string", "MyFirstPatch");

完全替换 UI 文件内容

ui_patch_add_set_content(ui_file, ui_file_content, name = "");
  • ui_file:UI 文件的相对路径。
  • ui_file_content:要写入的目标内容。
  • name:可选的补丁名称。

示例:

ui_patch_add_set_content("ZS_vanilla/ui/pda_hunter_skills_select.ui", "this is my content", "MyFirstPatch");

通用回调补丁

ui_patch_add(ui_file, __Name, __Function, __Args, __ExceptionHandler = "");
  • ui_file:UI 文件的相对路径。
  • __Name:补丁名称,例如 MyPatch。
  • __Function:用于修改 UI 文件内容的回调函数。调用时接收三个参数:
    • 参数 0:之前提供的 __Name。
    • 参数 1:当前 UI 文件内容。
    • 参数 2:之前提供的 __Args。
  • 函数返回的字符串将作为新的文件内容。
  • __Args:传递给函数的参数。
  • __ExceptionHandler:可选的异常处理函数;函数至少需要接收一个参数。

示例:

ui_patch_add(
    "ZS_vanilla/ui/pda_hunter_skills_select.ui",
    "MyPatch_To_Replace_Content_Of_pda_hunter_skills_select.ui",
    function(_name, _original_content, _args) {
        return _args[0];
    },
    ["this is my new content"],
    scr_draw_text_with_box
);

前置

  • GMLoader

作者:kofolamaster。

来源与文件

  • 原作者:kofolamaster
  • 原项目:UiPatchLib
  • 文件:UiPatchLib(ID:1582)

来源列出的依赖与关系

  • 作者列出的前置:GMLoader

前往 N 网打开所选文件。安装与下载要求以原作者及平台说明为准。

<!-- aoe-mods-source:nexusmods:zerosievert:139 -->

下载模块

共 1 个来源
立即下载推荐来源
前往下载