Make currentViewSetting into a settingsOption, cleanup, auto-format, add notes
This commit is contained in:
parent
1337312fc6
commit
369b4e375e
@ -83,7 +83,6 @@ class PluginsTableModel(QtCore.QAbstractTableModel):
|
|||||||
|
|
||||||
self.dataChanged.emit(index, index)
|
self.dataChanged.emit(index, index)
|
||||||
|
|
||||||
|
|
||||||
def flags(self, index):
|
def flags(self, index):
|
||||||
column = index.column()
|
column = index.column()
|
||||||
if column == 1:
|
if column == 1:
|
||||||
|
|||||||
@ -399,17 +399,17 @@ class MCEditApp(QtGui.QApplication):
|
|||||||
socket = QtNetwork.QLocalSocket()
|
socket = QtNetwork.QLocalSocket()
|
||||||
socket.connectToServer(serverName)
|
socket.connectToServer(serverName)
|
||||||
if socket.waitForConnected(500):
|
if socket.waitForConnected(500):
|
||||||
# xxx maybe write argv to the running app and have it open files?
|
# TODO: get filenames from argv and pass to running app
|
||||||
log.error("%s already running", serverName)
|
log.error("%s already running", serverName)
|
||||||
raise SystemExit # Already running
|
raise SystemExit # Already running
|
||||||
|
|
||||||
def newConnection():
|
def newConnection():
|
||||||
newSocket = server.nextPendingConnection()
|
newSocket = server.nextPendingConnection()
|
||||||
|
# TODO: read filenames from socket
|
||||||
newSocket.close()
|
newSocket.close()
|
||||||
self.mainWindow.activateWindow()
|
self.mainWindow.activateWindow()
|
||||||
self.mainWindow.raise_()
|
self.mainWindow.raise_()
|
||||||
|
|
||||||
|
|
||||||
server = QtNetwork.QLocalServer(newConnection=newConnection)
|
server = QtNetwork.QLocalServer(newConnection=newConnection)
|
||||||
server._listener = newConnection
|
server._listener = newConnection
|
||||||
server.listen(serverName)
|
server.listen(serverName)
|
||||||
@ -455,9 +455,10 @@ class MCEditApp(QtGui.QApplication):
|
|||||||
if fps is not None:
|
if fps is not None:
|
||||||
self.fpsLabel.setText("%0.1f fps" % fps)
|
self.fpsLabel.setText("%0.1f fps" % fps)
|
||||||
|
|
||||||
|
|
||||||
idleTime = 333
|
idleTime = 333
|
||||||
|
|
||||||
|
# --- Global chunk loading timer ---
|
||||||
|
|
||||||
@profiler.function
|
@profiler.function
|
||||||
def loadTimerFired(self):
|
def loadTimerFired(self):
|
||||||
session = self.currentSession()
|
session = self.currentSession()
|
||||||
@ -474,6 +475,8 @@ class MCEditApp(QtGui.QApplication):
|
|||||||
log.debug("Loading timer idle (no chunks)")
|
log.debug("Loading timer idle (no chunks)")
|
||||||
self.loadTimer.setInterval(self.idleTime)
|
self.loadTimer.setInterval(self.idleTime)
|
||||||
|
|
||||||
|
# --- Update UI after tab change ---
|
||||||
|
|
||||||
def sessionDidChange(self, session, previousSession):
|
def sessionDidChange(self, session, previousSession):
|
||||||
"""
|
"""
|
||||||
:type session: EditorSession
|
:type session: EditorSession
|
||||||
@ -539,7 +542,6 @@ class MCEditApp(QtGui.QApplication):
|
|||||||
|
|
||||||
session.focusWorldView()
|
session.focusWorldView()
|
||||||
|
|
||||||
|
|
||||||
def removeSessionDockWidgets(self):
|
def removeSessionDockWidgets(self):
|
||||||
for dw in self.sessionDockWidgets:
|
for dw in self.sessionDockWidgets:
|
||||||
self.mainWindow.removeDockWidget(dw)
|
self.mainWindow.removeDockWidget(dw)
|
||||||
@ -683,7 +685,6 @@ class MCEditApp(QtGui.QApplication):
|
|||||||
fileLoadingDialog.setMaximum(max)
|
fileLoadingDialog.setMaximum(max)
|
||||||
fileLoadingDialog.setLabelText(status)
|
fileLoadingDialog.setLabelText(status)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resourceLoader = self.getResourceLoaderForFilename(filename)
|
resourceLoader = self.getResourceLoaderForFilename(filename)
|
||||||
configuredBlocks = self.configureBlocksDialog.getConfiguredBlocks()
|
configuredBlocks = self.configureBlocksDialog.getConfiguredBlocks()
|
||||||
|
|||||||
@ -42,13 +42,15 @@ from mceditlib.revisionhistory import UndoFolderExists
|
|||||||
from mceditlib.worldeditor import WorldEditor
|
from mceditlib.worldeditor import WorldEditor
|
||||||
from mceditlib.blocktypes import BlockType
|
from mceditlib.blocktypes import BlockType
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
"""
|
|
||||||
An EditorSession is a world currently opened for editing, the state of the editor including the current
|
sessionSettings = Settings().getNamespace("editorsession")
|
||||||
selection box, the editor tab containing its viewports, its command history, a separate instance of each editor
|
currentViewSetting = sessionSettings.getOption("currentview", unicode, "cam")
|
||||||
tool (why?), and the ChunkLoader that coordinates loading chunks into its viewports.
|
|
||||||
"""
|
# An EditorSession is a world currently opened for editing, the state of the editor including the
|
||||||
|
# current selection box, the editor tab containing its viewports, its command history, its shared OpenGL context,
|
||||||
|
# a separate instance of each editor tool (why?), and the ChunkLoader that coordinates loading
|
||||||
|
# chunks into its viewports.
|
||||||
|
|
||||||
class PendingImport(object):
|
class PendingImport(object):
|
||||||
def __init__(self, schematic, pos, text):
|
def __init__(self, schematic, pos, text):
|
||||||
@ -63,6 +65,7 @@ class PendingImport(object):
|
|||||||
def bounds(self):
|
def bounds(self):
|
||||||
return BoundingBox(self.pos, self.schematic.getDimension().bounds.size)
|
return BoundingBox(self.pos, self.schematic.getDimension().bounds.size)
|
||||||
|
|
||||||
|
|
||||||
class PasteImportCommand(QtGui.QUndoCommand):
|
class PasteImportCommand(QtGui.QUndoCommand):
|
||||||
def __init__(self, editorSession, pendingImport, text, *args, **kwargs):
|
def __init__(self, editorSession, pendingImport, text, *args, **kwargs):
|
||||||
super(PasteImportCommand, self).__init__(*args, **kwargs)
|
super(PasteImportCommand, self).__init__(*args, **kwargs)
|
||||||
@ -77,8 +80,10 @@ class PasteImportCommand(QtGui.QUndoCommand):
|
|||||||
self.editorSession.moveTool.addPendingImport(self.pendingImport)
|
self.editorSession.moveTool.addPendingImport(self.pendingImport)
|
||||||
self.editorSession.chooseTool("Move")
|
self.editorSession.chooseTool("Move")
|
||||||
|
|
||||||
|
|
||||||
class EditorSession(QtCore.QObject):
|
class EditorSession(QtCore.QObject):
|
||||||
def __init__(self, filename, resourceLoader, configuredBlocks, readonly=False, progressCallback=None):
|
def __init__(self, filename, resourceLoader, configuredBlocks, readonly=False,
|
||||||
|
progressCallback=None):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
:param filename:
|
:param filename:
|
||||||
@ -111,6 +116,10 @@ class EditorSession(QtCore.QObject):
|
|||||||
QtCore.QObject.__init__(self)
|
QtCore.QObject.__init__(self)
|
||||||
self.undoStack = MCEUndoStack()
|
self.undoStack = MCEUndoStack()
|
||||||
|
|
||||||
|
self.loader = None
|
||||||
|
self.blockModels = None
|
||||||
|
self.textureAtlas = None
|
||||||
|
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.dockWidgets = []
|
self.dockWidgets = []
|
||||||
self.undoBlock = None
|
self.undoBlock = None
|
||||||
@ -118,7 +127,7 @@ class EditorSession(QtCore.QObject):
|
|||||||
self.dirty = False
|
self.dirty = False
|
||||||
self.configuredBlocks = None
|
self.configuredBlocks = None
|
||||||
|
|
||||||
self.copiedSchematic = None
|
self.copiedSchematic = None # xxx should be app global!!
|
||||||
""":type : WorldEditor"""
|
""":type : WorldEditor"""
|
||||||
|
|
||||||
# --- Open world editor ---
|
# --- Open world editor ---
|
||||||
@ -131,13 +140,16 @@ class EditorSession(QtCore.QObject):
|
|||||||
msgBox.setWindowTitle(self.tr("MCEdit %(version)s") % {"version": v})
|
msgBox.setWindowTitle(self.tr("MCEdit %(version)s") % {"version": v})
|
||||||
msgBox.setText(self.tr("This world was not properly closed by MCEdit."))
|
msgBox.setText(self.tr("This world was not properly closed by MCEdit."))
|
||||||
msgBox.setInformativeText(self.tr(
|
msgBox.setInformativeText(self.tr(
|
||||||
"MCEdit may have crashed. An undo history was found for this world. You may try to resume editing "
|
"MCEdit may have crashed. An undo history was found for this world. You may try "
|
||||||
"with the saved undo history, or start over with the current state of the world."))
|
"to resume editing with the saved undo history, or start over with the current "
|
||||||
|
"state of the world."))
|
||||||
resumeBtn = msgBox.addButton("Resume Editing", QtGui.QMessageBox.ApplyRole)
|
resumeBtn = msgBox.addButton("Resume Editing", QtGui.QMessageBox.ApplyRole)
|
||||||
msgBox.addButton("Discard History", QtGui.QMessageBox.DestructiveRole)
|
msgBox.addButton("Discard History", QtGui.QMessageBox.DestructiveRole)
|
||||||
# msgBox.exec_()
|
# msgBox.exec_()
|
||||||
# clicked = msgBox.clickedButton()
|
# clicked = msgBox.clickedButton()
|
||||||
clicked = None # xxxxx
|
|
||||||
|
# xxxxx resume editing not implemented in session - need to restore undo history!
|
||||||
|
clicked = None
|
||||||
resume = clicked is resumeBtn
|
resume = clicked is resumeBtn
|
||||||
try:
|
try:
|
||||||
self.worldEditor = WorldEditor(filename, readonly=readonly, resume=resume)
|
self.worldEditor = WorldEditor(filename, readonly=readonly, resume=resume)
|
||||||
@ -167,27 +179,33 @@ class EditorSession(QtCore.QObject):
|
|||||||
self.actionCopy.setShortcut(QtGui.QKeySequence.Copy)
|
self.actionCopy.setShortcut(QtGui.QKeySequence.Copy)
|
||||||
self.actionCopy.setObjectName("actionCopy")
|
self.actionCopy.setObjectName("actionCopy")
|
||||||
|
|
||||||
self.actionPaste = QtGui.QAction(self.tr("Paste"), self, triggered=self.paste, enabled=False)
|
self.actionPaste = QtGui.QAction(self.tr("Paste"), self, triggered=self.paste,
|
||||||
|
enabled=False)
|
||||||
self.actionPaste.setShortcut(QtGui.QKeySequence.Paste)
|
self.actionPaste.setShortcut(QtGui.QKeySequence.Paste)
|
||||||
self.actionPaste.setObjectName("actionPaste")
|
self.actionPaste.setObjectName("actionPaste")
|
||||||
|
|
||||||
self.actionPaste_Blocks = QtGui.QAction(self.tr("Paste Blocks"), self, triggered=self.pasteBlocks, enabled=False)
|
self.actionPaste_Blocks = QtGui.QAction(self.tr("Paste Blocks"), self,
|
||||||
|
triggered=self.pasteBlocks, enabled=False)
|
||||||
self.actionPaste_Blocks.setShortcut(QtGui.QKeySequence("Ctrl+Shift+V"))
|
self.actionPaste_Blocks.setShortcut(QtGui.QKeySequence("Ctrl+Shift+V"))
|
||||||
self.actionPaste_Blocks.setObjectName("actionPaste_Blocks")
|
self.actionPaste_Blocks.setObjectName("actionPaste_Blocks")
|
||||||
|
|
||||||
self.actionPaste_Entities = QtGui.QAction(self.tr("Paste Entities"), self, triggered=self.pasteEntities, enabled=False)
|
self.actionPaste_Entities = QtGui.QAction(self.tr("Paste Entities"), self,
|
||||||
|
triggered=self.pasteEntities, enabled=False)
|
||||||
self.actionPaste_Entities.setShortcut(QtGui.QKeySequence("Ctrl+Alt+V"))
|
self.actionPaste_Entities.setShortcut(QtGui.QKeySequence("Ctrl+Alt+V"))
|
||||||
self.actionPaste_Entities.setObjectName("actionPaste_Entities")
|
self.actionPaste_Entities.setObjectName("actionPaste_Entities")
|
||||||
|
|
||||||
self.actionClear = QtGui.QAction(self.tr("Delete"), self, triggered=self.deleteSelection, enabled=False)
|
self.actionClear = QtGui.QAction(self.tr("Delete"), self, triggered=self.deleteSelection,
|
||||||
|
enabled=False)
|
||||||
self.actionClear.setShortcut(QtGui.QKeySequence.Delete)
|
self.actionClear.setShortcut(QtGui.QKeySequence.Delete)
|
||||||
self.actionClear.setObjectName("actionClear")
|
self.actionClear.setObjectName("actionClear")
|
||||||
|
|
||||||
self.actionDeleteBlocks = QtGui.QAction(self.tr("Delete Blocks"), self, triggered=self.deleteBlocks, enabled=False)
|
self.actionDeleteBlocks = QtGui.QAction(self.tr("Delete Blocks"), self,
|
||||||
|
triggered=self.deleteBlocks, enabled=False)
|
||||||
self.actionDeleteBlocks.setShortcut(QtGui.QKeySequence("Shift+Del"))
|
self.actionDeleteBlocks.setShortcut(QtGui.QKeySequence("Shift+Del"))
|
||||||
self.actionDeleteBlocks.setObjectName("actionDeleteBlocks")
|
self.actionDeleteBlocks.setObjectName("actionDeleteBlocks")
|
||||||
|
|
||||||
self.actionDeleteEntities = QtGui.QAction(self.tr("Delete Entities"), self, triggered=self.deleteEntities, enabled=False)
|
self.actionDeleteEntities = QtGui.QAction(self.tr("Delete Entities"), self,
|
||||||
|
triggered=self.deleteEntities, enabled=False)
|
||||||
self.actionDeleteEntities.setShortcut(QtGui.QKeySequence("Shift+Alt+Del"))
|
self.actionDeleteEntities.setShortcut(QtGui.QKeySequence("Shift+Alt+Del"))
|
||||||
self.actionDeleteEntities.setObjectName("actionDeleteEntities")
|
self.actionDeleteEntities.setObjectName("actionDeleteEntities")
|
||||||
|
|
||||||
@ -195,12 +213,14 @@ class EditorSession(QtCore.QObject):
|
|||||||
self.actionFill.setShortcut(QtGui.QKeySequence("Shift+Ctrl+F"))
|
self.actionFill.setShortcut(QtGui.QKeySequence("Shift+Ctrl+F"))
|
||||||
self.actionFill.setObjectName("actionFill")
|
self.actionFill.setObjectName("actionFill")
|
||||||
|
|
||||||
self.actionFindReplace = QtGui.QAction(self.tr("Find/Replace"), self, triggered=self.findReplace, enabled=True)
|
self.actionFindReplace = QtGui.QAction(self.tr("Find/Replace"), self,
|
||||||
|
triggered=self.findReplace, enabled=True)
|
||||||
self.actionFindReplace.setShortcut(QtGui.QKeySequence.Find)
|
self.actionFindReplace.setShortcut(QtGui.QKeySequence.Find)
|
||||||
self.actionFindReplace.setObjectName("actionFindReplace")
|
self.actionFindReplace.setObjectName("actionFindReplace")
|
||||||
|
|
||||||
self.actionAnalyze = QtGui.QAction(self.tr("Analyze"), self, triggered=self.analyze, enabled=True)
|
self.actionAnalyze = QtGui.QAction(self.tr("Analyze"), self, triggered=self.analyze,
|
||||||
#self.actionAnalyze.setShortcut(QtGui.QKeySequence.Analyze)
|
enabled=True)
|
||||||
|
# self.actionAnalyze.setShortcut(QtGui.QKeySequence.Analyze)
|
||||||
self.actionAnalyze.setObjectName("actionAnalyze")
|
self.actionAnalyze.setObjectName("actionAnalyze")
|
||||||
|
|
||||||
undoAction = self.undoStack.createUndoAction(self.menuEdit)
|
undoAction = self.undoStack.createUndoAction(self.menuEdit)
|
||||||
@ -226,7 +246,6 @@ class EditorSession(QtCore.QObject):
|
|||||||
self.menuEdit.addAction(self.actionFindReplace)
|
self.menuEdit.addAction(self.actionFindReplace)
|
||||||
self.menuEdit.addAction(self.actionAnalyze)
|
self.menuEdit.addAction(self.actionAnalyze)
|
||||||
|
|
||||||
|
|
||||||
self.menus.append(self.menuEdit)
|
self.menus.append(self.menuEdit)
|
||||||
|
|
||||||
# - Select -
|
# - Select -
|
||||||
@ -304,8 +323,8 @@ class EditorSession(QtCore.QObject):
|
|||||||
def _dimChanged(f):
|
def _dimChanged(f):
|
||||||
def _changed():
|
def _changed():
|
||||||
self.gotoDimension(f)
|
self.gotoDimension(f)
|
||||||
return _changed
|
|
||||||
|
|
||||||
|
return _changed
|
||||||
|
|
||||||
dimButton = self.changeDimensionButton = QtGui.QToolButton()
|
dimButton = self.changeDimensionButton = QtGui.QToolButton()
|
||||||
dimButton.setText(self.dimensionMenuLabel(""))
|
dimButton.setText(self.dimensionMenuLabel(""))
|
||||||
@ -344,7 +363,8 @@ class EditorSession(QtCore.QObject):
|
|||||||
self.dockWidgets.append((Qt.RightDockWidgetArea, self.inspectorDockWidget))
|
self.dockWidgets.append((Qt.RightDockWidgetArea, self.inspectorDockWidget))
|
||||||
|
|
||||||
if len(self.toolActions):
|
if len(self.toolActions):
|
||||||
self.toolActions[0].trigger() # Must be called after toolChanged is connected to editorTab
|
# Must be called after toolChanged is connected to editorTab
|
||||||
|
self.toolActions[0].trigger()
|
||||||
|
|
||||||
if hasattr(progress, 'progressCount') and progress.progressCount != progressMax:
|
if hasattr(progress, 'progressCount') and progress.progressCount != progressMax:
|
||||||
log.info("Update progressMax to %d, please.", progress.progressCount)
|
log.info("Update progressMax to %d, please.", progress.progressCount)
|
||||||
@ -359,6 +379,7 @@ class EditorSession(QtCore.QObject):
|
|||||||
if self.worldEditor:
|
if self.worldEditor:
|
||||||
self.worldEditor.close()
|
self.worldEditor.close()
|
||||||
self.worldEditor = None
|
self.worldEditor = None
|
||||||
|
|
||||||
# Connecting these signals to the EditorTab creates a circular reference through
|
# Connecting these signals to the EditorTab creates a circular reference through
|
||||||
# the Qt objects, preventing the EditorSession from being destroyed
|
# the Qt objects, preventing the EditorSession from being destroyed
|
||||||
|
|
||||||
@ -434,7 +455,6 @@ class EditorSession(QtCore.QObject):
|
|||||||
blockJson['forcedRotationFlags'] = blockDef.rotationFlags
|
blockJson['forcedRotationFlags'] = blockDef.rotationFlags
|
||||||
blockJson['__configured__'] = True
|
blockJson['__configured__'] = True
|
||||||
|
|
||||||
|
|
||||||
self.configuredBlocks = configuredBlocks
|
self.configuredBlocks = configuredBlocks
|
||||||
|
|
||||||
self.blockModels = BlockModels(self.worldEditor.blocktypes, self.resourceLoader)
|
self.blockModels = BlockModels(self.worldEditor.blocktypes, self.resourceLoader)
|
||||||
@ -561,11 +581,10 @@ class EditorSession(QtCore.QObject):
|
|||||||
|
|
||||||
dimensionChanged = QtCore.Signal(object)
|
dimensionChanged = QtCore.Signal(object)
|
||||||
|
|
||||||
|
|
||||||
_dimDisplayNames = {"": "Overworld",
|
_dimDisplayNames = {"": "Overworld",
|
||||||
"DIM-1": "Nether",
|
"DIM-1": "Nether",
|
||||||
"DIM1": "The End",
|
"DIM1": "The End",
|
||||||
}
|
}
|
||||||
|
|
||||||
def dimensionDisplayName(self, dimName):
|
def dimensionDisplayName(self, dimName):
|
||||||
return self._dimDisplayNames.get(dimName, dimName)
|
return self._dimDisplayNames.get(dimName, dimName)
|
||||||
@ -587,7 +606,6 @@ class EditorSession(QtCore.QObject):
|
|||||||
|
|
||||||
self.dimensionChanged.emit(dim)
|
self.dimensionChanged.emit(dim)
|
||||||
|
|
||||||
|
|
||||||
# - Import/export -
|
# - Import/export -
|
||||||
|
|
||||||
def import_(self):
|
def import_(self):
|
||||||
@ -676,14 +694,15 @@ class EditorSession(QtCore.QObject):
|
|||||||
|
|
||||||
def loadDone(self):
|
def loadDone(self):
|
||||||
# Called by MCEditApp after the view is on screen to make sure view.center() works correctly
|
# Called by MCEditApp after the view is on screen to make sure view.center() works correctly
|
||||||
# xxx used depthbuffer read for that, now what?
|
# xxx was needed because view.centerOnPoint used a depthbuffer read for that, now what?
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
player = self.worldEditor.getPlayer()
|
player = self.worldEditor.getPlayer()
|
||||||
center = Vector(*player.Position) + (0, 1.8, 0)
|
center = Vector(*player.Position) + (0, 1.8, 0)
|
||||||
dimNo = player.Dimension
|
dimNo = player.Dimension
|
||||||
dimName = self.worldEditor.dimNameFromNumber(dimNo)
|
dimName = self.worldEditor.dimNameFromNumber(dimNo)
|
||||||
log.info("Setting view angle to single-player player's view in dimension %s.", dimName)
|
log.info("Setting view angle to single-player player's view in dimension %s.",
|
||||||
|
dimName)
|
||||||
rotation = player.Rotation
|
rotation = player.Rotation
|
||||||
if dimName:
|
if dimName:
|
||||||
self.gotoDimension(dimName)
|
self.gotoDimension(dimName)
|
||||||
@ -703,7 +722,6 @@ class EditorSession(QtCore.QObject):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.exception("Error while centering on player for world editor: %s", e)
|
log.exception("Error while centering on player for world editor: %s", e)
|
||||||
|
|
||||||
|
|
||||||
# --- Tools ---
|
# --- Tools ---
|
||||||
|
|
||||||
def toolShortcut(self, name):
|
def toolShortcut(self, name):
|
||||||
@ -732,15 +750,19 @@ class EditorSession(QtCore.QObject):
|
|||||||
|
|
||||||
def chunkDidComplete(self):
|
def chunkDidComplete(self):
|
||||||
from mcedit2 import editorapp
|
from mcedit2 import editorapp
|
||||||
editorapp.MCEditApp.app.updateStatusLabel(None, None, None, self.loader.cps, self.editorTab.currentView().fps)
|
|
||||||
|
editorapp.MCEditApp.app.updateStatusLabel(None, None, None, self.loader.cps,
|
||||||
|
self.editorTab.currentView().fps)
|
||||||
|
|
||||||
def updateStatusFromEvent(self, event):
|
def updateStatusFromEvent(self, event):
|
||||||
from mcedit2 import editorapp
|
from mcedit2 import editorapp
|
||||||
|
|
||||||
if event.blockPosition:
|
if event.blockPosition:
|
||||||
id = self.currentDimension.getBlockID(*event.blockPosition)
|
id = self.currentDimension.getBlockID(*event.blockPosition)
|
||||||
data = self.currentDimension.getBlockData(*event.blockPosition)
|
data = self.currentDimension.getBlockData(*event.blockPosition)
|
||||||
block = self.worldEditor.blocktypes[id, data]
|
block = self.worldEditor.blocktypes[id, data]
|
||||||
biomeID = self.currentDimension.getBiomeID(event.blockPosition[0], event.blockPosition[2])
|
biomeID = self.currentDimension.getBiomeID(event.blockPosition[0],
|
||||||
|
event.blockPosition[2])
|
||||||
biome = self.biomeTypes.types.get(biomeID)
|
biome = self.biomeTypes.types.get(biomeID)
|
||||||
if biome is not None:
|
if biome is not None:
|
||||||
biomeName = biome.name
|
biomeName = biome.name
|
||||||
@ -748,9 +770,11 @@ class EditorSession(QtCore.QObject):
|
|||||||
biomeName = "Unknown biome"
|
biomeName = "Unknown biome"
|
||||||
|
|
||||||
biomeText = "%s (%d)" % (biomeName, biomeID)
|
biomeText = "%s (%d)" % (biomeName, biomeID)
|
||||||
editorapp.MCEditApp.app.updateStatusLabel(event.blockPosition, block, biomeText, self.loader.cps, event.view.fps)
|
editorapp.MCEditApp.app.updateStatusLabel(event.blockPosition, block, biomeText,
|
||||||
|
self.loader.cps, event.view.fps)
|
||||||
else:
|
else:
|
||||||
editorapp.MCEditApp.app.updateStatusLabel('(N/A)', None, None, self.loader.cps, event.view.fps)
|
editorapp.MCEditApp.app.updateStatusLabel('(N/A)', None, None, self.loader.cps,
|
||||||
|
event.view.fps)
|
||||||
|
|
||||||
def viewMousePress(self, event):
|
def viewMousePress(self, event):
|
||||||
self.updateStatusFromEvent(event)
|
self.updateStatusFromEvent(event)
|
||||||
@ -789,7 +813,8 @@ class EditorSession(QtCore.QObject):
|
|||||||
msgBox = QtGui.QMessageBox(self.editorTab.window())
|
msgBox = QtGui.QMessageBox(self.editorTab.window())
|
||||||
msgBox.setText("The world has been modified.")
|
msgBox.setText("The world has been modified.")
|
||||||
msgBox.setInformativeText("Do you want to save your changes?")
|
msgBox.setInformativeText("Do you want to save your changes?")
|
||||||
msgBox.setStandardButtons(QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel)
|
msgBox.setStandardButtons(
|
||||||
|
QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel)
|
||||||
msgBox.setDefaultButton(QtGui.QMessageBox.Save)
|
msgBox.setDefaultButton(QtGui.QMessageBox.Save)
|
||||||
ret = msgBox.exec_()
|
ret = msgBox.exec_()
|
||||||
|
|
||||||
@ -837,18 +862,16 @@ class EditorSession(QtCore.QObject):
|
|||||||
if blocktype.unknown:
|
if blocktype.unknown:
|
||||||
yield blocktype.internalName
|
yield blocktype.internalName
|
||||||
|
|
||||||
|
|
||||||
class EditorTab(QtGui.QWidget):
|
class EditorTab(QtGui.QWidget):
|
||||||
"""
|
|
||||||
EditorTab is the widget containing the editor viewports, the minimap, and
|
|
||||||
the settings panel for the currently selected tool.
|
|
||||||
"""
|
|
||||||
def __init__(self, editorSession):
|
def __init__(self, editorSession):
|
||||||
"""
|
"""
|
||||||
|
EditorTab is the widget containing the editor viewports, the minimap, and
|
||||||
|
the settings panel for the currently selected tool and its dockwidget.
|
||||||
|
|
||||||
:type editorSession: mcedit2.editorsession.EditorSession
|
:type editorSession: mcedit2.editorsession.EditorSession
|
||||||
:rtype: EditorTab
|
:rtype: EditorTab
|
||||||
"""
|
"""
|
||||||
settings = Settings()
|
|
||||||
|
|
||||||
QtGui.QWidget.__init__(self)
|
QtGui.QWidget.__init__(self)
|
||||||
self.setContentsMargins(0, 0, 0, 0)
|
self.setContentsMargins(0, 0, 0, 0)
|
||||||
@ -863,11 +886,11 @@ class EditorTab(QtGui.QWidget):
|
|||||||
self.views = []
|
self.views = []
|
||||||
|
|
||||||
for name, handler in (
|
for name, handler in (
|
||||||
("2D", self.showCutawayView),
|
("2D", self.showCutawayView),
|
||||||
("Over", self.showOverheadView),
|
("Over", self.showOverheadView),
|
||||||
# ("Iso", self.showIsoView),
|
# ("Iso", self.showIsoView),
|
||||||
("Cam", self.showCameraView),
|
("Cam", self.showCameraView),
|
||||||
# ("4-up", self.showFourUpView),
|
# ("4-up", self.showFourUpView),
|
||||||
):
|
):
|
||||||
button = QtGui.QToolButton(text=name, checkable=True)
|
button = QtGui.QToolButton(text=name, checkable=True)
|
||||||
button.clicked.connect(handler)
|
button.clicked.connect(handler)
|
||||||
@ -917,7 +940,7 @@ class EditorTab(QtGui.QWidget):
|
|||||||
self.setLayout(Column(self.viewButtonToolbar,
|
self.setLayout(Column(self.viewButtonToolbar,
|
||||||
Row(self.viewStack, margin=0), margin=0))
|
Row(self.viewStack, margin=0), margin=0))
|
||||||
|
|
||||||
currentViewName = settings.value("mainwindow/currentview", "Cam")
|
currentViewName = currentViewSetting.value()
|
||||||
if currentViewName not in self.viewButtons:
|
if currentViewName not in self.viewButtons:
|
||||||
currentViewName = "Cam"
|
currentViewName = "Cam"
|
||||||
self.viewButtons[currentViewName].click()
|
self.viewButtons[currentViewName].click()
|
||||||
@ -930,6 +953,7 @@ class EditorTab(QtGui.QWidget):
|
|||||||
view.destroy()
|
view.destroy()
|
||||||
|
|
||||||
super(EditorTab, self).destroy()
|
super(EditorTab, self).destroy()
|
||||||
|
|
||||||
editorSession = weakrefprop()
|
editorSession = weakrefprop()
|
||||||
|
|
||||||
def configuredBlocksDidChange(self):
|
def configuredBlocksDidChange(self):
|
||||||
@ -946,7 +970,8 @@ class EditorTab(QtGui.QWidget):
|
|||||||
self.toolOptionsArea.takeWidget() # setWidget gives ownership to the scroll area
|
self.toolOptionsArea.takeWidget() # setWidget gives ownership to the scroll area
|
||||||
self.toolOptionsArea.setWidget(tool.toolWidget)
|
self.toolOptionsArea.setWidget(tool.toolWidget)
|
||||||
self.toolOptionsDockWidget.setWindowTitle(self.tr(tool.name) + self.tr(" Tool Options"))
|
self.toolOptionsDockWidget.setWindowTitle(self.tr(tool.name) + self.tr(" Tool Options"))
|
||||||
log.info("Setting cursor %r for tool %r on view %r", tool.cursorNode, tool, self.currentView())
|
log.info("Setting cursor %r for tool %r on view %r", tool.cursorNode, tool,
|
||||||
|
self.currentView())
|
||||||
self.currentView().setToolCursor(tool.cursorNode)
|
self.currentView().setToolCursor(tool.cursorNode)
|
||||||
|
|
||||||
def saveState(self):
|
def saveState(self):
|
||||||
@ -959,7 +984,6 @@ class EditorTab(QtGui.QWidget):
|
|||||||
|
|
||||||
def viewDidChange(self, view):
|
def viewDidChange(self, view):
|
||||||
self.miniMap.centerOnPoint(view.viewCenter())
|
self.miniMap.centerOnPoint(view.viewCenter())
|
||||||
Settings().setValue("mainwindow/currentview", view.viewID)
|
|
||||||
if self.editorSession.currentTool:
|
if self.editorSession.currentTool:
|
||||||
view.setToolCursor(self.editorSession.currentTool.cursorNode)
|
view.setToolCursor(self.editorSession.currentTool.cursorNode)
|
||||||
|
|
||||||
@ -971,7 +995,6 @@ class EditorTab(QtGui.QWidget):
|
|||||||
view.setToolOverlays(overlayNodes)
|
view.setToolOverlays(overlayNodes)
|
||||||
view.setFocus()
|
view.setFocus()
|
||||||
|
|
||||||
|
|
||||||
def viewOffsetChanged(self, view):
|
def viewOffsetChanged(self, view):
|
||||||
self.miniMap.centerOnPoint(view.viewCenter())
|
self.miniMap.centerOnPoint(view.viewCenter())
|
||||||
self.miniMap.currentViewMatrixChanged(view)
|
self.miniMap.currentViewMatrixChanged(view)
|
||||||
@ -1007,6 +1030,7 @@ class EditorTab(QtGui.QWidget):
|
|||||||
|
|
||||||
def showOverheadView(self):
|
def showOverheadView(self):
|
||||||
self.showViewFrame(self.overheadViewFrame)
|
self.showViewFrame(self.overheadViewFrame)
|
||||||
|
|
||||||
#
|
#
|
||||||
# def showIsoView(self):
|
# def showIsoView(self):
|
||||||
# self.showViewFrame(self.isoViewFrame)
|
# self.showViewFrame(self.isoViewFrame)
|
||||||
|
|||||||
Reference in New Issue
Block a user