Commit 56f1d900 authored by twanvl's avatar twanvl

HTML export widow also uses cards selector

parent 505d079c
...@@ -35,6 +35,7 @@ During the evaluation of the script the following variables are available: ...@@ -35,6 +35,7 @@ During the evaluation of the script the following variables are available:
| @game@ The current game. | @game@ The current game.
| @style@ The current stylesheet. | @style@ The current stylesheet.
| @set@ The set being exported. | @set@ The set being exported.
| @cards@ The cards selected by the user.
| @options@ The values of the @option fields@. | @options@ The values of the @option fields@.
| @directory@ Name of the directory created (if @create directory@ is set). | @directory@ Name of the directory created (if @create directory@ is set).
......
...@@ -42,8 +42,8 @@ ExportCardSelectionChoice::ExportCardSelectionChoice(const String& label, const ...@@ -42,8 +42,8 @@ ExportCardSelectionChoice::ExportCardSelectionChoice(const String& label, const
// ----------------------------------------------------------------------------- : ExportWindowBase // ----------------------------------------------------------------------------- : ExportWindowBase
ExportWindowBase::ExportWindowBase(Window* parent, const String& title, const SetP& set, const ExportCardSelectionChoices& cards_choices) ExportWindowBase::ExportWindowBase(Window* parent, const String& title, const SetP& set, const ExportCardSelectionChoices& cards_choices, long style)
: wxDialog(parent, wxID_ANY, title) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, style)
, set(set), cards_choices(cards_choices) , set(set), cards_choices(cards_choices)
, active_choice(0) , active_choice(0)
, select_cards(nullptr) , select_cards(nullptr)
......
...@@ -43,7 +43,7 @@ typedef vector<ExportCardSelectionChoiceP> ExportCardSelectionChoices; ...@@ -43,7 +43,7 @@ typedef vector<ExportCardSelectionChoiceP> ExportCardSelectionChoices;
class ExportWindowBase : public wxDialog { class ExportWindowBase : public wxDialog {
public: public:
ExportWindowBase(Window* parent, const String& window_title, 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 /// Create the controls, return a sizer containing them
wxSizer* Create(); wxSizer* Create();
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <gui/control/native_look_editor.hpp> #include <gui/control/native_look_editor.hpp>
#include <data/set.hpp> #include <data/set.hpp>
#include <data/game.hpp> #include <data/game.hpp>
#include <data/card.hpp>
#include <data/settings.hpp> #include <data/settings.hpp>
#include <data/export_template.hpp> #include <data/export_template.hpp>
#include <util/window_id.hpp> #include <util/window_id.hpp>
...@@ -24,8 +25,8 @@ DECLARE_POINTER_TYPE(ExportTemplate); ...@@ -24,8 +25,8 @@ DECLARE_POINTER_TYPE(ExportTemplate);
// ----------------------------------------------------------------------------- : HtmlExportWindow // ----------------------------------------------------------------------------- : HtmlExportWindow
HtmlExportWindow::HtmlExportWindow(Window* parent, const SetP& set) HtmlExportWindow::HtmlExportWindow(Window* parent, const SetP& set, const ExportCardSelectionChoices& choices)
: wxDialog(parent,wxID_ANY,_TITLE_("export html"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxCLIP_CHILDREN) : ExportWindowBase(parent,_TITLE_("export html"), set, choices, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxCLIP_CHILDREN)
, set(set) , set(set)
{ {
// init controls // init controls
...@@ -36,8 +37,11 @@ HtmlExportWindow::HtmlExportWindow(Window* parent, const SetP& set) ...@@ -36,8 +37,11 @@ HtmlExportWindow::HtmlExportWindow(Window* parent, const SetP& set)
wxSizer* s = new wxBoxSizer(wxVERTICAL); wxSizer* s = new wxBoxSizer(wxVERTICAL);
s->Add(new wxStaticText(this, wxID_ANY, _LABEL_("html template")), 0, wxALL, 4); s->Add(new wxStaticText(this, wxID_ANY, _LABEL_("html template")), 0, wxALL, 4);
s->Add(list, 0, wxEXPAND | wxALL & ~wxTOP, 4); s->Add(list, 0, wxEXPAND | wxALL & ~wxTOP, 4);
wxSizer* s2 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("html export options")); wxSizer* s2 = new wxBoxSizer(wxHORIZONTAL);
s2->Add(options, 2, wxEXPAND, 0); 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(s2, 1, wxEXPAND | wxALL, 4);
s->Add(CreateButtonSizer(wxOK | wxCANCEL) , 0, wxEXPAND | wxALL, 8); s->Add(CreateButtonSizer(wxOK | wxCANCEL) , 0, wxEXPAND | wxALL, 8);
s->SetSizeHints(this); s->SetSizeHints(this);
...@@ -72,6 +76,7 @@ void HtmlExportWindow::onOk(wxCommandEvent&) { ...@@ -72,6 +76,7 @@ void HtmlExportWindow::onOk(wxCommandEvent&) {
// run export script // run export script
Context& ctx = set->getContext(); Context& ctx = set->getContext();
LocalScope scope(ctx); LocalScope scope(ctx);
ctx.setVariable(_("cards"), to_script(&getSelection()));
ctx.setVariable(_("options"), to_script(&settings.exportOptionsFor(*exp))); ctx.setVariable(_("options"), to_script(&settings.exportOptionsFor(*exp)));
ctx.setVariable(_("directory"), to_script(info.directory_relative)); ctx.setVariable(_("directory"), to_script(info.directory_relative));
ScriptValueP result = exp->script.invoke(ctx); ScriptValueP result = exp->script.invoke(ctx);
...@@ -98,12 +103,12 @@ void HtmlExportWindow::onTemplateSelect(wxCommandEvent&) { ...@@ -98,12 +103,12 @@ void HtmlExportWindow::onTemplateSelect(wxCommandEvent&) {
void HtmlExportWindow::onUpdateUI(wxUpdateUIEvent& ev) { void HtmlExportWindow::onUpdateUI(wxUpdateUIEvent& ev) {
switch (ev.GetId()) { switch (ev.GetId()) {
case wxID_OK: case wxID_OK:
ev.Enable(list->hasSelection()); ev.Enable(list->hasSelection() && !getSelection().empty());
break; break;
} }
} }
BEGIN_EVENT_TABLE(HtmlExportWindow,wxDialog) BEGIN_EVENT_TABLE(HtmlExportWindow,ExportWindowBase)
EVT_GALLERY_SELECT (ID_EXPORT_LIST, HtmlExportWindow::onTemplateSelect) EVT_GALLERY_SELECT (ID_EXPORT_LIST, HtmlExportWindow::onTemplateSelect)
EVT_BUTTON (wxID_OK, HtmlExportWindow::onOk) EVT_BUTTON (wxID_OK, HtmlExportWindow::onOk)
EVT_UPDATE_UI (wxID_ANY, HtmlExportWindow::onUpdateUI) EVT_UPDATE_UI (wxID_ANY, HtmlExportWindow::onUpdateUI)
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
// ----------------------------------------------------------------------------- : Includes // ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp> #include <util/prec.hpp>
#include <gui/card_select_window.hpp>
class PackageList; class PackageList;
class ExportOptionsEditor; class ExportOptionsEditor;
...@@ -17,9 +18,9 @@ DECLARE_POINTER_TYPE(Set); ...@@ -17,9 +18,9 @@ DECLARE_POINTER_TYPE(Set);
// ----------------------------------------------------------------------------- : HtmlExportWindow // ----------------------------------------------------------------------------- : HtmlExportWindow
class HtmlExportWindow : public wxDialog { class HtmlExportWindow : public ExportWindowBase {
public: public:
HtmlExportWindow(Window* parent, const SetP& set); HtmlExportWindow(Window* parent, const SetP& set, const ExportCardSelectionChoices& cards_choices);
private: private:
PackageList* list; ///< List of templates PackageList* list; ///< List of templates
......
...@@ -587,7 +587,9 @@ void SetWindow::onFileExportImages(wxCommandEvent&) { ...@@ -587,7 +587,9 @@ void SetWindow::onFileExportImages(wxCommandEvent&) {
} }
void SetWindow::onFileExportHTML(wxCommandEvent&) { void SetWindow::onFileExportHTML(wxCommandEvent&) {
HtmlExportWindow wnd(this, set); ExportCardSelectionChoices choices;
selectionChoices(choices);
HtmlExportWindow 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