Merge branch 'main' into beta

This commit is contained in:
David Capello 2021-04-22 14:02:36 -03:00
commit ecbd845aae
6 changed files with 52 additions and 7 deletions

View File

@ -73,6 +73,7 @@
</enum> </enum>
<enum id="SelectionMode"> <enum id="SelectionMode">
<value id="DEFAULT" value="0" /> <value id="DEFAULT" value="0" />
<value id="REPLACE" value="0" />
<value id="ADD" value="1" /> <value id="ADD" value="1" />
<value id="SUBTRACT" value="2" /> <value id="SUBTRACT" value="2" />
<value id="INTERSECT" value="3" /> <value id="INTERSECT" value="3" />

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018-2020 Igara Studio S.A. // Copyright (C) 2018-2021 Igara Studio S.A.
// //
// This program is distributed under the terms of // This program is distributed under the terms of
// the End-User License Agreement for Aseprite. // the End-User License Agreement for Aseprite.
@ -10,6 +10,6 @@
// Increment this value if the scripting API is modified between two // Increment this value if the scripting API is modified between two
// released Aseprite versions. // released Aseprite versions.
#define API_VERSION 13 #define API_VERSION 14
#endif #endif

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018-2020 Igara Studio S.A. // Copyright (C) 2018-2021 Igara Studio S.A.
// Copyright (C) 2015-2018 David Capello // Copyright (C) 2015-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -26,6 +26,7 @@
#include "app/script/security.h" #include "app/script/security.h"
#include "app/site.h" #include "app/site.h"
#include "app/tools/active_tool.h" #include "app/tools/active_tool.h"
#include "app/tools/ink.h"
#include "app/tools/tool_box.h" #include "app/tools/tool_box.h"
#include "app/tools/tool_loop.h" #include "app/tools/tool_loop.h"
#include "app/tools/tool_loop_manager.h" #include "app/tools/tool_loop_manager.h"
@ -388,6 +389,30 @@ int App_useTool(lua_State* L)
params.freehandAlgorithm = get_value_from_lua<tools::FreehandAlgorithm>(L, -1); params.freehandAlgorithm = get_value_from_lua<tools::FreehandAlgorithm>(L, -1);
lua_pop(L, 1); lua_pop(L, 1);
if (params.ink->isSelection()) {
gen::SelectionMode selectionMode = Preferences::instance().selection.mode();
type = lua_getfield(L, 1, "selection");
if (type != LUA_TNIL)
selectionMode = get_value_from_lua<gen::SelectionMode>(L, -1);
lua_pop(L, 1);
switch (selectionMode) {
case gen::SelectionMode::REPLACE:
params.modifiers = tools::ToolLoopModifiers::kReplaceSelection;
break;
case gen::SelectionMode::ADD:
params.modifiers = tools::ToolLoopModifiers::kAddSelection;
break;
case gen::SelectionMode::SUBTRACT:
params.modifiers = tools::ToolLoopModifiers::kSubtractSelection;
break;
case gen::SelectionMode::INTERSECT:
params.modifiers = tools::ToolLoopModifiers::kIntersectSelection;
break;
}
}
// Are we going to modify pixels or tiles? // Are we going to modify pixels or tiles?
type = lua_getfield(L, 1, "tilemapMode"); type = lua_getfield(L, 1, "tilemapMode");
if (type != LUA_TNIL) { if (type != LUA_TNIL) {

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018-2020 Igara Studio S.A. // Copyright (C) 2018-2021 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -15,6 +15,7 @@
#include "app/console.h" #include "app/console.h"
#include "app/doc_exporter.h" #include "app/doc_exporter.h"
#include "app/doc_range.h" #include "app/doc_range.h"
#include "app/pref/preferences.h"
#include "app/script/luacpp.h" #include "app/script/luacpp.h"
#include "app/script/security.h" #include "app/script/security.h"
#include "app/sprite_sheet_type.h" #include "app/sprite_sheet_type.h"
@ -388,6 +389,15 @@ Engine::Engine()
setfield_integer(L, "STACK", TilesetMode::Stack); setfield_integer(L, "STACK", TilesetMode::Stack);
lua_pop(L, 1); lua_pop(L, 1);
lua_newtable(L);
lua_pushvalue(L, -1);
lua_setglobal(L, "SelectionMode");
setfield_integer(L, "REPLACE", (int)gen::SelectionMode::REPLACE);
setfield_integer(L, "ADD", (int)gen::SelectionMode::ADD);
setfield_integer(L, "SUBTRACT", (int)gen::SelectionMode::SUBTRACT);
setfield_integer(L, "INTERSECT", (int)gen::SelectionMode::INTERSECT);
lua_pop(L, 1);
// Register classes/prototypes // Register classes/prototypes
register_brush_class(L); register_brush_class(L);
register_cel_class(L); register_cel_class(L);

View File

@ -126,6 +126,9 @@ protected:
doc::color_t m_secondaryColor; doc::color_t m_secondaryColor;
tools::DynamicsOptions m_dynamics; tools::DynamicsOptions m_dynamics;
// Modifiers that can be used with scripts
tools::ToolLoopModifiers m_staticToolModifiers;
// Visible region (on the screen) of the all editors showing the // Visible region (on the screen) of the all editors showing the
// given document. // given document.
gfx::Region m_allVisibleRgn; gfx::Region m_allVisibleRgn;
@ -174,6 +177,7 @@ public:
, m_bgColor(color_utils::color_for_target_mask(params.bg, m_colorTarget)) , m_bgColor(color_utils::color_for_target_mask(params.bg, m_colorTarget))
, m_primaryColor(m_button == tools::ToolLoop::Left ? m_fgColor: m_bgColor) , m_primaryColor(m_button == tools::ToolLoop::Left ? m_fgColor: m_bgColor)
, m_secondaryColor(m_button == tools::ToolLoop::Left ? m_bgColor: m_fgColor) , m_secondaryColor(m_button == tools::ToolLoop::Left ? m_bgColor: m_fgColor)
, m_staticToolModifiers(params.modifiers)
{ {
ASSERT(m_tool); ASSERT(m_tool);
ASSERT(m_ink); ASSERT(m_ink);
@ -307,8 +311,10 @@ public:
int getTolerance() override { return m_tolerance; } int getTolerance() override { return m_tolerance; }
bool getContiguous() override { return m_contiguous; } bool getContiguous() override { return m_contiguous; }
tools::ToolLoopModifiers getModifiers() override { tools::ToolLoopModifiers getModifiers() override {
return m_editor ? m_editor->getToolLoopModifiers(): return
tools::ToolLoopModifiers::kNone; (m_staticToolModifiers == tools::ToolLoopModifiers::kNone &&
m_editor ? m_editor->getToolLoopModifiers():
m_staticToolModifiers);
} }
filters::TiledMode getTiledMode() override { return m_docPref.tiled.mode(); } filters::TiledMode getTiledMode() override { return m_docPref.tiled.mode(); }
bool getGridVisible() override { return m_docPref.show.grid(); } bool getGridVisible() override { return m_docPref.show.grid(); }

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2019-2020 Igara Studio S.A. // Copyright (C) 2019-2021 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello // Copyright (C) 2001-2017 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -46,6 +46,9 @@ namespace app {
int tolerance = 0; int tolerance = 0;
bool contiguous = true; bool contiguous = true;
tools::FreehandAlgorithm freehandAlgorithm = tools::FreehandAlgorithm::DEFAULT; tools::FreehandAlgorithm freehandAlgorithm = tools::FreehandAlgorithm::DEFAULT;
// For selection tools executed from scripts
tools::ToolLoopModifiers modifiers = tools::ToolLoopModifiers::kNone;
}; };
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////