Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

让trackNumber可以显示2位数字 #34

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ck2739046
Copy link
Contributor

@ck2739046 ck2739046 commented Feb 13, 2025

Sourcery 总结

新功能:

  • 以两位数显示音轨编号,允许显示大于 9 的数字。
Original summary in English

Summary by Sourcery

New Features:

  • Display the track number with two digits, allowing for numbers greater than 9 to be shown.

Copy link

sourcery-ai bot commented Feb 13, 2025

## Sourcery 评审者指南

此 Pull Request 引入了一个新的类,该类修改了 UI 中轨道编号的显示方式,以支持两位数,并可选择使用零前缀。该实现使用 Harmony 补丁来拦截 CommonMonitor.SetTrackCount 方法,其中包含一个用于初始化自定义扩展精灵的后缀补丁和一个用于根据当前和最大轨道编号调整 UI 组件(文本格式、缩放和定位)的前缀补丁。

_由于更改看起来很简单,不需要可视化表示,因此未生成图表。_

### 文件级别更改

| 变更 | 详情 | 文件 |
| ------ | ------- | ----- |
| 引入了用于两位数轨道编号显示的自定义精灵生成 | <ul><li>创建了一个 HarmonyPostfix 补丁,通过读取原始纹理、扩展其宽度并复制一个部分来填充间隙,从而初始化自定义精灵。</li><li>利用 RenderTexture 和 Texture2D 创建原始精灵的可读副本,并生成具有额外像素的新纹理,以适应两位数。</li><li>配置了一个新的精灵数组,其尺寸已更改,稍后将在设置 UI 精灵时使用。</li></ul> | `AquaMai.Mods/Fix/FixTrackNumDisplay.cs` |
| 调整了 UI 布局和文本格式以支持两位数 | <ul><li>实现了一个 HarmonyPrefix 补丁,该补丁拦截原始方法以在最大轨道编号至少为 10 时覆盖轨道编号显示。</li><li>修改了 RectTransform 大小,并调整了文本元素的位置、缩放和格式,以正确显示两位数。</li><li>添加了条件逻辑,以根据配置条目应用零前缀或空格作为填充。</li><li>确保轨道计数 UI 反映新的自定义精灵和颜色设置,同时保留错误处理,以便在必要时回退到原始行为。</li></ul> | `AquaMai.Mods/Fix/FixTrackNumDisplay.cs` |
| 集成了零填充的配置 | <ul><li>引入了一个配置条目,用于切换使用零前缀或空格填充来显示数字。</li></ul> | `AquaMai.Mods/Fix/FixTrackNumDisplay.cs` |

---

<details>
<summary>提示和命令</summary>

#### 与 Sourcery 互动

- **触发新的审查:** 在 pull request 上评论 `@sourcery-ai review`。
- **继续讨论:** 直接回复 Sourcery 的审查评论。
- **从审查评论生成 GitHub issue:** 通过回复审查评论,要求 Sourcery 从审查评论创建一个 issue。您也可以回复审查评论并使用 `@sourcery-ai issue` 从中创建一个 issue。
- **生成 pull request 标题:** 在 pull request 标题中的任何位置写入 `@sourcery-ai` 以随时生成标题。您也可以在 pull request 上评论 `@sourcery-ai title` 以随时(重新)生成标题。
- **生成 pull request 摘要:** 在 pull request 正文中的任何位置写入 `@sourcery-ai summary` 以随时在您想要的位置生成 PR 摘要。您也可以在 pull request 上评论 `@sourcery-ai summary` 以随时(重新)生成摘要。
- **生成评审者指南:** 在 pull request 上评论 `@sourcery-ai guide` 以随时(重新)生成评审者指南。
- **解决所有 Sourcery 评论:** 在 pull request 上评论 `@sourcery-ai resolve` 以解决所有 Sourcery 评论。如果您已经解决了所有评论并且不想再看到它们,这将非常有用。
- **驳回所有 Sourcery 审查:** 在 pull request 上评论 `@sourcery-ai dismiss` 以驳回所有现有的 Sourcery 审查。如果您想重新开始新的审查,这将特别有用 - 不要忘记评论 `@sourcery-ai review` 以触发新的审查!
- **为 issue 生成行动计划:** 在 issue 上评论 `@sourcery-ai plan` 以为其生成行动计划。

#### 自定义您的体验

