Skip to content

[Feature] 将服务器积分榜自动转换为Overlay窗口#112

Open
Wind-DeterMination-backup wants to merge 3 commits intoTinyLake:mainfrom
Wind-DeterMination-backup:broad-overlay
Open

[Feature] 将服务器积分榜自动转换为Overlay窗口#112
Wind-DeterMination-backup wants to merge 3 commits intoTinyLake:mainfrom
Wind-DeterMination-backup:broad-overlay

Conversation

@Wind-DeterMination-backup

背景

改动内容

  • 新增 BroadOverlay 组件,专门识别并承载带保留前缀的服务器积分榜消息。
  • Hooks.onHandleSendMessage 的服务端消息分支里优先拦截该前缀;命中后不再继续走默认聊天显示,避免前缀污染聊天框。
  • 将去前缀后的正文同步写入一个新的 OverlayUI 窗口 broadOverlay
  • 窗口首屏会在第一次收到积分榜时自动启用并固定,保证用户无需手动打开 Overlay 编辑模式就能直接看到结果。
  • 同时把处理后的正文保留到 ARC 中央监控室里,避免消息只出现在 overlay 后无法追溯历史记录。
  • 为新的 overlay 窗口补充了中英文 bundle 名称和描述。

技术细节

  • 新增文件:src/mindustryX/features/ui/BroadOverlay.kt
  • 注册点:UIExtKt.init() 中初始化并注册新的 Overlay 窗口。
  • 拦截点:Hooks.onHandleSendMessage()
    • 仅在 sender == null 的服务器消息分支处理。
    • 识别前缀后直接返回 null,从而跳过 Vars.ui.chatfrag.addMessage(message) 的默认路径。
  • 状态管理:
    • BroadOverlay 内部维护最近一次积分榜正文和更新时间。
    • ResetEvent / WorldLoadEvent 时清空内容,避免跨地图/跨服务器残留旧榜单。
    • overlay 可见性依赖 Vars.state.isGame && hasContent(),没有内容时不会占据 HUD。
  • UI 实现:
    • 使用 ScrollPane + labelWrap 承载多行排行榜文本,保留颜色标记。
    • 默认给出可读的初始尺寸,并允许用户后续手动缩放/调整位置。
    • 提供复制按钮,复制时会去除颜色和 glyph,方便导出纯文本。

行为说明

  • 命中特殊前缀的消息:
    • 会显示在新的 overlay 窗口中。
    • 会记录到 ARC 中央监控室。
    • 不会再把原始带前缀文本显示到聊天框。
  • 非命中的普通服务器消息与玩家消息:保持原有行为不变。

验证

  • work/ 下执行:./gradlew.bat core:compileJava --no-daemon
  • 编译通过。

@gemini-code-assist
Copy link

Summary of Changes

Hello, 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!

此拉取请求旨在通过引入一个新的Overlay窗口来优化服务器积分榜消息的显示方式。它能够自动识别并拦截带有特定前缀的积分榜消息,将其从聊天框中移除,转而在一个独立的、可调整大小和位置的Overlay窗口中清晰展示。这一改进显著提升了长文本消息的可读性,避免了聊天界面的混乱,并确保了重要信息的存档,为用户提供了更整洁、更高效的信息获取体验。

Highlights

  • 新增BroadOverlay组件: 引入了一个新的BroadOverlay组件,专门用于识别和承载带有特定保留前缀的服务器积分榜消息。
  • 消息拦截与处理: 在Hooks.onHandleSendMessage的服务端消息分支中,优先拦截带有[#FEBBEF][]前缀的消息,并阻止其显示在聊天框中,避免前缀污染和长文本可读性差的问题。
  • Overlay窗口显示: 将去除前缀后的积分榜正文显示在一个新的OverlayUI窗口broadOverlay中。该窗口在第一次收到积分榜消息时会自动启用并固定,用户无需手动操作即可查看。
  • 消息历史记录: 处理后的正文会保留到ARC中央监控室,确保消息即使只显示在Overlay中也能追溯历史记录。
  • 多语言支持: 为新的Overlay窗口补充了中英文的bundle名称和描述,提升用户体验。

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • assets/bundles/bundle-mdtx.properties
    • 新增了服务器积分榜Overlay窗口的中文名称和描述的本地化键值。
  • assets/bundles/bundle-mdtx_en.properties
    • 新增了服务器积分榜Overlay窗口的英文名称和描述的本地化键值。
  • src/mindustryX/Hooks.java
    • 导入了BroadOverlay类。
    • 修改了onHandleSendMessage方法,增加了对特定服务器消息前缀的拦截逻辑,并调用BroadOverlay.tryHandle进行处理。
  • src/mindustryX/features/UIExtKt.kt
    • init()方法中调用BroadOverlay.init(),注册并初始化新的Overlay窗口。
  • src/mindustryX/features/ui/BroadOverlay.kt
    • 新增了BroadOverlay对象,负责处理服务器积分榜消息的解析、状态管理和UI逻辑。
    • 新增了BroadOverlayTable类,定义了Overlay窗口的UI布局,包括标题、更新时间、内容显示(带滚动条和文本换行)以及复制按钮。
Activity
  • 此拉取请求目前没有外部评论或审查活动。
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 新增了服务器积分榜的悬浮窗(Overlay)显示功能,能有效识别并处理带特定前缀的服务器消息,避免了聊天框污染,并提升了信息的可读性,这是一个很好的功能改进。代码实现整体清晰,逻辑明确。我发现一处可以优化性能的地方:在 BroadOverlay.kt 中,更新时间的显示可以在每次渲染时避免不必要的对象创建和格式化。具体的修改建议请见我的评论。

@way-zer
Copy link
Member

way-zer commented Mar 14, 2026

暂缓,等上游发版 Anuken@d15da6e

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