mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-29 21:33:12 +00:00
Add palette option to save as preset
This works the same as saving a palette normally, but opens the file dialogue to the default palette preset directory.
This commit is contained in:
parent
21e893162d
commit
98a0bcb2d7
@ -1080,6 +1080,9 @@
|
||||
<separator />
|
||||
<item command="LoadPalette" text="@.load_palette" />
|
||||
<item command="SavePalette" text="@.save_palette" />
|
||||
<item command="SavePalette" text="@.save_palette_as_preset">
|
||||
<param name="save_as_preset" value="true" />
|
||||
</item>
|
||||
<item command="LoadPalette" text="@.load_default_palette">
|
||||
<param name="preset" value="default" />
|
||||
</item>
|
||||
|
@ -1318,6 +1318,7 @@ ryb_color_wheel = RYB Color Wheel
|
||||
normal_map_color_wheel = Normal Map Color Wheel
|
||||
load_palette = L&oad Palette
|
||||
save_palette = S&ave Palette
|
||||
save_palette_as_preset = Save Palette as Preset
|
||||
load_default_palette = Load Default Palette
|
||||
save_as_default_palette = Save as Default Palette
|
||||
create_palette_from_current_sprite = Create Palette from Current Sprite
|
||||
|
@ -35,6 +35,7 @@ protected:
|
||||
|
||||
private:
|
||||
std::string m_preset;
|
||||
bool m_save_as_preset;
|
||||
};
|
||||
|
||||
SavePaletteCommand::SavePaletteCommand()
|
||||
@ -45,6 +46,7 @@ SavePaletteCommand::SavePaletteCommand()
|
||||
void SavePaletteCommand::onLoadParams(const Params& params)
|
||||
{
|
||||
m_preset = params.get("preset");
|
||||
m_save_as_preset = params.get("save_as_preset") == "true";
|
||||
}
|
||||
|
||||
void SavePaletteCommand::onExecute(Context* context)
|
||||
@ -58,8 +60,9 @@ void SavePaletteCommand::onExecute(Context* context)
|
||||
else {
|
||||
base::paths exts = get_writable_palette_extensions();
|
||||
base::paths selFilename;
|
||||
std::string initialPath = m_save_as_preset ? get_preset_palettes_dir() : "";
|
||||
if (!app::show_file_selector(
|
||||
"Save Palette", "", exts,
|
||||
"Save Palette", initialPath, exts,
|
||||
FileSelectorType::Save, selFilename))
|
||||
return;
|
||||
|
||||
|
@ -161,12 +161,7 @@ bool set_current_palette(const Palette *_palette, bool forced)
|
||||
std::string get_preset_palette_filename(const std::string& preset,
|
||||
const std::string& dot_extension)
|
||||
{
|
||||
ResourceFinder rf;
|
||||
rf.includeUserDir(base::join_path("palettes", ".").c_str());
|
||||
std::string palettesDir = rf.getFirstOrCreateDefault();
|
||||
|
||||
if (!base::is_directory(palettesDir))
|
||||
base::make_directory(palettesDir);
|
||||
std::string palettesDir = get_preset_palettes_dir();
|
||||
|
||||
return base::join_path(palettesDir, preset + dot_extension);
|
||||
}
|
||||
@ -176,4 +171,16 @@ std::string get_default_palette_preset_name()
|
||||
return "default";
|
||||
}
|
||||
|
||||
std::string get_preset_palettes_dir()
|
||||
{
|
||||
ResourceFinder rf;
|
||||
rf.includeUserDir(base::join_path("palettes", ".").c_str());
|
||||
std::string palettesDir = rf.getFirstOrCreateDefault();
|
||||
|
||||
if (!base::is_directory(palettesDir))
|
||||
base::make_directory(palettesDir);
|
||||
|
||||
return palettesDir;
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -33,6 +33,7 @@ namespace app {
|
||||
std::string get_preset_palette_filename(const std::string& preset,
|
||||
const std::string& dot_extension);
|
||||
std::string get_default_palette_preset_name();
|
||||
std::string get_preset_palettes_dir();
|
||||
|
||||
} // namespace app
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user