Skip to content

Commit

Permalink
Merge pull request #183 from stanriders/update-and-fix-mod-select
Browse files Browse the repository at this point in the history
Update packages and improve mod selection in GUI
  • Loading branch information
peppy authored Oct 5, 2023
2 parents 86184b3 + 1e3fd0e commit eb0deb8
Show file tree
Hide file tree
Showing 19 changed files with 169 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public override void Execute()

var ruleset = LegacyHelper.GetRulesetFromLegacyID(apiScore.RulesetID);
var score = apiScore.ToScoreInfo(apiScore.Mods.Select(m => m.ToMod(ruleset)).ToArray(), apiBeatmap);
score.BeatmapInfo.Metadata = new BeatmapMetadata
score.BeatmapInfo!.Metadata = new BeatmapMetadata
{
Title = apiBeatmap.Metadata.Title,
Artist = apiBeatmap.Metadata.Artist,
Expand Down
10 changes: 5 additions & 5 deletions PerformanceCalculator/PerformanceCalculator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<ItemGroup>
<PackageReference Include="Alba.CsConsoleFormat" Version="1.0.0" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.0.2" />
<PackageReference Include="ppy.osu.Game" Version="2023.621.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Osu" Version="2023.621.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Taiko" Version="2023.621.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Catch" Version="2023.621.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Mania" Version="2023.621.0" />
<PackageReference Include="ppy.osu.Game" Version="2023.1004.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Osu" Version="2023.1004.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Taiko" Version="2023.1004.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Catch" Version="2023.1004.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Mania" Version="2023.1004.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions PerformanceCalculator/ProcessorCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public void OutputPerformance(ScoreInfo score, PerformanceAttributes performance
Score = new ScoreStatistics
{
RulesetId = score.Ruleset.OnlineID,
BeatmapId = score.BeatmapInfo.OnlineID,
Beatmap = score.BeatmapInfo.ToString(),
BeatmapId = score.BeatmapInfo?.OnlineID ?? -1,
Beatmap = score.BeatmapInfo?.ToString() ?? "Unknown beatmap",
Mods = score.Mods.Select(m => new APIMod(m)).ToList(),
Score = score.TotalScore,
Accuracy = score.Accuracy * 100,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ExtendedOsuFileSelector(string initialPath = null, string[] validFileExte
/// <summary>
/// Metadata decoder is created once to not recreate it for every file
/// </summary>
private readonly LegacyBeatmapMetadataDecoder beatmapDecoder = new();
private readonly LegacyBeatmapMetadataDecoder beatmapDecoder = new LegacyBeatmapMetadataDecoder();

protected override DirectoryListingFile CreateFileItem(FileInfo file) => new ExtendedOsuDirectoryListingFile(file, beatmapDecoder);

Expand Down
6 changes: 3 additions & 3 deletions PerformanceCalculatorGUI/Components/ExtendedProfileScore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public class ExtendedScore
public SoloScoreInfo SoloScore { get; }
public double LivePP { get; }

public Bindable<int> Position { get; } = new();
public Bindable<int> PositionChange { get; } = new();
public Bindable<int> Position { get; } = new Bindable<int>();
public Bindable<int> PositionChange { get; } = new Bindable<int>();

public PerformanceAttributes PerformanceAttributes { get; }

Expand Down Expand Up @@ -282,7 +282,7 @@ private void load(RulesetStore rulesets)
{
var ruleset = rulesets.GetRuleset(Score.SoloScore.RulesetID) ?? throw new InvalidOperationException();
return new ModIcon(ruleset.CreateInstance().CreateModFromAcronym(mod.Acronym))
return new ModIcon(ruleset.CreateInstance().CreateModFromAcronym(mod.Acronym)!)
{
Scale = new Vector2(0.35f)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace PerformanceCalculatorGUI.Components
{
public partial class ExtendedUserModSelectOverlay : UserModSelectOverlay
{
protected override bool ShowTotalMultiplier => false;
protected override bool ShowModEffects => false;

public ExtendedUserModSelectOverlay()
: base(OverlayColourScheme.Blue)
Expand Down
8 changes: 4 additions & 4 deletions PerformanceCalculatorGUI/Components/StrainVisualizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ public partial class StrainBarGraph : FillFlowContainer<StrainBar>

public partial class StrainVisualizer : Container
{
public readonly Bindable<Skill[]> Skills = new();
public readonly Bindable<Skill[]> Skills = new Bindable<Skill[]>();

private readonly List<Bindable<bool>> graphToggles = new();
private readonly List<Bindable<bool>> graphToggles = new List<Bindable<bool>>();

public readonly Bindable<int> TimeUntilFirstStrain = new();
public readonly Bindable<int> TimeUntilFirstStrain = new Bindable<int>();

private ZoomableScrollContainer graphsContainer;
private FillFlowContainer legendContainer;
Expand Down Expand Up @@ -109,7 +109,7 @@ private void updateGraphs(ValueChangedEvent<Skill[]> val)

var graphAlpha = Math.Min(1.5f / skills.Length, 0.9f);

List<(float val, string tooltip)[]> strainLists = new();
List<(float val, string tooltip)[]> strainLists = new List<(float val, string tooltip)[]>();

foreach (var skill in skills)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public partial class FileChooserLabelledTextBox : ExtendedLabelledTextBox, ICanA

public IEnumerable<string> HandledExtensions => handledExtensions;

private readonly Bindable<FileInfo> currentFile = new();
private readonly Bindable<FileInfo> currentFile = new Bindable<FileInfo>();

[Resolved]
private OsuGameBase game { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion PerformanceCalculatorGUI/Components/UserCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public partial class UserCard : UserListPanel
private OsuSpriteText differenceLabel;
private OsuSpriteText playcountLabel;

public Bindable<UserCardData> Data = new();
public Bindable<UserCardData> Data = new Bindable<UserCardData>();

public UserCard(APIUser user)
: base(user)
Expand Down
2 changes: 1 addition & 1 deletion PerformanceCalculatorGUI/Configuration/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected override void InitialiseDefaults()
SetDefault(Settings.ClientId, string.Empty);
SetDefault(Settings.ClientSecret, string.Empty);
SetDefault(Settings.DefaultPath, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
SetDefault(Settings.CachePath, Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "cache"));
SetDefault(Settings.CachePath, Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "cache"));
}
}
}
10 changes: 5 additions & 5 deletions PerformanceCalculatorGUI/PerformanceCalculatorGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game" Version="2023.621.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Osu" Version="2023.621.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Taiko" Version="2023.621.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Catch" Version="2023.621.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Mania" Version="2023.621.0" />
<PackageReference Include="ppy.osu.Game" Version="2023.1004.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Osu" Version="2023.1004.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Taiko" Version="2023.1004.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Catch" Version="2023.1004.0" />
<PackageReference Include="ppy.osu.Game.Rulesets.Mania" Version="2023.1004.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion PerformanceCalculatorGUI/PerformanceCalculatorGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public partial class PerformanceCalculatorGame : OsuGameBase
// This overwrites OsuGameBase's SelectedMods to make sure it can't tweak mods when we don't want it to
[Cached]
[Cached(typeof(IBindable<IReadOnlyList<Mod>>))]
private readonly Bindable<IReadOnlyList<Mod>> mods = new(Array.Empty<Mod>());
private readonly Bindable<IReadOnlyList<Mod>> mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());

[Resolved]
private FrameworkConfigManager frameworkConfig { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion PerformanceCalculatorGUI/ProcessorWorkingBeatmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private static Beatmap readFromFile(string filename)

public static ProcessorWorkingBeatmap FromFileOrId(string fileOrId, AudioManager audioManager = null, string cachePath = "cache")
{
if (fileOrId.EndsWith(".osu"))
if (fileOrId.EndsWith(".osu", StringComparison.Ordinal))
{
if (!File.Exists(fileOrId))
throw new ArgumentException($"Beatmap file {fileOrId} does not exist.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public partial class BeatmapLeaderboardScreen : PerformanceCalculatorScreen
private CancellationTokenSource calculationCancellatonToken;

[Cached]
private OverlayColourProvider colourProvider = new(OverlayColourScheme.Orange);
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Orange);

[Resolved]
private NotificationDisplay notificationDisplay { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public partial class ObjectDifficultyValuesContainer : Container

private FillFlowContainer flowContainer;

public Bindable<DifficultyHitObject> CurrentDifficultyHitObject { get; } = new();
public Bindable<DifficultyHitObject> CurrentDifficultyHitObject { get; } = new Bindable<DifficultyHitObject>();

private const int hit_object_type_container_height = 50;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl
=> dependencies = new DependencyContainer(base.CreateChildDependencies(parent));

[Cached]
private BindableBeatDivisor beatDivisor = new();
private BindableBeatDivisor beatDivisor = new BindableBeatDivisor();

[Resolved]
private Bindable<WorkingBeatmap> beatmap { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ private void updateState(DrawableHitObject hitObject, ArmedState state)
// adjust the visuals of top-level object types to make them stay on screen for longer than usual.
switch (hitObject)
{
case DrawableSlider _:
case DrawableHitCircle _:
case DrawableSlider:
case DrawableHitCircle:
var nextHitObject = difficultyHitObjects.FirstOrDefault(x => x.StartTime > hitObject.StartTimeBindable.Value)?.BaseObject;

if (nextHitObject != null)
Expand Down
26 changes: 10 additions & 16 deletions PerformanceCalculatorGUI/Screens/SimulateScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public partial class SimulateScreen : PerformanceCalculatorScreen
private PerformanceCalculator performanceCalculator;

[Cached]
private Bindable<DifficultyCalculator> difficultyCalculator = new();
private Bindable<DifficultyCalculator> difficultyCalculator = new Bindable<DifficultyCalculator>();

private FillFlowContainer beatmapDataContainer;
private Container beatmapTitle;
Expand Down Expand Up @@ -108,6 +108,7 @@ public partial class SimulateScreen : PerformanceCalculatorScreen

private const int file_selection_container_height = 40;
private const int map_title_container_height = 40;
private const float mod_selection_container_scale = 0.7f;

public SimulateScreen()
{
Expand Down Expand Up @@ -300,21 +301,14 @@ private void load()
modDisplay = new ModDisplay()
}
},
new ScalingContainer(ScalingMode.Everything)
userModsSelectOverlay = new ExtendedUserModSelectOverlay
{
Name = "Mod selection overlay",
RelativeSizeAxes = Axes.X,
Height = 300,
Width = 0.75f,
Scale = new Vector2(1.5f),
Child = userModsSelectOverlay = new ExtendedUserModSelectOverlay
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft,
IsValidMod = mod => mod.HasImplementation && ModUtils.FlattenMod(mod).All(m => m.UserPlayable),
SelectedMods = { BindTarget = appliedMods }
}
Height = 460 / mod_selection_container_scale,
Width = 1f / mod_selection_container_scale,
Scale = new Vector2(mod_selection_container_scale),
IsValidMod = mod => mod.HasImplementation && ModUtils.FlattenMod(mod).All(m => m.UserPlayable),
SelectedMods = { BindTarget = appliedMods }
}
}
}
Expand Down Expand Up @@ -594,7 +588,7 @@ private void calculateDifficulty()
if (difficultyCalculator.Value is IExtendedDifficultyCalculator extendedDifficultyCalculator)
{
// StrainSkill always skips the first object
if (working.Beatmap?.HitObjects?.Count > 1)
if (working.Beatmap?.HitObjects.Count > 1)
strainVisualizer.TimeUntilFirstStrain.Value = (int)working.Beatmap.HitObjects[1].StartTime;

strainVisualizer.Skills.Value = extendedDifficultyCalculator.GetSkills();
Expand Down Expand Up @@ -629,7 +623,7 @@ private void calculatePerformance()
var beatmap = working.GetPlayableBeatmap(ruleset.Value, appliedMods.Value);

var accuracy = accuracyTextBox.Value.Value / 100.0;
Dictionary<HitResult, int> statistics = null;
Dictionary<HitResult, int> statistics = new Dictionary<HitResult, int>();

if (ruleset.Value.OnlineID != -1)
{
Expand Down
Loading

0 comments on commit eb0deb8

Please sign in to comment.