update:修复单独打补丁失败的bug

This commit is contained in:
2025-07-05 17:16:21 +08:00
parent 3e79687c75
commit 48f0c200a3

View File

@@ -430,25 +430,34 @@ class MainWindow(QMainWindow):
return {}
def download_setting(self, url, game_folder, game_version, _7z_path, plugin_path):
game_exe = {
# 修改游戏可执行文件路径获取方式
game_exe_paths = {
game: os.path.join(
self.selected_folder, info["install_path"].split("/")[0], info["exe"]
self.selected_folder,
info["install_path"].split("/")[0],
info["exe"]
)
for game, info in GAME_INFO.items()
}
# 判断游戏是否存在,不存在则跳过
if (
game_version not in game_exe
or not os.path.exists(game_exe[game_version])
or self.installed_status[game_version]
):
self.installed_status[game_version] = False
self.show_result()
# 检查游戏是否存在
if not os.path.exists(game_exe_paths.get(game_version, "")):
QMessageBox.warning(
self,
f"通知 {APP_NAME}",
f"\n未找到 {game_version} 游戏主程序,跳过安装\n"
)
self.next_download_task()
return
# 如果已经安装则跳过
if self.installed_status[game_version]:
self.next_download_task()
return
progress_window = ProgressWindow(self)
progress_window.show()
self.current_download_thread = DownloadThread(url, _7z_path, self)
self.current_download_thread.progress.connect(progress_window.setprogressbarval)
self.current_download_thread.finished.connect(
@@ -509,14 +518,48 @@ class MainWindow(QMainWindow):
def pre_hash_compare(self, install_path, game_version, plugin_hash):
msg_box = self.hash_manager.hash_pop_window()
self.hash_manager.cfg_pre_hash_compare(
install_path, game_version, plugin_hash, self.installed_status
QApplication.processEvents()
# 检查游戏可执行文件是否存在
game_exe = os.path.join(
self.selected_folder,
GAME_INFO[game_version]["install_path"].split("/")[0],
GAME_INFO[game_version]["exe"]
)
if not os.path.exists(game_exe):
self.installed_status[game_version] = False
msg_box.close()
return
# 检查补丁文件
if not os.path.exists(install_path):
self.installed_status[game_version] = False
msg_box.close()
return
file_hash = self.hash_manager.hash_calculate(install_path)
if file_hash == plugin_hash[game_version]:
self.installed_status[game_version] = True
else:
reply = msgbox_frame(
f"文件校验 {APP_NAME}",
f"\n检测到 {game_version} 的文件哈希值不匹配,是否重新安装?\n",
QMessageBox.Yes | QMessageBox.No,
).exec()
if reply == QMessageBox.Yes:
self.installed_status[game_version] = False
else:
self.installed_status[game_version] = True
msg_box.close()
def download_action(self):
install_paths = self.get_install_paths()
for game_version, install_path in install_paths.items():
# 独立检查每个游戏的安装状态
for game_version in GAME_INFO:
install_path = install_paths[game_version]
self.pre_hash_compare(install_path, game_version, PLUGIN_HASH)
config = self.get_download_url()
@@ -526,32 +569,17 @@ class MainWindow(QMainWindow):
)
return
# 处理1-4卷
for i in range(1, 5):
game_version = f"NEKOPARA Vol.{i}"
for game_version in GAME_INFO:
if not self.installed_status[game_version]:
url = config[f"vol{i}"]
game_folder = os.path.join(self.selected_folder, f"NEKOPARA Vol. {i}")
_7z_path = os.path.join(PLUGIN, f"vol.{i}.7z")
plugin_path = os.path.join(
PLUGIN, GAME_INFO[game_version]["plugin_path"]
)
config_key = "after" if game_version == "NEKOPARA After" else f"vol{game_version.split('.')[1]}"
url = config[config_key]
game_folder = os.path.join(self.selected_folder, game_version.replace("Vol.", "Vol. "))
_7z_path = os.path.join(PLUGIN, f"{config_key}.7z")
plugin_path = os.path.join(PLUGIN, GAME_INFO[game_version]["plugin_path"])
self.download_queue.append(
(url, game_folder, game_version, _7z_path, plugin_path)
)
# 处理After
game_version = "NEKOPARA After"
if not self.installed_status[game_version]:
url = config["after"]
game_folder = os.path.join(self.selected_folder, "NEKOPARA After")
_7z_path = os.path.join(PLUGIN, "after.7z")
plugin_path = os.path.join(
PLUGIN, GAME_INFO[game_version]["plugin_path"]
)
self.download_queue.append(
(url, game_folder, game_version, _7z_path, plugin_path)
)
self.next_download_task()