等待战斗结束时的截图操作不强制移动鼠标 - #554
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
Walkthrough截图接口新增控制截图前是否移动鼠标的参数,战斗等待流程使用该参数,并在游戏设置中增加对应的持久化开关。 Changes截图鼠标控制
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 unusedscreen”);建议直接删除该导入,既消除告警也减少读者困惑。可以按如下方式调整 import 部分:
-from PIL.ImageChops import screen -from typing import Optional, Callable, ClassVar +from typing import Optional, Callable, ClassVarAlso applies to: 180-202
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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.pysrc/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 ofbefore_screenshothave the updated signatureThe
screenshotmethod now passesdont_move_mouseas a keyword argument tobefore_screenshot. Any subclass that overridesbefore_screenshotwithout accepting this parameter will raiseTypeErrorat runtime. Ensure all implementations includedef before_screenshot(self, dont_move_mouse: bool = False)or compatible signature.
在等待副本自动战斗结束时,游戏不需要操作鼠标,脚本只需要检测战斗结束标志即可,但是鼠标会每秒一次地移动到崩铁的左下角,用户需要按下脚本暂停键才能使用鼠标的正常功能
|
额,我还想着绝龙也强制抢鼠标,防止用户在运行时非法临时修改一条龙配置呢,跟隔壁原神一样 |
|
|
可以不动框架实现吗 |
那就得把 |
|
或者说可以识别崩铁在后台时不移动鼠标,这样就不会影响框架 |
|
before_screenshot 在zzz好像没有。看看能不能根据截图方式取消移动?后台的话原本的截图方式都没法截到东西,所以根本没考虑。现在printwindow可以后台截图 而且不会截到鼠标 所以应该不需要 |
|
那感觉可以加一个截图时是否移动鼠标的配置项 |
|
可以在printwindow方法直接不移(自动也是printwindow优先)
|
|
sr_pc_controller.py 中的 before_screenshot 函数加个可选项呗 |
There was a problem hiding this comment.
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
📒 Files selected for processing (4)
src/one_dragon/base/controller/controller_base.pysrc/one_dragon/base/operation/operation.pysrc/one_dragon/envs/env_config.pysrc/one_dragon_qt/view/setting/setting_env_interface.py
|
env_config是框架里的,放game_config吧 |
截图方式也是在env_config里面的 |
|
主要是env是框架共用的 |
Summary by CodeRabbit
新功能
体验优化