From 587b8b6dd7ee77739e728a17b6d852b0a68105a7 Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 13 Jun 2017 12:03:16 -0300 Subject: [PATCH] Get default palette from extensions --- src/app/extensions.cpp | 15 ++++++++++++++- src/app/extensions.h | 1 + src/app/modules/palettes.cpp | 13 +++++++------ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/app/extensions.cpp b/src/app/extensions.cpp index a0181ad4e..40defcc72 100644 --- a/src/app/extensions.cpp +++ b/src/app/extensions.cpp @@ -303,7 +303,7 @@ Extensions::~Extensions() std::string Extensions::themePath(const std::string& themeId) { for (auto ext : m_extensions) { - if (!ext->isEnabled()) // Ignore disabled themes + if (!ext->isEnabled()) // Ignore disabled extensions continue; auto it = ext->themes().find(themeId); @@ -313,6 +313,19 @@ std::string Extensions::themePath(const std::string& themeId) return std::string(); } +std::string Extensions::palettePath(const std::string& palId) +{ + for (auto ext : m_extensions) { + if (!ext->isEnabled()) // Ignore disabled extensions + continue; + + auto it = ext->palettes().find(palId); + if (it != ext->palettes().end()) + return it->second; + } + return std::string(); +} + ExtensionItems Extensions::palettes() const { ExtensionItems palettes; diff --git a/src/app/extensions.h b/src/app/extensions.h index cc9f38f44..610c32fa4 100644 --- a/src/app/extensions.h +++ b/src/app/extensions.h @@ -79,6 +79,7 @@ namespace app { Extension* installCompressedExtension(const std::string& zipFn); std::string themePath(const std::string& themeId); + std::string palettePath(const std::string& palId); ExtensionItems palettes() const; obs::signal NewExtension; diff --git a/src/app/modules/palettes.cpp b/src/app/modules/palettes.cpp index 31f8cb2b5..691010a43 100644 --- a/src/app/modules/palettes.cpp +++ b/src/app/modules/palettes.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2001-2016 David Capello +// Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of // the End-User License Agreement for Aseprite. @@ -11,6 +11,7 @@ #include "app/modules/palettes.h" #include "app/app.h" +#include "app/extensions.h" #include "app/file/palette_file.h" #include "app/resource_finder.h" #include "base/fs.h" @@ -98,11 +99,11 @@ void load_default_palette() // If the default palette file doesn't exist, we copy db32.gpl // as the default one (default.ase). else { - ResourceFinder rf; - rf.includeDataDir("palettes/db32.gpl"); - if (rf.findFirst()) { - pal.reset(load_palette(rf.filename().c_str())); - } + std::string path = App::instance()->extensions().palettePath("db32"); + if (path.empty()) + path = App::instance()->extensions().palettePath("vga-13h"); + if (!path.empty()) + pal.reset(load_palette(path.c_str())); } // Save default.ase file