Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 17 additions & 21 deletions games/baldursgate3/lslib_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ def _needed_lslib_files(self):
"Divine.dll.config",
"Divine.exe",
"Divine.runtimeconfig.json",
"K4os.Compression.LZ4.dll",
"K4os.Compression.LZ4.Streams.dll",
"LSLib.dll",
"LSLibNative.dll",
"LZ4.dll",
"Newtonsoft.Json.dll",
"System.IO.Hashing.dll",
"ZstdSharp.dll",
}
}

Expand Down Expand Up @@ -129,25 +121,29 @@ def reporthook(block_num: int, block_size: int, total_size: int) -> None:
else:
dialog_message = "Extracting/Updating LSLib files..."
win_title = "Extracting LSLib"
x_progress = self._utils.create_progress_window(
win_title, len(self._needed_lslib_files), msg=dialog_message
)
with zipfile.ZipFile(zip_path, "r") as zip_ref:
for file in self._needed_lslib_files:
if downloaded or not file.exists():
shutil.move(
zip_ref.extract(
f"Packed/Tools/{file.name}", self._utils.tools_dir
),
file,
)
names = list(
filter(
lambda name: name.startswith("Packed/Tools"), zip_ref.namelist()
)
)
qDebug(f"found files: {','.join(names)}")
x_progress = self._utils.create_progress_window(
win_title, len(names), msg=dialog_message
)
for file in names:
shutil.move(
zip_ref.extract(file, self._utils.tools_dir),
self._utils.tools_dir,
)
x_progress.setValue(x_progress.value() + 1)
QApplication.processEvents()
if x_progress.wasCanceled():
x_progress.close()
qWarning("processing canceled by user")
return False
x_progress.close()
shutil.rmtree(self._utils.tools_dir / "Packed", ignore_errors=True)
x_progress.close()
shutil.rmtree(self._utils.tools_dir / "Packed", ignore_errors=True)
except Exception as e:
qDebug(f"Extraction failed: {e}")
err = QMessageBox(self._utils.main_window)
Expand Down