convert to CRLF line endings

This commit is contained in:
GenevensiS
2026-01-05 01:01:18 +01:00
parent 168f6abe51
commit fbf2023848
68 changed files with 822 additions and 822 deletions
+2 -2
View File
@@ -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
+2 -2
View File
@@ -147,7 +147,7 @@ public:
Set& set; ///< The set to copy styling from
CardP card; ///< The affected card
IndexMap<FieldP,ValueP> 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
+3 -3
View File
@@ -36,7 +36,7 @@ void ValueAction::setCard(CardP const& card) {
}
// ----------------------------------------------------------------------------- : Simple
unique_ptr<ValueAction> value_action(const TextValueP& value, const Defaultable<String>& new_value) {
return make_unique<SimpleValueAction<TextValue, false>>(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
+8 -8
View File
@@ -298,32 +298,32 @@ CardP Card::getLinkedOtherFace(const Set& set) {
return getLinkedOtherFace(set.cards);
}
vector<CardP> Card::getLinkedCardsFromLink(const vector<CardP>& cards, const String& link, bool erase_if_no_card) {
vector<CardP> other_cards;
vector<CardP> Card::getLinkedCardsFromLink(const vector<CardP>& cards, const String& link, bool erase_if_no_card) {
vector<CardP> 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<CardP> 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<CardP>& cards, const String& uid) {
CardP Card::getCardFromUid(const vector<CardP>& 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);
+3 -3
View File
@@ -90,10 +90,10 @@ public:
void updateLink(String old_uid, String new_uid);
vector<pair<CardP, String>> getLinkedCards(const vector<CardP>& cards);
vector<pair<CardP, String>> getLinkedCards(const Set& set);
vector<pair<CardP, String>> getLinkedCards(const Set& set);
vector<CardP> getLinkedCardsFromLink(const vector<CardP>& cards, const String& link, bool erase_if_no_card);
vector<CardP> getLinkedCardsFromLink(const Set& set, const String& link, bool erase_if_no_card);
vector<CardP> getLinkedCardsFromLink(const vector<CardP>& cards, const String& link, bool erase_if_no_card);
vector<CardP> getLinkedCardsFromLink(const Set& set, const String& link, bool erase_if_no_card);
CardP getLinkedOtherFace(const vector<CardP>& cards);
CardP getLinkedOtherFace(const Set& set);
+8 -8
View File
@@ -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 "<mse-crop-data>" + std::to_string((int)std::ceil (rect.x + bleed + img_offset)) +
"-" + std::to_string((int)std::ceil (rect.y + bleed)) +
+1 -1
View File
@@ -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<Choice>(name));
}
+1 -1
View File
@@ -40,7 +40,7 @@ public:
String default_name; ///< Name of "default" value
map<String,Color> choice_colors; ///< Colors for the various choices (when color_cardlist)
map<String,Color> 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;
+2 -2
View File
@@ -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
+1 -1
View File
@@ -63,7 +63,7 @@ public:
Scriptable<double> 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;
};
+10 -10
View File
@@ -54,17 +54,17 @@ public:
ScriptableImage default_image; ///< Placeholder image when the user hasn't set one.
Scriptable<bool> 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 = "<mse-image-data>" + fileToUTF8(temppath.ToStdString()) + "</mse-image-data>";
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 = "<mse-image-data>" + fileToUTF8(temppath.ToStdString()) + "</mse-image-data>";
wxRemoveFile(temppath);
wxRemoveFile(temppath.substr(0, temppath.size() - 4));
return s;
}
};
+4 -4
View File
@@ -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;
}
+11 -11
View File
@@ -15,7 +15,7 @@
#include <data/stylesheet.hpp>
#include <data/keyword.hpp>
#include <util/io/package.hpp>
#include <script/scriptable.hpp>
#include <script/scriptable.hpp>
#include <wx/filename.h>
#include <wx/sstream.h>
@@ -145,20 +145,20 @@ KeywordP KeywordDataObject::getKeyword(const SetP& set) {
CardsOnClipboard::CardsOnClipboard(const SetP& set, const String id, const vector<CardP>& cards) {
// Conversion to image file
if (cards.size() < 6) {
Image img;
if (cards.size() == 1) {
if (cards.size() < 6) {
Image img;
if (cards.size() == 1) {
img = export_image(set, cards[0]);
}
}
else {
img = export_image(set, cards);
}
String temp_path = wxFileName::CreateTempFileName(_("mse")) + _(".png");
img.SaveFile(temp_path, wxBITMAP_TYPE_PNG);
wxFileDataObject* data = new wxFileDataObject();
data->AddFile(temp_path);
}
String temp_path = wxFileName::CreateTempFileName(_("mse")) + _(".png");
img.SaveFile(temp_path, wxBITMAP_TYPE_PNG);
wxFileDataObject* data = new wxFileDataObject();
data->AddFile(temp_path);
Add(data);
}
// Conversion to serialized card format
// Conversion to serialized card format
Add(new CardsDataObject(set, id, cards), true);
}
+2 -2
View File
@@ -93,8 +93,8 @@ Image export_image(const SetP& set, const CardP& card, const bool write_metadata
Image export_image(const SetP& set, const vector<CardP>& cards, const int padding = 2, const double global_zoom = 1.0, const bool use_zoom_setting = true, const bool use_rotation_setting = true, const bool use_bleed_setting = false);
/// Export the image of one or more cards to a given filename, using the app's zoom, rotation and bleed settings, and including metadata
void export_image(const SetP& set, const CardP& card, const String& filename);
void export_image(const SetP& set, const vector<CardP>& cards, const String& path, const String& filename_template, FilenameConflicts conflicts);
void export_image(const SetP& set, const CardP& card, const String& filename);
void export_image(const SetP& set, const vector<CardP>& cards, const String& path, const String& filename_template, FilenameConflicts conflicts);
/// Export a set to Magic Workstation format
void export_mws(Window* parent, const SetP& set);
+68 -68
View File
@@ -19,14 +19,14 @@
#include <data/settings.hpp>
#include <script/functions/json.hpp>
#include <gui/util.hpp>
#include <render/card/viewer.hpp>
#include <render/card/viewer.hpp>
class ZoomedUnrotatedDataViewer : public DataViewer {
public:
ZoomedUnrotatedDataViewer(double zoom) : zoom(zoom) {};
virtual ~ZoomedUnrotatedDataViewer() {};
Rotation getRotation() const override;
private:
Rotation getRotation() const override;
private:
double zoom;
};
@@ -36,14 +36,14 @@ Rotation ZoomedUnrotatedDataViewer::getRotation() const {
// ----------------------------------------------------------------------------- : wxImage export
Image export_image(const SetP& set, const CardP& card, const bool write_metadata, const double zoom, const Radians angle_radians, const double bleed_pixels) {
Image export_image(const SetP& set, const CardP& card, const bool write_metadata, const double zoom, const Radians angle_radians, const double bleed_pixels) {
if (!set) throw Error(_("no set"));
/// create and zoom
/// create and zoom
ZoomedUnrotatedDataViewer viewer = ZoomedUnrotatedDataViewer(zoom);
viewer.setSet(set);
viewer.setCard(card);
RealSize size = viewer.getRotation().getExternalSize();
int bleed = lround(bleed_pixels);
int bleed = lround(bleed_pixels);
Bitmap bitmap((int)size.width + 2 * bleed, (int)size.height + 2 * bleed);
if (!bitmap.Ok()) throw InternalError(_("Unable to create bitmap"));
wxMemoryDC dc;
@@ -51,18 +51,18 @@ Image export_image(const SetP& set, const CardP& card, const bool write_metadata
dc.SetDeviceOrigin(bleed, bleed);
viewer.draw(dc);
dc.SelectObject(wxNullBitmap);
Image img = bitmap.ConvertToImage();
/// rotate
img = rotate_image(img, angle_radians);
/// add print bleed edge
int width = img.GetWidth(), height = img.GetHeight();
bleed = max(0, min(width-1, min(height-1, bleed)));
Image img = bitmap.ConvertToImage();
/// rotate
img = rotate_image(img, angle_radians);
/// add print bleed edge
int width = img.GetWidth(), height = img.GetHeight();
bleed = max(0, min(width-1, min(height-1, bleed)));
if (size.width < bleed + 2 || size.height < bleed + 2) {
queue_message(MESSAGE_ERROR, _("Image too small to add bleed edge"));
}
else {
}
else {
if (!img.HasAlpha()) img.InitAlpha();
Byte* pixels = img.GetData();
Byte* alpha = img.GetAlpha();
@@ -126,17 +126,17 @@ Image export_image(const SetP& set, const CardP& card, const bool write_metadata
pixels[3 * pixel + 2] = pixels[3 * mirror + 2];
alpha[pixel] = alpha[mirror];
}
}
}
/// add metadata
}
}
/// add metadata
if (write_metadata) {
String metadata = _("<mse-card-data>[");
IndexMap<FieldP, ValueP>& card_data = card->data;
boost::json::object cardv = mse_to_json(card, set.get());
boost::json::object& cardv_data = cardv["data"].as_object();
StyleSheetP stylesheet = set->stylesheetForP(card);
if (!settings.stylesheetSettingsFor(*stylesheet).card_notes_export()) cardv["notes"] = "";
if (!settings.stylesheetSettingsFor(*stylesheet).card_notes_export()) cardv["notes"] = "";
// iterate over all image fields
for(IndexMap<FieldP, ValueP>::iterator it = card_data.begin() ; it != card_data.end() ; ++it) {
ImageValue* value = dynamic_cast<ImageValue*>(it->get());
@@ -144,64 +144,64 @@ Image export_image(const SetP& set, const CardP& card, const bool write_metadata
FieldP field = (*it)->fieldP;
ImageStyle* style = dynamic_cast<ImageStyle*>(stylesheet->card_style.at(field->index).get());
if (style) {
style->update(set->getContext(card));
// store the entire image in the metadata
if (style->store_in_metadata()) {
std::string bytes = style->getExternalImageString(set, value);
cardv_data[field->name.ToStdString()] = bytes;
}
// store only crop coordinates
else {
style->update(set->getContext(card));
// store the entire image in the metadata
if (style->store_in_metadata()) {
std::string bytes = style->getExternalImageString(set, value);
cardv_data[field->name.ToStdString()] = bytes;
}
// store only crop coordinates
else {
std::string rect = style->getExternalRectString(zoom, angle_radians, bleed_pixels, width, height, 0);
cardv_data[field->name.ToStdString()] = rect;
cardv_data[field->name.ToStdString()] = rect;
}
}
}
}
metadata += json_ugly_print(cardv) + _("]</mse-card-data>");
img.SetOption(wxIMAGE_OPTION_PNG_DESCRIPTION, metadata);
}
}
return img;
}
Image export_image( const SetP& set, const vector<CardP>& cards,
const int padding,
const double global_zoom,
const bool use_zoom_setting,
const bool use_rotation_setting,
Image export_image( const SetP& set, const vector<CardP>& cards,
const int padding,
const double global_zoom,
const bool use_zoom_setting,
const bool use_rotation_setting,
const bool use_bleed_setting) {
if (!set) throw Error(_("no set"));
if (cards.size() == 0) throw Error(_("no cards"));
vector<Image> imgs;
vector<int> offsets;
vector<int> offsets;
vector<double> zooms;
vector<double> angles;
vector<double> bleeds;
// Draw card images
FOR_EACH(card, cards) {
FOR_EACH(card, cards) {
Settings::ExportSettings card_settings = settings.exportSettingsFor(set->stylesheetFor(card));
double zoom = use_zoom_setting ? global_zoom * card_settings.zoom : global_zoom;
double angle = use_rotation_setting ? card_settings.angle_radians : 0.0;
double bleed = use_bleed_setting ? card_settings.bleed_pixels : 0.0;
imgs.push_back(export_image(set, card, false, zoom, angle, bleed));
zooms.push_back(zoom);
angles.push_back(angle);
imgs.push_back(export_image(set, card, false, zoom, angle, bleed));
zooms.push_back(zoom);
angles.push_back(angle);
bleeds.push_back(bleed);
}
}
int global_width = 0;
int global_height = 0;
vector<int> widths;
vector<int> heights;
FOR_EACH(img, imgs) {
int width = img.GetWidth();
int height = img.GetHeight();
widths.push_back(width);
heights.push_back(height);
offsets.push_back(global_width);
global_width += padding + width;
global_height = max(global_height, height);
}
FOR_EACH(img, imgs) {
int width = img.GetWidth();
int height = img.GetHeight();
widths.push_back(width);
heights.push_back(height);
offsets.push_back(global_width);
global_width += padding + width;
global_height = max(global_height, height);
}
global_width -= padding;
// Draw global image
Image global_img = Image(global_width, global_height);
@@ -215,11 +215,11 @@ Image export_image( const SetP& set, const vector<CardP>& cards,
pixels[3 * i + 1] = 0;
pixels[3 * i + 2] = 0;
alpha[i] = 0;
}
}
// Paste card images
FOR_EACH_2(img, imgs, offset, offsets) {
global_img.Paste(img, offset, 0);
}
FOR_EACH_2(img, imgs, offset, offsets) {
global_img.Paste(img, offset, 0);
}
// Write metadata
String metadata = _("<mse-card-data>[");
for (int i = 0; i < cards.size(); ++i) {
@@ -233,19 +233,19 @@ Image export_image( const SetP& set, const vector<CardP>& cards,
for(IndexMap<FieldP, ValueP>::iterator it = card_data.begin() ; it != card_data.end() ; ++it) {
ImageValue* value = dynamic_cast<ImageValue*>(it->get());
if (value && !value->filename.empty()) {
FieldP field = (*it)->fieldP;
FieldP field = (*it)->fieldP;
ImageStyle* style = dynamic_cast<ImageStyle*>(stylesheet->card_style.at(field->index).get());
if (style) {
style->update(set->getContext(card));
// store the entire image in the metadata
if (style->store_in_metadata()) {
std::string bytes = style->getExternalImageString(set, value);
cardv_data[field->name.ToStdString()] = bytes;
}
// store only crop coordinates
else {
style->update(set->getContext(card));
// store the entire image in the metadata
if (style->store_in_metadata()) {
std::string bytes = style->getExternalImageString(set, value);
cardv_data[field->name.ToStdString()] = bytes;
}
// store only crop coordinates
else {
std::string rect = style->getExternalRectString(zooms[i], angles[i], bleeds[i], widths[i], heights[i], offsets[i]);
cardv_data[field->name.ToStdString()] = rect;
cardv_data[field->name.ToStdString()] = rect;
}
}
}
@@ -253,14 +253,14 @@ Image export_image( const SetP& set, const vector<CardP>& cards,
metadata += json_ugly_print(cardv);
}
metadata += _("]</mse-card-data>");
global_img.SetOption(wxIMAGE_OPTION_PNG_DESCRIPTION, metadata);
global_img.SetOption(wxIMAGE_OPTION_PNG_DESCRIPTION, metadata);
return global_img;
}
void export_image(const SetP& set, const CardP& card, const String& filename) {
void export_image(const SetP& set, const CardP& card, const String& filename) {
const StyleSheet& stylesheet = set->stylesheetFor(card);
StyleSheetSettings& stylesheet_settings = settings.stylesheetSettingsFor(stylesheet);
StyleSheetSettings& stylesheet_settings = settings.stylesheetSettingsFor(stylesheet);
Settings::ExportSettings export_settings = settings.exportSettingsFor(stylesheet);
Image img = export_image(set, card, true, export_settings.zoom, export_settings.angle_radians, export_settings.bleed_pixels);
img.SaveFile(filename);
+17 -17
View File
@@ -67,7 +67,7 @@ IMPLEMENT_REFLECTION(Game) {
REFLECT_NO_SCRIPT(auto_replaces);
}
void Game::validate(Version v) {
void Game::validate(Version v) {
// check that we have at least one card field
if (card_fields.size() < 1) {
throw Error(_ERROR_1_("no card fields", name()));
@@ -123,11 +123,11 @@ void Game::validate(Version v) {
card_fields_alt_names.emplace(unified_name, field->name);
}
}
}
// front face/back face card link
card_links.insert(card_links.begin(), make_intrusive<CardLink>());
}
// front face/back face card link
card_links.insert(card_links.begin(), make_intrusive<CardLink>());
card_links[0]->selected.default_ = _("Front Face");
card_links[0]->selected.translations = std::unordered_map<String, String>{
card_links[0]->selected.translations = std::unordered_map<String, String>{
{_("ch-s"), _("卡片正面")},
{_("ch-t"), _("卡片正面")},
{_("da"), _("Forside")},
@@ -140,9 +140,9 @@ void Game::validate(Version v) {
{_("ko"), _("카드 앞면")},
{_("pl"), _("Przód")},
{_("pt-br"), _("Frente")},
{_("ru"), _("Лицевая сторона")}
};
card_links[0]->linked.default_ = _("Back Face");
{_("ru"), _("Лицевая сторона")}
};
card_links[0]->linked.default_ = _("Back Face");
card_links[0]->linked.translations = std::unordered_map<String, String>{
{_("ch-s"), _("卡片背面")},
{_("ch-t"), _("卡片背面")},
@@ -156,27 +156,27 @@ void Game::validate(Version v) {
{_("ko"), _("카드 뒷면")},
{_("pl"), _("Tył")},
{_("pt-br"), _("Verso")},
{_("ru"), _("Обратная сторона")}
};
{_("ru"), _("Обратная сторона")}
};
// localized card link names map
for (auto it = card_links.begin(); it != card_links.end(); ++it) {
CardLinkP link = *it;
String selected_default = link->selected.default_;
String selected_default = link->selected.default_;
for (auto selected_it = link->selected.translations.begin(); selected_it != link->selected.translations.end(); selected_it++) {
String selected_tr = unified_form(selected_it->second);
String selected_tr = unified_form(selected_it->second);
if (card_links_alt_names.find(selected_tr) != card_links_alt_names.end() && card_links_alt_names[selected_tr] != selected_default) {
queue_message(MESSAGE_WARNING, _ERROR_3_("link duplicate", selected_tr, card_links_alt_names[selected_tr], selected_default));
}
}
card_links_alt_names.emplace(selected_tr, selected_default);
}
String linked_default = link->linked.default_;
String linked_default = link->linked.default_;
for (auto linked_it = link->linked.translations.begin(); linked_it != link->linked.translations.end(); linked_it++) {
String linked_tr = unified_form(linked_it->second);
String linked_tr = unified_form(linked_it->second);
if (card_links_alt_names.find(linked_tr) != card_links_alt_names.end() && card_links_alt_names[linked_tr] != linked_default) {
queue_message(MESSAGE_WARNING, _ERROR_3_("link duplicate", linked_tr, card_links_alt_names[linked_tr], linked_default));
}
}
card_links_alt_names.emplace(linked_tr, linked_default);
}
}
}
}
+2 -2
View File
@@ -37,8 +37,8 @@ IMPLEMENT_REFLECTION(Installer) {
void Installer::validate(Version file_app_version) {
Packaged::validate(file_app_version);
// load icons where possible
FOR_EACH(p,packages) {
String url = p->icon_url;
FOR_EACH(p,packages) {
String url = p->icon_url;
if (settings.darkMode() && !p->dark_icon_url.empty()) {
url = p->dark_icon_url;
}
+5 -5
View File
@@ -108,11 +108,11 @@ IndexMap<FieldP, ValueP>& Set::stylingDataFor(const CardP& card) {
}
void Set::referenceActionStackFiles() {
referenceActionStackFiles(true);
referenceActionStackFiles(true);
referenceActionStackFiles(false);
}
void Set::referenceActionStackFiles(bool undo) {
for (auto&& action : undo ? actions.undo_actions : actions.redo_actions) {
void Set::referenceActionStackFiles(bool undo) {
for (auto&& action : undo ? actions.undo_actions : actions.redo_actions) {
try {
SimpleValueAction<ImageValue, false>& v = dynamic_cast<SimpleValueAction<ImageValue, false>&>(*action);
if (ImageValue* v2 = dynamic_cast<ImageValue*>(v.valueP.get())) {
@@ -125,9 +125,9 @@ void Set::referenceActionStackFiles(bool undo) {
referenceFile(v.new_value.toStringForWriting());
referenceFile(v2->filename.toStringForWriting());
}
} catch (...) {} }
} catch (...) {} }
}
}
}
String Set::identification() const {
// an identifying field
+4 -4
View File
@@ -89,12 +89,12 @@ public:
/// Styling information for a particular stylesheet
IndexMap<FieldP, ValueP>& stylingDataFor(const StyleSheet&);
/// Styling information for a particular card
IndexMap<FieldP, ValueP>& stylingDataFor(const CardP& card);
/// Make sure the image and symbol files from
IndexMap<FieldP, ValueP>& stylingDataFor(const CardP& card);
/// Make sure the image and symbol files from
/// the ActionStack are saved so we can undo
void referenceActionStackFiles();
void referenceActionStackFiles(bool undo);
void referenceActionStackFiles(bool undo);
/// Get the identification of this set, an identification is something like a name, title, etc.
/** May return "" */
+40 -40
View File
@@ -54,7 +54,7 @@ IMPLEMENT_REFLECTION_ENUM(FilenameConflicts) {
}
const vector<int> Settings::scale_choices = { 50,66,75,80,100,120,125,150,175,200 };
const int COLUMN_NOT_INITIALIZED = -100000;
ColumnSettings::ColumnSettings()
@@ -103,11 +103,11 @@ void GameSettings::initDefaults(const Game& game) {
ar->custom = false;
auto_replaces.push_back(ar);
}
}
// make sure things aren't in a problematic state
}
// make sure things aren't in a problematic state
for (auto it = cardlist_columns.begin(); it != cardlist_columns.end(); ++it) {
if (it->second.width < 20) it->second.width = 20;
}
}
if (images_export_filename.Trim().empty()) images_export_filename = _("{card.name}.png");
}
@@ -174,13 +174,13 @@ IMPLEMENT_REFLECTION_ENUM(CutterLinesType) {
VALUE_N("none", CUTTER_NONE);
}
// ----------------------------------------------------------------------------- : Dark mode settings
IMPLEMENT_REFLECTION_ENUM(DarkModeType) {
VALUE_N("yes", DARKMODE_YES);
VALUE_N("system", DARKMODE_SYSTEM);
VALUE_N("no", DARKMODE_NO);
}
// ----------------------------------------------------------------------------- : Dark mode settings
IMPLEMENT_REFLECTION_ENUM(DarkModeType) {
VALUE_N("yes", DARKMODE_YES);
VALUE_N("system", DARKMODE_SYSTEM);
VALUE_N("no", DARKMODE_NO);
}
// ----------------------------------------------------------------------------- : Settings
@@ -234,7 +234,7 @@ GameSettings& Settings::gameSettingsFor(const Game& game) {
if (!gs) gs = make_intrusive<GameSettings>();
gs->initDefaults(game);
return *gs;
}
}
ColumnSettings& Settings::columnSettingsFor(const Game& game, const Field& field) {
// Get game info
@@ -248,7 +248,7 @@ ColumnSettings& Settings::columnSettingsFor(const Game& game, const Field& field
cs.width = field.card_list_width;
}
return cs;
}
}
StyleSheetSettings& Settings::stylesheetSettingsFor(const StyleSheet& stylesheet) {
// Use the canonical form here since the stylesheet name will be used as a stored key.
@@ -257,37 +257,37 @@ StyleSheetSettings& Settings::stylesheetSettingsFor(const StyleSheet& stylesheet
if (!ss) ss = make_intrusive<StyleSheetSettings>();
ss->useDefault(default_stylesheet_settings); // update default settings
return *ss;
}
}
double Settings::exportScaleSettingsFor(const StyleSheet& stylesheet) {
StyleSheetSettings& ss = stylesheetSettingsFor(stylesheet);
int export_scale = ss.export_scale_selection();
if (export_scale == 0) return adaptiveScaleSettingsFor(stylesheet, 300.0, 50.0);
if (export_scale == 1) return adaptiveScaleSettingsFor(stylesheet, 300.0, 1.0);
if (export_scale == 2) return adaptiveScaleSettingsFor(stylesheet, 150.0, 1.0);
int export_scale = ss.export_scale_selection();
if (export_scale == 0) return adaptiveScaleSettingsFor(stylesheet, 300.0, 50.0);
if (export_scale == 1) return adaptiveScaleSettingsFor(stylesheet, 300.0, 1.0);
if (export_scale == 2) return adaptiveScaleSettingsFor(stylesheet, 150.0, 1.0);
return (double)scale_choices[export_scale - 3] / 100.0;
}
}
double Settings::importScaleSettingsFor(const StyleSheet& stylesheet) {
if (import_scale_selection == 0) return exportScaleSettingsFor(stylesheet);
if (import_scale_selection == 1) return adaptiveScaleSettingsFor(stylesheet, 300.0, 50.0);
if (import_scale_selection == 2) return adaptiveScaleSettingsFor(stylesheet, 300.0, 1.0);
if (import_scale_selection == 3) return adaptiveScaleSettingsFor(stylesheet, 150.0, 1.0);
if (import_scale_selection == 0) return exportScaleSettingsFor(stylesheet);
if (import_scale_selection == 1) return adaptiveScaleSettingsFor(stylesheet, 300.0, 50.0);
if (import_scale_selection == 2) return adaptiveScaleSettingsFor(stylesheet, 300.0, 1.0);
if (import_scale_selection == 3) return adaptiveScaleSettingsFor(stylesheet, 150.0, 1.0);
return (double)scale_choices[import_scale_selection - 4] / 100.0;
}
double Settings::adaptiveScaleSettingsFor(const StyleSheet& stylesheet, double dpi_target, double dpi_leeway) {
if (abs(stylesheet.card_dpi - dpi_target) <= dpi_leeway) return 1.0;
}
double Settings::adaptiveScaleSettingsFor(const StyleSheet& stylesheet, double dpi_target, double dpi_leeway) {
if (abs(stylesheet.card_dpi - dpi_target) <= dpi_leeway) return 1.0;
return dpi_target / max(10.0, stylesheet.card_dpi);
}
}
Settings::ExportSettings Settings::exportSettingsFor(const StyleSheet& stylesheet) {
StyleSheetSettings& ss = stylesheetSettingsFor(stylesheet);
double zoom = settings.exportScaleSettingsFor(stylesheet);
double zoom = settings.exportScaleSettingsFor(stylesheet);
double angle = ss.card_normal_export() ? 0.0 : deg_to_rad(ss.card_angle());
double bleed = ss.card_bleed_export() ? (stylesheet.card_dpi / 300.0) * 36.0 * zoom : 0.0; // 36 pixels of bleed on a 300 DPI print
double bleed = ss.card_bleed_export() ? (stylesheet.card_dpi / 300.0) * 36.0 * zoom : 0.0; // 36 pixels of bleed on a 300 DPI print
return ExportSettings{zoom, angle, bleed};
}
}
IndexMap<FieldP,ValueP>& Settings::exportOptionsFor(const ExportTemplate& export_template) {
return export_options.get(export_template.name(), export_template.option_fields);
@@ -306,17 +306,17 @@ String Settings::settingsFile() {
bool Settings::darkMode() {
return wxSystemSettings::GetAppearance().IsDark();
}
}
String Settings::darkModePrefix() {
if (darkMode()) return _("dark_");
if (darkMode()) return _("dark_");
return _("");
}
}
Color Settings::darkModeColor() {
if (darkMode()) return wxColor(15,8,0);
if (darkMode()) return wxColor(15,8,0);
return wxColor(240,247,255);
}
}
IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) {
REFLECT(locale);
@@ -377,10 +377,10 @@ void Settings::read() {
wxFileInputStream file(filename);
if (!file.Ok()) return; // failure is not an error
Reader reader(file, nullptr, filename);
reader.handle_greedy(*this);
// make sure things aren't in a problematic state
if (locale.Trim().empty()) locale = _("en");
if (symbol_grid_size < 30) symbol_grid_size = 30;
reader.handle_greedy(*this);
// make sure things aren't in a problematic state
if (locale.Trim().empty()) locale = _("en");
if (symbol_grid_size < 30) symbol_grid_size = 30;
if (default_stylesheet_settings.card_zoom < 0.5) default_stylesheet_settings.card_zoom = 1.0;
}
}
+29 -29
View File
@@ -113,22 +113,22 @@ public:
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : Printing settings
enum CutterLinesType
{ CUTTER_ALL
, CUTTER_NO_INTERSECTION
, CUTTER_NONE
};
// ----------------------------------------------------------------------------- : Dark mode settings
enum DarkModeType
{ DARKMODE_SYSTEM
, DARKMODE_NO
, DARKMODE_YES
};
// ----------------------------------------------------------------------------- : Printing settings
enum CutterLinesType
{ CUTTER_ALL
, CUTTER_NO_INTERSECTION
, CUTTER_NONE
};
// ----------------------------------------------------------------------------- : Dark mode settings
enum DarkModeType
{ DARKMODE_SYSTEM
, DARKMODE_NO
, DARKMODE_YES
};
// ----------------------------------------------------------------------------- : Settings
@@ -175,10 +175,10 @@ public:
String default_game;
// --------------------------------------------------- : Game/stylesheet specific
struct ExportSettings {
double zoom, angle_radians, bleed_pixels;
};
};
/// Get the settings object for a specific game
GameSettings& gameSettingsFor (const Game& game);
@@ -188,10 +188,10 @@ public:
StyleSheetSettings& stylesheetSettingsFor (const StyleSheet& stylesheet);
double exportScaleSettingsFor (const StyleSheet& stylesheet);
double importScaleSettingsFor (const StyleSheet& stylesheet);
double adaptiveScaleSettingsFor (const StyleSheet& stylesheet, double target_dpi, double leeway_dpi);
ExportSettings exportSettingsFor (const StyleSheet& stylesheet);
double adaptiveScaleSettingsFor (const StyleSheet& stylesheet, double target_dpi, double leeway_dpi);
ExportSettings exportSettingsFor (const StyleSheet& stylesheet);
static const vector<int> scale_choices;
static const vector<int> scale_choices;
private:
map<String,GameSettingsP> game_settings;
@@ -215,24 +215,24 @@ public:
// --------------------------------------------------- : Dark Mode
DarkModeType dark_mode_type;
/// Is the app currently displayed in dark mode?
bool darkMode();
DarkModeType dark_mode_type;
/// Is the app currently displayed in dark mode?
bool darkMode();
/// Prefix for resource files depending on dark mode
String darkModePrefix();
String darkModePrefix();
/// Background color for windows depending on dark mode
Color darkModeColor();
Color darkModeColor();
// --------------------------------------------------- : Special game stuff
String apprentice_location;
// --------------------------------------------------- : Internal settings
// --------------------------------------------------- : Internal settings
int import_scale_selection;
bool allow_image_download;
// --------------------------------------------------- : Update checking
// --------------------------------------------------- : Update checking
#if USE_OLD_STYLE_UPDATE_CHECKER
String updates_url;
@@ -243,7 +243,7 @@ public:
bool check_updates_all; ///< Check updates of all packages, not just the program
String website_url;
// --------------------------------------------------- : Installation settings
// --------------------------------------------------- : Installation settings
InstallType install_type;
+12 -12
View File
@@ -484,24 +484,24 @@ wxMenu* InsertSymbolMenu::makeMenu(int id, SymbolFont& font) const {
wxMenuItem* InsertSymbolMenu::makeMenuItem(wxMenu* parent, int first_id, SymbolFont& font) const {
String label = this->label.get();
// ensure that we are not defining an accelerator...
// ensure that we are not defining an accelerator...
// everything after a tab is considered to be an accelerator by wxMenuItem
int accel_pos = label.find_last_of('\t');
if (accel_pos != label.npos && accel_pos > 0) {
String accel = label.substr(accel_pos+1);
int accel_pos = label.find_last_of('\t');
if (accel_pos != label.npos && accel_pos > 0) {
String accel = label.substr(accel_pos+1);
#ifdef __WXMSW__
// if there is a + or - in the accelerator, replace the tab with spaces (simply adding a space does not work)
if (accel.Contains("+") || accel.Contains("-")) {
label = label.substr(0, accel_pos) + _(" ") + accel;
}
// otherwise simply add a space after the tab if there isn't one
else {
// if there is a + or - in the accelerator, replace the tab with spaces (simply adding a space does not work)
if (accel.Contains("+") || accel.Contains("-")) {
label = label.substr(0, accel_pos) + _(" ") + accel;
}
// otherwise simply add a space after the tab if there isn't one
else {
label.Replace(_("\t "), _("\t"));
label.Replace(_("\t"), _("\t "));
label.Replace(_("\t"), _("\t "));
}
#else
label = label.substr(0, accel_pos) + _(" ") + accel; // replace the tab with spaces
#endif
#endif
}
if (type == Type::SUBMENU) {
wxMenuItem* item = new wxMenuItem(parent, wxID_ANY, label,