Rename "Edit Chunk" to "Inspect Chunk" and move most of its code to inspector
This commit is contained in:
parent
8c98350426
commit
4cdf7cffc8
@ -938,6 +938,10 @@ class EditorSession(QtCore.QObject):
|
||||
self.inspectorDockWidget.show()
|
||||
self.inspectorWidget.inspectEntity(entity)
|
||||
|
||||
def inspectChunk(self, cx, cz):
|
||||
self.inspectorDockWidget.show()
|
||||
self.inspectorWidget.inspectChunk(cx, cz)
|
||||
|
||||
# --- Zooming ---
|
||||
|
||||
def zoomAndInspectBlock(self, pos):
|
||||
|
@ -13,129 +13,23 @@ from mcedit2.util.load_ui import load_ui
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class ChunkTool(EditorTool):
|
||||
name = "Edit Chunk"
|
||||
name = "Inspect Chunk"
|
||||
iconName = "edit_chunk"
|
||||
|
||||
def __init__(self, editorSession, *args, **kwargs):
|
||||
"""
|
||||
|
||||
:type editorSession: EditorSession
|
||||
"""
|
||||
super(ChunkTool, self).__init__(editorSession, *args, **kwargs)
|
||||
|
||||
self.toolWidget = load_ui("editortools/edit_chunk.ui")
|
||||
self.toolWidget.tabWidget.currentChanged.connect(self.tabDidChange)
|
||||
|
||||
self.toolWidget.terrainPopulatedInput.toggled.connect(self.terrainPopulatedDidChange)
|
||||
self.toolWidget.lightPopulatedInput.toggled.connect(self.lightPopulatedDidChange)
|
||||
self.toolWidget.inhabitedTimeInput.valueChanged.connect(self.inhabitedTimeDidChange)
|
||||
self.toolWidget.updateTimeInput.valueChanged.connect(self.updateTimeDidChange)
|
||||
|
||||
self.toolWidget.cxSpinBox.valueChanged.connect(self.chunkPositionDidChange)
|
||||
self.toolWidget.czSpinBox.valueChanged.connect(self.chunkPositionDidChange)
|
||||
|
||||
self.toolWidget.nbtEditor.editorSession = self.editorSession
|
||||
|
||||
self.currentChunk = None
|
||||
self.selectionNode = None
|
||||
self.overlayNode = scenenode.Node()
|
||||
self.updateChunkWidget()
|
||||
self.updateNBTView()
|
||||
|
||||
def toolInactive(self):
|
||||
if self.selectionNode:
|
||||
self.overlayNode.removeChild(self.selectionNode)
|
||||
self.selectionNode = None
|
||||
self.currentChunk = None
|
||||
self.updateChunkWidget()
|
||||
|
||||
|
||||
def updateChunkWidget(self):
|
||||
if self.currentChunk:
|
||||
chunk = self.currentChunk
|
||||
|
||||
self.toolWidget.terrainPopulatedInput.setEnabled(True)
|
||||
self.toolWidget.terrainPopulatedInput.setChecked(chunk.TerrainPopulated)
|
||||
|
||||
levelTag = chunk.rootTag["Level"]
|
||||
if "LightPopulated" in levelTag:
|
||||
self.toolWidget.lightPopulatedInput.setEnabled(True)
|
||||
self.toolWidget.lightPopulatedInput.setChecked(levelTag["LightPopulated"].value)
|
||||
else:
|
||||
self.toolWidget.lightPopulatedInput.setEnabled(False)
|
||||
|
||||
if "InhabitedTime" in levelTag:
|
||||
self.toolWidget.inhabitedTimeInput.setEnabled(True)
|
||||
self.toolWidget.inhabitedTimeInput.setValue(levelTag["InhabitedTime"].value)
|
||||
else:
|
||||
self.toolWidget.inhabitedTimeInput.setEnabled(False)
|
||||
|
||||
if "LastUpdate" in levelTag:
|
||||
self.toolWidget.updateTimeInput.setEnabled(True)
|
||||
self.toolWidget.updateTimeInput.setValue(levelTag["LastUpdate"].value)
|
||||
else:
|
||||
self.toolWidget.updateTimeInput.setEnabled(False)
|
||||
else:
|
||||
self.toolWidget.terrainPopulatedInput.setEnabled(False)
|
||||
self.toolWidget.lightPopulatedInput.setEnabled(False)
|
||||
self.toolWidget.inhabitedTimeInput.setEnabled(False)
|
||||
self.toolWidget.updateTimeInput.setEnabled(False)
|
||||
|
||||
|
||||
def terrainPopulatedDidChange(self, value):
|
||||
self.currentChunk.TerrainPopulated = value
|
||||
|
||||
def lightPopulatedDidChange(self, value):
|
||||
self.currentChunk.rootTag["Level"]["LightPopulated"].value = value
|
||||
|
||||
def inhabitedTimeDidChange(self, value):
|
||||
self.currentChunk.rootTag["Level"]["InhabitedTime"].value = value
|
||||
|
||||
def updateTimeDidChange(self, value):
|
||||
self.currentChunk.rootTag["Level"]["LastUpdate"].value = value
|
||||
|
||||
def tabDidChange(self, index):
|
||||
if index == 0: # Chunk tab
|
||||
self.updateChunkWidget()
|
||||
else: # NBT tab
|
||||
pass
|
||||
self.mousePos = None
|
||||
self.toolWidget = load_ui("editortools/select_chunk.ui")
|
||||
|
||||
def mousePress(self, event):
|
||||
x, y, z = event.blockPosition
|
||||
self.setMousePos(event.blockPosition)
|
||||
|
||||
def setMousePos(self, pos):
|
||||
x, y, z = self.mousePos = pos
|
||||
cx = x >> 4
|
||||
cz = z >> 4
|
||||
self.selectChunk(cx, cz)
|
||||
self.editorSession.inspectChunk(cx, cz)
|
||||
|
||||
def selectChunk(self, cx, cz):
|
||||
dim = self.editorSession.currentDimension
|
||||
if dim.containsChunk(cx, cz):
|
||||
chunk = dim.getChunk(cx, cz)
|
||||
self.setSelectedChunk(chunk)
|
||||
|
||||
def setSelectedChunk(self, chunk):
|
||||
if self.selectionNode is None:
|
||||
self.selectionNode = SelectionBoxNode()
|
||||
self.selectionNode.filled = False
|
||||
self.selectionNode.color = (0.3, 0.3, 1, .3)
|
||||
self.overlayNode.addChild(self.selectionNode)
|
||||
|
||||
self.selectionNode.selectionBox = chunk.bounds
|
||||
self.currentChunk = chunk
|
||||
self.updateChunkWidget()
|
||||
self.updateNBTView()
|
||||
|
||||
def updateNBTView(self):
|
||||
chunk = self.currentChunk
|
||||
if chunk is None:
|
||||
self.toolWidget.nbtEditor.setRootTagRef(None)
|
||||
return
|
||||
|
||||
self.toolWidget.nbtEditor.setRootTagRef(chunk)
|
||||
|
||||
self.toolWidget.cxSpinBox.setValue(chunk.cx)
|
||||
self.toolWidget.czSpinBox.setValue(chunk.cz)
|
||||
|
||||
def chunkPositionDidChange(self):
|
||||
cx = self.toolWidget.cxSpinBox.value()
|
||||
cz = self.toolWidget.czSpinBox.value()
|
||||
self.selectChunk(cx, cz)
|
||||
|
@ -1,224 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>653</width>
|
||||
<height>621</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0,1">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Chunk cx:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="cxSpinBox">
|
||||
<property name="frame">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::UpDownArrows</enum>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-900000000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>900000000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>cz:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="czSpinBox">
|
||||
<property name="minimum">
|
||||
<number>-90000000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>90000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="propertiesTab">
|
||||
<attribute name="title">
|
||||
<string>Chunk</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="terrainPopulatedInput">
|
||||
<property name="toolTip">
|
||||
<string>Marks this chunk to have trees, lakes, ores, and other terrain features regenerated in Minecraft.</string>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Terrain Populated</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="lightPopulatedInput">
|
||||
<property name="toolTip">
|
||||
<string>Currently does nothing. Minecraft sets it after generating a chunk but never reads it again.</string>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Light Populated</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Time in ticks when this chunk was last updated. Recently played chunks will reflect the current in-game time, older chunks will have smaller values.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Update Time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="updateTimeInput">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Time in ticks when this chunk was last updated. Recently played chunks will reflect the current in-game time, older chunks will have smaller values.</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Number of ticks the player has spent in this chunk.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Inhabited Time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="inhabitedTimeInput">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Number of ticks the player has spent in this chunk.</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="nbtTab">
|
||||
<attribute name="title">
|
||||
<string>NBT Data</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="NBTEditorWidget" name="nbtEditor" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>NBTEditorWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>nbteditorwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
20
src/mcedit2/ui/editortools/select_chunk.ui
Normal file
20
src/mcedit2/ui/editortools/select_chunk.ui
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>653</width>
|
||||
<height>621</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>498</width>
|
||||
<height>497</height>
|
||||
<width>379</width>
|
||||
<height>678</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -20,7 +20,7 @@
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="pageInspectBlock">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
@ -88,6 +88,30 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<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="pushButton">
|
||||
<property name="text">
|
||||
<string>Save Custom Block</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeTileEntityButton">
|
||||
<property name="text">
|
||||
@ -130,28 +154,7 @@
|
||||
<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>
|
||||
<string>Inspecting entity</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -219,6 +222,38 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Entity ID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="entityIDLabel">
|
||||
<property name="text">
|
||||
<string>(entityID)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>UUID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="entityUUIDLabel">
|
||||
<property name="text">
|
||||
<string>(uuid)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="NBTEditorWidget" name="entityNBTEditor" native="true">
|
||||
<property name="sizePolicy">
|
||||
@ -231,6 +266,210 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="pageInspectChunk">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Inspecting chunk at:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string>CX:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="chunkCXLabel">
|
||||
<property name="text">
|
||||
<string>(cx)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>CZ:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="chunkCZLabel">
|
||||
<property name="text">
|
||||
<string>(cz)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_7">
|
||||
<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="QTabWidget" name="chunkTabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="chunkPropertiesTab">
|
||||
<attribute name="title">
|
||||
<string>Chunk</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="terrainPopulatedInput">
|
||||
<property name="toolTip">
|
||||
<string>Marks this chunk to have trees, lakes, ores, and other terrain features regenerated in Minecraft.</string>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Terrain Populated</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="lightPopulatedInput">
|
||||
<property name="toolTip">
|
||||
<string>Currently does nothing. Minecraft sets it after generating a chunk but never reads it again.</string>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Light Populated</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_33">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Time in ticks when this chunk was last updated. Recently played chunks will reflect the current in-game time, older chunks will have smaller values.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Update Time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="updateTimeInput">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Time in ticks when this chunk was last updated. Recently played chunks will reflect the current in-game time, older chunks will have smaller values.</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_12">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_34">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Number of ticks the player has spent in this chunk.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Inhabited Time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="inhabitedTimeInput">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Number of ticks the player has spent in this chunk.</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="chunkNBTTab">
|
||||
<attribute name="title">
|
||||
<string>NBT Data</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_13">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="NBTEditorWidget" name="chunkNBTEditor" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -6,6 +6,9 @@ import logging
|
||||
import traceback
|
||||
|
||||
from PySide import QtGui
|
||||
from mcedit2.command import SimpleRevisionCommand
|
||||
from mcedit2.rendering.scenegraph import scenenode
|
||||
from mcedit2.rendering.selection import SelectionBoxNode
|
||||
|
||||
from mcedit2.widgets.inspector.tileentities.chest import ChestEditorWidget, DispenserEditorWidget, HopperEditorWidget
|
||||
from mcedit2.util.load_ui import load_ui
|
||||
@ -44,14 +47,27 @@ class InspectorWidget(QtGui.QWidget):
|
||||
self.editorSession = editorSession
|
||||
|
||||
self.blockNBTEditor.editorSession = self.editorSession
|
||||
|
||||
self.entityNBTEditor.editorSession = self.editorSession
|
||||
self.chunkNBTEditor.editorSession = self.editorSession
|
||||
|
||||
self.blockEditorWidget = None
|
||||
|
||||
self.tileEntity = None
|
||||
self.entity = None
|
||||
|
||||
self.currentChunk = None
|
||||
|
||||
# xxxx unused! how!
|
||||
self.selectionNode = None
|
||||
self.overlayNode = scenenode.Node()
|
||||
|
||||
self.chunkTabWidget.currentChanged.connect(self.chunkTabDidChange)
|
||||
|
||||
self.terrainPopulatedInput.toggled.connect(self.terrainPopulatedDidChange)
|
||||
self.lightPopulatedInput.toggled.connect(self.lightPopulatedDidChange)
|
||||
self.inhabitedTimeInput.valueChanged.connect(self.inhabitedTimeDidChange)
|
||||
self.updateTimeInput.valueChanged.connect(self.updateTimeDidChange)
|
||||
|
||||
def inspectBlock(self, pos):
|
||||
self.entity = None
|
||||
|
||||
@ -107,3 +123,117 @@ class InspectorWidget(QtGui.QWidget):
|
||||
self.entityZLabel.setText("%0.2f" % z)
|
||||
|
||||
self.entityNBTEditor.setRootTagRef(entity)
|
||||
|
||||
|
||||
# def toolInactive(self):
|
||||
# if self.selectionNode:
|
||||
# self.overlayNode.removeChild(self.selectionNode)
|
||||
# self.selectionNode = None
|
||||
# self.currentChunk = None
|
||||
# self.updateChunkWidget()
|
||||
|
||||
def inspectChunk(self, cx, cz):
|
||||
dim = self.editorSession.currentDimension
|
||||
if dim.containsChunk(cx, cz):
|
||||
chunk = dim.getChunk(cx, cz)
|
||||
self.setSelectedChunk(chunk)
|
||||
|
||||
def setSelectedChunk(self, chunk):
|
||||
if self.selectionNode is None:
|
||||
self.selectionNode = SelectionBoxNode()
|
||||
self.selectionNode.filled = False
|
||||
self.selectionNode.color = (0.3, 0.3, 1, .3)
|
||||
self.overlayNode.addChild(self.selectionNode)
|
||||
|
||||
self.selectionNode.selectionBox = chunk.bounds
|
||||
self.currentChunk = chunk
|
||||
self.updateChunkWidget()
|
||||
self.updateChunkNBTView()
|
||||
|
||||
def updateChunkWidget(self):
|
||||
if self.currentChunk:
|
||||
chunk = self.currentChunk
|
||||
cx, cz = chunk.chunkPosition
|
||||
|
||||
self.chunkCXLabel.setText(str(cx))
|
||||
self.chunkCZLabel.setText(str(cz))
|
||||
self.terrainPopulatedInput.setEnabled(True)
|
||||
self.terrainPopulatedInput.setChecked(chunk.TerrainPopulated)
|
||||
|
||||
levelTag = chunk.rootTag["Level"]
|
||||
if "LightPopulated" in levelTag:
|
||||
self.lightPopulatedInput.setEnabled(True)
|
||||
self.lightPopulatedInput.setChecked(levelTag["LightPopulated"].value)
|
||||
else:
|
||||
self.lightPopulatedInput.setEnabled(False)
|
||||
|
||||
if "InhabitedTime" in levelTag:
|
||||
self.inhabitedTimeInput.setEnabled(True)
|
||||
self.inhabitedTimeInput.setValue(levelTag["InhabitedTime"].value)
|
||||
else:
|
||||
self.inhabitedTimeInput.setEnabled(False)
|
||||
|
||||
if "LastUpdate" in levelTag:
|
||||
self.updateTimeInput.setEnabled(True)
|
||||
self.updateTimeInput.setValue(levelTag["LastUpdate"].value)
|
||||
else:
|
||||
self.updateTimeInput.setEnabled(False)
|
||||
else:
|
||||
self.terrainPopulatedInput.setEnabled(False)
|
||||
self.lightPopulatedInput.setEnabled(False)
|
||||
self.inhabitedTimeInput.setEnabled(False)
|
||||
self.updateTimeInput.setEnabled(False)
|
||||
|
||||
def terrainPopulatedDidChange(self, value):
|
||||
command = InspectPropertyChangeCommand(self.editorSession,
|
||||
self.tr("Change chunk (%s, %s) property TerrainPopulated")
|
||||
% self.currentChunk.chunkPosition)
|
||||
with command.begin():
|
||||
self.currentChunk.TerrainPopulated = value
|
||||
self.editorSession.pushCommand(command)
|
||||
|
||||
def lightPopulatedDidChange(self, value):
|
||||
command = InspectPropertyChangeCommand(self.editorSession,
|
||||
self.tr("Change chunk (%s, %s) property LightPopulated")
|
||||
% self.currentChunk.chunkPosition)
|
||||
with command.begin():
|
||||
self.currentChunk.rootTag["Level"]["LightPopulated"].value = value
|
||||
self.editorSession.pushCommand(command)
|
||||
|
||||
def inhabitedTimeDidChange(self, value):
|
||||
command = InspectPropertyChangeCommand(self.editorSession,
|
||||
self.tr("Change chunk (%s, %s) property InhabitedTime")
|
||||
% self.currentChunk.chunkPosition)
|
||||
with command.begin():
|
||||
self.currentChunk.rootTag["Level"]["InhabitedTime"].value = value
|
||||
self.editorSession.pushCommand(command)
|
||||
|
||||
def updateTimeDidChange(self, value):
|
||||
command = InspectPropertyChangeCommand(self.editorSession,
|
||||
self.tr("Change chunk (%s, %s) property LastUpdate")
|
||||
% self.currentChunk.chunkPosition)
|
||||
with command.begin():
|
||||
self.currentChunk.rootTag["Level"]["LastUpdate"].value = value
|
||||
self.editorSession.pushCommand(command)
|
||||
|
||||
def chunkTabDidChange(self, index):
|
||||
if self.chunkTabWidget.widget(index) is self.chunkPropertiesTab:
|
||||
self.updateChunkWidget()
|
||||
else: # NBT tab
|
||||
pass
|
||||
|
||||
def updateChunkNBTView(self):
|
||||
chunk = self.currentChunk
|
||||
if chunk is None:
|
||||
self.chunkNBTEditor.setRootTagRef(None)
|
||||
return
|
||||
|
||||
self.chunkNBTEditor.setRootTagRef(chunk)
|
||||
#
|
||||
# def chunkPositionDidChange(self):
|
||||
# cx = self.cxSpinBox.value()
|
||||
# cz = self.czSpinBox.value()
|
||||
# self.selectChunk(cx, cz)
|
||||
|
||||
class InspectPropertyChangeCommand(SimpleRevisionCommand):
|
||||
pass
|
Reference in New Issue
Block a user