Skip to content

feat: add respack export and drag & drag+flick judgment protection - #883

Closed
SeRazon wants to merge 5 commits into
TeamFlos:mainfrom
SeRazon:main
Closed

feat: add respack export and drag & drag+flick judgment protection#883
SeRazon wants to merge 5 commits into
TeamFlos:mainfrom
SeRazon:main

Conversation

@SeRazon

@SeRazon SeRazon commented Aug 26, 2026

Copy link
Copy Markdown

概述

本 PR 包含两个独立功能:

  1. 资源包导出:为非默认皮肤资源包增加导出功能,导出格式与导入格式完全一致(zip 压缩包)
  2. Drag/Flick 判定保护:参考官方 Phigros 判定机制,增加黄键/红键早按保护,避免误触后续蓝键

1. 资源包导出功能

实现内容

  • 在资源包列表的信息按钮左侧新增导出按钮(仅非默认资源包显示)
  • 导出格式与导入格式完全一致:使用 compress_folder 将资源包目录压缩为 zip
  • 导出流程复用谱面导出的 request_export / resolve_export / take_export 机制,支持系统文件选择器
  • 导出文件名自动清理非法字符(/ \ : * ? " < > |_

按钮位置

导出按钮位于信息按钮左侧,与信息、删除按钮保持相同间距和样式:

respack export button

改动文件

  • phira/src/page/respack.rs:导出逻辑、按钮渲染、文件名清理
  • phira/src/icons.rs:注册导出图标
  • assets/export.png:导出图标资源

2. Drag/Flick 判定保护

实现内容

参考 关于Phigros判定 中描述的官方判定机制,增加早按保护:

  • 当 Drag/Flick 已经过判定线但尚未被判定时,保护后续的 Click/Hold 不被早按误触
  • 保护触发条件:Drag/Flick 比 Click/Hold 更靠近判定线至少 0.01 秒(官方阈值)
  • 实现方式:在 closest 匹配阶段,将被保护的 Click/Hold 的匹配权重设为 INFINITY,使其不会被选中
  • 仅保护 early 侧(尚未到达判定线)的 Click/Hold,late 侧不受影响

判定逻辑示意

judgment protection logic 1 judgment protection logic 2

改动文件

  • prpr/src/judge.rs:新增 PROTECTION_THRESHOLD 常量、保护时间预处理、匹配阶段权重调整

测试情况

  • 编译通过(cargo build --release
  • 资源包导入功能正常(未受影响)
  • 资源包导出功能正常,导出的 zip 可重新导入
  • 默认资源包不显示导出按钮
  • 普通单键/多押判定正常(未受保护影响)
  • Drag/Flick 早按保护生效,不会误触后续蓝键
  • cargo fmt --all --check 通过

Copilot AI lite review requested due to automatic review settings August 26, 2026 22:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an export feature for non-default resource packs, wiring a new export button into the respack page UI and adding an export icon to the shared icon set.

Changes:

  • Add an “export respack” button to the resource pack page (non-default packs only) and export the pack folder as a .zip.
  • Add a filename sanitization helper for suggested export filenames.
  • Add a new export.png icon entry to the global Icons loader.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
phira/src/page/respack.rs Adds export button + background zip export task handling for respacks
phira/src/icons.rs Adds export icon texture field and loads export.png
Suppressed comments (2)

phira/src/page/respack.rs:159

  • Initialize the new pending_export_path field so the export target is well-defined before any export dialog callback returns.
            info_btn: delete_btn.clone(),
            export_btn: delete_btn.clone(),
            delete_btn,
            export_task: None,

phira/src/page/respack.rs:260

  • take_export() can return long after request_export(...) (Android/iOS), but this code uses self.items[self.index] at callback time and unwraps path. If the user switches selection (or the current item has path == None), this can export the wrong pack or panic. Also, on export failure the partially-created file/URI is never cleaned up (ExportConfig.deleter). Use the stored pending_export_path from click time and call deleter on errors (similar to LibraryPage).
        if let Some(config) = take_export() {
            match config {
                Ok(config) => {
                    let path = self.items[self.index].path.clone().unwrap();
                    let (tx, rx) = mpsc::channel();

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread phira/src/page/respack.rs Outdated
Comment thread phira/src/page/respack.rs
When a drag/flick note has passed the judge line but is not yet judged,
protect upcoming click/hold notes from being triggered by early taps.
This matches official Phigros behavior where tapping early near a yellow
or red note prioritizes that note over a later blue note.

Protection triggers when:
- The drag/flick is on the late side (time < current time) and NotJudged
- The click/hold is on the early side (time > current time)
- The drag/flick is at least 0.01s closer to the judge line than the click/hold
@SeRazon SeRazon changed the title feat: add respack export function feat: add respack export and drag & drag+flick judgment protection Aug 29, 2026
@SeRazon

SeRazon commented Aug 29, 2026

Copy link
Copy Markdown
Author

#886
#887

@SeRazon SeRazon closed this Aug 29, 2026
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