Disable tools that modify the world when it is opened read-only
This commit is contained in:
parent
2c4bcf013c
commit
d47b184fa3
@ -57,6 +57,8 @@ class EditorTool(QtCore.QObject):
|
|||||||
overlayNode = None
|
overlayNode = None
|
||||||
editorSession = weakrefprop()
|
editorSession = weakrefprop()
|
||||||
|
|
||||||
|
modifiesWorld = False
|
||||||
|
|
||||||
def __init__(self, editorSession, *args, **kwargs):
|
def __init__(self, editorSession, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Initialize toolWidget here.
|
Initialize toolWidget here.
|
||||||
@ -120,6 +122,8 @@ class EditorTool(QtCore.QObject):
|
|||||||
toolPicked = QtCore.Signal(object)
|
toolPicked = QtCore.Signal(object)
|
||||||
|
|
||||||
def pick(self):
|
def pick(self):
|
||||||
|
if self.editorSession.readonly and self.modifiesWorld:
|
||||||
|
return
|
||||||
self.toolPicked.emit(self.name)
|
self.toolPicked.emit(self.name)
|
||||||
|
|
||||||
def pickToolAction(self):
|
def pickToolAction(self):
|
||||||
@ -142,6 +146,7 @@ class EditorTool(QtCore.QObject):
|
|||||||
triggered=self.pick,
|
triggered=self.pick,
|
||||||
checkable=True,
|
checkable=True,
|
||||||
icon=icon,
|
icon=icon,
|
||||||
|
enabled=not(self.editorSession.readonly and self.modifiesWorld)
|
||||||
)
|
)
|
||||||
action.toolName = name
|
action.toolName = name
|
||||||
|
|
||||||
|
@ -112,6 +112,8 @@ class BrushTool(EditorTool):
|
|||||||
iconName = "brush"
|
iconName = "brush"
|
||||||
maxBrushSize = 512
|
maxBrushSize = 512
|
||||||
|
|
||||||
|
modifiesWorld = True
|
||||||
|
|
||||||
def __init__(self, editorSession, *args, **kwargs):
|
def __init__(self, editorSession, *args, **kwargs):
|
||||||
super(BrushTool, self).__init__(editorSession, *args, **kwargs)
|
super(BrushTool, self).__init__(editorSession, *args, **kwargs)
|
||||||
self.toolWidget = BrushToolWidget()
|
self.toolWidget = BrushToolWidget()
|
||||||
|
@ -110,6 +110,7 @@ class CloneTool(EditorTool):
|
|||||||
"""
|
"""
|
||||||
iconName = "clone"
|
iconName = "clone"
|
||||||
name = "Clone"
|
name = "Clone"
|
||||||
|
modifiesWorld = True
|
||||||
|
|
||||||
def __init__(self, editorSession, *args, **kwargs):
|
def __init__(self, editorSession, *args, **kwargs):
|
||||||
super(CloneTool, self).__init__(editorSession, *args, **kwargs)
|
super(CloneTool, self).__init__(editorSession, *args, **kwargs)
|
||||||
|
@ -19,6 +19,7 @@ log = logging.getLogger(__name__)
|
|||||||
class FloodFillTool(EditorTool):
|
class FloodFillTool(EditorTool):
|
||||||
name = "Flood Fill"
|
name = "Flood Fill"
|
||||||
iconName = "flood_fill"
|
iconName = "flood_fill"
|
||||||
|
modifiesWorld = True
|
||||||
|
|
||||||
def mousePress(self, event):
|
def mousePress(self, event):
|
||||||
pos = event.blockPosition
|
pos = event.blockPosition
|
||||||
|
@ -147,6 +147,7 @@ class GenerateTool(EditorTool):
|
|||||||
iconName = "generate"
|
iconName = "generate"
|
||||||
|
|
||||||
instantDisplayChunks = 32
|
instantDisplayChunks = 32
|
||||||
|
modifiesWorld = True
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
EditorTool.__init__(self, *args, **kwargs)
|
EditorTool.__init__(self, *args, **kwargs)
|
||||||
|
@ -98,6 +98,7 @@ class MoveFinishCommand(SimpleRevisionCommand):
|
|||||||
class MoveTool(EditorTool):
|
class MoveTool(EditorTool):
|
||||||
iconName = "move"
|
iconName = "move"
|
||||||
name = "Move"
|
name = "Move"
|
||||||
|
modifiesWorld = True
|
||||||
|
|
||||||
def __init__(self, editorSession, *args, **kwargs):
|
def __init__(self, editorSession, *args, **kwargs):
|
||||||
super(MoveTool, self).__init__(editorSession, *args, **kwargs)
|
super(MoveTool, self).__init__(editorSession, *args, **kwargs)
|
||||||
|
Reference in New Issue
Block a user