Started work on InspectorWidget
(doot-do-doot-do-doot doot doot, woo woo)
This commit is contained in:
parent
9d3ba92c76
commit
891649d9d3
@ -18,6 +18,7 @@ from mcedit2.util.raycast import rayCastInBounds
|
||||
from mcedit2.util.resources import resourcePath
|
||||
from mcedit2.util.showprogress import showProgress
|
||||
from mcedit2.util.undostack import MCEUndoStack
|
||||
from mcedit2.widgets.inspector import InspectorWidget
|
||||
from mcedit2.worldview.viewaction import UseToolMouseAction, TrackingMouseAction
|
||||
from mceditlib import util
|
||||
from mcedit2.rendering import chunkloader, scenegraph
|
||||
@ -241,6 +242,13 @@ class EditorSession(QtCore.QObject):
|
||||
for resultsWidget in self.findReplaceDialog.resultsWidgets:
|
||||
self.dockWidgets.append((Qt.BottomDockWidgetArea, resultsWidget))
|
||||
|
||||
self.inspectorWidget = InspectorWidget(self)
|
||||
self.inspectorDockWidget = QtGui.QDockWidget(self.tr("Inspector"), objectName="inspector")
|
||||
self.inspectorDockWidget.setWidget(self.inspectorWidget)
|
||||
self.inspectorDockWidget.hide()
|
||||
self.dockWidgets.append((Qt.RightDockWidgetArea, self.inspectorDockWidget))
|
||||
|
||||
|
||||
if len(self.toolActions):
|
||||
self.toolActions[0].trigger() # Must be called after toolChanged is connected to editorTab
|
||||
|
||||
@ -547,10 +555,12 @@ class EditorSession(QtCore.QObject):
|
||||
# --- Inspector ---
|
||||
|
||||
def inspectBlock(self, pos):
|
||||
pass
|
||||
self.inspectorDockWidget.show()
|
||||
self.inspectorWidget.inspectBlock(pos)
|
||||
|
||||
def inspectEntity(self, entity):
|
||||
pass
|
||||
self.inspectorDockWidget.show()
|
||||
self.inspectorWidget.inspectEntity(entity)
|
||||
|
||||
|
||||
class EditorTab(QtGui.QWidget):
|
||||
|
@ -46,7 +46,7 @@ class SelectBlockTool(EditorTool):
|
||||
self.toolWidget = load_ui("editortools/select_block.ui")
|
||||
|
||||
def mousePress(self, event):
|
||||
command = SelectBlockCommand(self, event.pos)
|
||||
command = SelectBlockCommand(self, event.blockPosition)
|
||||
self.editorSession.pushCommand(command)
|
||||
|
||||
def setMousePos(self, pos):
|
||||
|
@ -14,14 +14,233 @@
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="NBTEditorWidget" name="nbtEditor" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="pageInspectBlock">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Inspecting block at:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>X=</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="blockXLabel">
|
||||
<property name="text">
|
||||
<string>(x)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Y=</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="blockYLabel">
|
||||
<property name="text">
|
||||
<string>(y)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Z=</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="blockZLabel">
|
||||
<property name="text">
|
||||
<string>(z)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Tile entity:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeTileEntityButton">
|
||||
<property name="text">
|
||||
<string>Remove Tile Entity</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="NBTEditorWidget" name="blockNBTEditor" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="pageInspectEntity">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Inspecting entity:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="entityIDLabel">
|
||||
<property name="text">
|
||||
<string>(entityID)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>with UUID </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="entityUUIDLabel">
|
||||
<property name="text">
|
||||
<string>(uuid)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>at </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="text">
|
||||
<string>X=</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="entityXLabel">
|
||||
<property name="text">
|
||||
<string>(x)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Y=</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="entityYLabel">
|
||||
<property name="text">
|
||||
<string>(y)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Z=</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="entityZLabel">
|
||||
<property name="text">
|
||||
<string>(z)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="NBTEditorWidget" name="entityNBTEditor" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -10,12 +10,56 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class InspectorWidget(QtGui.QWidget):
|
||||
def __init__(self):
|
||||
def __init__(self, editorSession):
|
||||
"""
|
||||
|
||||
:param editorSession:
|
||||
:type editorSession: mcedit2.editorsession.EditorSession
|
||||
:return:
|
||||
:rtype:
|
||||
"""
|
||||
super(InspectorWidget, self).__init__()
|
||||
load_ui("inspector.ui", baseinstance=self)
|
||||
# self.nbtEditor.editorSession = self.editorSession
|
||||
# self.nbtEditor.editMade.connect(self.editWasMade)
|
||||
#
|
||||
# def editWasMade(self):
|
||||
# if self.currentEntity and self.currentEntity.chunk:
|
||||
# self.currentEntity.chunk.dirty = True
|
||||
self.editorSession = editorSession
|
||||
|
||||
self.blockNBTEditor.editorSession = self.editorSession
|
||||
self.blockNBTEditor.editMade.connect(self.editWasMade)
|
||||
|
||||
self.entityNBTEditor.editorSession = self.editorSession
|
||||
self.entityNBTEditor.editMade.connect(self.editWasMade)
|
||||
|
||||
self.tileEntity = None
|
||||
self.entity = None
|
||||
|
||||
|
||||
def editWasMade(self):
|
||||
if self.currentEntity and self.currentEntity.chunk:
|
||||
self.currentEntity.chunk.dirty = True
|
||||
|
||||
def inspectBlock(self, pos):
|
||||
self.stackedWidget.setCurrentWidget(self.pageInspectBlock)
|
||||
x, y, z = pos
|
||||
self.blockXLabel.setText(str(x))
|
||||
self.blockYLabel.setText(str(y))
|
||||
self.blockZLabel.setText(str(z))
|
||||
self.tileEntity = self.editorSession.currentDimension.getTileEntity(pos)
|
||||
if self.tileEntity is not None:
|
||||
self.blockNBTEditor.setRootTag(self.tileEntity.raw_tag())
|
||||
|
||||
self.removeTileEntityButton.setEnabled(self.tileEntity is not None)
|
||||
|
||||
def inspectEntity(self, entity):
|
||||
self.entity = entity
|
||||
self.stackedWidget.setCurrentWidget(self.pageInspectEntity)
|
||||
self.entityIDLabel.setText(entity.id)
|
||||
try:
|
||||
self.entityUUIDLabel.setText(entity.UUID)
|
||||
except KeyError:
|
||||
self.entityUUIDLabel.setText(self.tr("(Not set)"))
|
||||
|
||||
x, y, z = entity.Position
|
||||
self.entityXLabel.setText("%0.2f" % x)
|
||||
self.entityYLabel.setText("%0.2f" % y)
|
||||
self.entityZLabel.setText("%0.2f" % z)
|
||||
|
||||
self.entityNBTEditor.setRootTag(entity.raw_tag())
|
||||
|
@ -616,6 +616,15 @@ class WorldEditorDimension(object):
|
||||
if matchEntityTags(ref, kw):
|
||||
yield ref
|
||||
|
||||
def getTileEntity(self, pos, **kw):
|
||||
cx = pos[0] >> 4
|
||||
cz = pos[2] >> 4
|
||||
chunk = self.getChunk(cx, cz)
|
||||
for ref in chunk.TileEntities:
|
||||
if ref.Position == pos:
|
||||
if matchEntityTags(ref, kw):
|
||||
return ref
|
||||
|
||||
def addEntity(self, ref):
|
||||
x, y, z = ref.Position
|
||||
cx, cz = chunk_pos(x, z)
|
||||
|
Reference in New Issue
Block a user