Commit 70b9f85f authored by twanvl's avatar twanvl

Script errors now have information on where the error occureed (what value);

Script operator "int + object" now uses string concatenation instead of converting the object to integer;
Html export window uses a dummy set for editing options, so we don't pollute the set's undo stack;
Choice rendererer in nativelook 'both' style always leaves room for the icon;
Version bump
parent c272ed49
......@@ -29,7 +29,7 @@ HtmlExportWindow::HtmlExportWindow(Window* parent, const SetP& set)
// init controls
list = new PackageList(this, ID_EXPORT_LIST);
options = new ExportOptionsEditor(this, wxID_ANY, wxNO_BORDER);
options->setSet(set);
options->setSet(new_intrusive1<Set>(set->stylesheet)); // dummy set
// init sizers
wxSizer* s = new wxBoxSizer(wxVERTICAL);
s->Add(new wxStaticText(this, wxID_ANY, _LABEL_("html template")), 0, wxALL, 4);
......
......@@ -35,7 +35,7 @@ StylePanel::StylePanel(Window* parent, int id)
s2->Add(list, 0, wxEXPAND | wxBOTTOM, 4);
s2->Add(use_for_all, 0, wxRIGHT | wxBOTTOM | wxALIGN_RIGHT, 4);
wxSizer* s3 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("styling options"));
s3->Add(use_custom_options, 0, wxEXPAND, 0);
s3->Add(use_custom_options, 0, wxEXPAND | wxALL, 4);
s3->Add(editor, 2, wxEXPAND, 0);
s2->Add(s3, 1, wxEXPAND | wxALL, 2);
s->Add(s2, 1, wxEXPAND, 8);
......
......@@ -39,7 +39,7 @@ WelcomeWindow::WelcomeWindow()
wxControl* open_last = nullptr;
if (!settings.recent_sets.empty()) {
wxFileName n(settings.recent_sets.front());
if (n.FileExists())
if (n.FileExists() || n.DirExists())
#ifdef USE_HOVERBUTTON
open_last = new HoverButtonExt(this, ID_FILE_RECENT, load_resource_image(_("welcome_last")), _BUTTON_("last opened set"), _("Open '") + n.GetName() + _("'"));
#else
......
......@@ -53,6 +53,9 @@ void ChoiceValueViewer::draw(RotatedDC& dc) {
style().angle
);
margin = dc.trInvS(image.GetWidth()) + 1;
} else if (nativeLook()) {
// always have the margin
margin = 17;
}
}
if (style().render_style & RENDER_TEXT) {
......
......@@ -240,14 +240,13 @@ void instrUnary (UnaryInstructionType i, ScriptValueP& a) {
} \
break
// operator on strings or doubles or ints
// operator on strings or doubles or ints, when in doubt, uses strings
#define OPERATOR_SDI(OP) \
if (at == SCRIPT_STRING || bt == SCRIPT_STRING) { \
a = to_script(a->toString() OP b->toString()); \
} else if (at == SCRIPT_DOUBLE || bt == SCRIPT_DOUBLE) { \
a = to_script((double)*a OP (double)*b); \
} else if (at == SCRIPT_INT || bt == SCRIPT_INT ) { \
if (at == SCRIPT_INT && bt == SCRIPT_INT) { \
a = to_script((int)*a OP (int)*b); \
} else if ((at == SCRIPT_INT || at == SCRIPT_DOUBLE) && \
(bt == SCRIPT_INT || bt == SCRIPT_DOUBLE)) { \
a = to_script((double)*a OP (double)*b); \
} else { \
a = to_script(a->toString() OP b->toString()); \
} \
......@@ -288,12 +287,11 @@ void instrBinary (BinaryInstructionType i, ScriptValueP& a, const ScriptValueP&
// a = a;
} else if (at == SCRIPT_FUNCTION && bt == SCRIPT_FUNCTION) {
a = new_intrusive2<ScriptCompose>(a, b);
} else if (at == SCRIPT_STRING || bt == SCRIPT_STRING) {
a = to_script(a->toString() + b->toString());
} else if (at == SCRIPT_DOUBLE || bt == SCRIPT_DOUBLE) {
a = to_script((double)*a + (double)*b);
} else if (at == SCRIPT_INT || bt == SCRIPT_INT) {
} else if (at == SCRIPT_INT && bt == SCRIPT_INT) {
a = to_script((int)*a + (int)*b);
} else if ((at == SCRIPT_INT || at == SCRIPT_DOUBLE) &&
(bt == SCRIPT_INT || bt == SCRIPT_DOUBLE)) {
a = to_script((double)*a + (double)*b);
} else {
a = to_script(a->toString() + b->toString());
}
......
......@@ -214,9 +214,13 @@ void SetScriptManager::updateStyles(const CardP& card) {
}
void SetScriptManager::updateStyles(Context& ctx, const IndexMap<FieldP,StyleP>& styles) {
FOR_EACH_CONST(s, styles) {
if (s->update(ctx)) {
// style has changed, tell listeners
s->tellListeners();
try {
if (s->update(ctx)) {
// style has changed, tell listeners
s->tellListeners();
}
} catch (const ScriptError& e) {
throw ScriptError(e.what() + _("\nWhile updating styles for '") + s->fieldP->name + _("'"));
}
}
}
......@@ -251,13 +255,21 @@ void SetScriptManager::updateAll() {
// update set data
Context& ctx = getContext(set.stylesheet);
FOR_EACH(v, set.data) {
v->update(ctx);
try {
v->update(ctx);
} catch (const ScriptError& e) {
throw ScriptError(e.what() + _("\nWhile updating set value '") + v->fieldP->name + _("'"));
}
}
// update card data of all cards
FOR_EACH(card, set.cards) {
Context& ctx = getContext(card);
FOR_EACH(v, card->data) {
v->update(ctx);
try {
v->update(ctx);
} catch (const ScriptError& e) {
throw ScriptError(e.what() + _("\nWhile updating card value '") + v->fieldP->name + _("'"));
}
}
}
// update things that depend on the card list
......@@ -286,7 +298,13 @@ void SetScriptManager::updateToUpdate(const ToUpdate& u, deque<ToUpdate>& to_upd
Age age = u.value->last_script_update;
if (starting_age < age) return; // this value was already updated
Context& ctx = getContext(u.card);
if (u.value->update(ctx)) {
bool changes;
try {
changes = u.value->update(ctx);
} catch (const ScriptError& e) {
throw ScriptError(e.what() + _("\nWhile updating value '") + u.value->fieldP->name + _("'"));
}
if (changes) {
// changed, send event
ScriptValueEvent change(u.card.get(), u.value);
set.actions.tellListeners(change, false);
......
......@@ -49,7 +49,7 @@ template <> void GetDefaultMember::handle(const Version& v) {
// ----------------------------------------------------------------------------- : Versions
// NOTE: Don't use leading zeroes, they mean octal
const Version app_version = 303; // 0.3.3
const Version app_version = 304; // 0.3.4
#ifdef UNICODE
const Char* version_suffix = _(" (beta)");
#else
......@@ -65,5 +65,6 @@ const Char* version_suffix = _(" (beta, ascii build)");
* 0.3.1 : new keyword system, some new style options
* 0.3.2 : package dependencies
* 0.3.3 : keyword separator before/after
* 0.3.4 : html export; choice rendering based on scripted 'image'
*/
const Version file_version = 303; // 0.3.3
const Version file_version = 304; // 0.3.4
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