1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 03:27:24 +08:00

Merge branch 'master' into fix-player-loader

This commit is contained in:
Dean Herbert 2018-03-22 15:46:37 +09:00 committed by GitHub
commit 5f1bb8d753
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 159 additions and 35 deletions

@ -1 +1 @@
Subproject commit 41e2a0a4304544fb67779c21cad1435c105982d5
Subproject commit cc39713fbf9427aa53df91e27ecd09d15661089f

View File

@ -16,11 +16,9 @@
<language>en-AU</language>
</metadata>
<files>
<file src="*.exe" target="lib\net45\" exclude="**vshost**"/>
<file src="*.dll" target="lib\net45\"/>
<file src="*.config" target="lib\net45\"/>
<file src="x86\*.dll" target="lib\net45\x86\"/>
<file src="x64\*.dll" target="lib\net45\x64\"/>
<file src="**.exe" target="lib\net45\" exclude="**vshost**"/>
<file src="**.dll" target="lib\net45\"/>
<file src="**.config" target="lib\net45\"/>
</files>
</package>

View File

@ -96,7 +96,7 @@ namespace osu.Game.Beatmaps.Formats
private void handleGeneral(string line)
{
var pair = SplitKeyVal(line, ':');
var pair = SplitKeyVal(line);
var metadata = beatmap.BeatmapInfo.Metadata;
switch (pair.Key)
@ -155,7 +155,7 @@ namespace osu.Game.Beatmaps.Formats
private void handleEditor(string line)
{
var pair = SplitKeyVal(line, ':');
var pair = SplitKeyVal(line);
switch (pair.Key)
{
@ -179,7 +179,7 @@ namespace osu.Game.Beatmaps.Formats
private void handleMetadata(string line)
{
var pair = SplitKeyVal(line, ':');
var pair = SplitKeyVal(line);
var metadata = beatmap.BeatmapInfo.Metadata;
switch (pair.Key)
@ -220,7 +220,7 @@ namespace osu.Game.Beatmaps.Formats
private void handleDifficulty(string line)
{
var pair = SplitKeyVal(line, ':');
var pair = SplitKeyVal(line);
var difficulty = beatmap.BeatmapInfo.BaseDifficulty;
switch (pair.Key)

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using osu.Framework.Logging;
using OpenTK.Graphics;
namespace osu.Game.Beatmaps.Formats
@ -31,7 +32,11 @@ namespace osu.Game.Beatmaps.Formats
if (line.StartsWith(@"[") && line.EndsWith(@"]"))
{
if (!Enum.TryParse(line.Substring(1, line.Length - 2), out section))
throw new InvalidDataException($@"Unknown osu section {line}");
{
Logger.Log($"Unknown section \"{line}\" in {beatmap}");
section = Section.None;
}
continue;
}
@ -55,7 +60,7 @@ namespace osu.Game.Beatmaps.Formats
private void handleColours(T output, string line)
{
var pair = SplitKeyVal(line, ':');
var pair = SplitKeyVal(line);
bool isCombo = pair.Key.StartsWith(@"Combo");
@ -89,7 +94,7 @@ namespace osu.Game.Beatmaps.Formats
}
}
protected KeyValuePair<string, string> SplitKeyVal(string line, char separator)
protected KeyValuePair<string, string> SplitKeyVal(string line, char separator = ':')
{
var split = line.Trim().Split(new[] { separator }, 2);

View File

@ -13,6 +13,7 @@ using osu.Game.IO;
using osu.Game.IO.Archives;
using osu.Game.IPC;
using osu.Game.Overlays.Notifications;
using SharpCompress.Common;
using FileInfo = osu.Game.IO.FileInfo;
namespace osu.Game.Database
@ -79,7 +80,6 @@ namespace osu.Game.Database
var notification = new ProgressNotification
{
Text = "Import is initialising...",
CompletionText = "Import successful!",
Progress = 0,
State = ProgressNotificationState.Active,
};
@ -88,7 +88,8 @@ namespace osu.Game.Database
List<TModel> imported = new List<TModel>();
int i = 0;
int current = 0;
int errors = 0;
foreach (string path in paths)
{
if (notification.State == ProgressNotificationState.Cancelled)
@ -97,11 +98,11 @@ namespace osu.Game.Database
try
{
notification.Text = $"Importing ({i} of {paths.Length})\n{Path.GetFileName(path)}";
notification.Text = $"Importing ({++current} of {paths.Length})\n{Path.GetFileName(path)}";
using (ArchiveReader reader = getReaderFrom(path))
imported.Add(Import(reader));
notification.Progress = (float)++i / paths.Length;
notification.Progress = (float)current / paths.Length;
// We may or may not want to delete the file depending on where it is stored.
// e.g. reconstructing/repairing database with items from default storage.
@ -121,9 +122,11 @@ namespace osu.Game.Database
{
e = e.InnerException ?? e;
Logger.Error(e, $@"Could not import ({Path.GetFileName(path)})");
errors++;
}
}
notification.Text = errors > 0 ? $"Import complete with {errors} errors" : "Import successful!";
notification.State = ProgressNotificationState.Completed;
}
@ -218,9 +221,11 @@ namespace osu.Game.Database
// user requested abort
return;
notification.Text = $"Deleting ({i} of {items.Count})";
notification.Progress = (float)++i / items.Count;
notification.Text = $"Deleting ({++i} of {items.Count})";
Delete(b);
notification.Progress = (float)i / items.Count;
}
}
@ -254,9 +259,11 @@ namespace osu.Game.Database
// user requested abort
return;
notification.Text = $"Restoring ({i} of {items.Count})";
notification.Progress = (float)++i / items.Count;
notification.Text = $"Restoring ({++i} of {items.Count})";
Undelete(item);
notification.Progress = (float)i / items.Count;
}
}
@ -331,7 +338,9 @@ namespace osu.Game.Database
{
if (ZipFile.IsZipFile(path))
return new ZipArchiveReader(Files.Storage.GetStream(path), Path.GetFileName(path));
if (Directory.Exists(path))
return new LegacyFilesystemReader(path);
throw new InvalidFormatException($"{path} is not a valid archive");
}
}
}

