mirror of
https://github.com/hyb-oyqq/FRAISEMOE-Addons-Installer-NEXT.git
synced 2025-12-16 20:10:28 +00:00
- 在主窗口中添加离线模式管理器,支持自动切换到离线模式。 - 更新下载管理器以处理离线模式下的下载逻辑,确保用户体验流畅。 - 添加版本警告机制,提示用户在版本过低时的操作选项。 - 优化配置管理器,确保在离线模式下仍可使用相关功能。 - 更新UI管理器以反映当前工作模式,提升用户界面友好性。
89 lines
3.7 KiB
Python
89 lines
3.7 KiB
Python
import os
|
||
from PySide6 import QtWidgets
|
||
from PySide6.QtWidgets import QMessageBox
|
||
|
||
|
||
class ExtractionHandler:
|
||
"""解压处理器,负责管理解压任务和结果处理"""
|
||
|
||
def __init__(self, main_window):
|
||
"""初始化解压处理器
|
||
|
||
Args:
|
||
main_window: 主窗口实例,用于访问UI和状态
|
||
"""
|
||
self.main_window = main_window
|
||
self.APP_NAME = main_window.APP_NAME if hasattr(main_window, 'APP_NAME') else ""
|
||
|
||
def start_extraction(self, _7z_path, game_folder, plugin_path, game_version):
|
||
"""开始解压任务
|
||
|
||
Args:
|
||
_7z_path: 7z文件路径
|
||
game_folder: 游戏文件夹路径
|
||
plugin_path: 插件路径
|
||
game_version: 游戏版本名称
|
||
"""
|
||
# 检查是否处于离线模式
|
||
is_offline = False
|
||
if hasattr(self.main_window, 'offline_mode_manager'):
|
||
is_offline = self.main_window.offline_mode_manager.is_in_offline_mode()
|
||
|
||
# 显示解压中的消息窗口
|
||
self.main_window.hash_msg_box = self.main_window.hash_manager.hash_pop_window(
|
||
check_type="offline_extraction" if is_offline else "extraction",
|
||
is_offline=is_offline
|
||
)
|
||
|
||
# 创建并启动解压线程
|
||
self.main_window.extraction_thread = self.main_window.create_extraction_thread(
|
||
_7z_path, game_folder, plugin_path, game_version
|
||
)
|
||
self.main_window.extraction_thread.finished.connect(self.on_extraction_finished)
|
||
self.main_window.extraction_thread.start()
|
||
|
||
def on_extraction_finished(self, success, error_message, game_version):
|
||
"""解压完成后的处理
|
||
|
||
Args:
|
||
success: 是否解压成功
|
||
error_message: 错误信息
|
||
game_version: 游戏版本
|
||
"""
|
||
# 关闭哈希检查窗口
|
||
if self.main_window.hash_msg_box and self.main_window.hash_msg_box.isVisible():
|
||
self.main_window.hash_msg_box.close()
|
||
self.main_window.hash_msg_box = None
|
||
|
||
# 处理解压结果
|
||
if not success:
|
||
# 临时启用窗口以显示错误消息
|
||
self.main_window.setEnabled(True)
|
||
|
||
QtWidgets.QMessageBox.critical(self.main_window, f"错误 - {self.APP_NAME}", error_message)
|
||
self.main_window.installed_status[game_version] = False
|
||
|
||
# 询问用户是否继续其他游戏的安装
|
||
reply = QtWidgets.QMessageBox.question(
|
||
self.main_window,
|
||
f"继续安装? - {self.APP_NAME}",
|
||
f"\n{game_version} 的补丁安装失败。\n\n是否继续安装其他游戏的补丁?\n",
|
||
QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No,
|
||
QtWidgets.QMessageBox.StandardButton.Yes
|
||
)
|
||
|
||
if reply == QtWidgets.QMessageBox.StandardButton.Yes:
|
||
# 继续下一个,重新禁用窗口
|
||
self.main_window.setEnabled(False)
|
||
# 通知DownloadManager继续下一个下载任务
|
||
self.main_window.download_manager.on_extraction_finished(True)
|
||
else:
|
||
# 用户选择停止,保持窗口启用状态
|
||
self.main_window.ui.start_install_text.setText("开始安装")
|
||
# 通知DownloadManager停止下载队列
|
||
self.main_window.download_manager.on_extraction_finished(False)
|
||
else:
|
||
# 更新安装状态
|
||
self.main_window.installed_status[game_version] = True
|
||
# 通知DownloadManager继续下一个下载任务
|
||
self.main_window.download_manager.on_extraction_finished(True) |