mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-13 14:07:01 -04:00
Added identifying field to set, show set name in window title.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@519 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -354,6 +354,12 @@ label:
|
|||||||
# Open dialogs
|
# Open dialogs
|
||||||
all files All files
|
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
|
# New set window
|
||||||
game type: &Game type:
|
game type: &Game type:
|
||||||
style type: &Card style:
|
style type: &Card style:
|
||||||
@@ -451,6 +457,8 @@ button:
|
|||||||
############################################################## Titles in the GUI
|
############################################################## Titles in the GUI
|
||||||
title:
|
title:
|
||||||
magic set editor: Magic Set Editor
|
magic set editor: Magic Set Editor
|
||||||
|
%s - magic set editor: %s - Magic Set Editor
|
||||||
|
untitled: Untitled
|
||||||
about: About Magic Set Editor
|
about: About Magic Set Editor
|
||||||
symbol editor: Symbol Editor
|
symbol editor: Symbol Editor
|
||||||
# dialogs
|
# dialogs
|
||||||
@@ -458,6 +466,7 @@ title:
|
|||||||
save set: Save Set As
|
save set: Save Set As
|
||||||
save image: Save Image
|
save image: Save Image
|
||||||
updates availible: Updates Availible
|
updates availible: Updates Availible
|
||||||
|
save changes: Save Changes?
|
||||||
#preferences
|
#preferences
|
||||||
preferences: Preferences
|
preferences: Preferences
|
||||||
global: Global
|
global: Global
|
||||||
|
|||||||
@@ -99,6 +99,22 @@ IndexMap<FieldP, ValueP>& Set::stylingDataFor(const CardP& card) {
|
|||||||
else return stylingDataFor(stylesheetFor(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"); }
|
String Set::typeName() const { return _("set"); }
|
||||||
|
|
||||||
// fix values for versions < 0.2.7
|
// fix values for versions < 0.2.7
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ class Set : public Packaged {
|
|||||||
/// Styling information for a particular card
|
/// Styling information for a particular card
|
||||||
IndexMap<FieldP, ValueP>& stylingDataFor(const CardP& card);
|
IndexMap<FieldP, ValueP>& 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
|
/// Find a value in the data by name and type
|
||||||
template <typename T> T& value(const String& name) {
|
template <typename T> T& value(const String& name) {
|
||||||
for(IndexMap<FieldP, ValueP>::iterator it = data.begin() ; it != data.end() ; ++it) {
|
for(IndexMap<FieldP, ValueP>::iterator it = data.begin() ; it != data.end() ; ++it) {
|
||||||
|
|||||||
+26
-5
@@ -32,6 +32,7 @@
|
|||||||
#include <data/card.hpp>
|
#include <data/card.hpp>
|
||||||
#include <data/settings.hpp>
|
#include <data/settings.hpp>
|
||||||
#include <data/format/formats.hpp>
|
#include <data/format/formats.hpp>
|
||||||
|
#include <data/action/value.hpp>
|
||||||
#include <data/action/set.hpp>
|
#include <data/action/set.hpp>
|
||||||
|
|
||||||
DECLARE_TYPEOF_COLLECTION(SetWindowPanel*);
|
DECLARE_TYPEOF_COLLECTION(SetWindowPanel*);
|
||||||
@@ -232,6 +233,8 @@ bool SetWindow::isOnlyWithSet() {
|
|||||||
// ----------------------------------------------------------------------------- : Set actions
|
// ----------------------------------------------------------------------------- : Set actions
|
||||||
|
|
||||||
void SetWindow::onChangeSet() {
|
void SetWindow::onChangeSet() {
|
||||||
|
// window title
|
||||||
|
updateTitle();
|
||||||
// make sure there is always at least one card
|
// make sure there is always at least one card
|
||||||
// some things need this
|
// some things need this
|
||||||
if (set->cards.empty()) set->cards.push_back(new_intrusive1<Card>(*set->game));
|
if (set->cards.empty()) set->cards.push_back(new_intrusive1<Card>(*set->game));
|
||||||
@@ -247,6 +250,11 @@ void SetWindow::onChangeSet() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SetWindow::onAction(const Action& action, bool undone) {
|
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) {
|
/* TYPE_CASE_(action, DisplayChangeAction) {
|
||||||
// The style changed, maybe also the size of card viewers
|
// The style changed, maybe also the size of card viewers
|
||||||
if (current_panel) current_panel->Layout();
|
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) {
|
void SetWindow::onCardSelect(CardSelectEvent& ev) {
|
||||||
FOR_EACH(p, panels) {
|
FOR_EACH(p, panels) {
|
||||||
p->selectCard(ev.card);
|
p->selectCard(ev.card);
|
||||||
@@ -297,13 +317,13 @@ void SetWindow::onClose(wxCloseEvent& ev) {
|
|||||||
bool SetWindow::askSaveAndContinue() {
|
bool SetWindow::askSaveAndContinue() {
|
||||||
if (set->actions.atSavePoint()) return true;
|
if (set->actions.atSavePoint()) return true;
|
||||||
// todo : if more then one window has the set selected it's ok to proceed
|
// 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) {
|
if (save == wxYES) {
|
||||||
// save the set
|
// save the set
|
||||||
try {
|
try {
|
||||||
if (set->needSaveAs()) {
|
if (set->needSaveAs()) {
|
||||||
// need save as
|
// 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) {
|
if (dlg.ShowModal() == wxID_OK) {
|
||||||
export_set(*set, dlg.GetPath(), dlg.GetFilterIndex());
|
export_set(*set, dlg.GetPath(), dlg.GetFilterIndex());
|
||||||
return true;
|
return true;
|
||||||
@@ -422,9 +442,10 @@ void SetWindow::onFileSave(wxCommandEvent& ev) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SetWindow::onFileSaveAs(wxCommandEvent&) {
|
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) {
|
if (dlg.ShowModal() == wxID_OK) {
|
||||||
export_set(*set, dlg.GetPath(), dlg.GetFilterIndex());
|
export_set(*set, dlg.GetPath(), dlg.GetFilterIndex());
|
||||||
|
updateTitle(); // title may depend on filename
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ class SetWindow : public wxFrame, public SetView {
|
|||||||
// minSize = mainSizer->getMinWindowSize(this)
|
// minSize = mainSizer->getMinWindowSize(this)
|
||||||
// but wx made that private
|
// but wx made that private
|
||||||
void fixMinWindowSize();
|
void fixMinWindowSize();
|
||||||
|
/// Update the window title based on the set name
|
||||||
|
void updateTitle();
|
||||||
|
|
||||||
// --------------------------------------------------- : Window events - close
|
// --------------------------------------------------- : Window events - close
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user