Author Topic: Any way to make your gals emit light on night missions?  (Read 32059 times)

Offline Arthanor

  • Commander
  • *****
  • Posts: 2488
  • XCom Armoury Quartermaster
    • View Profile
Re: Any way to make your gals emit light on night missions?
« Reply #30 on: September 02, 2016, 12:45:24 am »
Yes, unfortunately you can't just map each row to the black and white row and call it done, their brightness differs a lot. That being said, it should be possible to go for "closest brightness on the grayscale"?

As we see from rezaf, you can get such a darkening that everything goes to black. An alternative to grayscale would be to prevent whatever code does the darkening from going more than X colors away from the "full light" color. I think darkening is done by just sliding down towards the dark end of the palette for a given row by a set amount for all colors and displaying that color instead? If you limit how much sliding is done (let's say a maximum of 10 indices, instead of sliding all the way to black), the brightest colors would retain some color instead of being slid all the way to black like the darker colors.  Doing this, it would essentially cap how dark the battlescape gets and there would be some color and contrast instead of the whole thing being black.

Offline Eddie

  • Commander
  • *****
  • Posts: 560
    • View Profile
Re: Any way to make your gals emit light on night missions?
« Reply #31 on: September 02, 2016, 01:03:19 am »
That polar terrain is better visible in the dark indicates that something might be doable with recoloring the map blocks. Maybe brightness and contrast can be increased enough to make the terrain visible in darkness. Unfortunately this would change the day look of the map too. Can a script be used to change where the map block visuals are loaded from? Then you could have night mode version of each map with increased brightness and contrast to be loaded for night missions. But that might still look ugly when you have light sources...

Online Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: Any way to make your gals emit light on night missions?
« Reply #32 on: September 02, 2016, 01:24:00 am »
As Arthanor said this will not solve problem because if something is black it will stay black even if you use different color.

Overall coloring in engine work in this way:
a) Determine shade of tile, this is based on time of day all light sources. Value is from 0 - 15 (bright - dark).
b) Pixel in graphic have two parts, shade and color, both can have 16 values. Shade part of pixel represent similar range as tile shade.
c) For each pixel in tile graphic we take it shade and add tile shade to it, if value is greater that 15 and can't fit available range we change color of pixel to back and leave shade of this pixel at 15.

Easiest and more clean way is toy with a), Changing b) is impossible without new palettes. c) will need more work that a) but still doable.

Offline Arthanor

  • Commander
  • *****
  • Posts: 2488
  • XCom Armoury Quartermaster
    • View Profile
Re: Any way to make your gals emit light on night missions?
« Reply #33 on: September 02, 2016, 01:40:51 am »
Yankes, wouldn't just changing how the tile shade is determined for a given time of day by setting the darkest darkness a little less dark (say.. -3, like shade 12 instead of shade 15?) solve the issue. In fact, It would be awesome to have it as a graphic option:

Night shading offset: takes a value of 0 to 15, lets the user decide what they want at night. If you set it to 0, you recover the "always day" behavior. If you set it to 15, you get F*ing dark nights, and people could find the sweet spot they want.

Actually, that might not work.. changing the time of day illumination means that you actually make night into day wouldn't it? So units will start seeing as if it were day and it changes the actual battle?

Then it would have to be "c" if we want to only change the graphical display to the player without changing the battle mechanics.

Offline ivandogovich

  • Commander
  • *****
  • Posts: 2381
  • X-Com Afficionado
    • View Profile
    • Ivan Dogovich Youtube
Re: Any way to make your gals emit light on night missions?
« Reply #34 on: September 02, 2016, 01:59:25 am »
Or "C" and then reset all tiles to 14? instead of black?

Offline Arthanor

  • Commander
  • *****
  • Posts: 2488
  • XCom Armoury Quartermaster
    • View Profile
Re: Any way to make your gals emit light on night missions?
« Reply #35 on: September 02, 2016, 02:50:59 am »
I think bumping colors should be done for all colors, not just 15, otherwise you'll end up with colors than were darkened to 14 staying there, and colors that are supposed to be 15 going to 14, and it'll look weird.

Basically the current function is something like:

i = min( i0 + d, 15)

where i is the final shade index for the color, i0 is the original index of the picture and d is the darkening which depends on light level. It'd be neat to have:

i = max(min( i0 + d - b, 15), i0)

