Prepping editor more...
This commit is contained in:
@@ -2,22 +2,23 @@ from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QLineEdit, QPushButton
|
||||
from editortool.map.map import map
|
||||
from dusk.defs import defs
|
||||
|
||||
CHUNK_WIDTH = int(defs.get('CHUNK_WIDTH'))
|
||||
CHUNK_HEIGHT = int(defs.get('CHUNK_HEIGHT'))
|
||||
CHUNK_DEPTH = int(defs.get('CHUNK_DEPTH'))
|
||||
chunkWidth = int(defs.get('CHUNK_WIDTH'))
|
||||
chunkHeight = int(defs.get('CHUNK_HEIGHT'))
|
||||
chunkDepth = int(defs.get('CHUNK_DEPTH'))
|
||||
|
||||
class MapInfoPanel(QWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
layout = QVBoxLayout()
|
||||
map_info_label = QLabel("Map Information")
|
||||
layout.addWidget(map_info_label)
|
||||
self.parent = parent
|
||||
|
||||
map_title_label = QLabel("Map Title")
|
||||
self.map_title_input = QLineEdit()
|
||||
layout.addWidget(map_title_label)
|
||||
layout.addWidget(self.map_title_input)
|
||||
# Components
|
||||
layout = QVBoxLayout()
|
||||
|
||||
mapTitleLabel = QLabel("Map Title")
|
||||
self.mapTitleInput = QLineEdit()
|
||||
layout.addWidget(mapTitleLabel)
|
||||
layout.addWidget(self.mapTitleInput)
|
||||
|
||||
tilePositionLabel = QLabel("Tile Position")
|
||||
layout.addWidget(tilePositionLabel)
|
||||
@@ -43,13 +44,18 @@ class MapInfoPanel(QWidget):
|
||||
layout.addStretch()
|
||||
self.setLayout(layout)
|
||||
|
||||
# Events
|
||||
self.tileGo.clicked.connect(self.goToPosition)
|
||||
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.mapTitleInput.textChanged.connect(self.onMapNameChange)
|
||||
|
||||
# Initial label setting
|
||||
self.updatePositionLabels(map.position)
|
||||
map.addPositionListener(self.updatePositionLabels)
|
||||
|
||||
def goToPosition(self):
|
||||
try:
|
||||
@@ -64,5 +70,12 @@ 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] % CHUNK_WIDTH}, {pos[1] % CHUNK_HEIGHT}, {pos[2] % CHUNK_DEPTH}")
|
||||
self.chunkLabel.setText(f"Chunk: {pos[0] // CHUNK_WIDTH}, {pos[1] // CHUNK_HEIGHT}, {pos[2] // CHUNK_DEPTH}")
|
||||
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}")
|
||||
|
||||
def onMapData(self, data):
|
||||
self.updatePositionLabels(map.position)
|
||||
self.mapTitleInput.setText(data.get("mapName", ""))
|
||||
|
||||
def onMapNameChange(self, text):
|
||||
self.parent.mapData.data['mapName'] = text
|
||||
Reference in New Issue
Block a user