mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Remember separate most recent directories for:
- set files - symbol files - importing images - exporting git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1257 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -61,10 +61,11 @@ void export_mws(Window* parent, const SetP& set) {
|
||||
}
|
||||
|
||||
// Select filename
|
||||
String name = wxFileSelector(_("Export to file"),_(""),_(""),_(""),
|
||||
String name = wxFileSelector(_("Export to file"),settings.default_export_dir,_(""),_(""),
|
||||
_("Text files (*.txt)|*.txt|All Files|*"),
|
||||
wxSAVE | wxOVERWRITE_PROMPT, parent);
|
||||
if (name.empty()) return;
|
||||
settings.default_export_dir = wxPathOnly(name);
|
||||
wxBusyCursor busy;
|
||||
// Open file
|
||||
wxFileOutputStream f(name);
|
||||
|
||||
@@ -233,6 +233,10 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) {
|
||||
REFLECT_ALIAS(300, "default style settings", "default stylesheet settings");
|
||||
REFLECT(locale);
|
||||
REFLECT(recent_sets);
|
||||
REFLECT(default_set_dir);
|
||||
REFLECT(default_image_dir);
|
||||
REFLECT(default_symbol_dir);
|
||||
REFLECT(default_export_dir);
|
||||
REFLECT(set_window_maximized);
|
||||
REFLECT(set_window_width);
|
||||
REFLECT(set_window_height);
|
||||
|
||||
@@ -132,6 +132,12 @@ class Settings {
|
||||
/// Add a file to the list of recent files
|
||||
void addRecentFile(const String& filename);
|
||||
|
||||
// --------------------------------------------------- : Files/directories
|
||||
String default_set_dir; ///< Where to look for .mse-set files
|
||||
String default_image_dir; ///< Where to look for images to import
|
||||
String default_symbol_dir; ///< Where to look for .mse-symbol files
|
||||
String default_export_dir; ///< Where to export to by default
|
||||
|
||||
// --------------------------------------------------- : Set window
|
||||
bool set_window_maximized;
|
||||
UInt set_window_width;
|
||||
|
||||
@@ -55,8 +55,9 @@ HtmlExportWindow::HtmlExportWindow(Window* parent, const SetP& set, const Export
|
||||
void HtmlExportWindow::onOk(wxCommandEvent&) {
|
||||
ExportTemplateP exp = list->getSelection<ExportTemplate>();
|
||||
// get filename
|
||||
String name = wxFileSelector(_TITLE_("save html"),_(""),_(""),_(""),exp->file_type, wxSAVE | wxOVERWRITE_PROMPT);
|
||||
String name = wxFileSelector(_TITLE_("save html"),settings.default_export_dir,_(""),_(""),exp->file_type, wxSAVE | wxOVERWRITE_PROMPT);
|
||||
if (name.empty()) return;
|
||||
settings.default_export_dir = wxPathOnly(name);
|
||||
wxBusyCursor wait;
|
||||
// export info for script
|
||||
ExportInfo info;
|
||||
|
||||
@@ -62,9 +62,10 @@ void ImagesExportWindow::onOk(wxCommandEvent&) {
|
||||
else if (sel == 2) gs.images_export_conflicts = CONFLICT_NUMBER;
|
||||
else gs.images_export_conflicts = CONFLICT_NUMBER_OVERWRITE;
|
||||
// Select filename
|
||||
String name = wxFileSelector(_TITLE_("export images"),_(""), _LABEL_("filename is ignored"),_(""),
|
||||
String name = wxFileSelector(_TITLE_("export images"), settings.default_export_dir, _LABEL_("filename is ignored"),_(""),
|
||||
_LABEL_("filename is ignored")+_("|*"), wxSAVE, this);
|
||||
if (name.empty()) return;
|
||||
settings.default_export_dir = wxPathOnly(name);
|
||||
// Export
|
||||
export_images(set, getSelection(), name, gs.images_export_filename, gs.images_export_conflicts);
|
||||
// Done
|
||||
|
||||
@@ -390,8 +390,9 @@ bool SetWindow::askSaveAndContinue() {
|
||||
try {
|
||||
if (set->needSaveAs()) {
|
||||
// need save as
|
||||
wxFileDialog dlg(this, _TITLE_("save set"), _(""), set->short_name, export_formats(*set->game), wxSAVE | wxOVERWRITE_PROMPT);
|
||||
wxFileDialog dlg(this, _TITLE_("save set"), settings.default_set_dir, set->short_name, export_formats(*set->game), wxSAVE | wxOVERWRITE_PROMPT);
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
settings.default_set_dir = dlg.GetDirectory();
|
||||
export_set(*set, dlg.GetPath(), dlg.GetFilterIndex());
|
||||
return true;
|
||||
} else {
|
||||
@@ -503,8 +504,9 @@ void SetWindow::onFileNew(wxCommandEvent&) {
|
||||
|
||||
void SetWindow::onFileOpen(wxCommandEvent&) {
|
||||
if (!settings.open_sets_in_new_window && isOnlyWithSet() && !askSaveAndContinue()) return;
|
||||
wxFileDialog dlg(this, _TITLE_("open set"), _(""), _(""), import_formats(), wxOPEN);
|
||||
wxFileDialog dlg(this, _TITLE_("open set"), settings.default_set_dir, _(""), import_formats(), wxOPEN);
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
settings.default_set_dir = dlg.GetDirectory();
|
||||
wxBusyCursor busy;
|
||||
SetP new_set = import_set(dlg.GetPath());
|
||||
switchSet(new_set);
|
||||
@@ -523,8 +525,9 @@ void SetWindow::onFileSave(wxCommandEvent& ev) {
|
||||
}
|
||||
|
||||
void SetWindow::onFileSaveAs(wxCommandEvent&) {
|
||||
wxFileDialog dlg(this, _TITLE_("save set"), _(""), set->short_name, export_formats(*set->game), wxSAVE | wxOVERWRITE_PROMPT);
|
||||
wxFileDialog dlg(this, _TITLE_("save set"), settings.default_set_dir, set->short_name, export_formats(*set->game), wxSAVE | wxOVERWRITE_PROMPT);
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
settings.default_set_dir = dlg.GetDirectory();
|
||||
export_set(*set, dlg.GetPath(), dlg.GetFilterIndex());
|
||||
updateTitle(); // title may depend on filename
|
||||
}
|
||||
@@ -571,10 +574,11 @@ void SetWindow::onFileExportMenu(wxCommandEvent& ev) {
|
||||
void SetWindow::onFileExportImage(wxCommandEvent&) {
|
||||
CardP card = current_panel->selectedCard();
|
||||
if (!card) return; // no card selected
|
||||
String name = wxFileSelector(_TITLE_("save image"), _(""), card->identification(), _(""),
|
||||
String name = wxFileSelector(_TITLE_("save image"), settings.default_export_dir, card->identification(), _(""),
|
||||
_("JPEG images (*.jpg)|*.jpg|Windows bitmaps (*.bmp)|*.bmp|PNG images (*.png)|*.png|GIF images (*.gif)|*.gif|TIFF images (*.tif)|*.tif"),
|
||||
wxSAVE | wxOVERWRITE_PROMPT, this);
|
||||
if (!name.empty()) {
|
||||
settings.default_export_dir = wxPathOnly(name);
|
||||
export_image(set, card, name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,8 +209,9 @@ void SymbolWindow::onFileNew(wxCommandEvent& ev) {
|
||||
}
|
||||
|
||||
void SymbolWindow::onFileOpen(wxCommandEvent& ev) {
|
||||
String name = wxFileSelector(_("Open symbol"),_(""),_(""),_(""),_("Symbol files|*.mse-symbol;*.bmp|MSE2 symbol files (*.mse-symbol)|*.mse-symbol|Images/MSE1 symbol files|*.bmp;*.png;*.jpg;*.gif"),wxOPEN|wxFILE_MUST_EXIST, this);
|
||||
String name = wxFileSelector(_("Open symbol"),settings.default_symbol_dir,_(""),_(""),_("Symbol files|*.mse-symbol;*.bmp|MSE2 symbol files (*.mse-symbol)|*.mse-symbol|Images/MSE1 symbol files|*.bmp;*.png;*.jpg;*.gif"),wxOPEN|wxFILE_MUST_EXIST, this);
|
||||
if (!name.empty()) {
|
||||
settings.default_symbol_dir = wxPathOnly(name);
|
||||
wxFileName n(name);
|
||||
String ext = n.GetExt();
|
||||
SymbolP symbol;
|
||||
@@ -235,8 +236,9 @@ void SymbolWindow::onFileSave(wxCommandEvent& ev) {
|
||||
}
|
||||
|
||||
void SymbolWindow::onFileSaveAs(wxCommandEvent& ev) {
|
||||
String name = wxFileSelector(_("Save symbol"),_(""),_(""),_(""),_("Symbol files (*.mse-symbol)|*.mse-symbol"),wxSAVE, this);
|
||||
String name = wxFileSelector(_("Save symbol"),settings.default_set_dir,_(""),_(""),_("Symbol files (*.mse-symbol)|*.mse-symbol"),wxSAVE, this);
|
||||
if (!name.empty()) {
|
||||
settings.default_set_dir = wxPathOnly(name);
|
||||
Writer writer(new_shared1<wxFileOutputStream>(name), file_version_symbol);
|
||||
writer.handle(control->getSymbol());
|
||||
}
|
||||
|
||||
@@ -18,10 +18,11 @@
|
||||
IMPLEMENT_VALUE_EDITOR(Image) {}
|
||||
|
||||
bool ImageValueEditor::onLeftDClick(const RealPoint&, wxMouseEvent&) {
|
||||
String filename = wxFileSelector(_("Open image file"), _(""), _(""), _(""),
|
||||
String filename = wxFileSelector(_("Open image file"), settings.default_image_dir, _(""), _(""),
|
||||
_("All images|*.bmp;*.jpg;*.png;*.gif|Windows bitmaps (*.bmp)|*.bmp|JPEG images (*.jpg;*.jpeg)|*.jpg;*.jpeg|PNG images (*.png)|*.png|GIF images (*.gif)|*.gif|TIFF images (*.tif;*.tiff)|*.tif;*.tiff"),
|
||||
wxOPEN, wxGetTopLevelParent(&editor()));
|
||||
if (!filename.empty()) {
|
||||
settings.default_image_dir = wxPathOnly(filename);
|
||||
sliceImage(wxImage(filename));
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -90,8 +90,9 @@ void WelcomeWindow::draw(DC& dc) {
|
||||
}
|
||||
|
||||
void WelcomeWindow::onOpenSet(wxCommandEvent&) {
|
||||
wxFileDialog dlg(this, _TITLE_("open set"), wxEmptyString, wxEmptyString, import_formats(), wxOPEN);
|
||||
wxFileDialog dlg(this, _TITLE_("open set"), settings.default_set_dir, wxEmptyString, import_formats(), wxOPEN);
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
settings.default_set_dir = dlg.GetDirectory();
|
||||
wxBusyCursor wait;
|
||||
close(import_set(dlg.GetPath()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user