diff --git a/data/pref.xml b/data/pref.xml
index 2a7ec7e9d..52b684bdf 100644
--- a/data/pref.xml
+++ b/data/pref.xml
@@ -435,6 +435,7 @@
diff --git a/data/strings/en.ini b/data/strings/en.ini
index 38a5383c9..38616c8e7 100644
--- a/data/strings/en.ini
+++ b/data/strings/en.ini
@@ -1425,8 +1425,8 @@ Visible aid to see the first tile with content from the tileset
as index 1 (by default, one-based index) or other value.
E.g. you can use 0 here for zero-based indexing.
END
-allow_flipped_tiles = Allow Flipped Tiles:
-allow_flipped_tiles_tooltip = <<
-
-
+
+
@@ -15,18 +15,19 @@
-
+
-
-
+
-
-
-
-
-
-
+
+
+
+
+
-
+
+
+
+
diff --git a/src/app/commands/cmd_layer_properties.cpp b/src/app/commands/cmd_layer_properties.cpp
index fcbb66188..c10a77aca 100644
--- a/src/app/commands/cmd_layer_properties.cpp
+++ b/src/app/commands/cmd_layer_properties.cpp
@@ -374,6 +374,9 @@ private:
if (window.closer() != window.ok())
return;
+ // Save "advanced" options
+ tilesetSel.saveAdvancedPreferences();
+
tilesetInfo = tilesetSel.getInfo();
if (tileset->name() != tilesetInfo.name ||
diff --git a/src/app/commands/cmd_new_layer.cpp b/src/app/commands/cmd_new_layer.cpp
index 79ac044d2..9d2fb98ea 100644
--- a/src/app/commands/cmd_new_layer.cpp
+++ b/src/app/commands/cmd_new_layer.cpp
@@ -238,7 +238,10 @@ void NewLayerCommand::onExecute(Context* context)
name = window.name()->text();
if (tilesetSelector) {
tilesetInfo = tilesetSelector->getInfo();
+
+ // Save information for next new tilemap layers
pref.tileset.baseIndex(tilesetInfo.baseIndex);
+ tilesetSelector->saveAdvancedPreferences();
}
}
#endif
diff --git a/src/app/ui/tileset_selector.cpp b/src/app/ui/tileset_selector.cpp
index aa8bc59ef..b358f67b5 100644
--- a/src/app/ui/tileset_selector.cpp
+++ b/src/app/ui/tileset_selector.cpp
@@ -11,6 +11,7 @@
#include "app/ui/tileset_selector.h"
#include "app/i18n/strings.h"
+#include "app/pref/preferences.h"
#include "doc/sprite.h"
#include "doc/tilesets.h"
#include "fmt/format.h"
@@ -22,7 +23,9 @@ namespace app {
using namespace ui;
TilesetSelector::TilesetSelector(const doc::Sprite* sprite,
- const TilesetSelector::Info& info) : m_info(info)
+ const TilesetSelector::Info& info)
+ : m_sprite(sprite)
+ , m_info(info)
{
initTheme();
@@ -55,12 +58,22 @@ TilesetSelector::TilesetSelector(const doc::Sprite* sprite,
}
if (m_info.enabled) {
- tilesets()->Change.connect(
- [this, sprite]() {
- updateControlsState(sprite->tilesets());
- });
+ tilesets()->Change.connect([this]() {
+ updateControlsState();
+ });
}
- updateControlsState(sprite->tilesets());
+
+ // Advanced controls
+ const Preferences& pref = Preferences::instance();
+ advanced()->setSelected(pref.tileset.advanced());
+ advanced()->Click.connect([this]() {
+ updateControlsVisibility();
+ if (auto win = window())
+ win->expandWindow(win->sizeHint());
+ });
+
+ updateControlsState();
+ updateControlsVisibility();
}
void TilesetSelector::fillControls(const std::string& nameValue,
@@ -77,8 +90,10 @@ void TilesetSelector::fillControls(const std::string& nameValue,
dflip()->setSelected((matchFlags & doc::tile_f_dflip) ? true: false);
}
-void TilesetSelector::updateControlsState(const doc::Tilesets* spriteTilesets)
+void TilesetSelector::updateControlsState()
{
+ const doc::Tilesets* spriteTilesets = m_sprite->tilesets();
+
if (m_info.enabled) {
const int index = getSelectedItemIndex();
const bool isNewTileset = (index == 0);
@@ -110,6 +125,17 @@ void TilesetSelector::updateControlsState(const doc::Tilesets* spriteTilesets)
}
}
+void TilesetSelector::updateControlsVisibility()
+{
+ const bool v = advanced()->isSelected();
+ baseIndexLabel()->setVisible(v);
+ baseIndex()->setVisible(v);
+ baseIndexFiller()->setVisible(v);
+ flipsLabel()->setVisible(v);
+ flips()->setVisible(v);
+ flipsFiller()->setVisible(v);
+}
+
TilesetSelector::Info TilesetSelector::getInfo()
{
int itemIndex = getSelectedItemIndex();
@@ -126,15 +152,34 @@ TilesetSelector::Info TilesetSelector::getInfo()
info.tsi = itemIndex-1;
}
info.name = name()->text();
- info.baseIndex = baseIndex()->textInt();
- info.matchFlags =
- (xflip()->isSelected() ? doc::tile_f_xflip: 0) |
- (yflip()->isSelected() ? doc::tile_f_yflip: 0) |
- (dflip()->isSelected() ? doc::tile_f_dflip: 0);
+
+ // If we are creating a new tilemap/tileset, and the advanced
+ // options are hidden, we use the default values (only in that
+ // case). In other case we use the edited options (even if the
+ // advanced options are hidden).
+ if (m_info.allowNewTileset &&
+ m_info.newTileset &&
+ !advanced()->isSelected()) {
+ info.baseIndex = 1;
+ info.matchFlags = 0;
+ }
+ else {
+ info.baseIndex = baseIndex()->textInt();
+ info.matchFlags =
+ (xflip()->isSelected() ? doc::tile_f_xflip: 0) |
+ (yflip()->isSelected() ? doc::tile_f_yflip: 0) |
+ (dflip()->isSelected() ? doc::tile_f_dflip: 0);
+ }
return info;
}
+void TilesetSelector::saveAdvancedPreferences()
+{
+ Preferences& pref = Preferences::instance();
+ pref.tileset.advanced(advanced()->isSelected());
+}
+
int TilesetSelector::getSelectedItemIndex()
{
int index = tilesets()->getSelectedItemIndex();
diff --git a/src/app/ui/tileset_selector.h b/src/app/ui/tileset_selector.h
index 41a668adc..4e9b89836 100644
--- a/src/app/ui/tileset_selector.h
+++ b/src/app/ui/tileset_selector.h
@@ -47,17 +47,22 @@ namespace app {
// Returns the data of this widget according to the user input
Info getInfo();
+ void saveAdvancedPreferences();
+
private:
void fillControls(const std::string& name,
const gfx::Size& gridSize,
const int baseIndex,
const doc::tile_flags matchFlags);
- void updateControlsState(const doc::Tilesets* spriteTilesets);
+ void updateControlsState();
+ void updateControlsVisibility();
// Returns the selected item index as if the combobox always has the "New Tileset"
// as its first item.
int getSelectedItemIndex();
+ const doc::Sprite* m_sprite;
+
// Holds the information used to create this widget
const TilesetSelector::Info m_info;
};
diff --git a/src/gen/ui_class.cpp b/src/gen/ui_class.cpp
index 054ed2859..c693cb268 100644
--- a/src/gen/ui_class.cpp
+++ b/src/gen/ui_class.cpp
@@ -1,5 +1,5 @@
// Aseprite Code Generator
-// Copyright (c) 2021 Igara Studio S.A.
+// Copyright (c) 2021-2023 Igara Studio S.A.
// Copyright (c) 2014-2018 David Capello
//
// This file is released under the terms of the MIT license.
@@ -82,6 +82,9 @@ static Item convert_to_item(TiXmlElement* elem)
if (name == "box")
return item.typeIncl("ui::Box",
"ui/box.h");
+ if (name == "boxfiller")
+ return item.typeIncl("ui::Box",
+ "ui/box.h");
if (name == "button")
return item.typeIncl("ui::Button",
"ui/button.h");