misc: throw internal image extension behind a preference setting

This commit is contained in:
Brendan Hagan
2022-07-04 01:57:32 -04:00
parent 386e5ba4a4
commit 95fdaa776c
5 changed files with 24 additions and 12 deletions
+1
View File
@@ -620,6 +620,7 @@ button:
always: Always always: Always
if internet connection exists: If internet connection exists if internet connection exists: If internet connection exists
never: Never never: Never
internal image extension: Store images internally with extension
# Column select # Column select
move up: Move &Up move up: Move &Up
+2
View File
@@ -173,6 +173,7 @@ Settings::Settings()
, symbol_grid_snap (false) , symbol_grid_snap (false)
, print_layout (LAYOUT_NO_SPACE) , print_layout (LAYOUT_NO_SPACE)
, internal_scale (1.0) , internal_scale (1.0)
, internal_image_extension(true)
#if USE_OLD_STYLE_UPDATE_CHECKER #if USE_OLD_STYLE_UPDATE_CHECKER
, updates_url (_("http://magicseteditor.sourceforge.net/updates")) , updates_url (_("http://magicseteditor.sourceforge.net/updates"))
#endif #endif
@@ -260,6 +261,7 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) {
REFLECT(print_layout); REFLECT(print_layout);
REFLECT(apprentice_location); REFLECT(apprentice_location);
REFLECT(internal_scale); REFLECT(internal_scale);
REFLECT(internal_image_extension);
#if USE_OLD_STYLE_UPDATE_CHECKER #if USE_OLD_STYLE_UPDATE_CHECKER
REFLECT(updates_url); REFLECT(updates_url);
#else #else
+1
View File
@@ -195,6 +195,7 @@ public:
// --------------------------------------------------- : Internal settings // --------------------------------------------------- : Internal settings
double internal_scale; double internal_scale;
bool internal_image_extension;
// --------------------------------------------------- : Update checking // --------------------------------------------------- : Update checking
#if USE_OLD_STYLE_UPDATE_CHECKER #if USE_OLD_STYLE_UPDATE_CHECKER
+16 -8
View File
@@ -75,6 +75,8 @@ public:
private: private:
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
wxCheckBox* internal_image_extension;
wxComboBox* internal_scale; wxComboBox* internal_scale;
int internal_scale_int; int internal_scale_int;
@@ -313,8 +315,11 @@ END_EVENT_TABLE ()
// ----------------------------------------------------------------------------- : Preferences page : internal // ----------------------------------------------------------------------------- : Preferences page : internal
InternalPreferencesPage::InternalPreferencesPage(Window* parent) : PreferencesPage(parent) { InternalPreferencesPage::InternalPreferencesPage(Window* parent) : PreferencesPage(parent) {
internal_image_extension = new wxCheckBox(this, wxID_ANY, _BUTTON_("internal image extension"));
internal_scale = new wxComboBox(this, ID_INTERNAL_SCALE); internal_scale = new wxComboBox(this, ID_INTERNAL_SCALE);
internal_image_extension->SetValue(settings.internal_image_extension);
internal_scale_int = static_cast<int>(settings.internal_scale * 100); internal_scale_int = static_cast<int>(settings.internal_scale * 100);
internal_scale->SetValue(String::Format(_("%d%%"), internal_scale_int)); internal_scale->SetValue(String::Format(_("%d%%"), internal_scale_int));
@@ -325,19 +330,22 @@ InternalPreferencesPage::InternalPreferencesPage(Window* parent) : PreferencesPa
wxSizer* s = new wxBoxSizer(wxVERTICAL); wxSizer* s = new wxBoxSizer(wxVERTICAL);
wxSizer* s2 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("storage")); wxSizer* s2 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("storage"));
wxSizer* s3 = new wxBoxSizer(wxHORIZONTAL); wxSizer* s3 = new wxBoxSizer(wxHORIZONTAL);
s3->Add(new wxStaticText(this, wxID_ANY, _LABEL_("scale")), 0, wxALL & ~wxLEFT, 4); s3->Add(new wxStaticText(this, wxID_ANY, _LABEL_("scale")), 0, wxALL & ~wxLEFT, 4);
s3->AddSpacer(2); s3->AddSpacer(2);
s3->Add(internal_scale); s3->Add(internal_scale);
s3->Add(new wxStaticText(this, wxID_ANY, _LABEL_("percent of normal")), 1, wxALL & ~wxRIGHT, 4); s3->Add(new wxStaticText(this, wxID_ANY, _LABEL_("percent of normal")), 1, wxALL & ~wxRIGHT, 4);
s2->Add(s3); s2->Add(s3);
s2->Add(new wxStaticText(this, wxID_ANY, _LABEL_("internal scale desc")), 0, wxALL & ~wxLEFT, 4); s2->Add(new wxStaticText(this, wxID_ANY, _LABEL_("internal scale desc")), 0, wxALL & ~wxLEFT, 4);
s2->Add(internal_image_extension, 0, wxEXPAND | wxALL, 4);
s->Add(s2, 0, wxEXPAND | wxALL, 8); s->Add(s2, 0, wxEXPAND | wxALL, 8);
s->SetSizeHints(this); s->SetSizeHints(this);
SetSizer(s); SetSizer(s);
} }
void InternalPreferencesPage::store() { void InternalPreferencesPage::store() {
settings.internal_image_extension = internal_image_extension->GetValue();
updateInternalScale(); updateInternalScale();
settings.internal_scale = internal_scale_int / 100.0; settings.internal_scale = internal_scale_int / 100.0;
} }
@@ -356,7 +364,7 @@ void InternalPreferencesPage::updateInternalScale() {
} }
BEGIN_EVENT_TABLE(InternalPreferencesPage, wxPanel) BEGIN_EVENT_TABLE(InternalPreferencesPage, wxPanel)
EVT_COMBOBOX(ID_INTERNAL_SCALE, InternalPreferencesPage::onInternalScaleChange) EVT_COMBOBOX(ID_INTERNAL_SCALE, InternalPreferencesPage::onInternalScaleChange)
END_EVENT_TABLE() END_EVENT_TABLE()
// ----------------------------------------------------------------------------- : Preferences page : directories // ----------------------------------------------------------------------------- : Preferences page : directories
+1 -1
View File
@@ -49,7 +49,7 @@ void ImageValueEditor::sliceImage(const Image& image) {
// clicked ok? // clicked ok?
if (s.ShowModal() == wxID_OK) { if (s.ShowModal() == wxID_OK) {
// store the image into the set // store the image into the set
LocalFileName new_image_file = getLocalPackage().newFileName(field().name,_(".png")); // a new unique name in the package LocalFileName new_image_file = getLocalPackage().newFileName(field().name, settings.internal_image_extension ? _(".png") : _("")); // a new unique name in the package
Image img = s.getImage(); 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. 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)); addAction(value_action(valueP(), new_image_file));