Skip to content

Commit

Permalink
round out fns dialog behaviour and save fns and asm path
Browse files Browse the repository at this point in the history
  • Loading branch information
mchlnix committed May 17, 2024
1 parent bb9669a commit bc20ee8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
13 changes: 7 additions & 6 deletions foundry/gui/dialogs/fns_asm_load_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def __init__(self, parent, cur_fns_file: str = "", current_asm_file: str = ""):
self._fns_line_edit.textChanged.connect(self._check_fns_file)

self._fns_line_edit.setPlaceholderText("Path to FNS file.")
self._fns_line_edit.setText(self.fns_path)

self._fns_check_icon = QLabel()
self._fns_check_icon.setPixmap(self.style().standardPixmap(QStyle.StandardPixmap.SP_MessageBoxCritical))
Expand All @@ -74,7 +73,6 @@ def __init__(self, parent, cur_fns_file: str = "", current_asm_file: str = ""):
self._asm_line_edit.textChanged.connect(self._check_asm_file)

self._asm_line_edit.setPlaceholderText("Path to smb3.asm file.")
self._asm_line_edit.setText(self.asm_path)

self._asm_check_icon = QLabel()
self._asm_check_icon.setPixmap(self.style().standardPixmap(QStyle.StandardPixmap.SP_MessageBoxCritical))
Expand All @@ -92,19 +90,22 @@ def __init__(self, parent, cur_fns_file: str = "", current_asm_file: str = ""):
hbox = QHBoxLayout()

cancel_button = QPushButton("Cancel")
cancel_button.pressed.connect(self.close)
cancel_button.pressed.connect(self.reject)

self._ok_button = QPushButton("Ok")
self._ok_button.setEnabled(False)
self._ok_button.pressed.connect(self._on_ok)

self._check_ok_button()

hbox.addStretch(2)
hbox.addWidget(cancel_button)
hbox.addWidget(self._ok_button)

vbox.addLayout(hbox)

# set current paths and update icon state
self._fns_line_edit.setText(self.fns_path)
self._asm_line_edit.setText(self.asm_path)

def _check_fns_file(self, path: str):
new_path = Path(path)

Expand Down Expand Up @@ -159,7 +160,7 @@ def _on_ok(self):
self.fns_path = self._fns_line_edit.text()
self.asm_path = self._asm_line_edit.text()

self.close()
self.accept()

def _get_fns_file(self):
fns_file, _ = QFileDialog.getOpenFileName(self, "Open FNS File", filter=FNS_FILE_FILTER)
Expand Down
10 changes: 8 additions & 2 deletions foundry/gui/menus/file_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ def on_save_m3l(self):
save_m3l(pathname, m3l_bytes)

def on_fns_import(self):
open_dialog = FnsAsmLoadDialog(NO_PARENT)
open_dialog.exec()
open_dialog = FnsAsmLoadDialog(NO_PARENT, ROM.fns_path, ROM.smb3_asm_path)
if open_dialog.exec() == FnsAsmLoadDialog.DialogCode.Rejected:
return

try:
QGuiApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
Expand All @@ -146,6 +147,9 @@ def on_fns_import(self):

update_global_offsets(absolute_fns_path)

ROM.fns_path = open_dialog.fns_path
ROM.smb3_asm_path = open_dialog.asm_path

except Exception as e:
QMessageBox.critical(NO_PARENT, "Failed updating globals", str(e))
return
Expand All @@ -157,3 +161,5 @@ def on_fns_import(self):

if self.level_ref:
self.level_ref.data_changed.emit()

QMessageBox.information(NO_PARENT, "Update complete", "Successfully updated the ASM globals.")

0 comments on commit bc20ee8

Please sign in to comment.