Add -sheet-columns and -sheet-rows CLI parameters

This commit is contained in:
David Capello 2019-11-01 14:55:52 -03:00
parent c2acc973ee
commit a20d55a0aa
3 changed files with 24 additions and 8 deletions

View File

@ -42,10 +42,12 @@ AppOptions::AppOptions(int argc, const char* argv[])
, m_data(m_po.add("data").requiresValue("<filename.json>").description("File to store the sprite sheet metadata"))
, m_format(m_po.add("format").requiresValue("<format>").description("Format to export the data file\n(json-hash, json-array)"))
, m_sheet(m_po.add("sheet").requiresValue("<filename.png>").description("Image file to save the texture"))
, m_sheetType(m_po.add("sheet-type").requiresValue("<type>").description("Algorithm to create the sprite sheet:\n horizontal\n vertical\n rows\n columns\n packed"))
, m_sheetPack(m_po.add("sheet-pack").description("Same as -sheet-type packed"))
, m_sheetWidth(m_po.add("sheet-width").requiresValue("<pixels>").description("Sprite sheet width"))
, m_sheetHeight(m_po.add("sheet-height").requiresValue("<pixels>").description("Sprite sheet height"))
, m_sheetType(m_po.add("sheet-type").requiresValue("<type>").description("Algorithm to create the sprite sheet:\n horizontal\n vertical\n rows\n columns\n packed"))
, m_sheetPack(m_po.add("sheet-pack").description("Same as --sheet-type packed"))
, m_sheetColumns(m_po.add("sheet-columns").requiresValue("<columns>").description("Fixed # of columns for -sheet-type rows"))
, m_sheetRows(m_po.add("sheet-rows").requiresValue("<rows>").description("Fixed # of rows for -sheet-type columns"))
, m_splitLayers(m_po.add("split-layers").description("Save each visible layer of sprites\nas separated images in the sheet\n"))
, m_splitTags(m_po.add("split-tags").description("Save each tag as a separated file"))
, m_splitSlices(m_po.add("split-slices").description("Save each slice as a separated file"))

View File

@ -56,10 +56,12 @@ public:
const Option& data() const { return m_data; }
const Option& format() const { return m_format; }
const Option& sheet() const { return m_sheet; }
const Option& sheetWidth() const { return m_sheetWidth; }
const Option& sheetHeight() const { return m_sheetHeight; }
const Option& sheetType() const { return m_sheetType; }
const Option& sheetPack() const { return m_sheetPack; }
const Option& sheetWidth() const { return m_sheetWidth; }
const Option& sheetHeight() const { return m_sheetHeight; }
const Option& sheetColumns() const { return m_sheetColumns; }
const Option& sheetRows() const { return m_sheetRows; }
const Option& splitLayers() const { return m_splitLayers; }
const Option& splitTags() const { return m_splitTags; }
const Option& splitSlices() const { return m_splitSlices; }
@ -118,10 +120,12 @@ private:
Option& m_data;
Option& m_format;
Option& m_sheet;
Option& m_sheetWidth;
Option& m_sheetHeight;
Option& m_sheetType;
Option& m_sheetPack;
Option& m_sheetWidth;
Option& m_sheetHeight;
Option& m_sheetColumns;
Option& m_sheetRows;
Option& m_splitLayers;
Option& m_splitTags;
Option& m_splitSlices;

View File

@ -231,12 +231,22 @@ void CliProcessor::process(Context* ctx)
// --sheet-width <width>
else if (opt == &m_options.sheetWidth()) {
if (m_exporter)
m_exporter->setTextureWidth(strtol(value.value().c_str(), NULL, 0));
m_exporter->setTextureWidth(strtol(value.value().c_str(), nullptr, 0));
}
// --sheet-height <height>
else if (opt == &m_options.sheetHeight()) {
if (m_exporter)
m_exporter->setTextureHeight(strtol(value.value().c_str(), NULL, 0));
m_exporter->setTextureHeight(strtol(value.value().c_str(), nullptr, 0));
}
// --sheet-columns <columns>
else if (opt == &m_options.sheetColumns()) {
if (m_exporter)
m_exporter->setTextureColumns(strtol(value.value().c_str(), nullptr, 0));
}
// --sheet-rows <rows>
else if (opt == &m_options.sheetRows()) {
if (m_exporter)
m_exporter->setTextureRows(strtol(value.value().c_str(), nullptr, 0));
}
// --sheet-type <sheet-type>
else if (opt == &m_options.sheetType()) {