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
|
||||
editorSession = weakrefprop()
|
||||
|
||||
modifiesWorld = False
|
||||
|
||||
def __init__(self, editorSession, *args, **kwargs):
|
||||
"""
|
||||
Initialize toolWidget here.
|
||||
@ -120,6 +122,8 @@ class EditorTool(QtCore.QObject):
|
||||
toolPicked = QtCore.Signal(object)
|
||||
|
||||
def pick(self):
|
||||
if self.editorSession.readonly and self.modifiesWorld:
|
||||
return
|
||||
self.toolPicked.emit(self.name)
|
||||
|
||||
def pickToolAction(self):
|
||||
@ -142,6 +146,7 @@ class EditorTool(QtCore.QObject):
|
||||
triggered=self.pick,
|
||||
checkable=True,
|
||||
icon=icon,
|
||||
enabled=not(self.editorSession.readonly and self.modifiesWorld)
|
||||
)
|
||||
action.toolName = name
|
||||
|
||||
|
@ -112,6 +112,8 @@ class BrushTool(EditorTool):
|
||||
iconName = "brush"
|
||||
maxBrushSize = 512
|
||||
|
||||
modifiesWorld = True
|
||||
|
||||
def __init__(self, editorSession, *args, **kwargs):
|
||||
super(BrushTool, self).__init__(editorSession, *args, **kwargs)
|
||||
self.toolWidget = BrushToolWidget()
|
||||
|
@ -110,6 +110,7 @@ class CloneTool(EditorTool):
|
||||
"""
|
||||
iconName = "clone"
|
||||
name = "Clone"
|
||||
modifiesWorld = True
|
||||
|
||||
def __init__(self, editorSession, *args, **kwargs):
|
||||
super(CloneTool, self).__init__(editorSession, *args, **kwargs)
|
||||
|
@ -19,6 +19,7 @@ log = logging.getLogger(__name__)
|
||||
class FloodFillTool(EditorTool):
|
||||
name = "Flood Fill"
|
||||
iconName = "flood_fill"
|
||||
modifiesWorld = True
|
||||
|
||||
def mousePress(self, event):
|
||||
pos = event.blockPosition
|
||||
|
@ -147,6 +147,7 @@ class GenerateTool(EditorTool):
|
||||
iconName = "generate"
|
||||
|
||||
instantDisplayChunks = 32
|
||||
modifiesWorld = True
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
EditorTool.__init__(self, *args, **kwargs)
|
||||
|
@ -98,6 +98,7 @@ class MoveFinishCommand(SimpleRevisionCommand):
|
||||
class MoveTool(EditorTool):
|
||||
iconName = "move"
|
||||
name = "Move"
|
||||
modifiesWorld = True
|
||||
|
||||
def __init__(self, editorSession, *args, **kwargs):
|
||||
super(MoveTool, self).__init__(editorSession, *args, **kwargs)
|
||||
|
Reference in New Issue
Block a user