diff --git a/Aquaria/DSQ.cpp b/Aquaria/DSQ.cpp index e87b526..294c7eb 100644 --- a/Aquaria/DSQ.cpp +++ b/Aquaria/DSQ.cpp @@ -40,6 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "GLLoad.h" #include "RenderBase.h" #include "Image.h" +#include "TileRender.h" #include diff --git a/Aquaria/DSQ.h b/Aquaria/DSQ.h index f160db0..21024fb 100644 --- a/Aquaria/DSQ.h +++ b/Aquaria/DSQ.h @@ -458,6 +458,8 @@ public: void fixupJoysticks(); void initActionButtons(); void importActionButtons(); + + TileRender *tileRenders[MAX_TILE_LAYERS]; }; extern DSQ *dsq; diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index 7d7d748..f2966f3 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -2491,6 +2491,7 @@ void Game::applyState() { TileRender *tr = new TileRender(dsq->tilemgr.tilestore[i]); addRenderObject(tr, LR_ELEMENTS1 + i); + dsq->tileRenders[i] = tr; } for (int i = LR_ELEMENTS1; i <= LR_ELEMENTS12; i++) // LR_ELEMENTS13 is darkness, stop before that diff --git a/Aquaria/SceneEditor.cpp b/Aquaria/SceneEditor.cpp index c369b7b..1eaac2d 100644 --- a/Aquaria/SceneEditor.cpp +++ b/Aquaria/SceneEditor.cpp @@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "GridRender.h" #include "Shot.h" #include "Tile.h" - +#include "TileRender.h" #ifdef BBGE_BUILD_WINDOWS #define WIN32_LEAN_AND_MEAN @@ -1678,6 +1678,11 @@ void SceneEditor::setActiveLayer(unsigned bglayer) if(this->bgLayer == bglayer) return; + for(size_t i = 0; i < MAX_TILE_LAYERS; ++i) + dsq->tileRenders[i]->renderBorders = false; + + dsq->tileRenders[bglayer]->renderBorders = true; + destroyMultiTileHelper(); clearSelection(); this->bgLayer = bglayer; @@ -1697,12 +1702,14 @@ void SceneEditor::action(int id, int state, int source, InputDevice device) if(editType == ET_ELEMENTS) { + bool change = true; if(size_t N = selectedTiles.size()) { TileStorage& ts = getCurrentLayerTiles(); if (core->getCtrlState()) { + change = false; if (id == ACTION_BGLAYEREND) { ts.setEffect(dsq->tilemgr.tileEffects, -1, &selectedTiles[0], N); @@ -1728,13 +1735,13 @@ void SceneEditor::action(int id, int state, int source, InputDevice device) for(size_t i = 0; i < N; ++i) selectedTiles.push_back(idx + i); //ts.changeFlags(TILEFLAG_SELECTED, 0, &selectedTiles[0], N); // they still have that flag + change = false; } } - - setActiveLayer(newLayer); - } } + if(change) + setActiveLayer(newLayer); } } @@ -2257,6 +2264,7 @@ void SceneEditor::toggle(bool on) { btnMenu->alpha = 1; dsq->getRenderObjectLayer(LR_BLACKGROUND)->update = true; + dsq->tileRenders[bgLayer]->renderBorders = true; game->togglePause(on); if (game->avatar) @@ -2294,6 +2302,7 @@ void SceneEditor::toggle(bool on) movingEntity = 0; dsq->getRenderObjectLayer(LR_BLACKGROUND)->update = false; + dsq->tileRenders[bgLayer]->renderBorders = false; game->togglePause(on); if (game->avatar) @@ -2408,10 +2417,18 @@ void SceneEditor::update(float dt) int sel = -1; if (state == ES_SELECTING && !ismulti) { - selectedTiles.clear(); sel = this->getTileAtCursor(); + //if(sel < 0 || (selectedTiles.size() == 1 && selectedTiles[0] != (size_t)sel)) + { + selectedTiles.clear(); + getCurrentLayerTiles().clearSelection(); + } if(sel >= 0) + { selectedTiles.push_back(sel); + const size_t idx = sel; + getCurrentLayerTiles().select(&idx, 1); + } } if (sel >= 0 || ismulti) diff --git a/BBGE/Tile.cpp b/BBGE/Tile.cpp index add8367..c91638e 100644 --- a/BBGE/Tile.cpp +++ b/BBGE/Tile.cpp @@ -217,6 +217,11 @@ void TileStorage::changeFlags(unsigned flagsToSet, unsigned flagsToUnset, const } } +void TileStorage::select(const size_t *indices, size_t n) +{ + changeFlags(TILEFLAG_SELECTED, 0, indices, n); +} + size_t TileStorage::cloneSome(const TileEffectStorage& effstore, const size_t* indices, size_t n) { const size_t ret = tiles.size(); // new starting index of clone tiles diff --git a/BBGE/Tile.h b/BBGE/Tile.h index 53a5937..0d3789f 100644 --- a/BBGE/Tile.h +++ b/BBGE/Tile.h @@ -239,6 +239,7 @@ public: void refreshAll(); // call this after changing properties or moving to front/back void destroyAll(); + void select(const size_t *indices, size_t n); void clearSelection(); struct Sizes diff --git a/BBGE/TileRender.cpp b/BBGE/TileRender.cpp index 18722f4..1179da8 100644 --- a/BBGE/TileRender.cpp +++ b/BBGE/TileRender.cpp @@ -172,6 +172,8 @@ void TileRender::onRender(const RenderState& rs) const lastTexId = 0; prevEff = ((TileEffectData*)NULL)+1; + rs.gpu.setBlend(BLEND_DEFAULT); + if(grid && RenderObject::renderCollisionShape) { grid->renderDebugPoints(rs);