mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
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
This commit is contained in:
@@ -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).
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -43,7 +43,7 @@ typedef vector<ExportCardSelectionChoiceP> 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();
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <gui/control/native_look_editor.hpp>
|
||||
#include <data/set.hpp>
|
||||
#include <data/game.hpp>
|
||||
#include <data/card.hpp>
|
||||
#include <data/settings.hpp>
|
||||
#include <data/export_template.hpp>
|
||||
#include <util/window_id.hpp>
|
||||
@@ -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)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/card_select_window.hpp>
|
||||
|
||||
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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user