mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-16 14:42:44 +00:00
Get default palette from extensions
This commit is contained in:
parent
c4d0273e4e
commit
587b8b6dd7
@ -303,7 +303,7 @@ Extensions::~Extensions()
|
|||||||
std::string Extensions::themePath(const std::string& themeId)
|
std::string Extensions::themePath(const std::string& themeId)
|
||||||
{
|
{
|
||||||
for (auto ext : m_extensions) {
|
for (auto ext : m_extensions) {
|
||||||
if (!ext->isEnabled()) // Ignore disabled themes
|
if (!ext->isEnabled()) // Ignore disabled extensions
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto it = ext->themes().find(themeId);
|
auto it = ext->themes().find(themeId);
|
||||||
@ -313,6 +313,19 @@ std::string Extensions::themePath(const std::string& themeId)
|
|||||||
return std::string();
|
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 Extensions::palettes() const
|
||||||
{
|
{
|
||||||
ExtensionItems palettes;
|
ExtensionItems palettes;
|
||||||
|
@ -79,6 +79,7 @@ namespace app {
|
|||||||
Extension* installCompressedExtension(const std::string& zipFn);
|
Extension* installCompressedExtension(const std::string& zipFn);
|
||||||
|
|
||||||
std::string themePath(const std::string& themeId);
|
std::string themePath(const std::string& themeId);
|
||||||
|
std::string palettePath(const std::string& palId);
|
||||||
ExtensionItems palettes() const;
|
ExtensionItems palettes() const;
|
||||||
|
|
||||||
obs::signal<void(Extension*)> NewExtension;
|
obs::signal<void(Extension*)> NewExtension;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -11,6 +11,7 @@
|
|||||||
#include "app/modules/palettes.h"
|
#include "app/modules/palettes.h"
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
#include "app/extensions.h"
|
||||||
#include "app/file/palette_file.h"
|
#include "app/file/palette_file.h"
|
||||||
#include "app/resource_finder.h"
|
#include "app/resource_finder.h"
|
||||||
#include "base/fs.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
|
// If the default palette file doesn't exist, we copy db32.gpl
|
||||||
// as the default one (default.ase).
|
// as the default one (default.ase).
|
||||||
else {
|
else {
|
||||||
ResourceFinder rf;
|
std::string path = App::instance()->extensions().palettePath("db32");
|
||||||
rf.includeDataDir("palettes/db32.gpl");
|
if (path.empty())
|
||||||
if (rf.findFirst()) {
|
path = App::instance()->extensions().palettePath("vga-13h");
|
||||||
pal.reset(load_palette(rf.filename().c_str()));
|
if (!path.empty())
|
||||||
}
|
pal.reset(load_palette(path.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save default.ase file
|
// Save default.ase file
|
||||||
|
Loading…
x
Reference in New Issue
Block a user