53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLineEdit, QLabel, QSizePolicy, QComboBox, QHBoxLayout, QSpacerItem
|
|
from PyQt5.QtCore import Qt, pyqtSignal
|
|
from .cutscenewait import CutsceneWaitEditor
|
|
from .cutscenetext import CutsceneTextEditor
|
|
|
|
EDITOR_MAP = (
|
|
( "wait", "Wait", CutsceneWaitEditor ),
|
|
( "text", "Text", CutsceneTextEditor )
|
|
)
|
|
|
|
class CutsceneItemEditor(QWidget):
|
|
def __init__(self, parent=None):
|
|
super().__init__(parent)
|
|
self.layout = QVBoxLayout(self)
|
|
self.layout.setAlignment(Qt.AlignTop | Qt.AlignLeft)
|
|
self.layout.addWidget(QLabel("Item Properties:"))
|
|
|
|
rowLayout = QHBoxLayout()
|
|
rowLayout.setSpacing(8)
|
|
|
|
rowLayout.addWidget(QLabel("Name:"))
|
|
self.nameInput = QLineEdit()
|
|
rowLayout.addWidget(self.nameInput)
|
|
|
|
rowLayout.addWidget(QLabel("Type:"))
|
|
self.typeDropdown = QComboBox()
|
|
self.typeDropdown.addItems([typeName for typeKey, typeName, editorClass in EDITOR_MAP])
|
|
rowLayout.addWidget(self.typeDropdown)
|
|
self.layout.addLayout(rowLayout)
|
|
|
|
self.activeEditor = None
|
|
|
|
# Events
|
|
self.typeDropdown.currentTextChanged.connect(self.onTypeChanged)
|
|
|
|
# First load
|
|
self.onTypeChanged(self.typeDropdown.currentText())
|
|
|
|
def onTypeChanged(self, typeText):
|
|
typeKey = typeText.lower()
|
|
|
|
# Remove existing editor
|
|
if self.activeEditor:
|
|
self.layout.removeWidget(self.activeEditor)
|
|
self.activeEditor.deleteLater()
|
|
self.activeEditor = None
|
|
|
|
# Create new editor
|
|
for key, name, editorClass in EDITOR_MAP:
|
|
if key == typeKey:
|
|
self.activeEditor = editorClass()
|
|
self.layout.addWidget(self.activeEditor)
|
|
break |