Prep ent
This commit is contained in:
53
tools/editortool/cutscene/cutsceneitem.py
Normal file
53
tools/editortool/cutscene/cutsceneitem.py
Normal file
@@ -0,0 +1,53 @@
|
||||
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
|
||||
21
tools/editortool/cutscene/cutscenetext.py
Normal file
21
tools/editortool/cutscene/cutscenetext.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QTextEdit
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
class CutsceneTextEditor(QWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.setSpacing(0)
|
||||
label = QLabel("Text:")
|
||||
label.setSizePolicy(label.sizePolicy().Expanding, label.sizePolicy().Fixed)
|
||||
layout.addWidget(label)
|
||||
self.textInput = QTextEdit()
|
||||
self.textInput.setSizePolicy(self.textInput.sizePolicy().Expanding, self.textInput.sizePolicy().Expanding)
|
||||
layout.addWidget(self.textInput, stretch=1)
|
||||
|
||||
def setText(self, text):
|
||||
self.textInput.setPlainText(text)
|
||||
|
||||
def getText(self):
|
||||
return self.textInput.toPlainText()
|
||||
20
tools/editortool/cutscene/cutscenewait.py
Normal file
20
tools/editortool/cutscene/cutscenewait.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from PyQt5.QtWidgets import QWidget, QFormLayout, QDoubleSpinBox, QLabel
|
||||
|
||||
class CutsceneWaitEditor(QWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
layout = QFormLayout(self)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.setSpacing(0)
|
||||
self.waitTimeInput = QDoubleSpinBox()
|
||||
self.waitTimeInput.setMinimum(0.0)
|
||||
self.waitTimeInput.setMaximum(9999.0)
|
||||
self.waitTimeInput.setDecimals(2)
|
||||
self.waitTimeInput.setSingleStep(0.1)
|
||||
layout.addRow(QLabel("Wait Time (seconds):"), self.waitTimeInput)
|
||||
|
||||
def setWaitTime(self, value):
|
||||
self.waitTimeInput.setValue(value)
|
||||
|
||||
def getWaitTime(self):
|
||||
return self.waitTimeInput.value()
|
||||
Reference in New Issue
Block a user