Skip to content

Conversation

@Haisairova-Official
Copy link
Contributor

@Haisairova-Official Haisairova-Official commented Dec 21, 2025

目前未发现更多兼容性问题。测试于SDGB151+EZ156+160
修改部分表述
烦内就这样子吧)


Note

Introduces CustomSkinsPlusStatic to load PNG overrides and forcibly replace Image/RawImage assets across the UI via Harmony patches.

  • Fancy Mod:
    • New CustomSkinsPlusStatic in AquaMai.Mods/Fancy/RsOverride.cs with ConfigSection and directory ConfigEntry (LocalAssets/GlobalTextureOverride).
    • Asset Loading: Preloads *.png from the configured folder into SpritePool/TexturePool with normalized names.
    • Rendering Hooks:
      • Harmony Prefix on Graphic.Rebuild to swap Image.sprite and RawImage.texture with pool matches and reset renderer color.
      • Harmony Postfix on CanvasScaler.OnEnable to bulk-scan children and replace matching sprites/textures.

Written by Cursor Bugbot for commit 692d10b. This will update automatically on new commits. Configure here.

Implement CustomSkinsPlusStatic for full-scene background replacement with static injection. Includes methods for loading custom sprites and textures, and patches for rendering graphics.
Updated warning message for potential performance impact and conflicts.
@gemini-code-assist
Copy link

Summary of Changes

Hello @Haisairova-Official, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求引入了一个名为“力大砖飞”的新模组,用于 AquaMai 游戏。该模组允许用户通过从本地目录加载自定义 PNG 图像,全局替换游戏中的精灵和纹理。其实现通过 HarmonyLib 进行静态注入,拦截图形渲染和画布缩放事件,确保自定义资源能在整个游戏中应用。作者已完成验证,并在特定测试配置下未发现其他兼容性问题。

Highlights

  • 新模组引入: 新增了 AquaMai.Mods/Fancy/RsOverride.cs 文件,引入了一个名为“力大砖飞”的全场景背景替换模组。
  • 自定义图片替换功能: 该模组允许用户从指定目录 (LocalAssets/Skins) 加载自定义 PNG 图片,以替换游戏中的精灵和纹理。
  • 实现方式: 它利用 HarmonyLib 对 Graphic.Rebuild (Prefix) 和 CanvasScaler.OnEnable (Postfix) 进行补丁,实现动态替换 Image.spriteRawImage.texture
  • 潜在风险提示: 模组配置中包含警告,提示可能对游戏性能造成未知影响,并可能与其他模组冲突。
  • 兼容性测试: PR 描述指出已在 SDGB151+EZ156+160 配置上进行了测试,未发现更多兼容性问题。
  • 描述修改: PR 描述中提到修改了部分表述。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

本次 PR 引入了一个“力大砖飞”式的自定义皮肤功能,通过 Harmony patch 运行时替换游戏内的 Sprite 和 Texture。这个实现方式非常直接,正如其名,但也带来了代码注释中提到的潜在性能风险。整体代码逻辑清晰,但在错误处理、路径解析和逻辑一致性方面有几个可以改进的地方。我已经在代码中留下了具体的建议,希望能帮助您完善这个功能。

SpritePool[name] = sprite;
TexturePool[name] = tex;
}
} catch { }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

catch 块为空,会静默地忽略所有加载图片过程中的错误(例如,文件损坏或格式不正确)。这会使调试变得非常困难,因为用户可能不知道为什么他们的自定义皮肤没有生效。建议在 catch 块中捕获异常并添加日志记录,以便追踪问题。

            } catch (Exception e) { MelonLogger.Error($"Failed to load custom skin '{Path.GetFileName(file)}': {e.Message}"); }

Comment on lines 28 to 29
try { resolvedPath = FileSystem.ResolvePath(skinsDir); }
catch { resolvedPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, skinsDir); }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

使用 try-catch 来处理路径解析逻辑会让代码意图变得不清晰,并且是一种反模式(anti-pattern)。对于游戏模组,使用 AppDomain.CurrentDomain.BaseDirectory 通常比 Environment.CurrentDirectory 更可靠,因为后者可能会在运行时被改变。建议简化此处的路径解析逻辑,直接使用更可靠的基准目录。

        resolvedPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, skinsDir);

Comment on lines +103 to +104
if (img.sprite != null && SpritePool.TryGetValue(img.sprite.name.ToLower(), out var s))
img.sprite = s;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

OnGraphicRebuild 方法中,替换图片后会调用 img.canvasRenderer.SetColor(Color.white) 来重置颜色,以避免意外的颜色叠加。但在 OnCanvasEnable 方法中缺少了这个逻辑。为了保持行为一致性并避免潜在的视觉问题,建议在这里也添加颜色重置的逻辑。同时,为了代码可读性和可维护性,建议为 if 语句使用花括号 {}

            if (img.sprite != null && SpritePool.TryGetValue(img.sprite.name.ToLower(), out var s))
            {
                img.sprite = s;
                img.canvasRenderer.SetColor(Color.white);
            }

Comment on lines +110 to +111
if (rImg.texture != null && TexturePool.TryGetValue(rImg.texture.name.ToLower(), out var t))
rImg.texture = t;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

同样地,为了与 OnGraphicRebuild 的行为保持一致,建议在替换 RawImagetexture 后,也重置其 canvasRenderer 的颜色为 Color.white。同时,为了代码可读性和可维护性,建议为 if 语句使用花括号 {}

            if (rImg.texture != null && TexturePool.TryGetValue(rImg.texture.name.ToLower(), out var t))
            {
                rImg.texture = t;
                rImg.canvasRenderer.SetColor(Color.white);
            }

Copy link
Member

@clansty clansty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我一年前尝试搞 4k 贴图的时候怎么没想到呢

@clansty
Copy link
Member

clansty commented Dec 21, 2025

以及隆重欢迎新开发者加入 AquaMai 大家庭

@Haisairova-Official
Copy link
Contributor Author

新屎山制造小作坊)

@Haisairova-Official
Copy link
Contributor Author

这下搞定啦 改成 "LocalAssets/ResourcesOverride"
我可能之后还会写个script什么相关的可以共用一个)

@clansty
Copy link
Member

clansty commented Dec 21, 2025

好耶
共用的话,得考虑一下功能是不是很有联系,不是很有联系的话应该开个新的 .cs 文件

@clansty clansty merged commit 29dc939 into MuNET-OSS:main Dec 21, 2025
1 check passed
@Haisairova-Official
Copy link
Contributor Author

对我会新写一个 毕竟这个能跑就不要动他了)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants