diff --git a/doc/file/format.txt b/doc/file/format.txt index 45677c7a..5860a4fa 100644 --- a/doc/file/format.txt +++ b/doc/file/format.txt @@ -33,16 +33,16 @@ A heirachical file can contain a reference to another file: Where filename must be an absolute or relative [[type:filename]]. That file is included literally into the current one; except for indentation, the included file never escapes from the level the 'include file' line is on. - -If the file to be included can vary depending on the locale that is selected, use: ->>>include localized file: filename -MSE will take the filename and add "_" followed by the name of the currently selected locale at the end of it. -So for example, if the locale used is the folder "en.mse-locale", the file that will be included is "filename_en" -You must provide a version of the file for each locale found in the data folder, even if it is simply a copy of the english one. - -If the file to be included can vary depending on if dark mode is selected, use: ->>>include dark file: filename -MSE will take the filename and add "_dark" if the app is currently in dark mode. If not, then nothing is added to the filename. + +If the file to be included can vary depending on the locale that is selected, use: +>>>include localized file: filename +MSE will take the filename and add "_" followed by the name of the currently selected locale at the end of it. +So for example, if the locale used is the folder "en.mse-locale", the file that will be included is "filename_en" +You must provide a version of the file for each locale found in the data folder, even if it is simply a copy of the english one. + +If the file to be included can vary depending on if dark mode is selected, use: +>>>include dark file: filename +MSE will take the filename and add "_dark" if the app is currently in dark mode. If not, then nothing is added to the filename. --Example-- For example, a [[type:set]] might look like this: diff --git a/doc/function/new_card.txt b/doc/function/new_card.txt index ff20ea65..bff8a8f4 100644 --- a/doc/function/new_card.txt +++ b/doc/function/new_card.txt @@ -6,10 +6,10 @@ Function: new_card Creates a new [[type:card]] object. The card is not automatically added to a set. Use the [[fun:add_card_to_set]] function for that. The argument is a map from card field names to values, for example @new_card([name: "My Card"])@ creates a card with the name @"My Card"@, and all other fields at their default value. - -The map can also contain the following built-in keys: notes, id, linked_card_1 to linked_card_4, linked_relation_1 to linked_relation_4, stylesheet, styling_data, and extra_data. For styling_data and extra_data, the value must itself be a map from field names to values. Be sure to define a stylesheet before these. - -NOTE: you should use underscores instead of spaces in field names. + +The map can also contain the following built-in keys: notes, id, linked_card_1 to linked_card_4, linked_relation_1 to linked_relation_4, stylesheet, styling_data, and extra_data. For styling_data and extra_data, the value must itself be a map from field names to values. Be sure to define a stylesheet before these. + +NOTE: you should use underscores instead of spaces in field names. --Parameters-- ! Parameter Type Description @@ -26,7 +26,7 @@ NOTE: you should use underscores instead of spaces in field names. > ]) > > # Write an image of the card to a file -> write_image_file(my_card, file: "my_card.png") +> write_image_file(my_card, file: "my_card.png") > # Add the card to the current set > add_card_to_set(my_card) diff --git a/doc/function/write_image_file.txt b/doc/function/write_image_file.txt index 9c394d53..8d82e81c 100644 --- a/doc/function/write_image_file.txt +++ b/doc/function/write_image_file.txt @@ -14,7 +14,7 @@ This function can only be used in an [[type:export template]], when create d --Parameters-- ! Parameter Type Description | @input@ [[type:image]] or [[type:card]] Image or Card to write to the file. -| @file@ [[type:string]] Name of the file to write to. +| @file@ [[type:string]] Name of the file to write to. | @width@ [[type:int]] Width in pixels to use for the image, by default the size of the image is used if available. | @height@ [[type:int]] Height in pixels to use for the image, by default the size of the image is used if available. | @zoom@ [[type:double]] Zoom percentage to apply to the card render. diff --git a/src/data/action/set.cpp b/src/data/action/set.cpp index 8b9425fd..936bae6d 100644 --- a/src/data/action/set.cpp +++ b/src/data/action/set.cpp @@ -212,7 +212,7 @@ String ChangeCardHasStylingAction::getName(bool to_undo) const { void ChangeCardHasStylingAction::perform(bool to_undo) { card->has_styling = !card->has_styling; swap(card->styling_data, styling_data); -} +} // ----------------------------------------------------------------------------- : Change notes @@ -239,7 +239,7 @@ void ChangeCardUIDAction::perform(bool to_undo) { c->updateLink(card->uid, uid); } swap(card->uid, uid); -} +} // ----------------------------------------------------------------------------- : Pack types diff --git a/src/data/action/set.hpp b/src/data/action/set.hpp index d5887e4d..0c53213d 100644 --- a/src/data/action/set.hpp +++ b/src/data/action/set.hpp @@ -147,7 +147,7 @@ public: Set& set; ///< The set to copy styling from CardP card; ///< The affected card IndexMap styling_data; ///< The old styling of the card -}; +}; // ----------------------------------------------------------------------------- : Change notes @@ -177,7 +177,7 @@ public: //private: CardP card; ///< The affected card String uid; ///< Its old uid -}; +}; // ----------------------------------------------------------------------------- : Pack types diff --git a/src/data/action/value.cpp b/src/data/action/value.cpp index 72a11470..4f0b09f1 100644 --- a/src/data/action/value.cpp +++ b/src/data/action/value.cpp @@ -36,7 +36,7 @@ void ValueAction::setCard(CardP const& card) { } // ----------------------------------------------------------------------------- : Simple - + unique_ptr value_action(const TextValueP& value, const Defaultable& new_value) { return make_unique>(value, new_value); } @@ -208,7 +208,7 @@ String ScriptStyleEvent::getName(bool) const { } void ScriptStyleEvent::perform(bool) { assert(false); // this action is just an event, it should not be performed -} +} // ----------------------------------------------------------------------------- : Bulk action @@ -235,7 +235,7 @@ void BulkAction::perform(bool to_undo) { bool BulkAction::merge(const Action& action) { return false; -} +} // ----------------------------------------------------------------------------- : Action performer diff --git a/src/data/card.cpp b/src/data/card.cpp index b886fc5f..9a11d643 100644 --- a/src/data/card.cpp +++ b/src/data/card.cpp @@ -298,32 +298,32 @@ CardP Card::getLinkedOtherFace(const Set& set) { return getLinkedOtherFace(set.cards); } -vector Card::getLinkedCardsFromLink(const vector& cards, const String& link, bool erase_if_no_card) { - vector other_cards; +vector Card::getLinkedCardsFromLink(const vector& cards, const String& link, bool erase_if_no_card) { + vector other_cards; THIS_LINKED_PAIRS(this_linked_pairs); FOR_EACH(this_linked_pair, this_linked_pairs) { String& this_linked_uid = this_linked_pair.first.get(); - String& this_linked_relation = this_linked_pair.second.get(); + String& this_linked_relation = this_linked_pair.second.get(); if (this_linked_relation == link) { CardP other_card = getCardFromUid(cards, this_linked_uid); - if (other_card) other_cards.push_back(other_card); + if (other_card) other_cards.push_back(other_card); else if (erase_if_no_card) { this_linked_relation = _(""); this_linked_uid = _(""); } - } + } } - return other_cards; + return other_cards; } vector Card::getLinkedCardsFromLink(const Set& set, const String& link, bool erase_if_no_card) { return getLinkedCardsFromLink(set.cards, link, erase_if_no_card); } -CardP Card::getCardFromUid(const vector& cards, const String& uid) { +CardP Card::getCardFromUid(const vector& cards, const String& uid) { FOR_EACH(card, cards) { if (card->uid == uid) return card; } - return nullptr; + return nullptr; } CardP Card::getCardFromUid(const Set& set, const String& uid) { return getCardFromUid(set.cards, uid); diff --git a/src/data/card.hpp b/src/data/card.hpp index c480a879..71511d7d 100644 --- a/src/data/card.hpp +++ b/src/data/card.hpp @@ -90,10 +90,10 @@ public: void updateLink(String old_uid, String new_uid); vector> getLinkedCards(const vector& cards); - vector> getLinkedCards(const Set& set); + vector> getLinkedCards(const Set& set); - vector getLinkedCardsFromLink(const vector& cards, const String& link, bool erase_if_no_card); - vector getLinkedCardsFromLink(const Set& set, const String& link, bool erase_if_no_card); + vector getLinkedCardsFromLink(const vector& cards, const String& link, bool erase_if_no_card); + vector getLinkedCardsFromLink(const Set& set, const String& link, bool erase_if_no_card); CardP getLinkedOtherFace(const vector& cards); CardP getLinkedOtherFace(const Set& set); diff --git a/src/data/field.hpp b/src/data/field.hpp index 3ede7d99..553a8559 100644 --- a/src/data/field.hpp +++ b/src/data/field.hpp @@ -126,23 +126,23 @@ public: inline RealPoint getPos() const { return RealPoint(left, top); } inline RealSize getSize() const { return RealSize(width, height); } inline RealRect getExternalRect() const { return RealRect(left, top, width, height); } - inline std::string getExternalRectString(double scale, Radians angle, double bleed, int img_width, int img_height, int img_offset) { ///< update the style before calling this + inline std::string getExternalRectString(double scale, Radians angle, double bleed, int img_width, int img_height, int img_offset) { ///< update the style before calling this double x = left * scale, y = top * scale; double w = width * scale, h = height * scale; - RealRect rect(x, y, w, h); - int degrees = 0; + RealRect rect(x, y, w, h); + int degrees = 0; if (is_rad0(angle)) { } else if (is_rad180(angle)) { - rect = RealRect(img_width - x - w, img_height - y - h, w, h); + rect = RealRect(img_width - x - w, img_height - y - h, w, h); degrees = 180; } else if (is_rad90(angle)) { - rect = RealRect(y, img_height - x - w, h, w); + rect = RealRect(y, img_height - x - w, h, w); degrees = 90; } else if (is_rad270(angle)) { - rect = RealRect(img_width - y - h, x, h, w); + rect = RealRect(img_width - y - h, x, h, w); degrees = 270; - } else { - return ""; + } else { + return ""; } return "" + std::to_string((int)std::ceil (rect.x + bleed + img_offset)) + "-" + std::to_string((int)std::ceil (rect.y + bleed)) + diff --git a/src/data/field/choice.cpp b/src/data/field/choice.cpp index 561715b7..41a1776e 100644 --- a/src/data/field/choice.cpp +++ b/src/data/field/choice.cpp @@ -39,7 +39,7 @@ IMPLEMENT_REFLECTION(ChoiceField) { } void ChoiceField::after_reading(Version ver) { - Field::after_reading(ver); + Field::after_reading(ver); if (choices->choices.size() < 1) { choices->choices.push_back(make_intrusive(name)); } diff --git a/src/data/field/choice.hpp b/src/data/field/choice.hpp index 4784677a..490e5f21 100644 --- a/src/data/field/choice.hpp +++ b/src/data/field/choice.hpp @@ -40,7 +40,7 @@ public: String default_name; ///< Name of "default" value map choice_colors; ///< Colors for the various choices (when color_cardlist) map choice_colors_cardlist; ///< Colors for the various choices, for in the card list - bool is_slider = false; ///< Should the UI be displayed as a slider? + bool is_slider = false; ///< Should the UI be displayed as a slider? void initDependencies(Context&, const Dependency&) const override; void after_reading(Version ver) override; diff --git a/src/data/field/color.cpp b/src/data/field/color.cpp index 575cc9c7..6b17c992 100644 --- a/src/data/field/color.cpp +++ b/src/data/field/color.cpp @@ -89,9 +89,9 @@ void ColorStyle::checkContentDependencies(Context& ctx, const Dependency& dep) c left_width .initDependencies(ctx, dep); right_width .initDependencies(ctx, dep); top_width .initDependencies(ctx, dep); - bottom_width.initDependencies(ctx, dep); + bottom_width.initDependencies(ctx, dep); Style::checkContentDependencies(ctx, dep); -} +} // ----------------------------------------------------------------------------- : ColorValue diff --git a/src/data/field/color.hpp b/src/data/field/color.hpp index 061dc02d..5707d18d 100644 --- a/src/data/field/color.hpp +++ b/src/data/field/color.hpp @@ -63,7 +63,7 @@ public: Scriptable bottom_width; ///< Width of the colored region on the bottom side ImageCombine combine; ///< How to combine image with the background - int update(Context&) override; + int update(Context&) override; void checkContentDependencies(Context&, const Dependency&) const override; }; diff --git a/src/data/field/image.hpp b/src/data/field/image.hpp index 0c95d82a..3b30cac2 100644 --- a/src/data/field/image.hpp +++ b/src/data/field/image.hpp @@ -54,17 +54,17 @@ public: ScriptableImage default_image; ///< Placeholder image when the user hasn't set one. Scriptable store_in_metadata; ///< Is the image stored in full in the metadata when exporting? - int update(Context&) override; - - inline std::string getExternalImageString(const SetP& set, ImageValue* value) { ///< update the style before calling this + int update(Context&) override; + + inline std::string getExternalImageString(const SetP& set, ImageValue* value) { ///< update the style before calling this auto imageInputStream = set->openIn(value->filename); Image img(*imageInputStream, wxBITMAP_TYPE_PNG); - if (!img.IsOk()) throw ScriptError(_ERROR_2_("file not found", value->filename.toStringForKey(), set)); - String temppath = wxFileName::CreateTempFileName(_("mse")) + _(".png"); - img.SaveFile(temppath); - std::string s = "" + fileToUTF8(temppath.ToStdString()) + ""; - wxRemoveFile(temppath); - wxRemoveFile(temppath.substr(0, temppath.size() - 4)); - return s; + if (!img.IsOk()) throw ScriptError(_ERROR_2_("file not found", value->filename.toStringForKey(), set)); + String temppath = wxFileName::CreateTempFileName(_("mse")) + _(".png"); + img.SaveFile(temppath); + std::string s = "" + fileToUTF8(temppath.ToStdString()) + ""; + wxRemoveFile(temppath); + wxRemoveFile(temppath.substr(0, temppath.size() - 4)); + return s; } }; diff --git a/src/data/font.cpp b/src/data/font.cpp index 993edb01..c08cd752 100644 --- a/src/data/font.cpp +++ b/src/data/font.cpp @@ -162,15 +162,15 @@ wxFont Font::toWxFont(double scale) const { if (flags & FONT_CODE) { if (size_i < 2) { - font = wxFont(wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, weight_i, underline(), _("Courier New")); - if (strikethrough()) font.MakeStrikethrough(); + font = wxFont(wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, weight_i, underline(), _("Courier New")); + if (strikethrough()) font.MakeStrikethrough(); return font; } else { font = wxFont(size_i, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, weight_i, underline(), _("Courier New")); } } else if (name().empty()) { font = *wxNORMAL_FONT; - font.SetPointSize(size > 1 ? size_i : int(scale * font.GetPointSize())); + font.SetPointSize(size > 1 ? size_i : int(scale * font.GetPointSize())); if (strikethrough()) font.MakeStrikethrough(); return font; } else if (flags & FONT_ITALIC && !italic_name().empty()) { @@ -188,7 +188,7 @@ wxFont Font::toWxFont(double scale) const { // make it independent of screen dpi, always use 96 dpi // TODO: do something more sensible, and more portable font.SetPixelSize(wxSize(0, -(int)(scale*size*96.0/72.0 + 0.5) )); - #endif + #endif if (strikethrough()) font.MakeStrikethrough(); return font; } diff --git a/src/data/format/clipboard.cpp b/src/data/format/clipboard.cpp index 40a1f734..1b38d807 100644 --- a/src/data/format/clipboard.cpp +++ b/src/data/format/clipboard.cpp @@ -15,7 +15,7 @@ #include #include #include -#include