View File

@ -242,7 +242,7 @@ namespace osu.Game.Graphics.Backgrounds
triangle,
colourInfo,
null,
Shared.VertexBatch.Add,
Shared.VertexBatch.AddAction,
Vector2.Divide(localInflationAmount, size));
}

View File

@ -47,7 +47,7 @@ namespace osu.Game.Overlays.Settings.Sections
},
};
void reloadSkins() => skinDropdown.Items = skins.GetAllUsableSkins().Select(s => new KeyValuePair<string, int>(s.Name, s.ID));
void reloadSkins() => skinDropdown.Items = skins.GetAllUsableSkins().Select(s => new KeyValuePair<string, int>(s.ToString(), s.ID));
skins.ItemAdded += _ => reloadSkins();
skins.ItemRemoved += _ => reloadSkins();

View File

@ -211,7 +211,7 @@ namespace osu.Game.Screens.Menu
rectangle,
colourInfo,
null,
Shared.VertexBatch.Add,
Shared.VertexBatch.AddAction,
//barSize by itself will make it smooth more in the X axis than in the Y axis, this reverts that.
Vector2.Divide(inflation, barSize.Yx));
}

View File

@ -337,12 +337,10 @@ namespace osu.Game.Screens.Menu
}
}
private bool interactive => Action != null && Alpha > 0.2f;
public override bool HandleMouseInput => base.HandleMouseInput && Action != null && Alpha > 0.2f;
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
if (!interactive) return false;
logoBounceContainer.ScaleTo(0.9f, 1000, Easing.Out);
return true;
}
@ -355,8 +353,6 @@ namespace osu.Game.Screens.Menu
protected override bool OnClick(InputState state)
{
if (!interactive) return false;
if (Action?.Invoke() ?? true)
sampleClick.Play();
@ -368,8 +364,6 @@ namespace osu.Game.Screens.Menu
protected override bool OnHover(InputState state)
{
if (!interactive) return false;
logoHoverContainer.ScaleTo(1.1f, 500, Easing.OutElastic);
return true;
}

View File

@ -259,6 +259,8 @@ namespace osu.Game.Screens.Select
private void workingBeatmapChanged(WorkingBeatmap beatmap)
{
if (beatmap is DummyWorkingBeatmap) return;
if (IsCurrentScreen && !Carousel.SelectBeatmap(beatmap?.BeatmapInfo, false))
// If selecting new beatmap without bypassing filters failed, there's possibly a ruleset mismatch
if (beatmap?.BeatmapInfo?.Ruleset != null && beatmap.BeatmapInfo.Ruleset != Ruleset.Value)

View File

@ -11,6 +11,7 @@ namespace osu.Game.Skinning
public DefaultSkin()
: base(SkinInfo.Default)
{
Configuration = new SkinConfiguration();
}
public override Drawable GetDrawableComponent(string componentName)

View File

@ -25,6 +25,14 @@ namespace osu.Game.Skinning
storage = new LegacySkinResourceStore(skin, storage);
samples = audioManager.GetSampleManager(storage);
textures = new TextureStore(new RawTextureLoaderStore(storage));
Stream stream = storage.GetStream("skin.ini");
if (stream != null)
using (StreamReader reader = new StreamReader(stream))
Configuration = new LegacySkinDecoder().Decode(reader);
else
Configuration = new SkinConfiguration();
}
public override Drawable GetDrawableComponent(string componentName)
@ -60,10 +68,12 @@ namespace osu.Game.Skinning
private string getPathForFile(string filename)
{
bool hasExtension = filename.Contains('.');
string lastPiece = filename.Split('/').Last();
var file = skin.Files.FirstOrDefault(f =>
string.Equals(Path.GetFileNameWithoutExtension(f.Filename), lastPiece, StringComparison.InvariantCultureIgnoreCase));
string.Equals(hasExtension ? f.Filename : Path.GetFileNameWithoutExtension(f.Filename), lastPiece, StringComparison.InvariantCultureIgnoreCase));
return file?.FileInfo.StoragePath;
}
@ -73,9 +83,17 @@ namespace osu.Game.Skinning
this.underlyingStore = underlyingStore;
}
public Stream GetStream(string name) => underlyingStore.GetStream(getPathForFile(name));
public Stream GetStream(string name)
{
string path = getPathForFile(name);
return path == null ? null : underlyingStore.GetStream(path);
}
byte[] IResourceStore<byte[]>.Get(string name) => underlyingStore.Get(getPathForFile(name));
byte[] IResourceStore<byte[]>.Get(string name)
{
string path = getPathForFile(name);
return path == null ? null : underlyingStore.Get(path);
}
}
}
}

