Skip to content

等待战斗结束时的截图操作不强制移动鼠标 - #554

Open
JoshCai233 wants to merge 4 commits into
OneDragon-Anything:mainfrom
JoshCai233:dont_move_mouse_in_battle
Open

等待战斗结束时的截图操作不强制移动鼠标#554
JoshCai233 wants to merge 4 commits into
OneDragon-Anything:mainfrom
JoshCai233:dont_move_mouse_in_battle

Conversation

@JoshCai233

@JoshCai233 JoshCai233 commented Dec 7, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • 新功能

    • 新增“截图前移动鼠标”设置开关,可在基础设置中进行配置。
    • 截图时支持保持鼠标当前位置,减少截图过程中的鼠标干扰。
  • 体验优化

    • 等待战斗结果时将避免自动移动鼠标,并优化截图前的处理流程。

@coderabbitai

coderabbitai Bot commented Dec 7, 2025

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3c336d23-98be-4371-8d0e-81f0d0b1053c

📥 Commits

Reviewing files that changed from the base of the PR and between 3f62c3f and 0ddd5bb.

📒 Files selected for processing (3)
  • src/one_dragon_qt/view/setting/setting_env_interface.py
  • src/sr_od/config/game_config.py
  • src/sr_od/gui/interface/setting/sr_setting_game_interface.py
💤 Files with no reviewable changes (1)
  • src/one_dragon_qt/view/setting/setting_env_interface.py

Walkthrough

截图接口新增控制截图前是否移动鼠标的参数,战斗等待流程使用该参数,并在游戏设置中增加对应的持久化开关。

Changes

截图鼠标控制

Layer / File(s) Summary
截图参数透传
src/one_dragon/base/controller/controller_base.py, src/one_dragon/base/operation/operation.py, src/sr_od/context/sr_pc_controller.py, src/sr_od/challenge_mission/use_trailblaze_power.py, src/sr_od/operations/battle/wait_battle_result.py
screenshotbefore_screenshot 新增 dont_move_mouse 参数,操作层继续维护截图缓存;战斗结果等待流程禁用截图前鼠标移动。
截图鼠标配置
src/sr_od/config/game_config.py, src/one_dragon_qt/view/setting/setting_env_interface.py, src/sr_od/gui/interface/setting/sr_setting_game_interface.py
GameConfig 新增默认值为 True 的配置属性,基础设置界面新增开关并绑定该属性。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: shadowlemoon

Poem

小兔挥耳看新屏,
鼠标悄悄不乱行。
开关一拨配置好,
截图清清留光影。
咕噜一跳庆改成!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 52.63% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了等待战斗结束时截图不再强制移动鼠标这一主要变化。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/sr_od/challenge_mission/use_trailblaze_power.py (1)

1-1: 等待战斗结果节点改动合理,顺便建议清理无用的 screen 导入

  • _wait_battle_result 上把 screenshot_before_round=False 与内部 self.screenshot(dont_move_mouse=True) 搭配使用,语义和 EchoOfWar / WaitBattleResult 中的等待节点保持一致,避免了重复截图和强制移动鼠标,符合预期。
  • 顶部 from PIL.ImageChops import screen 未被使用,并且与函数内的局部变量 screen 同名,Ruff 报 F811(“Redefinition of unused screen”);建议直接删除该导入,既消除告警也减少读者困惑。

可以按如下方式调整 import 部分:

-from PIL.ImageChops import screen
-from typing import Optional, Callable, ClassVar
+from typing import Optional, Callable, ClassVar

Also applies to: 180-202

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b55bee and 9e9fa51.

