diff --git a/data/en.mse-locale/locale b/data/en.mse-locale/locale index 138abcc4..fb1fcf56 100644 --- a/data/en.mse-locale/locale +++ b/data/en.mse-locale/locale @@ -354,6 +354,12 @@ label: # Open dialogs all files All files + # Other set window dialogs + save changes: + The set '%s' has changed. + + Do you want to save the changes? + # New set window game type: &Game type: style type: &Card style: @@ -451,6 +457,8 @@ button: ############################################################## Titles in the GUI title: magic set editor: Magic Set Editor + %s - magic set editor: %s - Magic Set Editor + untitled: Untitled about: About Magic Set Editor symbol editor: Symbol Editor # dialogs @@ -458,6 +466,7 @@ title: save set: Save Set As save image: Save Image updates availible: Updates Availible + save changes: Save Changes? #preferences preferences: Preferences global: Global diff --git a/src/data/set.cpp b/src/data/set.cpp index 814eda3f..a67c0125 100644 --- a/src/data/set.cpp +++ b/src/data/set.cpp @@ -99,6 +99,22 @@ IndexMap& Set::stylingDataFor(const CardP& card) { else return stylingDataFor(stylesheetFor(card)); } +String Set::identification() const { + // an identifying field + FOR_EACH_CONST(v, data) { + if (v->fieldP->identifying) { + return v->toString(); + } + } + // otherwise the first field + if (!data.empty()) { + return data.at(0)->toString(); + } else { + return wxEmptyString; + } +} + + String Set::typeName() const { return _("set"); } // fix values for versions < 0.2.7 diff --git a/src/data/set.hpp b/src/data/set.hpp index a4e6087c..6774f5a8 100644 --- a/src/data/set.hpp +++ b/src/data/set.hpp @@ -89,6 +89,10 @@ class Set : public Packaged { /// Styling information for a particular card IndexMap& stylingDataFor(const CardP& card); + /// Get the identification of this set, an identification is something like a name, title, etc. + /** May return "" */ + String identification() const; + /// Find a value in the data by name and type template T& value(const String& name) { for(IndexMap::iterator it = data.begin() ; it != data.end() ; ++it) { diff --git a/src/gui/set/window.cpp b/src/gui/set/window.cpp index 920297cd..f92e0957 100644 --- a/src/gui/set/window.cpp +++ b/src/gui/set/window.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include DECLARE_TYPEOF_COLLECTION(SetWindowPanel*); @@ -232,6 +233,8 @@ bool SetWindow::isOnlyWithSet() { // ----------------------------------------------------------------------------- : Set actions void SetWindow::onChangeSet() { + // window title + updateTitle(); // make sure there is always at least one card // some things need this if (set->cards.empty()) set->cards.push_back(new_intrusive1(*set->game)); @@ -247,6 +250,11 @@ void SetWindow::onChangeSet() { } void SetWindow::onAction(const Action& action, bool undone) { + TYPE_CASE(action, ValueAction) { + if (set->data.contains(action.valueP) && action.valueP->fieldP->identifying) { + updateTitle(); + } + } /* TYPE_CASE_(action, DisplayChangeAction) { // The style changed, maybe also the size of card viewers if (current_panel) current_panel->Layout(); @@ -254,8 +262,20 @@ void SetWindow::onAction(const Action& action, bool undone) { } */ } - - + +void SetWindow::updateTitle() { + if (!set) { + SetTitle(_TITLE_("magic set editor")); + } else { + String identification = set->identification(); + if (identification.empty()) identification = set->name(); + if (identification.empty()) identification = _TITLE_("untitled"); + set->short_name = identification; + SetTitle(format_string(_TITLE_("%s - magic set editor"),identification)); + } +} + + void SetWindow::onCardSelect(CardSelectEvent& ev) { FOR_EACH(p, panels) { p->selectCard(ev.card); @@ -297,13 +317,13 @@ void SetWindow::onClose(wxCloseEvent& ev) { bool SetWindow::askSaveAndContinue() { if (set->actions.atSavePoint()) return true; // todo : if more then one window has the set selected it's ok to proceed - int save = wxMessageBox(_("The set has changed\n\nDo you want to save the changes?"), _("Save changes"), wxYES_NO | wxCANCEL | wxICON_EXCLAMATION); + int save = wxMessageBox(format_string(_LABEL_("save changes"), set->short_name), _TITLE_("save changes"), wxYES_NO | wxCANCEL | wxICON_EXCLAMATION); if (save == wxYES) { // save the set try { if (set->needSaveAs()) { // need save as - wxFileDialog dlg(this, _("Save a set"), _(""), _(""), export_formats(*set->game), wxSAVE | wxOVERWRITE_PROMPT); + wxFileDialog dlg(this, _TITLE_("save set"), _(""), set->short_name, export_formats(*set->game), wxSAVE | wxOVERWRITE_PROMPT); if (dlg.ShowModal() == wxID_OK) { export_set(*set, dlg.GetPath(), dlg.GetFilterIndex()); return true; @@ -422,9 +442,10 @@ void SetWindow::onFileSave(wxCommandEvent& ev) { } void SetWindow::onFileSaveAs(wxCommandEvent&) { - wxFileDialog dlg(this, _TITLE_("save set"), _(""), _(""), export_formats(*set->game), wxSAVE | wxOVERWRITE_PROMPT); + wxFileDialog dlg(this, _TITLE_("save set"), _(""), set->short_name, export_formats(*set->game), wxSAVE | wxOVERWRITE_PROMPT); if (dlg.ShowModal() == wxID_OK) { export_set(*set, dlg.GetPath(), dlg.GetFilterIndex()); + updateTitle(); // title may depend on filename } } diff --git a/src/gui/set/window.hpp b/src/gui/set/window.hpp index 71ec6e0b..fc479187 100644 --- a/src/gui/set/window.hpp +++ b/src/gui/set/window.hpp @@ -80,6 +80,8 @@ class SetWindow : public wxFrame, public SetView { // minSize = mainSizer->getMinWindowSize(this) // but wx made that private void fixMinWindowSize(); + /// Update the window title based on the set name + void updateTitle(); // --------------------------------------------------- : Window events - close