Add fading effects when moving to/from worldmap

Follow-up to #193
This commit is contained in:
Alexander Batalov 2022-12-30 00:41:29 +03:00
parent 07f3c82444
commit cc1562b056
1 changed files with 42 additions and 0 deletions

View File

@ -30,6 +30,7 @@
#include "memory.h" #include "memory.h"
#include "mouse.h" #include "mouse.h"
#include "object.h" #include "object.h"
#include "palette.h"
#include "party_member.h" #include "party_member.h"
#include "perk.h" #include "perk.h"
#include "proto_instance.h" #include "proto_instance.h"
@ -545,6 +546,9 @@ static int wmFreeTabsLabelList(int** quickDestinationsListPtr, int* quickDestina
static void wmRefreshInterfaceDial(bool shouldRefreshWindow); static void wmRefreshInterfaceDial(bool shouldRefreshWindow);
static void wmInterfaceDialSyncTime(bool shouldRefreshWindow); static void wmInterfaceDialSyncTime(bool shouldRefreshWindow);
static int wmAreaFindFirstValidMap(int* mapIdxPtr); static int wmAreaFindFirstValidMap(int* mapIdxPtr);
static void wmFadeOut();
static void wmFadeIn();
static void wmFadeReset();
// 0x4BC860 // 0x4BC860
static const int _can_rest_here[ELEVATION_COUNT] = { static const int _can_rest_here[ELEVATION_COUNT] = {
@ -814,6 +818,7 @@ static bool gTownMapHotkeysFix;
static double gGameTimeIncRemainder = 0.0; static double gGameTimeIncRemainder = 0.0;
static FrmImage _backgroundFrmImage; static FrmImage _backgroundFrmImage;
static FrmImage _townFrmImage; static FrmImage _townFrmImage;
static bool wmFaded = false;
static inline bool cityIsValid(int city) static inline bool cityIsValid(int city)
{ {
@ -2975,11 +2980,16 @@ static int wmWorldMapFunc(int a1)
{ {
ScopedGameMode gm(GameMode::kWorldmap); ScopedGameMode gm(GameMode::kWorldmap);
wmFadeOut();
if (wmInterfaceInit() == -1) { if (wmInterfaceInit() == -1) {
wmInterfaceExit(); wmInterfaceExit();
wmFadeReset();
return -1; return -1;
} }
wmFadeIn();
wmMatchWorldPosToArea(wmGenData.worldPosX, wmGenData.worldPosY, &(wmGenData.currentAreaId)); wmMatchWorldPosToArea(wmGenData.worldPosX, wmGenData.worldPosY, &(wmGenData.currentAreaId));
unsigned int v24 = 0; unsigned int v24 = 0;
@ -3103,6 +3113,8 @@ static int wmWorldMapFunc(int a1)
if (wmGenData.isInCar) { if (wmGenData.isInCar) {
wmMatchAreaContainingMapIdx(wmGenData.encounterMapId, &(wmGenData.currentCarAreaId)); wmMatchAreaContainingMapIdx(wmGenData.encounterMapId, &(wmGenData.currentCarAreaId));
} }
wmFadeOut();
mapLoadById(wmGenData.encounterMapId); mapLoadById(wmGenData.encounterMapId);
} }
break; break;
@ -3156,6 +3168,8 @@ static int wmWorldMapFunc(int a1)
wmGenData.currentCarAreaId = wmGenData.currentAreaId; wmGenData.currentCarAreaId = wmGenData.currentAreaId;
} }
} }
wmFadeOut();
mapLoadById(map); mapLoadById(map);
break; break;
} }
@ -3193,6 +3207,7 @@ static int wmWorldMapFunc(int a1)
wmMatchAreaContainingMapIdx(map, &(wmGenData.currentCarAreaId)); wmMatchAreaContainingMapIdx(map, &(wmGenData.currentCarAreaId));
} }
wmFadeOut();
mapLoadById(map); mapLoadById(map);
} }
} }
@ -3260,9 +3275,12 @@ static int wmWorldMapFunc(int a1)
} }
if (wmInterfaceExit() == -1) { if (wmInterfaceExit() == -1) {
wmFadeReset();
return -1; return -1;
} }
wmFadeIn();
return rc; return rc;
} }
@ -3370,6 +3388,8 @@ static int wmRndEncounterOccurred()
if (wmGenData.isInCar) { if (wmGenData.isInCar) {
wmMatchAreaContainingMapIdx(MAP_IN_GAME_MOVIE1, &(wmGenData.currentCarAreaId)); wmMatchAreaContainingMapIdx(MAP_IN_GAME_MOVIE1, &(wmGenData.currentCarAreaId));
} }
wmFadeOut();
mapLoadById(MAP_IN_GAME_MOVIE1); mapLoadById(MAP_IN_GAME_MOVIE1);
return 1; return 1;
} }
@ -6612,4 +6632,26 @@ int wmTeleportToArea(int areaIdx)
return 0; 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 } // namespace fallout