Skip to content

Commit

Permalink
Adding demaster
Browse files Browse the repository at this point in the history
  • Loading branch information
HobbitDur committed Aug 22, 2024
1 parent 25c22bd commit 72f006b
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 20 deletions.
25 changes: 23 additions & 2 deletions ModSetup/setup.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,26 @@
"fr",
"de"
]
},
"Demaster": {
"download_type": "github",
"download_name": "none",
"link": "https://github.com/MaKiPL/FF8_demaster",
"git_tag": "1.3.3",
"rank": "31",
"compatibility": [
"demaster"
],
"modder_name": "MaKiPL",
"mod_info": "Low level tools to interface with the game",
"mod_type": "Wrapper",
"default_selected": "true",
"ffnx_param": {},
"lang": [
"en",
"fr",
"de"
]
},
"FF78Launcher": {
"download_type": "github",
Expand Down Expand Up @@ -162,14 +182,15 @@
"de"
]
},
"Tsunamods-FFNx-OST-RF": {
"Tsunamods-OST-RF": {
"download_type": "direct",
"download_name": "OST-RF v1.0 FFNx.zip",
"link": "https://download.tsunamods.com/?id=12",
"remaster-link": "https://download.tsunamods.com/?id=11",
"git_tag": "none",
"rank": "70",
"compatibility": [
"ffnx"
"ffnx", "demaster"
],
"modder_name": "MikeDoesAudio",
"mod_info": "Original SoundTrack ReFined by a professional mixer",
Expand Down
19 changes: 13 additions & 6 deletions hobbitgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class Installer(QObject):
completed = pyqtSignal(int)
update_data_completed = pyqtSignal()

@pyqtSlot(ModManager, list, bool, dict, bool)
def install(self, mod_manager, mod_to_be_installed, keep_downloaded_mod, special_status={}, download=True):
@pyqtSlot(ModManager, list, bool, dict, bool, str)
def install(self, mod_manager, mod_to_be_installed, keep_downloaded_mod, special_status={}, download=True, ff8_version="ffnx"):
for index, mod_name in enumerate(mod_to_be_installed):
mod_manager.install_mod(mod_name, keep_downloaded_mod, special_status, download)
mod_manager.install_mod(mod_name, keep_downloaded_mod, special_status, download, ff8_version)
self.progress.emit(index + 1)
self.completed.emit(len(mod_to_be_installed))

Expand All @@ -30,7 +30,7 @@ def update_data(self, mod_manager):


class WindowInstaller(QWidget):
install_requested = pyqtSignal(ModManager, list, bool, dict, bool)
install_requested = pyqtSignal(ModManager, list, bool, dict, bool, str)
update_data_requested = pyqtSignal(ModManager)
FF8_RELOAD_NAME = "FFVIII-Reloaded-FR-ONLY"
RAGNAROK_NAME = "Ragnarok-EN-ONLY"
Expand Down Expand Up @@ -227,7 +227,8 @@ def __setup_setup_layout(self):
self.layout_setup.addLayout(self.layout_language)
self.layout_setup.addLayout(self.layout_ff8_version)
self.layout_setup.addLayout(self.layout_mod_type)
self.layout_setup.addWidget(self.download)
#self.layout_setup.addWidget(self.download)
self.download.hide()
self.layout_setup.addWidget(self.keep_mod_archive)
self.layout_setup.addWidget(self.separator)

Expand Down Expand Up @@ -328,8 +329,14 @@ def install_click(self):
self.progress.setRange(0, len(mod_to_be_installed) + 1)
self.progress.setValue(1)
download = self.download.isChecked()
if self.ff8_version.currentText() == self.VERSION_LIST[0]:
ff8_version = "ffnx"
elif self.ff8_version.currentText() == self.VERSION_LIST[1]:
ff8_version = "demaster"
else:
ff8_version = ""
self.install_requested.emit(self.mod_manager, mod_to_be_installed, self.keep_mod_archive.isChecked(),
special_status, download)
special_status, download, ff8_version)

def update_data_click(self):
self.progress.show()
Expand Down
59 changes: 47 additions & 12 deletions modmanager.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import glob
import json
import os
import re
import shutil
from os import write
import subprocess
import time
from zipfile import ZipFile
import psutil
from ffnxmanager import FFNxManager
import patoolib
import requests
Expand All @@ -23,7 +24,6 @@ class ModManager():
MOD_AVAILABLE_FILE = 'mod_available.txt'
MOD_FILE_NAME = 'mod_file_name.txt'
MOD_NAME_LIST = 'mod_name_list.txt'
LIST_MOD_TO_BE_SETUP = ['FFNxFF8Music', 'FFNx-RoseAndWine', 'Tsunamods-OST-RF']
UPDATE_DATA_NAME = "UpdateData"
SETUP_FILE = os.path.join(FOLDER_SETUP, "setup.json")

Expand Down Expand Up @@ -84,7 +84,7 @@ def __get_github_url_file(self, mod_name: str, json_url="assets_url"):
dd_url = el[json_url]
return dd_url

def install_mod(self, mod_name: str, keep_download_mod=False, special_status={}, download=True):
def install_mod(self, mod_name: str, keep_download_mod=False, special_status={}, download=True, ff8_version="ffnx"):
os.makedirs(self.FOLDER_DOWNLOAD, exist_ok=True)
print("Start installing mod: {}".format(mod_name))
if mod_name == self.UPDATE_DATA_NAME:
Expand All @@ -108,7 +108,13 @@ def install_mod(self, mod_name: str, keep_download_mod=False, special_status={},
else:
dd_file_name = self.mod_dict_json["download_name"]
elif self.mod_dict_json[mod_name]["download_type"] == "direct":
direct_file = self.mod_dict_json[mod_name]['link']
if ff8_version == "ffnx":
direct_file = self.mod_dict_json[mod_name]['link']
elif ff8_version == "demaster":
direct_file = self.mod_dict_json[mod_name]['remaster-link']
else:
print("Error unexpected ff8_version: {}".format(ff8_version))
direct_file = self.mod_dict_json[mod_name]['link']
if mod_name == "FFNxFF8Music": # need remove " around
dd_file_name = self.mod_dict_json[mod_name]["download_name"]
else:
Expand Down Expand Up @@ -179,6 +185,36 @@ def install_mod(self, mod_name: str, keep_download_mod=False, special_status={},
os.makedirs(os.path.join(self.ff8_path, 'Data', 'Music', 'dmusic'), exist_ok=True)
shutil.copy(os.path.join(archive, "064s-choco.sgt"), os.path.join(self.ff8_path, 'Data', 'Music', 'dmusic'))
os.remove(os.path.join(archive, "064s-choco.sgt"))
elif mod_name == "Demaster": # Big special handle
installer_directory = os.getcwd()
print("Installing demaster - long process !")
if not os.path.isfile(os.path.join(self.ff8_path, "FFVIII_LAUNCHER.exe-original")):
print("First running the original launcher to create a config file, and waiting 10 sec that it launches")
os.chdir(os.path.join(self.ff8_path))
subprocess.run("FFVIII_LAUNCHER.exe")
time.sleep(10)
print("Now killing the launcher")
PROCNAME = "FFVIII_LAUNCHER.exe"
for proc in psutil.process_iter():
# check whether the process name matches
if proc.name() == PROCNAME:
proc.kill()
os.chdir(installer_directory)
print("Copying demaster file to ff8")

shutil.copy(os.path.join(self.ff8_path, "FFVIII_LAUNCHER.exe"), os.path.join(self.ff8_path, "FFVIII_LAUNCHER.exe-original"))

archive_to_copy = os.path.join(archive, "EN_FR_IT_DE_ES_LATIN")
futur_path = os.path.join(self.ff8_path)
shutil.copytree(archive_to_copy, futur_path, dirs_exist_ok=True,
copy_function=shutil.copy)
print("Now running the extractor, please accept by saying yes. Once it's over, please exit")
os.chdir(os.path.join(self.ff8_path))
subprocess.run("ffviii_demaster_manager.exe")
os.chdir(installer_directory)
archive_to_copy = ""
futur_path = ""

elif 'DefaultFiles' in mod_name:
futur_path = os.path.join(self.ff8_path, 'Data', 'lang-{}'.format(mod_name[-2:].lower()))
archive_to_copy = os.path.join(archive, list_dir[index_folder])
Expand All @@ -191,23 +227,22 @@ def install_mod(self, mod_name: str, keep_download_mod=False, special_status={},
else:
archive_to_copy = archive
futur_path = self.ff8_path
print("Archive to copy: {}, futur path: {}".format(archive_to_copy, futur_path))
shutil.copytree(archive_to_copy, futur_path, dirs_exist_ok=True,
copy_function=shutil.copy) # shutil.copy to make it works on linux proton
if archive_to_copy and futur_path:
print("Archive to copy: {}, futur path: {}".format(archive_to_copy, futur_path))
shutil.copytree(archive_to_copy, futur_path, dirs_exist_ok=True,
copy_function=shutil.copy) # shutil.copy to make it works on linux proton
if archive != "":
shutil.rmtree(archive)
# remove_test_file()
if not keep_download_mod:
shutil.rmtree(self.FOLDER_DOWNLOAD)

if mod_name in self.LIST_MOD_TO_BE_SETUP:
ffnx_param = self.mod_dict_json[mod_name]["ffnx_param"]
if ffnx_param and ff8_version == "ffnx":
print("Updating FFNx.toml file for mod {}".format(mod_name))
if not os.path.join(self.ff8_path, "FFNx.toml"):
with open(os.path.join(self.ff8_path, "FFNx.toml"), "w") as file:
pass
ffnx_param = self.mod_dict_json[mod_name]["ffnx_param"]
print(ffnx_param)
if ffnx_param:
self.ffnx_manager.change_ffnx_option(ffnx_param, self.ff8_path)

def update_data(self):
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ idna==3.7
packaging==24.1
patool==2.3.0
pefile==2023.2.7
psutil==6.0.0
pyinstaller==6.10.0
pyinstaller-hooks-contrib==2024.8
PyQt6==6.7.1
Expand Down

0 comments on commit 72f006b

Please sign in to comment.