Change TilesetMode names: Manual/Auto/Stack

This commit is contained in:
David Capello 2019-11-15 17:10:29 -03:00
parent 2bb8dc93af
commit f2abf09bbf
5 changed files with 16 additions and 16 deletions

View File

@ -420,8 +420,8 @@
<part id="outline_full_pixel" x="214" y="224" w="5" h="5" /> <part id="outline_full_pixel" x="214" y="224" w="5" h="5" />
<part id="tiles" x="144" y="208" w="6" h="6" /> <part id="tiles" x="144" y="208" w="6" h="6" />
<part id="tiles_manual" x="150" y="208" w="6" h="6" /> <part id="tiles_manual" x="150" y="208" w="6" h="6" />
<part id="tiles_semi" x="156" y="208" w="6" h="6" /> <part id="tiles_auto" x="156" y="208" w="6" h="6" />
<part id="tiles_auto" x="162" y="208" w="6" h="6" /> <part id="tiles_stack" x="162" y="208" w="6" h="6" />
</parts> </parts>
<styles> <styles>
<style id="box" /> <style id="box" />

View File

@ -350,8 +350,8 @@ Engine::Engine()
lua_pushvalue(L, -1); lua_pushvalue(L, -1);
lua_setglobal(L, "TilesetMode"); lua_setglobal(L, "TilesetMode");
setfield_integer(L, "MANUAL", TilesetMode::Manual); setfield_integer(L, "MANUAL", TilesetMode::Manual);
setfield_integer(L, "SEMI", TilesetMode::Semi);
setfield_integer(L, "AUTO", TilesetMode::Auto); setfield_integer(L, "AUTO", TilesetMode::Auto);
setfield_integer(L, "STACK", TilesetMode::Stack);
lua_pop(L, 1); lua_pop(L, 1);
// Register classes/prototypes // Register classes/prototypes

View File

@ -14,8 +14,8 @@ namespace app {
// tilemap is edited. // tilemap is edited.
enum class TilesetMode { enum class TilesetMode {
Manual, // Modify existent tiles (don't create new ones) Manual, // Modify existent tiles (don't create new ones)
Semi, // Auto-generate new tiles if needed, edit existent ones Auto, // Add/remove tiles automatically when needed
Auto, // Auto-generate new and modified tiles Stack, // Stack modified tiles as new ones
}; };
} // namespace app } // namespace app

View File

@ -165,7 +165,7 @@ ColorBar::ColorBar(int align, TooltipManager* tooltipManager)
, m_lastButtons(kButtonLeft) , m_lastButtons(kButtonLeft)
, m_editMode(false) , m_editMode(false)
, m_tilesMode(false) , m_tilesMode(false)
, m_tilesetMode(TilesetMode::Semi) , m_tilesetMode(TilesetMode::Auto)
, m_redrawTimer(250, this) , m_redrawTimer(250, this)
, m_redrawAll(false) , m_redrawAll(false)
, m_implantChange(false) , m_implantChange(false)
@ -182,12 +182,12 @@ ColorBar::ColorBar(int align, TooltipManager* tooltipManager)
m_tilesButton.addItem(theme->parts.tiles()); m_tilesButton.addItem(theme->parts.tiles());
static_assert(0 == int(TilesetMode::Manual) && static_assert(0 == int(TilesetMode::Manual) &&
1 == int(TilesetMode::Semi) && 1 == int(TilesetMode::Auto) &&
2 == int(TilesetMode::Auto), "Tileset mode buttons doesn't match TilesetMode enum values"); 2 == int(TilesetMode::Stack), "Tileset mode buttons doesn't match TilesetMode enum values");
m_tilesetModeButtons.addItem(theme->parts.tilesManual()); m_tilesetModeButtons.addItem(theme->parts.tilesManual());
m_tilesetModeButtons.addItem(theme->parts.tilesSemi());
m_tilesetModeButtons.addItem(theme->parts.tilesAuto()); m_tilesetModeButtons.addItem(theme->parts.tilesAuto());
m_tilesetModeButtons.addItem(theme->parts.tilesStack());
setTilesetMode(m_tilesetMode); setTilesetMode(m_tilesetMode);
m_paletteView.setColumns(8); m_paletteView.setColumns(8);
@ -1420,11 +1420,11 @@ void ColorBar::setupTooltips(TooltipManager* tooltipManager)
tooltipManager->addTooltipFor( tooltipManager->addTooltipFor(
m_tilesButton.getItem(0), "Show/Hide Tileset", BOTTOM); m_tilesButton.getItem(0), "Show/Hide Tileset", BOTTOM);
tooltipManager->addTooltipFor( tooltipManager->addTooltipFor(
m_tilesetModeButtons.getItem((int)TilesetMode::Manual), "Manual-mode: Modify existent tiles,\ndon't create new tiles automatically", BOTTOM); m_tilesetModeButtons.getItem((int)TilesetMode::Manual), "Manual: Modify existent tiles,\ndon't create new tiles automatically", BOTTOM);
tooltipManager->addTooltipFor( tooltipManager->addTooltipFor(
m_tilesetModeButtons.getItem((int)TilesetMode::Semi), "Semi-mode: Modify and reuse existent tiles,\ncreate/delete tiles if needed/possible", BOTTOM); m_tilesetModeButtons.getItem((int)TilesetMode::Auto), "Auto: Modify and reuse existent tiles,\ncreate/delete tiles if needed/possible", BOTTOM);
tooltipManager->addTooltipFor( tooltipManager->addTooltipFor(
m_tilesetModeButtons.getItem((int)TilesetMode::Auto), "Auto-mode: Don't modify existent tiles,\ngenerate new tiles automatically only", BOTTOM); m_tilesetModeButtons.getItem((int)TilesetMode::Stack), "Stack: Don't modify existent tiles,\ngenerate and stack new tiles automatically", BOTTOM);
} }
// static // static

