mirror of
https://github.com/ppy/osu-tools.git
synced 2025-06-11 02:13:33 +09:00
Use Bindable for the container's info dictionary
This commit is contained in:
parent
ec480adde8
commit
a00657bc67
4 changed files with 64 additions and 37 deletions
|
@ -34,7 +34,7 @@ namespace PerformanceCalculatorGUI.Screens.ObjectInspection
|
||||||
: base(ruleset, beatmap, mods)
|
: base(ruleset, beatmap, mods)
|
||||||
{
|
{
|
||||||
difficultyHitObjects = difficultyCalculator.GetDifficultyHitObjects(beatmap, clockRate)
|
difficultyHitObjects = difficultyCalculator.GetDifficultyHitObjects(beatmap, clockRate)
|
||||||
.Select(x => (CatchDifficultyHitObject)x).ToArray();
|
.Cast<CatchDifficultyHitObject>().ToArray();
|
||||||
focusedDiffHitBind = diffHitBind;
|
focusedDiffHitBind = diffHitBind;
|
||||||
focusedDiffHitBind.ValueChanged += (ValueChangedEvent<DifficultyHitObject> newHit) => UpdateDebugList(debugValueList, newHit.NewValue);
|
focusedDiffHitBind.ValueChanged += (ValueChangedEvent<DifficultyHitObject> newHit) => UpdateDebugList(debugValueList, newHit.NewValue);
|
||||||
}
|
}
|
||||||
|
@ -62,11 +62,15 @@ namespace PerformanceCalculatorGUI.Screens.ObjectInspection
|
||||||
if (curDiffHit == null) return;
|
if (curDiffHit == null) return;
|
||||||
|
|
||||||
CatchDifficultyHitObject catchDiffHit = (CatchDifficultyHitObject)curDiffHit;
|
CatchDifficultyHitObject catchDiffHit = (CatchDifficultyHitObject)curDiffHit;
|
||||||
|
|
||||||
string groupName = catchDiffHit.BaseObject.GetType().Name;
|
string groupName = catchDiffHit.BaseObject.GetType().Name;
|
||||||
valueList.AddGroup(groupName, new string[] { "Fruit", "Droplet" });
|
valueList.AddGroup(groupName, new string[] { "Fruit", "Droplet" });
|
||||||
valueList.SetValue(groupName, "Strain Time", catchDiffHit.StrainTime);
|
|
||||||
valueList.SetValue(groupName, "Normalized Position", catchDiffHit.NormalizedPosition);
|
Dictionary<string, Dictionary<string, object>> infoDict = valueList.InfoDictionary.Value;
|
||||||
valueList.UpdateValues();
|
infoDict[groupName] = new Dictionary<string, object> {
|
||||||
|
{ "Strain Time", catchDiffHit.StrainTime },
|
||||||
|
{ "Normalized Position", catchDiffHit.NormalizedPosition },
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private partial class CatchObjectInspectorPlayfield : CatchEditorPlayfield
|
private partial class CatchObjectInspectorPlayfield : CatchEditorPlayfield
|
||||||
|
|
|
@ -18,18 +18,21 @@ namespace PerformanceCalculatorGUI.Screens.ObjectInspection
|
||||||
{
|
{
|
||||||
public partial class ObjectDifficultyValuesContainer : Container
|
public partial class ObjectDifficultyValuesContainer : Container
|
||||||
{
|
{
|
||||||
public Dictionary<string, Dictionary<string, object>> InfoDictionary;
|
public Bindable<Dictionary<string, Dictionary<string, object>>> InfoDictionary;
|
||||||
|
|
||||||
private Box bgBox;
|
private Box bgBox;
|
||||||
private TextFlowContainer flowContainer;
|
private TextFlowContainer flowContainer;
|
||||||
private Bindable<DifficultyHitObject> focusedDiffHit = new Bindable<DifficultyHitObject>();
|
private Bindable<DifficultyHitObject> focusedDiffHit = new();
|
||||||
|
|
||||||
public ObjectDifficultyValuesContainer(Bindable<DifficultyHitObject> diffHitBind)
|
public ObjectDifficultyValuesContainer(Bindable<DifficultyHitObject> diffHitBind)
|
||||||
{
|
{
|
||||||
focusedDiffHit.BindTo(diffHitBind);
|
focusedDiffHit.BindTo(diffHitBind);
|
||||||
focusedDiffHit.ValueChanged += (ValueChangedEvent<DifficultyHitObject> hit) => UpdateValues();
|
focusedDiffHit.ValueChanged += (ValueChangedEvent<DifficultyHitObject> _) => UpdateValues();
|
||||||
|
|
||||||
InfoDictionary = new Dictionary<string, Dictionary<string, object>>();
|
InfoDictionary = new Bindable<Dictionary<string, Dictionary<string, object>>>
|
||||||
|
{
|
||||||
|
Value = new Dictionary<string, Dictionary<string, object>>()
|
||||||
|
};
|
||||||
RelativeSizeAxes = Axes.Y;
|
RelativeSizeAxes = Axes.Y;
|
||||||
Width = 215;
|
Width = 215;
|
||||||
}
|
}
|
||||||
|
@ -61,14 +64,14 @@ namespace PerformanceCalculatorGUI.Screens.ObjectInspection
|
||||||
public void UpdateValues()
|
public void UpdateValues()
|
||||||
{
|
{
|
||||||
flowContainer.Text = "";
|
flowContainer.Text = "";
|
||||||
foreach (KeyValuePair<string, Dictionary<string, object>> GroupPair in InfoDictionary)
|
foreach (KeyValuePair<string, Dictionary<string, object>> GroupPair in InfoDictionary.Value)
|
||||||
{
|
{
|
||||||
// Big text
|
// Big text
|
||||||
string groupName = GroupPair.Key;
|
string groupName = GroupPair.Key;
|
||||||
Dictionary<string, object> groupDict = GroupPair.Value;
|
Dictionary<string, object> groupDict = GroupPair.Value;
|
||||||
flowContainer.AddText($"- {GroupPair.Key}\n", t =>
|
flowContainer.AddText($"- {GroupPair.Key}\n", t =>
|
||||||
{
|
{
|
||||||
t.Font = OsuFont.Torus.With(weight: "Bold", size: 28);
|
t.Font = OsuFont.Torus.With(size: 28, weight: "Bold");
|
||||||
t.Colour = Colour4.Pink;
|
t.Colour = Colour4.Pink;
|
||||||
t.Shadow = true;
|
t.Shadow = true;
|
||||||
});
|
});
|
||||||
|
@ -77,14 +80,29 @@ namespace PerformanceCalculatorGUI.Screens.ObjectInspection
|
||||||
{
|
{
|
||||||
flowContainer.AddText($" {ValuePair.Key}:\n", t =>
|
flowContainer.AddText($" {ValuePair.Key}:\n", t =>
|
||||||
{
|
{
|
||||||
t.Font = OsuFont.TorusAlternate.With(weight: "SemiBold", size: 21);
|
t.Font = OsuFont.TorusAlternate.With(size: 21, weight: "SemiBold");
|
||||||
t.Colour = Colour4.White;
|
t.Colour = Colour4.White;
|
||||||
t.Shadow = true;
|
t.Shadow = true;
|
||||||
t.Truncate = true;
|
t.Truncate = true;
|
||||||
});
|
});
|
||||||
flowContainer.AddText($" -> {ValuePair.Value}\n\n", t =>
|
|
||||||
|
// value formatting
|
||||||
|
object value = ValuePair.Value;
|
||||||
|
if (value is double val)
|
||||||
{
|
{
|
||||||
t.Font = OsuFont.TorusAlternate.With(weight: "SemiBold", size: 21);
|
value = Math.Truncate(val * 1000) / 1000;
|
||||||
|
}
|
||||||
|
if (value is float val2)
|
||||||
|
{
|
||||||
|
value = Math.Truncate(val2 * 1000) / 1000;
|
||||||
|
}
|
||||||
|
if (value is Vector2 val3)
|
||||||
|
{
|
||||||
|
value = new Vector2((float)(Math.Truncate(val3.X * 100) / 100), (float)Math.Truncate(val3.Y * 100) / 100);
|
||||||
|
}
|
||||||
|
flowContainer.AddText($" -> {value}\n\n", t =>
|
||||||
|
{
|
||||||
|
t.Font = OsuFont.TorusAlternate.With(size: 21, weight: "SemiBold");
|
||||||
t.Colour = Colour4.White;
|
t.Colour = Colour4.White;
|
||||||
t.Shadow = true;
|
t.Shadow = true;
|
||||||
});
|
});
|
||||||
|
@ -97,19 +115,19 @@ namespace PerformanceCalculatorGUI.Screens.ObjectInspection
|
||||||
overrides ??= Array.Empty<string>();
|
overrides ??= Array.Empty<string>();
|
||||||
foreach (string other in overrides)
|
foreach (string other in overrides)
|
||||||
{
|
{
|
||||||
InfoDictionary.Remove(other);
|
InfoDictionary.Value.Remove(other);
|
||||||
}
|
}
|
||||||
InfoDictionary[name] = new Dictionary<string, object>();
|
InfoDictionary.Value[name] = new Dictionary<string, object>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool GroupExists(string name)
|
public bool GroupExists(string name)
|
||||||
{
|
{
|
||||||
return InfoDictionary.ContainsKey(name);
|
return InfoDictionary.Value.ContainsKey(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetValue(string group, string name, object value)
|
public void SetValue(string group, string name, object value)
|
||||||
{
|
{
|
||||||
InfoDictionary.TryGetValue(group, out var exists);
|
InfoDictionary.Value.TryGetValue(group, out var exists);
|
||||||
if (exists == null)
|
if (exists == null)
|
||||||
{
|
{
|
||||||
AddGroup(group);
|
AddGroup(group);
|
||||||
|
@ -127,12 +145,12 @@ namespace PerformanceCalculatorGUI.Screens.ObjectInspection
|
||||||
value = new Vector2((float)(Math.Truncate(val3.X * 100) / 100), (float)Math.Truncate(val3.Y * 100) / 100);
|
value = new Vector2((float)(Math.Truncate(val3.X * 100) / 100), (float)Math.Truncate(val3.Y * 100) / 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
InfoDictionary[group][name] = value;
|
InfoDictionary.Value[group][name] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object GetValue(string group, string name)
|
public object GetValue(string group, string name)
|
||||||
{
|
{
|
||||||
return InfoDictionary[group][name];
|
return InfoDictionary.Value[group][name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,27 +67,29 @@ namespace PerformanceCalculatorGUI.Screens.ObjectInspection
|
||||||
OsuHitObject baseHit = (OsuHitObject)osuDiffHit.BaseObject;
|
OsuHitObject baseHit = (OsuHitObject)osuDiffHit.BaseObject;
|
||||||
|
|
||||||
string groupName = osuDiffHit.BaseObject.GetType().Name;
|
string groupName = osuDiffHit.BaseObject.GetType().Name;
|
||||||
|
Dictionary<string, Dictionary<string, object>> infoDict = valueList.InfoDictionary.Value;
|
||||||
|
|
||||||
valueList.AddGroup(groupName, new string[] { "Slider", "HitCircle", "Spinner" });
|
valueList.AddGroup(groupName, new string[] { "Slider", "HitCircle", "Spinner" });
|
||||||
valueList.SetValue(groupName, "Position", baseHit.StackedPosition);
|
infoDict[groupName] = new Dictionary<string, object> {
|
||||||
valueList.SetValue(groupName, "Strain Time", osuDiffHit.StrainTime);
|
{ "Position", baseHit.StackedPosition },
|
||||||
valueList.SetValue(groupName, "Aim Difficulty", AimEvaluator.EvaluateDifficultyOf(osuDiffHit, true));
|
{ "Strain Time", osuDiffHit.StrainTime },
|
||||||
valueList.SetValue(groupName, "Speed Difficulty", SpeedEvaluator.EvaluateDifficultyOf(osuDiffHit));
|
{ "Aim Difficulty", AimEvaluator.EvaluateDifficultyOf(osuDiffHit, true) },
|
||||||
valueList.SetValue(groupName, "Rhythm Diff", RhythmEvaluator.EvaluateDifficultyOf(osuDiffHit));
|
{ "Speed Difficulty", SpeedEvaluator.EvaluateDifficultyOf(osuDiffHit) },
|
||||||
valueList.SetValue(groupName, "Flashlight Diff", FlashlightEvaluator.EvaluateDifficultyOf(osuDiffHit, false));
|
{ "Rhythm Diff",SpeedEvaluator.EvaluateDifficultyOf(osuDiffHit) },
|
||||||
|
{ "Flashlight Diff", SpeedEvaluator.EvaluateDifficultyOf(osuDiffHit)},
|
||||||
|
};
|
||||||
|
|
||||||
if (osuDiffHit.Angle is not null)
|
if (osuDiffHit.Angle is not null)
|
||||||
valueList.SetValue(groupName, "Angle", MathUtils.RadiansToDegrees(osuDiffHit.Angle.Value));
|
infoDict[groupName].Add("Angle", MathUtils.RadiansToDegrees(osuDiffHit.Angle.Value));
|
||||||
|
|
||||||
if (osuDiffHit.BaseObject is Slider)
|
if (osuDiffHit.BaseObject is Slider)
|
||||||
{
|
{
|
||||||
valueList.SetValue(groupName, "FL Travel Time", FlashlightEvaluator.EvaluateDifficultyOf(osuDiffHit, false));
|
infoDict[groupName].Add("FL Travel Time", FlashlightEvaluator.EvaluateDifficultyOf(osuDiffHit, false));
|
||||||
valueList.SetValue(groupName, "Travel Time", osuDiffHit.TravelTime);
|
infoDict[groupName].Add("Travel Time", osuDiffHit.TravelTime);
|
||||||
valueList.SetValue(groupName, "Travel Distance", osuDiffHit.TravelDistance);
|
infoDict[groupName].Add("Travel Distance", osuDiffHit.TravelDistance);
|
||||||
valueList.SetValue(groupName, "Min Jump Dist", osuDiffHit.MinimumJumpDistance);
|
infoDict[groupName].Add("Min Jump Dist", osuDiffHit.MinimumJumpDistance);
|
||||||
valueList.SetValue(groupName, "Min Jump Time", osuDiffHit.MinimumJumpTime);
|
infoDict[groupName].Add("Min Jump Time", osuDiffHit.MinimumJumpTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
valueList.UpdateValues();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private partial class OsuObjectInspectorPlayfield : OsuPlayfield
|
private partial class OsuObjectInspectorPlayfield : OsuPlayfield
|
||||||
|
|
|
@ -66,10 +66,13 @@ namespace PerformanceCalculatorGUI.Screens.ObjectInspection
|
||||||
|
|
||||||
string groupName = taikoDiffHit.BaseObject.GetType().Name;
|
string groupName = taikoDiffHit.BaseObject.GetType().Name;
|
||||||
valueList.AddGroup(groupName, new string[] { "Hit", "Swell", "DrumRoll" });
|
valueList.AddGroup(groupName, new string[] { "Hit", "Swell", "DrumRoll" });
|
||||||
valueList.SetValue(groupName, "Delta Time", taikoDiffHit.DeltaTime);
|
|
||||||
valueList.SetValue(groupName, "Rhythm Difficulty", taikoDiffHit.Rhythm.Difficulty);
|
Dictionary<string, Dictionary<string, object>> infoDict = valueList.InfoDictionary.Value;
|
||||||
valueList.SetValue(groupName, "Rhythm Ratio", taikoDiffHit.Rhythm.Ratio);
|
infoDict[groupName] = new Dictionary<string, object> {
|
||||||
valueList.UpdateValues();
|
{ "Delta Time", taikoDiffHit.DeltaTime },
|
||||||
|
{ "Rhythm Difficulty", taikoDiffHit.Rhythm.Difficulty },
|
||||||
|
{ "Rhythm Ratio", taikoDiffHit.Rhythm.Ratio }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private partial class TaikoObjectInspectorPlayfield : TaikoPlayfield
|
private partial class TaikoObjectInspectorPlayfield : TaikoPlayfield
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue