Conversation
Summary of ChangesHello @WUGqnwvMQPzl, 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! 此拉取请求引入了一个新模组,允许用户在游戏标题画面播放自定义的视频和音频文件。通过替换默认的标题动画,它为玩家提供了更丰富的个性化选项,并旨在重现旧版本游戏中曾有的标题视频功能。该模组通过HarmonyLib对游戏广告流程进行修改,以实现视频和音频的无缝集成和管理。 Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
这个 PR 实现了一个很棒的功能,允许在标题画面播放自定义视频。代码结构清晰,并利用 Harmony 来修改游戏行为,实现了预期的效果。
在代码审查中,我发现了一些可以改进的地方,主要集中在并发处理、资源管理和代码健壮性方面。具体来说,存在一个关于视频准备状态的竞态条件,可能会导致不稳定的行为;还有一个小的内存泄漏问题,与动态创建的材质有关。此外,一些硬编码的值和口语化的注释也可以优化,以提高代码的可读性和可维护性。
请查看我提出的具体建议,这些修改将有助于提高这个功能的稳定性和代码质量。
|
|
||
| private static List<string>[] _disabledCompoments = [[], []]; | ||
|
|
||
| private static bool _isVideoPrepared = false; |
There was a problem hiding this comment.
_isVideoPrepared 是一个静态布尔值,但它被用于处理两个显示器上两个独立的异步视频准备操作。这会引发竞态条件。例如,如果一个视频准备成功(将 _isVideoPrepared 设为 true),而另一个失败(将其设为 false),最终状态将取决于哪个事件最后触发。这可能导致行为不一致,比如一个准备好的视频没有播放。
为了解决这个问题,建议不要使用单一的布尔值。可以考虑使用一个计数器来跟踪已准备好的视频数量,并用另一个布尔标志来表示是否发生了任何错误。
例如:
private static int _preparedVideoCount = 0;
private static volatile bool _videoHasError = false;然后在 OnStart 中重置它们,在 prepareCompleted 回调中使用 Interlocked.Increment 来增加计数器,在 errorReceived 回调中设置错误标志。最后,在 OnUpdate 中根据这两个变量的组合来决定逻辑。
|
|
||
| _videoPlayers[i].Prepare(); | ||
|
|
||
| var movieMaterial = new Material(Shader.Find("Sprites/Default")); |
| private static GameObject[] _movieObjects = new GameObject[2]; | ||
| private static VideoPlayer[] _videoPlayers = new VideoPlayer[2]; | ||
|
|
||
| private static List<string>[] _disabledCompoments = [[], []]; |
| { | ||
| case AdvertiseProcess.AdvertiseSequence.Logo: | ||
| // Re-enable original title screen elements if the video is unavailable | ||
| // yeah calling it early so the switch is unnoticeable |
| { | ||
| for (int i = 0; i < ____monitors.Length; ++i) | ||
| { | ||
| // Stop yelling "maimai deluxe" I'm tired to hearing it |
| { | ||
| // Stop and unloads title music | ||
| SoundManager.StopMusic(); | ||
| Singleton<SoundCtrl>.Instance.UnloadCueSheet(1); |
| _videoPlayers[i].prepareCompleted -= null; | ||
| _videoPlayers[i].errorReceived -= null; |
| // So uhh... When I was testing the feature, this method makes title screen suddently go black before transition | ||
| // I don't like the sudden cutout so I disabled it, not sure about the side effect or compatibility though |
There was a problem hiding this comment.
No description provided.