which would uniformly brighten colors, but only at the drawing stage, by a number b. This way, you get the brightest value between "corrected darkened color" and black, but cannot be brighter than the base color, of course. It could theoretically be a user option, where masochists ( :P ) can keep b = 0, people who want it to always look like day can use 15, and others can find their favorite setting somewhere in between. No more squinting at the dark and relying on alt to spot units unless you want to. And if it happens at drawing time but isn't included for LoS checks, it'd leave battles unchanged.

Offline Stoddard

  • Colonel
  • ****
  • Posts: 485
  • in a fey mood
    • View Profile
    • Linux builds & stuff
Re: Any way to make your gals emit light on night missions?
« Reply #36 on: September 02, 2016, 07:30:01 am »
Why so complicated?

https://vid.me/0YHL

Press alt a little longer and it all lights up. Release and it fades back.

Took all of two hours thinking of, coding, debugging, fighting with a screencapture program, uploading ...

Spoiler:
Code: [Select]
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);
 };
 
 }


EDIT: that "#include <cstdio>" shouldn't be there obviously
« Last Edit: September 02, 2016, 07:36:46 am by Stoddard »

Offline Dioxine

  • Commander
  • *****
  • Posts: 5412
  • punk not dead
    • View Profile
    • Nocturnal Productions
Re: Any way to make your gals emit light on night missions?
« Reply #37 on: September 02, 2016, 08:22:25 am »
Very nice! But doesn't allow unit spotting?

Offline Stoddard

  • Colonel
  • ****
  • Posts: 485
  • in a fey mood
    • View Profile
    • Linux builds & stuff
Re: Any way to make your gals emit light on night missions?
« Reply #38 on: September 02, 2016, 08:33:07 am »
It doesn't show anything that would not be seen if it was day.


EDIT: Ah, I misunderstood. It does not touch in-game lightning in any way. If units are dark, they stay dark to the AI or player for visibility calculations.

It's a low-level rendering hack so to say.
« Last Edit: September 02, 2016, 08:37:34 am by Stoddard »

Offline Dioxine

  • Commander
  • *****
  • Posts: 5412
  • punk not dead
    • View Profile
    • Nocturnal Productions
Re: Any way to make your gals emit light on night missions?
« Reply #39 on: September 02, 2016, 08:50:40 am »
This might be the solution we need then... If that hack could be applied to be toggle-able... and render in a single 16-color palette only (nightvision effect!)... Then we already have 'vision modes' UI.

Offline Stoddard

  • Colonel
  • ****
  • Posts: 485
  • in a fey mood
    • View Profile
    • Linux builds & stuff
Re: Any way to make your gals emit light on night missions?
« Reply #40 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:
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.


Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8596
    • View Profile
Re: Any way to make your gals emit light on night missions?
« Reply #41 on: September 02, 2016, 10:44:27 am »
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.

Heh, exactly what I was going to add:
- faster
- not all the way to max brightness (I'd go to min+6 for previous absolute darkness and max-4 for previous partial visibility)
- tab key is also not very good, cause in vanilla it selects a new unit... although that's the first hotkey I always change to something else :) I guess I'll make it configurable with default something like space, numpad0 or something similar

Offline Boltgun

  • Colonel
  • ****
  • Posts: 252
  • [UTTERANCES]
    • View Profile
    • Piratez let's play
Re: Any way to make your gals emit light on night missions?
« Reply #42 on: September 02, 2016, 10:50:09 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:
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.

That's really good, alt or ctrl is fine if it's a press and hold.

Offline Dioxine

  • Commander
  • *****
  • Posts: 5412
  • punk not dead
    • View Profile
    • Nocturnal Productions
Re: Any way to make your gals emit light on night missions?
« Reply #43 on: September 02, 2016, 10:56:05 am »
Maybe something logical instead, like + for example (as in "+ brightness") :)

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8596
    • View Profile
Re: Any way to make your gals emit light on night missions?
« Reply #44 on: September 02, 2016, 10:58:02 am »
That's really good, alt or ctrl is fine if it's a press and hold.

Alt, Ctrl and Shift are already taken for other things and I personally don't want to have increased brightness if I only want to instruct a soldier to run (with Ctrl).
So, Ctrl and Shift are no-gos for me... we could argue about Alt (I guess time will tell, for now I'll leave Alt for arrows only and a new hotkey for brightness).