mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 11:42:54 +08:00
rework code logic to make more sense
analysis container creates settings and the settings items are created more nicely also removed use of localized strings because that can be done separately
This commit is contained in:
parent
1ed94e598a
commit
a2b15fcdee
@ -13,6 +13,7 @@ using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Configuration;
|
||||
using osu.Game.Rulesets.Difficulty;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
@ -37,7 +38,6 @@ using osu.Game.Rulesets.Scoring.Legacy;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Edit.Setup;
|
||||
using osu.Game.Screens.Play.PlayerSettings;
|
||||
using osu.Game.Screens.Ranking.Statistics;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
@ -361,7 +361,7 @@ namespace osu.Game.Rulesets.Osu
|
||||
return adjustedDifficulty;
|
||||
}
|
||||
|
||||
public override AnalysisSettings CreateAnalysisSettings(DrawableRuleset drawableRuleset) => new OsuAnalysisSettings(drawableRuleset);
|
||||
public override OsuAnalysisContainer CreateAnalysisContainer(Replay replay, Playfield playfield) => new OsuAnalysisContainer(replay, playfield);
|
||||
|
||||
public override bool EditorShowScrollSpeed => false;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Lines;
|
||||
using osu.Framework.Graphics.Performance;
|
||||
@ -21,27 +21,33 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
public partial class OsuAnalysisContainer : AnalysisContainer
|
||||
{
|
||||
public Bindable<bool> HitMarkerEnabled = new BindableBool();
|
||||
public Bindable<bool> AimMarkersEnabled = new BindableBool();
|
||||
public Bindable<bool> AimLinesEnabled = new BindableBool();
|
||||
public new OsuAnalysisSettings AnalysisSettings => (OsuAnalysisSettings)base.AnalysisSettings;
|
||||
|
||||
protected new OsuPlayfield Playfield => (OsuPlayfield)base.Playfield;
|
||||
|
||||
protected HitMarkersContainer HitMarkers;
|
||||
protected AimMarkersContainer AimMarkers;
|
||||
protected AimLinesContainer AimLines;
|
||||
|
||||
public OsuAnalysisContainer(Replay replay)
|
||||
: base(replay)
|
||||
public OsuAnalysisContainer(Replay replay, Playfield playfield)
|
||||
: base(replay, playfield)
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
AimLines = new AimLinesContainer { Depth = float.MaxValue },
|
||||
HitMarkers = new HitMarkersContainer(),
|
||||
AimMarkers = new AimMarkersContainer { Depth = float.MinValue },
|
||||
AimLines = new AimLinesContainer { Depth = float.MaxValue }
|
||||
AimMarkers = new AimMarkersContainer { Depth = float.MinValue }
|
||||
};
|
||||
}
|
||||
|
||||
HitMarkerEnabled.ValueChanged += e => HitMarkers.FadeTo(e.NewValue ? 1 : 0);
|
||||
AimMarkersEnabled.ValueChanged += e => AimMarkers.FadeTo(e.NewValue ? 1 : 0);
|
||||
AimLinesEnabled.ValueChanged += e => AimLines.FadeTo(e.NewValue ? 1 : 0);
|
||||
protected override OsuAnalysisSettings CreateAnalysisSettings()
|
||||
{
|
||||
var settings = new OsuAnalysisSettings();
|
||||
settings.HitMarkersEnabled.ValueChanged += e => HitMarkers.FadeTo(e.NewValue ? 1 : 0);
|
||||
settings.AimMarkersEnabled.ValueChanged += e => AimMarkers.FadeTo(e.NewValue ? 1 : 0);
|
||||
settings.AimLinesEnabled.ValueChanged += e => AimLines.FadeTo(e.NewValue ? 1 : 0);
|
||||
settings.CursorHideEnabled.ValueChanged += e => Playfield.Cursor.FadeTo(e.NewValue ? 0 : 1);
|
||||
return settings;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -51,6 +57,11 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
AimMarkers.Hide();
|
||||
AimLines.Hide();
|
||||
|
||||
LoadReplay();
|
||||
}
|
||||
|
||||
protected void LoadReplay()
|
||||
{
|
||||
bool leftHeld = false;
|
||||
bool rightHeld = false;
|
||||
|
||||
|
@ -2,58 +2,23 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Screens.Play.PlayerSettings;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
public partial class OsuAnalysisSettings : AnalysisSettings
|
||||
{
|
||||
protected new DrawableOsuRuleset DrawableRuleset => (DrawableOsuRuleset)base.DrawableRuleset;
|
||||
[SettingSource("Hit markers", SettingControlType = typeof(PlayerCheckbox))]
|
||||
public BindableBool HitMarkersEnabled { get; } = new BindableBool();
|
||||
|
||||
private readonly PlayerCheckbox hitMarkerToggle;
|
||||
private readonly PlayerCheckbox aimMarkerToggle;
|
||||
private readonly PlayerCheckbox aimLinesToggle;
|
||||
[SettingSource("Aim markers", SettingControlType = typeof(PlayerCheckbox))]
|
||||
public BindableBool AimMarkersEnabled { get; } = new BindableBool();
|
||||
|
||||
public OsuAnalysisSettings(DrawableRuleset drawableRuleset)
|
||||
: base(drawableRuleset)
|
||||
{
|
||||
PlayerCheckbox hideCursorToggle;
|
||||
[SettingSource("Aim lines", SettingControlType = typeof(PlayerCheckbox))]
|
||||
public BindableBool AimLinesEnabled { get; } = new BindableBool();
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
hitMarkerToggle = new PlayerCheckbox { LabelText = PlayerSettingsOverlayStrings.HitMarkers },
|
||||
aimMarkerToggle = new PlayerCheckbox { LabelText = PlayerSettingsOverlayStrings.AimMarkers },
|
||||
aimLinesToggle = new PlayerCheckbox { LabelText = PlayerSettingsOverlayStrings.AimLines },
|
||||
hideCursorToggle = new PlayerCheckbox { LabelText = PlayerSettingsOverlayStrings.HideCursor }
|
||||
};
|
||||
|
||||
hideCursorToggle.Current.BindValueChanged(onCursorToggle);
|
||||
}
|
||||
|
||||
private void onCursorToggle(ValueChangedEvent<bool> hide)
|
||||
{
|
||||
// this only hides half the cursor
|
||||
if (hide.NewValue)
|
||||
{
|
||||
DrawableRuleset.Playfield.Cursor.FadeOut();
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawableRuleset.Playfield.Cursor.FadeIn();
|
||||
}
|
||||
}
|
||||
|
||||
public override AnalysisContainer CreateAnalysisContainer(Replay replay)
|
||||
{
|
||||
var analysisContainer = new OsuAnalysisContainer(replay);
|
||||
analysisContainer.HitMarkerEnabled.BindTo(hitMarkerToggle.Current);
|
||||
analysisContainer.AimMarkersEnabled.BindTo(aimMarkerToggle.Current);
|
||||
analysisContainer.AimLinesEnabled.BindTo(aimLinesToggle.Current);
|
||||
return analysisContainer;
|
||||
}
|
||||
[SettingSource("Hide cursor", SettingControlType = typeof(PlayerCheckbox))]
|
||||
public BindableBool CursorHideEnabled { get; } = new BindableBool();
|
||||
}
|
||||
}
|
||||
|
@ -19,26 +19,6 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString StepForward => new TranslatableString(getKey(@"step_forward_frame"), @"Step forward one frame");
|
||||
|
||||
/// <summary>
|
||||
/// "Hit markers"
|
||||
/// </summary>
|
||||
public static LocalisableString HitMarkers => new TranslatableString(getKey(@"hit_markers"), @"Hit markers");
|
||||
|
||||
/// <summary>
|
||||
/// "Aim markers"
|
||||
/// </summary>
|
||||
public static LocalisableString AimMarkers => new TranslatableString(getKey(@"aim_markers"), @"Aim markers");
|
||||
|
||||
/// <summary>
|
||||
/// "Hide cursor"
|
||||
/// </summary>
|
||||
public static LocalisableString HideCursor => new TranslatableString(getKey(@"hide_cursor"), @"Hide cursor");
|
||||
|
||||
/// <summary>
|
||||
/// "Aim lines"
|
||||
/// </summary>
|
||||
public static LocalisableString AimLines => new TranslatableString(getKey(@"aim_lines"), @"Aim lines");
|
||||
|
||||
/// <summary>
|
||||
/// "Seek backward {0} seconds"
|
||||
/// </summary>
|
||||
|
@ -17,6 +17,7 @@ using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Configuration;
|
||||
using osu.Game.Rulesets.Difficulty;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
@ -27,7 +28,6 @@ using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Edit.Setup;
|
||||
using osu.Game.Screens.Play.PlayerSettings;
|
||||
using osu.Game.Screens.Ranking.Statistics;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Users;
|
||||
@ -410,6 +410,6 @@ namespace osu.Game.Rulesets
|
||||
|
||||
public virtual DifficultySection? CreateEditorDifficultySection() => null;
|
||||
|
||||
public virtual AnalysisSettings? CreateAnalysisSettings(DrawableRuleset drawableRuleset) => null;
|
||||
public virtual AnalysisContainer? CreateAnalysisContainer(Replay replay, Playfield playfield) => null;
|
||||
}
|
||||
}
|
||||
|
@ -3,16 +3,25 @@
|
||||
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Screens.Play.PlayerSettings;
|
||||
|
||||
namespace osu.Game.Rulesets.UI
|
||||
{
|
||||
public partial class AnalysisContainer : Container
|
||||
public abstract partial class AnalysisContainer : Container
|
||||
{
|
||||
protected Replay Replay;
|
||||
protected Playfield Playfield;
|
||||
|
||||
public AnalysisContainer(Replay replay)
|
||||
public AnalysisSettings AnalysisSettings;
|
||||
|
||||
public AnalysisContainer(Replay replay, Playfield playfield)
|
||||
{
|
||||
Replay = replay;
|
||||
Playfield = playfield;
|
||||
|
||||
AnalysisSettings = CreateAnalysisSettings();
|
||||
}
|
||||
|
||||
protected abstract AnalysisSettings CreateAnalysisSettings();
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,16 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Configuration;
|
||||
|
||||
namespace osu.Game.Screens.Play.PlayerSettings
|
||||
{
|
||||
public abstract partial class AnalysisSettings : PlayerSettingsGroup
|
||||
public partial class AnalysisSettings : PlayerSettingsGroup
|
||||
{
|
||||
protected DrawableRuleset DrawableRuleset;
|
||||
|
||||
protected AnalysisSettings(DrawableRuleset drawableRuleset)
|
||||
public AnalysisSettings()
|
||||
: base("Analysis Settings")
|
||||
{
|
||||
DrawableRuleset = drawableRuleset;
|
||||
AddRange(this.CreateSettingsControls());
|
||||
}
|
||||
|
||||
public abstract AnalysisContainer CreateAnalysisContainer(Replay replay);
|
||||
}
|
||||
}
|
||||
|
@ -72,12 +72,12 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
HUDOverlay.PlayerSettingsOverlay.AddAtStart(playbackSettings);
|
||||
|
||||
var analysisSettings = DrawableRuleset.Ruleset.CreateAnalysisSettings(DrawableRuleset);
|
||||
var analysisContainer = DrawableRuleset.Ruleset.CreateAnalysisContainer(GameplayState.Score.Replay, DrawableRuleset.Playfield);
|
||||
|
||||
if (analysisSettings != null)
|
||||
if (analysisContainer != null)
|
||||
{
|
||||
HUDOverlay.PlayerSettingsOverlay.AddAtStart(analysisSettings);
|
||||
DrawableRuleset.Playfield.AddAnalysisContainer(analysisSettings.CreateAnalysisContainer(GameplayState.Score.Replay));
|
||||
HUDOverlay.PlayerSettingsOverlay.AddAtStart(analysisContainer.AnalysisSettings);
|
||||
DrawableRuleset.Playfield.AddAnalysisContainer(analysisContainer);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user