Fixed some stuff, procrastinating the real problem
This commit is contained in:
@@ -1,15 +1,9 @@
|
||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QLineEdit, QPushButton, QHBoxLayout, QMessageBox
|
||||
from editortool.map.map import map
|
||||
from dusk.defs import defs
|
||||
|
||||
chunkWidth = int(defs.get('CHUNK_WIDTH'))
|
||||
chunkHeight = int(defs.get('CHUNK_HEIGHT'))
|
||||
chunkDepth = int(defs.get('CHUNK_DEPTH'))
|
||||
from editortool.map.mapdefs import CHUNK_WIDTH, CHUNK_HEIGHT, CHUNK_DEPTH
|
||||
|
||||
class MapInfoPanel(QWidget):
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, parent):
|
||||
super().__init__(parent)
|
||||
|
||||
self.parent = parent
|
||||
|
||||
# Components
|
||||
@@ -36,9 +30,9 @@ class MapInfoPanel(QWidget):
|
||||
tilePositionRow.addWidget(self.tileGo)
|
||||
layout.addLayout(tilePositionRow)
|
||||
|
||||
self.chunkPosLabel = QLabel("Chunk Position: 0, 0, 0")
|
||||
self.chunkPosLabel = QLabel()
|
||||
layout.addWidget(self.chunkPosLabel)
|
||||
self.chunkLabel = QLabel("Chunk: 0, 0, 0")
|
||||
self.chunkLabel = QLabel()
|
||||
layout.addWidget(self.chunkLabel)
|
||||
|
||||
layout.addStretch()
|
||||
@@ -49,13 +43,12 @@ class MapInfoPanel(QWidget):
|
||||
self.tileXInput.returnPressed.connect(self.goToPosition)
|
||||
self.tileYInput.returnPressed.connect(self.goToPosition)
|
||||
self.tileZInput.returnPressed.connect(self.goToPosition)
|
||||
map.positionEvent.sub(self.updatePositionLabels)
|
||||
parent.mapData.onMapData.sub(self.onMapData)
|
||||
|
||||
self.parent.map.positionEvent.sub(self.updatePositionLabels)
|
||||
self.parent.mapData.onMapData.sub(self.onMapData)
|
||||
self.mapTitleInput.textChanged.connect(self.onMapNameChange)
|
||||
|
||||
# Initial label setting
|
||||
self.updatePositionLabels(map.position)
|
||||
self.updatePositionLabels(self.parent.map.position)
|
||||
|
||||
def goToPosition(self):
|
||||
try:
|
||||
@@ -70,11 +63,20 @@ class MapInfoPanel(QWidget):
|
||||
self.tileXInput.setText(str(pos[0]))
|
||||
self.tileYInput.setText(str(pos[1]))
|
||||
self.tileZInput.setText(str(pos[2]))
|
||||
self.chunkPosLabel.setText(f"Chunk Position: {pos[0] % chunkWidth}, {pos[1] % chunkHeight}, {pos[2] % chunkDepth}")
|
||||
self.chunkLabel.setText(f"Chunk: {pos[0] // chunkWidth}, {pos[1] // chunkHeight}, {pos[2] // chunkDepth}")
|
||||
|
||||
chunkTileX = pos[0] % CHUNK_WIDTH
|
||||
chunkTileY = pos[1] % CHUNK_HEIGHT
|
||||
chunkTileZ = pos[2] % CHUNK_DEPTH
|
||||
chunkTileIndex = chunkTileX + chunkTileY * CHUNK_WIDTH + chunkTileZ * CHUNK_WIDTH * CHUNK_HEIGHT
|
||||
self.chunkPosLabel.setText(f"Chunk Position: {chunkTileX}, {chunkTileY}, {chunkTileZ} ({chunkTileIndex})")
|
||||
|
||||
chunkX = pos[0] // CHUNK_WIDTH
|
||||
chunkY = pos[1] // CHUNK_HEIGHT
|
||||
chunkZ = pos[2] // CHUNK_DEPTH
|
||||
self.chunkLabel.setText(f"Chunk: {chunkX}, {chunkY}, {chunkZ}")
|
||||
|
||||
def onMapData(self, data):
|
||||
self.updatePositionLabels(map.position)
|
||||
self.updatePositionLabels(self.parent.map.position)
|
||||
self.mapTitleInput.setText(data.get("mapName", ""))
|
||||
|
||||
def onMapNameChange(self, text):
|
||||
|
||||
Reference in New Issue
Block a user