mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-21 23:06:38 +00:00
Load & store LRU file dialogue directory.
assets/text/TODO: updated.
This commit is contained in:
parent
c7dd80327d
commit
35f6910427
@ -18,13 +18,11 @@
|
|||||||
Release roadmap:
|
Release roadmap:
|
||||||
1) BUG: fix & finish Arabic/RTL text tool support
|
1) BUG: fix & finish Arabic/RTL text tool support
|
||||||
2) BUG: a) text tool b) paste text c) undo
|
2) BUG: a) text tool b) paste text c) undo
|
||||||
3) BUG: a) tile once b) tile twice
|
3) {copy,cut,delete,insert from,paste}, edit asset in new canvas, import from {canvas,object}
|
||||||
4) {copy,cut,delete,insert from,paste}, edit asset in new canvas, import from {canvas,object}
|
4) add hotkeys.txt mIRC art canvas to help menu
|
||||||
5) add hotkeys.txt mIRC art canvas to help menu
|
5) operators: crop, scale, shift, slice
|
||||||
6) {load,store} LRU {open,save} directory
|
6) auto{load,save} & {backup,restore}
|
||||||
7) operators: crop, scale, shift, slice
|
7) tools: unicode block elements
|
||||||
8) auto{load,save} & {backup,restore}
|
8) floating/dockable toolbar
|
||||||
9) tools: unicode block elements
|
|
||||||
10) floating/dockable toolbar
|
|
||||||
|
|
||||||
vim:ff=dos tw=0
|
vim:ff=dos tw=0
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
from Canvas import Canvas
|
from Canvas import Canvas
|
||||||
from GuiFrame import GuiMiniFrame
|
from GuiFrame import GuiMiniFrame
|
||||||
from GuiWindow import GuiWindow
|
from GuiWindow import GuiWindow
|
||||||
|
from RtlPlatform import getLocalConfPathName
|
||||||
import json, os, sys, wx
|
import json, os, sys, wx
|
||||||
|
|
||||||
class RoarAssetsWindow(GuiMiniFrame):
|
class RoarAssetsWindow(GuiMiniFrame):
|
||||||
@ -37,7 +38,9 @@ class RoarAssetsWindow(GuiMiniFrame):
|
|||||||
else:
|
else:
|
||||||
for pathName in dialog.GetPaths():
|
for pathName in dialog.GetPaths():
|
||||||
resultList += [self._import(f, pathName)]
|
resultList += [self._import(f, pathName)]
|
||||||
self.lastDir = os.path.dirname(pathName)
|
lastDir = os.path.dirname(pathName)
|
||||||
|
if self.lastDir != lastDir:
|
||||||
|
self.lastDir = lastDir; self._storeLastDir(self.lastDir);
|
||||||
return resultList
|
return resultList
|
||||||
|
|
||||||
def _load_list(self, pathName):
|
def _load_list(self, pathName):
|
||||||
@ -81,6 +84,17 @@ class RoarAssetsWindow(GuiMiniFrame):
|
|||||||
with wx.MessageDialog(self, "Error: {}".format(str(e)), "", wx.OK | wx.OK_DEFAULT) as dialog:
|
with wx.MessageDialog(self, "Error: {}".format(str(e)), "", wx.OK | wx.OK_DEFAULT) as dialog:
|
||||||
dialogChoice = dialog.ShowModal()
|
dialogChoice = dialog.ShowModal()
|
||||||
|
|
||||||
|
def _loadLastDir(self):
|
||||||
|
localConfFileName = getLocalConfPathName("RecentAssetsDir.txt")
|
||||||
|
if os.path.exists(localConfFileName):
|
||||||
|
with open(localConfFileName, "r", encoding="utf-8") as inFile:
|
||||||
|
self.lastDir = inFile.read().rstrip("\r\n")
|
||||||
|
|
||||||
|
def _storeLastDir(self, pathName):
|
||||||
|
localConfFileName = getLocalConfPathName("RecentAssetsDir.txt")
|
||||||
|
with open(localConfFileName, "w", encoding="utf-8") as outFile:
|
||||||
|
print(pathName, file=outFile)
|
||||||
|
|
||||||
def _updateScrollBars(self):
|
def _updateScrollBars(self):
|
||||||
clientSize = self.panelCanvas.GetClientSize()
|
clientSize = self.panelCanvas.GetClientSize()
|
||||||
if self.currentIndex != None:
|
if self.currentIndex != None:
|
||||||
@ -235,7 +249,8 @@ class RoarAssetsWindow(GuiMiniFrame):
|
|||||||
if self.lastDir != None:
|
if self.lastDir != None:
|
||||||
dialog.SetDirectory(self.lastDir)
|
dialog.SetDirectory(self.lastDir)
|
||||||
if dialog.ShowModal() != wx.ID_CANCEL:
|
if dialog.ShowModal() != wx.ID_CANCEL:
|
||||||
pathName = dialog.GetPath(); self.lastDir = os.path.dirname(pathName);
|
pathName = dialog.GetPath()
|
||||||
|
self.lastDir = os.path.dirname(pathName); self._storeLastDir(self.lastDir);
|
||||||
self._load_list(pathName)
|
self._load_list(pathName)
|
||||||
|
|
||||||
def onRemove(self, event):
|
def onRemove(self, event):
|
||||||
@ -264,7 +279,8 @@ class RoarAssetsWindow(GuiMiniFrame):
|
|||||||
if self.lastDir != None:
|
if self.lastDir != None:
|
||||||
dialog.SetDirectory(self.lastDir)
|
dialog.SetDirectory(self.lastDir)
|
||||||
if dialog.ShowModal() != wx.ID_CANCEL:
|
if dialog.ShowModal() != wx.ID_CANCEL:
|
||||||
pathName = dialog.GetPath(); self.lastDir = os.path.dirname(pathName);
|
pathName = dialog.GetPath()
|
||||||
|
self.lastDir = os.path.dirname(pathName); self._storeLastDir(self.lastDir);
|
||||||
with open(pathName, "w") as fileObject:
|
with open(pathName, "w") as fileObject:
|
||||||
for pathName in [self.canvasList[k][1] for k in self.canvasList.keys()]:
|
for pathName in [self.canvasList[k][1] for k in self.canvasList.keys()]:
|
||||||
print(pathName, file=fileObject)
|
print(pathName, file=fileObject)
|
||||||
@ -284,6 +300,7 @@ class RoarAssetsWindow(GuiMiniFrame):
|
|||||||
self.backend, self.canvasList, self.lastDir = backend((0, 0), cellSize), {}, None
|
self.backend, self.canvasList, self.lastDir = backend((0, 0), cellSize), {}, None
|
||||||
self.cellSize, self.currentIndex, self.leftDown, self.parent, self.scrollFlag = cellSize, None, False, parent, False
|
self.cellSize, self.currentIndex, self.leftDown, self.parent, self.scrollFlag = cellSize, None, False, parent, False
|
||||||
self.Bind(wx.EVT_CHAR, self.onChar)
|
self.Bind(wx.EVT_CHAR, self.onChar)
|
||||||
|
self._loadLastDir()
|
||||||
|
|
||||||
self.contextMenu, self.contextMenuItems = wx.Menu(), []
|
self.contextMenu, self.contextMenuItems = wx.Menu(), []
|
||||||
for text, f in (
|
for text, f in (
|
||||||
|
@ -48,9 +48,15 @@ class RoarCanvasCommandsFile():
|
|||||||
if dialog.ShowModal() == wx.ID_CANCEL:
|
if dialog.ShowModal() == wx.ID_CANCEL:
|
||||||
return False, None
|
return False, None
|
||||||
elif self._promptSaveChanges():
|
elif self._promptSaveChanges():
|
||||||
pathName = dialog.GetPath(); self.lastDir = os.path.dirname(pathName);
|
pathName = dialog.GetPath(); self.lastDir = os.path.dirname(pathName); self._storeLastDir(self.lastDir);
|
||||||
return self._import(f, newDirty, pathName)
|
return self._import(f, newDirty, pathName)
|
||||||
|
|
||||||
|
def _loadLastDir(self):
|
||||||
|
localConfFileName = getLocalConfPathName("RecentDir.txt")
|
||||||
|
if os.path.exists(localConfFileName):
|
||||||
|
with open(localConfFileName, "r", encoding="utf-8") as inFile:
|
||||||
|
self.lastDir = inFile.read().rstrip("\r\n")
|
||||||
|
|
||||||
def _loadRecent(self):
|
def _loadRecent(self):
|
||||||
localConfFileName = getLocalConfPathName("Recent.lst")
|
localConfFileName = getLocalConfPathName("Recent.lst")
|
||||||
if os.path.exists(localConfFileName):
|
if os.path.exists(localConfFileName):
|
||||||
@ -91,6 +97,11 @@ class RoarCanvasCommandsFile():
|
|||||||
for lastFile in [l["pathName"] for l in self.lastFiles]:
|
for lastFile in [l["pathName"] for l in self.lastFiles]:
|
||||||
print(lastFile, file=outFile)
|
print(lastFile, file=outFile)
|
||||||
|
|
||||||
|
def _storeLastDir(self, pathName):
|
||||||
|
localConfFileName = getLocalConfPathName("RecentDir.txt")
|
||||||
|
with open(localConfFileName, "w", encoding="utf-8") as outFile:
|
||||||
|
print(pathName, file=outFile)
|
||||||
|
|
||||||
@GuiCommandDecorator("Clear list", "&Clear list", None, None, False)
|
@GuiCommandDecorator("Clear list", "&Clear list", None, None, False)
|
||||||
def canvasClearRecent(self, event):
|
def canvasClearRecent(self, event):
|
||||||
if self.lastFiles != None:
|
if self.lastFiles != None:
|
||||||
@ -115,7 +126,7 @@ class RoarCanvasCommandsFile():
|
|||||||
if dialog.ShowModal() == wx.ID_CANCEL:
|
if dialog.ShowModal() == wx.ID_CANCEL:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
outPathName = dialog.GetPath(); self.lastDir = os.path.dirname(outPathName);
|
outPathName = dialog.GetPath(); self.lastDir = os.path.dirname(outPathName); self._storeLastDir(self.lastDir);
|
||||||
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
||||||
with open(outPathName, "w", encoding="utf-8") as outFile:
|
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.canvas.exportStore.exportAnsiFile(self.parentCanvas.canvas.map, self.parentCanvas.canvas.size, outFile)
|
||||||
@ -130,7 +141,7 @@ class RoarCanvasCommandsFile():
|
|||||||
if dialog.ShowModal() == wx.ID_CANCEL:
|
if dialog.ShowModal() == wx.ID_CANCEL:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
outPathName = dialog.GetPath(); self.lastDir = os.path.dirname(outPathName);
|
outPathName = dialog.GetPath(); self.lastDir = os.path.dirname(outPathName); self._storeLastDir(self.lastDir);
|
||||||
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
||||||
self.parentCanvas.canvas.exportStore.exportBitmapToPngFile(self.parentCanvas.backend.canvasBitmap, outPathName, wx.BITMAP_TYPE_PNG)
|
self.parentCanvas.canvas.exportStore.exportBitmapToPngFile(self.parentCanvas.backend.canvasBitmap, outPathName, wx.BITMAP_TYPE_PNG)
|
||||||
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
||||||
@ -258,7 +269,7 @@ class RoarCanvasCommandsFile():
|
|||||||
if dialog.ShowModal() == wx.ID_CANCEL:
|
if dialog.ShowModal() == wx.ID_CANCEL:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
self.canvasPathName = dialog.GetPath(); self.lastDir = os.path.dirname(self.canvasPathName);
|
self.canvasPathName = dialog.GetPath(); self.lastDir = os.path.dirname(self.canvasPathName); self._storeLastDir(self.lastDir);
|
||||||
if self.canvasSave(event, newDirty=True):
|
if self.canvasSave(event, newDirty=True):
|
||||||
self._pushRecent(self.canvasPathName)
|
self._pushRecent(self.canvasPathName)
|
||||||
|
|
||||||
|
2
roar.py
2
roar.py
@ -20,7 +20,7 @@ def main(*argv):
|
|||||||
os.makedirs(localConfirName)
|
os.makedirs(localConfirName)
|
||||||
wxApp, roarClient = wx.App(False), RoarClient(None)
|
wxApp, roarClient = wx.App(False), RoarClient(None)
|
||||||
argv0, argv = argv[0], argv[1:]
|
argv0, argv = argv[0], argv[1:]
|
||||||
roarClient.canvasPanel.commands._loadRecent()
|
roarClient.canvasPanel.commands._loadLastDir(); roarClient.canvasPanel.commands._loadRecent();
|
||||||
if len(argv) >= 1:
|
if len(argv) >= 1:
|
||||||
if (len(argv) >= 2) and (argv[1].endswith(".lst")):
|
if (len(argv) >= 2) and (argv[1].endswith(".lst")):
|
||||||
roarClient.assetsWindow._load_list(argv[1])
|
roarClient.assetsWindow._load_list(argv[1])
|
||||||
|
Loading…
Reference in New Issue
Block a user