Closer to actually editing
This commit is contained in:
@@ -9,6 +9,8 @@ from PyQt5.QtWidgets import (
|
||||
QAction, QFileDialog, QLineEdit, QMessageBox
|
||||
)
|
||||
from editortool.map.glwidget import GLWidget
|
||||
from editortool.map.chunkpanel import ChunkPanel
|
||||
from editortool.map.mapinfopanel import MapInfoPanel
|
||||
|
||||
class MapWindow(QMainWindow):
|
||||
def __init__(self):
|
||||
@@ -45,41 +47,10 @@ class MapWindow(QMainWindow):
|
||||
|
||||
main_layout = QHBoxLayout(central)
|
||||
|
||||
# Left panel
|
||||
left_panel = QVBoxLayout()
|
||||
chunk_info_label = QLabel("CHUNK INFO")
|
||||
left_panel.addWidget(chunk_info_label)
|
||||
|
||||
# Movement controls
|
||||
move_label = QLabel("Move Selection")
|
||||
left_panel.addWidget(move_label)
|
||||
btn_n = QPushButton("N")
|
||||
btn_s = QPushButton("S")
|
||||
btn_e = QPushButton("E")
|
||||
btn_w = QPushButton("W")
|
||||
btn_up = QPushButton("Up")
|
||||
btn_down = QPushButton("Down")
|
||||
left_panel.addWidget(btn_n)
|
||||
left_panel.addWidget(btn_s)
|
||||
left_panel.addWidget(btn_e)
|
||||
left_panel.addWidget(btn_w)
|
||||
left_panel.addWidget(btn_up)
|
||||
left_panel.addWidget(btn_down)
|
||||
left_panel.addStretch()
|
||||
|
||||
# Right panel
|
||||
right_panel = QVBoxLayout()
|
||||
map_info_label = QLabel("Map Information")
|
||||
right_panel.addWidget(map_info_label)
|
||||
map_title_label = QLabel("Map Title")
|
||||
self.map_title_input = QLineEdit()
|
||||
right_panel.addWidget(map_title_label)
|
||||
right_panel.addWidget(self.map_title_input)
|
||||
right_panel.addStretch()
|
||||
|
||||
# Add panels to main layout
|
||||
# Left panel (ChunkPanel)
|
||||
self.chunk_panel = ChunkPanel()
|
||||
left_widget = QWidget()
|
||||
left_widget.setLayout(left_panel)
|
||||
left_widget.setLayout(self.chunk_panel.layout())
|
||||
left_widget.setFixedWidth(200)
|
||||
main_layout.addWidget(left_widget)
|
||||
|
||||
@@ -87,21 +58,15 @@ class MapWindow(QMainWindow):
|
||||
self.gl_widget = GLWidget(self)
|
||||
main_layout.addWidget(self.gl_widget, stretch=3)
|
||||
|
||||
right_widget = QWidget()
|
||||
right_widget.setLayout(right_panel)
|
||||
# Right panel (MapInfoPanel)
|
||||
self.map_info_panel = MapInfoPanel()
|
||||
right_widget = self.map_info_panel
|
||||
right_widget.setFixedWidth(250)
|
||||
main_layout.addWidget(right_widget)
|
||||
|
||||
self.map_title_input = self.map_info_panel.map_title_input
|
||||
self.map_title_input.textChanged.connect(self._on_map_title_changed)
|
||||
|
||||
# Connect movement buttons
|
||||
btn_n.clicked.connect(lambda: self.move_highlight(0, 1, 0))
|
||||
btn_s.clicked.connect(lambda: self.move_highlight(0, -1, 0))
|
||||
btn_e.clicked.connect(lambda: self.move_highlight(1, 0, 0))
|
||||
btn_w.clicked.connect(lambda: self.move_highlight(-1, 0, 0))
|
||||
btn_up.clicked.connect(lambda: self.move_highlight(0, 0, 1))
|
||||
btn_down.clicked.connect(lambda: self.move_highlight(0, 0, -1))
|
||||
|
||||
def _on_map_title_changed(self):
|
||||
self.dirty = True
|
||||
|
||||
@@ -109,7 +74,6 @@ class MapWindow(QMainWindow):
|
||||
self.current_file = None
|
||||
self.map_title_input.setText("")
|
||||
self.dirty = False
|
||||
# ...clear relevant data...
|
||||
|
||||
def openFile(self):
|
||||
default_dir = os.path.join(os.path.dirname(__file__), '../../assets/map/')
|
||||
@@ -123,7 +87,7 @@ class MapWindow(QMainWindow):
|
||||
self.dirty = False
|
||||
except Exception as e:
|
||||
self.map_title_input.setText("")
|
||||
# Optionally show error dialog
|
||||
QMessageBox.critical(self, "Error", f"Failed to load file:\n{e}")
|
||||
|
||||
def saveFile(self):
|
||||
if self.current_file:
|
||||
@@ -147,15 +111,7 @@ class MapWindow(QMainWindow):
|
||||
json.dump(data, f, indent=2)
|
||||
self.dirty = False
|
||||
except Exception as e:
|
||||
# Optionally show error dialog
|
||||
pass
|
||||
|
||||
def move_highlight(self, dx, dy, dz):
|
||||
self.highlighted_pos[0] += dx
|
||||
self.highlighted_pos[1] += dy
|
||||
self.highlighted_pos[2] += dz
|
||||
self.gl_widget.set_highlighted_pos(self.highlighted_pos)
|
||||
self.dirty = True
|
||||
QMessageBox.critical(self, "Error", f"Failed to save file:\n{e}")
|
||||
|
||||
def closeEvent(self, event):
|
||||
if self.dirty:
|
||||
|
||||
Reference in New Issue
Block a user