mirror of
https://github.com/aseprite/aseprite.git
synced 2024-09-02 13:09:27 +00:00
Added cli option --tagname-format
This commit is contained in:
parent
8eacee4c98
commit
bc9e201255
@ -529,6 +529,7 @@
|
|||||||
<option id="data_filename" type="std::string" />
|
<option id="data_filename" type="std::string" />
|
||||||
<option id="data_format" type="SpriteSheetDataFormat" default="SpriteSheetDataFormat::Default" />
|
<option id="data_format" type="SpriteSheetDataFormat" default="SpriteSheetDataFormat::Default" />
|
||||||
<option id="filename_format" type="std::string" />
|
<option id="filename_format" type="std::string" />
|
||||||
|
<option id="tagname_format" type="std::string" />
|
||||||
<option id="border_padding" type="int" default="0" />
|
<option id="border_padding" type="int" default="0" />
|
||||||
<option id="shape_padding" type="int" default="0" />
|
<option id="shape_padding" type="int" default="0" />
|
||||||
<option id="inner_padding" type="int" default="0" />
|
<option id="inner_padding" type="int" default="0" />
|
||||||
|
@ -861,6 +861,12 @@ Each frame in the JSON data will contain a filename
|
|||||||
how to build each frame. You can use special marks
|
how to build each frame. You can use special marks
|
||||||
like {layer}, {frame}, {tag}, {tagframe}, etc.
|
like {layer}, {frame}, {tag}, {tagframe}, etc.
|
||||||
END
|
END
|
||||||
|
data_tagname_format = Item Tagname:
|
||||||
|
data_tagname_format_tooltip = <<<END
|
||||||
|
Each frame tag in the JSON data will have a name
|
||||||
|
field, formatted with the {filename}, {title},
|
||||||
|
{path}, {tag}, etc.
|
||||||
|
END
|
||||||
preview = Preview
|
preview = Preview
|
||||||
open_sprite_sheet = Open Sprite Sheet
|
open_sprite_sheet = Open Sprite Sheet
|
||||||
export = &Export
|
export = &Export
|
||||||
|
@ -135,6 +135,12 @@
|
|||||||
tooltip="@.data_filename_format_tooltip" />
|
tooltip="@.data_filename_format_tooltip" />
|
||||||
<link text="(?)" url="https://www.aseprite.org/docs/cli/#filename-format" />
|
<link text="(?)" url="https://www.aseprite.org/docs/cli/#filename-format" />
|
||||||
</hbox>
|
</hbox>
|
||||||
|
<hbox id="data_tagname_format_placeholder" cell_hspan="3" cell_align="horizontal">
|
||||||
|
<label text="@.data_tagname_format" />
|
||||||
|
<entry id="data_tagname_format" maxsize="1024" maxwidth="256" expansive="true"
|
||||||
|
tooltip="@.data_tagname_format_tooltip" />
|
||||||
|
<link text="(?)" url="https://www.aseprite.org/docs/cli/#filename-format" />
|
||||||
|
</hbox>
|
||||||
</grid>
|
</grid>
|
||||||
|
|
||||||
</panel>
|
</panel>
|
||||||
|
@ -67,6 +67,7 @@ AppOptions::AppOptions(int argc, const char* argv[])
|
|||||||
, m_crop(m_po.add("crop").requiresValue("x,y,width,height").description("Crop all the images to the given rectangle"))
|
, m_crop(m_po.add("crop").requiresValue("x,y,width,height").description("Crop all the images to the given rectangle"))
|
||||||
, m_slice(m_po.add("slice").requiresValue("<name>").description("Crop the sprite to the given slice area"))
|
, m_slice(m_po.add("slice").requiresValue("<name>").description("Crop the sprite to the given slice area"))
|
||||||
, m_filenameFormat(m_po.add("filename-format").requiresValue("<fmt>").description("Special format to generate filenames"))
|
, m_filenameFormat(m_po.add("filename-format").requiresValue("<fmt>").description("Special format to generate filenames"))
|
||||||
|
, m_tagnameFormat(m_po.add("tagname-format").requiresValue("<fmt>").description("Special format to generate tagnames"))
|
||||||
#ifdef ENABLE_SCRIPTING
|
#ifdef ENABLE_SCRIPTING
|
||||||
, m_script(m_po.add("script").requiresValue("<filename>").description("Execute a specific script"))
|
, m_script(m_po.add("script").requiresValue("<filename>").description("Execute a specific script"))
|
||||||
, m_scriptParam(m_po.add("script-param").requiresValue("name=value").description("Parameter for a script executed from the\nCLI that you can access with app.params"))
|
, m_scriptParam(m_po.add("script-param").requiresValue("name=value").description("Parameter for a script executed from the\nCLI that you can access with app.params"))
|
||||||
|
@ -83,6 +83,7 @@ public:
|
|||||||
const Option& crop() const { return m_crop; }
|
const Option& crop() const { return m_crop; }
|
||||||
const Option& slice() const { return m_slice; }
|
const Option& slice() const { return m_slice; }
|
||||||
const Option& filenameFormat() const { return m_filenameFormat; }
|
const Option& filenameFormat() const { return m_filenameFormat; }
|
||||||
|
const Option& tagnameFormat() const { return m_tagnameFormat; }
|
||||||
#ifdef ENABLE_SCRIPTING
|
#ifdef ENABLE_SCRIPTING
|
||||||
const Option& script() const { return m_script; }
|
const Option& script() const { return m_script; }
|
||||||
const Option& scriptParam() const { return m_scriptParam; }
|
const Option& scriptParam() const { return m_scriptParam; }
|
||||||
@ -152,6 +153,7 @@ private:
|
|||||||
Option& m_crop;
|
Option& m_crop;
|
||||||
Option& m_slice;
|
Option& m_slice;
|
||||||
Option& m_filenameFormat;
|
Option& m_filenameFormat;
|
||||||
|
Option& m_tagnameFormat;
|
||||||
#ifdef ENABLE_SCRIPTING
|
#ifdef ENABLE_SCRIPTING
|
||||||
Option& m_script;
|
Option& m_script;
|
||||||
Option& m_scriptParam;
|
Option& m_scriptParam;
|
||||||
|
@ -24,6 +24,7 @@ namespace app {
|
|||||||
Doc* document = nullptr;
|
Doc* document = nullptr;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
std::string filenameFormat;
|
std::string filenameFormat;
|
||||||
|
std::string tagnameFormat;
|
||||||
std::string tag;
|
std::string tag;
|
||||||
std::string slice;
|
std::string slice;
|
||||||
std::vector<std::string> includeLayers;
|
std::vector<std::string> includeLayers;
|
||||||
|
@ -390,6 +390,12 @@ int CliProcessor::process(Context* ctx)
|
|||||||
if (m_exporter)
|
if (m_exporter)
|
||||||
m_exporter->setFilenameFormat(cof.filenameFormat);
|
m_exporter->setFilenameFormat(cof.filenameFormat);
|
||||||
}
|
}
|
||||||
|
// --tagname-format
|
||||||
|
else if (opt == &m_options.tagnameFormat()) {
|
||||||
|
cof.tagnameFormat = value.value();
|
||||||
|
if (m_exporter)
|
||||||
|
m_exporter->setTagnameFormat(cof.tagnameFormat);
|
||||||
|
}
|
||||||
// --save-as <filename>
|
// --save-as <filename>
|
||||||
else if (opt == &m_options.saveAs()) {
|
else if (opt == &m_options.saveAs()) {
|
||||||
if (lastDoc) {
|
if (lastDoc) {
|
||||||
|
@ -158,6 +158,7 @@ Doc* generate_sprite_sheet_from_params(
|
|||||||
const std::string dataFilename = params.dataFilename();
|
const std::string dataFilename = params.dataFilename();
|
||||||
const SpriteSheetDataFormat dataFormat = params.dataFormat();
|
const SpriteSheetDataFormat dataFormat = params.dataFormat();
|
||||||
const std::string filenameFormat = params.filenameFormat();
|
const std::string filenameFormat = params.filenameFormat();
|
||||||
|
const std::string tagnameFormat = params.tagnameFormat();
|
||||||
const std::string layerName = params.layer();
|
const std::string layerName = params.layer();
|
||||||
const int layerIndex = params.layerIndex();
|
const int layerIndex = params.layerIndex();
|
||||||
const std::string tagName = params.tag();
|
const std::string tagName = params.tag();
|
||||||
@ -235,6 +236,9 @@ Doc* generate_sprite_sheet_from_params(
|
|||||||
if (!filenameFormat.empty())
|
if (!filenameFormat.empty())
|
||||||
exporter.setFilenameFormat(filenameFormat);
|
exporter.setFilenameFormat(filenameFormat);
|
||||||
|
|
||||||
|
if (!tagnameFormat.empty())
|
||||||
|
exporter.setTagnameFormat(tagnameFormat);
|
||||||
|
|
||||||
exporter.setTextureWidth(width);
|
exporter.setTextureWidth(width);
|
||||||
exporter.setTextureHeight(height);
|
exporter.setTextureHeight(height);
|
||||||
exporter.setTextureColumns(columns);
|
exporter.setTextureColumns(columns);
|
||||||
@ -308,6 +312,7 @@ public:
|
|||||||
, m_genTimer(100, nullptr)
|
, m_genTimer(100, nullptr)
|
||||||
, m_executionID(0)
|
, m_executionID(0)
|
||||||
, m_filenameFormat(params.filenameFormat())
|
, m_filenameFormat(params.filenameFormat())
|
||||||
|
, m_tagnameFormat(params.tagnameFormat())
|
||||||
{
|
{
|
||||||
sectionTabs()->ItemChange.connect([this]{ onChangeSection(); });
|
sectionTabs()->ItemChange.connect([this]{ onChangeSection(); });
|
||||||
expandSections()->Click.connect([this]{ onExpandSections(); });
|
expandSections()->Click.connect([this]{ onExpandSections(); });
|
||||||
@ -414,6 +419,7 @@ public:
|
|||||||
listSlices()->setSelected(params.listSlices());
|
listSlices()->setSelected(params.listSlices());
|
||||||
|
|
||||||
updateDefaultDataFilenameFormat();
|
updateDefaultDataFilenameFormat();
|
||||||
|
updateDefaultDataTagnameFormat();
|
||||||
updateDataFields();
|
updateDataFields();
|
||||||
|
|
||||||
std::string base = site.document()->filename();
|
std::string base = site.document()->filename();
|
||||||
@ -457,6 +463,7 @@ public:
|
|||||||
splitTags()->Click.connect([this]{ onSplitLayersOrFrames(); });
|
splitTags()->Click.connect([this]{ onSplitLayersOrFrames(); });
|
||||||
frames()->Change.connect([this]{ generatePreview(); });
|
frames()->Change.connect([this]{ generatePreview(); });
|
||||||
dataFilenameFormat()->Change.connect([this]{ onDataFilenameFormatChange(); });
|
dataFilenameFormat()->Change.connect([this]{ onDataFilenameFormatChange(); });
|
||||||
|
dataTagnameFormat()->Change.connect([this]{ onDataTagnameFormatChange(); });
|
||||||
openGenerated()->Click.connect([this]{ onOpenGeneratedChange(); });
|
openGenerated()->Click.connect([this]{ onOpenGeneratedChange(); });
|
||||||
preview()->Click.connect([this]{ generatePreview(); });
|
preview()->Click.connect([this]{ generatePreview(); });
|
||||||
m_genTimer.Tick.connect([this]{ onGenTimerTick(); });
|
m_genTimer.Tick.connect([this]{ onGenTimerTick(); });
|
||||||
@ -525,6 +532,7 @@ public:
|
|||||||
params.dataFilename (dataFilenameValue());
|
params.dataFilename (dataFilenameValue());
|
||||||
params.dataFormat (dataFormatValue());
|
params.dataFormat (dataFormatValue());
|
||||||
params.filenameFormat (filenameFormatValue());
|
params.filenameFormat (filenameFormatValue());
|
||||||
|
params.tagnameFormat (tagnameFormatValue());
|
||||||
params.borderPadding (borderPaddingValue());
|
params.borderPadding (borderPaddingValue());
|
||||||
params.shapePadding (shapePaddingValue());
|
params.shapePadding (shapePaddingValue());
|
||||||
params.innerPadding (innerPaddingValue());
|
params.innerPadding (innerPaddingValue());
|
||||||
@ -666,6 +674,14 @@ private:
|
|||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string tagnameFormatValue() const {
|
||||||
|
if (!m_tagnameFormat.empty() &&
|
||||||
|
m_tagnameFormat != m_tagnameFormatDefault)
|
||||||
|
return m_tagnameFormat;
|
||||||
|
else
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
|
||||||
SpriteSheetDataFormat dataFormatValue() const {
|
SpriteSheetDataFormat dataFormatValue() const {
|
||||||
if (dataEnabled()->isSelected())
|
if (dataEnabled()->isSelected())
|
||||||
return SpriteSheetDataFormat(dataFormat()->getSelectedItemIndex());
|
return SpriteSheetDataFormat(dataFormat()->getSelectedItemIndex());
|
||||||
@ -910,6 +926,7 @@ private:
|
|||||||
|
|
||||||
void onSplitLayersOrFrames() {
|
void onSplitLayersOrFrames() {
|
||||||
updateDefaultDataFilenameFormat();
|
updateDefaultDataFilenameFormat();
|
||||||
|
updateDefaultDataTagnameFormat();
|
||||||
generatePreview();
|
generatePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -919,6 +936,12 @@ private:
|
|||||||
updateDefaultDataFilenameFormat();
|
updateDefaultDataFilenameFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onDataTagnameFormatChange() {
|
||||||
|
m_tagnameFormat = dataTagnameFormat()->text();
|
||||||
|
if (m_tagnameFormat.empty())
|
||||||
|
updateDefaultDataTagnameFormat();
|
||||||
|
}
|
||||||
|
|
||||||
void onOpenGeneratedChange() {
|
void onOpenGeneratedChange() {
|
||||||
updateExportButton();
|
updateExportButton();
|
||||||
}
|
}
|
||||||
@ -950,11 +973,16 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateDefaultDataTagnameFormat() {
|
||||||
|
m_tagnameFormatDefault = "{tag}";
|
||||||
|
}
|
||||||
|
|
||||||
void updateDataFields() {
|
void updateDataFields() {
|
||||||
bool state = dataEnabled()->isSelected();
|
bool state = dataEnabled()->isSelected();
|
||||||
dataFilename()->setVisible(state);
|
dataFilename()->setVisible(state);
|
||||||
dataMeta()->setVisible(state);
|
dataMeta()->setVisible(state);
|
||||||
dataFilenameFormatPlaceholder()->setVisible(state);
|
dataFilenameFormatPlaceholder()->setVisible(state);
|
||||||
|
dataTagnameFormatPlaceholder()->setVisible(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onGenTimerTick() {
|
void onGenTimerTick() {
|
||||||
@ -1142,6 +1170,8 @@ private:
|
|||||||
int m_executionID;
|
int m_executionID;
|
||||||
std::string m_filenameFormat;
|
std::string m_filenameFormat;
|
||||||
std::string m_filenameFormatDefault;
|
std::string m_filenameFormatDefault;
|
||||||
|
std::string m_tagnameFormat;
|
||||||
|
std::string m_tagnameFormatDefault;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ExportSpriteSheetJob : public Job {
|
class ExportSpriteSheetJob : public Job {
|
||||||
@ -1235,6 +1265,7 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
|
|||||||
if (!params.dataFilename.isSet()) params.dataFilename( defPref.spriteSheet.dataFilename());
|
if (!params.dataFilename.isSet()) params.dataFilename( defPref.spriteSheet.dataFilename());
|
||||||
if (!params.dataFormat.isSet()) params.dataFormat( defPref.spriteSheet.dataFormat());
|
if (!params.dataFormat.isSet()) params.dataFormat( defPref.spriteSheet.dataFormat());
|
||||||
if (!params.filenameFormat.isSet()) params.filenameFormat( defPref.spriteSheet.filenameFormat());
|
if (!params.filenameFormat.isSet()) params.filenameFormat( defPref.spriteSheet.filenameFormat());
|
||||||
|
if (!params.tagnameFormat.isSet()) params.tagnameFormat( defPref.spriteSheet.tagnameFormat());
|
||||||
if (!params.borderPadding.isSet()) params.borderPadding( defPref.spriteSheet.borderPadding());
|
if (!params.borderPadding.isSet()) params.borderPadding( defPref.spriteSheet.borderPadding());
|
||||||
if (!params.shapePadding.isSet()) params.shapePadding( defPref.spriteSheet.shapePadding());
|
if (!params.shapePadding.isSet()) params.shapePadding( defPref.spriteSheet.shapePadding());
|
||||||
if (!params.innerPadding.isSet()) params.innerPadding( defPref.spriteSheet.innerPadding());
|
if (!params.innerPadding.isSet()) params.innerPadding( defPref.spriteSheet.innerPadding());
|
||||||
@ -1283,6 +1314,7 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
|
|||||||
docPref.spriteSheet.dataFilename (params.dataFilename());
|
docPref.spriteSheet.dataFilename (params.dataFilename());
|
||||||
docPref.spriteSheet.dataFormat (params.dataFormat());
|
docPref.spriteSheet.dataFormat (params.dataFormat());
|
||||||
docPref.spriteSheet.filenameFormat (params.filenameFormat());
|
docPref.spriteSheet.filenameFormat (params.filenameFormat());
|
||||||
|
docPref.spriteSheet.tagnameFormat (params.tagnameFormat());
|
||||||
docPref.spriteSheet.borderPadding (params.borderPadding());
|
docPref.spriteSheet.borderPadding (params.borderPadding());
|
||||||
docPref.spriteSheet.shapePadding (params.shapePadding());
|
docPref.spriteSheet.shapePadding (params.shapePadding());
|
||||||
docPref.spriteSheet.innerPadding (params.innerPadding());
|
docPref.spriteSheet.innerPadding (params.innerPadding());
|
||||||
|
@ -29,6 +29,7 @@ struct ExportSpriteSheetParams : public NewParams {
|
|||||||
Param<std::string> dataFilename { this, std::string(), "dataFilename" };
|
Param<std::string> dataFilename { this, std::string(), "dataFilename" };
|
||||||
Param<SpriteSheetDataFormat> dataFormat { this, SpriteSheetDataFormat::Default, "dataFormat" };
|
Param<SpriteSheetDataFormat> dataFormat { this, SpriteSheetDataFormat::Default, "dataFormat" };
|
||||||
Param<std::string> filenameFormat { this, std::string(), "filenameFormat" };
|
Param<std::string> filenameFormat { this, std::string(), "filenameFormat" };
|
||||||
|
Param<std::string> tagnameFormat { this, std::string(), "tagnameFormat" };
|
||||||
Param<int> borderPadding { this, 0, "borderPadding" };
|
Param<int> borderPadding { this, 0, "borderPadding" };
|
||||||
Param<int> shapePadding { this, 0, "shapePadding" };
|
Param<int> shapePadding { this, 0, "shapePadding" };
|
||||||
Param<int> innerPadding { this, 0, "innerPadding" };
|
Param<int> innerPadding { this, 0, "innerPadding" };
|
||||||
|
@ -604,6 +604,7 @@ void DocExporter::reset()
|
|||||||
m_dataFilename.clear();
|
m_dataFilename.clear();
|
||||||
m_textureFilename.clear();
|
m_textureFilename.clear();
|
||||||
m_filenameFormat.clear();
|
m_filenameFormat.clear();
|
||||||
|
m_tagnameFormat.clear();
|
||||||
m_textureWidth = 0;
|
m_textureWidth = 0;
|
||||||
m_textureHeight = 0;
|
m_textureHeight = 0;
|
||||||
m_textureColumns = 0;
|
m_textureColumns = 0;
|
||||||
@ -1431,7 +1432,17 @@ void DocExporter::createDataFile(const Samples& samples,
|
|||||||
else
|
else
|
||||||
os << ",";
|
os << ",";
|
||||||
|
|
||||||
os << "\n { \"name\": \"" << escape_for_json(tag->name()) << "\","
|
std::string format = m_tagnameFormat;
|
||||||
|
if (format.empty()) {
|
||||||
|
format = "{tag}";
|
||||||
|
}
|
||||||
|
|
||||||
|
FilenameInfo fnInfo;
|
||||||
|
fnInfo
|
||||||
|
.filename(doc->filename())
|
||||||
|
.innerTagName(tag->name());
|
||||||
|
std::string tagname = filename_formatter(format, fnInfo);
|
||||||
|
os << "\n { \"name\": \"" << escape_for_json(tagname) << "\","
|
||||||
<< " \"from\": " << (tag->fromFrame()) << ","
|
<< " \"from\": " << (tag->fromFrame()) << ","
|
||||||
<< " \"to\": " << (tag->toFrame()) << ","
|
<< " \"to\": " << (tag->toFrame()) << ","
|
||||||
" \"direction\": \"" << escape_for_json(convert_anidir_to_string(tag->aniDir())) << "\"";
|
" \"direction\": \"" << escape_for_json(convert_anidir_to_string(tag->aniDir())) << "\"";
|
||||||
|
@ -52,6 +52,7 @@ namespace app {
|
|||||||
const std::string& textureFilename() { return m_textureFilename; }
|
const std::string& textureFilename() { return m_textureFilename; }
|
||||||
SpriteSheetType spriteSheetType() { return m_sheetType; }
|
SpriteSheetType spriteSheetType() { return m_sheetType; }
|
||||||
const std::string& filenameFormat() const { return m_filenameFormat; }
|
const std::string& filenameFormat() const { return m_filenameFormat; }
|
||||||
|
const std::string& tagnameFormat() const { return m_tagnameFormat; }
|
||||||
|
|
||||||
void setDataFormat(SpriteSheetDataFormat format) { m_dataFormat = format; }
|
void setDataFormat(SpriteSheetDataFormat format) { m_dataFormat = format; }
|
||||||
void setDataFilename(const std::string& filename) { m_dataFilename = filename; }
|
void setDataFilename(const std::string& filename) { m_dataFilename = filename; }
|
||||||
@ -71,6 +72,7 @@ namespace app {
|
|||||||
void setTrimByGrid(bool trimByGrid) { m_trimByGrid = trimByGrid; }
|
void setTrimByGrid(bool trimByGrid) { m_trimByGrid = trimByGrid; }
|
||||||
void setExtrude(bool extrude) { m_extrude = extrude; }
|
void setExtrude(bool extrude) { m_extrude = extrude; }
|
||||||
void setFilenameFormat(const std::string& format) { m_filenameFormat = format; }
|
void setFilenameFormat(const std::string& format) { m_filenameFormat = format; }
|
||||||
|
void setTagnameFormat(const std::string& format) { m_tagnameFormat = format; }
|
||||||
void setSplitLayers(bool splitLayers) { m_splitLayers = splitLayers; }
|
void setSplitLayers(bool splitLayers) { m_splitLayers = splitLayers; }
|
||||||
void setSplitTags(bool splitTags) { m_splitTags = splitTags; }
|
void setSplitTags(bool splitTags) { m_splitTags = splitTags; }
|
||||||
void setListTags(bool value) { m_listTags = value; }
|
void setListTags(bool value) { m_listTags = value; }
|
||||||
@ -160,6 +162,7 @@ namespace app {
|
|||||||
std::string m_dataFilename;
|
std::string m_dataFilename;
|
||||||
std::string m_textureFilename;
|
std::string m_textureFilename;
|
||||||
std::string m_filenameFormat;
|
std::string m_filenameFormat;
|
||||||
|
std::string m_tagnameFormat;
|
||||||
int m_textureWidth;
|
int m_textureWidth;
|
||||||
int m_textureHeight;
|
int m_textureHeight;
|
||||||
int m_textureColumns;
|
int m_textureColumns;
|
||||||
|
Loading…
Reference in New Issue
Block a user