mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-29 00:23:48 +00:00
[lua] Fix default color/bgColor params in app.useTool()
We can select the default color or tile from preferences depending if
we're going to paint pixels or tiles
Fixes a confusing logic from 4a91d150af
where the bg color was obtained from preferences only when the fg
color type (rgb/gray/index/hsv/tile/etc.) was equal to the bg color
type from the preferences (rgb/gray/index/hsv/tile/etc.).
This commit is contained in:
parent
240d481645
commit
9429d915ae
@ -348,24 +348,37 @@ int App_useTool(lua_State* L)
|
||||
params.inkType = get_value_from_lua<tools::InkType>(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
// Are we going to modify pixels or tiles?
|
||||
type = lua_getfield(L, 1, "tilemapMode");
|
||||
if (type != LUA_TNIL) {
|
||||
site.tilemapMode(TilemapMode(lua_tointeger(L, -1)));
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
// How the tileset must be modified depending on this tool usage
|
||||
type = lua_getfield(L, 1, "tilesetMode");
|
||||
if (type != LUA_TNIL) {
|
||||
site.tilesetMode(TilesetMode(lua_tointeger(L, -1)));
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
// Color
|
||||
type = lua_getfield(L, 1, "color");
|
||||
if (type != LUA_TNIL)
|
||||
params.fg = convert_args_into_color(L, -1);
|
||||
else {
|
||||
// Default color is the active fgColor
|
||||
else if (site.tilemapMode() == TilemapMode::Tiles)
|
||||
params.fg = Color::fromTile(Preferences::instance().colorBar.fgTile());
|
||||
else // Default color is the active fgColor
|
||||
params.fg = Preferences::instance().colorBar.fgColor();
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
type = lua_getfield(L, 1, "bgColor");
|
||||
if (type != LUA_TNIL)
|
||||
params.bg = convert_args_into_color(L, -1);
|
||||
else if (params.fg.getType() ==
|
||||
Preferences::instance().colorBar.bgColor().getType())
|
||||
params.bg = Preferences::instance().colorBar.bgColor();
|
||||
else if (site.tilemapMode() == TilemapMode::Tiles)
|
||||
params.bg = Color::fromTile(Preferences::instance().colorBar.bgTile());
|
||||
else
|
||||
params.bg = params.fg;
|
||||
params.bg = Preferences::instance().colorBar.bgColor();
|
||||
lua_pop(L, 1);
|
||||
|
||||
// Adjust ink depending on "inkType" and "color"
|
||||
@ -444,20 +457,6 @@ int App_useTool(lua_State* L)
|
||||
}
|
||||
}
|
||||
|
||||
// Are we going to modify pixels or tiles?
|
||||
type = lua_getfield(L, 1, "tilemapMode");
|
||||
if (type != LUA_TNIL) {
|
||||
site.tilemapMode(TilemapMode(lua_tointeger(L, -1)));
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
// How the tileset must be modified depending on this tool usage
|
||||
type = lua_getfield(L, 1, "tilesetMode");
|
||||
if (type != LUA_TNIL) {
|
||||
site.tilesetMode(TilesetMode(lua_tointeger(L, -1)));
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
// Do the tool loop
|
||||
type = lua_getfield(L, 1, "points");
|
||||
if (type == LUA_TTABLE) {
|
||||
|
Loading…
Reference in New Issue
Block a user