Skip to content

Commit

Permalink
Fix chain links, use (more) proper shader for dots
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlackParrot committed Dec 25, 2024
1 parent 08ca87e commit 9e0d764
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 16 deletions.
3 changes: 3 additions & 0 deletions NoteTweaks/Configuration/PluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ internal class PluginConfig

public virtual float GlowIntensity { get; set; } = 1.0f;
public virtual float GlowScale { get; set; } = 1.0f;
public bool EnableChainDots { get; set; } = true;
public Vector2 ChainDotScale { get; set; } = Vector2.one;
public bool EnableChainDotGlow { get; set; } = true;
}
}
72 changes: 59 additions & 13 deletions NoteTweaks/Patches/NoteArrowPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ internal class NoteArrowPatch
private static Vector3 _initialPosition = Vector3.zero;
private static bool _initialDotPositionDidSet = false;
private static Vector3 _initialDotPosition = Vector3.zero;
private static bool _initialChainDotPositionDidSet = false;
private static Vector3 _initialChainDotPosition = Vector3.zero;

internal static void Postfix(ColorNoteVisuals __instance, ref MeshRenderer[] ____arrowMeshRenderers, ref MeshRenderer[] ____circleMeshRenderers)
{
Expand All @@ -114,9 +116,10 @@ internal static void Postfix(ColorNoteVisuals __instance, ref MeshRenderer[] ___
if (_replacementDotMaterial == null)
{
Plugin.Log.Info("Creating replacement dot material");
_replacementDotMaterial = new Material(Shader.Find("Standard"))
Material arrowMat = Resources.FindObjectsOfTypeAll<Material>().ToList().Find(x => x.name == "NoteArrowHD");
_replacementDotMaterial = new Material(arrowMat.shader)
{
color = new Color(1f, 1f, 1f, 0f)
color = new Color(1f, 1f, 1f, 1f)
};
}
if(_dotGlowMaterial == null) {
Expand Down Expand Up @@ -165,26 +168,54 @@ internal static void Postfix(ColorNoteVisuals __instance, ref MeshRenderer[] ___
}
}

bool isChainLink = __instance.GetComponent<BurstSliderGameNoteController>() != null;

foreach (MeshRenderer meshRenderer in ____circleMeshRenderers)
{
if (_dotGlowMesh == null)
{
_dotGlowMesh = meshRenderer.GetComponent<MeshFilter>().mesh;
}

Vector3 dotPosition;
Vector3 glowPosition;
Vector3 dotScale;
Vector3 glowScale;
if (isChainLink)
{
dotPosition = new Vector3(_initialChainDotPosition.x, _initialChainDotPosition.y, _initialChainDotPosition.z);
glowPosition = new Vector3(_initialChainDotPosition.x, _initialChainDotPosition.y, _initialChainDotPosition.z + 0.001f);
dotScale = new Vector3(Plugin.Config.ChainDotScale.x / 18f, Plugin.Config.ChainDotScale.y / 18f, 0.0001f);
glowScale = new Vector3((Plugin.Config.ChainDotScale.x / 6f) * Plugin.Config.GlowScale, (Plugin.Config.ChainDotScale.y / 6f) * Plugin.Config.GlowScale, 0.0001f);
}
else
{
dotPosition = new Vector3(_initialDotPosition.x + Plugin.Config.DotPosition.x, _initialDotPosition.y + Plugin.Config.DotPosition.y, _initialDotPosition.z);
glowPosition = new Vector3(_initialDotPosition.x + Plugin.Config.DotPosition.x, _initialDotPosition.y + Plugin.Config.DotPosition.y, _initialDotPosition.z + 0.001f);
dotScale = new Vector3(Plugin.Config.DotScale.x / 5f, Plugin.Config.DotScale.y / 5f, 0.0001f);
glowScale = new Vector3((Plugin.Config.DotScale.x / 1.5f) * Plugin.Config.GlowScale, (Plugin.Config.DotScale.y / 1.5f) * Plugin.Config.GlowScale, 0.0001f);
}

Vector3 dotPosition = new Vector3(_initialDotPosition.x + Plugin.Config.DotPosition.x, _initialDotPosition.y + Plugin.Config.DotPosition.y, _initialDotPosition.z - 0.1f);
Vector3 glowPosition = new Vector3(_initialDotPosition.x + Plugin.Config.DotPosition.x, _initialDotPosition.y + Plugin.Config.DotPosition.y, _initialDotPosition.z - 0.101f);
Vector3 dotScale = new Vector3(Plugin.Config.DotScale.x / 5f, Plugin.Config.DotScale.y / 5f, 0.0001f);
Vector3 glowScale = new Vector3((Plugin.Config.DotScale.x / 1.5f) * Plugin.Config.GlowScale, (Plugin.Config.DotScale.y / 1.5f) * Plugin.Config.GlowScale, 0.0001f);

Transform originalDot = meshRenderer.transform.parent.Find("NoteCircleGlow");
Transform originalDot = isChainLink ? meshRenderer.transform.parent.Find("Circle") : meshRenderer.transform.parent.Find("NoteCircleGlow");
if (originalDot)
{
originalDot.gameObject.SetActive(Plugin.Config.EnableDots);
if (isChainLink)
{
originalDot.gameObject.SetActive(Plugin.Config.EnableChainDots);

if (!Plugin.Config.EnableDots)
if (!Plugin.Config.EnableChainDots)
{
continue;
}
}
else
{
continue;
originalDot.gameObject.SetActive(Plugin.Config.EnableDots);

if (!Plugin.Config.EnableDots)
{
continue;
}
}

Transform originalDotTransform = originalDot.transform;
Expand All @@ -194,6 +225,11 @@ internal static void Postfix(ColorNoteVisuals __instance, ref MeshRenderer[] ___
_initialDotPositionDidSet = true;
_initialDotPosition = originalDotTransform.localPosition;
}
if (!_initialChainDotPositionDidSet)
{
_initialChainDotPositionDidSet = true;
_initialChainDotPosition = originalDotTransform.localPosition;
}

originalDotTransform.localScale = dotScale;
originalDotTransform.localPosition = dotPosition;
Expand All @@ -208,9 +244,19 @@ internal static void Postfix(ColorNoteVisuals __instance, ref MeshRenderer[] ___
meshRenderer.material = _replacementDotMaterial;
meshRenderer.sharedMaterial = _replacementDotMaterial;

if (!Plugin.Config.EnableFaceGlow)
if (isChainLink)
{
if (!Plugin.Config.EnableChainDotGlow)
{
continue;
}
}
else
{
continue;
if (!Plugin.Config.EnableFaceGlow)
{
continue;
}
}

GameObject newGlowObject = Object.Instantiate(originalDot.gameObject, originalDot.parent).gameObject;
Expand Down
20 changes: 17 additions & 3 deletions NoteTweaks/UI/BSML/Settings.bsml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
<slider-setting apply-on-change="true" value="NoteScaleZ" text="Length Note Scale"
min="0.01" max="2.5" increment="0.01" show-buttons="true" formatter="PercentageFormatter"
hover-hint="Length scale (Z-axis) of notes"/>
<slider-setting apply-on-change="true" value="LinkScale" text="Chain Link Scale"
min="0.01" max="2.5" increment="0.01" show-buttons="true" formatter="PercentageFormatter"
hover-hint="Scale of chain links relative to note scale"/>

<horizontal><text text="-----" font-size="4" color="#00000000"/></horizontal>

Expand Down Expand Up @@ -65,6 +62,23 @@

<horizontal><text text="-----" font-size="4" color="#00000000"/></horizontal>

<slider-setting apply-on-change="true" value="LinkScale" text="Chain Link Scale"
min="0.01" max="2.5" increment="0.01" show-buttons="true" formatter="PercentageFormatter"
hover-hint="Scale of chain links relative to note scale"/>

<toggle-setting apply-on-change="true" value="EnableChainDots" text="Show Chain Dots"
hover-hint="Show dots on chain links"/>
<toggle-setting apply-on-change="true" value="EnableChainDotGlow" text="Enable Glowing Chain Dots"
hover-hint="Show glow around chain dots"/>
<slider-setting apply-on-change="true" value="ChainDotScaleX" text="Horizontal Chain Dot Scale"
min="0.05" max="5.0" increment="0.05" show-buttons="true" formatter="PercentageFormatter"
hover-hint="Horizontal scale (X-axis) of chain link dots"/>
<slider-setting apply-on-change="true" value="ChainDotScaleY" text="Vertical Chain Dot Scale"
min="0.05" max="2.0" increment="0.05" show-buttons="true" formatter="PercentageFormatter"
hover-hint="Vertical scale (Y-axis) of chain link dots"/>

<horizontal><text text="-----" font-size="4" color="#00000000"/></horizontal>

<slider-setting apply-on-change="true" value="ColorBoostLeft" text="Left Color Boost"
min="-0.95" max="3.0" increment="0.05" show-buttons="true" formatter="PercentageFormatter"
hover-hint="Boost left note colors beyond the normal clamping levels"/>
Expand Down
33 changes: 33 additions & 0 deletions NoteTweaks/UI/SettingsViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,38 @@ protected float GlowIntensity
get => _config.GlowIntensity;
set => _config.GlowIntensity = value;
}

protected bool EnableChainDots
{
get => _config.EnableChainDots;
set => _config.EnableChainDots = value;
}
protected float ChainDotScaleX
{
get => _config.ChainDotScale.x;
set
{
Vector3 scale = _config.ChainDotScale;
scale.x = value;
_config.ChainDotScale = scale;
}
}

protected float ChainDotScaleY
{
get => _config.ChainDotScale.y;
set
{
Vector3 scale = _config.ChainDotScale;
scale.y = value;
_config.ChainDotScale = scale;
}
}

protected bool EnableChainDotGlow
{
get => _config.EnableChainDotGlow;
set => _config.EnableChainDotGlow = value;
}
}
}

0 comments on commit 9e0d764

Please sign in to comment.