mirror of
https://github.com/ppy/osu.git
synced 2025-03-11 15:27:20 +08:00
Merge branch 'master' into counters-a
This commit is contained in:
commit
53cd698b3a
@ -1 +1 @@
|
|||||||
Subproject commit 30ff0e1a99a10e735611bb3ffa35352061f52d8a
|
Subproject commit 3629521379bea5d79cd41e35ad6c6dfe21b4f9e7
|
@ -31,7 +31,8 @@ namespace osu.Desktop.Beatmaps.IO
|
|||||||
using (var stream = new StreamReader(ReadFile(beatmaps[0])))
|
using (var stream = new StreamReader(ReadFile(beatmaps[0])))
|
||||||
{
|
{
|
||||||
var decoder = BeatmapDecoder.GetDecoder(stream);
|
var decoder = BeatmapDecoder.GetDecoder(stream);
|
||||||
firstMap = decoder.Decode(stream);
|
firstMap = new Beatmap();
|
||||||
|
decoder.Decode(stream, firstMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ using System.IO;
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.Formats;
|
using osu.Game.Beatmaps.Formats;
|
||||||
using osu.Game.Beatmaps.Objects.Osu;
|
using osu.Game.Beatmaps.Objects.Osu;
|
||||||
using osu.Game.Beatmaps.Samples;
|
using osu.Game.Beatmaps.Samples;
|
||||||
@ -25,7 +26,8 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new OsuLegacyDecoder();
|
var decoder = new OsuLegacyDecoder();
|
||||||
using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
||||||
{
|
{
|
||||||
var beatmap = decoder.Decode(new StreamReader(stream));
|
Beatmap beatmap = new Beatmap();
|
||||||
|
decoder.Decode(new StreamReader(stream), beatmap);
|
||||||
var meta = beatmap.Metadata;
|
var meta = beatmap.Metadata;
|
||||||
Assert.AreEqual(241526, meta.BeatmapSetID);
|
Assert.AreEqual(241526, meta.BeatmapSetID);
|
||||||
Assert.AreEqual("Soleily", meta.Artist);
|
Assert.AreEqual("Soleily", meta.Artist);
|
||||||
@ -47,7 +49,8 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new OsuLegacyDecoder();
|
var decoder = new OsuLegacyDecoder();
|
||||||
using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
||||||
{
|
{
|
||||||
var beatmap = decoder.Decode(new StreamReader(stream));
|
Beatmap beatmap = new Beatmap();
|
||||||
|
decoder.Decode(new StreamReader(stream), beatmap);
|
||||||
Assert.AreEqual(0, beatmap.AudioLeadIn);
|
Assert.AreEqual(0, beatmap.AudioLeadIn);
|
||||||
Assert.AreEqual(false, beatmap.Countdown);
|
Assert.AreEqual(false, beatmap.Countdown);
|
||||||
Assert.AreEqual(SampleSet.Soft, beatmap.SampleSet);
|
Assert.AreEqual(SampleSet.Soft, beatmap.SampleSet);
|
||||||
@ -65,7 +68,8 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new OsuLegacyDecoder();
|
var decoder = new OsuLegacyDecoder();
|
||||||
using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
||||||
{
|
{
|
||||||
var beatmap = decoder.Decode(new StreamReader(stream));
|
Beatmap beatmap = new Beatmap();
|
||||||
|
decoder.Decode(new StreamReader(stream), beatmap);
|
||||||
int[] expectedBookmarks =
|
int[] expectedBookmarks =
|
||||||
{
|
{
|
||||||
11505, 22054, 32604, 43153, 53703, 64252, 74802, 85351,
|
11505, 22054, 32604, 43153, 53703, 64252, 74802, 85351,
|
||||||
@ -88,7 +92,8 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new OsuLegacyDecoder();
|
var decoder = new OsuLegacyDecoder();
|
||||||
using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
||||||
{
|
{
|
||||||
var beatmap = decoder.Decode(new StreamReader(stream));
|
Beatmap beatmap = new Beatmap();
|
||||||
|
decoder.Decode(new StreamReader(stream), beatmap);
|
||||||
var difficulty = beatmap.BaseDifficulty;
|
var difficulty = beatmap.BaseDifficulty;
|
||||||
Assert.AreEqual(6.5f, difficulty.DrainRate);
|
Assert.AreEqual(6.5f, difficulty.DrainRate);
|
||||||
Assert.AreEqual(4, difficulty.CircleSize);
|
Assert.AreEqual(4, difficulty.CircleSize);
|
||||||
@ -105,7 +110,8 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new OsuLegacyDecoder();
|
var decoder = new OsuLegacyDecoder();
|
||||||
using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
||||||
{
|
{
|
||||||
var beatmap = decoder.Decode(new StreamReader(stream));
|
Beatmap beatmap = new Beatmap();
|
||||||
|
decoder.Decode(new StreamReader(stream), beatmap);
|
||||||
Color4[] expected =
|
Color4[] expected =
|
||||||
{
|
{
|
||||||
new Color4(142, 199, 255, 255),
|
new Color4(142, 199, 255, 255),
|
||||||
@ -126,7 +132,8 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var decoder = new OsuLegacyDecoder();
|
var decoder = new OsuLegacyDecoder();
|
||||||
using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
||||||
{
|
{
|
||||||
var beatmap = decoder.Decode(new StreamReader(stream));
|
Beatmap beatmap = new Beatmap();
|
||||||
|
decoder.Decode(new StreamReader(stream), beatmap);
|
||||||
var slider = beatmap.HitObjects[0] as Slider;
|
var slider = beatmap.HitObjects[0] as Slider;
|
||||||
Assert.IsNotNull(slider);
|
Assert.IsNotNull(slider);
|
||||||
Assert.AreEqual(new Vector2(192, 168), slider.Position);
|
Assert.AreEqual(new Vector2(192, 168), slider.Position);
|
||||||
|
@ -17,10 +17,12 @@ namespace osu.Game.Beatmaps
|
|||||||
[NotNull, Indexed]
|
[NotNull, Indexed]
|
||||||
public int BeatmapMetadataID { get; set; }
|
public int BeatmapMetadataID { get; set; }
|
||||||
[Ignore]
|
[Ignore]
|
||||||
public List<Beatmap> Beatmaps { get; protected set; }
|
public List<Beatmap> Beatmaps { get; protected set; } = new List<Beatmap>();
|
||||||
[Ignore]
|
[Ignore]
|
||||||
public BeatmapMetadata Metadata { get; set; }
|
public BeatmapMetadata Metadata { get; set; }
|
||||||
[Ignore]
|
[Ignore]
|
||||||
public User Creator { get; set; }
|
public User Creator { get; set; }
|
||||||
|
public string Hash { get; set; }
|
||||||
|
public string Path { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,6 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
decoders[magic] = typeof(T);
|
decoders[magic] = typeof(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Beatmap Decode(TextReader stream);
|
public abstract void Decode(TextReader stream, Beatmap beatmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -202,16 +202,16 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Beatmap Decode(TextReader stream)
|
public override void Decode(TextReader stream, Beatmap beatmap)
|
||||||
{
|
{
|
||||||
var beatmap = new Beatmap
|
// We don't overwrite these two because they're DB bound
|
||||||
{
|
if (beatmap.Metadata == null) beatmap.Metadata = new BeatmapMetadata();
|
||||||
Metadata = new BeatmapMetadata(),
|
if (beatmap.BaseDifficulty == null) beatmap.BaseDifficulty = new BaseDifficulty();
|
||||||
BaseDifficulty = new BaseDifficulty(),
|
// These are fine though
|
||||||
HitObjects = new List<HitObject>(),
|
beatmap.HitObjects = new List<HitObject>();
|
||||||
ControlPoints = new List<ControlPoint>(),
|
beatmap.ControlPoints = new List<ControlPoint>();
|
||||||
ComboColors = new List<Color4>(),
|
beatmap.ComboColors = new List<Color4>();
|
||||||
};
|
|
||||||
var section = Section.None;
|
var section = Section.None;
|
||||||
string line;
|
string line;
|
||||||
while (true)
|
while (true)
|
||||||
@ -266,7 +266,6 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return beatmap;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography;
|
||||||
using Ionic.Zip;
|
using Ionic.Zip;
|
||||||
using osu.Game.Beatmaps.Formats;
|
using osu.Game.Beatmaps.Formats;
|
||||||
|
|
||||||
@ -32,7 +33,8 @@ namespace osu.Game.Beatmaps.IO
|
|||||||
using (var stream = new StreamReader(ReadFile(beatmaps[0])))
|
using (var stream = new StreamReader(ReadFile(beatmaps[0])))
|
||||||
{
|
{
|
||||||
var decoder = BeatmapDecoder.GetDecoder(stream);
|
var decoder = BeatmapDecoder.GetDecoder(stream);
|
||||||
firstMap = decoder.Decode(stream);
|
firstMap = new Beatmap();
|
||||||
|
decoder.Decode(stream, firstMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Security.Cryptography;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.Formats;
|
using osu.Game.Beatmaps.Formats;
|
||||||
@ -12,9 +13,11 @@ namespace osu.Game.Database
|
|||||||
public class BeatmapDatabase
|
public class BeatmapDatabase
|
||||||
{
|
{
|
||||||
private static SQLiteConnection connection { get; set; }
|
private static SQLiteConnection connection { get; set; }
|
||||||
|
private BasicStorage storage;
|
||||||
|
|
||||||
public BeatmapDatabase(BasicStorage storage)
|
public BeatmapDatabase(BasicStorage storage)
|
||||||
{
|
{
|
||||||
|
this.storage = storage;
|
||||||
if (connection == null)
|
if (connection == null)
|
||||||
{
|
{
|
||||||
connection = storage.GetDatabase(@"beatmaps");
|
connection = storage.GetDatabase(@"beatmaps");
|
||||||
@ -24,20 +27,43 @@ namespace osu.Game.Database
|
|||||||
connection.CreateTable<Beatmap>();
|
connection.CreateTable<Beatmap>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void AddBeatmap(ArchiveReader input)
|
public void AddBeatmap(string path)
|
||||||
{
|
{
|
||||||
var metadata = input.ReadMetadata();
|
string hash = null;
|
||||||
|
ArchiveReader reader;
|
||||||
|
if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader
|
||||||
|
{
|
||||||
|
using (var md5 = MD5.Create())
|
||||||
|
using (var input = storage.GetStream(path))
|
||||||
|
{
|
||||||
|
hash = BitConverter.ToString(md5.ComputeHash(input)).Replace("-", "").ToLowerInvariant();
|
||||||
|
input.Seek(0, SeekOrigin.Begin);
|
||||||
|
var outputPath = Path.Combine(@"beatmaps", hash.Remove(1), hash.Remove(2), hash);
|
||||||
|
using (var output = storage.GetStream(outputPath, FileAccess.Write))
|
||||||
|
input.CopyTo(output);
|
||||||
|
reader = ArchiveReader.GetReader(storage, path = outputPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
reader = ArchiveReader.GetReader(storage, path);
|
||||||
|
var metadata = reader.ReadMetadata();
|
||||||
if (connection.Table<BeatmapSet>().Count(b => b.BeatmapSetID == metadata.BeatmapSetID) != 0)
|
if (connection.Table<BeatmapSet>().Count(b => b.BeatmapSetID == metadata.BeatmapSetID) != 0)
|
||||||
return;
|
return; // TODO: Update this beatmap instead
|
||||||
string[] mapNames = input.ReadBeatmaps();
|
string[] mapNames = reader.ReadBeatmaps();
|
||||||
var beatmapSet = new BeatmapSet { BeatmapSetID = metadata.BeatmapSetID };
|
var beatmapSet = new BeatmapSet
|
||||||
|
{
|
||||||
|
BeatmapSetID = metadata.BeatmapSetID,
|
||||||
|
Path = path,
|
||||||
|
Hash = hash,
|
||||||
|
};
|
||||||
var maps = new List<Beatmap>();
|
var maps = new List<Beatmap>();
|
||||||
foreach (var name in mapNames)
|
foreach (var name in mapNames)
|
||||||
{
|
{
|
||||||
using (var stream = new StreamReader(input.ReadFile(name)))
|
using (var stream = new StreamReader(reader.ReadFile(name)))
|
||||||
{
|
{
|
||||||
var decoder = BeatmapDecoder.GetDecoder(stream);
|
var decoder = BeatmapDecoder.GetDecoder(stream);
|
||||||
var beatmap = decoder.Decode(stream);
|
Beatmap beatmap = new Beatmap();
|
||||||
|
decoder.Decode(stream, beatmap);
|
||||||
maps.Add(beatmap);
|
maps.Add(beatmap);
|
||||||
beatmap.BaseDifficultyID = connection.Insert(beatmap.BaseDifficulty);
|
beatmap.BaseDifficultyID = connection.Insert(beatmap.BaseDifficulty);
|
||||||
}
|
}
|
||||||
@ -46,5 +72,29 @@ namespace osu.Game.Database
|
|||||||
connection.Insert(beatmapSet);
|
connection.Insert(beatmapSet);
|
||||||
connection.InsertAll(maps);
|
connection.InsertAll(maps);
|
||||||
}
|
}
|
||||||
|
public ArchiveReader GetReader(BeatmapSet beatmapSet)
|
||||||
|
{
|
||||||
|
return ArchiveReader.GetReader(storage, beatmapSet.Path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Given a BeatmapSet pulled from the database, loads the rest of its data from disk.
|
||||||
|
/// </summary>
public void PopulateBeatmap(BeatmapSet beatmapSet)
|
||||||
|
{
|
||||||
|
using (var reader = GetReader(beatmapSet))
|
||||||
|
{
|
||||||
|
string[] mapNames = reader.ReadBeatmaps();
|
||||||
|
foreach (var name in mapNames)
|
||||||
|
{
|
||||||
|
using (var stream = new StreamReader(reader.ReadFile(name)))
|
||||||
|
{
|
||||||
|
var decoder = BeatmapDecoder.GetDecoder(stream);
|
||||||
|
Beatmap beatmap = new Beatmap();
|
||||||
|
decoder.Decode(stream, beatmap);
|
||||||
|
beatmapSet.Beatmaps.Add(beatmap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,6 +14,7 @@ using osu.Game.GameModes.Play;
|
|||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
|
using osu.Game.Overlays;
|
||||||
|
|
||||||
namespace osu.Game.GameModes.Menu
|
namespace osu.Game.GameModes.Menu
|
||||||
{
|
{
|
||||||
@ -47,9 +48,7 @@ namespace osu.Game.GameModes.Menu
|
|||||||
OnMulti = delegate { Push(new Lobby()); },
|
OnMulti = delegate { Push(new Lobby()); },
|
||||||
OnTest = delegate { Push(new TestBrowser()); },
|
OnTest = delegate { Push(new TestBrowser()); },
|
||||||
OnExit = delegate { Scheduler.AddDelayed(Exit, ButtonSystem.EXIT_DELAY); },
|
OnExit = delegate { Scheduler.AddDelayed(Exit, ButtonSystem.EXIT_DELAY); },
|
||||||
OnSettings = delegate {
|
OnSettings = osu.Options.ToggleVisibility,
|
||||||
osu.Options.PoppedOut = !osu.Options.PoppedOut;
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,8 +73,7 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var reader = ArchiveReader.GetReader(Host.Storage, message.Path);
|
Beatmaps.AddBeatmap(message.Path);
|
||||||
Beatmaps.AddBeatmap(reader);
|
|
||||||
// TODO: Switch to beatmap list and select the new song
|
// TODO: Switch to beatmap list and select the new song
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -96,9 +95,8 @@ namespace osu.Game
|
|||||||
Toolbar = new Toolbar
|
Toolbar = new Toolbar
|
||||||
{
|
{
|
||||||
OnHome = delegate { MainMenu?.MakeCurrent(); },
|
OnHome = delegate { MainMenu?.MakeCurrent(); },
|
||||||
OnSettings = delegate { Options.PoppedOut = !Options.PoppedOut; },
|
OnSettings = Options.ToggleVisibility,
|
||||||
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
|
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
|
||||||
Alpha = 0.001f,
|
|
||||||
},
|
},
|
||||||
Chat = new ChatConsole(API),
|
Chat = new ChatConsole(API),
|
||||||
new VolumeControl
|
new VolumeControl
|
||||||
@ -113,12 +111,6 @@ namespace osu.Game
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Toolbar.State = ToolbarState.Hidden;
|
|
||||||
Toolbar.Flush();
|
|
||||||
|
|
||||||
Chat.State = ChatConsoleState.Hidden;
|
|
||||||
Chat.Flush();
|
|
||||||
|
|
||||||
intro.ModePushed += modeAdded;
|
intro.ModePushed += modeAdded;
|
||||||
intro.Exited += modeRemoved;
|
intro.Exited += modeRemoved;
|
||||||
|
|
||||||
@ -134,7 +126,7 @@ namespace osu.Game
|
|||||||
switch (args.Key)
|
switch (args.Key)
|
||||||
{
|
{
|
||||||
case Key.F8:
|
case Key.F8:
|
||||||
Chat.State = Chat.State == ChatConsoleState.Hidden ? ChatConsoleState.Visible : ChatConsoleState.Hidden;
|
Chat.ToggleVisibility();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,12 +144,12 @@ namespace osu.Game
|
|||||||
//central game mode change logic.
|
//central game mode change logic.
|
||||||
if (newMode is Player || newMode is Intro)
|
if (newMode is Player || newMode is Intro)
|
||||||
{
|
{
|
||||||
Toolbar.State = ToolbarState.Hidden;
|
Toolbar.State = Visibility.Hidden;
|
||||||
Chat.State = ChatConsoleState.Hidden;
|
Chat.State = Visibility.Hidden;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Toolbar.State = ToolbarState.Visible;
|
Toolbar.State = Visibility.Visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cursor.FadeIn(100);
|
Cursor.FadeIn(100);
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using OpenTK;
|
||||||
using System.Threading.Tasks;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Drawables;
|
using osu.Framework.Graphics.Drawables;
|
||||||
@ -17,15 +17,10 @@ using osu.Game.Online.API;
|
|||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
using osu.Game.Online.Chat.Display;
|
using osu.Game.Online.Chat.Display;
|
||||||
using OpenTK;
|
|
||||||
using OpenTK.Graphics;
|
|
||||||
using osu.Framework.Input;
|
|
||||||
using OpenTK.Input;
|
|
||||||
using osu.Framework;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
public class ChatConsole : Container, IStateful<ChatConsoleState>
|
public class ChatConsole : Overlay
|
||||||
{
|
{
|
||||||
private ChannelDisplay channelDisplay;
|
private ChannelDisplay channelDisplay;
|
||||||
|
|
||||||
@ -69,7 +64,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private long? lastMessageId;
|
private long? lastMessageId;
|
||||||
|
|
||||||
List<Channel> careChannels;
|
private List<Channel> careChannels;
|
||||||
|
|
||||||
private void initializeChannels()
|
private void initializeChannels()
|
||||||
{
|
{
|
||||||
@ -112,7 +107,7 @@ namespace osu.Game.Overlays
|
|||||||
careChannels.Add(channel);
|
careChannels.Add(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetMessagesRequest fetchReq;
|
private GetMessagesRequest fetchReq;
|
||||||
|
|
||||||
public void FetchNewMessages(APIAccess api)
|
public void FetchNewMessages(APIAccess api)
|
||||||
{
|
{
|
||||||
@ -140,36 +135,18 @@ namespace osu.Game.Overlays
|
|||||||
api.Queue(fetchReq);
|
api.Queue(fetchReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChatConsoleState state;
|
private const int transition_length = 500;
|
||||||
|
|
||||||
public ChatConsoleState State
|
protected override void PopIn()
|
||||||
{
|
{
|
||||||
get { return state; }
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
state = value;
|
|
||||||
|
|
||||||
const int transition_length = 500;
|
|
||||||
|
|
||||||
switch (state)
|
|
||||||
{
|
|
||||||
case ChatConsoleState.Hidden:
|
|
||||||
MoveToY(-Size.Y, transition_length, EasingTypes.InQuint);
|
|
||||||
FadeOut(transition_length, EasingTypes.InQuint);
|
|
||||||
break;
|
|
||||||
case ChatConsoleState.Visible:
|
|
||||||
MoveToY(0, transition_length, EasingTypes.OutQuint);
|
MoveToY(0, transition_length, EasingTypes.OutQuint);
|
||||||
FadeIn(transition_length, EasingTypes.OutQuint);
|
FadeIn(transition_length, EasingTypes.OutQuint);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ChatConsoleState
|
protected override void PopOut()
|
||||||
{
|
{
|
||||||
Visible,
|
MoveToY(-Size.Y, transition_length, EasingTypes.InQuint);
|
||||||
Hidden,
|
FadeOut(transition_length, EasingTypes.InQuint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Drawables;
|
|
||||||
using osu.Framework.Graphics.Transformations;
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Input;
|
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Drawables;
|
||||||
|
using osu.Framework.Graphics.Transformations;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
public class Options : Container
|
public class Options : Overlay
|
||||||
{
|
{
|
||||||
const float width = 300;
|
private const float width = 300;
|
||||||
|
|
||||||
public override void Load(BaseGame game)
|
public override void Load(BaseGame game)
|
||||||
{
|
{
|
||||||
@ -41,36 +40,22 @@ namespace osu.Game.Overlays
|
|||||||
switch (args.Key)
|
switch (args.Key)
|
||||||
{
|
{
|
||||||
case Key.Escape:
|
case Key.Escape:
|
||||||
if (!poppedOut) return false;
|
if (State == Visibility.Hidden) return false;
|
||||||
|
|
||||||
PoppedOut = false;
|
State = Visibility.Hidden;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return base.OnKeyDown(state, args);
|
return base.OnKeyDown(state, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool poppedOut;
|
protected override void PopIn()
|
||||||
|
|
||||||
public bool PoppedOut
|
|
||||||
{
|
{
|
||||||
get { return poppedOut; }
|
MoveToX(0, 300, EasingTypes.Out);
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value == poppedOut) return;
|
|
||||||
|
|
||||||
poppedOut = value;
|
|
||||||
|
|
||||||
if (poppedOut)
|
|
||||||
{
|
|
||||||
MoveTo(new Vector2(0, 0), 300, EasingTypes.Out);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MoveTo(new Vector2(-width, 0), 300, EasingTypes.Out);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
protected override void PopOut()
|
||||||
|
{
|
||||||
|
MoveToX(-width, 300, EasingTypes.Out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
53
osu.Game/Overlays/Overlay.cs
Normal file
53
osu.Game/Overlays/Overlay.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using osu.Framework;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An element which starts hidden and can be toggled to visible.
|
||||||
|
/// </summary>
|
||||||
|
public abstract class Overlay : Container, IStateful<Visibility>
|
||||||
|
{
|
||||||
|
public override void Load(BaseGame game)
|
||||||
|
{
|
||||||
|
base.Load(game);
|
||||||
|
|
||||||
|
//TODO: init code using Alpha or IsVisible override to ensure we don't call Load on children before we first get unhidden.
|
||||||
|
PopOut();
|
||||||
|
Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Visibility state;
|
||||||
|
public Visibility State
|
||||||
|
{
|
||||||
|
get { return state; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == state) return;
|
||||||
|
state = value;
|
||||||
|
|
||||||
|
switch (value)
|
||||||
|
{
|
||||||
|
case Visibility.Hidden:
|
||||||
|
PopOut();
|
||||||
|
break;
|
||||||
|
case Visibility.Visible:
|
||||||
|
PopIn();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void PopIn();
|
||||||
|
|
||||||
|
protected abstract void PopOut();
|
||||||
|
|
||||||
|
public void ToggleVisibility() => State = (State == Visibility.Visible ? Visibility.Hidden : Visibility.Visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Visibility
|
||||||
|
{
|
||||||
|
Hidden,
|
||||||
|
Visible
|
||||||
|
}
|
||||||
|
}
|
@ -1,24 +1,23 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Drawables;
|
using osu.Framework.Graphics.Drawables;
|
||||||
using OpenTK;
|
|
||||||
using OpenTK.Graphics;
|
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Configuration;
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Graphics.Transformations;
|
using osu.Framework.Graphics.Transformations;
|
||||||
using osu.Framework.Timing;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.GameModes.Play;
|
using osu.Game.GameModes.Play;
|
||||||
using osu.Framework;
|
using osu.Game.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
public class Toolbar : Container, IStateful<ToolbarState>
|
public class Toolbar : Overlay
|
||||||
{
|
{
|
||||||
const float height = 50;
|
private const float height = 50;
|
||||||
|
|
||||||
public Action OnSettings;
|
public Action OnSettings;
|
||||||
public Action OnHome;
|
public Action OnHome;
|
||||||
@ -26,29 +25,18 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private ToolbarModeSelector modeSelector;
|
private ToolbarModeSelector modeSelector;
|
||||||
|
|
||||||
private ToolbarState state;
|
private const int transition_time = 200;
|
||||||
|
|
||||||
public ToolbarState State
|
protected override void PopIn()
|
||||||
{
|
{
|
||||||
get { return state; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
state = value;
|
|
||||||
|
|
||||||
const int transition_time = 200;
|
|
||||||
|
|
||||||
switch (state)
|
|
||||||
{
|
|
||||||
case ToolbarState.Hidden:
|
|
||||||
MoveToY(-Size.Y, transition_time, EasingTypes.InQuint);
|
|
||||||
FadeOut(transition_time, EasingTypes.InQuint);
|
|
||||||
break;
|
|
||||||
case ToolbarState.Visible:
|
|
||||||
MoveToY(0, transition_time, EasingTypes.OutQuint);
|
MoveToY(0, transition_time, EasingTypes.OutQuint);
|
||||||
FadeIn(transition_time, EasingTypes.OutQuint);
|
FadeIn(transition_time, EasingTypes.OutQuint);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void PopOut()
|
||||||
|
{
|
||||||
|
MoveToY(-Size.Y, transition_time, EasingTypes.InQuint);
|
||||||
|
FadeOut(transition_time, EasingTypes.InQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Load(BaseGame game)
|
public override void Load(BaseGame game)
|
||||||
@ -119,10 +107,4 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode);
|
public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ToolbarState
|
|
||||||
{
|
|
||||||
Visible,
|
|
||||||
Hidden,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -164,6 +164,7 @@
|
|||||||
<Compile Include="OsuGameBase.cs" />
|
<Compile Include="OsuGameBase.cs" />
|
||||||
<Compile Include="Overlays\ChatConsole.cs" />
|
<Compile Include="Overlays\ChatConsole.cs" />
|
||||||
<Compile Include="Overlays\Options.cs" />
|
<Compile Include="Overlays\Options.cs" />
|
||||||
|
<Compile Include="Overlays\Overlay.cs" />
|
||||||
<Compile Include="Overlays\Toolbar.cs" />
|
<Compile Include="Overlays\Toolbar.cs" />
|
||||||
<Compile Include="Overlays\ToolbarButton.cs" />
|
<Compile Include="Overlays\ToolbarButton.cs" />
|
||||||
<Compile Include="Overlays\ToolbarModeButton.cs" />
|
<Compile Include="Overlays\ToolbarModeButton.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user