访问您的 [仪表板](https://app.sourcery.ai) 以:
- 启用或禁用审查功能,例如 Sourcery 生成的 pull request 摘要、评审者指南等。
- 更改审查语言。
- 添加、删除或编辑自定义审查说明。
- 调整其他审查设置。

#### 获取帮助

- [联系我们的支持团队](mailto:[email protected]) 提出问题或反馈。
- 访问我们的 [文档](https://docs.sourcery.ai) 获取详细的指南和信息。
- 通过在 [X/Twitter](https://x.com/SourceryAI)、[LinkedIn](https://www.linkedin.com/company/sourcery-ai/) 或 [GitHub](https://github.com/sourcery-ai) 上关注我们,与 Sourcery 团队保持联系。

</details>
Original review guide in English

Reviewer's Guide by Sourcery

This pull request introduces a new class that modifies the display of track numbers in the UI to support two digits, optionally using a zero prefix. The implementation uses Harmony patches to intercept the CommonMonitor.SetTrackCount method, with a postfix patch for initializing custom extended sprites and a prefix patch for adjusting the UI components (text formatting, scaling, and positioning) based on the current and max track numbers.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Introduced custom sprite generation for two-digit track number display
  • Created a HarmonyPostfix patch to initialize custom sprites by reading the original texture, extending its width, and replicating a section to fill the gap.
  • Utilized RenderTexture and Texture2D to make a readable copy of the original sprite and to generate new textures with extra pixels for accommodating two-digit numbers.
  • Configured a new sprite array with altered dimensions that will be used later when setting the UI sprite.
AquaMai.Mods/Fix/FixTrackNumDisplay.cs
Adjusted UI layout and text formatting to support two-digit numbers
  • Implemented a HarmonyPrefix patch that intercepts the original method to override track number display when the maximum track number is at least 10.
  • Modified the RectTransform size and adjusted the position, scale, and formatting of the text elements to properly display two digits.
  • Added conditional logic to apply either a zero prefix or an empty space as padding based on a configuration entry.
  • Ensured the track count UI reflects the new custom sprite and color settings while retaining error handling to fall back on the original behavior if necessary.
AquaMai.Mods/Fix/FixTrackNumDisplay.cs
Integrated configuration for zero padding
  • Introduced a configuration entry to toggle between using a zero prefix or space padding for the displayed numbers.
AquaMai.Mods/Fix/FixTrackNumDisplay.cs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

@ck2739046 - 我已经审查了你的更改 - 这里有一些反馈:

总体评论

  • 考虑将创建 newTex 的逻辑提取到一个单独的方法中,以提高可读性。
  • 使用字符串格式化进行填充可能更简洁,而不是 PadLeft,因为它直接传达了意图。
以下是我在审查期间查看的内容
  • 🟢 一般问题:一切看起来都很好
  • 🟢 安全性:一切看起来都很好
  • 🟢 测试:一切看起来都很好
  • 🟢 复杂性:一切看起来都很好
  • 🟢 文档:一切看起来都很好

Sourcery 对开源是免费的 - 如果你喜欢我们的评论,请考虑分享它们 ✨
帮助我更有用!请点击每个评论上的 👍 或 👎,我将使用反馈来改进你的评论。
Original comment in English

Hey @ck2739046 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider extracting the logic for creating newTex into a separate method to improve readability.
  • It might be cleaner to use string formatting for padding instead of PadLeft, as it directly conveys the intent.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Becods
Copy link
Contributor

Becods commented Feb 15, 2025

没有必要patch这么多

直接使用CommonMonitor中的_trackFreedomCountText即可

@ck2739046
Copy link
Contributor Author

没有必要patch这么多

直接使用CommonMonitor中的_trackFreedomCountText即可

请赐教

@Becods
Copy link
Contributor

Becods commented Feb 21, 2025

没有必要patch这么多
直接使用CommonMonitor中的_trackFreedomCountText即可

请赐教

diff --git a/Assembly-CSharp/Monitor/CommonMonitor.cs b/Assembly-CSharp/Monitor/CommonMonitor.cs
index 4362086..c94bac3 100644
--- a/Assembly-CSharp/Monitor/CommonMonitor.cs
+++ b/Assembly-CSharp/Monitor/CommonMonitor.cs
@@ -203,7 +203,7 @@ public void SetTrackCountVisible(bool active)
 	public void SetTrackCount(uint currentTrackNum, uint maxTrackNum)
 	{
 		TrackColor trackColor = TrackColor.Blue;
-		if (!GameManager.IsFreedomMode)
+		if (!GameManager.IsFreedomMode && !Singleton<SystemConfig>.Instance.config.IsInfiniteTrack)
 		{
 			_trackMaskImage.SetActive(value: false);
 			_trackCountText.ChangeText(currentTrackNum.ToString());

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