1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 06:43:21 +08:00

Merge branch 'master' of github.com:ppy/osu into peppy/hitcircle-revision-2

# Conflicts:
#	osu.Desktop.VisualTests/Tests/TestCasePlayer.cs
#	osu.Game/Beatmaps/Objects/Osu/Drawable/DrawableCircle.cs
This commit is contained in:
Thomas Müller 2016-11-05 13:35:15 +01:00
commit 07e74068e7
23 changed files with 144 additions and 66 deletions

@ -1 +1 @@
Subproject commit 2b9a56e8b3bb6c99bf4c75307639e6726fe8d3ec
Subproject commit ed33cc48996e9b57093c4d057aa0560319495dee

@ -1 +1 @@
Subproject commit c0781d1d557c3e5a00f6cf1780049e382f92c0c8
Subproject commit 5ce263988735b3f15c1195568b65fef40756198c

View File

@ -57,10 +57,7 @@ namespace osu.Desktop.VisualTests.Tests
Add(new Player
{
Beatmap = new WorkingBeatmap
{
Beatmap = b
}
Beatmap = new WorkingBeatmap(b)
});
}

View File

@ -29,7 +29,7 @@ namespace osu.Desktop.Beatmaps.IO
beatmaps = Directory.GetFiles(basePath, @"*.osu").Select(f => Path.GetFileName(f)).ToArray();
if (beatmaps.Length == 0)
throw new FileNotFoundException(@"This directory contains no beatmaps");
using (var stream = new StreamReader(ReadFile(beatmaps[0])))
using (var stream = new StreamReader(GetStream(beatmaps[0])))
{
var decoder = BeatmapDecoder.GetDecoder(stream);
firstMap = decoder.Decode(stream);
@ -41,7 +41,7 @@ namespace osu.Desktop.Beatmaps.IO
return beatmaps;
}
public override Stream ReadFile(string name)
public override Stream GetStream(string name)
{
return File.OpenRead(Path.Combine(basePath, name));
}

View File

@ -70,7 +70,7 @@ namespace osu.Game.Tests.Beatmaps.IO
{
var reader = new OszArchiveReader(osz);
using (var stream = new StreamReader(
reader.ReadFile("Soleily - Renatus (Deif) [Platter].osu")))
reader.GetStream("Soleily - Renatus (Deif) [Platter].osu")))
{
Assert.AreEqual("osu file format v13", stream.ReadLine().Trim());
}

View File

