Skip to content

Commit

Permalink
Customizable Highway Presets (#905)
Browse files Browse the repository at this point in the history
* WIP Rebuild of Active Players List PR for engine-refactor

* Rebuilt ActivePlayerList and ActivePlayerListItem components. Added these to the Status Bar

* Update Instrument icon on Active Players List when changing a profile's GameMode, or when choosing an instrument in the Diffisulty Select Menu.

* WIP Attempt to add star power glow to Color Presets

* Fix one type mismatch

* WIP adding color preset option for star power glow colour on note highways

* Update YARG.Core

* Implemented Star Power colour and Groove colours to ColorProfiles
Introduced new "Common" section for ColorProfiles
Star Power and Groove colours can now be customized or disabled using the above ColorProfile properties
Added "Boring" default color preset which hides Groove and Star Power glow effects.

* Update YARG.Core

* Added (non-groove) background colours to ColorProfile
Force Star Power and Groove on for FakeTrackPlayer

* Update YARG.Core

* Move highway colours to separate HighwayPreset class, and update usages
Update TrackPreviewBuilder to force Star Power and Groove on as needed
Added Highway Preset option to ProfileSidebar
Moved localization text to subkey

* Fixed Highway Preset changes not being applied on Profiles List screen

* Removed unused localization key.
Update YARG.Core

* Remove HighwayPreset from ReplayData

* Remove one unused parameter in ReplayData

* Removed TrackMaterial.Preset.Layer struct and simplified usage
Addressed PR feedback

* Update YARG.Core

* Update YARG.Core
  • Loading branch information
thomeval authored Nov 21, 2024
1 parent 4fb78d9 commit 9f0314a
Show file tree
Hide file tree
Showing 15 changed files with 631 additions and 65 deletions.
459 changes: 457 additions & 2 deletions Assets/Prefabs/Menu/ProfileList/ProfileListMenu.prefab

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Assets/Scenes/MenuScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,11 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: -47
objectReference: {fileID: 0}
- target: {fileID: 1660771025072783965, guid: 6814ad1b861f1fa4a93d6c5db38dee86,
type: 3}
propertyPath: m_OnValueChanged.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
value: YARG.Menu.ProfileList.ProfileSidebar, Assembly-CSharp
objectReference: {fileID: 0}
- target: {fileID: 1731608351740115684, guid: 6814ad1b861f1fa4a93d6c5db38dee86,
type: 3}
propertyPath: m_Name
Expand Down
14 changes: 11 additions & 3 deletions Assets/Script/Gameplay/Player/TrackPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
using YARG.Core.Audio;
using YARG.Core.Chart;
using YARG.Core.Engine;
using YARG.Core.Game;
using YARG.Core.Logging;
using YARG.Gameplay.HUD;
using YARG.Gameplay.Visuals;
using YARG.Helpers.Extensions;
using YARG.Player;
using YARG.Settings;
using YARG.Themes;
Expand Down Expand Up @@ -72,7 +74,10 @@ public abstract class TrackPlayer : BasePlayer
public virtual void Initialize(int index, YargPlayer player, SongChart chart, TrackView trackView,
StemMixer mixer, int? lastHighScore)
{
if (IsInitialized) return;
if (IsInitialized)
{
return;
}

Initialize(index, player, chart, lastHighScore);

Expand Down Expand Up @@ -162,7 +167,10 @@ public abstract class TrackPlayer<TEngine, TNote> : TrackPlayer
public override void Initialize(int index, YargPlayer player, SongChart chart, TrackView trackView,
StemMixer mixer, int? currentHighScore)
{
if (IsInitialized) return;
if (IsInitialized)
{
return;
}

base.Initialize(index, player, chart, trackView, mixer, currentHighScore);

Expand Down Expand Up @@ -210,7 +218,7 @@ protected virtual void FinishInitialization()
{
GameManager.BeatEventHandler.Subscribe(StarpowerBar.PulseBar);

TrackMaterial.Initialize(ZeroFadePosition, FadeSize);
TrackMaterial.Initialize(ZeroFadePosition, FadeSize, Player.HighwayPreset);
CameraPositioner.Initialize(Player.CameraPreset);
}

Expand Down
96 changes: 48 additions & 48 deletions Assets/Script/Gameplay/Visuals/TrackMaterial.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System;
using System.Collections.Generic;
using UnityEngine;
using YARG.Core.Game;
using YARG.Helpers.Extensions;
using YARG.Settings;

Expand All @@ -21,21 +22,40 @@ public class TrackMaterial : MonoBehaviour

private static readonly int _soloStateProperty = Shader.PropertyToID("_Solo_State");

private static readonly int _starPowerColorProperty = Shader.PropertyToID("_Starpower_Color");

public struct Preset
{
public struct Layer
public Color Layer1;
public Color Layer2;
public Color Layer3;
public Color Layer4;

public static Preset FromHighwayPreset(HighwayPreset preset, bool groove)
{
public Color Color;
}
if (groove)
{
return new Preset
{
Layer1 = preset.BackgroundGrooveBaseColor1.ToUnityColor(),
Layer2 = preset.BackgroundGrooveBaseColor2.ToUnityColor(),
Layer3 = preset.BackgroundGrooveBaseColor3.ToUnityColor(),
Layer4 = preset.BackgroundGroovePatternColor.ToUnityColor()
};
}

public Layer Layer1;
public Layer Layer2;
public Layer Layer3;
public Layer Layer4;
return new Preset
{
Layer1 = preset.BackgroundBaseColor1.ToUnityColor(),
Layer2 = preset.BackgroundBaseColor2.ToUnityColor(),
Layer3 = preset.BackgroundBaseColor3.ToUnityColor(),
Layer4 = preset.BackgroundPatternColor.ToUnityColor()
};
}
}

private static Preset _normalPreset;
private static Preset _groovePreset;
private Preset _normalPreset;
private Preset _groovePreset;

private float _grooveState;
private float GrooveState
Expand All @@ -46,13 +66,13 @@ private float GrooveState
_grooveState = value;

_material.SetColor(_layer1ColorProperty,
Color.Lerp(_normalPreset.Layer1.Color, _groovePreset.Layer1.Color, value));
Color.Lerp(_normalPreset.Layer1, _groovePreset.Layer1, value));
_material.SetColor(_layer2ColorProperty,
Color.Lerp(_normalPreset.Layer2.Color, _groovePreset.Layer2.Color, value));
Color.Lerp(_normalPreset.Layer2, _groovePreset.Layer2, value));
_material.SetColor(_layer3ColorProperty,
Color.Lerp(_normalPreset.Layer3.Color, _groovePreset.Layer3.Color, value));
Color.Lerp(_normalPreset.Layer3, _groovePreset.Layer3, value));
_material.SetColor(_layer4ColorProperty,
Color.Lerp(_normalPreset.Layer4.Color, _groovePreset.Layer4.Color, value));
Color.Lerp(_normalPreset.Layer4, _groovePreset.Layer4, value));

