This is an automated email from the git hooks/post-receive script. thansen pushed a commit to branch master in repository aseprite.
commit 52dd13c9a04c47b7ae1bd30548d31f801bc14e9b Author: David Capello <[email protected]> Date: Wed Apr 6 19:28:49 2016 -0300 Add Sprite.saveAs() method in scripting API --- src/app/script/sprite_class.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/app/script/sprite_class.cpp b/src/app/script/sprite_class.cpp index 786aa13..85be120 100644 --- a/src/app/script/sprite_class.cpp +++ b/src/app/script/sprite_class.cpp @@ -12,6 +12,8 @@ #include "app/script/sprite_class.h" #include "app/cmd/set_sprite_size.h" +#include "app/commands/commands.h" +#include "app/commands/params.h" #include "app/document.h" #include "app/document_api.h" #include "app/script/app_scripting.h" @@ -80,6 +82,28 @@ script::result_t Sprite_crop(script::ContextHandle handle) return 0; } +script::result_t Sprite_saveAs(script::ContextHandle handle) +{ + script::Context ctx(handle); + const char* fn = ctx.requireString(0); + + auto wrap = (SpriteWrap*)ctx.getThis(); + if (fn && wrap) { + Document* doc = wrap->document(); + + auto uiCtx = UIContext::instance(); + uiCtx->setActiveDocument(doc); + + Command* saveAsCommand = CommandsModule::instance()->getCommandByName(CommandId::SaveFileCopyAs); + + Params params; + params.set("filename", fn); + uiCtx->executeCommand(saveAsCommand, params); + } + + return 0; +} + script::result_t Sprite_get_width(script::ContextHandle handle) { script::Context ctx(handle); @@ -127,6 +151,7 @@ script::result_t Sprite_set_height(script::ContextHandle handle) const script::FunctionEntry Sprite_methods[] = { { "resize", Sprite_resize, 2 }, { "crop", Sprite_crop, 4 }, + { "saveAs", Sprite_saveAs, 2 }, { nullptr, nullptr, 0 } }; -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git _______________________________________________ Pkg-games-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