📒 Files selected for processing (6)
  • src/one_dragon/base/controller/controller_base.py (2 hunks)
  • src/one_dragon/base/operation/operation.py (2 hunks)
  • src/sr_od/app/echo_of_war/challenge_ehco_of_war.py (1 hunks)
  • src/sr_od/challenge_mission/use_trailblaze_power.py (1 hunks)
  • src/sr_od/context/sr_pc_controller.py (1 hunks)
  • src/sr_od/operations/battle/wait_battle_result.py (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-13T12:07:30.874Z
Learnt from: JoshCai233
Repo: OneDragon-Anything/StarRailOneDragon PR: 521
File: src/sr_od/app/sim_uni/sim_uni_app.py:61-87
Timestamp: 2025-10-13T12:07:30.874Z
Learning: 在 `_check_points_reward()` 中,`OperationRoundResult` 的语义与常规不同:`FAIL` 表示"奖励未完成,需要继续执行自动化",而 `SUCCESS` 和 `RETRY` 表示"提前返回,跳过自动化"。这是因为调用方使用 `if result != FAIL: return` 来判断是否跳过后续的自动化脚本执行。

Applied to files:

  • src/sr_od/app/echo_of_war/challenge_ehco_of_war.py
  • src/sr_od/challenge_mission/use_trailblaze_power.py
🧬 Code graph analysis (4)
src/sr_od/context/sr_pc_controller.py (2)
src/one_dragon/base/controller/controller_base.py (1)
  • before_screenshot (75-79)
src/one_dragon/base/controller/pc_controller_base.py (1)
  • mouse_move (204-210)
src/one_dragon/base/controller/controller_base.py (2)
src/one_dragon/base/operation/operation.py (1)
  • screenshot (624-634)
src/sr_od/context/sr_pc_controller.py (1)
  • before_screenshot (43-45)
src/sr_od/challenge_mission/use_trailblaze_power.py (3)
src/one_dragon/base/operation/operation_node.py (1)
  • operation_node (72-100)
src/one_dragon/base/operation/operation.py (2)
  • name (44-48)
  • screenshot (624-634)
src/sr_od/app/echo_of_war/challenge_ehco_of_war.py (1)
  • _wait_battle_result (150-168)
src/one_dragon/base/operation/operation.py (1)
src/one_dragon/base/controller/controller_base.py (1)
  • screenshot (53-73)
🪛 Ruff (0.14.7)
src/sr_od/challenge_mission/use_trailblaze_power.py

186-186: Redefinition of unused screen from line 1

(F811)

🔇 Additional comments (5)
src/one_dragon/base/operation/operation.py (1)

624-634: Operation.screenshot 扩展参数设计合理

这里增加 dont_move_mouse 并通过关键字透传到 ctx.controller.screenshot,对现有仅位置参数调用是向后兼容的;上层等待战斗结果节点用 dont_move_mouse=True 也能正确生效。后续如再新增调用点,建议也统一用关键字参数,避免误把其他布尔值位置上传给 dont_move_mouse

src/sr_od/app/echo_of_war/challenge_ehco_of_war.py (1)

149-150: 等待战斗结果节点的截图行为调整是合理的

screenshot_before_round=False 配合节点内部的 self.screenshot(dont_move_mouse=True),避免了每轮自动多截一张图,也避免在战斗结算期间强行移动鼠标;对 battle_screen_state.get_tp_battle_screen_state 的逻辑没有改变,只是截图时机和鼠标行为更可控,符合“等待战斗结束时不强制移动鼠标”的需求。

Also applies to: 155-168

src/sr_od/operations/battle/wait_battle_result.py (1)

17-20: WaitBattleResult 的截图策略与其他等待节点保持一致

wait 节点现在禁用了自动轮前截图,改为在函数内部调用 self.screenshot(dont_move_mouse=True),和其他等待战斗结果的节点风格统一,同时避免在长时间等待期间反复移动鼠标。try_attack 分支仍然在识别到大世界画面后主动操作,与本次改动没有冲突。

src/sr_od/context/sr_pc_controller.py (1)

43-46: before_screenshot 的新参数实现与基类对齐

这里的实现很好地利用了新加的 dont_move_mouse:默认仍然把鼠标移动到 fill_uid_black 遮挡区域,保持旧行为不变;在需要时(如等待战斗结果)可以通过 dont_move_mouse=True 完全跳过鼠标移动。与基类签名一致,便于后续扩展其它平台控制器时复用这一约定。

src/one_dragon/base/controller/controller_base.py (1)

53-57: Verify all subclass overrides of before_screenshot have the updated signature

The screenshot method now passes dont_move_mouse as a keyword argument to before_screenshot. Any subclass that overrides before_screenshot without accepting this parameter will raise TypeError at runtime. Ensure all implementations include def before_screenshot(self, dont_move_mouse: bool = False) or compatible signature.

@DoctorReid DoctorReid left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个改动的主要目的是?

@JoshCai233

Copy link
Copy Markdown
Contributor Author

这个改动的主要目的是?

在等待副本自动战斗结束时,游戏不需要操作鼠标,脚本只需要检测战斗结束标志即可,但是鼠标会每秒一次地移动到崩铁的左下角,用户需要按下脚本暂停键才能使用鼠标的正常功能

  1. 使用场景:
  • 想远程桌面挂其他脚本、本地桌面挂崩铁的同时使用电脑的副屏刷视频时、或者临时回复消息时
  • 使用pycharm等工具调试脚本打副本相关内容时
  1. 等待战斗结束时不移动鼠标的可行性:
  • 点击开始挑战、确认弹框或者平a进入战斗时鼠标不会出现在屏幕上半部分,而结尾的挑战成功字样出现在屏幕上半部分,等待战斗结束时不动鼠标并不会影响识别挑战结果
  • 如果用户动了鼠标导致识别挑战结果不成功,用户也能把鼠标动回去

@Usagi-wusaqi

Usagi-wusaqi commented Dec 20, 2025

Copy link
Copy Markdown
Contributor

这个改动的主要目的是?

在等待副本自动战斗结束时,游戏不需要操作鼠标,脚本只需要检测战斗结束标志即可,但是鼠标会每秒一次地移动到崩铁的左下角,用户需要按下脚本暂停键才能使用鼠标的正常功能

  1. 使用场景:
  • 想远程桌面挂其他脚本、本地桌面挂崩铁的同时使用电脑的副屏刷视频时、或者临时回复消息时
  • 使用pycharm等工具调试脚本打副本相关内容时
  1. 等待战斗结束时不移动鼠标的可行性:
  • 点击开始挑战、确认弹框或者平a进入战斗时鼠标不会出现在屏幕上半部分,而结尾的挑战成功字样出现在屏幕上半部分,等待战斗结束时不动鼠标并不会影响识别挑战结果
  • 如果用户动了鼠标导致识别挑战结果不成功,用户也能把鼠标动回去

额,我还想着绝龙也强制抢鼠标,防止用户在运行时非法临时修改一条龙配置呢,跟隔壁原神一样

@JoshCai233

Copy link
Copy Markdown
Contributor Author

额,我还想着绝龙也强制抢鼠标,防止用户在运行时非法临时修改一条龙配置呢,跟隔壁原神一样

  1. bettergi是窗口焦点离开原神就暂停,而且原神需要一直操作鼠标,但是崩铁不用啊
  2. 想变打边改配置可以按暂停改配置,防不住的

@ShadowLemoon

Copy link
Copy Markdown
Collaborator

可以不动框架实现吗

@JoshCai233

Copy link
Copy Markdown
Contributor Author

可以不动框架实现吗

那就得把 sr_pc_controller.py 中的 before_screenshot 函数直接干掉

@JoshCai233

Copy link
Copy Markdown
Contributor Author

或者说可以识别崩铁在后台时不移动鼠标,这样就不会影响框架

@ShadowLemoon

ShadowLemoon commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

before_screenshot 在zzz好像没有。看看能不能根据截图方式取消移动?后台的话原本的截图方式都没法截到东西,所以根本没考虑。现在printwindow可以后台截图 而且不会截到鼠标 所以应该不需要

@JoshCai233

Copy link
Copy Markdown
Contributor Author

那感觉可以加一个截图时是否移动鼠标的配置项

@ShadowLemoon

Copy link
Copy Markdown
Collaborator

可以在printwindow方法直接不移(自动也是printwindow优先)

那感觉可以加一个截图时是否移动鼠标的配置项

@ShadowLemoon

Copy link
Copy Markdown
Collaborator

sr_pc_controller.py 中的 before_screenshot 函数加个可选项呗

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/one_dragon_qt/view/setting/setting_env_interface.py`:
- Around line 71-72: 将 move_mouse_before_screenshot_opt 的 init_with_adapter 调用从
_init_basic_group() 移至 on_interface_shown(),确保界面每次显示时重新加载最新配置,并保持现有设置卡片注册逻辑不变。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f5d17b9e-2dc2-4cac-b14f-fa4bf2c36893

📥 Commits

Reviewing files that changed from the base of the PR and between 9e9fa51 and 3f62c3f.

📒 Files selected for processing (4)
  • src/one_dragon/base/controller/controller_base.py
  • src/one_dragon/base/operation/operation.py
  • src/one_dragon/envs/env_config.py
  • src/one_dragon_qt/view/setting/setting_env_interface.py

Comment thread src/one_dragon_qt/view/setting/setting_env_interface.py Outdated
@ShadowLemoon

Copy link
Copy Markdown
Collaborator

env_config是框架里的,放game_config吧

@JoshCai233

Copy link
Copy Markdown
Contributor Author

env_config是框架里的,放game_config吧

截图方式也是在env_config里面的

@ShadowLemoon

Copy link
Copy Markdown
Collaborator

主要是env是框架共用的

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.

4 participants