mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 13:22:55 +08:00
Restructure proof of concept
This commit is contained in:
parent
fe2520c599
commit
c397cc2027
24
osu.Game/Screens/Edit/Components/Menus/DifficultyMenuItem.cs
Normal file
24
osu.Game/Screens/Edit/Components/Menus/DifficultyMenuItem.cs
Normal file
@ -0,0 +1,24 @@
|
||||
// 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 osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Components.Menus
|
||||
{
|
||||
public class DifficultyMenuItem : StatefulMenuItem<bool>
|
||||
{
|
||||
public DifficultyMenuItem(BeatmapInfo beatmapInfo, bool selected, Action<BeatmapInfo> difficultyChangeFunc)
|
||||
: base(beatmapInfo.Version ?? "(unnamed)", null)
|
||||
{
|
||||
State.Value = selected;
|
||||
|
||||
if (!selected)
|
||||
Action.Value = () => difficultyChangeFunc.Invoke(beatmapInfo);
|
||||
}
|
||||
|
||||
public override IconUsage? GetIconForState(bool state) => state ? (IconUsage?)FontAwesome.Solid.Check : null;
|
||||
}
|
||||
}
|
@ -727,28 +727,24 @@ namespace osu.Game.Screens.Edit
|
||||
return fileMenuItems;
|
||||
}
|
||||
|
||||
private ToggleMenuItem createDifficultyMenuItem(BeatmapInfo b)
|
||||
private DifficultyMenuItem createDifficultyMenuItem(BeatmapInfo beatmapInfo)
|
||||
{
|
||||
bool isCurrentDifficulty = playableBeatmap.BeatmapInfo.Equals(b);
|
||||
bool isCurrentDifficulty = playableBeatmap.BeatmapInfo.Equals(beatmapInfo);
|
||||
return new DifficultyMenuItem(beatmapInfo, isCurrentDifficulty, switchToDifficulty);
|
||||
}
|
||||
|
||||
var menuItem = new ToggleMenuItem(b.Version ?? "(unnamed)") { State = { Value = isCurrentDifficulty }, };
|
||||
private void switchToDifficulty(BeatmapInfo beatmapInfo)
|
||||
{
|
||||
if (loader != null)
|
||||
loader.ValidForResume = true;
|
||||
|
||||
if (!isCurrentDifficulty)
|
||||
game?.PerformFromScreen(screen =>
|
||||
{
|
||||
menuItem.Action.Value = () =>
|
||||
{
|
||||
if (loader != null)
|
||||
loader.ValidForResume = true;
|
||||
if (screen == null || screen != loader)
|
||||
return;
|
||||
|
||||
game?.PerformFromScreen(screen =>
|
||||
{
|
||||
if (screen != null && screen == loader)
|
||||
loader.PushEditor();
|
||||
}, new[] { typeof(EditorLoader) });
|
||||
};
|
||||
}
|
||||
|
||||
return menuItem;
|
||||
loader.PushEditor(beatmapInfo);
|
||||
}, new[] { typeof(EditorLoader) });
|
||||
}
|
||||
|
||||
public double SnapTime(double time, double? referenceTime) => editorBeatmap.SnapTime(time, referenceTime);
|
||||
|
@ -1,7 +1,10 @@
|
||||
// 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 JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Screens.Edit
|
||||
@ -12,14 +15,20 @@ namespace osu.Game.Screens.Edit
|
||||
/// </summary>
|
||||
public class EditorLoader : ScreenWithBeatmapBackground
|
||||
{
|
||||
[Resolved]
|
||||
private BeatmapManager beatmapManager { get; set; }
|
||||
|
||||
public override void OnEntering(IScreen last)
|
||||
{
|
||||
base.OnEntering(last);
|
||||
PushEditor();
|
||||
}
|
||||
|
||||
public void PushEditor()
|
||||
public void PushEditor([CanBeNull] BeatmapInfo beatmapInfo = null)
|
||||
{
|
||||
if (beatmapInfo != null)
|
||||
Beatmap.Value = beatmapManager.GetWorkingBeatmap(beatmapInfo);
|
||||
|
||||
this.Push(new Editor(this));
|
||||
ValidForResume = false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user