Commit 9ea0a462 authored by twanvl's avatar twanvl

big change:

 * cannocial_name_form now outputs "_" where it used to use " "
   this simplifies some things, because now C++ names are also MSE internal names
 * added 'caption' property to fields. This is used instead of the name in NativeLookEditor, since the latter will now contain underscores.
parent 1f6fa71e
...@@ -51,6 +51,7 @@ IMPLEMENT_REFLECTION(Field) { ...@@ -51,6 +51,7 @@ IMPLEMENT_REFLECTION(Field) {
} }
REFLECT(name); REFLECT(name);
REFLECT_IF_READING name = canonical_name_form(name); REFLECT_IF_READING name = canonical_name_form(name);
REFLECT(caption);
REFLECT(description); REFLECT(description);
REFLECT_N("icon", icon_filename); REFLECT_N("icon", icon_filename);
REFLECT(editable); REFLECT(editable);
...@@ -64,9 +65,10 @@ IMPLEMENT_REFLECTION(Field) { ...@@ -64,9 +65,10 @@ IMPLEMENT_REFLECTION(Field) {
REFLECT(card_list_allow); REFLECT(card_list_allow);
REFLECT(card_list_name); REFLECT(card_list_name);
REFLECT(sort_script); REFLECT(sort_script);
REFLECT_IF_READING if(card_list_name.empty()) card_list_name = name;
REFLECT_N("card_list_alignment", card_list_align); REFLECT_N("card_list_alignment", card_list_align);
REFLECT(tab_index); REFLECT(tab_index);
REFLECT_IF_READING if(caption.empty()) caption = name_to_caption(name);
REFLECT_IF_READING if(card_list_name.empty()) card_list_name = capitalize(caption);
} }
template <> template <>
......
...@@ -44,8 +44,9 @@ class Field : public IntrusivePtrVirtualBase { ...@@ -44,8 +44,9 @@ class Field : public IntrusivePtrVirtualBase {
size_t index; ///< Used by IndexMap size_t index; ///< Used by IndexMap
String name; ///< Name of the field, for refering to it from scripts and files String name; ///< Name of the field, for refering to it from scripts and files
String caption; ///< Caption for NativeLookEditor
String description; ///< Description, used in status bar String description; ///< Description, used in status bar
String icon_filename; ///< Filename for an icon (for list of fields) String icon_filename; ///< Filename for an icon (for list of fields)
bool editable; ///< Can values of this field be edited? bool editable; ///< Can values of this field be edited?
bool save_value; ///< Should values of this field be written to files? Can be false for script generated fields. bool save_value; ///< Should values of this field be written to files? Can be false for script generated fields.
bool show_statistics; ///< Should this field appear as a group by choice in the statistics panel? bool show_statistics; ///< Should this field appear as a group by choice in the statistics panel?
......
...@@ -270,7 +270,7 @@ template <> void reflect_content(GetMember& tag, const ChoiceStyle& cs ...@@ -270,7 +270,7 @@ template <> void reflect_content(GetMember& tag, const ChoiceStyle& cs
} }
IMPLEMENT_REFLECTION(ChoiceStyle) { IMPLEMENT_REFLECTION(ChoiceStyle) {
REFLECT_ALIAS(300, "card list colors", "colors card list"); REFLECT_ALIAS(300, "card_list_colors", "colors_card_list");
REFLECT_BASE(Style); REFLECT_BASE(Style);
REFLECT(popup_style); REFLECT(popup_style);
REFLECT(render_style); REFLECT(render_style);
......
...@@ -53,7 +53,7 @@ IMPLEMENT_REFLECTION_NAMELESS(MultipleChoiceValue) { ...@@ -53,7 +53,7 @@ IMPLEMENT_REFLECTION_NAMELESS(MultipleChoiceValue) {
bool MultipleChoiceValue::update(Context& ctx) { bool MultipleChoiceValue::update(Context& ctx) {
String old_value = value(); String old_value = value();
ctx.setVariable(_("last change"), to_script(last_change)); ctx.setVariable(_("last_change"), to_script(last_change));
ChoiceValue::update(ctx); ChoiceValue::update(ctx);
normalForm(); normalForm();
return value() != old_value; return value() != old_value;
......
...@@ -54,7 +54,7 @@ IMPLEMENT_REFLECTION(Game) { ...@@ -54,7 +54,7 @@ IMPLEMENT_REFLECTION(Game) {
REFLECT_NO_SCRIPT(card_list_color_script); REFLECT_NO_SCRIPT(card_list_color_script);
REFLECT_NO_SCRIPT(statistics_dimensions); REFLECT_NO_SCRIPT(statistics_dimensions);
REFLECT_NO_SCRIPT(statistics_categories); REFLECT_NO_SCRIPT(statistics_categories);
REFLECT_ALIAS(308, "pack item", "pack type"); REFLECT_ALIAS(308, "pack_item", "pack_type");
REFLECT_NO_SCRIPT(pack_types); REFLECT_NO_SCRIPT(pack_types);
REFLECT_NO_SCRIPT(keyword_match_script); REFLECT_NO_SCRIPT(keyword_match_script);
REFLECT(has_keywords); REFLECT(has_keywords);
......
...@@ -248,7 +248,7 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(PackageDescription) { ...@@ -248,7 +248,7 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(PackageDescription) {
REFLECT(installer_group); REFLECT(installer_group);
REFLECT(position_hint); REFLECT(position_hint);
REFLECT(description); REFLECT(description);
REFLECT_N("depends ons", dependencies); REFLECT_N("depends_ons", dependencies);
} }
void PackageDescription::merge(const PackageDescription& p2) { void PackageDescription::merge(const PackageDescription& p2) {
......
...@@ -676,8 +676,8 @@ bool KeywordDatabase::tryExpand(const Keyword& kw, ...@@ -676,8 +676,8 @@ bool KeywordDatabase::tryExpand(const Keyword& kw,
part_start = part_end; part_start = part_end;
} }
ctx.setVariable(_("mode"), to_script(kw.mode)); ctx.setVariable(_("mode"), to_script(kw.mode));
ctx.setVariable(_("correct case"), to_script(correct_case)); ctx.setVariable(_("correct_case"), to_script(correct_case));
ctx.setVariable(_("used placeholders"), to_script(used_placeholders)); ctx.setVariable(_("used_placeholders"), to_script(used_placeholders));
// Final check whether the keyword matches // Final check whether the keyword matches
if (match_condition && (bool)*match_condition->eval(ctx) == false) { if (match_condition && (bool)*match_condition->eval(ctx) == false) {
......
...@@ -89,9 +89,12 @@ String warn_and_identity(const String& key) { ...@@ -89,9 +89,12 @@ String warn_and_identity(const String& key) {
queue_message(MESSAGE_WARNING, _("Missing key in locale: ") + key); queue_message(MESSAGE_WARNING, _("Missing key in locale: ") + key);
return key; return key;
} }
String identity(const String& key) {
return key;
}
String SubLocale::tr(const String& key, DefaultLocaleFun def) { String SubLocale::tr(const String& key, DefaultLocaleFun def) {
map<String,String>::const_iterator it = translations.find(key); map<String,String>::const_iterator it = translations.find(canonical_name_form(key));
if (it == translations.end()) { if (it == translations.end()) {
return def(key); return def(key);
} else { } else {
...@@ -99,7 +102,7 @@ String SubLocale::tr(const String& key, DefaultLocaleFun def) { ...@@ -99,7 +102,7 @@ String SubLocale::tr(const String& key, DefaultLocaleFun def) {
} }
} }
String SubLocale::tr(const String& subcat, const String& key, DefaultLocaleFun def) { String SubLocale::tr(const String& subcat, const String& key, DefaultLocaleFun def) {
map<String,String>::const_iterator it = translations.find(subcat + _(" ") + key); map<String,String>::const_iterator it = translations.find(subcat + _("_") + canonical_name_form(key));
if (it == translations.end()) { if (it == translations.end()) {
return def(key); return def(key);
} else { } else {
......
...@@ -171,7 +171,7 @@ void Set::validate(Version file_app_version) { ...@@ -171,7 +171,7 @@ void Set::validate(Version file_app_version) {
IMPLEMENT_REFLECTION(Set) { IMPLEMENT_REFLECTION(Set) {
REFLECT_ALIAS(300, "style", "stylesheet"); // < 0.3.0 used style instead of stylesheet REFLECT_ALIAS(300, "style", "stylesheet"); // < 0.3.0 used style instead of stylesheet
REFLECT_ALIAS(300, "extra set info", "styling"); REFLECT_ALIAS(300, "extra_set_info", "styling");
REFLECT(game); REFLECT(game);
if (game) { if (game) {
REFLECT_IF_READING { REFLECT_IF_READING {
...@@ -190,7 +190,7 @@ IMPLEMENT_REFLECTION(Set) { ...@@ -190,7 +190,7 @@ IMPLEMENT_REFLECTION(Set) {
REFLECT(pack_types); REFLECT(pack_types);
} }
reflect_set_info_get_member(tag,data); reflect_set_info_get_member(tag,data);
REFLECT_NO_SCRIPT_N("version control", vcs); REFLECT_NO_SCRIPT_N("version_control", vcs);
REFLECT(apprentice_code); REFLECT(apprentice_code);
} }
...@@ -226,7 +226,7 @@ void Set::reflect_cards<Writer> (Writer& tag) { ...@@ -226,7 +226,7 @@ void Set::reflect_cards<Writer> (Writer& tag) {
Writer writer(openOut(full_name), app_version); Writer writer(openOut(full_name), app_version);
writer.handle(_("card"), card); writer.handle(_("card"), card);
referenceFile(full_name); referenceFile(full_name);
REFLECT_N("include file", full_name); REFLECT_N("include_file", full_name);
} }
} }
} }
......
...@@ -109,7 +109,7 @@ void GameSettings::initDefaults(const Game& game) { ...@@ -109,7 +109,7 @@ void GameSettings::initDefaults(const Game& game) {
IMPLEMENT_REFLECTION_NO_SCRIPT(GameSettings) { IMPLEMENT_REFLECTION_NO_SCRIPT(GameSettings) {
REFLECT(default_stylesheet); REFLECT(default_stylesheet);
REFLECT(default_export); REFLECT(default_export);
REFLECT_N("cardlist columns", columns); REFLECT(cardlist_columns);
REFLECT(sort_cards_by); REFLECT(sort_cards_by);
REFLECT(sort_cards_ascending); REFLECT(sort_cards_ascending);
REFLECT(images_export_filename); REFLECT(images_export_filename);
...@@ -211,7 +211,7 @@ ColumnSettings& Settings::columnSettingsFor(const Game& game, const Field& field ...@@ -211,7 +211,7 @@ ColumnSettings& Settings::columnSettingsFor(const Game& game, const Field& field
// Get game info // Get game info
GameSettings& gs = gameSettingsFor(game); GameSettings& gs = gameSettingsFor(game);
// Get column info // Get column info
ColumnSettings& cs = gs.columns[field.name]; ColumnSettings& cs = gs.cardlist_columns[field.name];
if (cs.position == COLUMN_NOT_INITIALIZED) { if (cs.position == COLUMN_NOT_INITIALIZED) {
// column info not set, initialize based on the game // column info not set, initialize based on the game
cs.visible = field.card_list_visible; cs.visible = field.card_list_visible;
...@@ -244,8 +244,8 @@ String Settings::settingsFile() { ...@@ -244,8 +244,8 @@ String Settings::settingsFile() {
} }
IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) { IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) {
REFLECT_ALIAS(300, "style settings", "stylesheet settings"); REFLECT_ALIAS(300, "style_settings", "stylesheet_settings");
REFLECT_ALIAS(300, "default style settings", "default stylesheet settings"); REFLECT_ALIAS(300, "default_style_settings", "default_stylesheet_settings");
REFLECT(locale); REFLECT(locale);
REFLECT(recent_sets); REFLECT(recent_sets);
REFLECT(default_set_dir); REFLECT(default_set_dir);
......
...@@ -76,7 +76,7 @@ class GameSettings : public IntrusivePtrBase<GameSettings> { ...@@ -76,7 +76,7 @@ class GameSettings : public IntrusivePtrBase<GameSettings> {
String default_stylesheet; String default_stylesheet;
String default_export; String default_export;
map<String, ColumnSettings> columns; map<String, ColumnSettings> cardlist_columns;
String sort_cards_by; String sort_cards_by;
bool sort_cards_ascending; bool sort_cards_ascending;
String images_export_filename; String images_export_filename;
......
...@@ -95,14 +95,14 @@ void mark_dependency_value(const StyleSheet& stylesheet, const Dependency& dep) ...@@ -95,14 +95,14 @@ void mark_dependency_value(const StyleSheet& stylesheet, const Dependency& dep)
IMPLEMENT_REFLECTION(StyleSheet) { IMPLEMENT_REFLECTION(StyleSheet) {
// < 0.3.0 didn't use card_ prefix // < 0.3.0 didn't use card_ prefix
REFLECT_ALIAS(300, "width", "card width"); REFLECT_ALIAS(300, "width", "card_width");
REFLECT_ALIAS(300, "height", "card height"); REFLECT_ALIAS(300, "height", "card_height");
REFLECT_ALIAS(300, "dpi", "card dpi"); REFLECT_ALIAS(300, "dpi", "card_dpi");
REFLECT_ALIAS(300, "background", "card background"); REFLECT_ALIAS(300, "background", "card_background");
REFLECT_ALIAS(300, "info style", "set info style"); REFLECT_ALIAS(300, "info_style", "set_info_style");
REFLECT_ALIAS(300, "align", "alignment"); REFLECT_ALIAS(300, "align", "alignment");
REFLECT_ALIAS(300, "extra field", "styling field"); REFLECT_ALIAS(300, "extra_field", "styling_field");
REFLECT_ALIAS(300, "extra style", "styling style"); REFLECT_ALIAS(300, "extra_style", "styling_style");
REFLECT(game); REFLECT(game);
REFLECT_BASE(Packaged); REFLECT_BASE(Packaged);
......
...@@ -51,11 +51,11 @@ SymbolFontP SymbolFont::byName(const String& name) { ...@@ -51,11 +51,11 @@ SymbolFontP SymbolFont::byName(const String& name) {
IMPLEMENT_REFLECTION(SymbolFont) { IMPLEMENT_REFLECTION(SymbolFont) {
REFLECT_BASE(Packaged); REFLECT_BASE(Packaged);
REFLECT_ALIAS(300, "text align", "text alignment"); REFLECT_ALIAS(300, "text_align", "text_alignment");
REFLECT_N("image font size", img_size); REFLECT_N("image_font_size", img_size);
REFLECT_N("horizontal space", spacing.width); REFLECT_N("horizontal_space", spacing.width);
REFLECT_N("vertical space", spacing.height); REFLECT_N("vertical_space", spacing.height);
WITH_DYNAMIC_ARG(symbol_font_for_reading, this); WITH_DYNAMIC_ARG(symbol_font_for_reading, this);
REFLECT(symbols); REFLECT(symbols);
REFLECT(scale_text); REFLECT(scale_text);
...@@ -189,7 +189,7 @@ IMPLEMENT_REFLECTION(SymbolInFont) { ...@@ -189,7 +189,7 @@ IMPLEMENT_REFLECTION(SymbolInFont) {
REFLECT(text_margin_bottom); REFLECT(text_margin_bottom);
REFLECT(image); REFLECT(image);
REFLECT(enabled); REFLECT(enabled);
REFLECT_N("image font size", img_size); REFLECT_N("image_font_size", img_size);
} }
// ----------------------------------------------------------------------------- : SymbolFont : splitting // ----------------------------------------------------------------------------- : SymbolFont : splitting
......
...@@ -237,7 +237,7 @@ void CardListBase::rebuild() { ...@@ -237,7 +237,7 @@ void CardListBase::rebuild() {
else if (f.second->card_list_align & ALIGN_CENTER) align = wxLIST_FORMAT_CENTRE; else if (f.second->card_list_align & ALIGN_CENTER) align = wxLIST_FORMAT_CENTRE;
else align = wxLIST_FORMAT_LEFT; else align = wxLIST_FORMAT_LEFT;
InsertColumn((long)column_fields.size(), InsertColumn((long)column_fields.size(),
tr(*set->game, f.second->card_list_name, capitalize), tr(*set->game, f.second->card_list_name, identity),
align, cs.width); align, cs.width);
column_fields.push_back(f.second); column_fields.push_back(f.second);
} }
......
...@@ -76,7 +76,7 @@ void CardListColumnSelectDialog::initList() { ...@@ -76,7 +76,7 @@ void CardListColumnSelectDialog::initList() {
// Init items // Init items
Color window_color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); Color window_color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
FOR_EACH(c, columns) { FOR_EACH(c, columns) {
list->Append(tr(*game, c.field->card_list_name, capitalize)); list->Append(tr(*game, c.field->card_list_name, identity));
// check // check
int i = list->GetCount() - 1; int i = list->GetCount() - 1;
list->Check(i, c.settings.visible); list->Check(i, c.settings.visible);
...@@ -89,7 +89,7 @@ void CardListColumnSelectDialog::initList() { ...@@ -89,7 +89,7 @@ void CardListColumnSelectDialog::initList() {
void CardListColumnSelectDialog::refreshItem(int i) { void CardListColumnSelectDialog::refreshItem(int i) {
list->Check (i, columns[i].settings.visible); list->Check (i, columns[i].settings.visible);
list->SetString(i, tr(*game, columns[i].field->card_list_name, capitalize) ); list->SetString(i, tr(*game, columns[i].field->card_list_name, identity) );
} }
// ----------------------------------------------------------------------------- : Events // ----------------------------------------------------------------------------- : Events
......
...@@ -43,7 +43,7 @@ void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) { ...@@ -43,7 +43,7 @@ void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) {
dc.SetFont(*wxNORMAL_FONT); dc.SetFont(*wxNORMAL_FONT);
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT)); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
// TODO : tr using stylesheet or using game? // TODO : tr using stylesheet or using game?
dc.DrawText(tr(getStylePackage(), s.fieldP->name, capitalize_sentence), dc.DrawText(tr(getStylePackage(), s.fieldP->caption, identity),
RealPoint(margin_left - s.left, 1)); RealPoint(margin_left - s.left, 1));
} }
// draw viewer // draw viewer
...@@ -67,7 +67,7 @@ void NativeLookEditor::resizeViewers() { ...@@ -67,7 +67,7 @@ void NativeLookEditor::resizeViewers() {
// width of the label string // width of the label string
int w; int w;
Style& s = *v->getStyle(); Style& s = *v->getStyle();
String text = tr(getStylePackage(), s.fieldP->name, capitalize_sentence); String text = tr(getStylePackage(), s.fieldP->caption, identity);
dc.GetTextExtent(text,&w,nullptr); dc.GetTextExtent(text,&w,nullptr);
label_width = max(label_width, w + label_margin); label_width = max(label_width, w + label_margin);
} }
......
...@@ -235,11 +235,15 @@ void draw_control_box(Window* win, DC& dc, const wxRect& rect, bool focused, boo ...@@ -235,11 +235,15 @@ void draw_control_box(Window* win, DC& dc, const wxRect& rect, bool focused, boo
r.right = rect.x + rect.width + 1; r.right = rect.x + rect.width + 1;
r.bottom = rect.y + rect.height + 1; r.bottom = rect.y + rect.height + 1;
if (hTheme) { if (hTheme) {
wxUxThemeEngine::Get()->DrawThemeBackground( int state = !enabled ? ETS_DISABLED : focused ? ETS_NORMAL : ETS_NORMAL;
if (themeEngine->IsThemeBackgroundPartiallyTransparent((HTHEME)hTheme, EP_EDITTEXT, state)) {
themeEngine->DrawThemeParentBackground((HWND)win->GetHWND(), (HDC)dc.GetHDC(), &r);
}
themeEngine->DrawThemeBackground(
(HTHEME)hTheme, (HTHEME)hTheme,
(HDC)dc.GetHDC(), (HDC)dc.GetHDC(),
EP_EDITTEXT, EP_EDITBORDER_NOSCROLL,
!enabled ? ETS_DISABLED : focused ? ETS_NORMAL : ETS_NORMAL, state,
&r, &r,
NULL NULL
); );
...@@ -370,6 +374,18 @@ void draw_selection_rectangle(Window* win, DC& dc, const wxRect& rect, bool sele ...@@ -370,6 +374,18 @@ void draw_selection_rectangle(Window* win, DC& dc, const wxRect& rect, bool sele
} }
} }
#endif #endif
// fallback rendering
/*
Color c = selected ? ( focused
? wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)
: lerp(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW),
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), subcolumnActivity(j))
)
: unselected;
dc.SetPen(c);
dc.SetBrush(lerp(background, c, 0.3));
dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
*/
} }
void enable_themed_selection_rectangle(Window* win) { void enable_themed_selection_rectangle(Window* win) {
......
...@@ -70,7 +70,7 @@ template <> ...@@ -70,7 +70,7 @@ template <>
intrusive_ptr<SymbolFilter> read_new<SymbolFilter>(Reader& reader) { intrusive_ptr<SymbolFilter> read_new<SymbolFilter>(Reader& reader) {
// there must be a fill type specified // there must be a fill type specified
String fill_type; String fill_type;
reader.handle(_("fill type"), fill_type); reader.handle(_("fill_type"), fill_type);
if (fill_type == _("solid")) return intrusive(new SolidFillSymbolFilter); if (fill_type == _("solid")) return intrusive(new SolidFillSymbolFilter);
else if (fill_type == _("linear gradient")) return intrusive(new LinearGradientSymbolFilter); else if (fill_type == _("linear gradient")) return intrusive(new LinearGradientSymbolFilter);
else if (fill_type == _("radial gradient")) return intrusive(new RadialGradientSymbolFilter); else if (fill_type == _("radial gradient")) return intrusive(new RadialGradientSymbolFilter);
......
...@@ -506,7 +506,7 @@ ScriptValueP sort_script(Context& ctx, const ScriptValueP& list, ScriptValue& or ...@@ -506,7 +506,7 @@ ScriptValueP sort_script(Context& ctx, const ScriptValueP& list, ScriptValue& or
SCRIPT_FUNCTION_WITH_DEP(position_of) { SCRIPT_FUNCTION_WITH_DEP(position_of) {
ScriptValueP of = ctx.getVariable(_("of")); ScriptValueP of = ctx.getVariable(_("of"));
ScriptValueP in = ctx.getVariable(_("in")); ScriptValueP in = ctx.getVariable(_("in"));
ScriptValueP order_by = ctx.getVariableOpt(_("order by")); ScriptValueP order_by = ctx.getVariableOpt(_("order_by"));
ScriptValueP filter = ctx.getVariableOpt(_("filter")); ScriptValueP filter = ctx.getVariableOpt(_("filter"));
if (filter == script_nil) filter = ScriptValueP(); if (filter == script_nil) filter = ScriptValueP();
SCRIPT_RETURN(position_in_vector(of, in, order_by, filter)); SCRIPT_RETURN(position_in_vector(of, in, order_by, filter));
...@@ -514,7 +514,7 @@ SCRIPT_FUNCTION_WITH_DEP(position_of) { ...@@ -514,7 +514,7 @@ SCRIPT_FUNCTION_WITH_DEP(position_of) {
SCRIPT_FUNCTION_DEPENDENCIES(position_of) { SCRIPT_FUNCTION_DEPENDENCIES(position_of) {
ScriptValueP of = ctx.getVariable(_("of")); ScriptValueP of = ctx.getVariable(_("of"));
ScriptValueP in = ctx.getVariable(_("in")); ScriptValueP in = ctx.getVariable(_("in"));
ScriptValueP order_by = ctx.getVariableOpt(_("order by")); ScriptValueP order_by = ctx.getVariableOpt(_("order_by"));
ScriptValueP filter = ctx.getVariableOpt(_("filter")); ScriptValueP filter = ctx.getVariableOpt(_("filter"));
ScriptObject<Set*>* s = dynamic_cast<ScriptObject<Set*>* >(in.get()); ScriptObject<Set*>* s = dynamic_cast<ScriptObject<Set*>* >(in.get());
ScriptObject<CardP>* c = dynamic_cast<ScriptObject<CardP>*>(of.get()); ScriptObject<CardP>* c = dynamic_cast<ScriptObject<CardP>*>(of.get());
...@@ -571,8 +571,8 @@ SCRIPT_FUNCTION(filter_list) { ...@@ -571,8 +571,8 @@ SCRIPT_FUNCTION(filter_list) {
SCRIPT_FUNCTION(sort_list) { SCRIPT_FUNCTION(sort_list) {
SCRIPT_PARAM_C(ScriptValueP, input); SCRIPT_PARAM_C(ScriptValueP, input);
SCRIPT_PARAM_DEFAULT_N(ScriptValueP, _("order by"), order_by, script_nil); SCRIPT_PARAM_DEFAULT(ScriptValueP, order_by, script_nil);
SCRIPT_PARAM_DEFAULT_N(bool, _("remove duplicates"), remove_duplicates, false); SCRIPT_PARAM_DEFAULT(bool, remove_duplicates, false);
return sort_script(ctx, input, *order_by, remove_duplicates); return sort_script(ctx, input, *order_by, remove_duplicates);
} }
...@@ -638,8 +638,8 @@ SCRIPT_FUNCTION_WITH_DEP(expand_keywords) { ...@@ -638,8 +638,8 @@ SCRIPT_FUNCTION_WITH_DEP(expand_keywords) {
SCRIPT_PARAM_C(String, input); SCRIPT_PARAM_C(String, input);
SCRIPT_PARAM_C(Set*, set); SCRIPT_PARAM_C(Set*, set);
SCRIPT_OPTIONAL_PARAM_N_(ScriptValueP, _("condition"), match_condition); SCRIPT_OPTIONAL_PARAM_N_(ScriptValueP, _("condition"), match_condition);
SCRIPT_OPTIONAL_PARAM_N_(ScriptValueP, _("default expand"), default_expand); SCRIPT_OPTIONAL_PARAM_(ScriptValueP, default_expand);
SCRIPT_PARAM_N(ScriptValueP, _("combine"), combine); SCRIPT_PARAM(ScriptValueP, combine);
KeywordDatabase& db = set->keyword_db; KeywordDatabase& db = set->keyword_db;
if (db.empty()) { if (db.empty()) {
db.prepare_parameters(set->game->keyword_parameter_types, set->keywords); db.prepare_parameters(set->game->keyword_parameter_types, set->keywords);
...@@ -658,8 +658,8 @@ SCRIPT_FUNCTION_WITH_DEP(expand_keywords) { ...@@ -658,8 +658,8 @@ SCRIPT_FUNCTION_WITH_DEP(expand_keywords) {
SCRIPT_FUNCTION_DEPENDENCIES(expand_keywords) { SCRIPT_FUNCTION_DEPENDENCIES(expand_keywords) {
SCRIPT_PARAM_C(Set*, set); SCRIPT_PARAM_C(Set*, set);
SCRIPT_OPTIONAL_PARAM_N_(ScriptValueP, _("condition"), match_condition); SCRIPT_OPTIONAL_PARAM_N_(ScriptValueP, _("condition"), match_condition);
SCRIPT_OPTIONAL_PARAM_N_(ScriptValueP, _("default expand"), default_expand); SCRIPT_OPTIONAL_PARAM_(ScriptValueP, default_expand);
SCRIPT_PARAM_N(ScriptValueP, _("combine"), combine); SCRIPT_PARAM(ScriptValueP, combine);
if (match_condition) match_condition->dependencies(ctx,dep); if (match_condition) match_condition->dependencies(ctx,dep);
default_expand ->dependencies(ctx,dep); default_expand ->dependencies(ctx,dep);
combine ->dependencies(ctx,dep); combine ->dependencies(ctx,dep);
...@@ -705,61 +705,61 @@ void init_script_basic_functions(Context& ctx) { ...@@ -705,61 +705,61 @@ void init_script_basic_functions(Context& ctx) {
// debugging // debugging
ctx.setVariable(_("trace"), script_trace); ctx.setVariable(_("trace"), script_trace);
// conversion // conversion
ctx.setVariable(_("to string"), script_to_string); ctx.setVariable(_("to_string"), script_to_string);
ctx.setVariable(_("to int"), script_to_int); ctx.setVariable(_("to_int"), script_to_int);
ctx.setVariable(_("to real"), script_to_real); ctx.setVariable(_("to_real"), script_to_real);
ctx.setVariable(_("to number"), script_to_number); ctx.setVariable(_("to_number"), script_to_number);
ctx.setVariable(_("to boolean"), script_to_boolean); ctx.setVariable(_("to_boolean"), script_to_boolean);
ctx.setVariable(_("to color"), script_to_color); ctx.setVariable(_("to_color"), script_to_color);
ctx.setVariable(_("to date"), script_to_date); ctx.setVariable(_("to_date"), script_to_date);
ctx.setVariable(_("to code"), script_to_code); ctx.setVariable(_("to_code"), script_to_code);
// math // math
ctx.setVariable(_("abs"), script_abs); ctx.setVariable(_("abs"), script_abs);
ctx.setVariable(_("random real"), script_random_real); ctx.setVariable(_("random_real"), script_random_real);
ctx.setVariable(_("random int"), script_random_int); ctx.setVariable(_("random_int"), script_random_int);
ctx.setVariable(_("random boolean"), script_random_boolean); ctx.setVariable(_("random_boolean"), script_random_boolean);
ctx.setVariable(_("sin"), script_sin); ctx.setVariable(_("sin"), script_sin);
ctx.setVariable(_("cos"), script_cos); ctx.setVariable(_("cos"), script_cos);
ctx.setVariable(_("tan"), script_tan); ctx.setVariable(_("tan"), script_tan);
ctx.setVariable(_("sin deg"), script_sin_deg); ctx.setVariable(_("sin_deg"), script_sin_deg);
ctx.setVariable(_("cos deg"), script_cos_deg); ctx.setVariable(_("cos_deg"), script_cos_deg);
ctx.setVariable(_("tan deg"), script_tan_deg); ctx.setVariable(_("tan_deg"), script_tan_deg);
ctx.setVariable(_("exp"), script_exp); ctx.setVariable(_("exp"), script_exp);
ctx.setVariable(_("log"), script_log); ctx.setVariable(_("log"), script_log);
ctx.setVariable(_("log10"), script_log10); ctx.setVariable(_("log10"), script_log10);
ctx.setVariable(_("sqrt"), script_sqrt); ctx.setVariable(_("sqrt"), script_sqrt);
ctx.setVariable(_("pow"), script_pow); ctx.setVariable(_("pow"), script_pow);
// string // string
ctx.setVariable(_("to upper"), script_to_upper); ctx.setVariable(_("to_upper"), script_to_upper);
ctx.setVariable(_("to lower"), script_to_lower); ctx.setVariable(_("to_lower"), script_to_lower);
ctx.setVariable(_("to title"), script_to_title); ctx.setVariable(_("to_title"), script_to_title);
ctx.setVariable(_("reverse"), script_reverse); ctx.setVariable(_("reverse"), script_reverse);
ctx.setVariable(_("trim"), script_trim); ctx.setVariable(_("trim"), script_trim);
ctx.setVariable(_("substring"), script_substring); ctx.setVariable(_("substring"), script_substring);
ctx.setVariable(_("contains"), script_contains); ctx.setVariable(_("contains"), script_contains);
ctx.setVariable(_("format"), script_format); ctx.setVariable(_("format"), script_format);
ctx.setVariable(_("format rule"), intrusive(new ScriptRule(script_format))); ctx.setVariable(_("format_rule"), intrusive(new ScriptRule(script_format)));
ctx.setVariable(_("curly quotes"), script_curly_quotes); ctx.setVariable(_("curly_quotes"), script_curly_quotes);
ctx.setVariable(_("regex escape"), script_regex_escape); ctx.setVariable(_("regex_escape"), script_regex_escape);
ctx.setVariable(_("sort text"), script_sort_text); ctx.setVariable(_("sort_text"), script_sort_text);
ctx.setVariable(_("sort rule"), intrusive(new ScriptRule(script_sort_text))); ctx.setVariable(_("sort_rule"), intrusive(new ScriptRule(script_sort_text)));
// tagged string // tagged string
ctx.setVariable(_("tag contents"), script_tag_contents); ctx.setVariable(_("tag_contents"), script_tag_contents);
ctx.setVariable(_("remove tag"), script_remove_tag); ctx.setVariable(_("remove_tag"), script_remove_tag);
ctx.setVariable(_("remove tags"), script_remove_tags); ctx.setVariable(_("remove_tags"), script_remove_tags);
ctx.setVariable(_("tag contents rule"), intrusive(new ScriptRule(script_tag_contents))); ctx.setVariable(_("tag_contents_rule"), intrusive(new ScriptRule(script_tag_contents)));
ctx.setVariable(_("tag remove rule"), intrusive(new ScriptRule(script_remove_tag))); ctx.setVariable(_("tag_remove_rule"), intrusive(new ScriptRule(script_remove_tag)));
// collection // collection
ctx.setVariable(_("position"), script_position_of); ctx.setVariable(_("position"), script_position_of);
ctx.setVariable(_("length"), script_length); ctx.setVariable(_("length"), script_length);
ctx.setVariable(_("number of items"), script_number_of_items); ctx.setVariable(_("number_of_items"), script_number_of_items);
ctx.setVariable(_("filter list"), script_filter_list); ctx.setVariable(_("filter_list"), script_filter_list);
ctx.setVariable(_("sort list"), script_sort_list); ctx.setVariable(_("sort_list"), script_sort_list);
ctx.setVariable(_("random shuffle"), script_random_shuffle); ctx.setVariable(_("random_shuffle"), script_random_shuffle);
ctx.setVariable(_("random select"), script_random_select); ctx.setVariable(_("random_select"), script_random_select);
ctx.setVariable(_("random select many"), script_random_select_many); ctx.setVariable(_("random_select_many"), script_random_select_many);
// keyword // keyword
ctx.setVariable(_("expand keywords"), script_expand_keywords); ctx.setVariable(_("expand_keywords"), script_expand_keywords);
ctx.setVariable(_("expand keywords rule"), intrusive(new ScriptRule(script_expand_keywords))); ctx.setVariable(_("expand_keywords_rule"), intrusive(new ScriptRule(script_expand_keywords)));
ctx.setVariable(_("keyword usage"), script_keyword_usage); ctx.setVariable(_("keyword_usage"), script_keyword_usage);
} }
...@@ -55,5 +55,5 @@ SCRIPT_FUNCTION(new_card) { ...@@ -55,5 +55,5 @@ SCRIPT_FUNCTION(new_card) {
// ----------------------------------------------------------------------------- : Init // ----------------------------------------------------------------------------- : Init
void init_script_construction_functions(Context& ctx) { void init_script_construction_functions(Context& ctx) {
ctx.setVariable(_("new card"), script_new_card); ctx.setVariable(_("new_card"), script_new_card);
} }
...@@ -99,8 +99,8 @@ SCRIPT_FUNCTION_WITH_DEP(combined_editor) { ...@@ -99,8 +99,8 @@ SCRIPT_FUNCTION_WITH_DEP(combined_editor) {
nv.second = index_to_untagged(nv.first, nv.first.size()) == 0; nv.second = index_to_untagged(nv.first, nv.first.size()) == 0;
} }
// options // options
SCRIPT_PARAM_DEFAULT_N(bool, _("hide when empty"), hide_when_empty, false); SCRIPT_PARAM_DEFAULT(bool, hide_when_empty, false);
SCRIPT_PARAM_DEFAULT_N(bool, _("soft before empty"), soft_before_empty, false); SCRIPT_PARAM_DEFAULT(bool, soft_before_empty, false);
// recombine the parts // recombine the parts
String new_value = value_parts.front().first; String new_value = value_parts.front().first;
bool new_value_empty = value_parts.front().second; bool new_value_empty = value_parts.front().second;
...@@ -336,7 +336,7 @@ void read_choices_param(Context& ctx, vector<String>& choices_out) { ...@@ -336,7 +336,7 @@ void read_choices_param(Context& ctx, vector<String>& choices_out) {
// add the given choice if it is not already active // add the given choice if it is not already active
SCRIPT_FUNCTION(require_choice) { SCRIPT_FUNCTION(require_choice) {
SCRIPT_PARAM_C(String,input); SCRIPT_PARAM_C(String,input);
SCRIPT_OPTIONAL_PARAM_N_(String,_("last change"),last_change); SCRIPT_OPTIONAL_PARAM_(String,last_change);
vector<String> choices; vector<String> choices;
read_choices_param(ctx, choices); read_choices_param(ctx, choices);
SCRIPT_RETURN(filter_choices(input, choices, 1, (int)choices.size(), last_change)); SCRIPT_RETURN(filter_choices(input, choices, 1, (int)choices.size(), last_change));
...@@ -345,7 +345,7 @@ SCRIPT_FUNCTION(require_choice) { ...@@ -345,7 +345,7 @@ SCRIPT_FUNCTION(require_choice) {
// make sure at most one of the choices is active // make sure at most one of the choices is active
SCRIPT_FUNCTION(exclusive_choice) { SCRIPT_FUNCTION(exclusive_choice) {
SCRIPT_PARAM_C(String,input); SCRIPT_PARAM_C(String,input);
SCRIPT_OPTIONAL_PARAM_N_(String,_("last change"),last_change); SCRIPT_OPTIONAL_PARAM_(String,last_change);
vector<String> choices; vector<String> choices;
read_choices_param(ctx, choices); read_choices_param(ctx, choices);
SCRIPT_RETURN(filter_choices(input, choices, 0, 1, last_change)); SCRIPT_RETURN(filter_choices(input, choices, 0, 1, last_change));
...@@ -354,7 +354,7 @@ SCRIPT_FUNCTION(exclusive_choice) { ...@@ -354,7 +354,7 @@ SCRIPT_FUNCTION(exclusive_choice) {
// make sure exactly one of the choices is active // make sure exactly one of the choices is active
SCRIPT_FUNCTION(require_exclusive_choice) { SCRIPT_FUNCTION(require_exclusive_choice) {
SCRIPT_PARAM_C(String,input); SCRIPT_PARAM_C(String,input);
SCRIPT_OPTIONAL_PARAM_N_(String,_("last change"),last_change); SCRIPT_OPTIONAL_PARAM_(String,last_change);
vector<String> choices; vector<String> choices;
read_choices_param(ctx, choices); read_choices_param(ctx, choices);
SCRIPT_RETURN(filter_choices(input, choices, 1, 1, last_change)); SCRIPT_RETURN(filter_choices(input, choices, 1, 1, last_change));
...@@ -393,13 +393,13 @@ SCRIPT_FUNCTION(count_chosen) { ...@@ -393,13 +393,13 @@ SCRIPT_FUNCTION(count_chosen) {
// ----------------------------------------------------------------------------- : Init // ----------------------------------------------------------------------------- : Init
void init_script_editor_functions(Context& ctx) { void init_script_editor_functions(Context& ctx) {
ctx.setVariable(_("forward editor"), script_combined_editor); // compatability ctx.setVariable(_("forward_editor"), script_combined_editor); // compatability
ctx.setVariable(_("combined editor"), script_combined_editor); ctx.setVariable(_("combined_editor"), script_combined_editor);
ctx.setVariable(_("primary choice"), script_primary_choice); ctx.setVariable(_("primary_choice"), script_primary_choice);
ctx.setVariable(_("chosen"), script_chosen); ctx.setVariable(_("chosen"), script_chosen);
ctx.setVariable(_("count chosen"), script_count_chosen); ctx.setVariable(_("count_chosen"), script_count_chosen);
ctx.setVariable(_("require choice"), script_require_choice); ctx.setVariable(_("require_choice"), script_require_choice);
ctx.setVariable(_("exclusive choice"), script_exclusive_choice); ctx.setVariable(_("exclusive_choice"), script_exclusive_choice);
ctx.setVariable(_("require exclusive choice"), script_require_exclusive_choice); ctx.setVariable(_("require_exclusive_choice"), script_require_exclusive_choice);
ctx.setVariable(_("remove choice"), script_remove_choice); ctx.setVariable(_("remove_choice"), script_remove_choice);
} }
...@@ -334,11 +334,11 @@ SCRIPT_FUNCTION(process_english_hints) { ...@@ -334,11 +334,11 @@ SCRIPT_FUNCTION(process_english_hints) {
// ----------------------------------------------------------------------------- : Init // ----------------------------------------------------------------------------- : Init
void init_script_english_functions(Context& ctx) { void init_script_english_functions(Context& ctx) {
ctx.setVariable(_("english number"), script_english_number); ctx.setVariable(_("english_number"), script_english_number);
ctx.setVariable(_("english number a"), script_english_number_a); ctx.setVariable(_("english_number_a"), script_english_number_a);
ctx.setVariable(_("english number multiple"), script_english_number_multiple); ctx.setVariable(_("english_number_multiple"), script_english_number_multiple);
ctx.setVariable(_("english number ordinal"), script_english_number_ordinal); ctx.setVariable(_("english_number_ordinal"), script_english_number_ordinal);
ctx.setVariable(_("english singular"), script_english_singular); ctx.setVariable(_("english_singular"), script_english_singular);
ctx.setVariable(_("english plural"), script_english_plural); ctx.setVariable(_("english_plural"), script_english_plural);
ctx.setVariable(_("process english hints"), script_process_english_hints); ctx.setVariable(_("process_english_hints"), script_process_english_hints);
} }
...@@ -278,11 +278,11 @@ SCRIPT_FUNCTION(to_html) { ...@@ -278,11 +278,11 @@ SCRIPT_FUNCTION(to_html) {
SCRIPT_PARAM_C(String, input); SCRIPT_PARAM_C(String, input);
// symbol font? // symbol font?
SymbolFontP symbol_font; SymbolFontP symbol_font;
SCRIPT_OPTIONAL_PARAM_N(String, _("symbol font"), font_name) { SCRIPT_OPTIONAL_PARAM_N(String, _("symbol_font"), font_name) {
symbol_font = SymbolFont::byName(font_name); symbol_font = SymbolFont::byName(font_name);
symbol_font->update(ctx); symbol_font->update(ctx);
} }
SCRIPT_OPTIONAL_PARAM_N_(double, _("symbol font size"), symbol_font_size); SCRIPT_OPTIONAL_PARAM_(double, symbol_font_size);
if (symbol_font_size <= 0) symbol_font_size = 12; // a default if (symbol_font_size <= 0) symbol_font_size = 12; // a default
SCRIPT_RETURN(to_html(input, symbol_font, symbol_font_size)); SCRIPT_RETURN(to_html(input, symbol_font, symbol_font_size));
} }
...@@ -290,8 +290,8 @@ SCRIPT_FUNCTION(to_html) { ...@@ -290,8 +290,8 @@ SCRIPT_FUNCTION(to_html) {
// convert a symbol string to html // convert a symbol string to html
SCRIPT_FUNCTION(symbols_to_html) { SCRIPT_FUNCTION(symbols_to_html) {
SCRIPT_PARAM_C(String, input); SCRIPT_PARAM_C(String, input);
SCRIPT_PARAM_N(String, _("symbol font"), font_name); SCRIPT_PARAM_N(String, _("symbol_font"), font_name);
SCRIPT_OPTIONAL_PARAM_N_(double, _("symbol font size"), symbol_font_size); SCRIPT_OPTIONAL_PARAM_(double, symbol_font_size);
SymbolFontP symbol_font = SymbolFont::byName(font_name); SymbolFontP symbol_font = SymbolFont::byName(font_name);
symbol_font->update(ctx); symbol_font->update(ctx);
if (symbol_font_size <= 0) symbol_font_size = 12; // a default if (symbol_font_size <= 0) symbol_font_size = 12; // a default
...@@ -451,12 +451,12 @@ SCRIPT_FUNCTION(sanitize) { ...@@ -451,12 +451,12 @@ SCRIPT_FUNCTION(sanitize) {
// ----------------------------------------------------------------------------- : Init // ----------------------------------------------------------------------------- : Init
void init_script_export_functions(Context& ctx) { void init_script_export_functions(Context& ctx) {
ctx.setVariable(_("to html"), script_to_html); ctx.setVariable(_("to_html"), script_to_html);
ctx.setVariable(_("symbols to html"), script_symbols_to_html); ctx.setVariable(_("symbols_to_html"), script_symbols_to_html);
ctx.setVariable(_("to text"), script_to_text); ctx.setVariable(_("to_text"), script_to_text);
ctx.setVariable(_("copy file"), script_copy_file); ctx.setVariable(_("copy_file"), script_copy_file);
ctx.setVariable(_("write text file"), script_write_text_file); ctx.setVariable(_("write_text_file"), script_write_text_file);
ctx.setVariable(_("write image file"), script_write_image_file); ctx.setVariable(_("write_image_file"), script_write_image_file);
ctx.setVariable(_("write set file"), script_write_set_file); ctx.setVariable(_("write_set_file"), script_write_set_file);
ctx.setVariable(_("sanitize"), script_sanitize); ctx.setVariable(_("sanitize"), script_sanitize);
} }
...@@ -106,16 +106,16 @@ SCRIPT_FUNCTION(recolor_image) { ...@@ -106,16 +106,16 @@ SCRIPT_FUNCTION(recolor_image) {
SCRIPT_FUNCTION(enlarge) { SCRIPT_FUNCTION(enlarge) {
SCRIPT_PARAM_C(GeneratedImageP, input); SCRIPT_PARAM_C(GeneratedImageP, input);
SCRIPT_PARAM_N(double, _("border size"), border_size); SCRIPT_PARAM(double,border_size);
return intrusive(new EnlargeImage(input, border_size)); return intrusive(new EnlargeImage(input, border_size));
} }
SCRIPT_FUNCTION(crop) { SCRIPT_FUNCTION(crop) {
SCRIPT_PARAM_C(GeneratedImageP, input); SCRIPT_PARAM_C(GeneratedImageP, input);
SCRIPT_PARAM_N(int, _("width"), width); SCRIPT_PARAM(int, width);
SCRIPT_PARAM_N(int, _("height"), height); SCRIPT_PARAM(int, height);
SCRIPT_PARAM_N(double, _("offset x"), offset_x); SCRIPT_PARAM(double, offset_x);
SCRIPT_PARAM_N(double, _("offset y"), offset_y); SCRIPT_PARAM(double, offset_y);
return intrusive(new CropImage(input, width, height, offset_x, offset_y)); return intrusive(new CropImage(input, width, height, offset_x, offset_y));
} }
...@@ -131,17 +131,17 @@ SCRIPT_FUNCTION(flip_vertical) { ...@@ -131,17 +131,17 @@ SCRIPT_FUNCTION(flip_vertical) {
SCRIPT_FUNCTION(rotate) { SCRIPT_FUNCTION(rotate) {
SCRIPT_PARAM_C(GeneratedImageP, input); SCRIPT_PARAM_C(GeneratedImageP, input);
SCRIPT_PARAM_N(Degrees, _("angle"), angle); SCRIPT_PARAM(Degrees, angle);
return intrusive(new RotateImage(input,deg_to_rad(angle))); return intrusive(new RotateImage(input,deg_to_rad(angle)));
} }
SCRIPT_FUNCTION(drop_shadow) { SCRIPT_FUNCTION(drop_shadow) {
SCRIPT_PARAM_C(GeneratedImageP, input); SCRIPT_PARAM_C(GeneratedImageP, input);
SCRIPT_OPTIONAL_PARAM_N_(double, _("offset x"), offset_x); SCRIPT_OPTIONAL_PARAM_(double, offset_x);
SCRIPT_OPTIONAL_PARAM_N_(double, _("offset y"), offset_y); SCRIPT_OPTIONAL_PARAM_(double, offset_y);
SCRIPT_OPTIONAL_PARAM_N_(double, _("alpha"), alpha); SCRIPT_OPTIONAL_PARAM_(double, alpha);
SCRIPT_OPTIONAL_PARAM_N_(double, _("blur radius"), blur_radius); SCRIPT_OPTIONAL_PARAM_(double, blur_radius);
SCRIPT_OPTIONAL_PARAM_N_(Color, _("color"), color); SCRIPT_OPTIONAL_PARAM_(Color, color);
return intrusive(new DropShadowImage(input, offset_x, offset_y, alpha, blur_radius, color)); return intrusive(new DropShadowImage(input, offset_x, offset_y, alpha, blur_radius, color));
} }
...@@ -176,30 +176,30 @@ SCRIPT_FUNCTION(symbol_variation) { ...@@ -176,30 +176,30 @@ SCRIPT_FUNCTION(symbol_variation) {
throw ScriptError(_("Variation of symbol not found ('") + variation + _("')")); throw ScriptError(_("Variation of symbol not found ('") + variation + _("')"));
} else { } else {
// custom variation // custom variation
SCRIPT_PARAM_N(double, _("border radius"), border_radius); SCRIPT_PARAM(double, border_radius);
SCRIPT_OPTIONAL_PARAM_N_(String, _("fill type"), fill_type); SCRIPT_OPTIONAL_PARAM_(String, fill_type);
SymbolVariationP var(new SymbolVariation); SymbolVariationP var(new SymbolVariation);
var->border_radius = border_radius; var->border_radius = border_radius;
if (fill_type == _("solid") || fill_type.empty()) { if (fill_type == _("solid") || fill_type.empty()) {
SCRIPT_PARAM_N(Color, _("fill color"), fill_color); SCRIPT_PARAM(Color, fill_color);
SCRIPT_PARAM_N(Color, _("border color"), border_color); SCRIPT_PARAM(Color, border_color);
var->filter = intrusive(new SolidFillSymbolFilter(fill_color, border_color)); var->filter = intrusive(new SolidFillSymbolFilter(fill_color, border_color));
} else if (fill_type == _("linear gradient")) { } else if (fill_type == _("linear gradient")) {
SCRIPT_PARAM_N(Color, _("fill color 1"), fill_color_1); SCRIPT_PARAM(Color, fill_color_1);
SCRIPT_PARAM_N(Color, _("border color 1"), border_color_1); SCRIPT_PARAM(Color, border_color_1);
SCRIPT_PARAM_N(Color, _("fill color 2"), fill_color_2); SCRIPT_PARAM(Color, fill_color_2);
SCRIPT_PARAM_N(Color, _("border color 2"), border_color_2); SCRIPT_PARAM(Color, border_color_2);
SCRIPT_PARAM_N(double, _("center x"), center_x); SCRIPT_PARAM(double, center_x);
SCRIPT_PARAM_N(double, _("center y"), center_y); SCRIPT_PARAM(double, center_y);
SCRIPT_PARAM_N(double, _("end x"), end_x); SCRIPT_PARAM(double, end_x);
SCRIPT_PARAM_N(double, _("end y"), end_y); SCRIPT_PARAM(double, end_y);
var->filter = intrusive(new LinearGradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2 var->filter = intrusive(new LinearGradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2
,center_x, center_y, end_x, end_y)); ,center_x, center_y, end_x, end_y));
} else if (fill_type == _("radial gradient")) { } else if (fill_type == _("radial gradient")) {
SCRIPT_PARAM_N(Color, _("fill color 1"), fill_color_1); SCRIPT_PARAM(Color, fill_color_1);
SCRIPT_PARAM_N(Color, _("border color 1"), border_color_1); SCRIPT_PARAM(Color, border_color_1);
SCRIPT_PARAM_N(Color, _("fill color 2"), fill_color_2); SCRIPT_PARAM(Color, fill_color_2);
SCRIPT_PARAM_N(Color, _("border color 2"), border_color_2); SCRIPT_PARAM(Color, border_color_2);
var->filter = intrusive(new RadialGradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2)); var->filter = intrusive(new RadialGradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2));
} else { } else {
throw ScriptError(_("Unknown fill type for symbol_variation: ") + fill_type); throw ScriptError(_("Unknown fill type for symbol_variation: ") + fill_type);
...@@ -216,22 +216,22 @@ SCRIPT_FUNCTION(built_in_image) { ...@@ -216,22 +216,22 @@ SCRIPT_FUNCTION(built_in_image) {
// ----------------------------------------------------------------------------- : Init // ----------------------------------------------------------------------------- : Init
void init_script_image_functions(Context& ctx) { void init_script_image_functions(Context& ctx) {
ctx.setVariable(_("to image"), script_to_image); ctx.setVariable(_("to_image"), script_to_image);
ctx.setVariable(_("linear blend"), script_linear_blend); ctx.setVariable(_("linear_blend"), script_linear_blend);
ctx.setVariable(_("masked blend"), script_masked_blend); ctx.setVariable(_("masked_blend"), script_masked_blend);
ctx.setVariable(_("combine blend"), script_combine_blend); ctx.setVariable(_("combine_blend"), script_combine_blend);
ctx.setVariable(_("set mask"), script_set_mask); ctx.setVariable(_("set_mask"), script_set_mask);
ctx.setVariable(_("set alpha"), script_set_alpha); ctx.setVariable(_("set_alpha"), script_set_alpha);
ctx.setVariable(_("set combine"), script_set_combine); ctx.setVariable(_("set_combine"), script_set_combine);
ctx.setVariable(_("saturate"), script_saturate); ctx.setVariable(_("saturate"), script_saturate);
ctx.setVariable(_("invert image"), script_invert_image); ctx.setVariable(_("invert_image"), script_invert_image);
ctx.setVariable(_("recolor image"), script_recolor_image); ctx.setVariable(_("recolor_image"), script_recolor_image);
ctx.setVariable(_("enlarge"), script_enlarge); ctx.setVariable(_("enlarge"), script_enlarge);
ctx.setVariable(_("crop"), script_crop); ctx.setVariable(_("crop"), script_crop);
ctx.setVariable(_("flip horizontal"), script_flip_horizontal); ctx.setVariable(_("flip_horizontal"), script_flip_horizontal);
ctx.setVariable(_("flip vertical"), script_flip_vertical); ctx.setVariable(_("flip_vertical"), script_flip_vertical);
ctx.setVariable(_("rotate"), script_rotate); ctx.setVariable(_("rotate"), script_rotate);
ctx.setVariable(_("drop shadow"), script_drop_shadow); ctx.setVariable(_("drop_shadow"), script_drop_shadow);
ctx.setVariable(_("symbol variation"), script_symbol_variation); ctx.setVariable(_("symbol_variation"), script_symbol_variation);
ctx.setVariable(_("built in image"), script_built_in_image); ctx.setVariable(_("built_in_image"), script_built_in_image);
} }
...@@ -105,7 +105,7 @@ struct RegexReplacer { ...@@ -105,7 +105,7 @@ struct RegexReplacer {
} }
}; };
SCRIPT_FUNCTION_WITH_SIMPLIFY(replace) { SCRIPT_FUNCTION_WITH_SIMPLIFY(replace_text) {
// construct replacer // construct replacer
RegexReplacer replacer; RegexReplacer replacer;
replacer.match = from_script<ScriptRegexP>(ctx.getVariable(SCRIPT_VAR_match), SCRIPT_VAR_match); replacer.match = from_script<ScriptRegexP>(ctx.getVariable(SCRIPT_VAR_match), SCRIPT_VAR_match);
...@@ -132,7 +132,7 @@ SCRIPT_FUNCTION_WITH_SIMPLIFY(replace) { ...@@ -132,7 +132,7 @@ SCRIPT_FUNCTION_WITH_SIMPLIFY(replace) {
SCRIPT_RETURN(input); SCRIPT_RETURN(input);
} }
} }
SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(replace) { SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(replace_text) {
FOR_EACH(b, closure.bindings) { FOR_EACH(b, closure.bindings) {
if (b.first == SCRIPT_VAR_match || b.first == SCRIPT_VAR_in_context) { if (b.first == SCRIPT_VAR_match || b.first == SCRIPT_VAR_in_context) {
b.second = regex_from_script(b.second); // pre-compile b.second = regex_from_script(b.second); // pre-compile
...@@ -199,7 +199,7 @@ SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(break_text) { ...@@ -199,7 +199,7 @@ SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(break_text) {
SCRIPT_FUNCTION_WITH_SIMPLIFY(split_text) { SCRIPT_FUNCTION_WITH_SIMPLIFY(split_text) {
SCRIPT_PARAM_C(String, input); SCRIPT_PARAM_C(String, input);
SCRIPT_PARAM_C(ScriptRegexP, match); SCRIPT_PARAM_C(ScriptRegexP, match);
SCRIPT_PARAM_DEFAULT_N(bool, _("include empty"), include_empty, true); SCRIPT_PARAM_DEFAULT(bool, include_empty, true);
ScriptCustomCollectionP ret(new ScriptCustomCollection); ScriptCustomCollectionP ret(new ScriptCustomCollection);
// find all matches // find all matches
String::const_iterator start = input.begin(); String::const_iterator start = input.begin();
...@@ -228,12 +228,12 @@ SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(split_text) { ...@@ -228,12 +228,12 @@ SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(split_text) {
// ----------------------------------------------------------------------------- : Rules : regex match // ----------------------------------------------------------------------------- : Rules : regex match
SCRIPT_FUNCTION_WITH_SIMPLIFY(match) { SCRIPT_FUNCTION_WITH_SIMPLIFY(match_text) {
SCRIPT_PARAM_C(String, input); SCRIPT_PARAM_C(String, input);
SCRIPT_PARAM_C(ScriptRegexP, match); SCRIPT_PARAM_C(ScriptRegexP, match);
SCRIPT_RETURN(match->matches(input)); SCRIPT_RETURN(match->matches(input));
} }
SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(match) { SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(match_text) {
FOR_EACH(b, closure.bindings) { FOR_EACH(b, closure.bindings) {
if (b.first == SCRIPT_VAR_match) { if (b.first == SCRIPT_VAR_match) {
b.second = regex_from_script(b.second); // pre-compile b.second = regex_from_script(b.second); // pre-compile
...@@ -245,13 +245,15 @@ SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(match) { ...@@ -245,13 +245,15 @@ SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(match) {
// ----------------------------------------------------------------------------- : Init // ----------------------------------------------------------------------------- : Init
void init_script_regex_functions(Context& ctx) { void init_script_regex_functions(Context& ctx) {
ctx.setVariable(_("replace"), script_replace); ctx.setVariable(_("replace"), script_replace_text); // compatability
ctx.setVariable(_("filter text"), script_filter_text); ctx.setVariable(_("replace_text"), script_replace_text);
ctx.setVariable(_("break text"), script_break_text); ctx.setVariable(_("filter_text"), script_filter_text);
ctx.setVariable(_("split text"), script_split_text); ctx.setVariable(_("break_text"), script_break_text);
ctx.setVariable(_("match"), script_match); ctx.setVariable(_("split_text"), script_split_text);
ctx.setVariable(_("replace rule"), intrusive(new ScriptRule(script_replace))); ctx.setVariable(_("match"), script_match_text); // compatability
ctx.setVariable(_("filter rule"), intrusive(new ScriptRule(script_filter_text))); ctx.setVariable(_("match_text"), script_match_text);
ctx.setVariable(_("break rule"), intrusive(new ScriptRule(script_break_text))); ctx.setVariable(_("replace_rule"), intrusive(new ScriptRule(script_replace_text)));
ctx.setVariable(_("match rule"), intrusive(new ScriptRule(script_match))); ctx.setVariable(_("filter_rule"), intrusive(new ScriptRule(script_filter_text)));
ctx.setVariable(_("break_rule"), intrusive(new ScriptRule(script_break_text)));
ctx.setVariable(_("match_rule"), intrusive(new ScriptRule(script_match_text)));
} }
...@@ -96,8 +96,8 @@ SCRIPT_FUNCTION(check_spelling) { ...@@ -96,8 +96,8 @@ SCRIPT_FUNCTION(check_spelling) {
assert_tagged(input); assert_tagged(input);
if (!settings.stylesheetSettingsFor(*stylesheet).card_spellcheck_enabled) if (!settings.stylesheetSettingsFor(*stylesheet).card_spellcheck_enabled)
SCRIPT_RETURN(input); SCRIPT_RETURN(input);
SCRIPT_OPTIONAL_PARAM_N_(String,_("extra dictionary"),extra_dictionary); SCRIPT_OPTIONAL_PARAM_(String,extra_dictionary);
SCRIPT_OPTIONAL_PARAM_N_(ScriptValueP,_("extra match"),extra_match); SCRIPT_OPTIONAL_PARAM_(ScriptValueP,extra_match);
// remove old spelling error tags // remove old spelling error tags
input = remove_tag(input, _("<error-spelling")); input = remove_tag(input, _("<error-spelling"));
// no language -> spelling checking // no language -> spelling checking
...@@ -176,6 +176,6 @@ SCRIPT_FUNCTION(check_spelling_word) { ...@@ -176,6 +176,6 @@ SCRIPT_FUNCTION(check_spelling_word) {
// ----------------------------------------------------------------------------- : Init // ----------------------------------------------------------------------------- : Init
void init_script_spelling_functions(Context& ctx) { void init_script_spelling_functions(Context& ctx) {
ctx.setVariable(_("check spelling"), script_check_spelling); ctx.setVariable(_("check_spelling"), script_check_spelling);
ctx.setVariable(_("check spelling word"), script_check_spelling_word); ctx.setVariable(_("check_spelling_word"), script_check_spelling_word);
} }
...@@ -58,7 +58,7 @@ void init_script_variables() { ...@@ -58,7 +58,7 @@ void init_script_variables() {
Var(in); Var(in);
Var(match); Var(match);
Var(replace); Var(replace);
VarN(in_context,_("in context")); Var(in_context);
Var(recursive); Var(recursive);
Var(order); Var(order);
Var(begin); Var(begin);
...@@ -72,7 +72,7 @@ void init_script_variables() { ...@@ -72,7 +72,7 @@ void init_script_variables() {
Var(set); Var(set);
Var(game); Var(game);
Var(stylesheet); Var(stylesheet);
VarN(card_style,_("card style")); Var(card_style);
Var(card); Var(card);
Var(styling); Var(styling);
Var(value); Var(value);
......
...@@ -29,7 +29,7 @@ DECLARE_TYPEOF_COLLECTION(ScriptParseError); ...@@ -29,7 +29,7 @@ DECLARE_TYPEOF_COLLECTION(ScriptParseError);
wsprintf(buffer, L"Assertion failed: %s, file %s, line %d\n", expr, file, line); wsprintf(buffer, L"Assertion failed: %s, file %s, line %d\n", expr, file, line);
} }
OutputDebugStringW(buffer); OutputDebugStringW(buffer);
DebugBreak(); __debugbreak();
} else { } else {
_wassert(expr, file, line); _wassert(expr, file, line);
} }
......
...@@ -86,7 +86,7 @@ class GetMember : private GetDefaultMember { ...@@ -86,7 +86,7 @@ class GetMember : private GetDefaultMember {
/// Handle an object: we are done if the name matches /// Handle an object: we are done if the name matches
template <typename T> template <typename T>
void handle(const Char* name, const T& object) { void handle(const Char* name, const T& object) {
if (!gdm.result() && cannocial_name_compare(target_name, name)) { if (!gdm.result() && canoncial_name_compare(target_name, name)) {
gdm.handle(object); gdm.handle(object);
} }
} }
......
...@@ -508,7 +508,7 @@ IMPLEMENT_REFLECTION(Packaged) { ...@@ -508,7 +508,7 @@ IMPLEMENT_REFLECTION(Packaged) {
REFLECT(installer_group); REFLECT(installer_group);
REFLECT(version); REFLECT(version);
REFLECT(compatible_version); REFLECT(compatible_version);
REFLECT_NO_SCRIPT_N("depends ons", dependencies); // hack for singular_form REFLECT_NO_SCRIPT_N("depends_ons", dependencies); // hack for singular_form
} }
Packaged::Packaged() Packaged::Packaged()
......
...@@ -91,7 +91,7 @@ bool Reader::enterAnyBlock() { ...@@ -91,7 +91,7 @@ bool Reader::enterAnyBlock() {
bool Reader::enterBlock(const Char* name) { bool Reader::enterBlock(const Char* name) {
if (state == ENTERED) moveNext(); // on the key of the parent block, first move inside it if (state == ENTERED) moveNext(); // on the key of the parent block, first move inside it
if (indent != expected_indent) return false; // not enough indentation if (indent != expected_indent) return false; // not enough indentation
if (cannocial_name_compare(key, name)) { if (canoncial_name_compare(key, name)) {
state = ENTERED; state = ENTERED;
expected_indent += 1; // the indent inside the block must be at least this much expected_indent += 1; // the indent inside the block must be at least this much
return true; return true;
......
...@@ -181,7 +181,7 @@ class Reader { ...@@ -181,7 +181,7 @@ class Reader {
/** Maybe the key is "include file" */ /** Maybe the key is "include file" */
template <typename T> template <typename T>
void unknownKey(T& v) { void unknownKey(T& v) {
if (key == _("include file")) { if (key == _("include_file")) {
Reader reader(this, package, value, ignore_invalid); Reader reader(this, package, value, ignore_invalid);
reader.handle_greedy(v); reader.handle_greedy(v);
moveNext(); moveNext();
......
...@@ -43,6 +43,8 @@ enum LocaleCategory ...@@ -43,6 +43,8 @@ enum LocaleCategory
typedef String (*DefaultLocaleFun)(const String&); typedef String (*DefaultLocaleFun)(const String&);
/// Return the input and issue a warning /// Return the input and issue a warning
String warn_and_identity(const String&); String warn_and_identity(const String&);
/// Return the input and don't issue a warning
String identity(const String&);
/// Translate 'key' in the category 'cat' using the current locale /// Translate 'key' in the category 'cat' using the current locale
String tr(LocaleCategory cat, const String& key, DefaultLocaleFun def = warn_and_identity); String tr(LocaleCategory cat, const String& key, DefaultLocaleFun def = warn_and_identity);
......
...@@ -180,7 +180,20 @@ String capitalize_sentence(const String& s) { ...@@ -180,7 +180,20 @@ String capitalize_sentence(const String& s) {
return ret; return ret;
} }
Char canonical_name_form(Char c) {
if (c == _(' ')) return _('_');
return c;
}
String canonical_name_form(const String& str) { String canonical_name_form(const String& str) {
String ret;
ret.reserve(str.size());
FOR_EACH_CONST(c, str) {
ret += canonical_name_form((Char)c);
}
return ret;
}
String name_to_caption(const String& str) {
String ret; String ret;
ret.reserve(str.size()); ret.reserve(str.size());
bool leading = true; bool leading = true;
...@@ -190,14 +203,12 @@ String canonical_name_form(const String& str) { ...@@ -190,14 +203,12 @@ String canonical_name_form(const String& str) {
} else { } else {
ret += c; ret += c;
leading = false; leading = false;
/*
} else if (isAlnum(c) || c == _('-')) {
ret += toLower(c);
leading = false;
} else {
// ignore non alpha numeric*/
} }
} }
if (!ret.empty()) {
// capitalize_sentence
ret[0] = toUpper(ret[0]);
}
return ret; return ret;
} }
...@@ -406,10 +417,11 @@ bool is_substr_i(const String& str, size_t pos, const String& cmp) { ...@@ -406,10 +417,11 @@ bool is_substr_i(const String& str, size_t pos, const String& cmp) {
return is_substr_i(str, pos, static_cast<const Char*>(cmp.c_str())); return is_substr_i(str, pos, static_cast<const Char*>(cmp.c_str()));
} }
bool cannocial_name_compare(const String& as, const Char* b) { bool canoncial_name_compare(const String& as, const Char* b) {
assert(canonical_name_form(b) == b);
const Char* a = as.c_str(); const Char* a = as.c_str();
while (true) { while (true) {
if (*a != *b && !(*a == _(' ') && *b == _('_'))) return false; if (*a != *b && !(*a == _('_') && *b == _(' '))) return false;
if (*a == _('\0')) return true; if (*a == _('\0')) return true;
a++; b++; a++; b++;
} }
......
...@@ -153,12 +153,13 @@ String capitalize(const String&); ...@@ -153,12 +153,13 @@ String capitalize(const String&);
String capitalize_sentence(const String&); String capitalize_sentence(const String&);
/// Convert a field name to canonical form /// Convert a field name to canonical form
/** - lower case and ' ' instead of '_'. /** - currently only use '_' instead of ' '.
* - non alphanumeric characters are droped
* - "camalCase" is converted to words "camel case" (TODO)
*/ */
String canonical_name_form(const String&); String canonical_name_form(const String&);
/// Convert a field name to a string that can be shown to the user
String name_to_caption(const String&);
/// Returns the singular form of a string /// Returns the singular form of a string
/** Used for reflection, for example "vector<T> apples" is written with keys /** Used for reflection, for example "vector<T> apples" is written with keys
* singular_form("apples"), which is "apple" * singular_form("apples"), which is "apple"
...@@ -202,8 +203,11 @@ bool is_substr_i(const String& str, size_t pos, const String& cmp); ...@@ -202,8 +203,11 @@ bool is_substr_i(const String& str, size_t pos, const String& cmp);
/// Case insensitive string search, returns String::npos if not found /// Case insensitive string search, returns String::npos if not found
size_t find_i(const String& heystack, const String& needle); size_t find_i(const String& heystack, const String& needle);
/// Compare two strings for equality, b may contain '_' where a contains ' ' /// Compare two strings for equality, b may contain ' ' where a contains '_'
bool cannocial_name_compare(const String& a, const Char* b); /** canoncial_name_compare(a,b) == (cannocial_name_form(a) == b)
* b should already be in cannonical name form
*/
bool canoncial_name_compare(const String& a, const Char* b);
// ----------------------------------------------------------------------------- : Regular expressions // ----------------------------------------------------------------------------- : Regular expressions
......
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