mirror of
https://github.com/ppy/osu.git
synced 2025-03-11 15:27:20 +08:00
Implement Play button, drop textures
This commit is contained in:
parent
d3a857edb9
commit
cfc920c9c1
@ -101,7 +101,7 @@ namespace osu.Game.GameModes.Play
|
|||||||
BeatmapSelected?.Invoke(BeatmapSet, map);
|
BeatmapSelected?.Invoke(BeatmapSet, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BeatmapGroup(BeatmapSetInfo beatmapSet, BeatmapResourceStore beatmapStore, TextureStore resources)
|
public BeatmapGroup(BeatmapSetInfo beatmapSet)
|
||||||
{
|
{
|
||||||
BeatmapSet = beatmapSet;
|
BeatmapSet = beatmapSet;
|
||||||
selectedBeatmap = beatmapSet.Beatmaps[0];
|
selectedBeatmap = beatmapSet.Beatmaps[0];
|
||||||
@ -118,7 +118,7 @@ namespace osu.Game.GameModes.Play
|
|||||||
Direction = FlowDirection.VerticalOnly,
|
Direction = FlowDirection.VerticalOnly,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
setBox = new BeatmapSetBox(beatmapSet, beatmapStore, resources)
|
setBox = new BeatmapSetBox(beatmapSet)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Size = new Vector2(collapsedWidth, -1),
|
Size = new Vector2(collapsedWidth, -1),
|
||||||
@ -164,15 +164,11 @@ namespace osu.Game.GameModes.Play
|
|||||||
class BeatmapSetBox : AutoSizeContainer
|
class BeatmapSetBox : AutoSizeContainer
|
||||||
{
|
{
|
||||||
private BeatmapSetInfo beatmapSet;
|
private BeatmapSetInfo beatmapSet;
|
||||||
private BeatmapResourceStore beatmapStore;
|
|
||||||
private TextureStore resources;
|
|
||||||
private Sprite backgroundImage;
|
private Sprite backgroundImage;
|
||||||
|
|
||||||
public BeatmapSetBox(BeatmapSetInfo beatmapSet, BeatmapResourceStore beatmapStore, TextureStore resources)
|
public BeatmapSetBox(BeatmapSetInfo beatmapSet)
|
||||||
{
|
{
|
||||||
this.beatmapSet = beatmapSet;
|
this.beatmapSet = beatmapSet;
|
||||||
this.beatmapStore = beatmapStore;
|
|
||||||
this.resources = resources;
|
|
||||||
Masking = true;
|
Masking = true;
|
||||||
CornerRadius = 5;
|
CornerRadius = 5;
|
||||||
BorderThickness = 2;
|
BorderThickness = 2;
|
||||||
@ -237,20 +233,6 @@ namespace osu.Game.GameModes.Play
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Load(Framework.BaseGame game)
|
|
||||||
{
|
|
||||||
base.Load(game);
|
|
||||||
if (beatmapSet.Metadata.BackgroundFile != null)
|
|
||||||
{
|
|
||||||
Task.Factory.StartNew(() =>
|
|
||||||
{
|
|
||||||
beatmapStore.AddBeatmap(beatmapSet);
|
|
||||||
var texture = resources.Get($@"{beatmapSet.BeatmapSetID}:{beatmapSet.Metadata.BackgroundFile}");
|
|
||||||
Scheduler.Add(() => backgroundImage.Texture = texture);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DifficultyIcon : Container
|
class DifficultyIcon : Container
|
||||||
|
@ -27,8 +27,6 @@ namespace osu.Game.GameModes.Play
|
|||||||
private BeatmapDatabase beatmaps;
|
private BeatmapDatabase beatmaps;
|
||||||
private BeatmapSetInfo selectedBeatmapSet;
|
private BeatmapSetInfo selectedBeatmapSet;
|
||||||
private BeatmapInfo selectedBeatmap;
|
private BeatmapInfo selectedBeatmap;
|
||||||
private BeatmapResourceStore beatmapResources;
|
|
||||||
private TextureStore beatmapTextureResources;
|
|
||||||
// TODO: use currently selected track as bg
|
// TODO: use currently selected track as bg
|
||||||
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
|
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
|
||||||
private ScrollContainer scrollContainer;
|
private ScrollContainer scrollContainer;
|
||||||
@ -62,7 +60,7 @@ namespace osu.Game.GameModes.Play
|
|||||||
beatmapSet.Beatmaps.ForEach(b => beatmaps.GetChildren(b));
|
beatmapSet.Beatmaps.ForEach(b => beatmaps.GetChildren(b));
|
||||||
beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.BaseDifficulty.OverallDifficulty)
|
beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.BaseDifficulty.OverallDifficulty)
|
||||||
.ToList();
|
.ToList();
|
||||||
var group = new BeatmapGroup(beatmapSet, beatmapResources, beatmapTextureResources);
|
var group = new BeatmapGroup(beatmapSet);
|
||||||
group.SetSelected += selectBeatmapSet;
|
group.SetSelected += selectBeatmapSet;
|
||||||
group.BeatmapSelected += selectBeatmap;
|
group.BeatmapSelected += selectBeatmap;
|
||||||
setList.Add(group);
|
setList.Add(group);
|
||||||
@ -121,6 +119,32 @@ namespace osu.Game.GameModes.Play
|
|||||||
Spacing = new Vector2(0, 5),
|
Spacing = new Vector2(0, 5),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Size = new Vector2(1, 50),
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Size = Vector2.One,
|
||||||
|
Colour = new Color4(0, 0, 0, 0.5f),
|
||||||
|
},
|
||||||
|
new Button
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
Size = new Vector2(100, 1),
|
||||||
|
Text = "Play",
|
||||||
|
Colour = new Color4(238, 51, 153, 255),
|
||||||
|
Action = () => Push(new Player { /*Beatmap = selectedBeatmap*/ }),
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -139,8 +163,6 @@ namespace osu.Game.GameModes.Play
|
|||||||
}
|
}
|
||||||
|
|
||||||
beatmaps = (game as OsuGameBase).Beatmaps;
|
beatmaps = (game as OsuGameBase).Beatmaps;
|
||||||
beatmapTextureResources = new TextureStore(
|
|
||||||
new RawTextureLoaderStore(beatmapResources = new BeatmapResourceStore(beatmaps)));
|
|
||||||
beatmaps.BeatmapSetAdded += bset => Scheduler.Add(() => addBeatmapSet(bset));
|
beatmaps.BeatmapSetAdded += bset => Scheduler.Add(() => addBeatmapSet(bset));
|
||||||
addBeatmapSets();
|
addBeatmapSets();
|
||||||
var first = setList.Children.FirstOrDefault() as BeatmapGroup;
|
var first = setList.Children.FirstOrDefault() as BeatmapGroup;
|
||||||
@ -157,8 +179,6 @@ namespace osu.Game.GameModes.Play
|
|||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
if (playMode != null)
|
if (playMode != null)
|
||||||
playMode.ValueChanged -= PlayMode_ValueChanged;
|
playMode.ValueChanged -= PlayMode_ValueChanged;
|
||||||
if (beatmapResources != null)
|
|
||||||
beatmapResources.Dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PlayMode_ValueChanged(object sender, EventArgs e)
|
private void PlayMode_ValueChanged(object sender, EventArgs e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user