1 | // Aseprite |
---|---|
2 | // Copyright (C) 2001-2017 David Capello |
3 | // |
4 | // This program is distributed under the terms of |
5 | // the End-User License Agreement for Aseprite. |
6 | |
7 | #ifdef HAVE_CONFIG_H |
8 | #include "config.h" |
9 | #endif |
10 | |
11 | #include "app/app.h" |
12 | #include "app/commands/command.h" |
13 | #include "app/commands/commands.h" |
14 | #include "app/commands/params.h" |
15 | #include "app/context.h" |
16 | #include "app/context_access.h" |
17 | #include "app/pref/preferences.h" |
18 | |
19 | namespace app { |
20 | |
21 | class RepeatLastExportCommand : public Command { |
22 | public: |
23 | RepeatLastExportCommand(); |
24 | |
25 | protected: |
26 | virtual bool onEnabled(Context* context) override; |
27 | virtual void onExecute(Context* context) override; |
28 | }; |
29 | |
30 | RepeatLastExportCommand::RepeatLastExportCommand() |
31 | : Command(CommandId::RepeatLastExport(), CmdRecordableFlag) |
32 | { |
33 | } |
34 | |
35 | bool RepeatLastExportCommand::onEnabled(Context* context) |
36 | { |
37 | return context->checkFlags(ContextFlags::ActiveDocumentIsWritable); |
38 | } |
39 | |
40 | void RepeatLastExportCommand::onExecute(Context* context) |
41 | { |
42 | Command* cmd = Commands::instance()->byId(CommandId::ExportSpriteSheet()); |
43 | Params params; |
44 | |
45 | { |
46 | const ContextReader reader(context); |
47 | const Doc* document(reader.document()); |
48 | DocumentPreferences& docPref = |
49 | Preferences::instance().document(document); |
50 | |
51 | params.set("ui", (docPref.spriteSheet.defined() ? "0": "1")); |
52 | } |
53 | |
54 | context->executeCommand(cmd, params); |
55 | } |
56 | |
57 | Command* CommandFactory::createRepeatLastExportCommand() |
58 | { |
59 | return new RepeatLastExportCommand; |
60 | } |
61 | |
62 | } // namespace app |
63 |