View File

@ -0,0 +1,38 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Beatmaps.Formats;
namespace osu.Game.Skinning
{
public class LegacySkinDecoder : LegacyDecoder<SkinConfiguration>
{
public LegacySkinDecoder()
: base(1)
{
}
protected override void ParseLine(SkinConfiguration output, Section section, string line)
{
switch (section)
{
case Section.General:
var pair = SplitKeyVal(line);
switch (pair.Key)
{
case @"Name":
output.SkinInfo.Name = pair.Value;
break;
case @"Author":
output.SkinInfo.Creator = pair.Value;
break;
}
break;
}
base.ParseLine(output, section, line);
}
}
}

View File

@ -10,6 +10,8 @@ namespace osu.Game.Skinning
{
public readonly SkinInfo SkinInfo;
public virtual SkinConfiguration Configuration { get; protected set; }
public abstract Drawable GetDrawableComponent(string componentName);
public abstract SampleChannel GetSample(string sampleName);

View File

@ -0,0 +1,18 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Game.Beatmaps.Formats;
using OpenTK.Graphics;
namespace osu.Game.Skinning
{
public class SkinConfiguration : IHasComboColours, IHasCustomColours
{
public readonly SkinInfo SkinInfo = new SkinInfo();
public List<Color4> ComboColours { get; set; } = new List<Color4>();
public Dictionary<string, Color4> CustomColours { get; set; } = new Dictionary<string, Color4>();
}
}

View File

@ -24,5 +24,7 @@ namespace osu.Game.Skinning
public static SkinInfo Default { get; } = new SkinInfo { Name = "osu!lazer", Creator = "team osu!" };
public bool Equals(SkinInfo other) => other != null && ID == other.ID;
public override string ToString() => $"\"{Name}\" by {Creator}";
}
}

View File

@ -39,6 +39,31 @@ namespace osu.Game.Skinning
Name = archive.Name
};
protected override void Populate(SkinInfo model, ArchiveReader archive)
{
base.Populate(model, archive);
populate(model);
}
/// <summary>
/// Populate a <see cref="SkinInfo"/> from its <see cref="SkinConfiguration"/> (if possible).
/// </summary>
/// <param name="model"></param>
private void populate(SkinInfo model)
{
Skin reference = GetSkin(model);
if (!string.IsNullOrEmpty(reference.Configuration.SkinInfo.Name))
{
model.Name = reference.Configuration.SkinInfo.Name;
model.Creator = reference.Configuration.SkinInfo.Creator;
}
else
{
model.Name = model.Name.Replace(".osk", "");
model.Creator = "Unknown";
}
}
/// <summary>
/// Retrieve a <see cref="Skin"/> instance for the provided <see cref="SkinInfo"/>
/// </summary>
@ -65,6 +90,16 @@ namespace osu.Game.Skinning
if (skin.SkinInfo != CurrentSkinInfo.Value)
throw new InvalidOperationException($"Setting {nameof(CurrentSkin)}'s value directly is not supported. Use {nameof(CurrentSkinInfo)} instead.");
};
// migrate older imports which didn't have access to skin.ini
using (ContextFactory.GetForWrite())
{
foreach (var skinInfo in ModelStore.ConsumableItems.Where(s => s.Name.EndsWith(".osk")))
{
populate(skinInfo);
Update(skinInfo);
}
}
}
/// <summary>

View File

@ -873,7 +873,9 @@
<Compile Include="Screens\Tournament\Teams\StorageBackedTeamList.cs" />
<Compile Include="Skinning\DefaultSkin.cs" />
<Compile Include="Skinning\LegacySkin.cs" />
<Compile Include="Skinning\LegacySkinDecoder.cs" />
<Compile Include="Skinning\Skin.cs" />
<Compile Include="Skinning\SkinConfiguration.cs" />
<Compile Include="Skinning\SkinFileInfo.cs" />
<Compile Include="Skinning\SkinInfo.cs" />
<Compile Include="Skinning\SkinManager.cs" />