pep8 compliance: E301 expected 1 blank line
This commit is contained in:
parent
44277200a0
commit
a81a6c3a8d
@ -39,6 +39,7 @@ class BrushMode(object):
|
||||
|
||||
def performAtPoint(self, op, point, dirtyBox):
|
||||
pass
|
||||
|
||||
def createOptions(self, panel, tool):
|
||||
pass
|
||||
|
||||
@ -46,6 +47,7 @@ class BrushMode(object):
|
||||
class Modes:
|
||||
class Fill(BrushMode):
|
||||
name = "Fill"
|
||||
|
||||
def createOptions(self, panel, tool):
|
||||
col = [
|
||||
panel.modeStyleGrid,
|
||||
@ -72,6 +74,7 @@ class Modes:
|
||||
class FloodFill(BrushMode):
|
||||
name = "Flood Fill"
|
||||
options = ['indiscriminate']
|
||||
|
||||
def createOptions(self, panel, tool):
|
||||
col = [
|
||||
panel.brushModeRow,
|
||||
@ -87,6 +90,7 @@ class Modes:
|
||||
tmpfile = tempfile.mkdtemp("FloodFillUndo")
|
||||
undoLevel = MCInfdevOldLevel(tmpfile,create=True)
|
||||
dirtyChunks = set()
|
||||
|
||||
def saveUndoChunk(cx,cz):
|
||||
if (cx,cz) in dirtyChunks: return
|
||||
dirtyChunks.add( (cx,cz) )
|
||||
@ -150,6 +154,7 @@ class Modes:
|
||||
|
||||
class Replace(Fill):
|
||||
name = "Replace"
|
||||
|
||||
def createOptions(self, panel, tool):
|
||||
return Modes.Fill.createOptions(self, panel, tool) + [panel.replaceBlockButton]
|
||||
|
||||
@ -245,6 +250,7 @@ class Modes:
|
||||
class Topsoil(Fill):
|
||||
name = "Topsoil"
|
||||
options = ['naturalEarth', 'topsoilDepth']
|
||||
|
||||
def createOptions(self, panel, tool):
|
||||
col = Modes.Fill.createOptions(self, panel, tool)
|
||||
depthRow = IntInputRow("Depth: ", ref=AttrRef(tool, 'topsoilDepth'))
|
||||
@ -382,8 +388,10 @@ class BrushOperation(Operation):
|
||||
Modes.Topsoil,
|
||||
Modes.Paste
|
||||
]
|
||||
|
||||
@property
|
||||
def noise(self): return self.options.get('brushNoise', 100)
|
||||
|
||||
@property
|
||||
def hollow(self): return self.options.get('brushHollow', False)
|
||||
|
||||
@ -520,7 +528,6 @@ class BrushOperation(Operation):
|
||||
|
||||
|
||||
class BrushPanel(Panel):
|
||||
|
||||
def __init__(self, tool):
|
||||
Panel.__init__(self)
|
||||
self.tool = tool
|
||||
@ -638,6 +645,7 @@ class BrushTool(CloneTool):
|
||||
tooltipText = "Brush\nRight-click for options"
|
||||
toolIconName = "brush"
|
||||
minimumSpacing = 1
|
||||
|
||||
def __init__(self, *args):
|
||||
CloneTool.__init__(self, *args)
|
||||
self.optionsPanel = BrushToolOptions(self)
|
||||
@ -923,6 +931,7 @@ class BrushTool(CloneTool):
|
||||
|
||||
def flip(self):
|
||||
self.decreaseBrushSize()
|
||||
|
||||
def roll(self):
|
||||
self.increaseBrushSize()
|
||||
|
||||
@ -945,9 +954,11 @@ class BrushTool(CloneTool):
|
||||
blockInfo = self.replaceBlockInfo
|
||||
else:
|
||||
blockInfo = self.blockInfo
|
||||
|
||||
class FakeLevel(MCLevel):
|
||||
filename = "Fake Level"
|
||||
materials = self.editor.level.materials
|
||||
|
||||
def __init__(self):
|
||||
self.chunkCache = {}
|
||||
|
||||
@ -955,9 +966,11 @@ class BrushTool(CloneTool):
|
||||
|
||||
zerolight = zeros((16, 16, Height), dtype='uint8')
|
||||
zerolight[:] = 15
|
||||
|
||||
def getChunk(self, cx, cz):
|
||||
if (cx, cz) in self.chunkCache:
|
||||
return self.chunkCache[cx, cz]
|
||||
|
||||
class FakeBrushChunk(pymclevel.level.FakeChunk):
|
||||
def compress(self):
|
||||
del self.world.chunkCache[self.chunkPosition]
|
||||
@ -1093,10 +1106,12 @@ class BrushTool(CloneTool):
|
||||
glVertex3f(*map(lambda a:a + 0.5, reticlePoint))
|
||||
|
||||
def updateOffsets(self): pass
|
||||
|
||||
def selectionChanged(self): pass
|
||||
|
||||
def option1(self):
|
||||
self.swapBrushStyles()
|
||||
|
||||
def option2(self):
|
||||
self.swapBrushModes()
|
||||
|
||||
|
@ -99,6 +99,7 @@ class ChunkTool(EditorTool):
|
||||
|
||||
_selectedChunks = None
|
||||
_displayList = None
|
||||
|
||||
def drawToolMarkers(self):
|
||||
if self._displayList is None:
|
||||
self._displayList = DisplayList(self._drawToolMarkers)
|
||||
@ -173,6 +174,7 @@ class ChunkTool(EditorTool):
|
||||
glDepthMask(False)
|
||||
glDrawArrays(GL_QUADS, 0, len(positions) * 4)
|
||||
glDepthMask(True)
|
||||
|
||||
@property
|
||||
def worldTooltipText(self):
|
||||
box = self.editor.selectionTool.selectionBoxInProgress()
|
||||
@ -216,6 +218,7 @@ class ChunkTool(EditorTool):
|
||||
if chunks is None:
|
||||
chunks = self.selectedChunks()
|
||||
chunks = list(chunks)
|
||||
|
||||
def _destroyChunks():
|
||||
i = 0
|
||||
chunkCount = len(chunks)
|
||||
@ -318,6 +321,7 @@ class ChunkTool(EditorTool):
|
||||
|
||||
def mouseDown(self, *args):
|
||||
return self.editor.selectionTool.mouseDown(*args)
|
||||
|
||||
def mouseUp(self, evt, *args):
|
||||
self.editor.selectionTool.mouseUp(evt, *args)
|
||||
|
||||
@ -357,6 +361,7 @@ def GeneratorPanel():
|
||||
yield
|
||||
jarStorage.downloadCurrentServer()
|
||||
yield
|
||||
|
||||
showProgress("Checking for server updates...", _check())
|
||||
versionChoice.choices = sorted(jarStorage.versions, reverse=True)
|
||||
versionChoice.choiceIndex = 0
|
||||
@ -386,6 +391,7 @@ def GeneratorPanel():
|
||||
(revealStorage, revealCache, clearCache)[i]()
|
||||
|
||||
advancedButton = Button("Advanced...", presentMenu)
|
||||
|
||||
@alertException
|
||||
def revealStorage():
|
||||
mcplatform.platform_open(jarStorage.cacheDir)
|
||||
@ -399,6 +405,7 @@ def GeneratorPanel():
|
||||
@alertException
|
||||
def clearCache():
|
||||
MCServerChunkGenerator.clearWorldCache()
|
||||
|
||||
simRow = CheckBoxLabel("Simulate world", ref=AttrRef(panel, "simulate"), tooltipText = "Simulate the world for a few seconds after generating it. Reduces the save file size by processing all of the TileTicks.")
|
||||
|
||||
simRow = Row((simRow, advancedButton), anchor="lrh")
|
||||
|
@ -251,11 +251,13 @@ class CloneToolPanel(Panel):
|
||||
scaleField.max = 8
|
||||
dv = scaleField.decrease_value
|
||||
iv = scaleField.increase_value
|
||||
|
||||
def scaleFieldDecrease():
|
||||
if scaleField.value > 1 / 8.0 and scaleField.value <= 1.0:
|
||||
scaleField.value *= 0.5
|
||||
else:
|
||||
dv()
|
||||
|
||||
def scaleFieldIncrease():
|
||||
if scaleField.value < 1.0:
|
||||
scaleField.value *= 2.0
|
||||
@ -331,6 +333,7 @@ class CloneTool(EditorTool):
|
||||
|
||||
@property
|
||||
def scaleFactor(self): return self._scaleFactor
|
||||
|
||||
@scaleFactor.setter
|
||||
def scaleFactor(self, val):
|
||||
self.rescaleLevel(val)
|
||||
@ -355,6 +358,7 @@ class CloneTool(EditorTool):
|
||||
panelClass = CloneToolPanel
|
||||
#color = (0.89, 0.65, 0.35, 0.33)
|
||||
color = (0.3 , 1.0, 0.3, 0.19)
|
||||
|
||||
def __init__(self, *args):
|
||||
self.rotation = 0
|
||||
|
||||
@ -462,6 +466,7 @@ class CloneTool(EditorTool):
|
||||
self.showPanel()
|
||||
|
||||
cloneCameraDistance = 0
|
||||
|
||||
@property
|
||||
def cameraDistance(self):
|
||||
return self.cloneCameraDistance
|
||||
@ -527,6 +532,7 @@ class CloneTool(EditorTool):
|
||||
# srcshape = roundedShape[0]/srcfactor, srcfactor, roundedShape[1]/srcfactor, srcfactor, roundedShape[2]/srcfactor, srcfactor
|
||||
#
|
||||
# newlevel = MCSchematic(xyzshape)
|
||||
#
|
||||
# def copyArray(dest, src):
|
||||
# dest.shape = intershape
|
||||
# src.shape = srcshape
|
||||
@ -760,6 +766,7 @@ class CloneTool(EditorTool):
|
||||
|
||||
def option1(self):
|
||||
self.copyAir = not self.copyAir
|
||||
|
||||
def option2(self):
|
||||
self.copyWater = not self.copyWater
|
||||
|
||||
@ -950,6 +957,7 @@ class ConstructionTool(CloneTool):
|
||||
tooltipText = "Import"
|
||||
|
||||
panelClass = ConstructionToolPanel
|
||||
|
||||
def toolEnabled(self):
|
||||
return True
|
||||
|
||||
|
@ -28,6 +28,7 @@ def alertFilterException(func):
|
||||
|
||||
class FilterModuleOptions(Widget):
|
||||
is_gl_container = True
|
||||
|
||||
def __init__(self, tool, module, *args, **kw):
|
||||
Widget.__init__(self, *args, **kw)
|
||||
rows = []
|
||||
@ -193,6 +194,7 @@ class FilterToolPanel(Panel):
|
||||
self.reload()
|
||||
|
||||
filterOptionsPanel = None
|
||||
|
||||
def saveOptions(self):
|
||||
if self.filterOptionsPanel:
|
||||
self.savedOptions[self.selectedFilterName] = self.filterOptionsPanel.options
|
||||
|
@ -19,6 +19,7 @@ from pymclevel.box import FloatBox
|
||||
|
||||
class PlayerMoveOperation(Operation):
|
||||
undoPos = None
|
||||
|
||||
def __init__(self, tool, pos, player="Player", yp = (None, None)):
|
||||
self.tool, self.pos = tool, pos
|
||||
self.yp = yp
|
||||
@ -106,6 +107,7 @@ class PlayerPositionPanel(Panel):
|
||||
tableview.row_data = lambda i: (players[i],)
|
||||
tableview.row_is_selected = lambda x: x==tableview.index
|
||||
tableview.zebra_color = (0,0,0,48)
|
||||
|
||||
def selectTableRow(i, evt):
|
||||
tableview.index = i
|
||||
|
||||
@ -237,6 +239,7 @@ class PlayerPositionTool(EditorTool):
|
||||
self.markerList = DisplayList()
|
||||
|
||||
panel = None
|
||||
|
||||
def showPanel(self):
|
||||
if not self.panel:
|
||||
self.panel = PlayerPositionPanel(self)
|
||||
@ -391,6 +394,7 @@ class PlayerSpawnPositionTool(PlayerPositionTool):
|
||||
|
||||
def toolEnabled(self):
|
||||
return self.editor.level.dimNo == 0
|
||||
|
||||
def showPanel(self):
|
||||
self.panel = Panel()
|
||||
button = Button("Goto Spawn", action=self.gotoSpawn)
|
||||
@ -502,6 +506,7 @@ class PlayerSpawnPositionTool(PlayerPositionTool):
|
||||
self.markerList.invalidate()
|
||||
if len(status):
|
||||
alert("Spawn point fixed. Changes: \n\n" + status)
|
||||
|
||||
@alertException
|
||||
def toolReselected(self):
|
||||
self.gotoSpawn()
|
||||
|
@ -73,7 +73,6 @@ def GetSelectionColor(colorWord = None):
|
||||
|
||||
|
||||
class SelectionToolOptions(ToolOptions):
|
||||
|
||||
def updateColors(self):
|
||||
names = [name.lower() for (name, value) in config.config.items("Selection Colors")]
|
||||
self.colorPopupButton.choices = [name.capitalize() for name in names]
|
||||
@ -95,6 +94,7 @@ class SelectionToolOptions(ToolOptions):
|
||||
|
||||
def set_colorvalue(ch):
|
||||
i = "RGB".index(ch)
|
||||
|
||||
def _set(val):
|
||||
choice = self.colorPopupButton.selectedChoice
|
||||
values = GetSelectionColor(choice)
|
||||
@ -107,6 +107,7 @@ class SelectionToolOptions(ToolOptions):
|
||||
|
||||
def get_colorvalue(ch):
|
||||
i = "RGB".index(ch)
|
||||
|
||||
def _get():
|
||||
return int(GetSelectionColor()[i] * 255)
|
||||
return _get
|
||||
@ -686,6 +687,7 @@ class SelectionTool(EditorTool):
|
||||
self.selectOtherCorner()
|
||||
|
||||
_currentCorner = 0
|
||||
|
||||
@property
|
||||
def currentCorner(self):
|
||||
return self._currentCorner
|
||||
@ -985,6 +987,7 @@ class SelectionTool(EditorTool):
|
||||
self.editor.freezeStatus("Removing entities...")
|
||||
level = self.editor.level
|
||||
editor = self.editor
|
||||
|
||||
class DeleteEntitiesOperation(Operation):
|
||||
def perform(self, recordUndo=True):
|
||||
self.undoEntities = level.getEntitiesInBox(box)
|
||||
@ -1066,6 +1069,7 @@ class SelectionTool(EditorTool):
|
||||
|
||||
class SelectionOperation(Operation):
|
||||
changedLevel = False
|
||||
|
||||
def __init__(self, selectionTool, points):
|
||||
self.selectionTool = selectionTool
|
||||
self.points = points;
|
||||
@ -1083,6 +1087,7 @@ class SelectionOperation(Operation):
|
||||
|
||||
class NudgeSelectionOperation (Operation) :
|
||||
changedLevel = False
|
||||
|
||||
def __init__(self, selectionTool, direction):
|
||||
self.selectionTool = selectionTool;
|
||||
self.direction = direction;
|
||||
|
@ -109,6 +109,7 @@ class Operation(object):
|
||||
|
||||
sch.compress()
|
||||
return sch
|
||||
|
||||
#represents a single undoable operation
|
||||
def perform(self, recordUndo=True):
|
||||
" Perform the operation. Record undo information if recordUndo"
|
||||
@ -186,6 +187,7 @@ class ThumbView(GLPerspective):
|
||||
GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY)
|
||||
|
||||
drawBackground = True
|
||||
|
||||
def gl_draw_thumb(self):
|
||||
GL.glPushAttrib(GL.GL_SCISSOR_BIT)
|
||||
r = self.rect
|
||||
@ -207,9 +209,11 @@ class BlockThumbView(Widget):
|
||||
|
||||
thumb = None
|
||||
_blockInfo = None
|
||||
|
||||
@property
|
||||
def blockInfo(self):
|
||||
return self._blockInfo
|
||||
|
||||
@blockInfo.setter
|
||||
def blockInfo(self, b):
|
||||
if self._blockInfo != b:
|
||||
@ -271,6 +275,7 @@ class BlockView(GLOrtho):
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY)
|
||||
glDisable(GL_ALPHA_TEST)
|
||||
glDisable(GL_TEXTURE_2D)
|
||||
|
||||
@property
|
||||
def tooltipText(self):
|
||||
return "{0}".format(self.blockInfo.name)
|
||||
@ -278,6 +283,7 @@ class BlockView(GLOrtho):
|
||||
|
||||
class BlockButton(ButtonBase, Panel):
|
||||
_ref = None
|
||||
|
||||
def __init__(self, materials, blockInfo=None, ref=None, recentBlocks=None, *a, **kw):
|
||||
self.allowWildcards = False
|
||||
Panel.__init__(self, *a, **kw)
|
||||
@ -346,6 +352,7 @@ class BlockButton(ButtonBase, Panel):
|
||||
def makeBlockView(bi):
|
||||
bv = BlockView(self.materials, bi)
|
||||
bv.size = (16, 16)
|
||||
|
||||
def action(evt):
|
||||
self.blockInfo = bi
|
||||
bv.mouse_up = action
|
||||
@ -452,12 +459,14 @@ class BlockPicker(Dialog):
|
||||
tableview.row_is_selected = lambda x: x == self.selectedBlockIndex
|
||||
tableview.click_row = self.selectTableRow
|
||||
draw_table_cell = tableview.draw_table_cell
|
||||
|
||||
def draw_block_table_cell(surf, i, data, cell_rect, column):
|
||||
if isinstance(data, Block):
|
||||
|
||||
tableicons[i - tableview.rows.scroll].blockInfo = data
|
||||
else:
|
||||
draw_table_cell(surf, i, data, cell_rect, column)
|
||||
|
||||
tableview.draw_table_cell = draw_block_table_cell
|
||||
tableview.width = panelWidth
|
||||
tableview.anchor = "lrbt"
|
||||
@ -466,9 +475,11 @@ class BlockPicker(Dialog):
|
||||
tableWidget = Widget()
|
||||
tableWidget.add(tableview)
|
||||
tableWidget.shrink_wrap()
|
||||
|
||||
def wdraw(*args):
|
||||
for t in tableicons:
|
||||
t.blockInfo = materials.Air
|
||||
|
||||
tableWidget.draw = wdraw
|
||||
self.blockButton = blockView = BlockThumbView(materials, self.blockInfo)
|
||||
|
||||
@ -591,6 +602,7 @@ class EditorTool(object):
|
||||
previewRenderer = None
|
||||
|
||||
tooltipText = "???"
|
||||
|
||||
def levelChanged(self):
|
||||
""" called after a level change """
|
||||
pass
|
||||
@ -598,6 +610,7 @@ class EditorTool(object):
|
||||
@property
|
||||
def statusText(self):
|
||||
return ""
|
||||
|
||||
@property
|
||||
def cameraDistance(self):
|
||||
return self.editor.cameraToolDistance
|
||||
@ -616,6 +629,7 @@ class EditorTool(object):
|
||||
|
||||
def drawTerrainReticle(self):
|
||||
pass
|
||||
|
||||
def drawTerrainMarkers(self):
|
||||
pass
|
||||
|
||||
@ -629,9 +643,13 @@ class EditorTool(object):
|
||||
glDisable(GL_POLYGON_OFFSET_FILL)
|
||||
|
||||
def rotate(self, amount=1): pass
|
||||
|
||||
def roll(self, amount=1): pass
|
||||
|
||||
def flip(self, amount=1): pass
|
||||
|
||||
def mirror(self, amount=1): pass
|
||||
|
||||
def swap(self, amount=1): pass
|
||||
|
||||
def mouseDown(self, evt, pos, direction):
|
||||
@ -640,6 +658,7 @@ class EditorTool(object):
|
||||
its action on the specified block'''
|
||||
|
||||
pass;
|
||||
|
||||
def mouseUp(self, evt, pos, direction):
|
||||
pass;
|
||||
|
||||
@ -649,9 +668,11 @@ class EditorTool(object):
|
||||
def increaseToolReach(self):
|
||||
"Return True if the tool handles its own reach"
|
||||
return False
|
||||
|
||||
def decreaseToolReach(self):
|
||||
"Return True if the tool handles its own reach"
|
||||
return False
|
||||
|
||||
def resetToolReach(self):
|
||||
"Return True if the tool handles its own reach"
|
||||
return False
|
||||
@ -659,6 +680,7 @@ class EditorTool(object):
|
||||
def confirm(self):
|
||||
''' called when user presses enter '''
|
||||
pass
|
||||
|
||||
def cancel(self):
|
||||
'''cancel the current operation. called when a different tool
|
||||
is picked, escape is pressed, or etc etc'''
|
||||
@ -714,6 +736,7 @@ class EditorTool(object):
|
||||
dim2 = dim + 2
|
||||
dim1 %= 3
|
||||
dim2 %= 3
|
||||
|
||||
def pointInBounds(point, x):
|
||||
return box.origin[x] <= point[x] <= box.maximum[x]
|
||||
|
||||
@ -844,6 +867,7 @@ class EditorTool(object):
|
||||
return Settings.blockBuffer.get() / 2 #assume block buffer in megabytes
|
||||
|
||||
def showPanel(self): pass
|
||||
|
||||
def hidePanel(self):
|
||||
if self.panel and self.panel.parent:
|
||||
self.panel.parent.remove(self.panel)
|
||||
|
Reference in New Issue
Block a user