mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-02 13:56:39 +00:00
90840bd0a0
1) Canvas window: clear new canvases w/ [-1, -1] by default. 2) Canvas window: don't create new canvas on initialisation. 3) Canvas window: set default brush colours to [3, 9]. 4) Erase tool: correctly fill non-text cells w/ background colour. 5) GUI: correctly show current operator name in status bar whilst active. 6) GUI: {de,in}crease canvas {height,width} w/ <Ctrl> & cursor keys. 7) GUI: disable tiling items unless current tool is object tool. 8) GUI: select tool w/ <F2-F10> accelerators.
33 lines
1.9 KiB
Python
33 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
#
|
|
# ToolErase.py
|
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
|
#
|
|
|
|
from Tool import Tool
|
|
|
|
class ToolErase(Tool):
|
|
name = "Erase"
|
|
|
|
def onMouseEvent(self, atPoint, brushColours, brushPos, brushSize, canvas, keyModifiers, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown):
|
|
brushColours, brushSize, isCursor, patches, patchesCursor = list(brushColours), list(brushSize), not (mouseLeftDown or mouseRightDown), [], []
|
|
if brushSize[0] > 1:
|
|
brushSize[0] *= 2
|
|
for brushRow in range(brushSize[1]):
|
|
for brushCol in range(brushSize[0]):
|
|
if mouseLeftDown:
|
|
patches += [[mapPoint[0] + brushCol, mapPoint[1] + brushRow, brushColours[1], brushColours[1], 0, " "]]
|
|
elif mouseRightDown \
|
|
and ((mapPoint[0] + brushCol) < canvas.size[0]) \
|
|
and ((mapPoint[1] + brushRow) < canvas.size[1]) \
|
|
and (canvas.map[mapPoint[1] + brushRow][mapPoint[0] + brushCol][1] == brushColours[1]):
|
|
if canvas.map[mapPoint[1] + brushRow][mapPoint[0] + brushCol][3] == " ":
|
|
patches += [[mapPoint[0] + brushCol, mapPoint[1] + brushRow, brushColours[0], brushColours[0], *canvas.map[mapPoint[1] + brushRow][mapPoint[0] + brushCol][2:]]]
|
|
else:
|
|
patches += [[mapPoint[0] + brushCol, mapPoint[1] + brushRow, canvas.map[mapPoint[1] + brushRow][mapPoint[0] + brushCol][0], brushColours[0], *canvas.map[mapPoint[1] + brushRow][mapPoint[0] + brushCol][2:]]]
|
|
else:
|
|
patchesCursor += [[mapPoint[0] + brushCol, mapPoint[1] + brushRow, brushColours[1], brushColours[1], 0, " "]]
|
|
return True, patches if not isCursor else None, patchesCursor
|
|
|
|
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120
|