mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 15:07:44 +08:00
General cleanup per PR feedback
This commit is contained in:
parent
fd867b2eb7
commit
55e5ec6fae
@ -13,7 +13,7 @@ namespace osu.Desktop.VisualTests
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
BasicGameHost host = Host.GetSuitableHost(@"osu");
|
||||
BasicGameHost host = Host.GetSuitableHost(@"osu-visual-tests");
|
||||
host.Add(new VisualTestGame());
|
||||
host.Run();
|
||||
}
|
||||
|
@ -1,49 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Beatmaps.IO
|
||||
{
|
||||
public class BeatmapResourceStore : IResourceStore<byte[]>, IDisposable
|
||||
{
|
||||
private Dictionary<int, ArchiveReader> beatmaps = new Dictionary<int, ArchiveReader>();
|
||||
private BeatmapDatabase database;
|
||||
|
||||
public BeatmapResourceStore(BeatmapDatabase database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
public void AddBeatmap(BeatmapSetInfo setInfo)
|
||||
{
|
||||
beatmaps.Add(setInfo.BeatmapSetID, database.GetReader(setInfo));
|
||||
}
|
||||
|
||||
public void RemoveBeatmap(BeatmapSetInfo setInfo)
|
||||
{
|
||||
beatmaps[setInfo.BeatmapSetID].Dispose();
|
||||
beatmaps.Remove(setInfo.BeatmapSetID);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var b in beatmaps.Values)
|
||||
b.Dispose();
|
||||
}
|
||||
|
||||
public byte[] Get(string name)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Stream GetStream(string name)
|
||||
{
|
||||
string id = name.Remove(name.IndexOf(':'));
|
||||
string path = name.Substring(name.IndexOf(':') + 1);
|
||||
var reader = beatmaps[int.Parse(id)];
|
||||
return reader.ReadFile(path);
|
||||
}
|
||||
}
|
||||
}
|
@ -35,8 +35,8 @@ namespace osu.Game.GameModes.Play
|
||||
}
|
||||
}
|
||||
|
||||
public event Action<BeatmapSetInfo> SetSelected;
|
||||
public event Action<BeatmapSetInfo, BeatmapInfo> BeatmapSelected;
|
||||
public Action<BeatmapSetInfo> SetSelected;
|
||||
public Action<BeatmapSetInfo, BeatmapInfo> BeatmapSelected;
|
||||
public BeatmapSetInfo BeatmapSet;
|
||||
private BeatmapSetBox setBox;
|
||||
private FlowContainer topContainer;
|
||||
@ -50,19 +50,13 @@ namespace osu.Game.GameModes.Play
|
||||
if (collapsed == value)
|
||||
return;
|
||||
collapsed = value;
|
||||
this.ClearTransformations();
|
||||
ClearTransformations();
|
||||
const float uncollapsedAlpha = 1;
|
||||
Transforms.Add(new TransformAlpha(Clock)
|
||||
{
|
||||
StartValue = collapsed ? uncollapsedAlpha : collapsedAlpha,
|
||||
EndValue = collapsed ? collapsedAlpha : uncollapsedAlpha,
|
||||
StartTime = Time,
|
||||
EndTime = Time + 250,
|
||||
});
|
||||
FadeTo(collapsed ? collapsedAlpha : uncollapsedAlpha, 250);
|
||||
if (collapsed)
|
||||
topContainer.Remove(difficulties);
|
||||
difficulties.Hide();
|
||||
else
|
||||
topContainer.Add(difficulties);
|
||||
difficulties.Show();
|
||||
setBox.ClearTransformations();
|
||||
setBox.Width = collapsed ? collapsedWidth : 1; // TODO: Transform
|
||||
setBox.BorderColour = new Color4(
|
||||
@ -73,21 +67,6 @@ namespace osu.Game.GameModes.Play
|
||||
setBox.GlowRadius = collapsed ? 0 : 5;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSelected(BeatmapInfo map)
|
||||
{
|
||||
int selected = BeatmapSet.Beatmaps.IndexOf(map);
|
||||
var buttons = difficulties.Children.ToList();
|
||||
for (int i = 0; i < buttons.Count; i++)
|
||||
{
|
||||
var button = buttons[i] as BeatmapButton;
|
||||
float targetWidth = 1 - Math.Abs((selected - i) * 0.025f);
|
||||
targetWidth = MathHelper.Clamp(targetWidth, 0.8f, 1);
|
||||
button.Width = targetWidth; // TODO: Transform
|
||||
button.Selected = selected == i;
|
||||
}
|
||||
BeatmapSelected?.Invoke(BeatmapSet, map);
|
||||
}
|
||||
|
||||
public BeatmapGroup(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
@ -104,7 +83,7 @@ namespace osu.Game.GameModes.Play
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FlowDirection.VerticalOnly,
|
||||
Children = new[]
|
||||
Children = new Drawable[]
|
||||
{
|
||||
setBox = new BeatmapSetBox(beatmapSet)
|
||||
{
|
||||
@ -112,36 +91,45 @@ namespace osu.Game.GameModes.Play
|
||||
Width = collapsedWidth,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
},
|
||||
difficulties = new FlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Margin = new MarginPadding { Top = 5 },
|
||||
Padding = new MarginPadding { Left = 75 },
|
||||
Spacing = new Vector2(0, 5),
|
||||
Direction = FlowDirection.VerticalOnly,
|
||||
Alpha = 0,
|
||||
Children = BeatmapSet.Beatmaps.Select(
|
||||
b => {
|
||||
float width = difficultyWidth;
|
||||
if (difficultyWidth > 0.8f) difficultyWidth -= 0.025f;
|
||||
return new BeatmapPanel(BeatmapSet, b)
|
||||
{
|
||||
MapSelected = updateSelected,
|
||||
Selected = width == 1,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = width,
|
||||
};
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
difficulties = new FlowContainer // Deliberately not added to children
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Margin = new MarginPadding { Top = 5 },
|
||||
Padding = new MarginPadding { Left = 75 },
|
||||
Spacing = new Vector2(0, 5),
|
||||
Direction = FlowDirection.VerticalOnly,
|
||||
Children = this.BeatmapSet.Beatmaps.Select(
|
||||
b => {
|
||||
float width = difficultyWidth;
|
||||
if (difficultyWidth > 0.8f) difficultyWidth -= 0.025f;
|
||||
return new BeatmapButton(this.BeatmapSet, b)
|
||||
{
|
||||
MapSelected = beatmap => updateSelected(beatmap),
|
||||
Selected = width == 1,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = width,
|
||||
};
|
||||
})
|
||||
};
|
||||
|
||||
collapsed = true;
|
||||
}
|
||||
|
||||
private void updateSelected(BeatmapInfo map)
|
||||
{
|
||||
foreach (BeatmapPanel panel in difficulties.Children)
|
||||
panel.Selected = panel.Beatmap == map;
|
||||
BeatmapSelected?.Invoke(BeatmapSet, map);
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
SetSelected?.Invoke(BeatmapSet);
|
||||
@ -151,12 +139,8 @@ namespace osu.Game.GameModes.Play
|
||||
|
||||
class BeatmapSetBox : Container
|
||||
{
|
||||
private BeatmapSetInfo beatmapSet;
|
||||
private Sprite backgroundImage;
|
||||
|
||||
public BeatmapSetBox(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
this.beatmapSet = beatmapSet;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Masking = true;
|
||||
CornerRadius = 5;
|
||||
@ -177,12 +161,6 @@ namespace osu.Game.GameModes.Play
|
||||
Size = Vector2.One,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
backgroundImage = new Sprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
new Box // TODO: Gradient
|
||||
{
|
||||
Colour = new Color4(0, 0, 0, 100),
|
||||
@ -202,12 +180,12 @@ namespace osu.Game.GameModes.Play
|
||||
// TODO: Make these italic
|
||||
new SpriteText
|
||||
{
|
||||
Text = this.beatmapSet.Metadata.Title ?? this.beatmapSet.Metadata.TitleUnicode,
|
||||
Text = beatmapSet.Metadata.Title ?? beatmapSet.Metadata.TitleUnicode,
|
||||
TextSize = 20
|
||||
},
|
||||
new SpriteText
|
||||
{
|
||||
Text = this.beatmapSet.Metadata.Artist ?? this.beatmapSet.Metadata.ArtistUnicode,
|
||||
Text = beatmapSet.Metadata.Artist ?? beatmapSet.Metadata.ArtistUnicode,
|
||||
TextSize = 16
|
||||
},
|
||||
new FlowContainer
|
||||
|
@ -2,29 +2,22 @@
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.GameModes.Backgrounds;
|
||||
using osu.Framework;
|
||||
using osu.Game.Database;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.GameModes.Play
|
||||
{
|
||||
class BeatmapButton : Container
|
||||
class BeatmapPanel : Container
|
||||
{
|
||||
private BeatmapSetInfo beatmapSet;
|
||||
private BeatmapInfo beatmap;
|
||||
public BeatmapInfo Beatmap;
|
||||
|
||||
public Action<BeatmapInfo> MapSelected;
|
||||
|
||||
@ -47,10 +40,9 @@ namespace osu.Game.GameModes.Play
|
||||
}
|
||||
}
|
||||
|
||||
public BeatmapButton(BeatmapSetInfo set, BeatmapInfo beatmap)
|
||||
public BeatmapPanel(BeatmapSetInfo set, BeatmapInfo beatmap)
|
||||
{
|
||||
this.beatmapSet = set;
|
||||
this.beatmap = beatmap;
|
||||
Beatmap = beatmap;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Masking = true;
|
||||
CornerRadius = 5;
|
||||
@ -109,7 +101,7 @@ namespace osu.Game.GameModes.Play
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
MapSelected?.Invoke(beatmap);
|
||||
MapSelected?.Invoke(Beatmap);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -34,59 +34,6 @@ namespace osu.Game.GameModes.Play
|
||||
private ScrollContainer scrollContainer;
|
||||
private FlowContainer setList;
|
||||
|
||||
private void selectBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
selectedBeatmapSet = beatmapSet;
|
||||
foreach (var child in setList.Children)
|
||||
{
|
||||
var childGroup = child as BeatmapGroup;
|
||||
if (childGroup.BeatmapSet == beatmapSet)
|
||||
{
|
||||
childGroup.Collapsed = false;
|
||||
selectedBeatmap = childGroup.SelectedBeatmap;
|
||||
}
|
||||
else
|
||||
childGroup.Collapsed = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void selectBeatmap(BeatmapSetInfo set, BeatmapInfo beatmap)
|
||||
{
|
||||
selectBeatmapSet(set);
|
||||
selectedBeatmap = beatmap;
|
||||
}
|
||||
|
||||
private Stopwatch watch = new Stopwatch();
|
||||
|
||||
private void addBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
watch.Reset();
|
||||
watch.Start();
|
||||
beatmapSet = beatmaps.GetWithChildren<BeatmapSetInfo>(beatmapSet.BeatmapSetID);
|
||||
beatmapSet.Beatmaps.ForEach(b => beatmaps.GetChildren(b));
|
||||
beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.BaseDifficulty.OverallDifficulty)
|
||||
.ToList();
|
||||
Scheduler.Add(() =>
|
||||
{
|
||||
var group = new BeatmapGroup(beatmapSet);
|
||||
group.SetSelected += selectBeatmapSet;
|
||||
group.BeatmapSelected += selectBeatmap;
|
||||
setList.Add(group);
|
||||
if (setList.Children.Count() == 1)
|
||||
{
|
||||
selectedBeatmapSet = group.BeatmapSet;
|
||||
selectedBeatmap = group.SelectedBeatmap;
|
||||
group.Collapsed = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addBeatmapSets()
|
||||
{
|
||||
foreach (var beatmapSet in beatmaps.Query<BeatmapSetInfo>())
|
||||
addBeatmapSet(beatmapSet);
|
||||
}
|
||||
|
||||
public PlaySongSelect()
|
||||
{
|
||||
const float scrollWidth = 640;
|
||||
@ -169,13 +116,13 @@ namespace osu.Game.GameModes.Play
|
||||
{
|
||||
base.Load(game);
|
||||
|
||||
OsuGame osu = game as OsuGame;
|
||||
if (osu != null)
|
||||
OsuGame osuGame = game as OsuGame;
|
||||
if (osuGame != null)
|
||||
{
|
||||
playMode = osu.PlayMode;
|
||||
playMode = osuGame.PlayMode;
|
||||
playMode.ValueChanged += PlayMode_ValueChanged;
|
||||
// Temporary:
|
||||
scrollContainer.Padding = new MarginPadding { Top = osu.Toolbar.Height };
|
||||
scrollContainer.Padding = new MarginPadding { Top = osuGame.Toolbar.Height };
|
||||
}
|
||||
|
||||
beatmaps = (game as OsuGameBase).Beatmaps;
|
||||
@ -193,5 +140,60 @@ namespace osu.Game.GameModes.Play
|
||||
private void PlayMode_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void selectBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
if (selectedBeatmapSet == beatmapSet)
|
||||
return;
|
||||
selectedBeatmapSet = beatmapSet;
|
||||
foreach (var child in setList.Children)
|
||||
{
|
||||
var childGroup = child as BeatmapGroup;
|
||||
if (childGroup.BeatmapSet == beatmapSet)
|
||||
{
|
||||
childGroup.Collapsed = false;
|
||||
selectedBeatmap = childGroup.SelectedBeatmap;
|
||||
}
|
||||
else
|
||||
childGroup.Collapsed = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void selectBeatmap(BeatmapSetInfo set, BeatmapInfo beatmap)
|
||||
{
|
||||
if (selectedBeatmap == beatmap)
|
||||
return;
|
||||
selectBeatmapSet(set);
|
||||
selectedBeatmap = beatmap;
|
||||
}
|
||||
|
||||
private void addBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
beatmapSet = beatmaps.GetWithChildren<BeatmapSetInfo>(beatmapSet.BeatmapSetID);
|
||||
beatmapSet.Beatmaps.ForEach(b => beatmaps.GetChildren(b));
|
||||
beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.BaseDifficulty.OverallDifficulty)
|
||||
.ToList();
|
||||
Scheduler.Add(() =>
|
||||
{
|
||||
var group = new BeatmapGroup(beatmapSet)
|
||||
{
|
||||
SetSelected = selectBeatmapSet,
|
||||
BeatmapSelected = selectBeatmap,
|
||||
};
|
||||
setList.Add(group);
|
||||
if (setList.Children.Count() == 1)
|
||||
{
|
||||
selectedBeatmapSet = group.BeatmapSet;
|
||||
selectedBeatmap = group.SelectedBeatmap;
|
||||
group.Collapsed = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addBeatmapSets()
|
||||
{
|
||||
foreach (var beatmapSet in beatmaps.Query<BeatmapSetInfo>())
|
||||
addBeatmapSet(beatmapSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@
|
||||
<Compile Include="GameModes\Play\ModSelect.cs" />
|
||||
<Compile Include="GameModes\Play\Osu\ScoreOverlayOsu.cs" />
|
||||
<Compile Include="GameModes\Play\BeatmapGroup.cs" />
|
||||
<Compile Include="GameModes\Play\BeatmapButton.cs" />
|
||||
<Compile Include="GameModes\Play\BeatmapPanel.cs" />
|
||||
<Compile Include="GameModes\Play\Player.cs" />
|
||||
<Compile Include="GameModes\Charts\ChartListing.cs" />
|
||||
<Compile Include="GameModes\Play\PlayMode.cs" />
|
||||
@ -191,7 +191,6 @@
|
||||
<Compile Include="Database\BeatmapMetadata.cs" />
|
||||
<Compile Include="Database\BeatmapInfo.cs" />
|
||||
<Compile Include="Database\BaseDifficulty.cs" />
|
||||
<Compile Include="Beatmaps\IO\BeatmapResourceStore.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||
|
Loading…
Reference in New Issue
Block a user