@ -52,7 +52,7 @@ namespace osu.Game.Beatmaps.Drawable
header.State = PanelSelectedState.Selected;
break;
case BeatmapGroupState.Collapsed:
FadeTo(0.5f, 250);
FadeTo(0.8f, 250);
header.State = PanelSelectedState.NotSelected;
difficulties.Hide();
@ -61,7 +61,7 @@ namespace osu.Game.Beatmaps.Drawable
}
}
public BeatmapGroup(BeatmapSetInfo beatmapSet)
public BeatmapGroup(BeatmapSetInfo beatmapSet, WorkingBeatmap working)
{
this.beatmapSet = beatmapSet;
@ -78,7 +78,7 @@ namespace osu.Game.Beatmaps.Drawable
Direction = FlowDirection.VerticalOnly,
Children = new Framework.Graphics.Drawable[]
{
header = new BeatmapSetHeader(beatmapSet)
header = new BeatmapSetHeader(beatmapSet, working)
{
GainedSelection = headerGainedSelection,
RelativeSizeAxes = Axes.X,

View File

@ -29,7 +29,7 @@ namespace osu.Game.Beatmaps.Drawable
public BeatmapPanel(BeatmapInfo beatmap)
{
Beatmap = beatmap;
Height *= 0.75f;
Height *= 0.60f;
Children = new Framework.Graphics.Drawable[]
{
@ -44,12 +44,20 @@ namespace osu.Game.Beatmaps.Drawable
Padding = new MarginPadding(5),
Direction = FlowDirection.HorizontalOnly,
AutoSizeAxes = Axes.Both,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Children = new Framework.Graphics.Drawable[]
{
new DifficultyIcon(FontAwesome.dot_circle_o, new Color4(159, 198, 0, 255)),
new DifficultyIcon(FontAwesome.dot_circle_o, new Color4(159, 198, 0, 255))
{
Scale = new Vector2(1.8f),
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
new FlowContainer
{
Padding = new MarginPadding { Left = 10 },
Padding = new MarginPadding { Left = 5 },
Spacing = new Vector2(0, 5),
Direction = FlowDirection.VerticalOnly,
AutoSizeAxes = Axes.Both,
Children = new Framework.Graphics.Drawable[]
@ -58,17 +66,32 @@ namespace osu.Game.Beatmaps.Drawable
{
Direction = FlowDirection.HorizontalOnly,
AutoSizeAxes = Axes.Both,
Spacing = new Vector2(4, 0),
Children = new[]
{
new SpriteText
{
Font = @"Exo2.0-Medium",
Text = beatmap.Version,
TextSize = 20,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft
},
new SpriteText
{
Text = $" mapped by {(beatmap.Metadata ?? beatmap.BeatmapSet.Metadata).Author}",
Font = @"Exo2.0-Medium",
Text = "mapped by",
TextSize = 16,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft
},
new SpriteText
{
Font = @"Exo2.0-MediumItalic",
Text = $"{(beatmap.Metadata ?? beatmap.BeatmapSet.Metadata).Author}",
TextSize = 16,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft
},
}
},

View File

@ -31,27 +31,18 @@ namespace osu.Game.Beatmaps.Drawable
Width = 0.8f;
}
public BeatmapSetHeader(BeatmapSetInfo beatmapSet)
public BeatmapSetHeader(BeatmapSetInfo beatmapSet, WorkingBeatmap working)
{
Children = new Framework.Graphics.Drawable[]
{
new Box
working.Background == null ? new Box{ RelativeSizeAxes = Axes.Both, Colour = new Color4(20, 20, 20, 255) } : new Sprite
{
Colour = new Color4(85, 85, 85, 255),
RelativeSizeAxes = Axes.Both,
},
new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Framework.Graphics.Drawable[]
{
new Box // TODO: Gradient
{
Colour = new Color4(0, 0, 0, 100),
RelativeSizeAxes = Axes.Both,
}
}
},
Texture = working.Background,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Scale = new Vector2(0.5f),
Colour = new Color4(200, 200, 200, 255),
},
new FlowContainer
{
Direction = FlowDirection.VerticalOnly,
@ -60,14 +51,15 @@ namespace osu.Game.Beatmaps.Drawable
AutoSizeAxes = Axes.Both,
Children = new[]
{
// TODO: Make these italic
new SpriteText
{
Font = @"Exo2.0-SemiBoldItalic",
Text = beatmapSet.Metadata.Title ?? beatmapSet.Metadata.TitleUnicode,
TextSize = 20
TextSize = 22
},
new SpriteText
{
Font = @"Exo2.0-MediumItalic",
Text = beatmapSet.Metadata.Artist ?? beatmapSet.Metadata.ArtistUnicode,
TextSize = 16
},

View File

@ -10,6 +10,7 @@ using osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Beatmaps.Drawable
@ -69,7 +70,13 @@ namespace osu.Game.Beatmaps.Drawable
BorderColour = new Color4(BorderColour.R, BorderColour.G, BorderColour.B, 0);
BorderThickness = 0;
EdgeEffect = new EdgeEffect { Type = EdgeEffectType.None };
EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Shadow,
Offset = new Vector2(1),
Radius = 10,
Colour = new Color4(0, 0, 0, 100),
};
}
protected override bool OnClick(InputState state)

View File

@ -1,12 +1,13 @@
using System;
using System.Collections.Generic;
using System.IO;
using osu.Framework.IO.Stores;
using osu.Framework.Platform;
using osu.Game.Database;
namespace osu.Game.Beatmaps.IO
{
public abstract class ArchiveReader : IDisposable
public abstract class ArchiveReader : IDisposable, IResourceStore<byte[]>
{
private class Reader
{
@ -42,8 +43,23 @@ namespace osu.Game.Beatmaps.IO
/// <summary>
/// Opens a stream for reading a specific file from this archive.
/// </summary>
public abstract Stream ReadFile(string name);
public abstract Stream GetStream(string name);
public abstract void Dispose();
public virtual byte[] Get(string name)
{
using (Stream input = GetStream(name))
{
if (input == null)
return null;
using (MemoryStream ms = new MemoryStream())
{
input.CopyTo(ms);
return ms.ToArray();
}
}
}
}
}

View File

@ -33,7 +33,7 @@ namespace osu.Game.Beatmaps.IO
.Select(e => e.FileName).ToArray();
if (beatmaps.Length == 0)
throw new FileNotFoundException(@"This directory contains no beatmaps");
using (var stream = new StreamReader(ReadFile(beatmaps[0])))
using (var stream = new StreamReader(GetStream(beatmaps[0])))
{
var decoder = BeatmapDecoder.GetDecoder(stream);
firstMap = decoder.Decode(stream);
@ -45,7 +45,7 @@ namespace osu.Game.Beatmaps.IO
return beatmaps;
}
public override Stream ReadFile(string name)
public override Stream GetStream(string name)
{
ZipEntry entry = archive.Entries.SingleOrDefault(e => e.FileName == name);
if (entry == null)

View File

@ -171,7 +171,7 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Additive = true,
BlendingMode = BlendingMode.Additive,
Alpha = 0.5f
}
};
@ -222,7 +222,7 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Additive = true;
BlendingMode = BlendingMode.Additive;
Alpha = 0;
Children = new Framework.Graphics.Drawable[]
@ -244,7 +244,7 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Additive = true;
BlendingMode = BlendingMode.Additive;
Alpha = 0;
Children = new Framework.Graphics.Drawable[]
@ -283,7 +283,7 @@ namespace osu.Game.Beatmaps.Objects.Osu.Drawable
},
triangles = new Triangles
{
Additive = true,
BlendingMode = BlendingMode.Additive,
RelativeSizeAxes = Axes.Both
}
};

View File

@ -13,6 +13,11 @@ namespace osu.Game.Beatmaps.Timing
{
public double BeatLength;
public TimingChange(double beatLength)
{
BeatLength = beatLength;
}
public double BPM => 60000 / BeatLength;
}
}

View File

@ -4,6 +4,7 @@
using System;
using System.IO;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps.Formats;
using osu.Game.Beatmaps.IO;
using osu.Game.Database;
@ -12,9 +13,30 @@ namespace osu.Game.Beatmaps
{
public class WorkingBeatmap : IDisposable
{
public BeatmapInfo BeatmapInfo;
public readonly BeatmapInfo BeatmapInfo;
public readonly ArchiveReader Reader;
public readonly BeatmapSetInfo BeatmapSetInfo;
private readonly BeatmapDatabase database;
private ArchiveReader reader => database.GetReader(BeatmapSetInfo);
private Texture background;
public Texture Background
{
get
{
if (background != null) return background;
try
{
background = new TextureStore(new RawTextureLoaderStore(reader)).Get(BeatmapInfo.Metadata.BackgroundFile);
}
catch { }
return background;
}
set { background = value; }
}
private Beatmap beatmap;
public Beatmap Beatmap
@ -25,7 +47,7 @@ namespace osu.Game.Beatmaps
try
{
using (var stream = new StreamReader(Reader.ReadFile(BeatmapInfo.Path)))
using (var stream = new StreamReader(reader.GetStream(BeatmapInfo.Path)))
beatmap = BeatmapDecoder.GetDecoder(stream)?.Decode(stream);
}
catch { }
@ -44,7 +66,7 @@ namespace osu.Game.Beatmaps
try
{
var trackData = Reader.ReadFile(BeatmapInfo.Metadata.AudioFile);
var trackData = reader.GetStream(BeatmapInfo.Metadata.AudioFile);
if (trackData != null)
track = new AudioTrackBass(trackData);
}
@ -55,10 +77,16 @@ namespace osu.Game.Beatmaps
set { track = value; }
}
public WorkingBeatmap(BeatmapInfo beatmapInfo = null, ArchiveReader reader = null)
public WorkingBeatmap(Beatmap beatmap)
{
this.beatmap = beatmap;
}
public WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, BeatmapDatabase database)
{
this.BeatmapInfo = beatmapInfo;
Reader = reader;
this.BeatmapSetInfo = beatmapSetInfo;
this.database = database;
}
private bool isDisposed;
@ -68,7 +96,7 @@ namespace osu.Game.Beatmaps
if (!isDisposed)
{
track?.Dispose();
Reader?.Dispose();
reader?.Dispose();
isDisposed = true;
}
}

View File

@ -95,7 +95,7 @@ namespace osu.Game.Database
string[] mapNames = reader.ReadBeatmaps();
foreach (var name in mapNames)
{
using (var stream = new StreamReader(reader.ReadFile(name)))
using (var stream = new StreamReader(reader.GetStream(name)))
{
var decoder = BeatmapDecoder.GetDecoder(stream);
Beatmap beatmap = decoder.Decode(stream);
@ -149,12 +149,10 @@ namespace osu.Game.Database
if (beatmapSetInfo == null)
throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetID} is not in the local database.");
var reader = GetReader(beatmapSetInfo);
if (beatmapInfo.Metadata == null)
beatmapInfo.Metadata = beatmapSetInfo.Metadata;
var working = new WorkingBeatmap(beatmapInfo, reader);
var working = new WorkingBeatmap(beatmapInfo, beatmapSetInfo, this);
previous?.TransferTo(working);

View File

@ -91,7 +91,7 @@ namespace osu.Game.GameModes
Origin = Anchor.Centre,
Colour = getColourFor(GetType()),
Alpha = 1,
Additive = false
BlendingMode = BlendingMode.Additive,
},
textContainer = new Container
{

View File

@ -35,7 +35,7 @@ namespace osu.Game.GameModes.Menu
logo = new OsuLogo()
{
Alpha = 0,
Additive = true,
BlendingMode = BlendingMode.Additive,
Interactive = false,
Colour = Color4.DarkGray,
Ripple = false

View File

@ -83,7 +83,7 @@ namespace osu.Game.GameModes.Menu
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Additive = true,
BlendingMode = BlendingMode.Additive,
Alpha = 0.05f
}
}
@ -93,7 +93,7 @@ namespace osu.Game.GameModes.Menu
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = logo.Size,
Additive = true,
BlendingMode = BlendingMode.Additive,
Alpha = 0.2f,
}
}

View File

@ -240,7 +240,10 @@ namespace osu.Game.GameModes.Play
beatmapSet = database.GetWithChildren<BeatmapSetInfo>(beatmapSet.BeatmapSetID);
beatmapSet.Beatmaps.ForEach(b => database.GetChildren(b));
beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.BaseDifficulty.OverallDifficulty).ToList();
var group = new BeatmapGroup(beatmapSet) { SelectionChanged = selectionChanged };
var working = database.GetWorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault());
var group = new BeatmapGroup(beatmapSet, working) { SelectionChanged = selectionChanged };
group.Preload(Game, g =>
{

View File

@ -10,7 +10,6 @@ using OpenTK.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework;
using System.Threading.Tasks;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Graphics.Background
{
@ -27,8 +26,6 @@ namespace osu.Game.Graphics.Background
Depth = float.MinValue;
}
Texture texture;
protected override void Load(BaseGame game)
{
base.Load(game);

View File

@ -65,9 +65,21 @@ namespace osu.Game
//this completely overrides the framework default. will need to change once we make a proper FontStore.
Fonts = new TextureStore() { ScaleAdjust = 0.01f };
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/FontAwesome"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/osuFont"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-RegularItalic"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBold"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-SemiBoldItalic"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Bold"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BoldItalic"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Light"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-LightItalic"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Medium"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Black"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-BlackItalic"));
API = new APIAccess()
{

View File

@ -44,7 +44,7 @@ namespace osu.Game.Overlays
new ScrollContainer
{
RelativeSizeAxes = Axes.Both,
ScrollDraggerOnLeft = true,
ScrollDraggerAnchor = Anchor.TopLeft,
Children = new[]
{
new FlowContainer

View File

@ -66,7 +66,7 @@ namespace osu.Game.Overlays
HoverBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Additive = true,
BlendingMode = BlendingMode.Additive,
Colour = new Color4(60, 60, 60, 255),
Alpha = 0,
},