[F] DisplayInTouch无法热开启:在游戏开始后再按键打开DisplayInTouch会无效,由于组件未被创建#123
[F] DisplayInTouch无法热开启:在游戏开始后再按键打开DisplayInTouch会无效,由于组件未被创建#123clansty merged 1 commit intoMuNET-OSS:mainfrom
Conversation
审阅者指南(在小型 PR 中折叠)审阅者指南在游戏进行中,当中途开启该功能时,于 在 GameProcess.OnUpdate 期间延迟创建 DisplayInTouch 的时序图sequenceDiagram
actor Player
participant InputSystem
participant GameProcess
participant DisplayTouchInGame
participant GameMonitor0 as GameMonitor_0
participant CanvasList0 as canvasGameObjects_0
Player->>InputSystem: PressToggleDisplayInTouchKey
InputSystem->>DisplayTouchInGame: Update displayType[0] to enabled
loop Every frame
GameProcess->>GameProcess: OnUpdate
GameProcess-->>DisplayTouchInGame: OnGameProcessUpdate(____monitors)
DisplayTouchInGame->>CanvasList0: Check Count
alt Display just enabled and no canvas yet
DisplayTouchInGame->>DisplayTouchInGame: CreateDisplay(displayType[0], ____monitors[0])
DisplayTouchInGame->>GameMonitor0: Find Canvas/Sub and create UI
DisplayTouchInGame->>CanvasList0: Add created GameObjects
else Display already created or disabled
DisplayTouchInGame->>CanvasList0: Iterate and update active state
end
end
DisplayTouchInGame 及相关方法的类图classDiagram
class GameProcess {
+OnUpdate()
}
class GameMonitor {
+gameObject
}
class GameObject {
+transform
}
class Transform {
+Find(path)
}
class DisplayTouchInGame {
<<static>>
-int[] displayType
-List~GameObject~[] canvasGameObjects
+OnMusicSelectProcessUpdate()
+OnGameProcessUpdate(GameMonitor[] ____monitors)
+OnGameStart(GameMonitor[] ____monitors)
-CreateDisplay(int type, GameMonitor monitor)
}
GameProcess ..> DisplayTouchInGame : HarmonyPostfix_OnUpdate
GameProcess --> GameMonitor : uses
DisplayTouchInGame --> GameMonitor : uses
DisplayTouchInGame --> GameObject : creates
GameObject --> Transform : has
Transform --> GameObject : returns
文件层面的修改
技巧与命令与 Sourcery 交互
自定义你的使用体验访问你的 控制面板 来:
获取帮助Original review guide in EnglishReviewer's guide (collapsed on small PRs)Reviewer's GuideAdds lazy creation of DisplayInTouch UI during GameProcess.OnUpdate when the feature is toggled on mid‑game, and refactors the display-type splitting logic (types 4/5) into CreateDisplay so it can be reused outside of game start. Sequence diagram for lazy DisplayInTouch creation during GameProcess.OnUpdatesequenceDiagram
actor Player
participant InputSystem
participant GameProcess
participant DisplayTouchInGame
participant GameMonitor0 as GameMonitor_0
participant CanvasList0 as canvasGameObjects_0
Player->>InputSystem: PressToggleDisplayInTouchKey
InputSystem->>DisplayTouchInGame: Update displayType[0] to enabled
loop Every frame
GameProcess->>GameProcess: OnUpdate
GameProcess-->>DisplayTouchInGame: OnGameProcessUpdate(____monitors)
DisplayTouchInGame->>CanvasList0: Check Count
alt Display just enabled and no canvas yet
DisplayTouchInGame->>DisplayTouchInGame: CreateDisplay(displayType[0], ____monitors[0])
DisplayTouchInGame->>GameMonitor0: Find Canvas/Sub and create UI
DisplayTouchInGame->>CanvasList0: Add created GameObjects
else Display already created or disabled
DisplayTouchInGame->>CanvasList0: Iterate and update active state
end
end
Class diagram for DisplayTouchInGame and related methodsclassDiagram
class GameProcess {
+OnUpdate()
}
class GameMonitor {
+gameObject
}
class GameObject {
+transform
}
class Transform {
+Find(path)
}
class DisplayTouchInGame {
<<static>>
-int[] displayType
-List~GameObject~[] canvasGameObjects
+OnMusicSelectProcessUpdate()
+OnGameProcessUpdate(GameMonitor[] ____monitors)
+OnGameStart(GameMonitor[] ____monitors)
-CreateDisplay(int type, GameMonitor monitor)
}
GameProcess ..> DisplayTouchInGame : HarmonyPostfix_OnUpdate
GameProcess --> GameMonitor : uses
DisplayTouchInGame --> GameMonitor : uses
DisplayTouchInGame --> GameObject : creates
GameObject --> Transform : has
Transform --> GameObject : returns
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - 我在这里给出了一些高层次的反馈:
CreateDisplay上方的注释仍然写着它只接受类型 1–3,并且类型 4/5 应该拆成两个调用,这已经和当前实现不一致了;建议更新这个注释,以准确描述新的行为和有效输入范围。- 在
OnGameProcessUpdate中,延迟调用的CreateDisplay只检查了displayType[i] > 0,但现在CreateDisplay会在 1–5 之外的取值时抛出异常;这里最好和OnGameStart中使用的范围检查保持一致,或者以其他方式防止无效类型传入。
给 AI Agent 的提示
Please address the comments from this code review:
## Overall Comments
- The comment above `CreateDisplay` still says it only accepts types 1–3 and that 4/5 should be split into two calls, which no longer matches the implementation; consider updating this comment to accurately describe the new behavior and valid input range.
- In `OnGameProcessUpdate`, the lazy `CreateDisplay` call only checks `displayType[i] > 0`, but `CreateDisplay` will now throw for values outside 1–5; it may be safer to mirror the same range check used in `OnGameStart` or otherwise guard against invalid types there.帮我变得更有用!请对每条评论点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English
Hey - I've left some high level feedback:
- The comment above
CreateDisplaystill says it only accepts types 1–3 and that 4/5 should be split into two calls, which no longer matches the implementation; consider updating this comment to accurately describe the new behavior and valid input range. - In
OnGameProcessUpdate, the lazyCreateDisplaycall only checksdisplayType[i] > 0, butCreateDisplaywill now throw for values outside 1–5; it may be safer to mirror the same range check used inOnGameStartor otherwise guard against invalid types there.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The comment above `CreateDisplay` still says it only accepts types 1–3 and that 4/5 should be split into two calls, which no longer matches the implementation; consider updating this comment to accurately describe the new behavior and valid input range.
- In `OnGameProcessUpdate`, the lazy `CreateDisplay` call only checks `displayType[i] > 0`, but `CreateDisplay` will now throw for values outside 1–5; it may be safer to mirror the same range check used in `OnGameStart` or otherwise guard against invalid types there.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request updates the DisplayTouchInGame utility to support dynamic display creation during game updates and refactors the CreateDisplay method to handle specific display types recursively. The review feedback suggests improving code readability by shortening a verbose comment and updating method documentation to accurately reflect the supported display types.
80f46e2 to
07f98a3
Compare
There was a problem hiding this comment.
2 issues found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="AquaMai.Mods/Utils/DisplayTouchInGame.cs">
<violation number="1" location="AquaMai.Mods/Utils/DisplayTouchInGame.cs:91">
P1: Guard the hot-create path when `prefab` is still null. Right now this new branch bypasses the existing `OnGameStart` null check and can throw when the toggle key is pressed before `RegisterMouseTouchPanel` has initialized the prefab.</violation>
<violation number="2" location="AquaMai.Mods/Utils/DisplayTouchInGame.cs:132">
P3: The comment `// type 只能传入 1 2 3,如果是 4 或 5 的话,拆分成两个 call` is now stale. Since the recursive handling of types 4 and 5 has been moved into `CreateDisplay` itself, this method now accepts 1–5 directly. Update the comment to reflect the current behavior.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
07f98a3 to
aadf425
Compare
之前版本代码中,
CreateDisplay创建组件,是仅在GameProcess Onstart的时候,根据DisplayType的值,调用一次的。导致如果游戏开始时玩家没有开启DisplayInTouch,那组件就不会被创建;游戏过程中按触发功能的按键,尽管
DisplayType调成了1,但由于没有组件,所以还是显示不出来。Summary by Sourcery
通过在功能被切换为开启时再创建显示器,而不是只在游戏开始时创建,确保游戏内触摸显示 UI 可以在游戏开始后动态启用。
Bug Fixes:
DisplayInTouch时不显示的问题,因为如果在游戏开始时被禁用,其 UI 组件从未被创建。Enhancements:
CreateDisplay帮助方法中得到一致的处理。Original summary in English
Summary by Sourcery
Ensure in-game touch display UI can be enabled dynamically after game start by creating the display when the feature is toggled on instead of only at game start.
Bug Fixes:
Enhancements: