Skip to content

Commit

Permalink
Merge branch 'mod-integration' of https://github.com/gymnast86/sshd-r…
Browse files Browse the repository at this point in the history
…ando into pr-test
  • Loading branch information
gymnast86 committed Jan 24, 2025
2 parents 4ecc285 + 5d217bf commit f166a0b
Show file tree
Hide file tree
Showing 18 changed files with 1,103 additions and 479 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ damage-multiplier-diff.yaml

# OS BS
.DS_Store

# Other Mods
other_mods
1 change: 1 addition & 0 deletions constants/configconstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def get_new_seed() -> str:
"Shipyard - Gossip Stone after First Minecart Track",
],
"mixed_entrance_pools": [],
"other_mods": [],
}

if platform.system() != "Windows":
Expand Down
96 changes: 96 additions & 0 deletions data/patches/extracts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,100 @@
# For model texture stuff?
- objectpack:
- Alink
- Bc
- Bee
- Bird_Link
- BRockHole00
- BRockWall
- BRockWall00
- Camera
- Candle00
- Common
- DoorBoss
- FenceBoko
- FlowerA00
- FlowerB00
- FlowerB01
- FlowerBomb
- FlowerHeart
- FX_TBoxOpen
- FX_WaterColumn
- GetArrow
- GetBomb
- GetBombSet
- GetBottleEmpty
- GetBottleFairy
- GetBottleKinokoA
- GetBottleKinokoB
- GetBottleWater
- GetFairy
- GetGenki
- GetGuts
- GetHeart
- GetHeartKakera
- GetInsectBee
- GetInsectButterfly
- GetKeySmall
- GetMap
- GetRupee
- GetSeed
- GetSozaiE
- GetSozaiI
- GetSozaiJ
- GetSozaiM
- GoddessCube
- GoddessTBox
- GrassA
- GrassB
- GrassC
- GrassD
- GrassE
- GrassOcta
- HoleShovel
- InsectButterfly
- Kanban
- KanbanStone
- KanbanTree
- KibakoHang
- LockSmall
- MogumaMud
- MoundShovel
- MudShovel
- PLCommonAnime
- PLCommonAnmSnd
- PLCompItem
- PutArrow
- PutBombSet
- PutFairy
- PutGuts
- PutHeart
- PutHeartKakera
- PutKeySmall
- PutRupee
- PutSeed
- Rival
- RockCarryMiddle
- RockCarrySmall
- RockRollB
- SaveObjectA
- SaveObjectB
- SaveObjectC
- ShotMark
- ShutterChain
- ShutterFenced00
- ShutterFencedAnim
- SkyCmn
- SwitchHit
- SwitchWall
- SwordGirl
- TBoxBossT
- TBoxNormalT
- TBoxSmallT
- Tubo
- UI_Data
- WiiRemocon
- Zelda
- Zelda_face
- Zelda_hair
- Zelda_handL
- Zelda_handR
3 changes: 3 additions & 0 deletions filepathconstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
SSHD_EXTRACT_PATH = Path(userdata_path) / "sshd_extract"
EXEFS_EXTRACT_PATH = SSHD_EXTRACT_PATH / "exefs"
ROMFS_EXTRACT_PATH = SSHD_EXTRACT_PATH / "romfs"
OTHER_MODS_PATH = Path(userdata_path) / "other_mods"
COMBINED_MODS_FOLDER = "TEMP_COMBINED_MOD_DATA"
COMBINED_MODS_PATH = OTHER_MODS_PATH / COMBINED_MODS_FOLDER

# Outputs
DEFAULT_OUTPUT_PATH = Path(userdata_path) / "sshdr_output"
Expand Down
60 changes: 58 additions & 2 deletions gui/advanced.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from functools import partial
from pathlib import Path
import os

from PySide6.QtCore import Qt, QUrl
from PySide6.QtGui import QDesktopServices
Expand All @@ -9,6 +10,8 @@
QComboBox,
QLineEdit,
QFileDialog,
QSpacerItem,
QSizePolicy,
)

from filepathconstants import (
Expand All @@ -17,6 +20,8 @@
PLANDO_PATH,
SPOILER_LOGS_PATH,
SSHD_EXTRACT_PATH,
OTHER_MODS_PATH,
COMBINED_MODS_FOLDER,
)
from gui.dialogs.error_dialog import error_from_str
from gui.dialogs.verify_files_progress_dialog import VerifyFilesProgressDialog
Expand All @@ -39,8 +44,6 @@ def __init__(self, main: "Main", ui: "Ui_main_window"):
self.ui = ui
self.config: Config = main.config

self.ui.random_settings_group_box.setTitle("")

self.output_dir_line_edit: QLineEdit = self.ui.config_output
self.output_dir_line_edit.setText(self.config.output_dir.as_posix())

Expand All @@ -65,6 +68,8 @@ def __init__(self, main: "Main", ui: "Ui_main_window"):
partial(self.verify_extract, verify_all=True)
)

self.ui.refresh_mod_list_button.clicked.connect(self.generate_other_mods_list)

self.verify_dialog = None

self.use_plando_button: QCheckBox = self.ui.config_use_plandomizer
Expand Down Expand Up @@ -112,6 +117,9 @@ def __init__(self, main: "Main", ui: "Ui_main_window"):
self.open_spoiler_logs_folder
)

# Other mods
self.generate_other_mods_list()

def update_config(self):
write_config_to_file(CONFIG_PATH, self.config)
self.update_hash()
Expand Down Expand Up @@ -219,6 +227,54 @@ def verify_extract(self, verify_all: bool = False) -> bool:

return True

def generate_other_mods_list(self):
self.main.clear_layout(self.ui.other_mods_scroll_layout)
found_mods = []
for entry in os.scandir(OTHER_MODS_PATH):
if entry.is_dir():
mod_name = entry.name

# Don't include the combined mods folder as a mod folder. Normally this folder is deleted, but
# if generation fails for some reason, then it might not get deleted.
if mod_name == COMBINED_MODS_FOLDER:
continue

# Don't include the mod if it has an exefs folder. We don't support integrating other mods which modify code
if (OTHER_MODS_PATH / mod_name / "exefs").exists():
continue

mod_checkbox = QCheckBox(mod_name)
mod_checkbox.clicked.connect(self.update_mods_in_config)
if mod_name in self.config.settings[0].other_mods:
mod_checkbox.setChecked(True)
found_mods.append(mod_name)

self.ui.other_mods_scroll_layout.addWidget(mod_checkbox)

# Add a vertical spacer to push the mod list up
self.ui.other_mods_scroll_layout.addSpacerItem(
QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
)

# Remove mods from config which weren't found
for mod_name in self.config.settings[0].other_mods.copy():
if mod_name not in found_mods:
print(
f"Removing mod {mod_name} from other_mods list as the QCheckbox for the mod could not be found"
)
self.config.settings[0].other_mods.remove(mod_name)

self.update_config()

def update_mods_in_config(self):
other_mods = self.config.settings[0].other_mods
other_mods.clear()
for checkbox in self.ui.other_mods_scroll_widget.findChildren(QCheckBox):
if checkbox.isChecked():
other_mods.append(checkbox.text())

self.update_config()

def cancel_callback(self):
VerificationThread.cancelled = True

Expand Down
15 changes: 15 additions & 0 deletions gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
QMessageBox,
QMainWindow,
QWidget,
QLayout,
)

from constants.guiconstants import OPTION_PREFIX
Expand Down Expand Up @@ -252,6 +253,20 @@ def closeEvent(self, event: QCloseEvent) -> None:
self.tracker.autosave_tracker()
event.accept()

def clear_layout(self, layout: QLayout, remove_nested_layouts=True) -> None:
# Recursively clear nested layouts
for nested_layout in layout.findChildren(QLayout):
self.clear_layout(nested_layout, remove_nested_layouts)

while item := layout.takeAt(0):
if widget := item.widget():
widget.deleteLater()
del item

if remove_nested_layouts:
for nested_layout in layout.findChildren(QLayout):
layout.removeItem(nested_layout)


def start_gui(app: QApplication):
try:
Expand Down
Loading

0 comments on commit f166a0b

Please sign in to comment.