Add sign editor and entity ref
This commit is contained in:
parent
544e08379a
commit
f31a5b1f17
@ -15,6 +15,7 @@ from mcedit2.ui.inspector import Ui_inspectorWidget
|
|||||||
from mcedit2.util.commandblock import ParseCommand
|
from mcedit2.util.commandblock import ParseCommand
|
||||||
from mcedit2.widgets.inspector.tileentities.chest import ChestEditorWidget, DispenserEditorWidget, HopperEditorWidget
|
from mcedit2.widgets.inspector.tileentities.chest import ChestEditorWidget, DispenserEditorWidget, HopperEditorWidget
|
||||||
from mcedit2.widgets.inspector.tileentities.command import CommandBlockEditorWidget
|
from mcedit2.widgets.inspector.tileentities.command import CommandBlockEditorWidget
|
||||||
|
from mcedit2.widgets.inspector.tileentities.sign import SignEditorWidget
|
||||||
from mceditlib.geometry import Vector
|
from mceditlib.geometry import Vector
|
||||||
from mceditlib.selection import BoundingBox
|
from mceditlib.selection import BoundingBox
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ registerBlockInspectorWidget(ChestEditorWidget)
|
|||||||
registerBlockInspectorWidget(DispenserEditorWidget)
|
registerBlockInspectorWidget(DispenserEditorWidget)
|
||||||
registerBlockInspectorWidget(HopperEditorWidget)
|
registerBlockInspectorWidget(HopperEditorWidget)
|
||||||
registerBlockInspectorWidget(CommandBlockEditorWidget)
|
registerBlockInspectorWidget(CommandBlockEditorWidget)
|
||||||
|
registerBlockInspectorWidget(SignEditorWidget)
|
||||||
|
|
||||||
|
|
||||||
class InspectorWidget(QtGui.QWidget, Ui_inspectorWidget):
|
class InspectorWidget(QtGui.QWidget, Ui_inspectorWidget):
|
||||||
|
@ -13,6 +13,7 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class CommandBlockEditorWidget(QtGui.QWidget):
|
class CommandBlockEditorWidget(QtGui.QWidget):
|
||||||
tileEntityID = "Control"
|
tileEntityID = "Control"
|
||||||
|
|
||||||
def __init__(self, editorSession, tileEntityRef):
|
def __init__(self, editorSession, tileEntityRef):
|
||||||
super(CommandBlockEditorWidget, self).__init__()
|
super(CommandBlockEditorWidget, self).__init__()
|
||||||
assert tileEntityRef.id == self.tileEntityID
|
assert tileEntityRef.id == self.tileEntityID
|
||||||
|
41
src/mcedit2/widgets/inspector/tileentities/sign.py
Normal file
41
src/mcedit2/widgets/inspector/tileentities/sign.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
"""
|
||||||
|
sign
|
||||||
|
"""
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from PySide import QtGui
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class SignEditorWidget(QtGui.QWidget):
|
||||||
|
tileEntityID = "Sign"
|
||||||
|
|
||||||
|
def __init__(self, editorSession, tileEntityRef):
|
||||||
|
super(SignEditorWidget, self).__init__()
|
||||||
|
assert tileEntityRef.id == self.tileEntityID
|
||||||
|
|
||||||
|
self.editorSession = editorSession
|
||||||
|
|
||||||
|
layout = QtGui.QFormLayout()
|
||||||
|
|
||||||
|
self.tileEntityRef = tileEntityRef
|
||||||
|
|
||||||
|
self.lineEdits = []
|
||||||
|
for i in range(4):
|
||||||
|
lineEdit = QtGui.QLineEdit()
|
||||||
|
line = getattr(tileEntityRef, "Text%d" % (i+1), None)
|
||||||
|
if line is not None:
|
||||||
|
lineEdit.setText(line)
|
||||||
|
|
||||||
|
layout.addRow(self.tr("Text %d") % (i+1), lineEdit)
|
||||||
|
self.lineEdits.append(lineEdit)
|
||||||
|
lineEdit.textChanged.connect(self.textDidChange)
|
||||||
|
|
||||||
|
self.setLayout(layout)
|
||||||
|
|
||||||
|
def textDidChange(self):
|
||||||
|
with self.editorSession.beginSimpleCommand(self.tr("Edit sign text")):
|
||||||
|
for i, lineEdit in self.enumerate(self.lineEdits):
|
||||||
|
setattr(self.tileEntityRef, "Text%d" % (i+1), lineEdit.text())
|
@ -474,6 +474,15 @@ class PCTileEntityControlRef(PCTileEntityRefBase):
|
|||||||
TrackOutput = nbtattr.NBTAttr("TrackOutput", 'b', 1)
|
TrackOutput = nbtattr.NBTAttr("TrackOutput", 'b', 1)
|
||||||
|
|
||||||
|
|
||||||
|
class PCTileEntitySignRef(PCTileEntityRefBase):
|
||||||
|
tileEntityID = "Sign"
|
||||||
|
|
||||||
|
Text1 = nbtattr.NBTAttr("Text1", 't', "")
|
||||||
|
Text2 = nbtattr.NBTAttr("Text2", 't', "")
|
||||||
|
Text3 = nbtattr.NBTAttr("Text3", 't', "")
|
||||||
|
Text4 = nbtattr.NBTAttr("Text4", 't', "")
|
||||||
|
|
||||||
|
|
||||||
def convertStackTo17(stack, blocktypes):
|
def convertStackTo17(stack, blocktypes):
|
||||||
if stack["id"].tagID == nbt.ID_STRING:
|
if stack["id"].tagID == nbt.ID_STRING:
|
||||||
stack["id"] = nbt.TAG_Short(blocktypes.itemTypes.internalNamesByID[stack["id"].value])
|
stack["id"] = nbt.TAG_Short(blocktypes.itemTypes.internalNamesByID[stack["id"].value])
|
||||||
@ -521,6 +530,7 @@ _tileEntityClasses = {
|
|||||||
"Trap": PCTileEntityChestRef,
|
"Trap": PCTileEntityChestRef,
|
||||||
"Hopper": PCTileEntityChestRef,
|
"Hopper": PCTileEntityChestRef,
|
||||||
"Control": PCTileEntityControlRef,
|
"Control": PCTileEntityControlRef,
|
||||||
|
"Sign": PCTileEntitySignRef,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user