From 5b7710e2acc5ab089850f20c7ff36dc24bd9458a Mon Sep 17 00:00:00 2001 From: Death Killer <884052+deathkiller@users.noreply.github.com> Date: Sun, 7 Jan 2024 14:07:52 +0100 Subject: [PATCH] Added "Parallax Layers Only" to Unaligned Viewport --- Sources/Jazz2/PreferencesCache.cpp | 3 +++ Sources/Jazz2/PreferencesCache.h | 2 ++ Sources/Jazz2/Tiles/TileMap.cpp | 15 +++++++++++---- Sources/Jazz2/UI/Menu/GraphicsOptionsSection.cpp | 13 ++++++++++--- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Sources/Jazz2/PreferencesCache.cpp b/Sources/Jazz2/PreferencesCache.cpp index ca595f29..7e51aa65 100644 --- a/Sources/Jazz2/PreferencesCache.cpp +++ b/Sources/Jazz2/PreferencesCache.cpp @@ -25,6 +25,7 @@ namespace Jazz2 bool PreferencesCache::ShowPlayerTrails = true; bool PreferencesCache::LowGraphicsQuality = false; bool PreferencesCache::UnalignedViewport = false; + bool PreferencesCache::UnalignedParallaxLayers = false; bool PreferencesCache::EnableReforgedGameplay = true; bool PreferencesCache::EnableReforgedHUD = true; bool PreferencesCache::EnableReforgedMainMenu = true; @@ -154,6 +155,7 @@ namespace Jazz2 ShowPlayerTrails = ((boolOptions & BoolOptions::ShowPlayerTrails) == BoolOptions::ShowPlayerTrails); LowGraphicsQuality = ((boolOptions & BoolOptions::LowGraphicsQuality) == BoolOptions::LowGraphicsQuality); UnalignedViewport = ((boolOptions & BoolOptions::UnalignedViewport) == BoolOptions::UnalignedViewport); + UnalignedParallaxLayers = ((boolOptions & BoolOptions::UnalignedParallaxLayers) == BoolOptions::UnalignedParallaxLayers); EnableReforgedGameplay = ((boolOptions & BoolOptions::EnableReforgedGameplay) == BoolOptions::EnableReforgedGameplay); EnableLedgeClimb = ((boolOptions & BoolOptions::EnableLedgeClimb) == BoolOptions::EnableLedgeClimb); WeaponWheel = ((boolOptions & BoolOptions::EnableWeaponWheel) == BoolOptions::EnableWeaponWheel ? WeaponWheelStyle::Enabled : WeaponWheelStyle::Disabled); @@ -341,6 +343,7 @@ namespace Jazz2 if (ShowPlayerTrails) boolOptions |= BoolOptions::ShowPlayerTrails; if (LowGraphicsQuality) boolOptions |= BoolOptions::LowGraphicsQuality; if (UnalignedViewport) boolOptions |= BoolOptions::UnalignedViewport; + if (UnalignedParallaxLayers) boolOptions |= BoolOptions::UnalignedParallaxLayers; if (EnableReforgedGameplay) boolOptions |= BoolOptions::EnableReforgedGameplay; if (EnableLedgeClimb) boolOptions |= BoolOptions::EnableLedgeClimb; if (WeaponWheel != WeaponWheelStyle::Disabled) boolOptions |= BoolOptions::EnableWeaponWheel; diff --git a/Sources/Jazz2/PreferencesCache.h b/Sources/Jazz2/PreferencesCache.h index fe576069..48d70170 100644 --- a/Sources/Jazz2/PreferencesCache.h +++ b/Sources/Jazz2/PreferencesCache.h @@ -93,6 +93,7 @@ namespace Jazz2 static bool ShowPlayerTrails; static bool LowGraphicsQuality; static bool UnalignedViewport; + static bool UnalignedParallaxLayers; // Gameplay static bool EnableReforgedGameplay; @@ -137,6 +138,7 @@ namespace Jazz2 ShowPlayerTrails = 0x08, LowGraphicsQuality = 0x10, UnalignedViewport = 0x20, + UnalignedParallaxLayers = 0x40, EnableReforgedGameplay = 0x100, EnableLedgeClimb = 0x200, diff --git a/Sources/Jazz2/Tiles/TileMap.cpp b/Sources/Jazz2/Tiles/TileMap.cpp index df67af42..9c3fa49d 100644 --- a/Sources/Jazz2/Tiles/TileMap.cpp +++ b/Sources/Jazz2/Tiles/TileMap.cpp @@ -617,16 +617,18 @@ namespace Jazz2::Tiles constexpr float PerspectiveSpeedY = 0.16f; RenderTexturedBackground(renderQueue, layer, x1 * PerspectiveSpeedX + loX, y1 * PerspectiveSpeedY + loY); } else { - float xt, yt; + float xt, yt; bool xAlign, yAlign; switch (layer.Description.SpeedModelX) { case LayerSpeedModel::AlwaysOnTop: xt = -HardcodedOffset; + xAlign = false; break; case LayerSpeedModel::FitLevel: { float progress = (float)viewCenter.X / (_layers[_sprLayerIndex].LayoutSize.X * TileSet::DefaultTileSize); xt = std::clamp(progress, 0.0f, 1.0f) * ((layer.LayoutSize.X * TileSet::DefaultTileSize) - viewSize.X + HardcodedOffset) + loX; + xAlign = !PreferencesCache::UnalignedViewport && !PreferencesCache::UnalignedParallaxLayers; break; } case LayerSpeedModel::SpeedMultipliers: { @@ -637,21 +639,25 @@ namespace Jazz2::Tiles xt = progress * ((layer.LayoutSize.X * TileSet::DefaultTileSize) - HardcodedOffset) + loX; + xAlign = !PreferencesCache::UnalignedViewport && !PreferencesCache::UnalignedParallaxLayers; break; } default: xt = TranslateCoordinate(x1, layer.Description.SpeedX, loX, viewSize.X, false); + xAlign = !PreferencesCache::UnalignedViewport && (!PreferencesCache::UnalignedParallaxLayers || layer.Description.SpeedX == 1.0f); break; } switch (layer.Description.SpeedModelY) { case LayerSpeedModel::AlwaysOnTop: yt = -HardcodedOffset; + yAlign = false; break; case LayerSpeedModel::FitLevel: { float progress = (float)viewCenter.Y / (_layers[_sprLayerIndex].LayoutSize.Y * TileSet::DefaultTileSize); yt = std::clamp(progress, 0.0f, 1.0f) * ((layer.LayoutSize.Y * TileSet::DefaultTileSize) - viewSize.Y + HardcodedOffset) + loY; + yAlign = !PreferencesCache::UnalignedViewport && !PreferencesCache::UnalignedParallaxLayers; break; } case LayerSpeedModel::SpeedMultipliers: { @@ -662,6 +668,7 @@ namespace Jazz2::Tiles yt = progress * ((layer.LayoutSize.Y * TileSet::DefaultTileSize) - HardcodedOffset) + loY; + yAlign = !PreferencesCache::UnalignedViewport && !PreferencesCache::UnalignedParallaxLayers; break; } default: @@ -673,6 +680,7 @@ namespace Jazz2::Tiles }*/ yt = TranslateCoordinate(y1, layer.Description.SpeedY, loY, viewSize.Y, true); + yAlign = !PreferencesCache::UnalignedViewport && (!PreferencesCache::UnalignedParallaxLayers || layer.Description.SpeedY == 1.0f); break; } @@ -779,9 +787,8 @@ namespace Jazz2::Tiles instanceBlock->uniform(Material::ColorUniformName)->setFloatVector(color.Data()); float x2r = x2, y2r = y2; - if (!PreferencesCache::UnalignedViewport) { - x2r = std::floor(x2r); y2r = std::floor(y2r); - } + if (xAlign) x2r = std::floor(x2r); + if (yAlign) y2r = std::floor(y2r); command->setTransformation(Matrix4x4f::Translation(x2r, y2r, 0.0f)); command->setLayer(layer.Description.Depth); diff --git a/Sources/Jazz2/UI/Menu/GraphicsOptionsSection.cpp b/Sources/Jazz2/UI/Menu/GraphicsOptionsSection.cpp index 85155273..789b711c 100644 --- a/Sources/Jazz2/UI/Menu/GraphicsOptionsSection.cpp +++ b/Sources/Jazz2/UI/Menu/GraphicsOptionsSection.cpp @@ -109,9 +109,9 @@ namespace Jazz2::UI::Menu case GraphicsOptionsItemType::Fullscreen: enabled = PreferencesCache::EnableFullscreen; break; #endif case GraphicsOptionsItemType::Antialiasing: enabled = (PreferencesCache::ActiveRescaleMode & RescaleMode::UseAntialiasing) == RescaleMode::UseAntialiasing; break; - case GraphicsOptionsItemType::LowGraphicsQuality: enabled = PreferencesCache::LowGraphicsQuality; customText = (enabled ? _("Low") : _("High")); break; + case GraphicsOptionsItemType::LowGraphicsQuality: customText = (enabled ? _("Low") : _("High")); break; case GraphicsOptionsItemType::ShowPlayerTrails: enabled = PreferencesCache::ShowPlayerTrails; break; - case GraphicsOptionsItemType::UnalignedViewport: enabled = PreferencesCache::UnalignedViewport; break; + case GraphicsOptionsItemType::UnalignedViewport: customText = (PreferencesCache::UnalignedViewport ? _("Enabled") : (PreferencesCache::UnalignedParallaxLayers ? _("Parallax Layers Only") : _("Disabled"))); break; case GraphicsOptionsItemType::KeepAspectRatioInCinematics: enabled = PreferencesCache::KeepAspectRatioInCinematics; break; case GraphicsOptionsItemType::ShowPerformanceMetrics: enabled = PreferencesCache::ShowPerformanceMetrics; break; } @@ -175,7 +175,14 @@ namespace Jazz2::UI::Menu _root->PlaySfx("MenuSelect"_s, 0.6f); break; case GraphicsOptionsItemType::UnalignedViewport: - PreferencesCache::UnalignedViewport = !PreferencesCache::UnalignedViewport; + if (PreferencesCache::UnalignedViewport) { + PreferencesCache::UnalignedViewport = false; + PreferencesCache::UnalignedParallaxLayers = true; + } else if (PreferencesCache::UnalignedParallaxLayers) { + PreferencesCache::UnalignedParallaxLayers = false; + } else { + PreferencesCache::UnalignedViewport = true; + } _isDirty = true; _animation = 0.0f; _root->PlaySfx("MenuSelect"_s, 0.6f);