Skip to content

Commit

Permalink
Add fading effects when moving to/from worldmap
Browse files Browse the repository at this point in the history
Follow-up to #193
  • Loading branch information
alexbatalov committed Dec 29, 2022
1 parent 07f3c82 commit cc1562b
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/worldmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "memory.h"
#include "mouse.h"
#include "object.h"
#include "palette.h"
#include "party_member.h"
#include "perk.h"
#include "proto_instance.h"
Expand Down Expand Up @@ -545,6 +546,9 @@ static int wmFreeTabsLabelList(int** quickDestinationsListPtr, int* quickDestina
static void wmRefreshInterfaceDial(bool shouldRefreshWindow);
static void wmInterfaceDialSyncTime(bool shouldRefreshWindow);
static int wmAreaFindFirstValidMap(int* mapIdxPtr);
static void wmFadeOut();
static void wmFadeIn();
static void wmFadeReset();

// 0x4BC860
static const int _can_rest_here[ELEVATION_COUNT] = {
Expand Down Expand Up @@ -814,6 +818,7 @@ static bool gTownMapHotkeysFix;
static double gGameTimeIncRemainder = 0.0;
static FrmImage _backgroundFrmImage;
static FrmImage _townFrmImage;
static bool wmFaded = false;

static inline bool cityIsValid(int city)
{
Expand Down Expand Up @@ -2975,11 +2980,16 @@ static int wmWorldMapFunc(int a1)
{
ScopedGameMode gm(GameMode::kWorldmap);

wmFadeOut();

if (wmInterfaceInit() == -1) {
wmInterfaceExit();
wmFadeReset();
return -1;
}

wmFadeIn();

wmMatchWorldPosToArea(wmGenData.worldPosX, wmGenData.worldPosY, &(wmGenData.currentAreaId));

unsigned int v24 = 0;
Expand Down Expand Up @@ -3103,6 +3113,8 @@ static int wmWorldMapFunc(int a1)
if (wmGenData.isInCar) {
wmMatchAreaContainingMapIdx(wmGenData.encounterMapId, &(wmGenData.currentCarAreaId));
}

wmFadeOut();
mapLoadById(wmGenData.encounterMapId);
}
break;
Expand Down Expand Up @@ -3156,6 +3168,8 @@ static int wmWorldMapFunc(int a1)
wmGenData.currentCarAreaId = wmGenData.currentAreaId;
}
}

wmFadeOut();
mapLoadById(map);
break;
}
Expand Down Expand Up @@ -3193,6 +3207,7 @@ static int wmWorldMapFunc(int a1)
wmMatchAreaContainingMapIdx(map, &(wmGenData.currentCarAreaId));
}

wmFadeOut();
mapLoadById(map);
}
}
Expand Down Expand Up @@ -3260,9 +3275,12 @@ static int wmWorldMapFunc(int a1)
}

if (wmInterfaceExit() == -1) {
wmFadeReset();
return -1;
}

wmFadeIn();

return rc;
}

Expand Down Expand Up @@ -3370,6 +3388,8 @@ static int wmRndEncounterOccurred()
if (wmGenData.isInCar) {
wmMatchAreaContainingMapIdx(MAP_IN_GAME_MOVIE1, &(wmGenData.currentCarAreaId));
}

wmFadeOut();
mapLoadById(MAP_IN_GAME_MOVIE1);
return 1;
}
Expand Down Expand Up @@ -6612,4 +6632,26 @@ int wmTeleportToArea(int areaIdx)
return 0;
}

void wmFadeOut()
{
if (!wmFaded) {
paletteFadeTo(gPaletteBlack);
wmFaded = true;
}
}

void wmFadeIn()
{
if (wmFaded) {
paletteFadeTo(_cmap);
wmFaded = false;
}
}

void wmFadeReset()
{
wmFaded = false;
paletteSetEntries(_cmap);
}

} // namespace fallout

0 comments on commit cc1562b

Please sign in to comment.