BlockTypeButton is now able to respond to the editorSession's signal configuredBlocksChanged

Changed textureAtlas back to editorSession
This commit is contained in:
David Vierra 2015-05-02 06:04:41 -10:00
parent c1b59f5365
commit 460a6f1dde
6 changed files with 21 additions and 17 deletions

View File

@ -15,7 +15,7 @@ class FillCommandWidget(QtGui.QDialog):
super(FillCommandWidget, self).__init__()
load_ui("fill.ui", baseinstance=self)
self.adjustSize()
self.blockTypeInput.textureAtlas = editorSession.textureAtlas
self.blockTypeInput.editorSession = editorSession
self.blockTypeInput.block = "minecraft:stone"
_fillWidget = None

View File

@ -212,14 +212,14 @@ class FindReplaceBlocks(QtCore.QObject):
return frame
leftButton = BlockTypeButton(flat=True, multipleSelect=True)
leftButton.textureAtlas = self.editorSession.textureAtlas
leftButton.editorSession = self.editorSession
leftButton.blocks = oldBlocks
leftFramedButton = frameButton(leftButton)
left.setSizeHint(leftFramedButton.sizeHint())
log.info("Left button")
rightButton = BlockTypeButton(flat=True)
rightButton.textureAtlas = self.editorSession.textureAtlas
rightButton.editorSession = self.editorSession
rightButton.block = newBlock
rightFramedButton = frameButton(rightButton, True)
right.setSizeHint(rightFramedButton.sizeHint())

View File

@ -696,7 +696,6 @@ class EditorSession(QtCore.QObject):
if t.name == name:
return t
def chooseTool(self, name):
oldTool = self.currentTool
self.currentTool = self.getTool(name)

View File

@ -134,7 +134,7 @@ class Fill(BrushMode):
self.optionsWidget = QtGui.QWidget()
label = QtGui.QLabel(self.tr("Fill Block:"))
self.blockTypeButton = BlockTypeButton()
self.blockTypeButton.textureAtlas = brushTool.editorSession.textureAtlas
self.blockTypeButton.editorSession = brushTool.editorSession
self.blockTypeButton.block = brushTool.editorSession.worldEditor.blocktypes['minecraft:stone']
self.blockTypeButton.blocksChanged.connect(brushTool.updateCursor)

View File

@ -31,7 +31,7 @@ class FloodFillTool(EditorTool):
self.blockTypeWidget = BlockTypeButton()
self.blockTypeWidget.block = self.editorSession.worldEditor.blocktypes["stone"]
self.blockTypeWidget.textureAtlas = self.editorSession.textureAtlas
self.blockTypeWidget.editorSession = self.editorSession
self.indiscriminateCheckBox = QtGui.QCheckBox("Ignore block meta")
self.indiscriminateCheckBox.setChecked(False)

View File

@ -498,30 +498,35 @@ class BlockTypeButton(QtGui.QPushButton):
blocksChanged = QtCore.Signal(list)
_textureAtlas = None
_editorSession = None
@property
def textureAtlas(self):
return self._textureAtlas
def editorSession(self):
return self._editorSession
@textureAtlas.setter
def textureAtlas(self, textureAtlas):
@editorSession.setter
def editorSession(self, editorSession):
"""
:type textureAtlas: mcedit2.rendering.textureatlas.TextureAtlas
:type editorSession: mcedit2.editorsession.EditorSession
"""
self._textureAtlas = textureAtlas
self.picker.textureAtlas = textureAtlas
self._editorSession = editorSession
self.picker.textureAtlas = editorSession.textureAtlas
editorSession.configuredBlocksChanged.connect(self.configuredBlocksDidChange)
self.updateView()
def configuredBlocksDidChange(self):
self.picker.textureAtlas = self.editorSession.textureAtlas
self.updateView()
def updateView(self):
if self.textureAtlas and self.blocks:
if self.editorSession and self.blocks:
log.info("Updating button with %s", self.blocks)
layout = self.layout()
if self._viewWidget:
layout.removeWidget(self._viewWidget)
self._viewWidget = BlockTypesItemWidget(self, self.blocks, self.textureAtlas)
self._viewWidget = BlockTypesItemWidget(self, self.blocks, self.editorSession.textureAtlas)
layout.addWidget(self._viewWidget)
assert isinstance(layout, QtGui.QLayout)
@ -541,7 +546,7 @@ class BlockTypeButton(QtGui.QPushButton):
@blocks.setter
def blocks(self, value):
value = [self.textureAtlas.blocktypes[block]
value = [self.editorSession.blocktypes[block]
if not isinstance(block, BlockType)
else block
for block in value]