Get default palette from extensions

This commit is contained in:
David Capello 2017-06-13 12:03:16 -03:00
parent c4d0273e4e
commit 587b8b6dd7
3 changed files with 22 additions and 7 deletions

View File

@ -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;

View File

@ -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<void(Extension*)> NewExtension;

View File

@ -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