diff --git a/INSTALL.md b/INSTALL.md index 57105f12a..38f593ebc 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -19,7 +19,7 @@ You should be able to compile Aseprite successfully on the following platforms: -* Windows 10 + [Visual Studio Community 2019 + Windows 10.0.18362.0 SDK](https://imgur.com/a/7zs51IT) (we don't support [MinGW](#mingw)) +* Windows 10 + [Visual Studio Community 2019 + Windows 10.0 SDK (the latest version available)](https://imgur.com/a/7zs51IT) (we don't support [MinGW](#mingw)) * macOS 10.15.3 Catalina + Xcode 11.2.1 + macOS 10.15 SDK (older version might work) * Linux + gcc 9.2 or clang 9.0 diff --git a/data/strings/en.ini b/data/strings/en.ini index e7a280e29..90bd4ae91 100644 --- a/data/strings/en.ini +++ b/data/strings/en.ini @@ -53,6 +53,7 @@ Import Sprite Sheet END error_loading_file = Error<invalidate(); + auto manager = ui::Manager::getDefault(); + manager->invalidate(); // Create the main window. m_mainWindow.reset(new MainWindow); @@ -322,7 +323,16 @@ int App::initialize(const AppOptions& options) m_mainWindow->openWindow(); // Redraw the whole screen. - ui::Manager::getDefault()->invalidate(); + manager->invalidate(); + + // Pump some messages so we receive the first + // Manager::onNewDisplayConfiguration() and we known the manager + // initial size. This is required so if the OpenFileCommand + // (called when we're processing the CLI with OpenBatchOfFiles) + // shows a dialog to open a sequence of files, the dialog is + // centered correctly to the manager bounds. + ui::MessageLoop loop(manager); + loop.pumpMessages(); } #endif // ENABLE_UI diff --git a/src/app/commands/cmd_save_palette.cpp b/src/app/commands/cmd_save_palette.cpp index 05be7186d..893d697eb 100644 --- a/src/app/commands/cmd_save_palette.cpp +++ b/src/app/commands/cmd_save_palette.cpp @@ -1,4 +1,5 @@ // Aseprite +// Copyright (C) 2021 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -50,7 +51,7 @@ void SavePaletteCommand::onLoadParams(const Params& params) m_saveAsPreset = (params.get("saveAsPreset") == "true"); } -void SavePaletteCommand::onExecute(Context* context) +void SavePaletteCommand::onExecute(Context* ctx) { const doc::Palette* palette = get_current_palette(); std::string filename; @@ -68,6 +69,18 @@ void SavePaletteCommand::onExecute(Context* context) return; filename = selFilename.front(); + + // Check that the file format supports saving indexed images/color + // palettes (e.g. if the user specified .jpg we should show that + // that file format is not supported to save color palettes) + if (!base::has_file_extension(filename, exts)) { + if (ctx->isUIAvailable()) { + ui::Alert::show( + fmt::format(Strings::alerts_file_format_doesnt_support_palette(), + base::get_file_extension(filename))); + } + return; + } } if (!save_palette(filename.c_str(), palette, 16)) // TODO 16 should be configurable @@ -75,7 +88,7 @@ void SavePaletteCommand::onExecute(Context* context) if (m_preset == get_default_palette_preset_name()) { set_default_palette(palette); - if (!context->activeDocument()) + if (!ctx->activeDocument()) set_current_palette(palette, false); } if (m_saveAsPreset) { diff --git a/src/app/file/file.cpp b/src/app/file/file.cpp index fa568235e..e7ed26bff 100644 --- a/src/app/file/file.cpp +++ b/src/app/file/file.cpp @@ -63,11 +63,13 @@ base::paths get_readable_extensions() return paths; } -base::paths get_writable_extensions() +base::paths get_writable_extensions(const int requiredFormatFlag) { base::paths paths; for (const FileFormat* format : *FileFormatsManager::instance()) { - if (format->support(FILE_SUPPORT_SAVE)) + if (format->support(FILE_SUPPORT_SAVE) && + (requiredFormatFlag == 0 || + format->support(requiredFormatFlag))) format->getExtensions(paths); } return paths; diff --git a/src/app/file/file.h b/src/app/file/file.h index 526280cf0..9e9385a7b 100644 --- a/src/app/file/file.h +++ b/src/app/file/file.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2018-2020 Igara Studio S.A. +// Copyright (C) 2018-2021 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -281,7 +281,7 @@ namespace app { // Available extensions for each load/save operation. base::paths get_readable_extensions(); - base::paths get_writable_extensions(); + base::paths get_writable_extensions(const int requiredFormatFlag = 0); // High-level routines to load/save documents. Doc* load_document(Context* context, const std::string& filename); diff --git a/src/app/file/jpeg_format.cpp b/src/app/file/jpeg_format.cpp index 4abde1853..274417b4e 100644 --- a/src/app/file/jpeg_format.cpp +++ b/src/app/file/jpeg_format.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2018-2020 Igara Studio S.A. +// Copyright (C) 2018-2021 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -357,7 +357,9 @@ bool JpegFormat::onSave(FileOp* fop) JSAMPARRAY buffer; JDIMENSION buffer_height; const auto jpeg_options = std::static_pointer_cast(fop->formatOptions()); - const int qualityValue = (int)base::clamp(100.0f * jpeg_options->quality, 0.f, 100.f); + const int qualityValue = + (jpeg_options ? (int)base::clamp(100.0f * jpeg_options->quality, 0.f, 100.f): + 100); int c; diff --git a/src/app/file/palette_file.cpp b/src/app/file/palette_file.cpp index 2ae17a674..5ebd8faf3 100644 --- a/src/app/file/palette_file.cpp +++ b/src/app/file/palette_file.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2018-2019 Igara Studio S.A. +// Copyright (C) 2018-2021 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -47,7 +47,7 @@ base::paths get_readable_palette_extensions() base::paths get_writable_palette_extensions() { - base::paths paths = get_writable_extensions(); + base::paths paths = get_writable_extensions(FILE_SUPPORT_INDEXED); for (const char* s : palExts) paths.push_back(s); return paths; diff --git a/src/ui/manager.cpp b/src/ui/manager.cpp index 4737d3f62..2106d3a4e 100644 --- a/src/ui/manager.cpp +++ b/src/ui/manager.cpp @@ -284,7 +284,7 @@ void Manager::run() if (first_time) { first_time = false; - Manager::getDefault()->invalidate(); + invalidate(); set_mouse_cursor(kArrowCursor); }