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();
void export_images(Window* parent, const SetP& set);
/// 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);
/// Export the image of a single card
......
......@@ -66,7 +66,7 @@ Bitmap export_bitmap(const SetP& set, const CardP& card) {
// ----------------------------------------------------------------------------- : 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)
{
wxBusyCursor busy;
......
......@@ -42,8 +42,9 @@ ExportCardSelectionChoice::ExportCardSelectionChoice(const String& label, const
// ----------------------------------------------------------------------------- : ExportWindowBase
ExportWindowBase::ExportWindowBase(const SetP& set, const ExportCardSelectionChoices& cards_choices)
: set(set), cards_choices(cards_choices)
ExportWindowBase::ExportWindowBase(Window* parent, const String& title, const SetP& set, const ExportCardSelectionChoices& cards_choices)
: wxDialog(parent, wxID_ANY, title)
, set(set), cards_choices(cards_choices)
, active_choice(0)
, select_cards(nullptr)
{}
......@@ -56,6 +57,7 @@ wxSizer* ExportWindowBase::Create() {
bool any_custom = false;
FOR_EACH(choice, cards_choices) {
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);
s->Add(btn, 0, wxALL, 6);
s->AddSpacer(-4);
......
......@@ -42,7 +42,8 @@ typedef vector<ExportCardSelectionChoiceP> ExportCardSelectionChoices;
/// Base class for export windows, deals with card selection
class ExportWindowBase : public wxDialog {
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
wxSizer* Create();
......
......@@ -21,8 +21,8 @@ DECLARE_TYPEOF_COLLECTION(CardP);
// ----------------------------------------------------------------------------- : ImagesExportWindow
ImagesExportWindow::ImagesExportWindow(Window* parent, const SetP& set)
: CardSelectWindow(parent, set, wxEmptyString, _TITLE_("select cards export"), false)
ImagesExportWindow::ImagesExportWindow(Window* parent, const SetP& set, const ExportCardSelectionChoices& choices)
: ExportWindowBase(parent, _TITLE_("select cards export"), set, choices)
{
// init controls
GameSettings& gs = settings.gameSettingsFor(*set->game);
......@@ -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(conflicts, 0, wxEXPAND | wxALL & ~wxTOP, 4);
s->Add(s2, 0, wxEXPAND | wxALL, 8);
wxSizer* s3 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("cards to export"));
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);
wxSizer* s3 = ExportWindowBase::Create();
s->Add(s3, 1, wxEXPAND | wxALL & ~wxTOP, 8);
s->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxEXPAND | wxALL & ~wxTOP, 8);
s->SetSizeHints(this);
SetSizer(s);
SetSize(500,500);
SetSize(500,-1);
}
// ----------------------------------------------------------------------------- : Exporting the images
......@@ -70,16 +65,13 @@ void ImagesExportWindow::onOk(wxCommandEvent&) {
String name = wxFileSelector(_TITLE_("export images"),_(""), _LABEL_("filename is ignored"),_(""),
_LABEL_("filename is ignored")+_("|*"), wxSAVE, this);
if (name.empty()) return;
// Cards to export
vector<CardP> cards;
getSelection(cards);
// 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
EndModal(wxID_OK);
}
BEGIN_EVENT_TABLE(ImagesExportWindow,CardSelectWindow)
BEGIN_EVENT_TABLE(ImagesExportWindow,ExportWindowBase)
EVT_BUTTON (wxID_OK, ImagesExportWindow::onOk)
END_EVENT_TABLE ()
......@@ -16,9 +16,9 @@
// ----------------------------------------------------------------------------- : ImagesExportWindow
/// 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:
ImagesExportWindow(Window* parent, const SetP& set);
ImagesExportWindow(Window* parent, const SetP& set, const ExportCardSelectionChoices& choices);
private:
DECLARE_EVENT_TABLE();
......
......@@ -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) {
// Let the user choose cards
//CardSelectWindow wnd(parent, set, _LABEL_("select cards print"), _TITLE_("select cards"));
ExportWindowBase wnd(set, choices);
wnd.wxDialog::Create(parent, wxID_ANY, _TITLE_("select cards"));
ExportWindowBase wnd(parent, _TITLE_("select cards"), set, choices);
wxSizer* s = new wxBoxSizer(wxVERTICAL);
wxSizer* s2 = wnd.Create();
s->Add(s2, 1, wxEXPAND | wxALL, 8);
......
......@@ -580,7 +580,9 @@ void SetWindow::onFileExportImage(wxCommandEvent&) {
}
void SetWindow::onFileExportImages(wxCommandEvent&) {
ImagesExportWindow wnd(this, set);
ExportCardSelectionChoices choices;
selectionChoices(choices);
ImagesExportWindow wnd(this, set, choices);
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