Skip to content

Commit

Permalink
Added "Parallax Layers Only" to Unaligned Viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
deathkiller committed Jan 7, 2024
1 parent 1ae02f0 commit 5b7710e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Sources/Jazz2/PreferencesCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions Sources/Jazz2/PreferencesCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ namespace Jazz2
static bool ShowPlayerTrails;
static bool LowGraphicsQuality;
static bool UnalignedViewport;
static bool UnalignedParallaxLayers;

// Gameplay
static bool EnableReforgedGameplay;
Expand Down Expand Up @@ -137,6 +138,7 @@ namespace Jazz2
ShowPlayerTrails = 0x08,
LowGraphicsQuality = 0x10,
UnalignedViewport = 0x20,
UnalignedParallaxLayers = 0x40,

EnableReforgedGameplay = 0x100,
EnableLedgeClimb = 0x200,
Expand Down
15 changes: 11 additions & 4 deletions Sources/Jazz2/Tiles/TileMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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: {
Expand All @@ -662,6 +668,7 @@ namespace Jazz2::Tiles
yt = progress
* ((layer.LayoutSize.Y * TileSet::DefaultTileSize) - HardcodedOffset)
+ loY;
yAlign = !PreferencesCache::UnalignedViewport && !PreferencesCache::UnalignedParallaxLayers;
break;
}
default:
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down
13 changes: 10 additions & 3 deletions Sources/Jazz2/UI/Menu/GraphicsOptionsSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5b7710e

Please sign in to comment.