From 0d0ce3cf27f5e84752bf43bfbcf45ea2b671a2c7 Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Thu, 12 Sep 2024 07:52:54 +0200 Subject: [PATCH 01/19] add dpi factor --- src/gui/control/card_viewer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/control/card_viewer.cpp b/src/gui/control/card_viewer.cpp index bf7d17d4..09d2c901 100644 --- a/src/gui/control/card_viewer.cpp +++ b/src/gui/control/card_viewer.cpp @@ -31,7 +31,7 @@ wxSize CardViewer::DoGetBestSize() const { if (set) { if (!stylesheet) stylesheet = set->stylesheet; StyleSheetSettings& ss = settings.stylesheetSettingsFor(*stylesheet); - wxSize size(int(stylesheet->card_width * ss.card_zoom()), int(stylesheet->card_height * ss.card_zoom())); + wxSize size(int(stylesheet->card_width * (150.0 / stylesheet->card_dpi) * ss.card_zoom()), int(stylesheet->card_height * (150.0 / stylesheet->card_dpi) * ss.card_zoom())); if (is_sideways(deg_to_rad(ss.card_angle()))) swap(size.x, size.y); return size + ws - cs; } @@ -150,7 +150,7 @@ Rotation CardViewer::getRotation() const { StyleSheetSettings& ss = settings.stylesheetSettingsFor(*stylesheet); int dx = CanScroll(wxHORIZONTAL) ? GetScrollPos(wxHORIZONTAL) : 0; int dy = CanScroll(wxVERTICAL) ? GetScrollPos(wxVERTICAL) : 0; - return Rotation(deg_to_rad(ss.card_angle()), stylesheet->getCardRect().move(-dx,-dy,0,0), ss.card_zoom(), 1.0, ROTATION_ATTACH_TOP_LEFT); + return Rotation(deg_to_rad(ss.card_angle()), stylesheet->getCardRect().move(-dx,-dy,0,0), (150.0 / stylesheet->card_dpi) * ss.card_zoom(), 1.0, ROTATION_ATTACH_TOP_LEFT); } // ----------------------------------------------------------------------------- : Event table From 6a0476929ec107ba8b0a0f23be2061bf51f544f0 Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Fri, 13 Sep 2024 03:43:16 +0200 Subject: [PATCH 02/19] take margin_right into account when determining width --- src/render/text/viewer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/render/text/viewer.cpp b/src/render/text/viewer.cpp index cc1bba5c..cae26541 100644 --- a/src/render/text/viewer.cpp +++ b/src/render/text/viewer.cpp @@ -613,7 +613,7 @@ bool TextViewer::prepareLinesAtScale(RotatedDC& dc, const vector& char } // Did the word become too long? if (!break_now) { - double max_width = lineRight(dc, style, line.top); + double max_width = lineRight(dc, style, line.top) - line.margin_right; if (line_size.width + word_size.width > max_width) { if (!style.field().multi_line) { // single line word does not fit From 14d357d69f064c5dfb4e2f5a42ce5530c5675d09 Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Fri, 13 Sep 2024 04:09:03 +0200 Subject: [PATCH 03/19] add brightness combine_blend modes --- src/gfx/combine_image.cpp | 310 +++++++++++++++++++++++++++++++++++++- src/gfx/gfx.hpp | 102 +++++++++++++ 2 files changed, 410 insertions(+), 2 deletions(-) diff --git a/src/gfx/combine_image.cpp b/src/gfx/combine_image.cpp index 65edcd49..f639ecb4 100644 --- a/src/gfx/combine_image.cpp +++ b/src/gfx/combine_image.cpp @@ -39,7 +39,109 @@ IMPLEMENT_REFLECTION_ENUM(ImageCombine) { VALUE_N("or", COMBINE_OR); VALUE_N("xor", COMBINE_XOR); VALUE_N("shadow", COMBINE_SHADOW); - VALUE_N("symmetric overlay",COMBINE_SYMMETRIC_OVERLAY); + VALUE_N("symmetric overlay", COMBINE_SYMMETRIC_OVERLAY); + VALUE_N("brightness to alpha", COMBINE_BRIGHTNESS_TO_ALPHA); + VALUE_N("darkness to alpha", COMBINE_DARKNESS_TO_ALPHA); + VALUE_N("greater than 5", COMBINE_GREATER_THAN_5); + VALUE_N("greater than 10", COMBINE_GREATER_THAN_10); + VALUE_N("greater than 15", COMBINE_GREATER_THAN_15); + VALUE_N("greater than 20", COMBINE_GREATER_THAN_20); + VALUE_N("greater than 25", COMBINE_GREATER_THAN_25); + VALUE_N("greater than 30", COMBINE_GREATER_THAN_30); + VALUE_N("greater than 35", COMBINE_GREATER_THAN_35); + VALUE_N("greater than 40", COMBINE_GREATER_THAN_40); + VALUE_N("greater than 45", COMBINE_GREATER_THAN_45); + VALUE_N("greater than 50", COMBINE_GREATER_THAN_50); + VALUE_N("greater than 55", COMBINE_GREATER_THAN_55); + VALUE_N("greater than 60", COMBINE_GREATER_THAN_60); + VALUE_N("greater than 65", COMBINE_GREATER_THAN_65); + VALUE_N("greater than 70", COMBINE_GREATER_THAN_70); + VALUE_N("greater than 75", COMBINE_GREATER_THAN_75); + VALUE_N("greater than 80", COMBINE_GREATER_THAN_80); + VALUE_N("greater than 85", COMBINE_GREATER_THAN_85); + VALUE_N("greater than 90", COMBINE_GREATER_THAN_90); + VALUE_N("greater than 95", COMBINE_GREATER_THAN_95); + VALUE_N("greater than 100", COMBINE_GREATER_THAN_100); + VALUE_N("greater than 105", COMBINE_GREATER_THAN_105); + VALUE_N("greater than 110", COMBINE_GREATER_THAN_110); + VALUE_N("greater than 115", COMBINE_GREATER_THAN_115); + VALUE_N("greater than 120", COMBINE_GREATER_THAN_120); + VALUE_N("greater than 125", COMBINE_GREATER_THAN_125); + VALUE_N("greater than 130", COMBINE_GREATER_THAN_130); + VALUE_N("greater than 135", COMBINE_GREATER_THAN_135); + VALUE_N("greater than 140", COMBINE_GREATER_THAN_140); + VALUE_N("greater than 145", COMBINE_GREATER_THAN_145); + VALUE_N("greater than 150", COMBINE_GREATER_THAN_150); + VALUE_N("greater than 155", COMBINE_GREATER_THAN_155); + VALUE_N("greater than 160", COMBINE_GREATER_THAN_160); + VALUE_N("greater than 165", COMBINE_GREATER_THAN_165); + VALUE_N("greater than 170", COMBINE_GREATER_THAN_170); + VALUE_N("greater than 175", COMBINE_GREATER_THAN_175); + VALUE_N("greater than 180", COMBINE_GREATER_THAN_180); + VALUE_N("greater than 185", COMBINE_GREATER_THAN_185); + VALUE_N("greater than 190", COMBINE_GREATER_THAN_190); + VALUE_N("greater than 195", COMBINE_GREATER_THAN_195); + VALUE_N("greater than 200", COMBINE_GREATER_THAN_200); + VALUE_N("greater than 205", COMBINE_GREATER_THAN_205); + VALUE_N("greater than 210", COMBINE_GREATER_THAN_210); + VALUE_N("greater than 215", COMBINE_GREATER_THAN_215); + VALUE_N("greater than 220", COMBINE_GREATER_THAN_220); + VALUE_N("greater than 225", COMBINE_GREATER_THAN_225); + VALUE_N("greater than 230", COMBINE_GREATER_THAN_230); + VALUE_N("greater than 235", COMBINE_GREATER_THAN_235); + VALUE_N("greater than 240", COMBINE_GREATER_THAN_240); + VALUE_N("greater than 245", COMBINE_GREATER_THAN_245); + VALUE_N("greater than 250", COMBINE_GREATER_THAN_250); + VALUE_N("smaller than 5", COMBINE_SMALLER_THAN_5); + VALUE_N("smaller than 10", COMBINE_SMALLER_THAN_10); + VALUE_N("smaller than 15", COMBINE_SMALLER_THAN_15); + VALUE_N("smaller than 20", COMBINE_SMALLER_THAN_20); + VALUE_N("smaller than 25", COMBINE_SMALLER_THAN_25); + VALUE_N("smaller than 30", COMBINE_SMALLER_THAN_30); + VALUE_N("smaller than 35", COMBINE_SMALLER_THAN_35); + VALUE_N("smaller than 40", COMBINE_SMALLER_THAN_40); + VALUE_N("smaller than 45", COMBINE_SMALLER_THAN_45); + VALUE_N("smaller than 50", COMBINE_SMALLER_THAN_50); + VALUE_N("smaller than 55", COMBINE_SMALLER_THAN_55); + VALUE_N("smaller than 60", COMBINE_SMALLER_THAN_60); + VALUE_N("smaller than 65", COMBINE_SMALLER_THAN_65); + VALUE_N("smaller than 70", COMBINE_SMALLER_THAN_70); + VALUE_N("smaller than 75", COMBINE_SMALLER_THAN_75); + VALUE_N("smaller than 80", COMBINE_SMALLER_THAN_80); + VALUE_N("smaller than 85", COMBINE_SMALLER_THAN_85); + VALUE_N("smaller than 90", COMBINE_SMALLER_THAN_90); + VALUE_N("smaller than 95", COMBINE_SMALLER_THAN_95); + VALUE_N("smaller than 100", COMBINE_SMALLER_THAN_100); + VALUE_N("smaller than 105", COMBINE_SMALLER_THAN_105); + VALUE_N("smaller than 110", COMBINE_SMALLER_THAN_110); + VALUE_N("smaller than 115", COMBINE_SMALLER_THAN_115); + VALUE_N("smaller than 120", COMBINE_SMALLER_THAN_120); + VALUE_N("smaller than 125", COMBINE_SMALLER_THAN_125); + VALUE_N("smaller than 130", COMBINE_SMALLER_THAN_130); + VALUE_N("smaller than 135", COMBINE_SMALLER_THAN_135); + VALUE_N("smaller than 140", COMBINE_SMALLER_THAN_140); + VALUE_N("smaller than 145", COMBINE_SMALLER_THAN_145); + VALUE_N("smaller than 150", COMBINE_SMALLER_THAN_150); + VALUE_N("smaller than 155", COMBINE_SMALLER_THAN_155); + VALUE_N("smaller than 160", COMBINE_SMALLER_THAN_160); + VALUE_N("smaller than 165", COMBINE_SMALLER_THAN_165); + VALUE_N("smaller than 170", COMBINE_SMALLER_THAN_170); + VALUE_N("smaller than 175", COMBINE_SMALLER_THAN_175); + VALUE_N("smaller than 180", COMBINE_SMALLER_THAN_180); + VALUE_N("smaller than 185", COMBINE_SMALLER_THAN_185); + VALUE_N("smaller than 190", COMBINE_SMALLER_THAN_190); + VALUE_N("smaller than 195", COMBINE_SMALLER_THAN_195); + VALUE_N("smaller than 200", COMBINE_SMALLER_THAN_200); + VALUE_N("smaller than 205", COMBINE_SMALLER_THAN_205); + VALUE_N("smaller than 210", COMBINE_SMALLER_THAN_210); + VALUE_N("smaller than 215", COMBINE_SMALLER_THAN_215); + VALUE_N("smaller than 220", COMBINE_SMALLER_THAN_220); + VALUE_N("smaller than 225", COMBINE_SMALLER_THAN_225); + VALUE_N("smaller than 230", COMBINE_SMALLER_THAN_230); + VALUE_N("smaller than 235", COMBINE_SMALLER_THAN_235); + VALUE_N("smaller than 240", COMBINE_SMALLER_THAN_240); + VALUE_N("smaller than 245", COMBINE_SMALLER_THAN_245); + VALUE_N("smaller than 250", COMBINE_SMALLER_THAN_250); } // ----------------------------------------------------------------------------- : Combining functions @@ -83,7 +185,109 @@ COMBINE_FUN(COMBINE_AND, a & b) COMBINE_FUN(COMBINE_OR, a | b) COMBINE_FUN(COMBINE_XOR, a ^ b) COMBINE_FUN(COMBINE_SHADOW, (b * a * a) / (255 * 255)) -COMBINE_FUN(COMBINE_SYMMETRIC_OVERLAY, (Combine::f(a,b) + Combine::f(b,a)) / 2 ) +COMBINE_FUN(COMBINE_SYMMETRIC_OVERLAY, (Combine::f(a, b) + Combine::f(b, a)) / 2) +COMBINE_FUN(COMBINE_BRIGHTNESS_TO_ALPHA, ((255 - a) * a + a * b) / 255) +COMBINE_FUN(COMBINE_DARKNESS_TO_ALPHA, (255 * a + (255 - a) * b) / 255) +COMBINE_FUN(COMBINE_GREATER_THAN_5, a > 5 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_10, a > 10 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_15, a > 15 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_20, a > 20 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_25, a > 25 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_30, a > 30 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_35, a > 35 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_40, a > 40 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_45, a > 45 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_50, a > 50 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_55, a > 55 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_60, a > 60 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_65, a > 65 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_70, a > 70 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_75, a > 75 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_80, a > 80 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_85, a > 85 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_90, a > 90 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_95, a > 95 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_100, a > 100 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_105, a > 105 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_110, a > 110 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_115, a > 115 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_120, a > 120 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_125, a > 125 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_130, a > 130 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_135, a > 135 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_140, a > 140 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_145, a > 145 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_150, a > 150 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_155, a > 155 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_160, a > 160 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_165, a > 165 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_170, a > 170 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_175, a > 175 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_180, a > 180 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_185, a > 185 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_190, a > 190 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_195, a > 195 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_200, a > 200 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_205, a > 205 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_210, a > 210 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_215, a > 215 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_220, a > 220 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_225, a > 225 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_230, a > 230 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_235, a > 235 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_240, a > 240 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_245, a > 245 ? b : a) +COMBINE_FUN(COMBINE_GREATER_THAN_250, a > 250 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_5, a < 5 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_10, a < 10 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_15, a < 15 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_20, a < 20 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_25, a < 25 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_30, a < 30 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_35, a < 35 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_40, a < 40 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_45, a < 45 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_50, a < 50 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_55, a < 55 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_60, a < 60 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_65, a < 65 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_70, a < 70 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_75, a < 75 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_80, a < 80 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_85, a < 85 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_90, a < 90 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_95, a < 95 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_100, a < 100 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_105, a < 105 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_110, a < 110 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_115, a < 115 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_120, a < 120 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_125, a < 125 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_130, a < 130 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_135, a < 135 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_140, a < 140 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_145, a < 145 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_150, a < 150 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_155, a < 155 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_160, a < 160 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_165, a < 165 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_170, a < 170 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_175, a < 175 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_180, a < 180 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_185, a < 185 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_190, a < 190 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_195, a < 195 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_200, a < 200 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_205, a < 205 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_210, a < 210 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_215, a < 215 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_220, a < 220 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_225, a < 225 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_230, a < 230 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_235, a < 235 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_240, a < 240 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_245, a < 245 ? b : a) +COMBINE_FUN(COMBINE_SMALLER_THAN_250, a < 250 ? b : a) // ----------------------------------------------------------------------------- : Combining @@ -136,6 +340,108 @@ void combine_image(Image& a, const Image& b, ImageCombine combine) { DISPATCH(COMBINE_XOR); DISPATCH(COMBINE_SHADOW); DISPATCH(COMBINE_SYMMETRIC_OVERLAY); + DISPATCH(COMBINE_BRIGHTNESS_TO_ALPHA); + DISPATCH(COMBINE_DARKNESS_TO_ALPHA); + DISPATCH(COMBINE_GREATER_THAN_5); + DISPATCH(COMBINE_GREATER_THAN_10); + DISPATCH(COMBINE_GREATER_THAN_15); + DISPATCH(COMBINE_GREATER_THAN_20); + DISPATCH(COMBINE_GREATER_THAN_25); + DISPATCH(COMBINE_GREATER_THAN_30); + DISPATCH(COMBINE_GREATER_THAN_35); + DISPATCH(COMBINE_GREATER_THAN_40); + DISPATCH(COMBINE_GREATER_THAN_45); + DISPATCH(COMBINE_GREATER_THAN_50); + DISPATCH(COMBINE_GREATER_THAN_55); + DISPATCH(COMBINE_GREATER_THAN_60); + DISPATCH(COMBINE_GREATER_THAN_65); + DISPATCH(COMBINE_GREATER_THAN_70); + DISPATCH(COMBINE_GREATER_THAN_75); + DISPATCH(COMBINE_GREATER_THAN_80); + DISPATCH(COMBINE_GREATER_THAN_85); + DISPATCH(COMBINE_GREATER_THAN_90); + DISPATCH(COMBINE_GREATER_THAN_95); + DISPATCH(COMBINE_GREATER_THAN_100); + DISPATCH(COMBINE_GREATER_THAN_105); + DISPATCH(COMBINE_GREATER_THAN_110); + DISPATCH(COMBINE_GREATER_THAN_115); + DISPATCH(COMBINE_GREATER_THAN_120); + DISPATCH(COMBINE_GREATER_THAN_125); + DISPATCH(COMBINE_GREATER_THAN_130); + DISPATCH(COMBINE_GREATER_THAN_135); + DISPATCH(COMBINE_GREATER_THAN_140); + DISPATCH(COMBINE_GREATER_THAN_145); + DISPATCH(COMBINE_GREATER_THAN_150); + DISPATCH(COMBINE_GREATER_THAN_155); + DISPATCH(COMBINE_GREATER_THAN_160); + DISPATCH(COMBINE_GREATER_THAN_165); + DISPATCH(COMBINE_GREATER_THAN_170); + DISPATCH(COMBINE_GREATER_THAN_175); + DISPATCH(COMBINE_GREATER_THAN_180); + DISPATCH(COMBINE_GREATER_THAN_185); + DISPATCH(COMBINE_GREATER_THAN_190); + DISPATCH(COMBINE_GREATER_THAN_195); + DISPATCH(COMBINE_GREATER_THAN_200); + DISPATCH(COMBINE_GREATER_THAN_205); + DISPATCH(COMBINE_GREATER_THAN_210); + DISPATCH(COMBINE_GREATER_THAN_215); + DISPATCH(COMBINE_GREATER_THAN_220); + DISPATCH(COMBINE_GREATER_THAN_225); + DISPATCH(COMBINE_GREATER_THAN_230); + DISPATCH(COMBINE_GREATER_THAN_235); + DISPATCH(COMBINE_GREATER_THAN_240); + DISPATCH(COMBINE_GREATER_THAN_245); + DISPATCH(COMBINE_GREATER_THAN_250); + DISPATCH(COMBINE_SMALLER_THAN_5); + DISPATCH(COMBINE_SMALLER_THAN_10); + DISPATCH(COMBINE_SMALLER_THAN_15); + DISPATCH(COMBINE_SMALLER_THAN_20); + DISPATCH(COMBINE_SMALLER_THAN_25); + DISPATCH(COMBINE_SMALLER_THAN_30); + DISPATCH(COMBINE_SMALLER_THAN_35); + DISPATCH(COMBINE_SMALLER_THAN_40); + DISPATCH(COMBINE_SMALLER_THAN_45); + DISPATCH(COMBINE_SMALLER_THAN_50); + DISPATCH(COMBINE_SMALLER_THAN_55); + DISPATCH(COMBINE_SMALLER_THAN_60); + DISPATCH(COMBINE_SMALLER_THAN_65); + DISPATCH(COMBINE_SMALLER_THAN_70); + DISPATCH(COMBINE_SMALLER_THAN_75); + DISPATCH(COMBINE_SMALLER_THAN_80); + DISPATCH(COMBINE_SMALLER_THAN_85); + DISPATCH(COMBINE_SMALLER_THAN_90); + DISPATCH(COMBINE_SMALLER_THAN_95); + DISPATCH(COMBINE_SMALLER_THAN_100); + DISPATCH(COMBINE_SMALLER_THAN_105); + DISPATCH(COMBINE_SMALLER_THAN_110); + DISPATCH(COMBINE_SMALLER_THAN_115); + DISPATCH(COMBINE_SMALLER_THAN_120); + DISPATCH(COMBINE_SMALLER_THAN_125); + DISPATCH(COMBINE_SMALLER_THAN_130); + DISPATCH(COMBINE_SMALLER_THAN_135); + DISPATCH(COMBINE_SMALLER_THAN_140); + DISPATCH(COMBINE_SMALLER_THAN_145); + DISPATCH(COMBINE_SMALLER_THAN_150); + DISPATCH(COMBINE_SMALLER_THAN_155); + DISPATCH(COMBINE_SMALLER_THAN_160); + DISPATCH(COMBINE_SMALLER_THAN_165); + DISPATCH(COMBINE_SMALLER_THAN_170); + DISPATCH(COMBINE_SMALLER_THAN_175); + DISPATCH(COMBINE_SMALLER_THAN_180); + DISPATCH(COMBINE_SMALLER_THAN_185); + DISPATCH(COMBINE_SMALLER_THAN_190); + DISPATCH(COMBINE_SMALLER_THAN_195); + DISPATCH(COMBINE_SMALLER_THAN_200); + DISPATCH(COMBINE_SMALLER_THAN_205); + DISPATCH(COMBINE_SMALLER_THAN_210); + DISPATCH(COMBINE_SMALLER_THAN_215); + DISPATCH(COMBINE_SMALLER_THAN_220); + DISPATCH(COMBINE_SMALLER_THAN_225); + DISPATCH(COMBINE_SMALLER_THAN_230); + DISPATCH(COMBINE_SMALLER_THAN_235); + DISPATCH(COMBINE_SMALLER_THAN_240); + DISPATCH(COMBINE_SMALLER_THAN_245); + DISPATCH(COMBINE_SMALLER_THAN_250); } } diff --git a/src/gfx/gfx.hpp b/src/gfx/gfx.hpp index bb3c0d7c..5f1ce9cd 100644 --- a/src/gfx/gfx.hpp +++ b/src/gfx/gfx.hpp @@ -121,6 +121,108 @@ enum ImageCombine , COMBINE_XOR , COMBINE_SHADOW , COMBINE_SYMMETRIC_OVERLAY +, COMBINE_BRIGHTNESS_TO_ALPHA +, COMBINE_DARKNESS_TO_ALPHA +, COMBINE_GREATER_THAN_5 +, COMBINE_GREATER_THAN_10 +, COMBINE_GREATER_THAN_15 +, COMBINE_GREATER_THAN_20 +, COMBINE_GREATER_THAN_25 +, COMBINE_GREATER_THAN_30 +, COMBINE_GREATER_THAN_35 +, COMBINE_GREATER_THAN_40 +, COMBINE_GREATER_THAN_45 +, COMBINE_GREATER_THAN_50 +, COMBINE_GREATER_THAN_55 +, COMBINE_GREATER_THAN_60 +, COMBINE_GREATER_THAN_65 +, COMBINE_GREATER_THAN_70 +, COMBINE_GREATER_THAN_75 +, COMBINE_GREATER_THAN_80 +, COMBINE_GREATER_THAN_85 +, COMBINE_GREATER_THAN_90 +, COMBINE_GREATER_THAN_95 +, COMBINE_GREATER_THAN_100 +, COMBINE_GREATER_THAN_105 +, COMBINE_GREATER_THAN_110 +, COMBINE_GREATER_THAN_115 +, COMBINE_GREATER_THAN_120 +, COMBINE_GREATER_THAN_125 +, COMBINE_GREATER_THAN_130 +, COMBINE_GREATER_THAN_135 +, COMBINE_GREATER_THAN_140 +, COMBINE_GREATER_THAN_145 +, COMBINE_GREATER_THAN_150 +, COMBINE_GREATER_THAN_155 +, COMBINE_GREATER_THAN_160 +, COMBINE_GREATER_THAN_165 +, COMBINE_GREATER_THAN_170 +, COMBINE_GREATER_THAN_175 +, COMBINE_GREATER_THAN_180 +, COMBINE_GREATER_THAN_185 +, COMBINE_GREATER_THAN_190 +, COMBINE_GREATER_THAN_195 +, COMBINE_GREATER_THAN_200 +, COMBINE_GREATER_THAN_205 +, COMBINE_GREATER_THAN_210 +, COMBINE_GREATER_THAN_215 +, COMBINE_GREATER_THAN_220 +, COMBINE_GREATER_THAN_225 +, COMBINE_GREATER_THAN_230 +, COMBINE_GREATER_THAN_235 +, COMBINE_GREATER_THAN_240 +, COMBINE_GREATER_THAN_245 +, COMBINE_GREATER_THAN_250 +, COMBINE_SMALLER_THAN_5 +, COMBINE_SMALLER_THAN_10 +, COMBINE_SMALLER_THAN_15 +, COMBINE_SMALLER_THAN_20 +, COMBINE_SMALLER_THAN_25 +, COMBINE_SMALLER_THAN_30 +, COMBINE_SMALLER_THAN_35 +, COMBINE_SMALLER_THAN_40 +, COMBINE_SMALLER_THAN_45 +, COMBINE_SMALLER_THAN_50 +, COMBINE_SMALLER_THAN_55 +, COMBINE_SMALLER_THAN_60 +, COMBINE_SMALLER_THAN_65 +, COMBINE_SMALLER_THAN_70 +, COMBINE_SMALLER_THAN_75 +, COMBINE_SMALLER_THAN_80 +, COMBINE_SMALLER_THAN_85 +, COMBINE_SMALLER_THAN_90 +, COMBINE_SMALLER_THAN_95 +, COMBINE_SMALLER_THAN_100 +, COMBINE_SMALLER_THAN_105 +, COMBINE_SMALLER_THAN_110 +, COMBINE_SMALLER_THAN_115 +, COMBINE_SMALLER_THAN_120 +, COMBINE_SMALLER_THAN_125 +, COMBINE_SMALLER_THAN_130 +, COMBINE_SMALLER_THAN_135 +, COMBINE_SMALLER_THAN_140 +, COMBINE_SMALLER_THAN_145 +, COMBINE_SMALLER_THAN_150 +, COMBINE_SMALLER_THAN_155 +, COMBINE_SMALLER_THAN_160 +, COMBINE_SMALLER_THAN_165 +, COMBINE_SMALLER_THAN_170 +, COMBINE_SMALLER_THAN_175 +, COMBINE_SMALLER_THAN_180 +, COMBINE_SMALLER_THAN_185 +, COMBINE_SMALLER_THAN_190 +, COMBINE_SMALLER_THAN_195 +, COMBINE_SMALLER_THAN_200 +, COMBINE_SMALLER_THAN_205 +, COMBINE_SMALLER_THAN_210 +, COMBINE_SMALLER_THAN_215 +, COMBINE_SMALLER_THAN_220 +, COMBINE_SMALLER_THAN_225 +, COMBINE_SMALLER_THAN_230 +, COMBINE_SMALLER_THAN_235 +, COMBINE_SMALLER_THAN_240 +, COMBINE_SMALLER_THAN_245 +, COMBINE_SMALLER_THAN_250 }; /// Combine image b onto image a using some combining function. From d9220022dd0e210333e41daba79aecdf68013409 Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Fri, 13 Sep 2024 05:03:01 +0200 Subject: [PATCH 04/19] exempt symbol-fonts from dependency checks --- src/util/io/package.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util/io/package.cpp b/src/util/io/package.cpp index 272cfa52..b2384737 100644 --- a/src/util/io/package.cpp +++ b/src/util/io/package.cpp @@ -644,6 +644,8 @@ void Packaged::requireDependency(Packaged* package) { } } } + // skip dependency checks for symbol-fonts + if (package->relativeFilename().find("mse-symbol-font") != std::string::npos) return; // dependency not found queue_message(MESSAGE_WARNING,_ERROR_4_("dependency not given", name(), package->relativeFilename(), package->relativeFilename(), package->version.toString())); } From 9b34ae5446a252a45eb52dbb4b655117e0ad1dea Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Mon, 16 Sep 2024 08:59:55 +0200 Subject: [PATCH 05/19] add get_card_styling function for export scripts --- doc/function/get_card_styling.txt | 17 +++++++++++++++++ doc/function/index.txt | 1 + src/script/functions/basic.cpp | 14 +++++++++++++- .../drupal/mse-drupal-modules/highlight.inc | 5 +++-- 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 doc/function/get_card_styling.txt diff --git a/doc/function/get_card_styling.txt b/doc/function/get_card_styling.txt new file mode 100644 index 00000000..f7f6e15e --- /dev/null +++ b/doc/function/get_card_styling.txt @@ -0,0 +1,17 @@ +Function: get_card_styling + +--Usage-- +> get_card_styling(card, set: set) + +Get the styling data of a [[type:card]]. + +This is for use in exporter scripts. In card scripts, use the "styling" predefined variable instead. + +--Parameters-- +! Parameter Type Description +| @input@ [[type:card]] The card you want to retrieve the styling data from. +| @set@ [[type:set]] The set the card belongs to. In an exporter script, this can be ommited since "set" is a predefined variable. + +--Examples-- +> # Retrieve the value "is foil" from the card's styling options +> card_is_foil := get_card_styling(card)["is_foil"] or else false diff --git a/doc/function/index.txt b/doc/function/index.txt index 700fdf7d..f0bfa889 100644 --- a/doc/function/index.txt +++ b/doc/function/index.txt @@ -97,6 +97,7 @@ These functions are built into the program, other [[type:function]]s can be defi ! Cards <<< | [[fun:new_card]] Construct a new [[type:card]] object. +| [[fun:get_card_styling]] Get the styling data of a [[type:card]]. ! HTML export <<< | [[fun:to_html]] Convert [[type:tagged text]] to html. diff --git a/src/script/functions/basic.cpp b/src/script/functions/basic.cpp index 751b77de..ca00b002 100644 --- a/src/script/functions/basic.cpp +++ b/src/script/functions/basic.cpp @@ -662,6 +662,17 @@ SCRIPT_FUNCTION(random_select_many) { return ret; } +SCRIPT_FUNCTION(get_card_styling) { + SCRIPT_PARAM_C(ScriptValueP, input); + SCRIPT_PARAM_C(ScriptValueP, set); + ScriptObject* c = dynamic_cast*>(input.get()); + ScriptObject* s = dynamic_cast*>(set.get()); + if (s && c) { + return to_script(&s->getValue()->stylingDataFor(c->getValue())); + } + throw ScriptError(_("invalid set or card argument")); +} + // ----------------------------------------------------------------------------- : Keywords @@ -747,7 +758,8 @@ void init_script_basic_functions(Context& ctx) { ctx.setVariable(_("to_color"), script_to_color); ctx.setVariable(_("to_date"), script_to_date); ctx.setVariable(_("to_code"), script_to_code); - ctx.setVariable(_("type_name"), script_type_name); + ctx.setVariable(_("type_name"), script_type_name); + ctx.setVariable(_("get_card_styling"), script_get_card_styling); // math ctx.setVariable(_("abs"), script_abs); ctx.setVariable(_("random_real"), script_random_real); diff --git a/tools/website/drupal/mse-drupal-modules/highlight.inc b/tools/website/drupal/mse-drupal-modules/highlight.inc index c34c41c4..afe0b0d7 100644 --- a/tools/website/drupal/mse-drupal-modules/highlight.inc +++ b/tools/website/drupal/mse-drupal-modules/highlight.inc @@ -48,7 +48,8 @@ $built_in_functions = array( 'filter_list' =>'', 'random_shuffle' =>'', 'random_select' =>'', - 'random_select_many' =>'', + 'random_select_many' =>'', + 'get_card_styling' =>'', // keywords 'expand_keywords' =>'', 'expand_keywords_rule'=>'expand_keywords', 'keyword_usage' =>'', @@ -232,4 +233,4 @@ function highlight_script_string($code) { return $code; } -?> \ No newline at end of file +?> From eedcd611523431a919c10533a6cf4959a338f50a Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Mon, 16 Sep 2024 09:02:16 +0200 Subject: [PATCH 06/19] fix typeline print bug --- src/render/value/choice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/render/value/choice.cpp b/src/render/value/choice.cpp index 998d3229..2af4bf9b 100644 --- a/src/render/value/choice.cpp +++ b/src/render/value/choice.cpp @@ -50,8 +50,8 @@ bool prepare_choice_viewer(RotatedDC& dc, ValueViewer& viewer, ChoiceStyle& styl img.generateCached(img_options, &style.mask, &combine, &bitmap, &image, &size); // store content properties if (style.content_width != size.width || style.content_height != size.height) { - style.content_width = size.width; - style.content_height = size.height; + style.content_width = size.width / dc.getZoom(); + style.content_height = size.height / dc.getZoom(); return true; } } From 4054443a7268bba90e5063ef5ebfebbc087e5c39 Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Tue, 17 Sep 2024 06:13:01 +0200 Subject: [PATCH 07/19] add exists_in_package script function --- doc/function/exists_in_package.txt | 13 +++++++++ src/script/functions/basic.cpp | 10 ++++++- src/util/io/package.cpp | 29 +++++++++++++++++++ src/util/io/package.hpp | 8 ++++- src/util/io/package_manager.cpp | 14 +++++++++ src/util/io/package_manager.hpp | 7 +++-- .../drupal/mse-drupal-modules/highlight.inc | 3 +- 7 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 doc/function/exists_in_package.txt diff --git a/doc/function/exists_in_package.txt b/doc/function/exists_in_package.txt new file mode 100644 index 00000000..20f8d096 --- /dev/null +++ b/doc/function/exists_in_package.txt @@ -0,0 +1,13 @@ +Function: exists_in_package + +--Usage-- +> exists_in_package("/package/filename") + +Check if a file exists in a given package. + +--Parameters-- +! Parameter Type Description +| @input@ [[type:string]] Path of the file, starting from the data directory. + +--Examples-- +> exists_in_package("/magic-modules.mse-include/watermarks/custom_user_watermark.png") == true diff --git a/src/script/functions/basic.cpp b/src/script/functions/basic.cpp index 751b77de..d59beea4 100644 --- a/src/script/functions/basic.cpp +++ b/src/script/functions/basic.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -62,7 +63,13 @@ SCRIPT_FUNCTION(error) { queue_message(MESSAGE_ERROR, input); } return script_nil; -} +} + +SCRIPT_FUNCTION(exists_in_package) { + SCRIPT_PARAM_C(String, input); + bool result = package_manager.existsInPackage(input); + SCRIPT_RETURN(result); +} // ----------------------------------------------------------------------------- : Conversion @@ -738,6 +745,7 @@ void init_script_basic_functions(Context& ctx) { ctx.setVariable(_("trace"), script_trace); ctx.setVariable(_("warning"), script_warning); ctx.setVariable(_("error"), script_error); + ctx.setVariable(_("exists_in_package"), script_exists_in_package); // conversion ctx.setVariable(_("to_string"), script_to_string); ctx.setVariable(_("to_int"), script_to_int); diff --git a/src/util/io/package.cpp b/src/util/io/package.cpp index 272cfa52..895fa60a 100644 --- a/src/util/io/package.cpp +++ b/src/util/io/package.cpp @@ -186,6 +186,35 @@ public: // ----------------------------------------------------------------------------- : Package : inside +bool Package::existsIn(const String& file) { + FileInfos::iterator it = files.find(normalize_internal_filename(file)); + if (it == files.end()) { + // does it look like a relative filename? + if (filename.find(_(".mse-")) != String::npos) { + return false; + } + } + + unique_ptr stream; + if (it != files.end() && it->second.wasWritten()) { + // written to this file, open the temp file + stream = make_unique(it->second.tempName); + } + else if (wxFileExists(filename + _("/") + file)) { + // a file in directory package + stream = make_unique(filename + _("/") + file); + } + else if (wxFileExists(filename) && it != files.end() && it->second.zipEntry) { + // a file in a zip archive + stream = make_unique(filename, it->second.zipEntry); + } + else { + // shouldn't happen, packaged changed by someone else since opening it + return false; + } + return stream && stream->IsOk(); +} + unique_ptr Package::openIn(const String& file) { if (!file.empty() && file.GetChar(0) == _('/')) { // absolute path, open file from another package diff --git a/src/util/io/package.hpp b/src/util/io/package.hpp index 6d15df9c..eee03149 100644 --- a/src/util/io/package.hpp +++ b/src/util/io/package.hpp @@ -132,10 +132,16 @@ public: // --------------------------------------------------- : Managing the inside of the package + /// Check if a file is in the package. + bool existsIn(const String& file); + inline bool existsIn(const LocalFileName& file) { + return existsIn(file.fn); + } + /// Open an input stream for a file in the package. unique_ptr openIn(const String& file); inline unique_ptr openIn(const LocalFileName& file) { - return openIn(file.fn); + return openIn(file.fn); } /// Open an output stream for a file in the package. diff --git a/src/util/io/package_manager.cpp b/src/util/io/package_manager.cpp index 2f368ad0..9eeca4f2 100644 --- a/src/util/io/package_manager.cpp +++ b/src/util/io/package_manager.cpp @@ -95,6 +95,20 @@ void PackageManager::findMatching(const String& pattern, vector& out) } } +bool PackageManager::existsInPackage(const String& name) { + if (!name.empty() && name.GetChar(0) == _('/')) { + // break name + size_t start = name.find_first_not_of(_("/\\"), 1); // allow "//package/name" from incorrect scripts + size_t pos = name.find_first_of(_("/\\"), start); + if (start < pos && pos != String::npos) { + // open package + PackagedP p = openAny(name.substr(start, pos - start)); + return p->existsIn(name.substr(pos + 1)); + } + } + throw FileNotFoundError(name, _("No package name specified, use '/package/filename'")); +} + pair,Packaged*> PackageManager::openFileFromPackage(Packaged* package, const String& name) { if (!name.empty() && name.GetChar(0) == _('/')) { // absolute name; break name diff --git a/src/util/io/package_manager.hpp b/src/util/io/package_manager.hpp index 4178d310..7e6037c4 100644 --- a/src/util/io/package_manager.hpp +++ b/src/util/io/package_manager.hpp @@ -139,7 +139,10 @@ public: /// Find all packages that match a filename pattern, store them in out /** Only reads the package headers */ void findMatching(const String& pattern, vector& out); - + + /// Check if a file exists in a package + bool existsInPackage(const String& name); + /// Open a file from a package, with a name encoded as "/package/file" /** If 'package' is set then: * - tries to open a relative file from the package if the name is "file" @@ -148,7 +151,7 @@ public: * Returns the opened file and the package it is in */ pair,Packaged*> openFileFromPackage(Packaged* package, const String& name); - + /// Get a filename to open from a package /** WARNING: this is a bit of a hack, since not all package types support names in this way. * It is needed for third party libraries (i.e. hunspell) that load stuff from files. diff --git a/tools/website/drupal/mse-drupal-modules/highlight.inc b/tools/website/drupal/mse-drupal-modules/highlight.inc index c34c41c4..dca657e8 100644 --- a/tools/website/drupal/mse-drupal-modules/highlight.inc +++ b/tools/website/drupal/mse-drupal-modules/highlight.inc @@ -101,6 +101,7 @@ $built_in_functions = array( // other 'trace' =>'', 'assert' =>'', + 'exists_in_package' =>'', ); @@ -232,4 +233,4 @@ function highlight_script_string($code) { return $code; } -?> \ No newline at end of file +?> From 28dd64ddebfb356ce63cdab813f43ca08a914afd Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Tue, 17 Sep 2024 06:30:17 +0200 Subject: [PATCH 08/19] Update index.txt --- doc/function/index.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/function/index.txt b/doc/function/index.txt index 700fdf7d..4d6dbc8f 100644 --- a/doc/function/index.txt +++ b/doc/function/index.txt @@ -112,3 +112,4 @@ These functions are built into the program, other [[type:function]]s can be defi | [[fun:assert]] Check a condition for debugging purposes. | [[fun:warning]] Output a warning message. | [[fun:error]] Output an error message. +| [[fun:exists_in_package]] Checks if a file exists in a package. From c956901a375167a1bb8b9167916a98b9a1a0a7b8 Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:01:21 +0200 Subject: [PATCH 09/19] make combine_blend function blend alpha channels as well --- src/gfx/combine_image.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gfx/combine_image.cpp b/src/gfx/combine_image.cpp index 65edcd49..a1e2ff96 100644 --- a/src/gfx/combine_image.cpp +++ b/src/gfx/combine_image.cpp @@ -91,11 +91,17 @@ COMBINE_FUN(COMBINE_SYMMETRIC_OVERLAY, (Combine::f(a,b) + Combi /// The results are stored in the image A. template void combine_image_do(Image& a, Image b) { - UInt size = a.GetWidth() * a.GetHeight() * 3; + UInt size = a.GetWidth() * a.GetHeight(); Byte *dataA = a.GetData(), *dataB = b.GetData(); // for each pixel: apply function - for (UInt i = 0 ; i < size ; ++i) { + for (UInt i = 0 ; i < (size * 3); ++i) { dataA[i] = Combine::f(dataA[i], dataB[i]); + } + if (a.HasAlpha() && b.HasAlpha()) { + Byte* alphaA = a.GetAlpha(), * alphaB = b.GetAlpha(); + for (UInt i = 0; i < size; ++i) { + alphaA[i] = Combine::f(alphaA[i], alphaB[i]); + } } } From 488e54fed2bc5a04b177a6d69435da0be3273124 Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:22:54 +0200 Subject: [PATCH 10/19] Update combine_image.cpp --- src/gfx/combine_image.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/gfx/combine_image.cpp b/src/gfx/combine_image.cpp index a1e2ff96..5aa9376e 100644 --- a/src/gfx/combine_image.cpp +++ b/src/gfx/combine_image.cpp @@ -107,12 +107,8 @@ void combine_image_do(Image& a, Image b) { void combine_image(Image& a, const Image& b, ImageCombine combine) { // Images must have same size - assert(a.GetWidth() == b.GetWidth()); - assert(a.GetHeight() == b.GetHeight()); - // Copy alpha channel? - if (b.HasAlpha()) { - if (!a.HasAlpha()) a.InitAlpha(); - memcpy(a.GetAlpha(), b.GetAlpha(), a.GetWidth() * a.GetHeight()); + if (a.GetWidth() != b.GetWidth() || a.GetHeight() != b.GetHeight()) { + throw Error(_ERROR_("images used for combine blending must have the same size")); } // Combine image data, by dispatching to combineImageDo switch(combine) { From 258679b3c357bea3728c21bfafd10cf8c7b95af2 Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Wed, 18 Sep 2024 09:16:57 +0200 Subject: [PATCH 11/19] fix width_of invocation in console not working --- src/script/functions/image.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/script/functions/image.cpp b/src/script/functions/image.cpp index 55ab22b1..23951556 100644 --- a/src/script/functions/image.cpp +++ b/src/script/functions/image.cpp @@ -47,14 +47,16 @@ SCRIPT_FUNCTION(to_card_image) { // ----------------------------------------------------------------------------- : Image functions SCRIPT_FUNCTION(width_of) { + SCRIPT_PARAM(Set*, set); SCRIPT_PARAM(GeneratedImageP, input); - Image image = input->generate(GeneratedImage::Options()); + Image image = input->generate(GeneratedImage::Options(0, 0, set->stylesheet.get())); SCRIPT_RETURN(image.GetWidth()); } SCRIPT_FUNCTION(height_of) { + SCRIPT_PARAM(Set*, set); SCRIPT_PARAM(GeneratedImageP, input); - Image image = input->generate(GeneratedImage::Options()); + Image image = input->generate(GeneratedImage::Options(0, 0, set->stylesheet.get())); SCRIPT_RETURN(image.GetHeight()); } From 59a184e2b20b22e6426c3a0fb28bd27fba56794b Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Sun, 22 Sep 2024 16:51:23 +0200 Subject: [PATCH 12/19] revert combine_blend changes --- src/gfx/combine_image.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/gfx/combine_image.cpp b/src/gfx/combine_image.cpp index 2c5630c6..d8df1bc4 100644 --- a/src/gfx/combine_image.cpp +++ b/src/gfx/combine_image.cpp @@ -295,24 +295,23 @@ COMBINE_FUN(COMBINE_SMALLER_THAN_250, a < 250 ? b : a) /// The results are stored in the image A. template void combine_image_do(Image& a, Image b) { - UInt size = a.GetWidth() * a.GetHeight(); - Byte *dataA = a.GetData(), *dataB = b.GetData(); + UInt size = a.GetWidth() * a.GetHeight() * 3; + Byte* dataA = a.GetData(), * dataB = b.GetData(); // for each pixel: apply function - for (UInt i = 0 ; i < (size * 3); ++i) { + for (UInt i = 0; i < size; ++i) { dataA[i] = Combine::f(dataA[i], dataB[i]); - } - if (a.HasAlpha() && b.HasAlpha()) { - Byte* alphaA = a.GetAlpha(), * alphaB = b.GetAlpha(); - for (UInt i = 0; i < size; ++i) { - alphaA[i] = Combine::f(alphaA[i], alphaB[i]); - } } } void combine_image(Image& a, const Image& b, ImageCombine combine) { // Images must have same size if (a.GetWidth() != b.GetWidth() || a.GetHeight() != b.GetHeight()) { - throw Error(_ERROR_("images used for combine blending must have the same size")); + throw Error(_ERROR_("images used for combine blending must have the same size")); + } + // Copy alpha channel? + if (b.HasAlpha()) { + if (!a.HasAlpha()) a.InitAlpha(); + memcpy(a.GetAlpha(), b.GetAlpha(), a.GetWidth() * a.GetHeight()); } // Combine image data, by dispatching to combineImageDo switch(combine) { From 9ffe2f06a189532519b122c7d8fb53a08d002be9 Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Thu, 26 Sep 2024 14:56:52 +0200 Subject: [PATCH 13/19] Update preferences_window.cpp --- src/gui/preferences_window.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/preferences_window.cpp b/src/gui/preferences_window.cpp index bdaafdb7..ea2dc210 100644 --- a/src/gui/preferences_window.cpp +++ b/src/gui/preferences_window.cpp @@ -227,14 +227,14 @@ DisplayPreferencesPage::DisplayPreferencesPage(Window* parent) non_normal_export->SetValue(!settings.default_stylesheet_settings.card_normal_export()); zoom_int = static_cast(settings.default_stylesheet_settings.card_zoom() * 100); zoom->SetValue(String::Format(_("%d%%"),zoom_int)); - int choices[] = { 50,66,75,100,120,150,200 }; + int choices[] = { 50,66,75,100,120,150,175,200 }; for (unsigned int i = 0 ; i < sizeof(choices)/sizeof(choices[0]) ; ++i) { zoom->Append(String::Format(_("%d%%"),choices[i])); } export_zoom_int = static_cast(settings.default_stylesheet_settings.export_zoom() * 100); export_zoom->SetValue(String::Format(_("%d%%"), export_zoom_int)); - int export_choices[] = { 50,66,75,100,120,150,200 }; + int export_choices[] = { 50,66,75,100,120,150,175,200 }; for (unsigned int i = 0; i < sizeof(export_choices) / sizeof(export_choices[0]); ++i) { export_zoom->Append(String::Format(_("%d%%"), export_choices[i])); } From 6d9e536df6f79b954ac852272e5fb60803a00f75 Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Fri, 27 Sep 2024 14:00:30 +0200 Subject: [PATCH 14/19] only draw text if field is editable --- src/render/value/image.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/render/value/image.cpp b/src/render/value/image.cpp index c6262b8c..eabee827 100644 --- a/src/render/value/image.cpp +++ b/src/render/value/image.cpp @@ -43,7 +43,7 @@ void ImageValueViewer::draw(RotatedDC& dc) { image = style().default_image.generate(GeneratedImage::Options(w, h, &getStylePackage(), &getLocalPackage())); is_default = true; if (what & DRAW_EDITING) { - bitmap = imagePlaceholder(dc, w, h, image, what & DRAW_EDITING); + bitmap = imagePlaceholder(dc, w, h, image, (what & DRAW_EDITING) && field().editable); if (alpha_mask.isLoaded() || !is_rad0(a)) { image = bitmap.ConvertToImage(); // we need to convert back to an image } else { @@ -54,7 +54,7 @@ void ImageValueViewer::draw(RotatedDC& dc) { // checkerboard placeholder if (!image.Ok() && !bitmap.Ok() && style().width > 40) { // placeholder bitmap - bitmap = imagePlaceholder(dc, w, h, wxNullImage, what & DRAW_EDITING); + bitmap = imagePlaceholder(dc, w, h, wxNullImage, (what & DRAW_EDITING) && field().editable); if (alpha_mask.isLoaded() || !is_rad0(a)) { // we need to convert back to an image image = bitmap.ConvertToImage(); From 2387173350a6dd5a18fb45eaa161dae54c3b231b Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Fri, 27 Sep 2024 16:22:51 +0200 Subject: [PATCH 15/19] Add hack to fetch caption if value is empty --- src/render/value/information.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/render/value/information.cpp b/src/render/value/information.cpp index ca4f3e03..f3b01ad5 100644 --- a/src/render/value/information.cpp +++ b/src/render/value/information.cpp @@ -34,7 +34,16 @@ void InfoValueViewer::draw(RotatedDC& dc) { style().padding_top, -style().padding_left - style().padding_right, -style().padding_top - style().padding_bottom - ); - RealSize size = dc.GetTextExtent(value().value); - dc.DrawText(value().value, align_in_rect(style().alignment, size, rect)); + ); + // for some reason, while inside the style tab, this value is empty + // so as a hack for now, if the value is empty, go fetch the caption instead + if (value().value.empty()) { + RealSize size = dc.GetTextExtent(field().caption.get()); + dc.DrawText(field().caption.get(), align_in_rect(style().alignment, size, rect)); + } + // this is what should happen + else { + RealSize size = dc.GetTextExtent(value().value); + dc.DrawText(value().value, align_in_rect(style().alignment, size, rect)); + } } From 67a38e0fdc01abe2501a912bec90b62c745cc91a Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Fri, 27 Sep 2024 20:25:26 +0200 Subject: [PATCH 16/19] remove checkerboard placeholder --- src/render/value/image.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/render/value/image.cpp b/src/render/value/image.cpp index eabee827..a5e2759f 100644 --- a/src/render/value/image.cpp +++ b/src/render/value/image.cpp @@ -42,8 +42,8 @@ void ImageValueViewer::draw(RotatedDC& dc) { if (!image.Ok() && style().default_image.isReady()) { image = style().default_image.generate(GeneratedImage::Options(w, h, &getStylePackage(), &getLocalPackage())); is_default = true; - if (what & DRAW_EDITING) { - bitmap = imagePlaceholder(dc, w, h, image, (what & DRAW_EDITING) && field().editable); + if ((what & DRAW_EDITING) && field().editable) { + bitmap = imagePlaceholder(dc, w, h, image, true); if (alpha_mask.isLoaded() || !is_rad0(a)) { image = bitmap.ConvertToImage(); // we need to convert back to an image } else { From 4878b1c8d4234bbf1865f96f416cf6bf7c85ef8c Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Sat, 28 Sep 2024 01:20:13 +0200 Subject: [PATCH 17/19] Update item_list.cpp --- src/gui/control/item_list.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/control/item_list.cpp b/src/gui/control/item_list.cpp index 83dc0437..e3521003 100644 --- a/src/gui/control/item_list.cpp +++ b/src/gui/control/item_list.cpp @@ -180,10 +180,10 @@ void ItemList::refreshList(bool refresh_current_only) { // refresh // Note: Freeze/Thaw makes flicker worse long item_count = (long)sorted_list.size(); + SetItemCount(item_count); if (item_count == 0) { Refresh(); } else { - SetItemCount(item_count); // (re)select current item findSelectedItemPos(); focusNone(); From f3cfbd05941ef00d8e32fe1890484f302d156a67 Mon Sep 17 00:00:00 2001 From: cajun <12363371+CajunAvenger@users.noreply.github.com> Date: Sun, 29 Sep 2024 15:46:52 -0500 Subject: [PATCH 18/19] Update parser.cpp --- src/script/parser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/script/parser.cpp b/src/script/parser.cpp index ea9a8e14..b47410c3 100644 --- a/src/script/parser.cpp +++ b/src/script/parser.cpp @@ -122,7 +122,7 @@ bool isOper (wxUniChar c) { return wxStrchr(_("+-*/!.@%^&:=<>;,"),c) != nullptr bool isLparen(wxUniChar c) { return c==_('(') || c==_('[') || c==_('{'); } bool isRparen(wxUniChar c) { return c==_(')') || c==_(']') || c==_('}'); } bool isDigitOrDot(wxUniChar c) { return isDigit(c) || c==_('.'); } -bool isLongOper(StringView s) { return s==_(":=") || s==_("==") || s==_("!=") || s==_("<=") || s==_(">="); } +bool isLongOper(StringView s) { return s==_(":=") || s==_("==") || s==_("!=") || s==_("<=") || s==_(">=") || s==_("->"); } // moveme // ----------------------------------------------------------------------------- : Tokenizing @@ -351,7 +351,7 @@ enum Precedence { PREC_ALL , PREC_NEWLINE // newline ; , PREC_SEQ // ; -, PREC_SET // := +, PREC_SET // := -> , PREC_AND // and or , PREC_CMP // == != < > <= >= , PREC_ADD // + - @@ -736,7 +736,7 @@ ExprType parseOper(TokenIterator& input, Script& script, Precedence minPrec, Ins } script.addInstruction(I_POP); // discard result of first expression type = parseOper(input, script, PREC_SET); - } else if (minPrec <= PREC_SET && token==_(":=")) { + } else if (minPrec <= PREC_SET && (token==_(":=") || token==_("->"))) { // We made a mistake, the part before the := should be a variable name, // not an expression. Remove that instruction. Instruction& instr = script.getInstructions().back(); From 8ab0246a34d57d41ac769e57169f24f8cc5fcd85 Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:05:38 +0200 Subject: [PATCH 19/19] Update README.md --- README.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/README.md b/README.md index 9202fde7..1a670e02 100644 --- a/README.md +++ b/README.md @@ -4,15 +4,6 @@ Magic Set Editor, or MSE for short, is a program with which you can design your More information on https://magicseteditor.boards.net/ -======= -## Main Features in the Unofficial Branch - * Fixes the "All Image" art selector list to include .jpeg images. - * Allows for the option to remove aliasing on selected art by increasing the size of the stored images in the set file. - * Adds a text filter on the style tab for Stylesheet. - * Decouples the zoom and export scales. - -======= - ## Dependencies The code depends on