diff --git a/src/Battlescape/Map.cpp b/src/Battlescape/Map.cpp
index ec64c89..b425d82 100644
--- a/src/Battlescape/Map.cpp
+++ b/src/Battlescape/Map.cpp
@@ -52,6 +52,7 @@
#include "../Interface/NumberText.h"
#include "../Interface/Text.h"
+#include <cstdio>
/*
1) Map origin is top corner.
@@ -108,6 +109,10 @@ Map::Map(Game *game, int width, int height, int x, int y, int visibleMapHeight)
_scrollMouseTimer->onTimer((SurfaceHandler)&Map::scrollMouse);
_scrollKeyTimer = new Timer(SCROLL_INTERVAL);
_scrollKeyTimer->onTimer((SurfaceHandler)&Map::scrollKey);
+ _fadeTimer = new Timer(FADE_INTERVAL);
+ _fadeTimer->onTimer((SurfaceHandler)&Map::fadeShade);
+ _fadeTimer->start();
+ _fadeShade = 15; https:// or _save->getGlobalShade();
_camera->setScrollTimer(_scrollMouseTimer, _scrollKeyTimer);
_txtAccuracy = new Text(24, 9, 0, 0);
@@ -124,6 +129,7 @@ Map::~Map()
{
delete _scrollMouseTimer;
delete _scrollKeyTimer;
+ delete _fadeTimer;
delete _arrow;
delete _message;
delete _camera;
@@ -174,6 +180,7 @@ void Map::think()
{
_scrollMouseTimer->think(0, this);
_scrollKeyTimer->think(0, this);
+ _fadeTimer->think(0, this);
}
/**
@@ -417,7 +424,7 @@ void Map::drawTerrain(Surface *surface)
if (tile->isDiscovered(2))
{
- tileShade = tile->getShade();
+ tileShade = reShade(tile->getShade());
}
else
{
@@ -469,7 +476,7 @@ void Map::drawTerrain(Surface *surface)
int tileNorthShade, tileTwoNorthShade, tileWestShade, tileNorthWestShade, tileSouthWestShade;
if (tileNorth->isDiscovered(2))
{
- tileNorthShade = tileNorth->getShade();
+ tileNorthShade = reShade(tileNorth->getShade());
}
else
{
@@ -508,7 +515,7 @@ void Map::drawTerrain(Surface *surface)
Tile *tileTwoNorth = _save->getTile(mapPosition - Position(0,2,0));
if (tileTwoNorth->isDiscovered(2))
{
- tileTwoNorthShade = tileTwoNorth->getShade();
+ tileTwoNorthShade = reShade(tileTwoNorth->getShade());
}
else
{
@@ -529,7 +536,7 @@ void Map::drawTerrain(Surface *surface)
Tile *tileNorthWest = _save->getTile(mapPosition - Position(1,1,0));
if (tileNorthWest->isDiscovered(2))
{
- tileNorthWestShade = tileNorthWest->getShade();
+ tileNorthWestShade = reShade(tileNorthWest->getShade());
}
else
{
@@ -563,7 +570,7 @@ void Map::drawTerrain(Surface *surface)
Tile *tileSouthWest = _save->getTile(mapPosition + Position(-1, 1, 0));
if (tileSouthWest->isDiscovered(2))
{
- tileSouthWestShade = tileSouthWest->getShade();
+ tileSouthWestShade = reShade(tileSouthWest->getShade());
}
else
{
@@ -583,7 +590,7 @@ void Map::drawTerrain(Surface *surface)
BattleUnit *westUnit = tileWest->getUnit();
if (tileWest->isDiscovered(2))
{
- tileWestShade = tileWest->getShade();
+ tileWestShade = reShade(tileWest->getShade());
}
else
{
@@ -595,7 +602,7 @@ void Map::drawTerrain(Surface *surface)
{
if ((tileWest->getMapData(O_WESTWALL)->isDoor() || tileWest->getMapData(O_WESTWALL)->isUFODoor())
&& tileWest->isDiscovered(0))
- wallShade = tileWest->getShade();
+ wallShade = reShade(tileWest->getShade());
else
wallShade = tileWestShade;
tmpSurface->blitNShade(surface, screenPosition.x - tileOffset.x, screenPosition.y - tileWest->getMapData(O_WESTWALL)->getYOffset() + tileOffset.y, wallShade, true);
@@ -605,7 +612,7 @@ void Map::drawTerrain(Surface *surface)
{
if ((tileWest->getMapData(O_NORTHWALL)->isDoor() || tileWest->getMapData(O_NORTHWALL)->isUFODoor())
&& tileWest->isDiscovered(1))
- wallShade = tileWest->getShade();
+ wallShade = reShade(tileWest->getShade());
else
wallShade = tileWestShade;
tmpSurface->blitNShade(surface, screenPosition.x - tileOffset.x, screenPosition.y - tileWest->getMapData(O_NORTHWALL)->getYOffset() + tileOffset.y, wallShade, true);
@@ -677,7 +684,7 @@ void Map::drawTerrain(Surface *surface)
frameNumber += halfAnimFrame + tileWest->getAnimationOffset();
}
tmpSurface = _game->getMod()->getSurfaceSet("SMOKE.PCK")->getFrame(frameNumber);
- tmpSurface->blitNShade(surface, screenPosition.x - tileOffset.x, screenPosition.y + tileOffset.y, shade, true);
+ tmpSurface->blitNShade(surface, screenPosition.x - tileOffset.x, screenPosition.y + tileOffset.y, reShade(shade), true);
}
https:// Draw object
if (tileWest->getMapData(O_OBJECT) && tileWest->getMapData(O_OBJECT)->getBigWall() >= 6 && tileWest->getMapData(O_OBJECT)->getBigWall() != 9)
@@ -702,7 +709,7 @@ void Map::drawTerrain(Surface *surface)
wallShade = tile->getShade();
else
wallShade = tileShade;
- tmpSurface->blitNShade(surface, screenPosition.x, screenPosition.y - tile->getMapData(O_WESTWALL)->getYOffset(), wallShade);
+ tmpSurface->blitNShade(surface, screenPosition.x, screenPosition.y - tile->getMapData(O_WESTWALL)->getYOffset(), reShade(wallShade));
}
https:// Draw north wall
tmpSurface = tile->getSprite(O_NORTHWALL);
@@ -710,7 +717,7 @@ void Map::drawTerrain(Surface *surface)
{
if ((tile->getMapData(O_NORTHWALL)->isDoor() || tile->getMapData(O_NORTHWALL)->isUFODoor())
&& tile->isDiscovered(1))
- wallShade = tile->getShade();
+ wallShade = reShade(tile->getShade());
else
wallShade = tileShade;
if (tile->getMapData(O_WESTWALL))
@@ -897,7 +904,7 @@ void Map::drawTerrain(Surface *surface)
tunit, part,
offset.x,
offset.y,
- ttile->getShade()
+ reShade(ttile->getShade())
);
}
}
@@ -1325,6 +1332,16 @@ void Map::keyboardPress(Action *action, State *state)
}
/**
+ * Handles fade-in and fade-out on Alt key
+ * @param original tile/item/unit shade
+ */
+
+int Map::reShade(const int shade)
+{
+ return shade > _fadeShade ? _fadeShade : shade;
+}
+
+/**
* Handles keyboard releases on the map.
* @param action Pointer to an action.
* @param state State that the action handlers belong to.
@@ -1626,6 +1643,27 @@ void Map::scrollKey()
}
/**
+ * Modify the fade shade level if fade's in progress.
+ */
+void Map::fadeShade()
+{
+ if (((SDL_GetModState() & KMOD_ALT) != 0))
+ {
+ if (_fadeShade > 0)
+ {
+ --_fadeShade;
+ }
+ }
+ else
+ {
+ if (_fadeShade < _save->getGlobalShade())
+ {
+ ++_fadeShade;
+ }
+ }
+}
+
+/**
* Gets a list of waypoints on the map.
* @return A list of waypoints.
*/
diff --git a/src/Battlescape/Map.h b/src/Battlescape/Map.h
index ea2bd22..6a8eac5 100644
--- a/src/Battlescape/Map.h
+++ b/src/Battlescape/Map.h
@@ -46,8 +46,11 @@ class Map : public InteractiveSurface
{
private:
static const int SCROLL_INTERVAL = 15;
+ static const int FADE_INTERVAL = 222;
static const int BULLET_SPRITES = 35;
Timer *_scrollMouseTimer, *_scrollKeyTimer;
+ Timer *_fadeTimer;
+ int _fadeShade;
Game *_game;
SavedBattleGame *_save;
Surface *_arrow;
@@ -121,6 +124,8 @@ public:
void scrollMouse();
https:/// Keyboard-scrolls the camera.
void scrollKey();
+ https:/// fades in/out
+ void fadeShade();
https:/// Get waypoints vector.
std::vector<Position> *getWaypoints();
https:/// Set mouse-buttons' pressed state.
@@ -147,6 +152,8 @@ public:
void setBlastFlash(bool flash);
https:/// Check if the screen is flashing this.
bool getBlastFlash();
+ https:/// Modify shade for fading
+ int reShade(const int shade);
};
}