From d113e30423c2aa248a103483222ff1a02101e308 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, 4 Jan 2026 17:31:23 +0100 Subject: [PATCH] add allow_image_download setting --- src/data/settings.cpp | 4 ++-- src/data/settings.hpp | 2 +- src/gui/control/card_list.cpp | 4 ++-- src/gui/preferences_window.cpp | 10 +++++----- src/gui/value/image.cpp | 2 +- src/script/functions/construction.cpp | 12 ++++++------ src/script/functions/construction_helper.hpp | 2 +- src/script/functions/image.cpp | 3 ++- 8 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/data/settings.cpp b/src/data/settings.cpp index 0a94babc..977eba9a 100644 --- a/src/data/settings.cpp +++ b/src/data/settings.cpp @@ -201,7 +201,7 @@ Settings::Settings() , print_cutter_lines (CUTTER_ALL) , dark_mode_type (DARKMODE_SYSTEM) , import_scale_selection (0) - , internal_image_extension (true) + , allow_image_download (true) #if USE_OLD_STYLE_UPDATE_CHECKER , updates_url (_("https://magicseteditor.boards.net/page/downloads")) #endif @@ -340,7 +340,7 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) { REFLECT(dark_mode_type); REFLECT(apprentice_location); REFLECT(import_scale_selection); - REFLECT(internal_image_extension); + REFLECT(allow_image_download); #if USE_OLD_STYLE_UPDATE_CHECKER REFLECT(updates_url); #else diff --git a/src/data/settings.hpp b/src/data/settings.hpp index 024645bb..9be412f3 100644 --- a/src/data/settings.hpp +++ b/src/data/settings.hpp @@ -229,7 +229,7 @@ public: // --------------------------------------------------- : Internal settings int import_scale_selection; - bool internal_image_extension; + bool allow_image_download; // --------------------------------------------------- : Update checking diff --git a/src/gui/control/card_list.cpp b/src/gui/control/card_list.cpp index f2af7d8d..1deb4d9f 100644 --- a/src/gui/control/card_list.cpp +++ b/src/gui/control/card_list.cpp @@ -310,7 +310,7 @@ bool CardListBase::parseImage(Image& image, vector& out) { if (rect.width > 0 && rect.height > 0) { Image img = image.GetSubImage(rect); img = rotate_image(img, deg_to_rad(360-degrees)); - LocalFileName filename = set->newFileName("cropped_image", settings.internal_image_extension ? _(".png") : _("")); // a new unique name in the package + LocalFileName filename = set->newFileName("cropped_image", _(".png")); // a new unique name in the package img.SaveFile(set->nameOut(filename), wxBITMAP_TYPE_PNG); value->filename = filename; } @@ -349,7 +349,7 @@ bool CardListBase::parseText(String& text, vector& out) { if (value) { Image img = value->filename.getExternalImage(); if (img.IsOk()) { - LocalFileName filename = set->newFileName(_("decoded_image"), settings.internal_image_extension ? _(".png") : _("")); // a new unique name in the package + LocalFileName filename = set->newFileName(_("decoded_image"), _(".png")); // a new unique name in the package img.SaveFile(set->nameOut(filename), wxBITMAP_TYPE_PNG); value->filename = filename; } diff --git a/src/gui/preferences_window.cpp b/src/gui/preferences_window.cpp index f427582b..07ab7384 100644 --- a/src/gui/preferences_window.cpp +++ b/src/gui/preferences_window.cpp @@ -68,7 +68,7 @@ public: void store() override; private: - wxCheckBox* non_normal_export, *bleed_export, *notes_export, *internal_image_extension; + wxCheckBox* non_normal_export, *bleed_export, *notes_export, *allow_image_download; wxChoice* export_scale, *import_scale; }; @@ -287,7 +287,7 @@ TransfersPreferencesPage::TransfersPreferencesPage(Window* parent) : Preferences notes_export = new wxCheckBox(this, wxID_ANY, _BUTTON_("notes export")); export_scale = new wxChoice (this, ID_EXPORT_ZOOM); - internal_image_extension = new wxCheckBox(this, wxID_ANY, _BUTTON_("internal image extension")); + allow_image_download = new wxCheckBox(this, wxID_ANY, _BUTTON_("allow image download")); import_scale = new wxChoice (this, ID_IMPORT_ZOOM); // set values @@ -304,7 +304,7 @@ TransfersPreferencesPage::TransfersPreferencesPage(Window* parent) : Preferences if (default_export_scale < 0 || default_export_scale > (int)export_scale->GetCount() - 1) default_export_scale = 0; export_scale->SetSelection(default_export_scale); - internal_image_extension->SetValue(settings.internal_image_extension); + allow_image_download->SetValue(settings.allow_image_download); import_scale->Append(_LABEL_("use export scale")); import_scale->Append(_LABEL_("export around 300")); import_scale->Append(_LABEL_("export force 300")); @@ -336,7 +336,7 @@ TransfersPreferencesPage::TransfersPreferencesPage(Window* parent) : Preferences s6->Add(import_scale); s5->Add(s6, 0, wxEXPAND | wxALL & ~wxBottom, 4); s5->Add(new wxStaticText(this, wxID_ANY, _LABEL_("internal scale desc")), 0, wxALL & ~wxTOP, 4); - s5->Add(internal_image_extension, 0, wxEXPAND | wxALL, 4); + s5->Add(allow_image_download, 0, wxEXPAND | wxALL, 4); s->Add(s2, 0, wxEXPAND | wxALL, 8); s->Add(s5, 0, wxEXPAND | wxALL, 8); export_scale->SetFocus(); @@ -350,7 +350,7 @@ void TransfersPreferencesPage::store() { settings.default_stylesheet_settings.card_notes_export = notes_export->GetValue(); settings.default_stylesheet_settings.export_scale_selection = export_scale->GetSelection(); - settings.internal_image_extension = internal_image_extension->GetValue(); + settings.allow_image_download = allow_image_download->GetValue(); settings.import_scale_selection = import_scale->GetSelection(); } diff --git a/src/gui/value/image.cpp b/src/gui/value/image.cpp index 8290f0e0..bd4dd08d 100644 --- a/src/gui/value/image.cpp +++ b/src/gui/value/image.cpp @@ -66,7 +66,7 @@ void ImageValueEditor::sliceImage(const Image& image, const String& filename, co // clicked ok? if (s.ShowModal() == wxID_OK) { // store the image into the set - LocalFileName new_image_file = getLocalPackage().newFileName(field().name, settings.internal_image_extension ? _(".png") : _("")); // a new unique name in the package + LocalFileName new_image_file = getLocalPackage().newFileName(field().name, _(".png")); // a new unique name in the package Image img = s.getImage(); img.SaveFile(getLocalPackage().nameOut(new_image_file), wxBITMAP_TYPE_PNG); // always use PNG images, see #69. Disk space is cheap anyway. addAction(value_action(valueP(), new_image_file)); diff --git a/src/script/functions/construction.cpp b/src/script/functions/construction.cpp index 21589409..9ffccd48 100644 --- a/src/script/functions/construction.cpp +++ b/src/script/functions/construction.cpp @@ -35,7 +35,7 @@ SCRIPT_FUNCTION(new_card) { ScriptValueP key; while (ScriptValueP value = it->next(&key)) { assert(key); - if (key == script_nil) continue; + if (key == script_nil || value == script_nil) continue; String key_name = key->toString(); if (set_stylesheet_container(*game, new_card, value, key_name, ignore_field_not_found)) break; } @@ -43,7 +43,7 @@ SCRIPT_FUNCTION(new_card) { it = input->makeIterator(); while (ScriptValueP value = it->next(&key)) { assert(key); - if (key == script_nil) continue; + if (key == script_nil || value == script_nil) continue; String key_name = key->toString(); // check if the given value is for a built-in field if (set_builtin_container(*game, new_card, value, key_name, ignore_field_not_found)) continue; @@ -66,7 +66,7 @@ SCRIPT_FUNCTION(new_card) { ScriptValueP script_key; while (ScriptValueP script_value = script_it->next(&script_key)) { assert(script_key); - if (script_key == script_nil) continue; + if (script_key == script_nil || script_value == script_nil) continue; String script_key_name = script_key->toString(); if (set_stylesheet_container(*game, new_card, script_value, script_key_name, ignore_field_not_found)) break; } @@ -74,7 +74,7 @@ SCRIPT_FUNCTION(new_card) { script_it = script_input->makeIterator(); while (ScriptValueP script_value = script_it->next(&script_key)) { assert(script_key); - if (script_key == script_nil) continue; + if (script_key == script_nil || script_value == script_nil) continue; String script_key_name = script_key->toString(); // check if the script value is for a built-in field if (set_builtin_container(*game, new_card, script_value, script_key_name, ignore_field_not_found)) continue; @@ -109,7 +109,7 @@ SCRIPT_FUNCTION(new_card) { ScriptValueP script_key; while (ScriptValueP script_value = script_it->next(&script_key)) { assert(script_key); - if (script_key == script_nil) continue; + if (script_key == script_nil || script_value == script_nil) continue; String script_key_name = script_key->toString(); if (set_stylesheet_container(*game, new_card, script_value, script_key_name, ignore_field_not_found)) break; } @@ -117,7 +117,7 @@ SCRIPT_FUNCTION(new_card) { script_it = script_input->makeIterator(); while (ScriptValueP script_value = script_it->next(&script_key)) { assert(script_key); - if (script_key == script_nil) continue; + if (script_key == script_nil || script_value == script_nil) continue; String script_key_name = script_key->toString(); // check if the script value is for a built-in field if (set_builtin_container(*game, new_card, script_value, script_key_name, ignore_field_not_found)) continue; diff --git a/src/script/functions/construction_helper.hpp b/src/script/functions/construction_helper.hpp index 455ba2bf..9df34f87 100644 --- a/src/script/functions/construction_helper.hpp +++ b/src/script/functions/construction_helper.hpp @@ -160,7 +160,7 @@ inline static bool set_builtin_container(const Game& game, CardP& card, ScriptVa ScriptValueP key; while (ScriptValueP value = it->next(&key)) { assert(key); - if (key == script_nil) continue; + if (key == script_nil || value == script_nil) continue; String key_name = key->toString(); Value* container = get_container(data, type, key_name, ignore_field_not_found); set_container(container, value, key_name); diff --git a/src/script/functions/image.cpp b/src/script/functions/image.cpp index bf4f1aa8..a74963bd 100644 --- a/src/script/functions/image.cpp +++ b/src/script/functions/image.cpp @@ -56,7 +56,8 @@ SCRIPT_FUNCTION(import_image) { return make_intrusive(set, input); } -SCRIPT_FUNCTION(download_image) { +SCRIPT_FUNCTION(download_image) { + if (!settings.allow_image_download) return script_nil; SCRIPT_PARAM(Set*, set); SCRIPT_PARAM(String, input); return make_intrusive(set, input);