Map exec
This commit is contained in:
@@ -131,12 +131,12 @@ class Chunk:
|
||||
return self.dirty
|
||||
|
||||
def getFilename(self):
|
||||
if not self.map or not hasattr(self.map, 'getMapDirectory'):
|
||||
if not self.map or not hasattr(self.map, 'getChunkDirectory'):
|
||||
return None
|
||||
dir_path = self.map.getMapDirectory()
|
||||
if dir_path is None:
|
||||
dirPath = self.map.getChunkDirectory()
|
||||
if dirPath is None:
|
||||
return None
|
||||
return f"{dir_path}/{self.x}_{self.y}_{self.z}.json"
|
||||
return f"{dirPath}/{self.x}_{self.y}_{self.z}.json"
|
||||
|
||||
def draw(self):
|
||||
self.vertexBuffer.draw()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import json
|
||||
import sys
|
||||
from dusk.event import Event
|
||||
from PyQt5.QtWidgets import QFileDialog, QMessageBox
|
||||
from PyQt5.QtCore import QTimer
|
||||
@@ -129,11 +130,17 @@ class Map:
|
||||
return self.mapFileName if self.mapFileName and os.path.exists(self.mapFileName) else None
|
||||
|
||||
def getMapDirectory(self):
|
||||
fname = self.getMapFilename()
|
||||
if not fname or not fname.endswith('.json'):
|
||||
if self.mapFileName is None:
|
||||
return None
|
||||
return fname[:-5] # Remove '.json' extension
|
||||
|
||||
dirname = os.path.dirname(self.mapFileName)
|
||||
return dirname
|
||||
|
||||
def getChunkDirectory(self):
|
||||
dirName = self.getMapDirectory()
|
||||
if dirName is None:
|
||||
return None
|
||||
return os.path.join(dirName, 'chunks')
|
||||
|
||||
def anyChunksDirty(self):
|
||||
for chunk in self.chunks.values():
|
||||
if chunk.isDirty():
|
||||
|
||||
Reference in New Issue
Block a user