From 28670afbfc0935f8d6096aa2e08bb461953446f4 Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Mon, 23 Jun 2025 02:12:50 +0300 Subject: [PATCH 1/6] Update StrainVisualizer.cs --- .../Components/StrainVisualizer.cs | 143 ++++++++++-------- 1 file changed, 81 insertions(+), 62 deletions(-) diff --git a/PerformanceCalculatorGUI/Components/StrainVisualizer.cs b/PerformanceCalculatorGUI/Components/StrainVisualizer.cs index 0e34342f72..e7ebe7ae8a 100644 --- a/PerformanceCalculatorGUI/Components/StrainVisualizer.cs +++ b/PerformanceCalculatorGUI/Components/StrainVisualizer.cs @@ -4,8 +4,10 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; @@ -49,8 +51,6 @@ public StrainVisualizer() private void updateGraphs(ValueChangedEvent val) { - graphsContainer.Clear(); - var skills = val.NewValue.Where(x => x is StrainSkill or StrainDecaySkill).ToArray(); // dont bother if there are no strain skills to draw @@ -63,69 +63,93 @@ private void updateGraphs(ValueChangedEvent val) graphAlpha = Math.Min(1.5f / skills.Length, 0.9f); var strainLists = getStrainLists(skills); - addStrainBars(skills, strainLists); - addTooltipBars(strainLists); - if (val.OldValue == null || !val.NewValue.All(x => val.OldValue.Any(y => y.GetType().Name == x.GetType().Name))) + createStrainBars(skills, strainLists).ContinueWith((t) => Schedule(() => { - // skill list changed - recreate toggles - legendContainer.Clear(); - graphToggles.Clear(); + graphsContainer.Clear(); + addStrainBars(t.GetResultSafely(), skills, strainLists); + addTooltipBars(strainLists); - for (int i = 0; i < skills.Length; i++) + if (val.OldValue == null || !val.NewValue.All(x => val.OldValue.Any(y => y.GetType().Name == x.GetType().Name))) { - // this is ugly, but it works - var graphToggleBindable = new Bindable(); - int graphNum = i; - graphToggleBindable.BindValueChanged(state => - { - if (state.NewValue) - { - graphsContainer[graphNum].FadeTo(graphAlpha); - } - else - { - graphsContainer[graphNum].Hide(); - } - }); - graphToggles.Add(graphToggleBindable); + // skill list changed - recreate toggles + legendContainer.Clear(); + graphToggles.Clear(); - legendContainer.Add(new Container + for (int i = 0; i < skills.Length; i++) { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Masking = true, - CornerRadius = 10, - AutoSizeAxes = Axes.Both, - Children = new Drawable[] + // this is ugly, but it works + var graphToggleBindable = new Bindable(); + int graphNum = i; + graphToggleBindable.BindValueChanged(state => { - new Box + if (state.NewValue) { - RelativeSizeAxes = Axes.Both, - Colour = colourProvider.Background5 - }, - new ExtendedOsuCheckbox + graphsContainer[graphNum].FadeTo(graphAlpha); + } + else { - Padding = new MarginPadding(10), - RelativeSizeAxes = Axes.None, - Width = 200, - Current = { BindTarget = graphToggleBindable, Default = true, Value = true }, - LabelText = skills[i].GetType().Name, - TextColour = skillColours[i % skillColours.Length] + graphsContainer[graphNum].Hide(); } - } - }); + }); + graphToggles.Add(graphToggleBindable); + + legendContainer.Add(new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Masking = true, + CornerRadius = 10, + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Background5 + }, + new ExtendedOsuCheckbox + { + Padding = new MarginPadding(10), + RelativeSizeAxes = Axes.None, + Width = 200, + Current = { BindTarget = graphToggleBindable, Default = true, Value = true }, + LabelText = skills[i].GetType().Name, + TextColour = skillColours[i % skillColours.Length] + } + } + }); + } } - } - else - { - for (int i = 0; i < skills.Length; i++) + else { - // graphs are visible by default, we want to hide ones that were disabled before - if (!graphToggles[i].Value) - graphsContainer[i].Hide(); + for (int i = 0; i < skills.Length; i++) + { + // graphs are visible by default, we want to hide ones that were disabled before + if (!graphToggles[i].Value) + graphsContainer[i].Hide(); + } } + })); + } + + private Task> createStrainBars(Skill[] skills, List strainLists) + { + List graphs = []; + + var strainMaxValue = strainLists.Max(list => list.Max()); + + for (int i = 0; i < skills.Length; i++) + { + graphs.Add(new StrainBarGraph() + { + RelativeSizeAxes = Axes.Both, + MaxValue = strainMaxValue, + Values = strainLists[i] + }); } + + return LoadComponentsAsync(graphs).ContinueWith(_ => graphs); } [BackgroundDependencyLoader] @@ -184,7 +208,7 @@ private void load(OsuColour colours) Skills.BindValueChanged(updateGraphs); } - private void addStrainBars(Skill[] skills, List strainLists) + private void addStrainBars(List graphs, Skill[] skills, List strainLists) { float strainMaxValue = strainLists.Max(list => list.Max()); @@ -194,16 +218,11 @@ private void addStrainBars(Skill[] skills, List strainLists) { new BufferedContainer(cachedFrameBuffer: true) { - RelativeSizeAxes = Axes.Both, - Alpha = graphAlpha, - Colour = skillColours[i % skillColours.Length], - Child = new StrainBarGraph - { - RelativeSizeAxes = Axes.Both, - MaxValue = strainMaxValue, - Values = strainLists[i] - } - } + RelativeSizeAxes = Axes.Both, + Alpha = graphAlpha, + Colour = skillColours[i % skillColours.Length], + Child = graphs[i] + } }); } From 8cb93b8185db8a9038fb2fcb0853e502d60dae0e Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Mon, 23 Jun 2025 02:23:43 +0300 Subject: [PATCH 2/6] fix cli --- PerformanceCalculatorGUI/Components/StrainVisualizer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PerformanceCalculatorGUI/Components/StrainVisualizer.cs b/PerformanceCalculatorGUI/Components/StrainVisualizer.cs index e7ebe7ae8a..0672409ac4 100644 --- a/PerformanceCalculatorGUI/Components/StrainVisualizer.cs +++ b/PerformanceCalculatorGUI/Components/StrainVisualizer.cs @@ -64,7 +64,7 @@ private void updateGraphs(ValueChangedEvent val) graphAlpha = Math.Min(1.5f / skills.Length, 0.9f); var strainLists = getStrainLists(skills); - createStrainBars(skills, strainLists).ContinueWith((t) => Schedule(() => + createStrainBars(skills, strainLists).ContinueWith(_ => Schedule(() => { graphsContainer.Clear(); addStrainBars(t.GetResultSafely(), skills, strainLists); @@ -137,11 +137,11 @@ private Task> createStrainBars(Skill[] skills, List graphs = []; - var strainMaxValue = strainLists.Max(list => list.Max()); + float strainMaxValue = strainLists.Max(list => list.Max()); for (int i = 0; i < skills.Length; i++) { - graphs.Add(new StrainBarGraph() + graphs.Add(new StrainBarGraph { RelativeSizeAxes = Axes.Both, MaxValue = strainMaxValue, From 955eadb83edab2945d505eb901ed9a3ddd83c544 Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Mon, 23 Jun 2025 02:26:36 +0300 Subject: [PATCH 3/6] Update StrainVisualizer.cs --- PerformanceCalculatorGUI/Components/StrainVisualizer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PerformanceCalculatorGUI/Components/StrainVisualizer.cs b/PerformanceCalculatorGUI/Components/StrainVisualizer.cs index 0672409ac4..c4d2241ac4 100644 --- a/PerformanceCalculatorGUI/Components/StrainVisualizer.cs +++ b/PerformanceCalculatorGUI/Components/StrainVisualizer.cs @@ -64,7 +64,7 @@ private void updateGraphs(ValueChangedEvent val) graphAlpha = Math.Min(1.5f / skills.Length, 0.9f); var strainLists = getStrainLists(skills); - createStrainBars(skills, strainLists).ContinueWith(_ => Schedule(() => + createStrainBars(skills, strainLists).ContinueWith(t => Schedule(() => { graphsContainer.Clear(); addStrainBars(t.GetResultSafely(), skills, strainLists); From d39ad2a926e4c3ff29bbe155ed7575eaa5d88e5f Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Mon, 23 Jun 2025 02:33:00 +0300 Subject: [PATCH 4/6] fix ci again --- .../Components/StrainVisualizer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/PerformanceCalculatorGUI/Components/StrainVisualizer.cs b/PerformanceCalculatorGUI/Components/StrainVisualizer.cs index c4d2241ac4..c7fd1d5f7a 100644 --- a/PerformanceCalculatorGUI/Components/StrainVisualizer.cs +++ b/PerformanceCalculatorGUI/Components/StrainVisualizer.cs @@ -218,11 +218,11 @@ private void addStrainBars(List graphs, Skill[] skills, List Date: Mon, 30 Jun 2025 03:14:46 +0300 Subject: [PATCH 5/6] move create function --- .../Components/StrainVisualizer.cs | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/PerformanceCalculatorGUI/Components/StrainVisualizer.cs b/PerformanceCalculatorGUI/Components/StrainVisualizer.cs index c7fd1d5f7a..57f87e09a5 100644 --- a/PerformanceCalculatorGUI/Components/StrainVisualizer.cs +++ b/PerformanceCalculatorGUI/Components/StrainVisualizer.cs @@ -133,25 +133,6 @@ private void updateGraphs(ValueChangedEvent val) })); } - private Task> createStrainBars(Skill[] skills, List strainLists) - { - List graphs = []; - - float strainMaxValue = strainLists.Max(list => list.Max()); - - for (int i = 0; i < skills.Length; i++) - { - graphs.Add(new StrainBarGraph - { - RelativeSizeAxes = Axes.Both, - MaxValue = strainMaxValue, - Values = strainLists[i] - }); - } - - return LoadComponentsAsync(graphs).ContinueWith(_ => graphs); - } - [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -208,6 +189,24 @@ private void load(OsuColour colours) Skills.BindValueChanged(updateGraphs); } + private Task> createStrainBars(Skill[] skills, List strainLists) + { + List graphs = []; + + float strainMaxValue = strainLists.Max(list => list.Max()); + + for (int i = 0; i < skills.Length; i++) + { + graphs.Add(new StrainBarGraph + { + RelativeSizeAxes = Axes.Both, + MaxValue = strainMaxValue, + Values = strainLists[i] + }); + } + + return LoadComponentsAsync(graphs).ContinueWith(_ => graphs); + } private void addStrainBars(List graphs, Skill[] skills, List strainLists) { float strainMaxValue = strainLists.Max(list => list.Max()); From 0317c27347eb3e8436a179d4395381f18d2d104e Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Mon, 30 Jun 2025 12:31:49 +0300 Subject: [PATCH 6/6] fix CI --- PerformanceCalculatorGUI/Components/StrainVisualizer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/PerformanceCalculatorGUI/Components/StrainVisualizer.cs b/PerformanceCalculatorGUI/Components/StrainVisualizer.cs index 57f87e09a5..111aff9db3 100644 --- a/PerformanceCalculatorGUI/Components/StrainVisualizer.cs +++ b/PerformanceCalculatorGUI/Components/StrainVisualizer.cs @@ -207,6 +207,7 @@ private Task> createStrainBars(Skill[] skills, List graphs); } + private void addStrainBars(List graphs, Skill[] skills, List strainLists) { float strainMaxValue = strainLists.Max(list => list.Max());