mirror of
https://github.com/osukey/osukey.git
synced 2025-06-27 22:27:57 +09:00
Move resolved usage of WorkingBeatmap in editor components as local as possible to avoid misuse
This commit is contained in:
parent
7fdf876b4c
commit
b7dd54847f
@ -16,6 +16,9 @@ namespace osu.Game.Screens.Edit.Compose
|
|||||||
{
|
{
|
||||||
public class ComposeScreen : EditorScreenWithTimeline
|
public class ComposeScreen : EditorScreenWithTimeline
|
||||||
{
|
{
|
||||||
|
[Resolved]
|
||||||
|
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
||||||
|
|
||||||
private HitObjectComposer composer;
|
private HitObjectComposer composer;
|
||||||
|
|
||||||
public ComposeScreen()
|
public ComposeScreen()
|
||||||
@ -59,7 +62,7 @@ namespace osu.Game.Screens.Edit.Compose
|
|||||||
{
|
{
|
||||||
Debug.Assert(ruleset != null);
|
Debug.Assert(ruleset != null);
|
||||||
|
|
||||||
var beatmapSkinProvider = new BeatmapSkinProvidingContainer(Beatmap.Value.Skin);
|
var beatmapSkinProvider = new BeatmapSkinProvidingContainer(beatmap.Value.Skin);
|
||||||
|
|
||||||
// the beatmapSkinProvider is used as the fallback source here to allow the ruleset-specific skin implementation
|
// the beatmapSkinProvider is used as the fallback source here to allow the ruleset-specific skin implementation
|
||||||
// full access to all skin sources.
|
// full access to all skin sources.
|
||||||
|
@ -2,10 +2,8 @@
|
|||||||
// 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 osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit
|
namespace osu.Game.Screens.Edit
|
||||||
{
|
{
|
||||||
@ -14,9 +12,6 @@ namespace osu.Game.Screens.Edit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class EditorScreen : Container
|
public abstract class EditorScreen : Container
|
||||||
{
|
{
|
||||||
[Resolved]
|
|
||||||
protected IBindable<WorkingBeatmap> Beatmap { get; private set; }
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
protected EditorBeatmap EditorBeatmap { get; private set; }
|
protected EditorBeatmap EditorBeatmap { get; private set; }
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
{
|
{
|
||||||
Label = "Object Size",
|
Label = "Object Size",
|
||||||
Description = "The size of all hit objects",
|
Description = "The size of all hit objects",
|
||||||
Current = new BindableFloat(Beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize)
|
Current = new BindableFloat(Beatmap.BeatmapInfo.BaseDifficulty.CircleSize)
|
||||||
{
|
{
|
||||||
Default = BeatmapDifficulty.DEFAULT_DIFFICULTY,
|
Default = BeatmapDifficulty.DEFAULT_DIFFICULTY,
|
||||||
MinValue = 0,
|
MinValue = 0,
|
||||||
@ -46,7 +46,7 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
{
|
{
|
||||||
Label = "Health Drain",
|
Label = "Health Drain",
|
||||||
Description = "The rate of passive health drain throughout playable time",
|
Description = "The rate of passive health drain throughout playable time",
|
||||||
Current = new BindableFloat(Beatmap.Value.BeatmapInfo.BaseDifficulty.DrainRate)
|
Current = new BindableFloat(Beatmap.BeatmapInfo.BaseDifficulty.DrainRate)
|
||||||
{
|
{
|
||||||
Default = BeatmapDifficulty.DEFAULT_DIFFICULTY,
|
Default = BeatmapDifficulty.DEFAULT_DIFFICULTY,
|
||||||
MinValue = 0,
|
MinValue = 0,
|
||||||
@ -58,7 +58,7 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
{
|
{
|
||||||
Label = "Approach Rate",
|
Label = "Approach Rate",
|
||||||
Description = "The speed at which objects are presented to the player",
|
Description = "The speed at which objects are presented to the player",
|
||||||
Current = new BindableFloat(Beatmap.Value.BeatmapInfo.BaseDifficulty.ApproachRate)
|
Current = new BindableFloat(Beatmap.BeatmapInfo.BaseDifficulty.ApproachRate)
|
||||||
{
|
{
|
||||||
Default = BeatmapDifficulty.DEFAULT_DIFFICULTY,
|
Default = BeatmapDifficulty.DEFAULT_DIFFICULTY,
|
||||||
MinValue = 0,
|
MinValue = 0,
|
||||||
@ -70,7 +70,7 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
{
|
{
|
||||||
Label = "Overall Difficulty",
|
Label = "Overall Difficulty",
|
||||||
Description = "The harshness of hit windows and difficulty of special objects (ie. spinners)",
|
Description = "The harshness of hit windows and difficulty of special objects (ie. spinners)",
|
||||||
Current = new BindableFloat(Beatmap.Value.BeatmapInfo.BaseDifficulty.OverallDifficulty)
|
Current = new BindableFloat(Beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty)
|
||||||
{
|
{
|
||||||
Default = BeatmapDifficulty.DEFAULT_DIFFICULTY,
|
Default = BeatmapDifficulty.DEFAULT_DIFFICULTY,
|
||||||
MinValue = 0,
|
MinValue = 0,
|
||||||
@ -88,10 +88,10 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
{
|
{
|
||||||
// for now, update these on commit rather than making BeatmapMetadata bindables.
|
// for now, update these on commit rather than making BeatmapMetadata bindables.
|
||||||
// after switching database engines we can reconsider if switching to bindables is a good direction.
|
// after switching database engines we can reconsider if switching to bindables is a good direction.
|
||||||
Beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize = circleSizeSlider.Current.Value;
|
Beatmap.BeatmapInfo.BaseDifficulty.CircleSize = circleSizeSlider.Current.Value;
|
||||||
Beatmap.Value.BeatmapInfo.BaseDifficulty.DrainRate = healthDrainSlider.Current.Value;
|
Beatmap.BeatmapInfo.BaseDifficulty.DrainRate = healthDrainSlider.Current.Value;
|
||||||
Beatmap.Value.BeatmapInfo.BaseDifficulty.ApproachRate = approachRateSlider.Current.Value;
|
Beatmap.BeatmapInfo.BaseDifficulty.ApproachRate = approachRateSlider.Current.Value;
|
||||||
Beatmap.Value.BeatmapInfo.BaseDifficulty.OverallDifficulty = overallDifficultySlider.Current.Value;
|
Beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty = overallDifficultySlider.Current.Value;
|
||||||
|
|
||||||
editorBeatmap.UpdateAllHitObjects();
|
editorBeatmap.UpdateAllHitObjects();
|
||||||
}
|
}
|
||||||
|
@ -29,25 +29,25 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
artistTextBox = new LabelledTextBox
|
artistTextBox = new LabelledTextBox
|
||||||
{
|
{
|
||||||
Label = "Artist",
|
Label = "Artist",
|
||||||
Current = { Value = Beatmap.Value.Metadata.Artist },
|
Current = { Value = Beatmap.Metadata.Artist },
|
||||||
TabbableContentContainer = this
|
TabbableContentContainer = this
|
||||||
},
|
},
|
||||||
titleTextBox = new LabelledTextBox
|
titleTextBox = new LabelledTextBox
|
||||||
{
|
{
|
||||||
Label = "Title",
|
Label = "Title",
|
||||||
Current = { Value = Beatmap.Value.Metadata.Title },
|
Current = { Value = Beatmap.Metadata.Title },
|
||||||
TabbableContentContainer = this
|
TabbableContentContainer = this
|
||||||
},
|
},
|
||||||
creatorTextBox = new LabelledTextBox
|
creatorTextBox = new LabelledTextBox
|
||||||
{
|
{
|
||||||
Label = "Creator",
|
Label = "Creator",
|
||||||
Current = { Value = Beatmap.Value.Metadata.AuthorString },
|
Current = { Value = Beatmap.Metadata.AuthorString },
|
||||||
TabbableContentContainer = this
|
TabbableContentContainer = this
|
||||||
},
|
},
|
||||||
difficultyTextBox = new LabelledTextBox
|
difficultyTextBox = new LabelledTextBox
|
||||||
{
|
{
|
||||||
Label = "Difficulty Name",
|
Label = "Difficulty Name",
|
||||||
Current = { Value = Beatmap.Value.BeatmapInfo.Version },
|
Current = { Value = Beatmap.BeatmapInfo.Version },
|
||||||
TabbableContentContainer = this
|
TabbableContentContainer = this
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -62,10 +62,10 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
|
|
||||||
// for now, update these on commit rather than making BeatmapMetadata bindables.
|
// for now, update these on commit rather than making BeatmapMetadata bindables.
|
||||||
// after switching database engines we can reconsider if switching to bindables is a good direction.
|
// after switching database engines we can reconsider if switching to bindables is a good direction.
|
||||||
Beatmap.Value.Metadata.Artist = artistTextBox.Current.Value;
|
Beatmap.Metadata.Artist = artistTextBox.Current.Value;
|
||||||
Beatmap.Value.Metadata.Title = titleTextBox.Current.Value;
|
Beatmap.Metadata.Title = titleTextBox.Current.Value;
|
||||||
Beatmap.Value.Metadata.AuthorString = creatorTextBox.Current.Value;
|
Beatmap.Metadata.AuthorString = creatorTextBox.Current.Value;
|
||||||
Beatmap.Value.BeatmapInfo.Version = difficultyTextBox.Current.Value;
|
Beatmap.BeatmapInfo.Version = difficultyTextBox.Current.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,9 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapManager beatmaps { get; set; }
|
private BeatmapManager beatmaps { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IBindable<WorkingBeatmap> working { get; set; }
|
||||||
|
|
||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private Editor editor { get; set; }
|
private Editor editor { get; set; }
|
||||||
|
|
||||||
@ -70,7 +73,7 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
audioTrackTextBox = new FileChooserLabelledTextBox
|
audioTrackTextBox = new FileChooserLabelledTextBox
|
||||||
{
|
{
|
||||||
Label = "Audio Track",
|
Label = "Audio Track",
|
||||||
Current = { Value = Beatmap.Value.Metadata.AudioFile ?? "Click to select a track" },
|
Current = { Value = Beatmap.Metadata.AudioFile ?? "Click to select a track" },
|
||||||
Target = audioTrackFileChooserContainer,
|
Target = audioTrackFileChooserContainer,
|
||||||
TabbableContentContainer = this
|
TabbableContentContainer = this
|
||||||
},
|
},
|
||||||
@ -115,11 +118,11 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
if (!info.Exists)
|
if (!info.Exists)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var set = Beatmap.Value.BeatmapSetInfo;
|
var set = working.Value.BeatmapSetInfo;
|
||||||
|
|
||||||
// remove the previous background for now.
|
// remove the previous background for now.
|
||||||
// in the future we probably want to check if this is being used elsewhere (other difficulties?)
|
// in the future we probably want to check if this is being used elsewhere (other difficulties?)
|
||||||
var oldFile = set.Files.FirstOrDefault(f => f.Filename == Beatmap.Value.Metadata.BackgroundFile);
|
var oldFile = set.Files.FirstOrDefault(f => f.Filename == working.Value.Metadata.BackgroundFile);
|
||||||
|
|
||||||
using (var stream = info.OpenRead())
|
using (var stream = info.OpenRead())
|
||||||
{
|
{
|
||||||
@ -129,7 +132,7 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
beatmaps.AddFile(set, stream, info.Name);
|
beatmaps.AddFile(set, stream, info.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Beatmap.Value.Metadata.BackgroundFile = info.Name;
|
working.Value.Metadata.BackgroundFile = info.Name;
|
||||||
updateBackgroundSprite();
|
updateBackgroundSprite();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -148,11 +151,11 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
if (!info.Exists)
|
if (!info.Exists)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var set = Beatmap.Value.BeatmapSetInfo;
|
var set = working.Value.BeatmapSetInfo;
|
||||||
|
|
||||||
// remove the previous audio track for now.
|
// remove the previous audio track for now.
|
||||||
// in the future we probably want to check if this is being used elsewhere (other difficulties?)
|
// in the future we probably want to check if this is being used elsewhere (other difficulties?)
|
||||||
var oldFile = set.Files.FirstOrDefault(f => f.Filename == Beatmap.Value.Metadata.AudioFile);
|
var oldFile = set.Files.FirstOrDefault(f => f.Filename == working.Value.Metadata.AudioFile);
|
||||||
|
|
||||||
using (var stream = info.OpenRead())
|
using (var stream = info.OpenRead())
|
||||||
{
|
{
|
||||||
@ -162,7 +165,7 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
beatmaps.AddFile(set, stream, info.Name);
|
beatmaps.AddFile(set, stream, info.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Beatmap.Value.Metadata.AudioFile = info.Name;
|
working.Value.Metadata.AudioFile = info.Name;
|
||||||
|
|
||||||
music.ReloadCurrentTrack();
|
music.ReloadCurrentTrack();
|
||||||
|
|
||||||
@ -178,7 +181,7 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
|
|
||||||
private void updateBackgroundSprite()
|
private void updateBackgroundSprite()
|
||||||
{
|
{
|
||||||
LoadComponentAsync(new BeatmapBackgroundSprite(Beatmap.Value)
|
LoadComponentAsync(new BeatmapBackgroundSprite(working.Value)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
|
@ -2,10 +2,8 @@
|
|||||||
// 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 osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -19,7 +17,7 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
protected OsuColour Colours { get; private set; }
|
protected OsuColour Colours { get; private set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
protected IBindable<WorkingBeatmap> Beatmap { get; private set; }
|
protected EditorBeatmap Beatmap { get; private set; }
|
||||||
|
|
||||||
protected override Container<Drawable> Content => flow;
|
protected override Container<Drawable> Content => flow;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user