From 8cad58f0c4a0d9e56757877ddd164d947a8b74fd Mon Sep 17 00:00:00 2001 From: fgenesis Date: Sat, 13 Oct 2012 05:43:47 +0200 Subject: [PATCH] Implement new (optional) world map reveal method. This one doesn't give the whole map away already just after entering it. --- Aquaria/GridRender.h | 9 +++++++ Aquaria/WorldMapRender.cpp | 52 +++++++++++++++++++++++++++++++------- 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/Aquaria/GridRender.h b/Aquaria/GridRender.h index 52a2c2d..c6ed3be 100644 --- a/Aquaria/GridRender.h +++ b/Aquaria/GridRender.h @@ -67,6 +67,12 @@ protected: InterpolatedVector lerp; }; +enum WorldMapRevealMethod +{ + REVEAL_DEFAULT = 0, + REVEAL_PARTIAL = 1 // Not visited areas have zero alpha (invisible) +}; + class WorldMapRender : public RenderObject, public ActionMapper { public: @@ -86,6 +92,9 @@ public: void removeGem(GemMover *gemMover); void onToggleHelpScreen(); bool isCursorOffHud(); + + static void setRevealMethod(WorldMapRevealMethod m); + protected: Quad *addHintQuad1, *addHintQuad2; AquariaMenuItem *helpButton; diff --git a/Aquaria/WorldMapRender.cpp b/Aquaria/WorldMapRender.cpp index b49f2e6..b8d07c7 100644 --- a/Aquaria/WorldMapRender.cpp +++ b/Aquaria/WorldMapRender.cpp @@ -44,11 +44,12 @@ namespace WorldMapRenderNamespace enum VisMethod { - VIS_VERTEX = 0, - VIS_WRITE = 1 + VIS_VERTEX = 0, // Uses the RenderObject tile grid (RenderObject::setSegs()) to display visited areas + VIS_WRITE = 1 // Uses render-to-texture instead }; VisMethod visMethod = VIS_VERTEX; + WorldMapRevealMethod revMethod = REVEAL_DEFAULT; std::vector tiles; @@ -84,6 +85,23 @@ WorldMapTile *activeTile=0; const float beaconSpawnBitTime = 0.05; + +void WorldMapRender::setRevealMethod(WorldMapRevealMethod m) +{ + switch(m) + { + case REVEAL_PARTIAL: + revMethod = REVEAL_PARTIAL; + baseMapSegAlpha = 0; + break; + + default: + revMethod = REVEAL_DEFAULT; + baseMapSegAlpha = 0.4; + } +} + + class WorldMapBoundQuad : public Quad { public: @@ -731,8 +749,6 @@ WorldMapRender::WorldMapRender() : RenderObject(), ActionMapper() q->alphaMod = 0; tile->q = q; - - setProperTileColor(tile); q->setWidthHeight(q->getWidth()*tile->scale, q->getHeight()*tile->scale); q->scale = Vector(0.25f*tile->scale2, 0.25f*tile->scale2); @@ -740,10 +756,18 @@ WorldMapRender::WorldMapRender() : RenderObject(), ActionMapper() if (tile == activeTile) activeQuad = q; - if (activeQuad == q) + if (revMethod == REVEAL_PARTIAL || activeQuad == q) { setVis(tile); } + + setProperTileColor(tile); + + if(activeQuad == q) + { + activeTile->q->color = Vector(1,1,1); + activeTile->q->alphaMod = 1; + } addChild(q, PM_POINTER); @@ -861,7 +885,13 @@ void WorldMapRender::bindInput() void WorldMapRender::destroy() { - clearVis(activeTile); + //clearVis(activeTile); + for (int i = 0; i < dsq->continuity.worldMap.getNumWorldMapTiles(); i++) + { + WorldMapTile *tile = dsq->continuity.worldMap.getWorldMapTile(i); + clearVis(tile); + } + RenderObject::destroy(); delete[] savedTexData; } @@ -973,7 +1003,8 @@ void WorldMapRender::onUpdate(float dt) { if ((activeTile != selectedTile) && selectedTile->q) { - clearVis(activeTile); + if(revMethod == REVEAL_DEFAULT) + clearVis(activeTile); activeTile = selectedTile; activeQuad = activeTile->q; @@ -1428,8 +1459,11 @@ void WorldMapRender::toggle(bool turnON) { if (activeTile != originalActiveTile) { - clearVis(activeTile); - setVis(originalActiveTile); + if(revMethod == REVEAL_DEFAULT) + { + clearVis(activeTile); + setVis(originalActiveTile); + } activeTile = originalActiveTile; activeQuad = activeTile->q; }