add allow_image_download setting

This commit is contained in:
GenevensiS
2026-01-04 17:31:23 +01:00
parent 099c5ae738
commit d113e30423
8 changed files with 20 additions and 19 deletions
+2 -2
View File
@@ -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
+1 -1
View File
@@ -229,7 +229,7 @@ public:
// --------------------------------------------------- : Internal settings
int import_scale_selection;
bool internal_image_extension;
bool allow_image_download;
// --------------------------------------------------- : Update checking
+2 -2
View File
@@ -310,7 +310,7 @@ bool CardListBase::parseImage(Image& image, vector<CardP>& 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<CardP>& 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;
}
+5 -5
View File
@@ -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();
}
+1 -1
View File
@@ -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));
+6 -6
View File
@@ -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;
+1 -1
View File
@@ -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);
+2 -1
View File
@@ -56,7 +56,8 @@ SCRIPT_FUNCTION(import_image) {
return make_intrusive<ImportedImage>(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<DownloadedImage>(set, input);