mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-16 10:20:50 +00:00
Don't use Preferences to get default slice color in background thread
Continuation of 673e1955fa10e8ce643c80f64c439852b543f62a
This commit is contained in:
parent
bbd96a23b5
commit
9c98f9c4df
@ -709,7 +709,9 @@ void FileOp::operate(IFileOpProgress* progress)
|
||||
m_document->sprite() &&
|
||||
!m_dataFilename.empty()) {
|
||||
try {
|
||||
load_aseprite_data_file(m_dataFilename, m_document);
|
||||
load_aseprite_data_file(m_dataFilename,
|
||||
m_document,
|
||||
m_defaultSliceColor);
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
setError("Error loading data file: %s\n", ex.what());
|
||||
@ -1191,6 +1193,7 @@ FileOp::FileOp(FileOpType type, Context* context)
|
||||
, m_preserveColorProfile(Preferences::instance().color.manage())
|
||||
, m_embeddedColorProfile(false)
|
||||
, m_newBlend(Preferences::instance().experimental.newBlend())
|
||||
, m_defaultSliceColor(Preferences::instance().slices.defaultColor())
|
||||
{
|
||||
m_seq.palette = nullptr;
|
||||
m_seq.image.reset();
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2019 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -9,6 +9,7 @@
|
||||
#define APP_FILE_FILE_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/color.h"
|
||||
#include "base/mutex.h"
|
||||
#include "base/paths.h"
|
||||
#include "base/shared_ptr.h"
|
||||
@ -212,6 +213,8 @@ namespace app {
|
||||
// blend mode.
|
||||
bool m_newBlend;
|
||||
|
||||
app::Color m_defaultSliceColor;
|
||||
|
||||
base::SharedPtr<FormatOptions> m_formatOptions;
|
||||
|
||||
// Data for sequences.
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -10,13 +11,14 @@
|
||||
|
||||
#include "app/file/file_data.h"
|
||||
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/color.h"
|
||||
#include "app/xml_document.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "base/fs.h"
|
||||
#include "doc/color.h"
|
||||
#include "doc/document.h"
|
||||
#include "doc/slice.h"
|
||||
#include "gfx/color.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
@ -222,7 +224,9 @@ void update_xml_slice(const doc::Slice* slice, TiXmlElement* xmlSlice)
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void load_aseprite_data_file(const std::string& dataFilename, doc::Document* doc)
|
||||
void load_aseprite_data_file(const std::string& dataFilename,
|
||||
doc::Document* doc,
|
||||
app::Color& defaultSliceColor)
|
||||
{
|
||||
XmlDocumentRef xmlDoc = open_xml(dataFilename);
|
||||
TiXmlHandle handle(xmlDoc.get());
|
||||
@ -254,12 +258,11 @@ void load_aseprite_data_file(const std::string& dataFilename, doc::Document* doc
|
||||
slice->setName(partId);
|
||||
|
||||
// Default slice color
|
||||
auto color = Preferences::instance().slices.defaultColor();
|
||||
slice->userData().setColor(
|
||||
doc::rgba(color.getRed(),
|
||||
color.getGreen(),
|
||||
color.getBlue(),
|
||||
color.getAlpha()));
|
||||
doc::rgba(defaultSliceColor.getRed(),
|
||||
defaultSliceColor.getGreen(),
|
||||
defaultSliceColor.getBlue(),
|
||||
defaultSliceColor.getAlpha()));
|
||||
|
||||
doc::SliceKey key;
|
||||
|
||||
@ -320,11 +323,10 @@ void load_aseprite_data_file(const std::string& dataFilename, doc::Document* doc
|
||||
color = color_from_hex(xmlSlice->Attribute("color"));
|
||||
}
|
||||
else {
|
||||
app::Color appColor = Preferences::instance().slices.defaultColor();
|
||||
color = doc::rgba(appColor.getRed(),
|
||||
appColor.getGreen(),
|
||||
appColor.getBlue(),
|
||||
appColor.getAlpha());
|
||||
color = doc::rgba(defaultSliceColor.getRed(),
|
||||
defaultSliceColor.getGreen(),
|
||||
defaultSliceColor.getBlue(),
|
||||
defaultSliceColor.getAlpha());
|
||||
}
|
||||
slice->userData().setColor(color);
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -8,6 +9,7 @@
|
||||
#define APP_FILE_FILE_DATA_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/color.h"
|
||||
#include <string>
|
||||
|
||||
namespace doc {
|
||||
@ -16,7 +18,9 @@ namespace doc {
|
||||
|
||||
namespace app {
|
||||
|
||||
void load_aseprite_data_file(const std::string& dataFilename, doc::Document* doc);
|
||||
void load_aseprite_data_file(const std::string& dataFilename,
|
||||
doc::Document* doc,
|
||||
app::Color& defaultSliceColor);
|
||||
#ifdef ENABLE_SAVE
|
||||
void save_aseprite_data_file(const std::string& dataFilename, const doc::Document* doc);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user