diff --git a/Source/palette.cpp b/Source/palette.cpp index dccfdd095..e99c1c24a 100644 --- a/Source/palette.cpp +++ b/Source/palette.cpp @@ -167,7 +167,6 @@ void SetFadeLevel(DWORD fadeval) system_palette[i].peGreen = (fadeval * logical_palette[i].peGreen) >> 8; system_palette[i].peBlue = (fadeval * logical_palette[i].peBlue) >> 8; } - Sleep(3); palette_update(); // Workaround for flickering mouse in caves https://github.com/diasurgical/devilutionX/issues/7 @@ -185,7 +184,8 @@ void PaletteFadeIn(int fr) int i; ApplyGamma(logical_palette, orig_palette, 256); - for (i = 0; i < 256; i += fr) { + DWORD tc = SDL_GetTicks(); + for (i = 0; i < 256; i = (SDL_GetTicks() - tc) / 1.875) { // 1000ms / 60 * 32 SetFadeLevel(i); } SetFadeLevel(256); @@ -198,7 +198,8 @@ void PaletteFadeOut(int fr) int i; if (sgbFadedIn) { - for (i = 256; i > 0; i -= fr) { + DWORD tc = SDL_GetTicks(); + for (i = 256; i > 0; i = 256 - (SDL_GetTicks() - tc) / 1.875) { // 1000ms / 60 * 32 SetFadeLevel(i); } SetFadeLevel(0); diff --git a/SourceX/DiabloUI/diabloui.cpp b/SourceX/DiabloUI/diabloui.cpp index 10ba45ec8..565468809 100644 --- a/SourceX/DiabloUI/diabloui.cpp +++ b/SourceX/DiabloUI/diabloui.cpp @@ -500,12 +500,16 @@ void LoadBackgroundArt(const char *pszFile) ApplyGamma(logical_palette, orig_palette, 256); } -void UiFadeIn(int steps) +void UiFadeIn() { + static DWORD tc; + if (fadeValue == 0 && tc == 0) + tc = SDL_GetTicks(); if (fadeValue < 256) { - fadeValue += steps; + fadeValue = (SDL_GetTicks() - tc) / 1.875; // 1000ms / 60 * 32 if (fadeValue > 256) { fadeValue = 256; + tc = 0; } } diff --git a/SourceX/DiabloUI/diabloui.h b/SourceX/DiabloUI/diabloui.h index d1ec03ac8..c8d4a3b3f 100644 --- a/SourceX/DiabloUI/diabloui.h +++ b/SourceX/DiabloUI/diabloui.h @@ -39,7 +39,7 @@ constexpr size_t size(T (&)[N]) extern void (*gfnSoundFunction)(char *file); bool IsInsideRect(const SDL_Event &event, const SDL_Rect &rect); -void UiFadeIn(int steps = 16); +void UiFadeIn(); bool UiFocusNavigation(SDL_Event *event); bool UiItemMouseEvents(SDL_Event *event, UiItem *items, std::size_t size); int GetCenterOffset(int w, int bw = 0);