From e941f473a5a53486869d1ef8c0a1235edc0e6c1b Mon Sep 17 00:00:00 2001 From: PercyDan54 <50285552+PercyDan54@users.noreply.github.com> Date: Fri, 9 Jun 2023 16:41:57 +0800 Subject: [PATCH] Adjust color to match osu --- AccuracyIndicator/Indicator/InGameIndicator.cs | 16 +++++++++------- AccuracyIndicator/Indicator/Utils.cs | 13 +++++++++---- AccuracyIndicator/Indicator/VictoryIndicator.cs | 6 +++--- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/AccuracyIndicator/Indicator/InGameIndicator.cs b/AccuracyIndicator/Indicator/InGameIndicator.cs index 09aa277..99646e1 100644 --- a/AccuracyIndicator/Indicator/InGameIndicator.cs +++ b/AccuracyIndicator/Indicator/InGameIndicator.cs @@ -18,6 +18,7 @@ public InGameIndicator(IntPtr intPtr) : base(intPtr) private readonly List _hitEntries = new(); private readonly List _hitReport = new(); private GameObject _canvas; + private RectTransform _centerIndicator; private RectTransform _arrowRt; private float _totalDelay; private int _totalHits; @@ -44,7 +45,7 @@ private void Start() // Ok : 0.1 = 280px // Perfect : 0.05 = 140px - Utils.CreateBars(_canvas, 0, DefaultY, 730, 280, 140); + _centerIndicator = Utils.CreateBars(_canvas, 0, DefaultY, 730, 280, 140).GetComponent(); var arrow = new GameObject("Arrow"); arrow.transform.SetParent(_canvas.transform); @@ -81,20 +82,21 @@ public void AddHit(float time) var color = time switch { - < 0.025f and > -0.025f => new Color(0, 0.73F, 0.83F), - < 0.05f and > -0.05f => new Color(0.29F, 0.68F, 0.31F), - _ => new Color(1f, 0.59F, 0) + < 0.025f and > -0.025f => Utils.ColorPerfect, + < 0.05f and > -0.05f => Utils.ColorAlmostPerfect, + _ => Utils.ColorGreat }; var hitIndicator = new GameObject("Hit"); hitIndicator.transform.SetParent(_canvas.transform); var hitRt = hitIndicator.AddComponent(); var hitRi = hitIndicator.AddComponent(); - hitRi.color = color; + hitRi.color = color.AlphaMultiplied(0.4f); hitRt.anchoredPosition = new Vector2(x, DefaultY); hitRt.sizeDelta = new Vector2(Utils.ConvertWidthFrom1920P(5), Utils.ConvertHeightFrom1080P(40)); _hitEntries.Add(new HitEntry(Time.time, time, hitIndicator, hitRi)); + _centerIndicator.SetAsLastSibling(); // -130 = 0 // -125 = 1 @@ -136,11 +138,11 @@ private void Update() float alpha; if (since < 2f) { - alpha = 1f; + alpha = 0.4f; } else { - alpha = 1f - (since - 2f) / 3f; + alpha = (1f - (since - 2f) / 3f) * 0.4f; } var color = hitEntry.RawImage.color; diff --git a/AccuracyIndicator/Indicator/Utils.cs b/AccuracyIndicator/Indicator/Utils.cs index 1a76882..21160e3 100644 --- a/AccuracyIndicator/Indicator/Utils.cs +++ b/AccuracyIndicator/Indicator/Utils.cs @@ -9,14 +9,18 @@ public static class Utils public static float ConvertWidthFrom1920P(float x) => x / 1920f * Screen.width; public static float ConvertHeightFrom1080P(float x) => x / 1080f * Screen.height; - public static void CreateBars(GameObject canvas, float x, float y, int greatBarWidth, int okBarWidth, int perfectBarWidth) + public static readonly Color ColorPerfect = new Color(0.2f, 0.74f, 0.91f); + public static readonly Color ColorAlmostPerfect = new Color(0.34f, 0.89f, 0.07f); + public static readonly Color ColorGreat = new Color(1, 0.59f, 0); + + public static GameObject CreateBars(GameObject canvas, float x, float y, int greatBarWidth, int okBarWidth, int perfectBarWidth) { var greatBar = new GameObject("GreatBar"); greatBar.transform.SetParent(canvas.transform); var greatRt = greatBar.AddComponent(); var greatRi = greatBar.AddComponent(); greatRt.anchoredPosition = new Vector2(x, y); - greatRi.color = new Color(1f, 0.59F, 0); + greatRi.color = ColorGreat; greatRt.sizeDelta = new Vector2(ConvertWidthFrom1920P(greatBarWidth), ConvertHeightFrom1080P(10)); var almostPerfectBar = new GameObject("AlmostPerfectBar"); @@ -24,7 +28,7 @@ public static void CreateBars(GameObject canvas, float x, float y, int greatBarW var almostPerfectRt = almostPerfectBar.AddComponent(); var almostPerfectRi = almostPerfectBar.AddComponent(); almostPerfectRt.anchoredPosition = new Vector2(x, y); - almostPerfectRi.color = new Color(0.29F, 0.68F, 0.31F); + almostPerfectRi.color = ColorAlmostPerfect; almostPerfectRt.sizeDelta = new Vector2(ConvertWidthFrom1920P(okBarWidth), ConvertHeightFrom1080P(10)); var perfectBar = new GameObject("PerfectBar"); @@ -32,7 +36,7 @@ public static void CreateBars(GameObject canvas, float x, float y, int greatBarW var perfectRt = perfectBar.AddComponent(); var perfectRi = perfectBar.AddComponent(); perfectRt.anchoredPosition = new Vector2(x, y); - perfectRi.color = new Color(0, 0.73F, 0.83F); + perfectRi.color = ColorPerfect; perfectRt.sizeDelta = new Vector2(ConvertWidthFrom1920P(perfectBarWidth), ConvertHeightFrom1080P(10)); var centerIndicator = new GameObject("CenterIndicator"); @@ -42,6 +46,7 @@ public static void CreateBars(GameObject canvas, float x, float y, int greatBarW centerRt.anchoredPosition = new Vector2(x, y); centerRi.color = new Color(1, 1, 1); centerRt.sizeDelta = new Vector2(ConvertWidthFrom1920P(3), ConvertHeightFrom1080P(50)); + return centerIndicator; } } \ No newline at end of file diff --git a/AccuracyIndicator/Indicator/VictoryIndicator.cs b/AccuracyIndicator/Indicator/VictoryIndicator.cs index 21fa6d2..c0d66ad 100644 --- a/AccuracyIndicator/Indicator/VictoryIndicator.cs +++ b/AccuracyIndicator/Indicator/VictoryIndicator.cs @@ -97,9 +97,9 @@ private void Render() ri.color = time switch { - < 0.025f and > -0.025f => new Color(0, 0.73F, 0.83F), - < 0.05f and > -0.05f => new Color(0.29F, 0.68F, 0.31F), - _ => new Color(1f, 0.59F, 0) + < 0.025f and > -0.025f => Utils.ColorPerfect.AlphaMultiplied(0.4f), + < 0.05f and > -0.05f => Utils.ColorAlmostPerfect.AlphaMultiplied(0.4f), + _ => Utils.ColorGreat.AlphaMultiplied(0.4f) }; var height = (int)(hits.Amount / (float)max * 300);