mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-28 18:32:50 +00:00
Add support to call PaletteSize without UI
This commit is contained in:
parent
b7c68579ca
commit
34834792e3
@ -254,7 +254,6 @@ if(ENABLE_UI)
|
|||||||
commands/cmd_open_with_app.cpp
|
commands/cmd_open_with_app.cpp
|
||||||
commands/cmd_options.cpp
|
commands/cmd_options.cpp
|
||||||
commands/cmd_palette_editor.cpp
|
commands/cmd_palette_editor.cpp
|
||||||
commands/cmd_palette_size.cpp
|
|
||||||
commands/cmd_paste.cpp
|
commands/cmd_paste.cpp
|
||||||
commands/cmd_paste_text.cpp
|
commands/cmd_paste_text.cpp
|
||||||
commands/cmd_pixel_perfect_mode.cpp
|
commands/cmd_pixel_perfect_mode.cpp
|
||||||
@ -516,6 +515,7 @@ add_library(app-lib
|
|||||||
commands/cmd_new_frame.cpp
|
commands/cmd_new_frame.cpp
|
||||||
commands/cmd_new_layer.cpp
|
commands/cmd_new_layer.cpp
|
||||||
commands/cmd_open_file.cpp
|
commands/cmd_open_file.cpp
|
||||||
|
commands/cmd_palette_size.cpp
|
||||||
commands/cmd_remove_layer.cpp
|
commands/cmd_remove_layer.cpp
|
||||||
commands/cmd_save_file.cpp
|
commands/cmd_save_file.cpp
|
||||||
commands/cmd_sprite_size.cpp
|
commands/cmd_sprite_size.cpp
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
|
// Copyright (C) 2019 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -53,25 +54,35 @@ void PaletteSizeCommand::onExecute(Context* context)
|
|||||||
ContextReader reader(context);
|
ContextReader reader(context);
|
||||||
frame_t frame = reader.frame();
|
frame_t frame = reader.frame();
|
||||||
Palette palette(*reader.sprite()->palette(frame));
|
Palette palette(*reader.sprite()->palette(frame));
|
||||||
|
int ncolors = (m_size != 0 ? m_size: palette.size());
|
||||||
|
|
||||||
app::gen::PaletteSize window;
|
#ifdef ENABLE_UI
|
||||||
window.colors()->setTextf("%d", palette.size());
|
if (m_size == 0 && context->isUIAvailable()) {
|
||||||
window.openWindowInForeground();
|
app::gen::PaletteSize window;
|
||||||
if (window.closer() == window.ok()) {
|
window.colors()->setTextf("%d", ncolors);
|
||||||
int ncolors = window.colors()->textInt();
|
window.openWindowInForeground();
|
||||||
if (ncolors == palette.size())
|
if (window.closer() != window.ok())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
palette.resize(MID(1, ncolors, std::numeric_limits<int>::max()));
|
ncolors = window.colors()->textInt();
|
||||||
|
|
||||||
ContextWriter writer(reader);
|
|
||||||
Tx tx(context, "Palette Size", ModifyDocument);
|
|
||||||
tx(new cmd::SetPalette(writer.sprite(), frame, &palette));
|
|
||||||
tx.commit();
|
|
||||||
|
|
||||||
set_current_palette(&palette, false);
|
|
||||||
ui::Manager::getDefault()->invalidate();
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (ncolors == palette.size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
palette.resize(MID(1, ncolors, std::numeric_limits<int>::max()));
|
||||||
|
|
||||||
|
ContextWriter writer(reader);
|
||||||
|
Tx tx(context, "Palette Size", ModifyDocument);
|
||||||
|
tx(new cmd::SetPalette(writer.sprite(), frame, &palette));
|
||||||
|
tx.commit();
|
||||||
|
|
||||||
|
set_current_palette(&palette, false);
|
||||||
|
#ifdef ENABLE_UI
|
||||||
|
if (context->isUIAvailable())
|
||||||
|
ui::Manager::getDefault()->invalidate();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Command* CommandFactory::createPaletteSizeCommand()
|
Command* CommandFactory::createPaletteSizeCommand()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user