Skip to content

Commit

Permalink
Fix annoying issue with adding struct into list
Browse files Browse the repository at this point in the history
  • Loading branch information
th3w1zard1 committed Mar 20, 2024
1 parent 86b6818 commit 594d953
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Tools/HolocronToolset/src/toolset/gui/editors/gff.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ def typeChanged(self, ftypeId: int):
self.loadItem(item) # type: ignore[]
self.refreshItemText(item)

def insertNode(self, parent: QStandardItem, label: str, ftype: GFFFieldType, value: Any):
def insertNode(self, parent: QStandardItem, label: str, ftype: GFFFieldType, value: Any) -> QStandardItem:
"""Inserts a new child node under the given parent node.
Args:
Expand All @@ -691,6 +691,7 @@ def insertNode(self, parent: QStandardItem, label: str, ftype: GFFFieldType, val
item.setData(value, _VALUE_NODE_ROLE)
parent.appendRow(item)
self.refreshItemText(item)
return item

def addNode(self, item: QStandardItem):
"""Add a node from the tree model.
Expand All @@ -699,7 +700,19 @@ def addNode(self, item: QStandardItem):
----
item: The item to add
"""
self.insertNode(item, "New Struct", GFFFieldType.Struct, GFFStruct())
def set_spinbox(minv: int, maxv: int, item: QListWidgetItem):
self.ui.pages.setCurrentWidget(self.ui.intPage)
self.ui.intSpin.setRange(minv, maxv)
self.ui.intSpin.setValue(item.data(_VALUE_NODE_ROLE))
parentType = item.data(_TYPE_NODE_ROLE)
newValue = GFFStruct()
newLabel = "[New Struct]"
if parentType == GFFFieldType.List:
self.ui.fieldBox.setEnabled(False)
newValue = newValue.struct_id
newLabel = str(item.rowCount())
newItem = self.insertNode(item, newLabel, GFFFieldType.Struct, newValue)
set_spinbox(-1, 0xFFFFFFFF, newItem)

def removeNode(self, item: QStandardItem):
"""Remove a node from the tree model.
Expand Down

0 comments on commit 594d953

Please sign in to comment.