1// Aseprite
2// Copyright (C) 2022 Igara Studio S.A.
3//
4// This program is distributed under the terms of
5// the End-User License Agreement for Aseprite.
6
7#ifndef APP_COMMANDS_CMD_EXPORT_SPRITE_SHEET_H_INCLUDED
8#define APP_COMMANDS_CMD_EXPORT_SPRITE_SHEET_H_INCLUDED
9#pragma once
10
11#include "app/commands/new_params.h"
12#include "app/sprite_sheet_data_format.h"
13#include "app/sprite_sheet_type.h"
14
15#include <limits>
16#include <sstream>
17
18namespace app {
19
20struct ExportSpriteSheetParams : public NewParams {
21 Param<bool> ui { this, true, "ui" };
22 Param<bool> askOverwrite { this, true, { "askOverwrite", "ask-overwrite" } };
23 Param<app::SpriteSheetType> type { this, app::SpriteSheetType::None, "type" };
24 Param<int> columns { this, 0, "columns" };
25 Param<int> rows { this, 0, "rows" };
26 Param<int> width { this, 0, "width" };
27 Param<int> height { this, 0, "height" };
28 Param<std::string> textureFilename { this, std::string(), "textureFilename" };
29 Param<std::string> dataFilename { this, std::string(), "dataFilename" };
30 Param<SpriteSheetDataFormat> dataFormat { this, SpriteSheetDataFormat::Default, "dataFormat" };
31 Param<std::string> filenameFormat { this, std::string(), "filenameFormat" };
32 Param<int> borderPadding { this, 0, "borderPadding" };
33 Param<int> shapePadding { this, 0, "shapePadding" };
34 Param<int> innerPadding { this, 0, "innerPadding" };
35 Param<bool> trimSprite { this, false, "trimSprite" };
36 Param<bool> trim { this, false, "trim" };
37 Param<bool> trimByGrid { this, false, "trimByGrid" };
38 Param<bool> extrude { this, false, "extrude" };
39 Param<bool> ignoreEmpty { this, false, "ignoreEmpty" };
40 Param<bool> mergeDuplicates { this, false, "mergeDuplicates" };
41 Param<bool> openGenerated { this, false, "openGenerated" };
42 Param<std::string> layer { this, std::string(), "layer" };
43 // TODO The layerIndex parameter is for internal use only, layers
44 // are counted in the same order as they are displayed in the
45 // Timeline or in the Export Sprite Sheet combobox. But this
46 // index is different to the one specified in the .aseprite
47 // file spec (where layers are counted from bottom to top).
48 Param<int> layerIndex { this, -1, "_layerIndex" };
49 Param<std::string> tag { this, std::string(), "tag" };
50 Param<bool> splitLayers { this, false, "splitLayers" };
51 Param<bool> splitTags { this, false, "splitTags" };
52 Param<bool> splitGrid { this, false, "splitGrid" };
53 Param<bool> listLayers { this, true, "listLayers" };
54 Param<bool> listTags { this, true, "listTags" };
55 Param<bool> listSlices { this, true, "listSlices" };
56 Param<bool> fromTilesets { this, false, "fromTilesets" };
57};
58
59class ExportSpriteSheetCommand : public CommandWithNewParams<ExportSpriteSheetParams> {
60public:
61 ExportSpriteSheetCommand(const char* id = CommandId::ExportSpriteSheet());
62protected:
63 bool onEnabled(Context* context) override;
64 void onExecute(Context* context) override;
65};
66
67} // namespace app
68
69#endif // APP_COMMANDS_CMD_EXPORT_SPRITE_SHEET_H_INCLUDED
70