451
XPiratez / Re: Any way to make your gals emit light on night missions?
« on: September 02, 2016, 10:12:35 am »
After some playtesting ... slow transition to full brightness got annoying very fast, so I made it faster and limited to min shade 4, so that it doesn't ruin your night vision so much. And rebound it to tab key, so you can do useful things like walking while seeing where you in fact step.
https://vid.me/NFHm
I tried toggle mode and did not like it. In current form it ruins the night for me. Maybe with the palette hack it won't.
Cleaned up patch:
Can't make a windows binary, sorry for that.
https://vid.me/NFHm
I tried toggle mode and did not like it. In current form it ruins the night for me. Maybe with the palette hack it won't.
Cleaned up patch:
Spoiler:
Code: [Select]
diff --git a/src/Battlescape/Map.cpp b/src/Battlescape/Map.cpp
index ec64c89..52b9db6 100644
--- a/src/Battlescape/Map.cpp
+++ b/src/Battlescape/Map.cpp
@@ -108,6 +108,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 = 16;
_camera->setScrollTimer(_scrollMouseTimer, _scrollKeyTimer);
_txtAccuracy = new Text(24, 9, 0, 0);
@@ -124,6 +128,7 @@ Map::~Map()
{
delete _scrollMouseTimer;
delete _scrollKeyTimer;
+ delete _fadeTimer;
delete _arrow;
delete _message;
delete _camera;
@@ -174,6 +179,7 @@ void Map::think()
{
_scrollMouseTimer->think(0, this);
_scrollKeyTimer->think(0, this);
+ _fadeTimer->think(0, this);
}
/**
@@ -417,7 +423,7 @@ void Map::drawTerrain(Surface *surface)
if (tile->isDiscovered(2))
{
- tileShade = tile->getShade();
+ tileShade = reShade(tile->getShade());
}
else
{
@@ -469,7 +475,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 +514,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 +535,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 +569,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 +589,7 @@ void Map::drawTerrain(Surface *surface)
BattleUnit *westUnit = tileWest->getUnit();
if (tileWest->isDiscovered(2))
{
- tileWestShade = tileWest->getShade();
+ tileWestShade = reShade(tileWest->getShade());
}
else
{
@@ -595,7 +601,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 +611,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);
@@ -699,7 +705,7 @@ void Map::drawTerrain(Surface *surface)
{
if ((tile->getMapData(O_WESTWALL)->isDoor() || tile->getMapData(O_WESTWALL)->isUFODoor())
&& tile->isDiscovered(0))
- wallShade = tile->getShade();
+ wallShade = reShade(tile->getShade());
else
wallShade = tileShade;
tmpSurface->blitNShade(surface, screenPosition.x, screenPosition.y - tile->getMapData(O_WESTWALL)->getYOffset(), wallShade);
@@ -710,7 +716,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 +903,7 @@ void Map::drawTerrain(Surface *surface)
tunit, part,
offset.x,
offset.y,
- ttile->getShade()
+ reShade(ttile->getShade())
);
}
}
@@ -1325,6 +1331,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 +1642,28 @@ void Map::scrollKey()
}
/**
+ * Modify the fade shade level if fade's in progress.
+ */
+void Map::fadeShade()
+{
+ Uint8 *keystate = SDL_GetKeyState(NULL);
+ if (keystate[SDLK_TAB])
+ {
+ if (_fadeShade > 4)
+ {
+ --_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..33c3157 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 = 23;
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);
};
}
Can't make a windows binary, sorry for that.