_material.SetFloat(_wavinessProperty, value);
}
Expand Down Expand Up @@ -104,56 +124,36 @@ private void Awake()
{
_trimMaterials.Add(trim.material);
}

_normalPreset = new()
{
Layer1 = new()
{
Color = FromHex("0F0F0F", 1f)
},
Layer2 = new()
{
Color = FromHex("4B4B4B", 0.15f)
},
Layer3 = new()
{
Color = FromHex("FFFFFF", 0f)
},
Layer4 = new()
{
Color = FromHex("575757", 1f)
}
Layer1 = FromHex("0F0F0F", 1f),
Layer2 = FromHex("4B4B4B", 0.15f),
Layer3 = FromHex("FFFFFF", 0f),
Layer4 = FromHex("575757", 1f)
};

_groovePreset = new()
{
Layer1 = new()
{
Color = FromHex("000933", 1f)
},
Layer2 = new()
{
Color = FromHex("23349C", 0.15f)
},
Layer3 = new()
{
Color = FromHex("FFFFFF", 0f)
},
Layer4 = new()
{
Color = FromHex("2C499E", 1f)
}
Layer1 = FromHex("000933", 1f),
Layer2 = FromHex("23349C", 0.15f),
Layer3 = FromHex("FFFFFF", 0f),
Layer4 = FromHex("2C499E", 1f)
};
}

public void Initialize(float fadePos, float fadeSize)
public void Initialize(float fadePos, float fadeSize, HighwayPreset highwayPreset)
{
// Set all fade values
_material.SetFade(fadePos, fadeSize);
foreach (var trimMat in _trimMaterials)
{
trimMat.SetFade(fadePos, fadeSize);
}

_material.SetColor(_starPowerColorProperty, highwayPreset.StarPowerColor.ToUnityColor() );
_normalPreset = Preset.FromHighwayPreset(highwayPreset, false);
_groovePreset = Preset.FromHighwayPreset(highwayPreset, true);
}

private void Update()
Expand Down
15 changes: 14 additions & 1 deletion Assets/Script/Menu/ProfileList/ProfileSidebar.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
Expand Down Expand Up @@ -63,6 +63,8 @@ public class ProfileSidebar : MonoBehaviour
private TMP_Dropdown _colorProfileDropdown;
[SerializeField]
private TMP_Dropdown _cameraPresetDropdown;
[SerializeField]
private TMP_Dropdown _highwayPresetDropdown;

[Space]
[SerializeField]
Expand All @@ -89,6 +91,7 @@ public class ProfileSidebar : MonoBehaviour
private List<Guid> _colorProfilesByIndex;
private List<Guid> _cameraPresetsByIndex;
private List<Guid> _themesByIndex;
private List<Guid> _highwayPresetsByIndex;

private void Awake()
{
Expand Down Expand Up @@ -120,6 +123,9 @@ private void OnEnable()
_cameraPresetsByIndex =
CustomContentManager.CameraSettings.AddOptionsToDropdown(_cameraPresetDropdown)
.Select(i => i.Id).ToList();
_highwayPresetsByIndex =
CustomContentManager.HighwayPresets.AddOptionsToDropdown(_highwayPresetDropdown)
.Select(i => i.Id).ToList();
}

public void UpdateSidebar(YargProfile profile, ProfileView profileView)
Expand Down Expand Up @@ -152,6 +158,8 @@ public void UpdateSidebar(YargProfile profile, ProfileView profileView)
_colorProfilesByIndex.IndexOf(profile.ColorProfile));
_cameraPresetDropdown.SetValueWithoutNotify(
_cameraPresetsByIndex.IndexOf(profile.CameraPreset));
_highwayPresetDropdown.SetValueWithoutNotify(
_highwayPresetsByIndex.IndexOf(profile.HighwayPreset));

// Show the proper name container (hide the editing version)
_nameContainer.SetActive(true);
Expand Down Expand Up @@ -328,5 +336,10 @@ public void ChangeCameraPreset()
{
_profile.CameraPreset = _cameraPresetsByIndex[_cameraPresetDropdown.value];
}

public void ChangeHighwayPreset()
{
_profile.HighwayPreset = _highwayPresetsByIndex[_highwayPresetDropdown.value];
}
}
}
18 changes: 14 additions & 4 deletions Assets/Script/Player/YargPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ public class YargPlayer : IDisposable
public bool InputsEnabled { get; private set; }
public ProfileBindings Bindings { get; private set; }

public EnginePreset EnginePreset { get; private set; }
public ThemePreset ThemePreset { get; private set; }
public ColorProfile ColorProfile { get; private set; }
public CameraPreset CameraPreset { get; private set; }
public EnginePreset EnginePreset { get; private set; }
public ThemePreset ThemePreset { get; private set; }
public ColorProfile ColorProfile { get; private set; }
public CameraPreset CameraPreset { get; private set; }
public HighwayPreset HighwayPreset { get; private set; }

/// <summary>
/// Overrides the engine parameters in the gameplay player.
Expand Down Expand Up @@ -57,6 +58,9 @@ public YargPlayer(ReplayFrame frame, ReplayData replay)
CameraPreset = replay.GetCameraPreset(Profile.CameraPreset)
?? CustomContentManager.CameraSettings.GetPresetById(Profile.CameraPreset)
?? CameraPreset.Default;

HighwayPreset = CustomContentManager.HighwayPresets.GetPresetById(Profile.HighwayPreset)
?? HighwayPreset.Default;
}

public void SwapToProfile(YargProfile profile, ProfileBindings bindings, bool resolveDevices)
Expand Down Expand Up @@ -93,12 +97,16 @@ public void RefreshPresets()
?? ColorProfile.Default;
CameraPreset = CustomContentManager.CameraSettings.GetPresetById(Profile.CameraPreset)
?? CameraPreset.Default;
HighwayPreset = CustomContentManager.HighwayPresets.GetPresetById(Profile.HighwayPreset)
?? HighwayPreset.Default;
}

public void EnableInputs()
{
if (InputsEnabled || Bindings == null)
{
return;
}

Bindings.EnableInputs();
Bindings.MenuInputProcessed += OnMenuInput;
Expand All @@ -110,7 +118,9 @@ public void EnableInputs()
public void DisableInputs()
{
if (!InputsEnabled || Bindings == null)
{
return;
}

Bindings.DisableInputs();
Bindings.MenuInputProcessed -= OnMenuInput;
Expand Down
7 changes: 5 additions & 2 deletions Assets/Script/Settings/Customization/CustomContentManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using YARG.Core.Logging;
Expand All @@ -16,6 +16,7 @@ public static class CustomContentManager
public static readonly CameraSettingsContainer CameraSettings;
public static readonly ThemePresetContainer ThemePresets;
public static readonly EnginePresetContainer EnginePresets;
public static readonly HighwayPresetContainer HighwayPresets;

private static readonly List<CustomContent> _customContentContainers;
public static IReadOnlyList<CustomContent> CustomContentContainers => _customContentContainers;
Expand All @@ -26,13 +27,15 @@ static CustomContentManager()
ColorProfiles = new ColorProfileContainer();
ThemePresets = new ThemePresetContainer();
EnginePresets = new EnginePresetContainer();
HighwayPresets = new HighwayPresetContainer();

_customContentContainers = new()
{
CameraSettings,
ColorProfiles,
ThemePresets,
EnginePresets
EnginePresets,
HighwayPresets
};
}

Expand Down
14 changes: 14 additions & 0 deletions Assets/Script/Settings/Customization/HighwayPresetContainer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Collections.Generic;
using YARG.Core.Game;

namespace YARG.Settings.Customization
{
public class HighwayPresetContainer : CustomContent<HighwayPreset>
{
protected override string ContentDirectory => "highwayPresets";

public override string PresetTypeStringName => "HighwayPreset";

public override IReadOnlyList<HighwayPreset> DefaultPresets => HighwayPreset.Defaults;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ public class TrackPreviewBuilder : IPreviewBuilder
public GameMode? StartingGameMode { get; set; }

private readonly bool _forceShowHitWindow;
private readonly bool _forceGroove;
private readonly bool _forceStarPower;

public TrackPreviewBuilder(bool forceShowHitWindow = false)
public TrackPreviewBuilder(bool forceShowHitWindow = false, bool forceGroove = false, bool forceStarPower = false)
{
_forceShowHitWindow = forceShowHitWindow;
_forceGroove = forceGroove;
_forceStarPower = forceStarPower;
}

public UniTask BuildPreviewWorld(Transform worldContainer)
Expand All @@ -35,6 +39,8 @@ public UniTask BuildPreviewWorld(Transform worldContainer)
var trackPreview = trackObj.GetComponentInChildren<FakeTrackPlayer>();

trackPreview.ForceShowHitWindow = _forceShowHitWindow;
trackPreview.ForceGroove = _forceGroove;
trackPreview.ForceStarPower = _forceStarPower;

// If null, just use the default value and skip setting it
if (StartingGameMode is not null)
Expand Down
Loading

0 comments on commit 9f0314a

Please sign in to comment.