From f870f48b13d825a1f1e7783b3c34f2be5291d24c Mon Sep 17 00:00:00 2001 From: twanvl Date: Fri, 8 Aug 2008 22:16:06 +0000 Subject: [PATCH] HTML export widow also uses cards selector git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1109 0fc631ac-6414-0410-93d0-97cfa31319b6 --- doc/type/export_template.txt | 1 + src/gui/card_select_window.cpp | 4 ++-- src/gui/card_select_window.hpp | 2 +- src/gui/html_export_window.cpp | 17 +++++++++++------ src/gui/html_export_window.hpp | 5 +++-- src/gui/set/window.cpp | 4 +++- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/doc/type/export_template.txt b/doc/type/export_template.txt index 511cae0c..aafcae3d 100644 --- a/doc/type/export_template.txt +++ b/doc/type/export_template.txt @@ -35,6 +35,7 @@ During the evaluation of the script the following variables are available: | @game@ The current game. | @style@ The current stylesheet. | @set@ The set being exported. +| @cards@ The cards selected by the user. | @options@ The values of the @option fields@. | @directory@ Name of the directory created (if @create directory@ is set). diff --git a/src/gui/card_select_window.cpp b/src/gui/card_select_window.cpp index a7fdab71..89e66367 100644 --- a/src/gui/card_select_window.cpp +++ b/src/gui/card_select_window.cpp @@ -42,8 +42,8 @@ ExportCardSelectionChoice::ExportCardSelectionChoice(const String& label, const // ----------------------------------------------------------------------------- : ExportWindowBase -ExportWindowBase::ExportWindowBase(Window* parent, const String& title, const SetP& set, const ExportCardSelectionChoices& cards_choices) - : wxDialog(parent, wxID_ANY, title) +ExportWindowBase::ExportWindowBase(Window* parent, const String& title, const SetP& set, const ExportCardSelectionChoices& cards_choices, long style) + : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, style) , set(set), cards_choices(cards_choices) , active_choice(0) , select_cards(nullptr) diff --git a/src/gui/card_select_window.hpp b/src/gui/card_select_window.hpp index 0d857772..e66aeb16 100644 --- a/src/gui/card_select_window.hpp +++ b/src/gui/card_select_window.hpp @@ -43,7 +43,7 @@ typedef vector ExportCardSelectionChoices; class ExportWindowBase : public wxDialog { public: ExportWindowBase(Window* parent, const String& window_title, - const SetP& set, const ExportCardSelectionChoices& cards_choices); + const SetP& set, const ExportCardSelectionChoices& cards_choices, long style = wxDEFAULT_DIALOG_STYLE); /// Create the controls, return a sizer containing them wxSizer* Create(); diff --git a/src/gui/html_export_window.cpp b/src/gui/html_export_window.cpp index 03aea06f..a6577ea0 100644 --- a/src/gui/html_export_window.cpp +++ b/src/gui/html_export_window.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -24,8 +25,8 @@ DECLARE_POINTER_TYPE(ExportTemplate); // ----------------------------------------------------------------------------- : HtmlExportWindow -HtmlExportWindow::HtmlExportWindow(Window* parent, const SetP& set) - : wxDialog(parent,wxID_ANY,_TITLE_("export html"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxCLIP_CHILDREN) +HtmlExportWindow::HtmlExportWindow(Window* parent, const SetP& set, const ExportCardSelectionChoices& choices) + : ExportWindowBase(parent,_TITLE_("export html"), set, choices, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxCLIP_CHILDREN) , set(set) { // init controls @@ -36,8 +37,11 @@ HtmlExportWindow::HtmlExportWindow(Window* parent, const SetP& set) wxSizer* s = new wxBoxSizer(wxVERTICAL); s->Add(new wxStaticText(this, wxID_ANY, _LABEL_("html template")), 0, wxALL, 4); s->Add(list, 0, wxEXPAND | wxALL & ~wxTOP, 4); - wxSizer* s2 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("html export options")); - s2->Add(options, 2, wxEXPAND, 0); + wxSizer* s2 = new wxBoxSizer(wxHORIZONTAL); + s2->Add(ExportWindowBase::Create(), 2, wxEXPAND); + wxSizer* s3 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("html export options")); + s3->Add(options, 2, wxEXPAND, 0); + s2->Add(s3, 7, wxEXPAND | wxLEFT, 8); s->Add(s2, 1, wxEXPAND | wxALL, 4); s->Add(CreateButtonSizer(wxOK | wxCANCEL) , 0, wxEXPAND | wxALL, 8); s->SetSizeHints(this); @@ -72,6 +76,7 @@ void HtmlExportWindow::onOk(wxCommandEvent&) { // run export script Context& ctx = set->getContext(); LocalScope scope(ctx); + ctx.setVariable(_("cards"), to_script(&getSelection())); ctx.setVariable(_("options"), to_script(&settings.exportOptionsFor(*exp))); ctx.setVariable(_("directory"), to_script(info.directory_relative)); ScriptValueP result = exp->script.invoke(ctx); @@ -98,12 +103,12 @@ void HtmlExportWindow::onTemplateSelect(wxCommandEvent&) { void HtmlExportWindow::onUpdateUI(wxUpdateUIEvent& ev) { switch (ev.GetId()) { case wxID_OK: - ev.Enable(list->hasSelection()); + ev.Enable(list->hasSelection() && !getSelection().empty()); break; } } -BEGIN_EVENT_TABLE(HtmlExportWindow,wxDialog) +BEGIN_EVENT_TABLE(HtmlExportWindow,ExportWindowBase) EVT_GALLERY_SELECT (ID_EXPORT_LIST, HtmlExportWindow::onTemplateSelect) EVT_BUTTON (wxID_OK, HtmlExportWindow::onOk) EVT_UPDATE_UI (wxID_ANY, HtmlExportWindow::onUpdateUI) diff --git a/src/gui/html_export_window.hpp b/src/gui/html_export_window.hpp index bdbe4c89..2aa36915 100644 --- a/src/gui/html_export_window.hpp +++ b/src/gui/html_export_window.hpp @@ -10,6 +10,7 @@ // ----------------------------------------------------------------------------- : Includes #include +#include class PackageList; class ExportOptionsEditor; @@ -17,9 +18,9 @@ DECLARE_POINTER_TYPE(Set); // ----------------------------------------------------------------------------- : HtmlExportWindow -class HtmlExportWindow : public wxDialog { +class HtmlExportWindow : public ExportWindowBase { public: - HtmlExportWindow(Window* parent, const SetP& set); + HtmlExportWindow(Window* parent, const SetP& set, const ExportCardSelectionChoices& cards_choices); private: PackageList* list; ///< List of templates diff --git a/src/gui/set/window.cpp b/src/gui/set/window.cpp index d7522e3f..052fa21a 100644 --- a/src/gui/set/window.cpp +++ b/src/gui/set/window.cpp @@ -587,7 +587,9 @@ void SetWindow::onFileExportImages(wxCommandEvent&) { } void SetWindow::onFileExportHTML(wxCommandEvent&) { - HtmlExportWindow wnd(this, set); + ExportCardSelectionChoices choices; + selectionChoices(choices); + HtmlExportWindow wnd(this, set, choices); wnd.ShowModal(); }