View File

@ -407,7 +407,7 @@ void modify_tilemap_cel_region(
// Autogenerate tiles // Autogenerate tiles
if (tilesetMode == TilesetMode::Auto || if (tilesetMode == TilesetMode::Auto ||
tilesetMode == TilesetMode::Semi) { tilesetMode == TilesetMode::Stack) {
doc::TilesetHashTable hashImages; // TODO the hashImages should be inside the Tileset doc::TilesetHashTable hashImages; // TODO the hashImages should be inside the Tileset
{ {
// Add existent tiles in the hash table // Add existent tiles in the hash table
@ -451,7 +451,7 @@ void modify_tilemap_cel_region(
const doc::tile_index ti = doc::tile_geti(t); const doc::tile_index ti = doc::tile_geti(t);
const doc::ImageRef existenTileImage = tileset->get(ti); const doc::ImageRef existenTileImage = tileset->get(ti);
if (tilesetMode == TilesetMode::Semi) if (tilesetMode == TilesetMode::Auto)
modifiedTileIndexes[ti] = true; modifiedTileIndexes[ti] = true;
const gfx::Rect tileInCanvasRc(grid.tileToCanvas(tilePt), tileSize); const gfx::Rect tileInCanvasRc(grid.tileToCanvas(tilePt), tileSize);
@ -465,7 +465,7 @@ void modify_tilemap_cel_region(
if (it != hashImages.end()) { if (it != hashImages.end()) {
tileIndex = it->second; // TODO tileIndex = it->second; // TODO
if (tilesetMode == TilesetMode::Semi) { if (tilesetMode == TilesetMode::Auto) {
if (tileIndex >= 0 && tileIndex < modifiedTileIndexes.size()) if (tileIndex >= 0 && tileIndex < modifiedTileIndexes.size())
modifiedTileIndexes[tileIndex] = false; modifiedTileIndexes[tileIndex] = false;
} }
@ -507,7 +507,7 @@ void modify_tilemap_cel_region(
} }
// Remove unused tiles // Remove unused tiles
if (tilesetMode == TilesetMode::Semi) { if (tilesetMode == TilesetMode::Auto) {
// TODO reuse tiles that will be removed in the algorithm above // TODO reuse tiles that will be removed in the algorithm above
remove_unused_tiles_from_tileset(cmds, tileset, modifiedTileIndexes); remove_unused_tiles_from_tileset(cmds, tileset, modifiedTileIndexes);
} }