mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Cleaned up Set::Styling/Card::Styling by spliting that functionality into a 'DelayedIndexMaps' class;
Added 'right' and 'bottom' properties to style as an alternative way of specifying width/height; Added content_width, content_height and content_lines properties that give feedback on text rendering; Always show warnings when showing errors and vice-versa, this prevents script errors from appearing before the reader/parse error that caused them; Finally some preliminairy work on export templates git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@428 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/control/card_editor.hpp>
|
||||
|
||||
DECLARE_POINTER_TYPE(ExportTemplate);
|
||||
|
||||
// ----------------------------------------------------------------------------- : NativeLookEditor
|
||||
|
||||
/// A data editor with a platform native look
|
||||
@@ -71,7 +73,20 @@ class StylingEditor : public NativeLookEditor {
|
||||
|
||||
protected:
|
||||
virtual void onChangeSet();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : ExportOptionsEditor
|
||||
|
||||
/// Editor for export options
|
||||
class ExportOptionsEditor : public NativeLookEditor {
|
||||
public:
|
||||
ExportOptionsEditor(Window* parent, int id, long style = 0);
|
||||
|
||||
/// Show the options for given export template
|
||||
void showExport(const ExportTemplateP& export);
|
||||
|
||||
protected:
|
||||
virtual void onChangeSet();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
|
||||
@@ -8,16 +8,23 @@
|
||||
|
||||
#include <gui/html_export_window.hpp>
|
||||
#include <gui/control/package_list.hpp>
|
||||
#include <data/set.hpp>
|
||||
#include <data/game.hpp>
|
||||
#include <data/settings.hpp>
|
||||
#include <data/export_template.hpp>
|
||||
#include <util/window_id.hpp>
|
||||
#include <util/error.hpp>
|
||||
|
||||
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 | wxFULL_REPAINT_ON_RESIZE)
|
||||
, set(set)
|
||||
{
|
||||
// init controls
|
||||
list = new PackageList (this, wxID_ANY);
|
||||
list = new PackageList(this, ID_EXPORT_LIST);
|
||||
// init sizers
|
||||
wxSizer* s = new wxBoxSizer(wxVERTICAL);
|
||||
s->Add(new wxStaticText(this, wxID_ANY, _LABEL_("html template")), 0, wxALL, 4);
|
||||
@@ -25,6 +32,9 @@ HtmlExportWindow::HtmlExportWindow(Window* parent, const SetP& set)
|
||||
s->Add(CreateButtonSizer(wxOK | wxCANCEL) , 0, wxEXPAND | wxALL, 8);
|
||||
s->SetSizeHints(this);
|
||||
SetSizer(s);
|
||||
// list
|
||||
list->showData<ExportTemplate>(set->game->name() + _("-*"));
|
||||
list->select(settings.gameSettingsFor(*set->game).default_export);
|
||||
}
|
||||
|
||||
void HtmlExportWindow::onOk(wxCommandEvent&) {
|
||||
@@ -43,6 +53,24 @@ void HtmlExportWindow::onOk(wxCommandEvent&) {
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
|
||||
void HtmlExportWindow::onTemplateSelect(wxCommandEvent&) {
|
||||
wxBusyCursor wait;
|
||||
ExportTemplateP export = list->getSelection<ExportTemplate>();
|
||||
handle_pending_errors();
|
||||
settings.gameSettingsFor(*set->game).default_export = export->name();
|
||||
UpdateWindowUI(wxUPDATE_UI_RECURSE);
|
||||
}
|
||||
|
||||
void HtmlExportWindow::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
switch (ev.GetId()) {
|
||||
case wxID_OK:
|
||||
ev.Enable(list->hasSelection());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(HtmlExportWindow,wxDialog)
|
||||
EVT_BUTTON (wxID_OK, HtmlExportWindow::onOk)
|
||||
EVT_GALLERY_SELECT (ID_EXPORT_LIST, HtmlExportWindow::onTemplateSelect)
|
||||
EVT_BUTTON (wxID_OK, HtmlExportWindow::onOk)
|
||||
EVT_UPDATE_UI (wxID_ANY, HtmlExportWindow::onUpdateUI)
|
||||
END_EVENT_TABLE ()
|
||||
|
||||
@@ -22,10 +22,13 @@ class HtmlExportWindow : public wxDialog {
|
||||
|
||||
private:
|
||||
PackageList* list; ///< List of templates
|
||||
SetP set; ///< Set to export
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
void onOk(wxCommandEvent&);
|
||||
void onTemplateSelect(wxCommandEvent&);
|
||||
void onUpdateUI(wxUpdateUIEvent& ev);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
|
||||
@@ -50,9 +50,9 @@ NewSetWindow::NewSetWindow(Window* parent)
|
||||
// init lists
|
||||
game_list->showData<Game>();
|
||||
try {
|
||||
game_list->select(settings.default_game);
|
||||
game_list->select(settings.default_game);
|
||||
} catch (FileNotFoundError e) {
|
||||
handle_error(e);
|
||||
handle_error(e);
|
||||
}
|
||||
UpdateWindowUI(wxUPDATE_UI_RECURSE);
|
||||
}
|
||||
@@ -62,9 +62,8 @@ void NewSetWindow::onGameSelect(wxCommandEvent&) {
|
||||
GameP game = game_list->getSelection<Game>();
|
||||
handle_pending_errors();
|
||||
settings.default_game = game->name();
|
||||
GameSettings& gs = settings.gameSettingsFor(*game);
|
||||
stylesheet_list->showData<StyleSheet>(game->name() + _("-*"));
|
||||
stylesheet_list->select(gs.default_stylesheet);
|
||||
stylesheet_list->select(settings.gameSettingsFor(*game).default_stylesheet);
|
||||
UpdateWindowUI(wxUPDATE_UI_RECURSE);
|
||||
// resize (yuck)
|
||||
SetSize(630,-1);
|
||||
@@ -80,8 +79,7 @@ void NewSetWindow::onStyleSheetSelect(wxCommandEvent&) {
|
||||
GameP game = game_list ->getSelection<Game>();
|
||||
StyleSheetP stylesheet = stylesheet_list->getSelection<StyleSheet>();
|
||||
handle_pending_errors();
|
||||
GameSettings& gs = settings.gameSettingsFor(*game);
|
||||
gs.default_stylesheet = stylesheet->name();
|
||||
settings.gameSettingsFor(*game).default_stylesheet = stylesheet->name();
|
||||
UpdateWindowUI(wxUPDATE_UI_RECURSE);
|
||||
}
|
||||
void NewSetWindow::onStyleSheetActivate(wxCommandEvent&) {
|
||||
|
||||
Reference in New Issue
Block a user