From bd5a67676b5473eca8b3466fa424ab4b9838b2ad Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Wed, 19 Nov 2025 13:25:58 -0600 Subject: [PATCH] Minor improvements, add east and west ramp --- assets/map/map/0_0_0.json | 2 +- tools/editortool/map/chunk.py | 1 + tools/editortool/map/chunkpanel.py | 38 ++++++++-- tools/editortool/map/menubar.py | 6 ++ tools/editortool/map/tile.py | 117 ++++++++++++++++++++--------- 5 files changed, 118 insertions(+), 46 deletions(-) diff --git a/assets/map/map/0_0_0.json b/assets/map/map/0_0_0.json index 4ba9e03..83f9443 100644 --- a/assets/map/map/0_0_0.json +++ b/assets/map/map/0_0_0.json @@ -1 +1 @@ -{"shapes": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]} \ No newline at end of file diff --git a/tools/editortool/map/chunk.py b/tools/editortool/map/chunk.py index 14b5ccd..23f6942 100644 --- a/tools/editortool/map/chunk.py +++ b/tools/editortool/map/chunk.py @@ -76,6 +76,7 @@ class Chunk: with open(fname, 'w') as f: json.dump(dataOut, f) self.dirty = False + self.onChunkData.invoke(self) except Exception as e: raise RuntimeError(f"Failed to save chunk file: {e}") diff --git a/tools/editortool/map/chunkpanel.py b/tools/editortool/map/chunkpanel.py index dbb68e3..7ac0c8b 100644 --- a/tools/editortool/map/chunkpanel.py +++ b/tools/editortool/map/chunkpanel.py @@ -35,13 +35,6 @@ class ChunkPanel(QWidget): # Add expandable tree list self.tree = QTreeWidget() self.tree.setHeaderLabel("Chunks") - # Example tree items - parentItem = QTreeWidgetItem(self.tree, ["Chunk 1"]) - childItem1 = QTreeWidgetItem(parentItem, ["Tile A"]) - childItem2 = QTreeWidgetItem(parentItem, ["Tile B"]) - parentItem2 = QTreeWidgetItem(self.tree, ["Chunk 2"]) - QTreeWidgetItem(parentItem2, ["Tile C"]) - QTreeWidgetItem(parentItem2, ["Tile D"]) self.tree.expandAll() # Expand by default, remove if you want collapsed layout.addWidget(self.tree) # Removed invalid stretch factor @@ -60,10 +53,22 @@ class ChunkPanel(QWidget): self.parent.map.onPositionChange.sub(self.onPositionChange) self.tileShapeDropdown.currentTextChanged.connect(self.onTileShapeChanged) + # For each chunk + for chunk in self.parent.map.chunks.values(): + # Create tree element + item = QTreeWidgetItem(self.tree, ["Chunk ({}, {}, {})".format(chunk.x, chunk.y, chunk.z)]) + chunk.chunkPanelTree = item + chunk.chunkPanelTree.setExpanded(True) + item.setData(0, 0, chunk) # Store chunk reference + + chunk.onChunkData.sub(self.onChunkData) + def onMapData(self, data): pass def onPositionChange(self, pos): + self.updateChunkList() + tile = self.parent.map.getTileAtWorldPos(*self.parent.map.position) if tile is None: return @@ -81,4 +86,21 @@ class ChunkPanel(QWidget): if tile is None or shape_key not in TILE_SHAPES: return - tile.setShape(TILE_SHAPES[shape_key]) \ No newline at end of file + tile.setShape(TILE_SHAPES[shape_key]) + + def updateChunkList(self): + # Clear existing items + currentChunk = self.parent.map.getChunkAtWorldPos(*self.parent.map.position) + + # Example tree items + for chunk in self.parent.map.chunks.values(): + title = "Chunk ({}, {}, {})".format(chunk.x, chunk.y, chunk.z) + if chunk == currentChunk: + title += " [C]" + if chunk.isDirty(): + title += " *" + item = chunk.chunkPanelTree + item.setText(0, title) + + def onChunkData(self, chunk): + self.updateChunkList() \ No newline at end of file diff --git a/tools/editortool/map/menubar.py b/tools/editortool/map/menubar.py index 85ecdcf..e34c416 100644 --- a/tools/editortool/map/menubar.py +++ b/tools/editortool/map/menubar.py @@ -1,5 +1,6 @@ import os from PyQt5.QtWidgets import QAction, QMenuBar, QFileDialog +from PyQt5.QtGui import QKeySequence from editortool.map.map import MAP_DEFAULT_PATH class MapMenubar: @@ -14,6 +15,11 @@ class MapMenubar: self.actionSave = QAction("Save", parent) self.actionSaveAs = QAction("Save As", parent) + self.actionNew.setShortcut(QKeySequence("Ctrl+N")) + self.actionOpen.setShortcut(QKeySequence("Ctrl+O")) + self.actionSave.setShortcut(QKeySequence("Ctrl+S")) + self.actionSaveAs.setShortcut(QKeySequence("Ctrl+Shift+S")) + self.actionNew.triggered.connect(self.newFile) self.actionOpen.triggered.connect(self.openFile) self.actionSave.triggered.connect(self.saveFile) diff --git a/tools/editortool/map/tile.py b/tools/editortool/map/tile.py index a97b961..6ad933e 100644 --- a/tools/editortool/map/tile.py +++ b/tools/editortool/map/tile.py @@ -1,5 +1,11 @@ from OpenGL.GL import * -from editortool.map.mapdefs import TILE_WIDTH, TILE_HEIGHT, TILE_DEPTH, CHUNK_WIDTH, CHUNK_HEIGHT, CHUNK_DEPTH, TILE_SHAPE_NULL, TILE_SHAPE_FLOOR, TILE_SHAPE_RAMP_NORTH +from editortool.map.mapdefs import ( + TILE_WIDTH, TILE_HEIGHT, TILE_DEPTH, + CHUNK_WIDTH, CHUNK_HEIGHT, CHUNK_DEPTH, + TILE_SHAPE_NULL, TILE_SHAPE_FLOOR, + TILE_SHAPE_RAMP_NORTH, TILE_SHAPE_RAMP_SOUTH, + TILE_SHAPE_RAMP_EAST, TILE_SHAPE_RAMP_WEST +) def getItem(arr, index, default): if index < len(arr): @@ -24,51 +30,88 @@ class Tile: self.shape = getItem(chunkData['shapes'], self.index, TILE_SHAPE_NULL) def setShape(self, shape): + if shape == self.shape: + return + self.shape = shape self.chunk.dirty = True self.chunk.tileUpdateVertices() + self.chunk.onChunkData.invoke(self.chunk) def getBaseTileModel(self): - vertices = [] - indices = [] - uvs = [] - colors = [] + vertices = [] + indices = [] + uvs = [] + colors = [] - if self.shape == TILE_SHAPE_NULL: - pass + if self.shape == TILE_SHAPE_NULL: + pass - elif self.shape == TILE_SHAPE_FLOOR: - vertices = [ - (self.posX, self.posY, self.posZ), - (self.posX + TILE_WIDTH, self.posY, self.posZ), - (self.posX + TILE_WIDTH, self.posY + TILE_HEIGHT, self.posZ), - (self.posX, self.posY + TILE_HEIGHT, self.posZ) - ] - indices = [0, 1, 2, 0, 2, 3] - uvs = [ (0, 0), (1, 0), (1, 1), (0, 1) ] - colors = [ ( 255, 255, 255, 255 ) ] * 4 - - elif self.shape == TILE_SHAPE_RAMP_NORTH: - vertices = [ - (self.posX, self.posY, self.posZ + TILE_DEPTH), - (self.posX + TILE_WIDTH, self.posY, self.posZ + TILE_DEPTH), - (self.posX + TILE_WIDTH, self.posY + TILE_HEIGHT, self.posZ), - (self.posX, self.posY + TILE_HEIGHT, self.posZ) - ] - indices = [0, 1, 2, 0, 2, 3] - uvs = [ (0, 0), (1, 0), (1, 1), (0, 1) ] - colors = [ ( 255, 0, 0, 255 ) ] * 4 + elif self.shape == TILE_SHAPE_FLOOR: + vertices = [ + (self.posX, self.posY, self.posZ), + (self.posX + TILE_WIDTH, self.posY, self.posZ), + (self.posX + TILE_WIDTH, self.posY + TILE_HEIGHT, self.posZ), + (self.posX, self.posY + TILE_HEIGHT, self.posZ) + ] + indices = [0, 1, 2, 0, 2, 3] + uvs = [ (0, 0), (1, 0), (1, 1), (0, 1) ] + colors = [ (255, 255, 255, 255) ] * 4 - else: - print("Unknown tile shape:", self.shape) - pass + elif self.shape == TILE_SHAPE_RAMP_NORTH: + vertices = [ + (self.posX, self.posY, self.posZ + TILE_DEPTH), + (self.posX + TILE_WIDTH, self.posY, self.posZ + TILE_DEPTH), + (self.posX + TILE_WIDTH, self.posY + TILE_HEIGHT, self.posZ), + (self.posX, self.posY + TILE_HEIGHT, self.posZ) + ] + indices = [0, 1, 2, 0, 2, 3] + uvs = [ (0, 0), (1, 0), (1, 1), (0, 1) ] + colors = [ (255, 0, 0, 255) ] * 4 - return { - 'vertices': vertices, - 'indices': indices, - 'uvs': uvs, - 'colors': colors - } + elif self.shape == TILE_SHAPE_RAMP_SOUTH: + vertices = [ + (self.posX, self.posY, self.posZ), + (self.posX + TILE_WIDTH, self.posY, self.posZ), + (self.posX + TILE_WIDTH, self.posY + TILE_HEIGHT, self.posZ + TILE_DEPTH), + (self.posX, self.posY + TILE_HEIGHT, self.posZ + TILE_DEPTH) + ] + indices = [0, 1, 2, 0, 2, 3] + uvs = [ (0, 0), (1, 0), (1, 1), (0, 1) ] + colors = [ (0, 255, 0, 255) ] * 4 + + elif self.shape == TILE_SHAPE_RAMP_EAST: + vertices = [ + (self.posX, self.posY, self.posZ), + (self.posX + TILE_WIDTH, self.posY, self.posZ + TILE_DEPTH), + (self.posX + TILE_WIDTH, self.posY + TILE_HEIGHT, self.posZ + TILE_DEPTH), + (self.posX, self.posY + TILE_HEIGHT, self.posZ) + ] + indices = [0, 1, 2, 0, 2, 3] + uvs = [ (0, 0), (1, 0), (1, 1), (0, 1) ] + colors = [ (0, 0, 255, 255) ] * 4 + + elif self.shape == TILE_SHAPE_RAMP_WEST: + vertices = [ + (self.posX, self.posY, self.posZ + TILE_DEPTH), + (self.posX + TILE_WIDTH, self.posY, self.posZ), + (self.posX + TILE_WIDTH, self.posY + TILE_HEIGHT, self.posZ), + (self.posX, self.posY + TILE_HEIGHT, self.posZ + TILE_DEPTH) + ] + indices = [0, 1, 2, 0, 2, 3] + uvs = [ (0, 0), (1, 0), (1, 1), (0, 1) ] + colors = [ (255, 255, 0, 255) ] * 4 + + else: + print("Unknown tile shape:", self.shape) + pass + + return { + 'vertices': vertices, + 'indices': indices, + 'uvs': uvs, + 'colors': colors + } def buffer(self, vertexBuffer): if self.shape == TILE_SHAPE_NULL: