mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-06-08 01:22:02 +00:00
don't lose tile flags when changing solidness; update grid when flipping solid tile
This commit is contained in:
parent
fef32b042c
commit
22e682cebc
2 changed files with 25 additions and 4 deletions
|
@ -1269,7 +1269,12 @@ void SceneEditor::toggleElementSolid()
|
||||||
for(size_t i = 0; i < n; ++i)
|
for(size_t i = 0; i < n; ++i)
|
||||||
{
|
{
|
||||||
TileData& t = ts.tiles[selectedTiles[i]];
|
TileData& t = ts.tiles[selectedTiles[i]];
|
||||||
t.flags = TileMgr::GetTileFlags(nextSolidEF(TileMgr::GetElementFlag((TileFlags)t.flags)));
|
// cycle to next flag combination
|
||||||
|
ElementFlag ef = TileMgr::GetElementFlag((TileFlags)t.flags);
|
||||||
|
ef = nextSolidEF(ef);
|
||||||
|
TileFlags newflags = TileMgr::GetTileFlags(ef);
|
||||||
|
// keep old flags that have nothing to do with tile solidness
|
||||||
|
t.flags = (t.flags & ~TILEFLAG_MASK_SOLID) | (newflags & TILEFLAG_MASK_SOLID);
|
||||||
}
|
}
|
||||||
game->reconstructGrid(true, true);
|
game->reconstructGrid(true, true);
|
||||||
}
|
}
|
||||||
|
@ -1284,9 +1289,9 @@ void SceneEditor::toggleElementHurt()
|
||||||
const bool set = !(t0.flags & TILEFLAG_HURT);
|
const bool set = !(t0.flags & TILEFLAG_HURT);
|
||||||
|
|
||||||
if(set)
|
if(set)
|
||||||
ts.changeFlags(TILEFLAG_SOLID | TILEFLAG_HURT, TILEFLAG_TRIM, &selectedTiles[0], n);
|
ts.changeFlags(TILEFLAG_SOLID | TILEFLAG_HURT, TILEFLAG_TRIM, &selectedTiles[0], n); // solid, hurting
|
||||||
else
|
else
|
||||||
ts.changeFlags(0, TILEFLAG_SOLID | TILEFLAG_HURT | TILEFLAG_SOLID_IN | TILEFLAG_TRIM, &selectedTiles[0], n);
|
ts.changeFlags(0, TILEFLAG_MASK_SOLID, &selectedTiles[0], n); // not solid, not hurting
|
||||||
|
|
||||||
game->reconstructGrid(true, true);
|
game->reconstructGrid(true, true);
|
||||||
}
|
}
|
||||||
|
@ -1685,9 +1690,16 @@ void SceneEditor::flipElementHorz()
|
||||||
|
|
||||||
if (n)
|
if (n)
|
||||||
{
|
{
|
||||||
|
unsigned allflags = 0;
|
||||||
TileStorage& ts = getCurrentLayerTiles();
|
TileStorage& ts = getCurrentLayerTiles();
|
||||||
for(size_t i = 0; i < n; ++i)
|
for(size_t i = 0; i < n; ++i)
|
||||||
ts.tiles[selectedTiles[i]].flags ^= TILEFLAG_FH; // toggle bit
|
{
|
||||||
|
TileData& t = ts.tiles[selectedTiles[i]];
|
||||||
|
allflags |= t.flags;
|
||||||
|
t.flags ^= TILEFLAG_FH; // toggle bit
|
||||||
|
}
|
||||||
|
if(allflags & TILEFLAG_MASK_SOLID) // there was a solid tile among them, regen grid
|
||||||
|
game->reconstructGrid(true, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this->placer->flipHorizontal();
|
this->placer->flipHorizontal();
|
||||||
|
@ -1700,9 +1712,16 @@ void SceneEditor::flipElementVert()
|
||||||
|
|
||||||
if (size_t n = selectedTiles.size())
|
if (size_t n = selectedTiles.size())
|
||||||
{
|
{
|
||||||
|
//unsigned allflags = 0; // FIXME? Vertical flip was ignored by tile collision generation (bug-compatibility)
|
||||||
TileStorage& ts = getCurrentLayerTiles();
|
TileStorage& ts = getCurrentLayerTiles();
|
||||||
for(size_t i = 0; i < n; ++i)
|
for(size_t i = 0; i < n; ++i)
|
||||||
|
{
|
||||||
|
TileData& t = ts.tiles[selectedTiles[i]];
|
||||||
|
//allflags |= t.flags;
|
||||||
ts.tiles[selectedTiles[i]].flags ^= TILEFLAG_FV; // toggle bit
|
ts.tiles[selectedTiles[i]].flags ^= TILEFLAG_FV; // toggle bit
|
||||||
|
}
|
||||||
|
//if(allflags & TILEFLAG_MASK_SOLID)
|
||||||
|
// game->reconstructGrid(true, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this->placer->flipVertical();
|
this->placer->flipVertical();
|
||||||
|
|
|
@ -108,6 +108,8 @@ enum TileFlags
|
||||||
TILEFLAG_SELECTED = 0x100, // ephemeral: selected in editor
|
TILEFLAG_SELECTED = 0x100, // ephemeral: selected in editor
|
||||||
TILEFLAG_EDITOR_HIDDEN = 0x200, // tile is hidden for editor reasons. temporarily set when multi-selecting and moving. doesn't count as hidden externally and is only for rendering.
|
TILEFLAG_EDITOR_HIDDEN = 0x200, // tile is hidden for editor reasons. temporarily set when multi-selecting and moving. doesn't count as hidden externally and is only for rendering.
|
||||||
TILEFLAG_FV = 0x400, // flipped vertically
|
TILEFLAG_FV = 0x400, // flipped vertically
|
||||||
|
|
||||||
|
TILEFLAG_MASK_SOLID = TILEFLAG_SOLID | TILEFLAG_SOLID_IN | TILEFLAG_TRIM | TILEFLAG_HURT
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TileEffectData
|
struct TileEffectData
|
||||||
|
|
Loading…
Add table
Reference in a new issue