mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-22 23:36:36 +00:00
{libcanvas/Canvas,libgui/GuiCanvasPanel}.py: neither commit nor draw patches referencing cells outside of the current map.
This commit is contained in:
parent
6bd8815640
commit
f6559de704
@ -16,6 +16,10 @@ class Canvas():
|
|||||||
|
|
||||||
# {{{ dispatchPatch(self, isCursor, patch, commitUndo=True)
|
# {{{ dispatchPatch(self, isCursor, patch, commitUndo=True)
|
||||||
def dispatchPatch(self, isCursor, patch, commitUndo=True):
|
def dispatchPatch(self, isCursor, patch, commitUndo=True):
|
||||||
|
if (patch[0] >= self.size[0]) \
|
||||||
|
or (patch[1] >= self.size[1]):
|
||||||
|
return False
|
||||||
|
else:
|
||||||
patchDeltaCell = self.map[patch[1]][patch[0]]; patchDelta = [*patch[0:2], *patchDeltaCell];
|
patchDeltaCell = self.map[patch[1]][patch[0]]; patchDelta = [*patch[0:2], *patchDeltaCell];
|
||||||
if isCursor:
|
if isCursor:
|
||||||
self.journal.pushCursor(patchDelta)
|
self.journal.pushCursor(patchDelta)
|
||||||
@ -25,6 +29,7 @@ class Canvas():
|
|||||||
self.journal.pushDeltas([], []); self.dirtyJournal = True;
|
self.journal.pushDeltas([], []); self.dirtyJournal = True;
|
||||||
self.journal.updateCurrentDeltas(patch, patchDelta)
|
self.journal.updateCurrentDeltas(patch, patchDelta)
|
||||||
self._commitPatch(patch)
|
self._commitPatch(patch)
|
||||||
|
return True
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ resize(self, newSize, commitUndo=True)
|
# {{{ resize(self, newSize, commitUndo=True)
|
||||||
def resize(self, newSize, commitUndo=True):
|
def resize(self, newSize, commitUndo=True):
|
||||||
|
@ -31,7 +31,7 @@ class GuiCanvasPanel(wx.Panel):
|
|||||||
# }}}
|
# }}}
|
||||||
# {{{ dispatchPatch(self, eventDc, isCursor, patch)
|
# {{{ dispatchPatch(self, eventDc, isCursor, patch)
|
||||||
def dispatchPatch(self, eventDc, isCursor, patch):
|
def dispatchPatch(self, eventDc, isCursor, patch):
|
||||||
self.canvas.dispatchPatch(isCursor, patch, False if isCursor else True)
|
if self.canvas.dispatchPatch(isCursor, patch, False if isCursor else True):
|
||||||
self._drawPatch(eventDc, isCursor, patch)
|
self._drawPatch(eventDc, isCursor, patch)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ resize(self, newSize, commitUndo=True)
|
# {{{ resize(self, newSize, commitUndo=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user