2019-09-10 10:06:56 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#
|
|
|
|
# RoarCanvasCommandsFile.py
|
|
|
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
|
|
|
#
|
|
|
|
|
|
|
|
try:
|
|
|
|
from ImgurApiKey import ImgurApiKey
|
|
|
|
haveImgurApiKey = True
|
|
|
|
except ImportError:
|
|
|
|
haveImgurApiKey = False
|
|
|
|
|
|
|
|
try:
|
|
|
|
import base64, json, requests, urllib.request
|
|
|
|
haveUrllib = True
|
|
|
|
except ImportError:
|
|
|
|
haveUrllib = False
|
|
|
|
|
2019-09-14 13:16:57 +00:00
|
|
|
from GuiFrame import GuiCommandDecorator, GuiSubMenuDecorator, NID_MENU_SEP
|
|
|
|
from RtlPlatform import getLocalConfPathName
|
2019-09-10 10:06:56 +00:00
|
|
|
import io, os, wx
|
|
|
|
|
|
|
|
class RoarCanvasCommandsFile():
|
|
|
|
def _import(self, f, newDirty, pathName):
|
2019-09-11 11:53:48 +00:00
|
|
|
rc = False
|
2019-09-10 10:06:56 +00:00
|
|
|
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
2019-09-11 11:53:48 +00:00
|
|
|
try:
|
|
|
|
rc, error, newMap, newPathName, newSize = f(pathName)
|
|
|
|
if rc:
|
2019-09-23 17:55:31 +00:00
|
|
|
self.parentCanvas.update(newSize, False, newMap, dirty=newDirty)
|
2019-09-11 11:53:48 +00:00
|
|
|
self.parentCanvas.dirty = newDirty
|
|
|
|
self.canvasPathName = newPathName
|
|
|
|
self.update(dirty=self.parentCanvas.dirty, pathName=self.canvasPathName, undoLevel=-1)
|
|
|
|
self.parentCanvas.canvas.journal.resetCursor()
|
|
|
|
self.parentCanvas.canvas.journal.resetUndo()
|
|
|
|
except FileNotFoundError as e:
|
|
|
|
rc, error, newMap, newPathName, newSize = False, str(e), None, None, None
|
|
|
|
if not rc:
|
2019-09-10 10:06:56 +00:00
|
|
|
with wx.MessageDialog(self.parentCanvas, "Error: {}".format(error), "", wx.OK | wx.OK_DEFAULT) as dialog:
|
|
|
|
dialogChoice = dialog.ShowModal()
|
|
|
|
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
2019-09-14 13:16:57 +00:00
|
|
|
return rc, newPathName
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-10 10:06:56 +00:00
|
|
|
def _importFile(self, f, newDirty, wildcard):
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
with wx.FileDialog(self.parentCanvas, "Open...", os.getcwd(), "", wildcard, wx.FD_OPEN) as dialog:
|
libroar/RoarAssetsWindow.py:{_importFiles, on{Load,Save}List,__init__}(): {pass,receive} lastDir {before,after} wx.FileDialog()s.
libroar/RoarCanvasCommandsFile.py:{_importFile,canvasExportAs{Ansi,Png},SaveAs,__init__}(): {pass,receive} lastDir {before,after} wx.FileDialog()s.
2019-09-14 09:49:08 +00:00
|
|
|
if self.lastDir != None:
|
|
|
|
dialog.SetDirectory(self.lastDir)
|
2019-09-10 10:06:56 +00:00
|
|
|
if dialog.ShowModal() == wx.ID_CANCEL:
|
2019-09-14 13:16:57 +00:00
|
|
|
return False, None
|
2019-09-10 10:06:56 +00:00
|
|
|
elif self._promptSaveChanges():
|
libroar/RoarAssetsWindow.py:{_importFiles, on{Load,Save}List,__init__}(): {pass,receive} lastDir {before,after} wx.FileDialog()s.
libroar/RoarCanvasCommandsFile.py:{_importFile,canvasExportAs{Ansi,Png},SaveAs,__init__}(): {pass,receive} lastDir {before,after} wx.FileDialog()s.
2019-09-14 09:49:08 +00:00
|
|
|
pathName = dialog.GetPath(); self.lastDir = os.path.dirname(pathName);
|
|
|
|
return self._import(f, newDirty, pathName)
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-14 13:16:57 +00:00
|
|
|
def _loadRecent(self):
|
|
|
|
localConfFileName = getLocalConfPathName("Recent.lst")
|
|
|
|
if os.path.exists(localConfFileName):
|
|
|
|
with open(localConfFileName, "r", encoding="utf-8") as inFile:
|
|
|
|
for lastFile in inFile.readlines():
|
|
|
|
self._pushRecent(lastFile.rstrip("\r\n"), False)
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-10 10:06:56 +00:00
|
|
|
def _promptSaveChanges(self):
|
|
|
|
if self.parentCanvas.dirty:
|
|
|
|
message = "Do you want to save changes to {}?".format(self.canvasPathName if self.canvasPathName != None else "(Untitled)")
|
|
|
|
with wx.MessageDialog(self.parentCanvas, message, "", wx.CANCEL | wx.CANCEL_DEFAULT | wx.ICON_QUESTION | wx.YES_NO) as dialog:
|
|
|
|
dialogChoice = dialog.ShowModal()
|
|
|
|
if dialogChoice == wx.ID_CANCEL:
|
|
|
|
return False
|
|
|
|
elif dialogChoice == wx.ID_NO:
|
|
|
|
return True
|
|
|
|
elif dialogChoice == wx.ID_YES:
|
|
|
|
return self.canvasSaveAs(None) if self.canvasPathName == None else self.canvasSave(None)
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
return True
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-14 13:16:57 +00:00
|
|
|
def _pushRecent(self, pathName, serialise=True):
|
|
|
|
menuItemId = wx.NewId()
|
|
|
|
if not pathName in [l["pathName"] for l in self.lastFiles]:
|
|
|
|
numLastFiles = len(self.lastFiles) if self.lastFiles != None else 0
|
|
|
|
if (numLastFiles + 1) > 8:
|
|
|
|
self.canvasOpenRecent.attrDict["menu"].Delete(self.lastFiles[0]["menuItemId"])
|
|
|
|
del self.lastFiles[0]
|
2019-09-23 19:37:52 +00:00
|
|
|
menuItemWindow = self.canvasOpenRecent.attrDict["menu"].Insert(self.canvasOpenRecent.attrDict["menu"].GetMenuItemCount() - 2, menuItemId, "{}".format(pathName), pathName)
|
2019-09-14 13:16:57 +00:00
|
|
|
self.parentFrame.menuItemsById[self.canvasOpenRecent.attrDict["id"]].Enable(True)
|
|
|
|
self.parentFrame.Bind(wx.EVT_MENU, lambda event: self.canvasOpenRecent(event, pathName), menuItemWindow)
|
|
|
|
self.lastFiles += [{"menuItemId":menuItemId, "menuItemWindow":menuItemWindow, "pathName":pathName}]
|
|
|
|
if serialise:
|
|
|
|
localConfFileName = getLocalConfPathName("Recent.lst")
|
|
|
|
with open(localConfFileName, "w", encoding="utf-8") as outFile:
|
|
|
|
for lastFile in [l["pathName"] for l in self.lastFiles]:
|
|
|
|
print(lastFile, file=outFile)
|
2019-09-10 10:06:56 +00:00
|
|
|
|
2019-09-23 19:37:52 +00:00
|
|
|
@GuiCommandDecorator("Clear list", "&Clear list", None, None, False)
|
|
|
|
def canvasClearRecent(self, event):
|
|
|
|
if self.lastFiles != None:
|
|
|
|
for lastFile in self.lastFiles:
|
|
|
|
self.canvasOpenRecent.attrDict["menu"].Delete(lastFile["menuItemId"])
|
|
|
|
self.lastFiles = []
|
|
|
|
localConfFileName = getLocalConfPathName("Recent.lst")
|
|
|
|
if os.path.exists(localConfFileName):
|
|
|
|
os.unlink(localConfFileName)
|
|
|
|
self.parentFrame.menuItemsById[self.canvasOpenRecent.attrDict["id"]].Enable(False)
|
|
|
|
|
2019-09-10 10:06:56 +00:00
|
|
|
@GuiCommandDecorator("Exit", "E&xit", None, [wx.ACCEL_CTRL, ord("X")], None)
|
|
|
|
def canvasExit(self, event):
|
|
|
|
if self._promptSaveChanges():
|
|
|
|
self.parentFrame.Close(True)
|
2019-09-15 10:41:14 +00:00
|
|
|
|
|
|
|
@GuiCommandDecorator("Export as ANSI...", "Export as &ANSI...", None, None, None)
|
2019-09-10 10:06:56 +00:00
|
|
|
def canvasExportAsAnsi(self, event):
|
|
|
|
with wx.FileDialog(self.parentFrame, "Save As...", os.getcwd(), "", "ANSI files (*.ans;*.txt)|*.ans;*.txt|All Files (*.*)|*.*", wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dialog:
|
libroar/RoarAssetsWindow.py:{_importFiles, on{Load,Save}List,__init__}(): {pass,receive} lastDir {before,after} wx.FileDialog()s.
libroar/RoarCanvasCommandsFile.py:{_importFile,canvasExportAs{Ansi,Png},SaveAs,__init__}(): {pass,receive} lastDir {before,after} wx.FileDialog()s.
2019-09-14 09:49:08 +00:00
|
|
|
if self.lastDir != None:
|
|
|
|
dialog.SetDirectory(self.lastDir)
|
2019-09-10 10:06:56 +00:00
|
|
|
if dialog.ShowModal() == wx.ID_CANCEL:
|
|
|
|
return False
|
|
|
|
else:
|
libroar/RoarAssetsWindow.py:{_importFiles, on{Load,Save}List,__init__}(): {pass,receive} lastDir {before,after} wx.FileDialog()s.
libroar/RoarCanvasCommandsFile.py:{_importFile,canvasExportAs{Ansi,Png},SaveAs,__init__}(): {pass,receive} lastDir {before,after} wx.FileDialog()s.
2019-09-14 09:49:08 +00:00
|
|
|
outPathName = dialog.GetPath(); self.lastDir = os.path.dirname(outPathName);
|
2019-09-10 10:06:56 +00:00
|
|
|
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
|
|
|
with open(outPathName, "w", encoding="utf-8") as outFile:
|
|
|
|
self.parentCanvas.canvas.exportStore.exportAnsiFile(self.parentCanvas.canvas.map, self.parentCanvas.canvas.size, outFile)
|
|
|
|
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
|
|
|
return True
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-10 10:06:56 +00:00
|
|
|
@GuiCommandDecorator("Export as PNG...", "Export as PN&G...", None, None, None)
|
|
|
|
def canvasExportAsPng(self, event):
|
|
|
|
with wx.FileDialog(self.parentFrame, "Save As...", os.getcwd(), "", "PNG (*.png)|*.png|All Files (*.*)|*.*", wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dialog:
|
libroar/RoarAssetsWindow.py:{_importFiles, on{Load,Save}List,__init__}(): {pass,receive} lastDir {before,after} wx.FileDialog()s.
libroar/RoarCanvasCommandsFile.py:{_importFile,canvasExportAs{Ansi,Png},SaveAs,__init__}(): {pass,receive} lastDir {before,after} wx.FileDialog()s.
2019-09-14 09:49:08 +00:00
|
|
|
if self.lastDir != None:
|
|
|
|
dialog.SetDirectory(self.lastDir)
|
2019-09-10 10:06:56 +00:00
|
|
|
if dialog.ShowModal() == wx.ID_CANCEL:
|
|
|
|
return False
|
|
|
|
else:
|
libroar/RoarAssetsWindow.py:{_importFiles, on{Load,Save}List,__init__}(): {pass,receive} lastDir {before,after} wx.FileDialog()s.
libroar/RoarCanvasCommandsFile.py:{_importFile,canvasExportAs{Ansi,Png},SaveAs,__init__}(): {pass,receive} lastDir {before,after} wx.FileDialog()s.
2019-09-14 09:49:08 +00:00
|
|
|
outPathName = dialog.GetPath(); self.lastDir = os.path.dirname(outPathName);
|
2019-09-10 10:06:56 +00:00
|
|
|
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
|
|
|
self.parentCanvas.canvas.exportStore.exportBitmapToPngFile(self.parentCanvas.backend.canvasBitmap, outPathName, wx.BITMAP_TYPE_PNG)
|
|
|
|
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
|
|
|
return True
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-10 10:06:56 +00:00
|
|
|
@GuiCommandDecorator("Export to Imgur...", "Export to I&mgur...", None, None, haveImgurApiKey and haveUrllib)
|
|
|
|
def canvasExportImgur(self, event):
|
|
|
|
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
|
|
|
rc, status, result = self.parentCanvas.canvas.exportStore.exportBitmapToImgur(self.imgurApiKey, self.parentCanvas.backend.canvasBitmap, "", "", wx.BITMAP_TYPE_PNG)
|
|
|
|
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
|
|
|
if rc:
|
|
|
|
if not wx.TheClipboard.IsOpened():
|
|
|
|
wx.TheClipboard.Open(); wx.TheClipboard.SetData(wx.TextDataObject(result)); wx.TheClipboard.Close();
|
|
|
|
wx.MessageBox("Exported to Imgur: {}".format(result), "Export to Imgur", wx.ICON_INFORMATION | wx.OK)
|
|
|
|
else:
|
|
|
|
wx.MessageBox("Failed to export to Imgur: {}".format(result), "Export to Imgur", wx.ICON_EXCLAMATION | wx.OK)
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-10 10:06:56 +00:00
|
|
|
@GuiCommandDecorator("Export to Pastebin...", "Export to Pasteb&in...", None, None, haveUrllib)
|
|
|
|
def canvasExportPastebin(self, event):
|
|
|
|
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
|
|
|
pasteStatus, pasteResult = self.parentCanvas.canvas.exportStore.exportPastebin("253ce2f0a45140ee0a44ca99aa49260", self.parentCanvas.canvas.map, self.parentCanvas.canvas.size)
|
|
|
|
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
|
|
|
if pasteStatus:
|
|
|
|
if not wx.TheClipboard.IsOpened():
|
|
|
|
wx.TheClipboard.Open()
|
|
|
|
wx.TheClipboard.SetData(wx.TextDataObject(pasteResult))
|
|
|
|
wx.TheClipboard.Close()
|
|
|
|
wx.MessageBox("Exported to Pastebin: " + pasteResult, "Export to Pastebin", wx.OK|wx.ICON_INFORMATION)
|
|
|
|
else:
|
|
|
|
wx.MessageBox("Failed to export to Pastebin: " + pasteResult, "Export to Pastebin", wx.OK|wx.ICON_EXCLAMATION)
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-15 10:41:14 +00:00
|
|
|
@GuiCommandDecorator("Export to clipboard", "Export to &clipboard", None, None, None)
|
2019-09-10 10:06:56 +00:00
|
|
|
def canvasExportToClipboard(self, event):
|
|
|
|
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
|
|
|
rc, outBuffer = self.parentCanvas.canvas.exportStore.exportTextBuffer(self.parentCanvas.canvas.map, self.parentCanvas.canvas.size)
|
|
|
|
if rc and wx.TheClipboard.Open():
|
|
|
|
wx.TheClipboard.SetData(wx.TextDataObject(outBuffer))
|
|
|
|
wx.TheClipboard.Close()
|
|
|
|
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
|
|
|
return True
|
2019-09-15 10:41:14 +00:00
|
|
|
|
|
|
|
@GuiCommandDecorator("Import ANSI...", "Import &ANSI...", None, None, None)
|
2019-09-10 10:06:56 +00:00
|
|
|
def canvasImportAnsi(self, event):
|
|
|
|
def canvasImportAnsi_(pathName):
|
|
|
|
rc, error = self.parentCanvas.canvas.importStore.importAnsiFile(pathName)
|
|
|
|
return (rc, error, self.parentCanvas.canvas.importStore.outMap, pathName, self.parentCanvas.canvas.importStore.inSize)
|
|
|
|
self._importFile(canvasImportAnsi_, True, "ANSI files (*.ans;*.txt)|*.ans;*.txt|All Files (*.*)|*.*")
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-15 10:41:14 +00:00
|
|
|
@GuiCommandDecorator("Import from clipboard", "Import from &clipboard", None, None, None)
|
2019-09-10 10:06:56 +00:00
|
|
|
def canvasImportFromClipboard(self, event):
|
|
|
|
def canvasImportFromClipboard_(pathName):
|
|
|
|
if wx.TheClipboard.IsSupported(wx.DataFormat(wx.DF_TEXT)) \
|
|
|
|
and wx.TheClipboard.Open():
|
|
|
|
inBuffer = wx.TextDataObject()
|
|
|
|
if wx.TheClipboard.GetData(inBuffer):
|
|
|
|
if self._promptSaveChanges():
|
|
|
|
rc, error = self.parentCanvas.canvas.importStore.importTextBuffer(io.StringIO(inBuffer.GetText()))
|
|
|
|
wx.TheClipboard.Close()
|
|
|
|
else:
|
|
|
|
rc, error = False, "Clipboard does not contain text data and/or cannot be opened"
|
|
|
|
return (rc, error, self.parentCanvas.canvas.importStore.outMap, None, self.parentCanvas.canvas.importStore.inSize)
|
|
|
|
if self._promptSaveChanges():
|
|
|
|
self._import(canvasImportFromClipboard_, True, None)
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-15 10:41:14 +00:00
|
|
|
@GuiCommandDecorator("Import SAUCE...", "Import &SAUCE...", None, None, None)
|
2019-09-10 10:06:56 +00:00
|
|
|
def canvasImportSauce(self, event):
|
|
|
|
def canvasImportSauce_(pathName):
|
|
|
|
rc, error = self.parentCanvas.canvas.importStore.importSauceFile(pathName)
|
|
|
|
return (rc, error, self.parentCanvas.canvas.importStore.outMap, pathName, self.parentCanvas.canvas.importStore.inSize)
|
|
|
|
self._importFile(canvasImportSauce_, True, "SAUCE files (*.ans;*.txt)|*.ans;*.txt|All Files (*.*)|*.*")
|
2019-09-15 10:41:14 +00:00
|
|
|
|
2019-09-10 10:06:56 +00:00
|
|
|
@GuiCommandDecorator("New", "&New", ["", wx.ART_NEW], [wx.ACCEL_CTRL, ord("N")], None)
|
|
|
|
def canvasNew(self, event, newCanvasSize=None):
|
|
|
|
def canvasImportEmpty(pathName):
|
|
|
|
nonlocal newCanvasSize
|
|
|
|
if newCanvasSize == None:
|
|
|
|
newCanvasSize = list(self.parentCanvas.canvas.size)
|
|
|
|
newMap = [[[1, 1, 0, " "] for x in range(newCanvasSize[0])] for y in range(newCanvasSize[1])]
|
|
|
|
return (True, "", newMap, None, newCanvasSize)
|
|
|
|
if self._promptSaveChanges():
|
|
|
|
self._import(canvasImportEmpty, False, None)
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-10 10:06:56 +00:00
|
|
|
@GuiCommandDecorator("Open", "&Open", ["", wx.ART_FILE_OPEN], [wx.ACCEL_CTRL, ord("O")], None)
|
|
|
|
def canvasOpen(self, event):
|
|
|
|
def canvasImportmIRC(pathName):
|
|
|
|
rc, error = self.parentCanvas.canvas.importStore.importTextFile(pathName)
|
|
|
|
return (rc, error, self.parentCanvas.canvas.importStore.outMap, pathName, self.parentCanvas.canvas.importStore.inSize)
|
2019-09-14 13:16:57 +00:00
|
|
|
rc, newPathName = self._importFile(canvasImportmIRC, False, "mIRC art files (*.txt)|*.txt|All Files (*.*)|*.*")
|
|
|
|
if rc:
|
|
|
|
self._pushRecent(newPathName)
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-14 13:16:57 +00:00
|
|
|
@GuiSubMenuDecorator("Open Recent", "Open &Recent", None, None, False)
|
|
|
|
def canvasOpenRecent(self, event, pathName=None):
|
2019-09-23 19:37:52 +00:00
|
|
|
def canvasImportmIRC(pathName_):
|
|
|
|
rc, error = self.parentCanvas.canvas.importStore.importTextFile(pathName_)
|
|
|
|
return (rc, error, self.parentCanvas.canvas.importStore.outMap, pathName_, self.parentCanvas.canvas.importStore.inSize)
|
2019-09-23 17:55:31 +00:00
|
|
|
if self._promptSaveChanges():
|
2019-09-23 19:37:52 +00:00
|
|
|
rc, newPathName = self._import(canvasImportmIRC, False, pathName)
|
|
|
|
if not rc:
|
|
|
|
numLastFile = [i for i in range(len(self.lastFiles)) if self.lastFiles[i]["pathName"] == pathName][0]
|
|
|
|
self.canvasOpenRecent.attrDict["menu"].Delete(self.lastFiles[numLastFile]["menuItemId"]); del self.lastFiles[numLastFile];
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-10 10:06:56 +00:00
|
|
|
@GuiCommandDecorator("Save", "&Save", ["", wx.ART_FILE_SAVE], [wx.ACCEL_CTRL, ord("S")], None)
|
2019-09-13 19:14:11 +00:00
|
|
|
def canvasSave(self, event, newDirty=False):
|
2019-09-10 10:06:56 +00:00
|
|
|
if self.canvasPathName == None:
|
|
|
|
if self.canvasSaveAs(event) == False:
|
|
|
|
return False
|
|
|
|
try:
|
|
|
|
with open(self.canvasPathName, "w", encoding="utf-8") as outFile:
|
|
|
|
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
|
|
|
self.parentCanvas.canvas.exportStore.exportTextFile(self.parentCanvas.canvas.map, self.parentCanvas.canvas.size, outFile)
|
|
|
|
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
2019-09-13 19:14:11 +00:00
|
|
|
if self.parentCanvas.dirty != newDirty:
|
|
|
|
self.parentCanvas.dirty = newDirty
|
2019-09-10 10:06:56 +00:00
|
|
|
self.update(dirty=self.parentCanvas.dirty)
|
|
|
|
return True
|
|
|
|
except IOError as error:
|
|
|
|
return False
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-10 10:06:56 +00:00
|
|
|
@GuiCommandDecorator("Save As...", "Save &As...", ["", wx.ART_FILE_SAVE_AS], None, None)
|
|
|
|
def canvasSaveAs(self, event):
|
|
|
|
with wx.FileDialog(self.parentCanvas, "Save As", os.getcwd(), "", "mIRC art files (*.txt)|*.txt|All Files (*.*)|*.*", wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dialog:
|
libroar/RoarAssetsWindow.py:{_importFiles, on{Load,Save}List,__init__}(): {pass,receive} lastDir {before,after} wx.FileDialog()s.
libroar/RoarCanvasCommandsFile.py:{_importFile,canvasExportAs{Ansi,Png},SaveAs,__init__}(): {pass,receive} lastDir {before,after} wx.FileDialog()s.
2019-09-14 09:49:08 +00:00
|
|
|
if self.lastDir != None:
|
|
|
|
dialog.SetDirectory(self.lastDir)
|
2019-09-10 10:06:56 +00:00
|
|
|
if dialog.ShowModal() == wx.ID_CANCEL:
|
|
|
|
return False
|
|
|
|
else:
|
libroar/RoarAssetsWindow.py:{_importFiles, on{Load,Save}List,__init__}(): {pass,receive} lastDir {before,after} wx.FileDialog()s.
libroar/RoarCanvasCommandsFile.py:{_importFile,canvasExportAs{Ansi,Png},SaveAs,__init__}(): {pass,receive} lastDir {before,after} wx.FileDialog()s.
2019-09-14 09:49:08 +00:00
|
|
|
self.canvasPathName = dialog.GetPath(); self.lastDir = os.path.dirname(self.canvasPathName);
|
2019-09-14 13:16:57 +00:00
|
|
|
if self.canvasSave(event, newDirty=True):
|
2019-09-16 06:05:50 +00:00
|
|
|
self._pushRecent(self.canvasPathName)
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
|
2019-09-10 10:06:56 +00:00
|
|
|
#
|
|
|
|
# __init__(self)
|
|
|
|
def __init__(self):
|
2019-09-14 13:16:57 +00:00
|
|
|
self.imgurApiKey, self.lastFiles, self.lastDir = ImgurApiKey.imgurApiKey if haveImgurApiKey else None, [], None
|
Various bugfixes & usability improvements.
1) Add background colour toolbar beneath (foreground) colour toolbar.
2) Add colour flipping command w/ {accelerator,{menu,toolbar} item}.
3) Add {de,in}crease {brush,canvas} size accelerator.
4) Add {hide,show} assets window toolbar item.
5) Circle tool: draw outline with foreground colour.
6) Circle tool: honour transparency.
7) Fill tool: change comprehensive fill modifier key from <Shift> to <Ctrl>.
8) Fill tool: fill with {back,fore}ground colour given <[RL]MB>
9) Fix arrow keys cursor motion when scrolled down.
10 Instantly reflect {brush size,colour,tool} changes in canvas.
11) Object tool: honour transparency w/ non-external objects.
12) Object tool: update selection rectangle during <LMB> whilst dragging, set w/ release of <LMB>.
13) Rectangle tool: draw outline with foreground colour.
14) Rectangle tool: honour transparency.
15) Replace wx.ToolBar() w/ wx.lib.agw.aui.AuiToolBar() & custom wx.lib.agw.aui.AuiDefaultToolBarArt().
16) Restore scrolling position after resizing canvas.
.TODO: deleted.
assets/audio/roar{arab8,spoke11}.wav: added.
assets/text/hotkeys.txt: added to document hotkeys.
assets/text/requirements.txt, requirements.txt: moved.
assets/text/TODO: updated.
{assets/tools,lib{canvas,gui,roar,rtl,tools}}/*.py: remove Vim fold markers.
libroar/RoarCanvasCommandsFile.py:_importFile(): update wx.FileDialog() message.
libroar/RoarCanvasCommandsOperators.py:canvasOperator(): update invert colours {caption,label}.
2019-09-23 16:49:33 +00:00
|
|
|
self.accels = ()
|
2019-09-10 10:06:56 +00:00
|
|
|
self.menus = (
|
|
|
|
("&File",
|
2019-09-14 13:16:57 +00:00
|
|
|
self.canvasNew, self.canvasOpen, self.canvasOpenRecent, self.canvasSave, self.canvasSaveAs, NID_MENU_SEP,
|
2019-09-15 10:41:14 +00:00
|
|
|
("&Export...", self.canvasExportAsAnsi, self.canvasExportToClipboard, self.canvasExportImgur, self.canvasExportPastebin, self.canvasExportAsPng,),
|
|
|
|
("&Import...", self.canvasImportAnsi, self.canvasImportFromClipboard, self.canvasImportSauce,),
|
|
|
|
NID_MENU_SEP,
|
2019-09-10 10:06:56 +00:00
|
|
|
self.canvasExit,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
self.toolBars = ()
|
|
|
|
|
|
|
|
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=0
|