Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rushiiMachine committed Mar 27, 2024
1 parent afb58d0 commit fa4976c
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ private static void After(
var performanceSprite = ((ConstructorInfo)pSpriteText.Constructor.Reference).Invoke(
[
/* text: */ "0000.0",
/* fontName: */ "", // TODO: use correct value
/* spacingOverlap: */ 0f, // TODO: use correct value
/* fontName: */ "Assets/score/score",
/* spacingOverlap: */ 10f,
/* fieldType: */ alignRight ? Fields.TopRight : Fields.TopLeft,
/* origin: */ alignRight ? Origins.TopRight : Origins.TopLeft,
/* clock: */ Clocks.Game,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ private static void After(
[HarmonyArgument(0)] int increaseScoreType,
[HarmonyArgument(2)] bool increaseCombo)
{
Console.WriteLine(increaseScoreType);
if (!PerformanceCalculator.IsInitialized)
{
Console.WriteLine("OnIncreaseScoreHit called before performance calculator initialized!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private static void ResetCalculatorSync()
if (beatmapPath == null) return;

Calculator = new OsuPerformance(beatmapPath, (uint)mods);
Calculator.OnNewCalculation += Console.WriteLine;
Calculator.OnNewCalculation += PerformanceDisplay.UpdatePerformanceCounter;

Debug.WriteLine("Initialized performance calculator!");
}
Expand Down
26 changes: 25 additions & 1 deletion Osu.Patcher.Hook/Patches/LivePerformance/PerformanceDisplay.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Reflection;
using HarmonyLib;
using Osu.Stubs;

namespace Osu.Patcher.Hook.Patches.LivePerformance;
Expand Down Expand Up @@ -39,4 +41,26 @@ public static void UpdatePerformanceCounter(double pp)
Console.WriteLine($"Failed to set performance counter sprite text: {e}");
}
}
}
}

// [HarmonyPatch]
// public class fhjks
// {
// static fhjks()
// {
// Console.WriteLine("sinit");
// }
//
// [HarmonyTargetMethod]
// private static MethodBase fjhsdf() => pSpriteText.Constructor.Reference;
//
// [HarmonyPrefix]
// private static void before(
// [HarmonyArgument(0)] string text,
// [HarmonyArgument(1)] string abc,
// [HarmonyArgument(2)] float abcd
// )
// {
// Console.WriteLine($"{text} {abc} {abcd}");
// }
// }
2 changes: 1 addition & 1 deletion Osu.Stubs/Ruleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static class Ruleset
public static readonly LazyField<object?> ScoreDisplay = new(
"Ruleset#ScoreDisplay",
() => RuntimeType.GetRuntimeFields()
.Single(field => field.FieldType == ScoreDisplay.Reference)
.Single(field => field.FieldType == Stubs.ScoreDisplay.RuntimeType)
);

[UsedImplicitly]
Expand Down
6 changes: 3 additions & 3 deletions Osu.Stubs/ScoreDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ public class ScoreDisplay
[UsedImplicitly]
public static readonly LazyField<object> SpriteManager = new(
"ScoreDisplay#spriteManager",
() => RuntimeTime.GetDeclaredFields()
.Single(field => field.FieldType == SpriteManager.Reference)
() => RuntimeType.GetDeclaredFields()
.Single(field => field.FieldType == Stubs.SpriteManager.RuntimeType)
);

[UsedImplicitly]
public static Type RuntimeTime => Constructor.Reference.DeclaringType!;
public static Type RuntimeType => Constructor.Reference.DeclaringType!;
}
2 changes: 1 addition & 1 deletion Osu.Stubs/SpriteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ public class SpriteManager
);

[UsedImplicitly]
public static Type RuntimeTime => Add.Reference.DeclaringType!;
public static Type RuntimeType => Add.Reference.DeclaringType!;
}
5 changes: 2 additions & 3 deletions Osu.Stubs/pText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class pText
Ldarg_0,
Ldfld,
Ldarg_1,
Callvirt,
Call,
Brfalse_S,
Ret,
Ldarg_0,
Expand All @@ -37,7 +37,6 @@ public class pText
Stfld,
Ret,
},
false,
true
entireMethod: true
);
}

0 comments on commit fa4976c

Please sign in to comment.