diff --git a/Makefile.am b/Makefile.am index 92ef2155..0fa41651 100644 --- a/Makefile.am +++ b/Makefile.am @@ -89,13 +89,17 @@ magicseteditor_SOURCES += ./src/gui/drop_down_list.cpp magicseteditor_SOURCES += ./src/gui/image_slice_window.cpp magicseteditor_SOURCES += ./src/script/script_manager.cpp magicseteditor_SOURCES += ./src/script/script.cpp -magicseteditor_SOURCES += ./src/script/functions.cpp magicseteditor_SOURCES += ./src/script/value.cpp magicseteditor_SOURCES += ./src/script/dependency.cpp magicseteditor_SOURCES += ./src/script/image.cpp magicseteditor_SOURCES += ./src/script/context.cpp magicseteditor_SOURCES += ./src/script/scriptable.cpp magicseteditor_SOURCES += ./src/script/parser.cpp +magicseteditor_SOURCES += ./src/script/functions/basic.cpp +magicseteditor_SOURCES += ./src/script/functions/image.cpp +magicseteditor_SOURCES += ./src/script/functions/editor.cpp +magicseteditor_SOURCES += ./src/script/functions/export.cpp +magicseteditor_SOURCES += ./src/script/functions/english.cpp magicseteditor_SOURCES += ./src/data/field/color.cpp magicseteditor_SOURCES += ./src/data/field/boolean.cpp magicseteditor_SOURCES += ./src/data/field/image.cpp diff --git a/src/data/format/formats.hpp b/src/data/format/formats.hpp index 4875e5a9..e2b84dbf 100644 --- a/src/data/format/formats.hpp +++ b/src/data/format/formats.hpp @@ -92,7 +92,7 @@ void export_image(const SetP& set, const CardP& card, const String& filename); Bitmap export_bitmap(const SetP& set, const CardP& card); /// Export a set to Magic Workstation format -void export_mws(const SetP& set); +void export_mws(Window* parent, const SetP& set); // ----------------------------------------------------------------------------- : EOF #endif diff --git a/src/data/format/mws.cpp b/src/data/format/mws.cpp index 4e8517a1..3a8fc53e 100644 --- a/src/data/format/mws.cpp +++ b/src/data/format/mws.cpp @@ -52,7 +52,7 @@ String card_rarity_code(const String& rarity) { // ----------------------------------------------------------------------------- : export_mws -void export_mws(const SetP& set) { +void export_mws(Window* parent, const SetP& set) { if (!set->game->isMagic()) { throw Error(_("Can only export Magic sets to Magic Workstation")); } @@ -60,7 +60,7 @@ void export_mws(const SetP& set) { // Select filename String name = wxFileSelector(_("Export to file"),_(""),_(""),_(""), _("Text files (*.txt)|*.txt|All Files|*.*"), - wxSAVE | wxOVERWRITE_PROMPT); + wxSAVE | wxOVERWRITE_PROMPT, parent); if (name.empty()) return; wxBusyCursor busy; // Open file diff --git a/src/data/keyword.cpp b/src/data/keyword.cpp index 7825f822..c05ce63c 100644 --- a/src/data/keyword.cpp +++ b/src/data/keyword.cpp @@ -389,17 +389,17 @@ String KeywordDatabase::expand(const String& text, part = part + param; // keep tags } else if (kw->parameters[j/2-1]->script) { // apply parameter script - ctx.setVariable(_("input"), toScript(part)); + ctx.setVariable(_("input"), to_script(part)); part = kw->parameters[j/2-1]->script.invoke(ctx)->toString(); - ctx.setVariable(_("input"), toScript(part)); + ctx.setVariable(_("input"), to_script(part)); param = kw->parameters[j/2-1]->script.invoke(ctx)->toString(); } - ctx.setVariable(String(_("param")) << (int)(j/2), toScript(param)); + ctx.setVariable(String(_("param")) << (int)(j/2), to_script(param)); } total += part; start = part_end; } - ctx.setVariable(_("mode"), toScript(kw->mode)); + ctx.setVariable(_("mode"), to_script(kw->mode)); // Show reminder text? bool expand = expand_type == _('1'); @@ -412,8 +412,8 @@ String KeywordDatabase::expand(const String& text, // Combine keyword & reminder with result if (expand) { String reminder = kw->reminder.invoke(ctx)->toString(); - ctx.setVariable(_("keyword"), toScript(total)); - ctx.setVariable(_("reminder"), toScript(reminder)); + ctx.setVariable(_("keyword"), to_script(total)); + ctx.setVariable(_("reminder"), to_script(reminder)); result += _(""); result += combine_script->eval(ctx)->toString(); result += _(""); diff --git a/src/data/settings.cpp b/src/data/settings.cpp index 38cd3822..3282043c 100644 --- a/src/data/settings.cpp +++ b/src/data/settings.cpp @@ -33,7 +33,7 @@ ColumnSettings::ColumnSettings() {} // dummy for ColumnSettings reflection -ScriptValueP toScript(const ColumnSettings&) { return script_nil; } +ScriptValueP to_script(const ColumnSettings&) { return script_nil; } IMPLEMENT_REFLECTION(ColumnSettings) { REFLECT(width); diff --git a/src/gui/set/window.cpp b/src/gui/set/window.cpp index 455cbe0b..85e4c4a3 100644 --- a/src/gui/set/window.cpp +++ b/src/gui/set/window.cpp @@ -457,7 +457,7 @@ void SetWindow::onFileExportApprentice(wxCommandEvent&) { } void SetWindow::onFileExportMWS(wxCommandEvent&) { - export_mws(set); + export_mws(this, set); } void SetWindow::onFilePrint(wxCommandEvent&) { diff --git a/src/mse.vcproj b/src/mse.vcproj index 4b16c783..286cc113 100644 --- a/src/mse.vcproj +++ b/src/mse.vcproj @@ -2120,9 +2120,6 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + makeIterator(); break; case I_NEGATE: - a = toScript(-(int)*a); + a = to_script(-(int)*a); break; case I_NOT: - a = toScript(!(bool)*a); + a = to_script(!(bool)*a); break; } } @@ -224,26 +224,26 @@ void instrUnary (UnaryInstructionType i, ScriptValueP& a) { // operator on ints #define OPERATOR_I(OP) \ - a = toScript((int)*a OP (int)*b); \ + a = to_script((int)*a OP (int)*b); \ break // operator on doubles or ints #define OPERATOR_DI(OP) \ if (at == SCRIPT_DOUBLE || bt == SCRIPT_DOUBLE) { \ - a = toScript((double)*a OP (double)*b); \ + a = to_script((double)*a OP (double)*b); \ } else { \ - a = toScript((int)*a OP (int)*b); \ + a = to_script((int)*a OP (int)*b); \ } \ break // operator on strings or doubles or ints #define OPERATOR_SDI(OP) \ if (at == SCRIPT_STRING || bt == SCRIPT_STRING) { \ - a = toScript(a->toString() OP b->toString()); \ + a = to_script(a->toString() OP b->toString()); \ } else if (at == SCRIPT_DOUBLE || bt == SCRIPT_DOUBLE) { \ - a = toScript((double)*a OP (double)*b); \ + a = to_script((double)*a OP (double)*b); \ } else { \ - a = toScript((int)*a OP (int)*b); \ + a = to_script((int)*a OP (int)*b); \ } \ break @@ -283,13 +283,13 @@ void instrBinary (BinaryInstructionType i, ScriptValueP& a, const ScriptValueP& } else if (at == SCRIPT_FUNCTION && bt == SCRIPT_FUNCTION) { a = new_intrusive2(a, b); } else if (at == SCRIPT_STRING || bt == SCRIPT_STRING) { - a = toScript(a->toString() + b->toString()); + a = to_script(a->toString() + b->toString()); } else if (at == SCRIPT_DOUBLE || bt == SCRIPT_DOUBLE) { - a = toScript((double)*a + (double)*b); + a = to_script((double)*a + (double)*b); } else if (at == SCRIPT_INT || bt == SCRIPT_INT) { - a = toScript((int)*a + (int)*b); + a = to_script((int)*a + (int)*b); } else { - a = toScript(a->toString() + b->toString()); + a = to_script(a->toString() + b->toString()); } break; case I_SUB: OPERATOR_DI(-); @@ -297,9 +297,9 @@ void instrBinary (BinaryInstructionType i, ScriptValueP& a, const ScriptValueP& case I_DIV: OPERATOR_DI(/); case I_MOD: if (at == SCRIPT_DOUBLE || bt == SCRIPT_DOUBLE) { - a = toScript(fmod((double)*a, (double)*b)); + a = to_script(fmod((double)*a, (double)*b)); } else { - a = toScript((int)*a % (int)*b); + a = to_script((int)*a % (int)*b); } break; case I_AND: OPERATOR_I(&&); @@ -318,7 +318,7 @@ void instrBinary (BinaryInstructionType i, ScriptValueP& a, const ScriptValueP& void instrTernary(TernaryInstructionType i, ScriptValueP& a, const ScriptValueP& b, const ScriptValueP& c) { switch (i) { case I_RGB: - a = toScript(Color((int)*a, (int)*b, (int)*c)); + a = to_script(Color((int)*a, (int)*b, (int)*c)); break; } } diff --git a/src/script/functions.cpp b/src/script/functions/basic.cpp similarity index 65% rename from src/script/functions.cpp rename to src/script/functions/basic.cpp index 7d2e7a26..724a4f9a 100644 --- a/src/script/functions.cpp +++ b/src/script/functions/basic.cpp @@ -6,25 +6,203 @@ // ----------------------------------------------------------------------------- : Includes -#include