from __future__ import annotations import tkinter as tk from .data import DashboardData, cfg_get from .page_context import PageContext from .page_helpers import pack_fields, pack_switches from .widgets import card, section def build_debug_settings(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None: section(parent, "调试参数", "识别阈值 / OCR 开关 / 像素检测 / 坐标") _debug_images(parent, data, ctx) _fudai_find(parent, data, ctx) _ocr_and_pixel(parent, data, ctx) _diagnostics(parent, data, ctx) def _debug_images(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None: box = card(parent, "调试图像") box.pack(fill="x", pady=(0, 12)) pack_switches(box, ctx, [ ("全局调试图像(OCR / 像素 / 模板等)", "debug_captures_enabled_var", False), ("启用自动清理调试图像", "debug_captures_auto_cleanup_var", True), ("异步保存调试图像(默认启用)", "debug_captures_async_save_var", True), ("保存完成后记录日志(显示路径)", "debug_captures_log_on_complete_var", False), ], columns=2) pack_fields(box, ctx, [ ("保留天数", "debug_captures_keep_days_var", cfg_get(data.cfg, "debug_captures", "keep_days")), ("最大文件数量", "debug_captures_max_files_var", cfg_get(data.cfg, "debug_captures", "max_files")), ]) def _fudai_find(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None: box = card(parent, "找福袋参数") box.pack(fill="x", pady=(0, 12)) pack_switches(box, ctx, [ ("禁用福袋内容OCR识别", "fudai_disable_content_recognition_var", False), ("禁用福袋任务列表OCR识别", "fudai_disable_task_recognition_var", False), ("保存福袋详情综合标注图", "fudai_detail_save_debug_images_var", False), ("启用坐标调整(默认关闭,避免滚轮误触)", "region_coords_edit_enabled_var", False), ], columns=2) pack_fields(box, ctx, [ ("找福袋最大尝试次数", "fudai_find_max_attempts_var", cfg_get(data.cfg, "fudai_find_max_attempts")), ("找福袋重试间隔(秒)", "fudai_icon_retry_delay_seconds_var", cfg_get(data.cfg, "fudai_icon_retry_delay_seconds")), ("最大等待时间(秒)", "fudai_icon_max_wait_seconds_var", cfg_get(data.cfg, "fudai_icon_max_wait_seconds")), ("点击福袋后等待时间(秒)", "fudai_click_wait_seconds_var", cfg_get(data.cfg, "fudai_click_wait_seconds")), ("福袋详情页UI版本", "fudai_detail_ui_mode_var", cfg_get(data.cfg, "fudai_detail_ui_mode")), ("切换直播间后等待时间(秒)", "switch_room_wait_after_stage_diag_seconds_var", cfg_get(data.cfg, "switch_room_wait_after_stage_diag_seconds")), ("直播间检测阈值", "live_room_match_threshold_var", cfg_get(data.cfg, "live_room_match_threshold")), ]) def _ocr_and_pixel(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None: box = card(parent, "OCR 与像素检测开关") box.pack(fill="x", pady=(0, 12)) pack_switches(box, ctx, [ ("内容OCR", "fudai_detail_ocr_content_enabled_var", True), ("价值OCR", "fudai_detail_ocr_value_enabled_var", True), ("倒计时OCR", "fudai_detail_ocr_countdown_enabled_var", True), ("任务OCR", "fudai_detail_ocr_task_enabled_var", True), ("任务数量OCR", "fudai_detail_ocr_task_count_enabled_var", True), ("按钮文案OCR", "fudai_detail_ocr_button_enabled_var", True), ("人数OCR(默认关)", "fudai_detail_ocr_participants_enabled_var", False), ("直播间标题OCR(默认关)", "fudai_detail_ocr_live_title_enabled_var", False), ("启用OCR模式1(二值化)", "enable_ocr_mode1_var", False), ("启用福袋模板匹配", "fudai_template_match_enabled_var", False), ("福袋icon", "pixel_detect_fudai_icon_enabled_var", True), ("优惠券", "pixel_detect_coupon_popup_enabled_var", True), ("购物红包(默认关)", "pixel_detect_shopping_redpacket_enabled_var", False), ("开奖结果", "pixel_detect_lottery_result_enabled_var", True), ("参与按钮", "pixel_detect_attend_button_enabled_var", True), ("粉丝团", "pixel_detect_fansclub_join_enabled_var", True), ("福袋详情", "pixel_detect_fudai_detail_enabled_var", True), ("直播间", "pixel_detect_live_room_enabled_var", True), ("开奖结果OCR", "ocr_lottery_result_enabled_var", True), ("优惠券OCR", "ocr_coupon_popup_enabled_var", True), ("购物红包OCR(默认关)", "ocr_shopping_redpacket_enabled_var", False), ("页面OCR", "ocr_stage_page_enabled_var", True), ]) pack_fields(box, ctx, [ ("福袋模板匹配阈值", "fudai_template_match_threshold_var", cfg_get(data.cfg, "fudai_template_match_threshold")), ("详情页模板匹配阈值", "fudai_detail_template_threshold_var", cfg_get(data.cfg, "fudai_detail_template_threshold")), ("开奖页红色占比阈值", "lucky_draw_red_ratio_threshold_var", cfg_get(data.cfg, "lucky_draw_red_ratio_threshold")), ("优惠券模板匹配阈值", "coupon_template_match_threshold_var", cfg_get(data.cfg, "coupon_template_match_threshold")), ("参与按钮红色占比阈值", "attend_button_red_ratio_threshold_var", cfg_get(data.cfg, "attend_button_red_ratio_threshold")), ("粉丝团加入红色占比阈值", "fansclub_join_red_ratio_threshold_var", cfg_get(data.cfg, "fansclub_join_red_ratio_threshold")), ("购物红包背景红色占比阈值", "shopping_redpacket_red_ratio_threshold_var", cfg_get(data.cfg, "shopping_redpacket_red_ratio_threshold")), ("详情主体蓝紫比例阈值", "fudai_detail_body_bluepurple_threshold_var", cfg_get(data.cfg, "fudai_detail_body_bluepurple_threshold")), ("暗色比例阈值", "fudai_detail_body_dark_threshold_var", cfg_get(data.cfg, "fudai_detail_body_dark_threshold")), ("达成形状匹配阈值", "fudai_task_status_template_threshold_var", cfg_get(data.cfg, "fudai_task_status_template_threshold")), ]) def _diagnostics(parent: tk.Misc, data: DashboardData, ctx: PageContext) -> None: box = card(parent, "鼠标与阶段诊断") box.pack(fill="x", pady=(0, 12)) pack_switches(box, ctx, [("详细阶段诊断日志", "stage_diag_verbose_var", False)]) pack_fields(box, ctx, [ ("滑动速度(毫秒)", "swipe_duration_ms_var", cfg_get(data.cfg, "swipe_duration_ms")), ("上滑起始Y坐标", "swipe_up_start_y_var", cfg_get(data.cfg, "swipe_up_start_y")), ("上滑结束Y坐标", "swipe_up_end_y_var", cfg_get(data.cfg, "swipe_up_end_y")), ("最大诊断时间(秒)", "stage_diag_max_time_var", cfg_get(data.cfg, "stage_diag_max_time")), ("每步最大耗时(秒)", "stage_diag_max_step_time_var", cfg_get(data.cfg, "stage_diag_max_step_time")), ])