mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 04:05:35 +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;
|
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 (screen == null || screen != loader)
|
||||||
{
|
return;
|
||||||
if (loader != null)
|
|
||||||
loader.ValidForResume = true;
|
|
||||||
|
|
||||||
game?.PerformFromScreen(screen =>
|
loader.PushEditor(beatmapInfo);
|
||||||
{
|
}, new[] { typeof(EditorLoader) });
|
||||||
if (screen != null && screen == loader)
|
|
||||||
loader.PushEditor();
|
|
||||||
}, new[] { typeof(EditorLoader) });
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return menuItem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double SnapTime(double time, double? referenceTime) => editorBeatmap.SnapTime(time, referenceTime);
|
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.
|
// 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.
|
// 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.Framework.Screens;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit
|
namespace osu.Game.Screens.Edit
|
||||||
@ -12,14 +15,20 @@ namespace osu.Game.Screens.Edit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class EditorLoader : ScreenWithBeatmapBackground
|
public class EditorLoader : ScreenWithBeatmapBackground
|
||||||
{
|
{
|
||||||
|
[Resolved]
|
||||||
|
private BeatmapManager beatmapManager { get; set; }
|
||||||
|
|
||||||
public override void OnEntering(IScreen last)
|
public override void OnEntering(IScreen last)
|
||||||
{
|
{
|
||||||
base.OnEntering(last);
|
base.OnEntering(last);
|
||||||
PushEditor();
|
PushEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PushEditor()
|
public void PushEditor([CanBeNull] BeatmapInfo beatmapInfo = null)
|
||||||
{
|
{
|
||||||
|
if (beatmapInfo != null)
|
||||||
|
Beatmap.Value = beatmapManager.GetWorkingBeatmap(beatmapInfo);
|
||||||
|
|
||||||
this.Push(new Editor(this));
|
this.Push(new Editor(this));
|
||||||
ValidForResume = false;
|
ValidForResume = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user