Skip to content

Commit

Permalink
last remaining textbox->combobox
Browse files Browse the repository at this point in the history
  • Loading branch information
th3w1zard1 committed Jul 6, 2024
1 parent 00c6ec9 commit a37cfd5
Show file tree
Hide file tree
Showing 36 changed files with 351 additions and 353 deletions.
41 changes: 31 additions & 10 deletions Tools/HolocronToolset/src/toolset/gui/editors/are.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ def __init__(self, parent: QWidget | None, installation: HTInstallation | None =
"""
supported: list[ResourceType] = [ResourceType.ARE]
super().__init__(parent, "ARE Editor", "none", supported, supported, installation)
self.resize(400, 600)
self.setFixedSize(400, 600) # Lock the window size
self.setMinimumSize(400, 600) # Lock the window size

self._are: ARE = ARE()
self._minimap = None
Expand Down Expand Up @@ -110,6 +109,22 @@ def _setupSignals(self):
self.ui.mapImageY1Spin.valueChanged.connect(self.redoMinimap)
self.ui.mapImageY2Spin.valueChanged.connect(self.redoMinimap)

self.relevant_script_resnames = sorted(
iter(
{
res.resname().lower()
for res in self._installation.getRelevantResources(
ResourceType.NCS, self._filepath
)
}
)
)

self.ui.onEnterSelect.populateComboBox(self.relevant_script_resnames)
self.ui.onExitSelect.populateComboBox(self.relevant_script_resnames)
self.ui.onHeartbeatSelect.populateComboBox(self.relevant_script_resnames)
self.ui.onUserDefinedSelect.populateComboBox(self.relevant_script_resnames)

def _setupInstallation(self, installation: HTInstallation):
"""Set up installation details.
Expand Down Expand Up @@ -142,11 +157,17 @@ def _setupInstallation(self, installation: HTInstallation):
self.ui.rainCheck.setVisible(installation.tsl)
self.ui.lightningCheck.setVisible(installation.tsl)

installation.setupFileContextMenu(self.ui.onEnterSelect, [ResourceType.NSS, ResourceType.NCS])
installation.setupFileContextMenu(self.ui.onExitSelect, [ResourceType.NSS, ResourceType.NCS])
installation.setupFileContextMenu(self.ui.onHeartbeatSelect, [ResourceType.NSS, ResourceType.NCS])
installation.setupFileContextMenu(self.ui.onUserDefinedSelect, [ResourceType.NSS, ResourceType.NCS])

def load(self, filepath: os.PathLike | str, resref: str, restype: ResourceType, data: bytes):
super().load(filepath, resref, restype, data)

are: ARE = read_are(data)
self._loadARE(are)
self.adjustSize()

def _loadARE(self, are: ARE):
"""Loads area data into UI widgets.
Expand Down Expand Up @@ -252,10 +273,10 @@ def _loadARE(self, are: ARE):
self.ui.dirtSize3Spin.setValue(are.dirty_size_3)

# Scripts
self.ui.onEnterEdit.setText(str(are.on_enter))
self.ui.onExitEdit.setText(str(are.on_exit))
self.ui.onHeartbeatEdit.setText(str(are.on_heartbeat))
self.ui.onUserDefinedEdit.setText(str(are.on_user_defined))
self.ui.onEnterSelect.setComboBoxText(str(are.on_enter))
self.ui.onExitSelect.setComboBoxText(str(are.on_exit))
self.ui.onHeartbeatSelect.setComboBoxText(str(are.on_heartbeat))
self.ui.onUserDefinedSelect.setComboBoxText(str(are.on_user_defined))

# Comments
self.ui.commentsEdit.setPlainText(are.comment)
Expand Down Expand Up @@ -344,10 +365,10 @@ def _buildARE(self) -> ARE:
are.dirty_size_3 = self.ui.dirtSize3Spin.value()

# Scripts
are.on_enter = ResRef(self.ui.onEnterEdit.text())
are.on_exit = ResRef(self.ui.onExitEdit.text())
are.on_heartbeat = ResRef(self.ui.onHeartbeatEdit.text())
are.on_user_defined = ResRef(self.ui.onUserDefinedEdit.text())
are.on_enter = ResRef(self.ui.onEnterSelect.text())
are.on_exit = ResRef(self.ui.onExitSelect.text())
are.on_heartbeat = ResRef(self.ui.onHeartbeatSelect.text())
are.on_user_defined = ResRef(self.ui.onUserDefinedSelect.text())

# Comments
are.comment = self.ui.commentsEdit.toPlainText()
Expand Down
16 changes: 8 additions & 8 deletions Tools/HolocronToolset/src/toolset/gui/editors/utc.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ def _setupInstallation(self, installation: HTInstallation):
self._installation.setupFileContextMenu(self.ui.onEndRoundEdit, [ResourceType.NSS, ResourceType.NCS])
self._installation.setupFileContextMenu(self.ui.onEndConversationEdit, [ResourceType.NSS, ResourceType.NCS])
self._installation.setupFileContextMenu(self.ui.onDisturbedEdit, [ResourceType.NSS, ResourceType.NCS])
self._installation.setupFileContextMenu(self.ui.onHeartbeatEdit, [ResourceType.NSS, ResourceType.NCS])
self._installation.setupFileContextMenu(self.ui.onHeartbeatSelect, [ResourceType.NSS, ResourceType.NCS])
self._installation.setupFileContextMenu(self.ui.onSpawnEdit, [ResourceType.NSS, ResourceType.NCS])
self._installation.setupFileContextMenu(self.ui.onSpellCastEdit, [ResourceType.NSS, ResourceType.NCS])
self._installation.setupFileContextMenu(self.ui.onUserDefinedEdit, [ResourceType.NSS, ResourceType.NCS])
self._installation.setupFileContextMenu(self.ui.onUserDefinedSelect, [ResourceType.NSS, ResourceType.NCS])

def load(
self,
Expand Down Expand Up @@ -503,10 +503,10 @@ def _loadUTC(
self.ui.onEndRoundEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onEndConversationEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onDisturbedEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onHeartbeatEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onHeartbeatSelect.populateComboBox(self.relevant_script_resnames)
self.ui.onSpawnEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onSpellCastEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onUserDefinedEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onUserDefinedSelect.populateComboBox(self.relevant_script_resnames)

# Scripts
self.ui.onBlockedEdit.setComboBoxText(str(utc.on_blocked))
Expand All @@ -518,10 +518,10 @@ def _loadUTC(
self.ui.onEndRoundEdit.setComboBoxText(str(utc.on_end_round))
self.ui.onEndConversationEdit.setComboBoxText(str(utc.on_end_dialog))
self.ui.onDisturbedEdit.setComboBoxText(str(utc.on_disturbed))
self.ui.onHeartbeatEdit.setComboBoxText(str(utc.on_heartbeat))
self.ui.onHeartbeatSelect.setComboBoxText(str(utc.on_heartbeat))
self.ui.onSpawnEdit.setComboBoxText(str(utc.on_spawn))
self.ui.onSpellCastEdit.setComboBoxText(str(utc.on_spell))
self.ui.onUserDefinedEdit.setComboBoxText(str(utc.on_user_defined))
self.ui.onUserDefinedSelect.setComboBoxText(str(utc.on_user_defined))

# Comments
self.ui.comments.setPlainText(utc.comment)
Expand Down Expand Up @@ -607,10 +607,10 @@ def build(self) -> tuple[bytes, bytes]:
utc.on_death = ResRef(self.ui.onDeathEdit.currentText())
utc.on_end_round = ResRef(self.ui.onEndRoundEdit.currentText())
utc.on_end_dialog = ResRef(self.ui.onEndConversationEdit.currentText())
utc.on_heartbeat = ResRef(self.ui.onHeartbeatEdit.currentText())
utc.on_heartbeat = ResRef(self.ui.onHeartbeatSelect.currentText())
utc.on_spawn = ResRef(self.ui.onSpawnEdit.currentText())
utc.on_spell = ResRef(self.ui.onSpellCastEdit.currentText())
utc.on_user_defined = ResRef(self.ui.onUserDefinedEdit.currentText())
utc.on_user_defined = ResRef(self.ui.onUserDefinedSelect.currentText())
utc.comment = self.ui.comments.toPlainText()

utc.classes = []
Expand Down
16 changes: 8 additions & 8 deletions Tools/HolocronToolset/src/toolset/gui/editors/utd.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ def _setupInstallation(self, installation: HTInstallation):
installation.setupFileContextMenu(self.ui.onClosedEdit, [ResourceType.NSS, ResourceType.NCS])
installation.setupFileContextMenu(self.ui.onDamagedEdit, [ResourceType.NSS, ResourceType.NCS])
installation.setupFileContextMenu(self.ui.onDeathEdit, [ResourceType.NSS, ResourceType.NCS])
installation.setupFileContextMenu(self.ui.onHeartbeatEdit, [ResourceType.NSS, ResourceType.NCS])
installation.setupFileContextMenu(self.ui.onHeartbeatSelect, [ResourceType.NSS, ResourceType.NCS])
installation.setupFileContextMenu(self.ui.onMeleeAttackEdit, [ResourceType.NSS, ResourceType.NCS])
installation.setupFileContextMenu(self.ui.onOpenEdit, [ResourceType.NSS, ResourceType.NCS])
installation.setupFileContextMenu(self.ui.onOpenFailedEdit, [ResourceType.NSS, ResourceType.NCS])
installation.setupFileContextMenu(self.ui.onSpellEdit, [ResourceType.NSS, ResourceType.NCS])
installation.setupFileContextMenu(self.ui.onUnlockEdit, [ResourceType.NSS, ResourceType.NCS])
installation.setupFileContextMenu(self.ui.onUserDefinedEdit, [ResourceType.NSS, ResourceType.NCS])
installation.setupFileContextMenu(self.ui.onUserDefinedSelect, [ResourceType.NSS, ResourceType.NCS])
installation.setupFileContextMenu(self.ui.conversationEdit, [ResourceType.DLG])

def handleWidgetWithTSL(self, widget: QWidget, installation: HTInstallation):
Expand Down Expand Up @@ -225,12 +225,12 @@ def _loadUTD(self, utd: UTD):
self.ui.onDamagedEdit.setComboBoxText(str(utd.on_damaged))
self.ui.onDeathEdit.setComboBoxText(str(utd.on_death))
self.ui.onOpenFailedEdit.setComboBoxText(str(utd.on_open_failed))
self.ui.onHeartbeatEdit.setComboBoxText(str(utd.on_heartbeat))
self.ui.onHeartbeatSelect.setComboBoxText(str(utd.on_heartbeat))
self.ui.onMeleeAttackEdit.setComboBoxText(str(utd.on_melee))
self.ui.onSpellEdit.setComboBoxText(str(utd.on_power))
self.ui.onOpenEdit.setComboBoxText(str(utd.on_open))
self.ui.onUnlockEdit.setComboBoxText(str(utd.on_unlock))
self.ui.onUserDefinedEdit.setComboBoxText(str(utd.on_user_defined))
self.ui.onUserDefinedSelect.setComboBoxText(str(utd.on_user_defined))

self.relevant_script_resnames = sorted(
iter(
Expand All @@ -246,13 +246,13 @@ def _loadUTD(self, utd: UTD):
self.ui.onClosedEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onDamagedEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onDeathEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onHeartbeatEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onHeartbeatSelect.populateComboBox(self.relevant_script_resnames)
self.ui.onMeleeAttackEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onOpenEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onOpenFailedEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onSpellEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onUnlockEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onUserDefinedEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onUserDefinedSelect.populateComboBox(self.relevant_script_resnames)
self.ui.conversationEdit.populateComboBox(
sorted(
iter(
Expand Down Expand Up @@ -320,12 +320,12 @@ def build(self) -> tuple[bytes, bytes]:
utd.on_damaged = ResRef(self.ui.onDamagedEdit.currentText())
utd.on_death = ResRef(self.ui.onDeathEdit.currentText())
utd.on_open_failed = ResRef(self.ui.onOpenFailedEdit.currentText())
utd.on_heartbeat = ResRef(self.ui.onHeartbeatEdit.currentText())
utd.on_heartbeat = ResRef(self.ui.onHeartbeatSelect.currentText())
utd.on_melee = ResRef(self.ui.onMeleeAttackEdit.currentText())
utd.on_power = ResRef(self.ui.onSpellEdit.currentText())
utd.on_open = ResRef(self.ui.onOpenEdit.currentText())
utd.on_unlock = ResRef(self.ui.onUnlockEdit.currentText())
utd.on_user_defined = ResRef(self.ui.onUserDefinedEdit.currentText())
utd.on_user_defined = ResRef(self.ui.onUserDefinedSelect.currentText())

# Comments
utd.comment = self.ui.commentsEdit.toPlainText()
Expand Down
32 changes: 16 additions & 16 deletions Tools/HolocronToolset/src/toolset/gui/editors/ute.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ def _setupInstallation(
self.ui.factionSelect.setItems(factions.get_column("label"))
self.ui.factionSelect.setContext(factions, installation, HTInstallation.TwoDA_FACTIONS)

self._installation.setupFileContextMenu(self.ui.onEnterEdit, [ResourceType.NSS, ResourceType.NCS])
self._installation.setupFileContextMenu(self.ui.onExitEdit, [ResourceType.NSS, ResourceType.NCS])
self._installation.setupFileContextMenu(self.ui.onEnterSelect, [ResourceType.NSS, ResourceType.NCS])
self._installation.setupFileContextMenu(self.ui.onExitSelect, [ResourceType.NSS, ResourceType.NCS])
self._installation.setupFileContextMenu(self.ui.onExhaustedEdit, [ResourceType.NSS, ResourceType.NCS])
self._installation.setupFileContextMenu(self.ui.onHeartbeatEdit, [ResourceType.NSS, ResourceType.NCS])
self._installation.setupFileContextMenu(self.ui.onUserDefinedEdit, [ResourceType.NSS, ResourceType.NCS])
self._installation.setupFileContextMenu(self.ui.onHeartbeatSelect, [ResourceType.NSS, ResourceType.NCS])
self._installation.setupFileContextMenu(self.ui.onUserDefinedSelect, [ResourceType.NSS, ResourceType.NCS])
self.relevant_creature_resnames = sorted(
iter(
{
Expand Down Expand Up @@ -196,11 +196,11 @@ def _loadUTE(self, ute: UTE):
)

# Scripts
self.ui.onEnterEdit.setComboBoxText(str(ute.on_entered))
self.ui.onExitEdit.setComboBoxText(str(ute.on_exit))
self.ui.onEnterSelect.setComboBoxText(str(ute.on_entered))
self.ui.onExitSelect.setComboBoxText(str(ute.on_exit))
self.ui.onExhaustedEdit.setComboBoxText(str(ute.on_exhausted))
self.ui.onHeartbeatEdit.setComboBoxText(str(ute.on_heartbeat))
self.ui.onUserDefinedEdit.setComboBoxText(str(ute.on_user_defined))
self.ui.onHeartbeatSelect.setComboBoxText(str(ute.on_heartbeat))
self.ui.onUserDefinedSelect.setComboBoxText(str(ute.on_user_defined))

self.relevant_script_resnames = sorted(
iter(
Expand All @@ -213,11 +213,11 @@ def _loadUTE(self, ute: UTE):
)
)

self.ui.onEnterEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onExitEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onEnterSelect.populateComboBox(self.relevant_script_resnames)
self.ui.onExitSelect.populateComboBox(self.relevant_script_resnames)
self.ui.onExhaustedEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onHeartbeatEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onUserDefinedEdit.populateComboBox(self.relevant_script_resnames)
self.ui.onHeartbeatSelect.populateComboBox(self.relevant_script_resnames)
self.ui.onUserDefinedSelect.populateComboBox(self.relevant_script_resnames)

# Comments
self.ui.commentsEdit.setPlainText(ute.comment)
Expand Down Expand Up @@ -271,11 +271,11 @@ def build(self) -> tuple[bytes, bytes]:
ute.creatures.append(creature)

# Scripts
ute.on_entered = ResRef(self.ui.onEnterEdit.currentText())
ute.on_exit = ResRef(self.ui.onExitEdit.currentText())
ute.on_entered = ResRef(self.ui.onEnterSelect.currentText())
ute.on_exit = ResRef(self.ui.onExitSelect.currentText())
ute.on_exhausted = ResRef(self.ui.onExhaustedEdit.currentText())
ute.on_heartbeat = ResRef(self.ui.onHeartbeatEdit.currentText())
ute.on_user_defined = ResRef(self.ui.onUserDefinedEdit.currentText())
ute.on_heartbeat = ResRef(self.ui.onHeartbeatSelect.currentText())
ute.on_user_defined = ResRef(self.ui.onUserDefinedSelect.currentText())

# Comments
ute.comment = self.ui.commentsEdit.toPlainText()
Expand Down
Loading

0 comments on commit a37cfd5

Please sign in to comment.