Commit 505d079c authored by twanvl's avatar twanvl

new card selection thingy also used for "export all card images"

parent 296f4942
...@@ -87,7 +87,7 @@ FileFormatP mtg_editor_file_format(); ...@@ -87,7 +87,7 @@ FileFormatP mtg_editor_file_format();
void export_images(Window* parent, const SetP& set); void export_images(Window* parent, const SetP& set);
/// Export the image for each card in a list of cards /// Export the image for each card in a list of cards
void export_images(const SetP& set, vector<CardP>& cards, void export_images(const SetP& set, const vector<CardP>& cards,
const String& path, const String& filename_template, FilenameConflicts conflicts); const String& path, const String& filename_template, FilenameConflicts conflicts);
/// Export the image of a single card /// Export the image of a single card
......
...@@ -66,7 +66,7 @@ Bitmap export_bitmap(const SetP& set, const CardP& card) { ...@@ -66,7 +66,7 @@ Bitmap export_bitmap(const SetP& set, const CardP& card) {
// ----------------------------------------------------------------------------- : Multiple card export // ----------------------------------------------------------------------------- : Multiple card export
void export_images(const SetP& set, vector<CardP>& cards, void export_images(const SetP& set, const vector<CardP>& cards,
const String& path, const String& filename_template, FilenameConflicts conflicts) const String& path, const String& filename_template, FilenameConflicts conflicts)
{ {
wxBusyCursor busy; wxBusyCursor busy;
......
...@@ -42,8 +42,9 @@ ExportCardSelectionChoice::ExportCardSelectionChoice(const String& label, const ...@@ -42,8 +42,9 @@ ExportCardSelectionChoice::ExportCardSelectionChoice(const String& label, const
// ----------------------------------------------------------------------------- : ExportWindowBase // ----------------------------------------------------------------------------- : ExportWindowBase
ExportWindowBase::ExportWindowBase(const SetP& set, const ExportCardSelectionChoices& cards_choices) ExportWindowBase::ExportWindowBase(Window* parent, const String& title, const SetP& set, const ExportCardSelectionChoices& cards_choices)
: set(set), cards_choices(cards_choices) : wxDialog(parent, wxID_ANY, title)
, set(set), cards_choices(cards_choices)
, active_choice(0) , active_choice(0)
, select_cards(nullptr) , select_cards(nullptr)
{} {}
...@@ -56,6 +57,7 @@ wxSizer* ExportWindowBase::Create() { ...@@ -56,6 +57,7 @@ wxSizer* ExportWindowBase::Create() {
bool any_custom = false; bool any_custom = false;
FOR_EACH(choice, cards_choices) { FOR_EACH(choice, cards_choices) {
wxRadioButton* btn = new wxRadioButton(this, ID_SELECTION_CHOICE + i, choice->label); wxRadioButton* btn = new wxRadioButton(this, ID_SELECTION_CHOICE + i, choice->label);
btn->SetValue(i == 0);
btn->Enable(!choice->the_cards->empty() || choice->type == EXPORT_SEL_CUSTOM); btn->Enable(!choice->the_cards->empty() || choice->type == EXPORT_SEL_CUSTOM);
s->Add(btn, 0, wxALL, 6); s->Add(btn, 0, wxALL, 6);
s->AddSpacer(-4); s->AddSpacer(-4);
......
...@@ -42,7 +42,8 @@ typedef vector<ExportCardSelectionChoiceP> ExportCardSelectionChoices; ...@@ -42,7 +42,8 @@ typedef vector<ExportCardSelectionChoiceP> ExportCardSelectionChoices;
/// Base class for export windows, deals with card selection /// Base class for export windows, deals with card selection
class ExportWindowBase : public wxDialog { class ExportWindowBase : public wxDialog {
public: public:
ExportWindowBase(const SetP& set, const ExportCardSelectionChoices& cards_choices); ExportWindowBase(Window* parent, const String& window_title,
const SetP& set, const ExportCardSelectionChoices& cards_choices);
/// Create the controls, return a sizer containing them /// Create the controls, return a sizer containing them
wxSizer* Create(); wxSizer* Create();
......
...@@ -21,8 +21,8 @@ DECLARE_TYPEOF_COLLECTION(CardP); ...@@ -21,8 +21,8 @@ DECLARE_TYPEOF_COLLECTION(CardP);
// ----------------------------------------------------------------------------- : ImagesExportWindow // ----------------------------------------------------------------------------- : ImagesExportWindow
ImagesExportWindow::ImagesExportWindow(Window* parent, const SetP& set) ImagesExportWindow::ImagesExportWindow(Window* parent, const SetP& set, const ExportCardSelectionChoices& choices)
: CardSelectWindow(parent, set, wxEmptyString, _TITLE_("select cards export"), false) : ExportWindowBase(parent, _TITLE_("select cards export"), set, choices)
{ {
// init controls // init controls
GameSettings& gs = settings.gameSettingsFor(*set->game); GameSettings& gs = settings.gameSettingsFor(*set->game);
...@@ -42,17 +42,12 @@ ImagesExportWindow::ImagesExportWindow(Window* parent, const SetP& set) ...@@ -42,17 +42,12 @@ ImagesExportWindow::ImagesExportWindow(Window* parent, const SetP& set)
s2->Add(new wxStaticText(this, -1, _LABEL_("filename conflicts")), 0, wxALL, 4); s2->Add(new wxStaticText(this, -1, _LABEL_("filename conflicts")), 0, wxALL, 4);
s2->Add(conflicts, 0, wxEXPAND | wxALL & ~wxTOP, 4); s2->Add(conflicts, 0, wxEXPAND | wxALL & ~wxTOP, 4);
s->Add(s2, 0, wxEXPAND | wxALL, 8); s->Add(s2, 0, wxEXPAND | wxALL, 8);
wxSizer* s3 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("cards to export")); wxSizer* s3 = ExportWindowBase::Create();
s3->Add(list, 1, wxEXPAND | wxALL, 4);
wxSizer* s4 = new wxBoxSizer(wxHORIZONTAL);
s4->Add(sel_all, 0, wxEXPAND | wxRIGHT, 4);
s4->Add(sel_none, 0, wxEXPAND, 4);
s3->Add(s4, 0, wxEXPAND | wxALL & ~wxTOP, 8);
s->Add(s3, 1, wxEXPAND | wxALL & ~wxTOP, 8); s->Add(s3, 1, wxEXPAND | wxALL & ~wxTOP, 8);
s->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxEXPAND | wxALL & ~wxTOP, 8); s->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxEXPAND | wxALL & ~wxTOP, 8);
s->SetSizeHints(this); s->SetSizeHints(this);
SetSizer(s); SetSizer(s);
SetSize(500,500); SetSize(500,-1);
} }
// ----------------------------------------------------------------------------- : Exporting the images // ----------------------------------------------------------------------------- : Exporting the images
...@@ -70,16 +65,13 @@ void ImagesExportWindow::onOk(wxCommandEvent&) { ...@@ -70,16 +65,13 @@ void ImagesExportWindow::onOk(wxCommandEvent&) {
String name = wxFileSelector(_TITLE_("export images"),_(""), _LABEL_("filename is ignored"),_(""), String name = wxFileSelector(_TITLE_("export images"),_(""), _LABEL_("filename is ignored"),_(""),
_LABEL_("filename is ignored")+_("|*"), wxSAVE, this); _LABEL_("filename is ignored")+_("|*"), wxSAVE, this);
if (name.empty()) return; if (name.empty()) return;
// Cards to export
vector<CardP> cards;
getSelection(cards);
// Export // Export
export_images(set, cards, name, gs.images_export_filename, gs.images_export_conflicts); export_images(set, getSelection(), name, gs.images_export_filename, gs.images_export_conflicts);
// Done // Done
EndModal(wxID_OK); EndModal(wxID_OK);
} }
BEGIN_EVENT_TABLE(ImagesExportWindow,CardSelectWindow) BEGIN_EVENT_TABLE(ImagesExportWindow,ExportWindowBase)
EVT_BUTTON (wxID_OK, ImagesExportWindow::onOk) EVT_BUTTON (wxID_OK, ImagesExportWindow::onOk)
END_EVENT_TABLE () END_EVENT_TABLE ()
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
// ----------------------------------------------------------------------------- : ImagesExportWindow // ----------------------------------------------------------------------------- : ImagesExportWindow
/// A window for selecting a subset of the cards from a set to export to images /// A window for selecting a subset of the cards from a set to export to images
class ImagesExportWindow : public CardSelectWindow { class ImagesExportWindow : public ExportWindowBase {
public: public:
ImagesExportWindow(Window* parent, const SetP& set); ImagesExportWindow(Window* parent, const SetP& set, const ExportCardSelectionChoices& choices);
private: private:
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
......
...@@ -251,8 +251,7 @@ void CardsPrintout::drawCard(DC& dc, const CardP& card, int card_nr) { ...@@ -251,8 +251,7 @@ void CardsPrintout::drawCard(DC& dc, const CardP& card, int card_nr) {
const vector<CardP>* cards_to_print(Window* parent, const SetP& set, const ExportCardSelectionChoices& choices) { const vector<CardP>* cards_to_print(Window* parent, const SetP& set, const ExportCardSelectionChoices& choices) {
// Let the user choose cards // Let the user choose cards
//CardSelectWindow wnd(parent, set, _LABEL_("select cards print"), _TITLE_("select cards")); //CardSelectWindow wnd(parent, set, _LABEL_("select cards print"), _TITLE_("select cards"));
ExportWindowBase wnd(set, choices); ExportWindowBase wnd(parent, _TITLE_("select cards"), set, choices);
wnd.wxDialog::Create(parent, wxID_ANY, _TITLE_("select cards"));
wxSizer* s = new wxBoxSizer(wxVERTICAL); wxSizer* s = new wxBoxSizer(wxVERTICAL);
wxSizer* s2 = wnd.Create(); wxSizer* s2 = wnd.Create();
s->Add(s2, 1, wxEXPAND | wxALL, 8); s->Add(s2, 1, wxEXPAND | wxALL, 8);
......
...@@ -580,7 +580,9 @@ void SetWindow::onFileExportImage(wxCommandEvent&) { ...@@ -580,7 +580,9 @@ void SetWindow::onFileExportImage(wxCommandEvent&) {
} }
void SetWindow::onFileExportImages(wxCommandEvent&) { void SetWindow::onFileExportImages(wxCommandEvent&) {
ImagesExportWindow wnd(this, set); ExportCardSelectionChoices choices;
selectionChoices(choices);
ImagesExportWindow wnd(this, set, choices);
wnd.ShowModal(); wnd.ShowModal();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment