This commit is contained in:
DrabWeb
2017-02-22 12:35:55 -04:00
117 changed files with 1756 additions and 583 deletions

View File

@ -26,26 +26,36 @@ namespace osu.Game.Beatmaps
return 60000 / BeatLengthAt(time);
}
public double BeatLengthAt(double time, bool applyMultipliers = false)
public double BeatLengthAt(double time)
{
int point = 0;
int samplePoint = 0;
ControlPoint overridePoint;
ControlPoint timingPoint = TimingPointAt(time, out overridePoint);
return timingPoint.BeatLength;
}
for (int i = 0; i < ControlPoints.Count; i++)
if (ControlPoints[i].Time <= time)
public ControlPoint TimingPointAt(double time, out ControlPoint overridePoint)
{
overridePoint = null;
ControlPoint timingPoint = null;
foreach (var controlPoint in ControlPoints)
{
// Some beatmaps have the first timingPoint (accidentally) start after the first HitObject(s).
// This null check makes it so that the first ControlPoint that makes a timing change is used as
// the timingPoint for those HitObject(s).
if (controlPoint.Time <= time || timingPoint == null)
{
if (ControlPoints[i].TimingChange)
point = i;
else
samplePoint = i;
if (controlPoint.TimingChange)
{
timingPoint = controlPoint;
overridePoint = null;
}
else overridePoint = controlPoint;
}
else break;
}
double mult = 1;
if (applyMultipliers && samplePoint > point)
mult = ControlPoints[samplePoint].VelocityAdjustment;
return ControlPoints[point].BeatLength * mult;
return timingPoint ?? ControlPoint.Default;
}
}
}

View File

@ -0,0 +1,50 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Modes;
using osu.Game.Modes.Objects;
using System;
using System.Collections.Generic;
namespace osu.Game.Beatmaps
{
public abstract class DifficultyCalculator
{
protected abstract PlayMode PlayMode { get; }
protected double TimeRate = 1;
protected abstract double ComputeDifficulty(Dictionary<String, String> categoryDifficulty);
private void loadTiming()
{
// TODO: Handle mods
int audioRate = 100;
TimeRate = audioRate / 100.0;
}
public double GetDifficulty(Dictionary<string, string> categoryDifficulty = null)
{
loadTiming();
double difficulty = ComputeDifficulty(categoryDifficulty);
return difficulty;
}
}
public abstract class DifficultyCalculator<T> : DifficultyCalculator where T : HitObject
{
protected List<T> Objects;
protected abstract HitObjectConverter<T> Converter { get; }
public DifficultyCalculator(Beatmap beatmap)
{
Objects = Converter.Convert(beatmap);
PreprocessHitObjects();
}
protected virtual void PreprocessHitObjects()
{
}
}
}

View File

@ -60,7 +60,7 @@ namespace osu.Game.Beatmaps.Drawables
}
}
public BeatmapGroup(WorkingBeatmap beatmap, BeatmapSetInfo set = null)
public BeatmapGroup(WorkingBeatmap beatmap)
{
Header = new BeatmapSetHeader(beatmap)
{
@ -68,6 +68,7 @@ namespace osu.Game.Beatmaps.Drawables
RelativeSizeAxes = Axes.X,
};
BeatmapSet = beatmap.BeatmapSetInfo;
BeatmapPanels = beatmap.BeatmapSetInfo.Beatmaps.Select(b => new BeatmapPanel(b)
{
Alpha = 0,
@ -76,7 +77,6 @@ namespace osu.Game.Beatmaps.Drawables
RelativeSizeAxes = Axes.X,
}).ToList();
BeatmapSet = set;
Header.AddDifficultyIcons(BeatmapPanels);
}

View File

@ -1,20 +1,21 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Beatmaps.Timing
{
public class ControlPoint
{
public static ControlPoint Default = new ControlPoint
{
BeatLength = 500,
TimingChange = true,
};
public double Time;
public double BeatLength;
public double VelocityAdjustment;
public bool TimingChange;
}
internal enum TimeSignatures

View File

@ -1,12 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Beatmaps.Timing
{
class TimingChange : ControlPoint

View File

@ -68,7 +68,6 @@ namespace osu.Game.Beatmaps
beatmap = decoder?.Decode(stream);
}
if (WithStoryboard && beatmap != null && BeatmapSetInfo.StoryboardFile != null)
using (var stream = new StreamReader(reader.GetStream(BeatmapSetInfo.StoryboardFile)))
decoder?.Decode(stream, beatmap);
@ -83,9 +82,9 @@ namespace osu.Game.Beatmaps
}
private ArchiveReader trackReader;
private AudioTrack track;
private Track track;
private object trackLock = new object();
public AudioTrack Track
public Track Track
{
get
{
@ -99,7 +98,7 @@ namespace osu.Game.Beatmaps
trackReader = getReader();
var trackData = trackReader?.GetStream(BeatmapInfo.Metadata.AudioFile);
if (trackData != null)
track = new AudioTrackBass(trackData);
track = new TrackBass(trackData);
}
catch { }

View File

@ -31,6 +31,7 @@ namespace osu.Game.Configuration
Set(OsuConfig.SnakingInSliders, true);
Set(OsuConfig.SnakingOutSliders, false);
Set(OsuConfig.MenuParallax, true);
//todo: implement all settings below this line (remove the Disabled set when doing so).
Set(OsuConfig.MouseSpeed, 1.0).Disabled = true;
@ -143,7 +144,6 @@ namespace osu.Game.Configuration
Set(OsuConfig.DetectPerformanceIssues, true).Disabled = true;
Set(OsuConfig.MenuMusic, true).Disabled = true;
Set(OsuConfig.MenuVoice, true).Disabled = true;
Set(OsuConfig.MenuParallax, true).Disabled = true;
Set(OsuConfig.RawInput, false).Disabled = true;
Set(OsuConfig.AbsoluteToOsuWindow, Get<bool>(OsuConfig.RawInput)).Disabled = true;
Set(OsuConfig.ShowMenuTips, true).Disabled = true;

View File

@ -8,6 +8,7 @@ using osu.Game.Modes;
using osu.Game.Screens.Play;
using SQLite.Net.Attributes;
using SQLiteNetExtensions.Attributes;
using osu.Game.Beatmaps;
namespace osu.Game.Database
{
@ -73,7 +74,23 @@ namespace osu.Game.Database
// Metadata
public string Version { get; set; }
public float StarDifficulty => BaseDifficulty?.OverallDifficulty ?? 5; //todo: implement properly
//todo: background threaded computation of this
private float starDifficulty = -1;
public float StarDifficulty
{
get
{
return (starDifficulty < 0) ? (BaseDifficulty?.OverallDifficulty ?? 5) : starDifficulty;
}
set { starDifficulty = value; }
}
internal void ComputeDifficulty(BeatmapDatabase database)
{
WorkingBeatmap wb = new WorkingBeatmap(this, BeatmapSet, database);
StarDifficulty = (float)Ruleset.GetRuleset(Mode).CreateDifficultyCalculator(wb.Beatmap).GetDifficulty();
}
public bool Equals(BeatmapInfo other)
{

View File

@ -8,6 +8,8 @@ using OpenTK;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Transformations;
using osu.Game.Configuration;
using osu.Framework.Configuration;
namespace osu.Game.Graphics.Containers
{
@ -15,6 +17,8 @@ namespace osu.Game.Graphics.Containers
{
public float ParallaxAmount = 0.02f;
private Bindable<bool> parallaxEnabled;
public override bool Contains(Vector2 screenSpacePos) => true;
public ParallaxContainer()
@ -34,9 +38,18 @@ namespace osu.Game.Graphics.Containers
protected override Container<Drawable> Content => content;
[BackgroundDependencyLoader]
private void load(UserInputManager input)
private void load(UserInputManager input, OsuConfigManager config)
{
this.input = input;
parallaxEnabled = config.GetBindable<bool>(OsuConfig.MenuParallax);
parallaxEnabled.ValueChanged += delegate
{
if (!parallaxEnabled)
{
content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, EasingTypes.OutQuint);
content.Scale = new Vector2(1 + ParallaxAmount);
}
};
}
bool firstUpdate = true;
@ -45,9 +58,12 @@ namespace osu.Game.Graphics.Containers
{
base.Update();
Vector2 offset = input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.NativeState.Position) - DrawSize / 2;
content.MoveTo(offset * ParallaxAmount, firstUpdate ? 0 : 1000, EasingTypes.OutQuint);
content.Scale = new Vector2(1 + ParallaxAmount);
if (parallaxEnabled)
{
Vector2 offset = input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.NativeState.Position) - DrawSize / 2;
content.MoveTo(offset * ParallaxAmount, firstUpdate ? 0 : 1000, EasingTypes.OutQuint);
content.Scale = new Vector2(1 + ParallaxAmount);
}
firstUpdate = false;
}

View File

@ -0,0 +1,49 @@
using OpenTK.Graphics;
using OpenTK.Input;
using osu.Framework.Input;
using System;
using System.Linq;
namespace osu.Game.Graphics.UserInterface
{
public class FocusedTextBox : OsuTextBox
{
protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255);
protected override Color4 BackgroundFocused => new Color4(10, 10, 10, 255);
public Action Exit;
private bool focus;
public bool HoldFocus
{
get { return focus; }
set
{
focus = value;
if (!focus)
TriggerFocusLost();
}
}
protected override bool OnFocus(InputState state)
{
var result = base.OnFocus(state);
BorderThickness = 0;
return result;
}
protected override void OnFocusLost(InputState state)
{
if (state.Keyboard.Keys.Any(key => key == Key.Escape))
{
if (Text.Length > 0)
Text = string.Empty;
else
Exit?.Invoke();
}
base.OnFocusLost(state);
}
public override bool RequestingFocus => HoldFocus;
}
}

View File

@ -71,8 +71,8 @@ namespace osu.Game.Graphics.UserInterface
private Nub nub;
private SpriteText labelSpriteText;
private AudioSample sampleChecked;
private AudioSample sampleUnchecked;
private SampleChannel sampleChecked;
private SampleChannel sampleUnchecked;
public OsuCheckbox()
{

View File

@ -16,7 +16,7 @@ namespace osu.Game.Graphics.UserInterface
{
public class OsuSliderBar<U> : SliderBar<U> where U : struct
{
private AudioSample sample;
private SampleChannel sample;
private double lastSampleTime;
private Nub nub;

View File

@ -8,7 +8,6 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
using OpenTK.Graphics;
namespace osu.Game.Graphics.UserInterface

View File

@ -20,8 +20,7 @@ namespace osu.Game.Graphics.UserInterface
{
protected override Type TransformType => typeof(TransformAccuracy);
protected override double RollingDuration => 150;
protected override bool IsRollingProportional => true;
protected override double RollingDuration => 750;
private float epsilon => 1e-10f;
@ -32,6 +31,7 @@ namespace osu.Game.Graphics.UserInterface
public PercentageCounter()
{
DisplayedCountSpriteText.FixedWidth = true;
Count = 1.0f;
}

View File

@ -38,7 +38,7 @@ namespace osu.Game.Graphics.UserInterface
/// <summary>
/// Easing for the counter rollover animation.
/// </summary>
protected virtual EasingTypes RollingEasing => EasingTypes.Out;
protected virtual EasingTypes RollingEasing => EasingTypes.OutQuint;
private T displayedCount;
@ -107,17 +107,16 @@ namespace osu.Game.Graphics.UserInterface
{
Children = new Drawable[]
{
DisplayedCountSpriteText = new OsuSpriteText(),
DisplayedCountSpriteText = new OsuSpriteText()
{
Font = @"Venera"
},
};
TextSize = 40;
AutoSizeAxes = Axes.Both;
DisplayedCount = Count;
DisplayedCountSpriteText.Text = FormatCount(count);
DisplayedCountSpriteText.Anchor = Anchor;
DisplayedCountSpriteText.Origin = Origin;
}
protected override void LoadComplete()
@ -125,6 +124,10 @@ namespace osu.Game.Graphics.UserInterface
base.LoadComplete();
Flush(false, TransformType);
DisplayedCountSpriteText.Text = FormatCount(count);
DisplayedCountSpriteText.Anchor = Anchor;
DisplayedCountSpriteText.Origin = Origin;
}
/// <summary>

View File

@ -28,7 +28,7 @@ namespace osu.Game.Graphics.UserInterface
public static readonly Vector2 SIZE_EXTENDED = new Vector2(140, 50);
public static readonly Vector2 SIZE_RETRACTED = new Vector2(100, 50);
public AudioSample ActivationSound;
public SampleChannel ActivationSound;
private SpriteText text;
public Color4 HoverColour;

View File

@ -13,6 +13,11 @@ namespace osu.Game.Input
public override bool HandleInput => true;
public GlobalHotkeys()
{
RelativeSizeAxes = Axes.Both;
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
return Handler(state, args);

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using osu.Framework;
@ -23,8 +24,6 @@ namespace osu.Game.Modes.Objects.Drawables
public bool Interactive = true;
public Container<DrawableHitObject> ChildObjects;
public JudgementInfo Judgement;
public abstract JudgementInfo CreateJudgementInfo();
@ -55,7 +54,7 @@ namespace osu.Game.Modes.Objects.Drawables
}
}
AudioSample sample;
SampleChannel sample;
[BackgroundDependencyLoader]
private void load(AudioManager audio)
@ -66,7 +65,7 @@ namespace osu.Game.Modes.Objects.Drawables
sample = audio.Sample.Get($@"Gameplay/{sampleSet}-hit{hitType}");
}
protected void PlaySample()
protected virtual void PlaySample()
{
sample?.Play();
}
@ -85,6 +84,19 @@ namespace osu.Game.Modes.Objects.Drawables
Expire(true);
}
private List<DrawableHitObject> nestedHitObjects;
protected IEnumerable<DrawableHitObject> NestedHitObjects => nestedHitObjects;
protected void AddNested(DrawableHitObject h)
{
if (nestedHitObjects == null)
nestedHitObjects = new List<DrawableHitObject>();
h.OnJudgement += (d, j) => { OnJudgement?.Invoke(d, j); } ;
nestedHitObjects.Add(h);
}
/// <summary>
/// Process a hit of this hitobject. Carries out judgement.
/// </summary>
@ -119,7 +131,11 @@ namespace osu.Game.Modes.Objects.Drawables
protected virtual void CheckJudgement(bool userTriggered)
{
//todo: consider making abstract.
if (NestedHitObjects != null)
{
foreach (var d in NestedHitObjects)
d.CheckJudgement(userTriggered);
}
}
protected override void UpdateAfterChildren()

View File

@ -32,6 +32,8 @@ namespace osu.Game.Modes
public abstract HitObjectParser CreateHitObjectParser();
public abstract DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap);
public static void Register(Ruleset ruleset) => availableRulesets.TryAdd(ruleset.PlayMode, ruleset.GetType());
protected abstract PlayMode PlayMode { get; }

View File

@ -1,23 +1,29 @@
// Copyright (c) 2007-2017 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-framework/master/LICENCE
using OpenTK;
using OpenTK.Graphics;
using System;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using System;
using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Modes.UI
{
public class HealthDisplay : Container
{
private Box background;
private Box fill;
private Container fill;
public BindableDouble Current = new BindableDouble() { MinValue = 0, MaxValue = 1 };
public BindableDouble Current = new BindableDouble()
{
MinValue = 0,
MaxValue = 1
};
public HealthDisplay()
{
@ -26,19 +32,38 @@ namespace osu.Game.Modes.UI
background = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Gray,
Colour = Color4.Black,
},
fill = new Box
fill = new Container
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
Scale = new Vector2(0, 1),
},
Masking = true,
Children = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
}
}
},
};
Current.ValueChanged += current_ValueChanged;
}
[BackgroundDependencyLoader]
private void laod(OsuColour colours)
{
fill.Colour = colours.BlueLighter;
fill.EdgeEffect = new EdgeEffect
{
Colour = colours.BlueDarker.Opacity(0.6f),
Radius = 8,
Type= EdgeEffectType.Glow
};
}
private void current_ValueChanged(object sender, EventArgs e)
{
fill.ScaleTo(new Vector2((float)Current, 1), 200, EasingTypes.OutQuint);

View File

@ -27,9 +27,9 @@ namespace osu.Game.Modes.UI
protected abstract ScoreCounter CreateScoreCounter();
protected virtual HealthDisplay CreateHealthDisplay() => new HealthDisplay
{
Size = new Vector2(0.5f, 20),
Size = new Vector2(1, 5),
RelativeSizeAxes = Axes.X,
Padding = new MarginPadding(5)
Margin = new MarginPadding { Top = 20 }
};
public virtual void OnHit(HitObject h)

View File

@ -196,7 +196,10 @@ namespace osu.Game.Online.API
Logger.Log($@"Performing request {req}", LoggingTarget.Network);
req.Perform(this);
State = APIState.Online;
//we could still be in initialisation, at which point we don't want to say we're Online yet.
if (LocalUser.Value != null)
State = APIState.Online;
failureCount = 0;
return true;
}

View File

@ -3,12 +3,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Newtonsoft.Json;
using osu.Framework.Configuration;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
namespace osu.Game.Online.Chat
{
@ -30,16 +25,16 @@ namespace osu.Game.Online.Chat
//internal bool Joined;
public const int MAX_HISTORY = 100;
public const int MAX_HISTORY = 300;
[JsonConstructor]
public Channel()
{
}
public event Action<Message[]> NewMessagesArrived;
public event Action<IEnumerable<Message>> NewMessagesArrived;
public void AddNewMessages(params Message[] messages)
public void AddNewMessages(IEnumerable<Message> messages)
{
Messages.AddRange(messages);
purgeOldMessages();

View File

@ -1,10 +1,12 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
@ -15,6 +17,50 @@ namespace osu.Game.Online.Chat.Drawables
{
public readonly Message Message;
private static readonly Color4[] username_colours = {
OsuColour.FromHex("588c7e"),
OsuColour.FromHex("b2a367"),
OsuColour.FromHex("c98f65"),
OsuColour.FromHex("bc5151"),
OsuColour.FromHex("5c8bd6"),
OsuColour.FromHex("7f6ab7"),
OsuColour.FromHex("a368ad"),
OsuColour.FromHex("aa6880"),
OsuColour.FromHex("6fad9b"),
OsuColour.FromHex("f2e394"),
OsuColour.FromHex("f2ae72"),
OsuColour.FromHex("f98f8a"),
OsuColour.FromHex("7daef4"),
OsuColour.FromHex("a691f2"),
OsuColour.FromHex("c894d3"),
OsuColour.FromHex("d895b0"),
OsuColour.FromHex("53c4a1"),
OsuColour.FromHex("eace5c"),
OsuColour.FromHex("ea8c47"),
OsuColour.FromHex("fc4f4f"),
OsuColour.FromHex("3d94ea"),
OsuColour.FromHex("7760ea"),
OsuColour.FromHex("af52c6"),
OsuColour.FromHex("e25696"),
OsuColour.FromHex("677c66"),
OsuColour.FromHex("9b8732"),
OsuColour.FromHex("8c5129"),
OsuColour.FromHex("8c3030"),
OsuColour.FromHex("1f5d91"),
OsuColour.FromHex("4335a5"),
OsuColour.FromHex("812a96"),
OsuColour.FromHex("992861"),
};
private Color4 getUsernameColour(Message message)
{
//todo: use User instead of Message when user_id is correctly populated.
return username_colours[message.UserId % username_colours.Length];
}
const float padding = 200;
const float text_size = 20;
@ -25,6 +71,8 @@ namespace osu.Game.Online.Chat.Drawables
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Padding = new MarginPadding { Left = 15, Right = 15 };
Children = new Drawable[]
{
new Container
@ -34,13 +82,19 @@ namespace osu.Game.Online.Chat.Drawables
{
new OsuSpriteText
{
Text = Message.Timestamp.LocalDateTime.ToLongTimeString(),
TextSize = text_size,
Colour = Color4.Gray
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Font = @"Exo2.0-SemiBold",
Text = $@"{Message.Timestamp.LocalDateTime:hh:mm:ss}",
FixedWidth = true,
TextSize = text_size * 0.75f,
Alpha = 0.4f,
},
new OsuSpriteText
{
Text = Message.User.Name,
Font = @"Exo2.0-BoldItalic",
Text = $@"{Message.User.Name}:",
Colour = getUsernameColour(Message),
TextSize = text_size,
Origin = Anchor.TopRight,
Anchor = Anchor.TopRight,
@ -51,7 +105,7 @@ namespace osu.Game.Online.Chat.Drawables
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Left = padding + 10 },
Padding = new MarginPadding { Left = padding + 15 },
Children = new Drawable[]
{
new OsuSpriteText

View File

@ -4,25 +4,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Primitives;
using osu.Framework.MathUtils;
using osu.Framework.Threading;
using osu.Game.Graphics.Sprites;
using OpenTK;
namespace osu.Game.Online.Chat.Drawables
{
public class ChannelDisplay : Container
public class DrawableChannel : Container
{
private readonly Channel channel;
private FlowContainer flow;
private ScrollContainer scroll;
public ChannelDisplay(Channel channel)
public DrawableChannel(Channel channel)
{
this.channel = channel;
newMessages(channel.Messages);
channel.NewMessagesArrived += newMessages;
RelativeSizeAxes = Axes.Both;
@ -36,8 +36,9 @@ namespace osu.Game.Online.Chat.Drawables
Anchor = Anchor.Centre,
Origin = Anchor.Centre
},
new ScrollContainer
scroll = new ScrollContainer
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
flow = new FlowContainer
@ -45,37 +46,54 @@ namespace osu.Game.Online.Chat.Drawables
Direction = FlowDirections.Vertical,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Spacing = new Vector2(1, 1)
Padding = new MarginPadding { Left = 20, Right = 20 }
}
}
}
};
channel.NewMessagesArrived += newMessagesArrived;
}
protected override void LoadComplete()
{
base.LoadComplete();
newMessagesArrived(channel.Messages);
scrollToEnd();
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
channel.NewMessagesArrived -= newMessages;
channel.NewMessagesArrived -= newMessagesArrived;
}
[BackgroundDependencyLoader]
private void load()
{
newMessages(channel.Messages);
}
private void newMessages(IEnumerable<Message> newMessages)
private void newMessagesArrived(IEnumerable<Message> newMessages)
{
if (!IsLoaded) return;
var displayMessages = newMessages.Skip(Math.Max(0, newMessages.Count() - Channel.MAX_HISTORY));
if (scroll.IsScrolledToEnd(10) || !flow.Children.Any())
scrollToEnd();
//up to last Channel.MAX_HISTORY messages
foreach (Message m in displayMessages)
flow.Add(new ChatLine(m));
{
var d = new ChatLine(m);
flow.Add(d);
}
while (flow.Children.Count() > Channel.MAX_HISTORY)
flow.Remove(flow.Children.First());
while (flow.Children.Count(c => c.LifetimeEnd == double.MaxValue) > Channel.MAX_HISTORY)
{
var d = flow.Children.First(c => c.LifetimeEnd == double.MaxValue);
if (!scroll.IsScrolledToEnd(10))
scroll.OffsetScrollPosition(-d.DrawHeight);
d.Expire();
}
}
private void scrollToEnd() => Scheduler.AddDelayed(() => scroll.ScrollToEnd(), 50);
}
}

View File

@ -11,6 +11,7 @@ namespace osu.Game.Online.Chat
[JsonProperty(@"message_id")]
public long Id;
//todo: this should be inside sender.
[JsonProperty(@"user_id")]
public int UserId;

View File

@ -3,7 +3,7 @@
using System;
using osu.Framework.Configuration;
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Game.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -31,6 +31,8 @@ namespace osu.Game
{
public class OsuGame : OsuGameBase
{
public virtual bool IsDeployedBuild => false;
public Toolbar Toolbar;
private ChatOverlay chat;
@ -39,10 +41,18 @@ namespace osu.Game
private NotificationManager notificationManager;
private MainMenu mainMenu => modeStack?.ChildGameMode as MainMenu;
private Intro intro => modeStack as Intro;
private Intro intro
{
get
{
Screen s = screenStack;
while (s != null && !(s is Intro))
s = s.ChildScreen;
return s as Intro;
}
}
private OsuGameMode modeStack;
private OsuScreen screenStack;
private VolumeControl volume;
@ -106,11 +116,11 @@ namespace osu.Game
}
});
(modeStack = new Intro()).Preload(this, d =>
(screenStack = new Loader()).Preload(this, d =>
{
modeStack.ModePushed += modeAdded;
modeStack.Exited += modeRemoved;
mainContent.Add(modeStack);
screenStack.ModePushed += screenAdded;
screenStack.Exited += screenRemoved;
mainContent.Add(screenStack);
});
//overlay elements
@ -148,7 +158,7 @@ namespace osu.Game
(Toolbar = new Toolbar
{
Depth = -3,
OnHome = delegate { mainMenu?.MakeCurrent(); },
OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); },
OnPlayModeChange = delegate (PlayMode m) { PlayMode.Value = m; },
}).Preload(this, t =>
{
@ -206,20 +216,16 @@ namespace osu.Game
return base.OnKeyDown(state, args);
}
public Action<GameMode> ModeChanged;
public event Action<Screen> ModeChanged;
private Container mainContent;
private Container overlayContent;
private void modeChanged(GameMode newMode)
private void modeChanged(Screen newScreen)
{
// - Ability to change window size
// - Ability to adjust music playback
// - Frame limiter changes
//central game mode change logic.
if ((newMode as OsuGameMode)?.ShowOverlays != true)
if ((newScreen as OsuScreen)?.ShowOverlays != true)
{
Toolbar.State = Visibility.Hidden;
musicController.State = Visibility.Hidden;
@ -230,22 +236,24 @@ namespace osu.Game
Toolbar.State = Visibility.Visible;
}
Cursor.FadeIn(100);
if (newScreen is MainMenu)
Cursor.FadeIn(100);
ModeChanged?.Invoke(newMode);
ModeChanged?.Invoke(newScreen);
if (newMode == null)
Host.Exit();
if (newScreen == null)
Exit();
}
protected override bool OnExiting()
{
if (!intro.DidLoadMenu || intro.ChildGameMode != null)
if (screenStack.ChildScreen == null) return false;
if (intro == null) return true;
if (!intro.DidLoadMenu || intro.ChildScreen != null)
{
Scheduler.Add(delegate
{
intro.MakeCurrent();
});
Scheduler.Add(intro.MakeCurrent);
return true;
}
@ -256,21 +264,21 @@ namespace osu.Game
{
base.UpdateAfterChildren();
if (modeStack.ChildGameMode != null)
modeStack.ChildGameMode.Padding = new MarginPadding { Top = Toolbar.Position.Y + Toolbar.DrawHeight };
if (intro?.ChildScreen != null)
intro.ChildScreen.Padding = new MarginPadding { Top = Toolbar.Position.Y + Toolbar.DrawHeight };
}
private void modeAdded(GameMode newMode)
private void screenAdded(Screen newScreen)
{
newMode.ModePushed += modeAdded;
newMode.Exited += modeRemoved;
newScreen.ModePushed += screenAdded;
newScreen.Exited += screenRemoved;
modeChanged(newMode);
modeChanged(newScreen);
}
private void modeRemoved(GameMode newMode)
private void screenRemoved(Screen newScreen)
{
modeChanged(newMode);
modeChanged(newScreen);
}
}
}

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -19,12 +18,19 @@ using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.Chat;
using osu.Game.Online.Chat.Drawables;
using osu.Game.Graphics.UserInterface;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.UserInterface;
using OpenTK.Graphics;
using osu.Framework.Input;
namespace osu.Game.Overlays
{
public class ChatOverlay : OverlayContainer, IOnlineComponent
public class ChatOverlay : FocusedOverlayContainer, IOnlineComponent
{
private ChannelDisplay channelDisplay;
const float textbox_height = 40;
private DrawableChannel channelDisplay;
private ScheduledDelegate messageRequest;
@ -32,6 +38,8 @@ namespace osu.Game.Overlays
protected override Container<Drawable> Content => content;
private FocusedTextBox inputTextBox;
private APIAccess api;
public ChatOverlay()
@ -47,15 +55,65 @@ namespace osu.Game.Overlays
{
Depth = float.MaxValue,
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.1f).Opacity(0.4f),
Colour = Color4.Black,
Alpha = 0.9f,
},
content = new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = 5, Bottom = textbox_height + 5 },
},
new Container
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
Height = textbox_height,
Padding = new MarginPadding(5),
Children = new Drawable[]
{
inputTextBox = new FocusedTextBox
{
RelativeSizeAxes = Axes.Both,
Height = 1,
PlaceholderText = "type your message",
Exit = () => State = Visibility.Hidden,
OnCommit = postMessage,
HoldFocus = true,
}
}
}
});
}
protected override bool OnFocus(InputState state)
{
//this is necessary as inputTextBox is masked away and therefore can't get focus :(
inputTextBox.TriggerFocus();
return false;
}
private void postMessage(TextBox sender, bool newText)
{
var postText = sender.Text;
if (!string.IsNullOrEmpty(postText))
{
//todo: actually send to server
careChannels.FirstOrDefault()?.AddNewMessages(new[]
{
new Message
{
User = api.LocalUser.Value,
Timestamp = DateTimeOffset.Now,
Content = postText
}
});
}
sender.Text = string.Empty;
}
[BackgroundDependencyLoader]
private void load(APIAccess api)
{
@ -69,7 +127,7 @@ namespace osu.Game.Overlays
private void addChannel(Channel channel)
{
Add(channelDisplay = new ChannelDisplay(channel));
Add(channelDisplay = new DrawableChannel(channel));
careChannels.Add(channel);
}
@ -82,10 +140,11 @@ namespace osu.Game.Overlays
fetchReq = new GetMessagesRequest(careChannels, lastMessageId);
fetchReq.Success += delegate (List<Message> messages)
{
foreach (Message m in messages)
{
careChannels.Find(c => c.Id == m.ChannelId).AddNewMessages(m);
}
var ids = messages.Select(m => m.ChannelId).Distinct();
//batch messages per channel.
foreach (var id in ids)
careChannels.Find(c => c.Id == id)?.AddNewMessages(messages.Where(m => m.ChannelId == id));
lastMessageId = messages.LastOrDefault()?.Id ?? lastMessageId;
@ -151,6 +210,8 @@ namespace osu.Game.Overlays
ListChannelsRequest req = new ListChannelsRequest();
req.Success += delegate (List<Channel> channels)
{
Debug.Assert(careChannels.Count == 0);
Scheduler.Add(delegate
{
loading.FadeOut(100);

View File

@ -38,8 +38,9 @@ namespace osu.Game.Overlays
Colour = Color4.Black,
Alpha = 0.6f,
},
scrollContainer = new ScrollContainer()
scrollContainer = new ScrollContainer
{
RelativeSizeAxes = Axes.Both,
Margin = new MarginPadding { Top = Toolbar.Toolbar.HEIGHT },
Children = new[]
{

View File

@ -89,7 +89,6 @@ namespace osu.Game.Overlays.Notifications
IconContent = new Container
{
Size = new Vector2(40),
Colour = Color4.DarkGray,
Masking = true,
CornerRadius = 5,
},

View File

@ -1,7 +1,11 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Game.Graphics;
using osu.Framework.Graphics.Colour;
using OpenTK.Graphics;
namespace osu.Game.Overlays.Notifications
{
@ -14,5 +18,11 @@ namespace osu.Game.Overlays.Notifications
this.progressNotification = progressNotification;
Icon = FontAwesome.fa_check;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
IconBackgound.ColourInfo = ColourInfo.GradientVertical(colours.GreenDark, colours.GreenLight);
}
}
}

View File

@ -37,19 +37,21 @@ namespace osu.Game.Overlays.Notifications
private SpriteText textDrawable;
private TextAwesome iconDrawable;
protected Box IconBackgound;
public SimpleNotification()
{
IconContent.Add(new Drawable[]
{
new Box
IconBackgound = new Box
{
RelativeSizeAxes = Axes.Both,
ColourInfo = ColourInfo.GradientVertical(OsuColour.Gray(0.2f), OsuColour.Gray(0.5f))
ColourInfo = ColourInfo.GradientVertical(OsuColour.Gray(0.2f), OsuColour.Gray(0.6f))
},
iconDrawable = new TextAwesome
{
Anchor = Anchor.Centre,
Icon = icon ,
Icon = icon,
}
});

View File

@ -74,6 +74,7 @@ namespace osu.Game.Overlays.Options
{
Content.Anchor = Anchor.CentreLeft;
Content.Origin = Anchor.CentreLeft;
RelativeSizeAxes = Axes.Both;
}
}
}

View File

@ -55,7 +55,7 @@ namespace osu.Game.Overlays.Pause
}
}
public AudioSample SampleClick, SampleHover;
public SampleChannel SampleClick, SampleHover;
private Container backgroundContainer, colourContainer, glowContainer;
private Box leftGlow, centerGlow, rightGlow;

View File

@ -66,7 +66,7 @@ namespace osu.Game.Overlays.Toolbar
private SpriteText tooltip1;
private SpriteText tooltip2;
protected FlowContainer Flow;
private AudioSample sampleClick;
private SampleChannel sampleClick;
public ToolbarButton()
{

View File

@ -5,7 +5,7 @@ using System;
using System.Threading;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Input;
@ -13,9 +13,9 @@ using OpenTK;
namespace osu.Game.Screens
{
public abstract class BackgroundMode : GameMode, IEquatable<BackgroundMode>
public abstract class BackgroundScreen : Screen, IEquatable<BackgroundScreen>
{
public virtual bool Equals(BackgroundMode other)
public virtual bool Equals(BackgroundScreen other)
{
return other?.GetType() == GetType();
}
@ -37,21 +37,21 @@ namespace osu.Game.Screens
this.game = game;
}
public override bool Push(GameMode mode)
public override bool Push(Screen screen)
{
// When trying to push a non-loaded GameMode, load it asynchronously and re-invoke Push
// once it's done.
if (mode.LoadState == LoadState.NotLoaded)
if (screen.LoadState == LoadState.NotLoaded)
{
mode.Preload(game, d => Push((BackgroundMode)d));
screen.Preload(game, d => Push((BackgroundScreen)d));
return true;
}
// Make sure the in-progress loading is complete before pushing the GameMode.
while (mode.LoadState < LoadState.Loaded)
while (screen.LoadState < LoadState.Loaded)
Thread.Sleep(1);
base.Push(mode);
base.Push(screen);
return true;
}
@ -62,7 +62,7 @@ namespace osu.Game.Screens
Content.Scale = new Vector2(1 + (x_movement_amount / DrawSize.X) * 2);
}
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
Content.FadeOut();
Content.MoveToX(x_movement_amount);
@ -73,13 +73,13 @@ namespace osu.Game.Screens
base.OnEntering(last);
}
protected override void OnSuspending(GameMode next)
protected override void OnSuspending(Screen next)
{
Content.MoveToX(-x_movement_amount, transition_length, EasingTypes.InOutQuart);
base.OnSuspending(next);
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
Content.FadeOut(transition_length, EasingTypes.OutExpo);
Content.MoveToX(x_movement_amount, transition_length, EasingTypes.OutExpo);
@ -87,7 +87,7 @@ namespace osu.Game.Screens
return base.OnExiting(next);
}
protected override void OnResuming(GameMode last)
protected override void OnResuming(Screen last)
{
Content.MoveToX(0, transition_length, EasingTypes.OutExpo);
base.OnResuming(last);

View File

@ -9,7 +9,7 @@ using osu.Game.Graphics.Backgrounds;
namespace osu.Game.Screens.Backgrounds
{
public class BackgroundModeBeatmap : BackgroundMode
public class BackgroundScreenBeatmap : BackgroundScreen
{
private Background background;
@ -55,7 +55,7 @@ namespace osu.Game.Screens.Backgrounds
}
}
public BackgroundModeBeatmap(WorkingBeatmap beatmap)
public BackgroundScreenBeatmap(WorkingBeatmap beatmap)
{
Beatmap = beatmap;
}
@ -66,9 +66,9 @@ namespace osu.Game.Screens.Backgrounds
blurTarget = sigma;
}
public override bool Equals(BackgroundMode other)
public override bool Equals(BackgroundScreen other)
{
return base.Equals(other) && beatmap == ((BackgroundModeBeatmap)other).Beatmap;
return base.Equals(other) && beatmap == ((BackgroundScreenBeatmap)other).Beatmap;
}
class BeatmapBackground : Background

View File

@ -5,19 +5,19 @@ using osu.Game.Graphics.Backgrounds;
namespace osu.Game.Screens.Backgrounds
{
public class BackgroundModeCustom : BackgroundMode
public class BackgroundScreenCustom : BackgroundScreen
{
private readonly string textureName;
public BackgroundModeCustom(string textureName)
public BackgroundScreenCustom(string textureName)
{
this.textureName = textureName;
Add(new Background(textureName));
}
public override bool Equals(BackgroundMode other)
public override bool Equals(BackgroundScreen other)
{
return base.Equals(other) && textureName == ((BackgroundModeCustom)other).textureName;
return base.Equals(other) && textureName == ((BackgroundScreenCustom)other).textureName;
}
}
}

View File

@ -7,7 +7,7 @@ using osu.Game.Graphics.Backgrounds;
namespace osu.Game.Screens.Backgrounds
{
public class BackgroundModeDefault : BackgroundMode
public class BackgroundScreenDefault : BackgroundScreen
{
[BackgroundDependencyLoader]
private void load(BaseGame game)

View File

@ -3,7 +3,7 @@
namespace osu.Game.Screens.Backgrounds
{
public class BackgroundModeEmpty : BackgroundMode
public class BackgroundScreenEmpty : BackgroundScreen
{
}

View File

@ -3,7 +3,7 @@
namespace osu.Game.Screens.Charts
{
class ChartInfo : GameModeWhiteBox
class ChartInfo : ScreenWhiteBox
{
}
}

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
namespace osu.Game.Screens.Charts
{
class ChartListing : GameModeWhiteBox
class ChartListing : ScreenWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(ChartInfo)

View File

@ -3,7 +3,7 @@
namespace osu.Game.Screens.Direct
{
class OnlineListing : GameModeWhiteBox
class OnlineListing : ScreenWhiteBox
{
}
}

View File

@ -1,23 +1,23 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Game.Screens.Backgrounds;
using OpenTK.Graphics;
namespace osu.Game.Screens.Edit
{
class Editor : GameModeWhiteBox
class Editor : ScreenWhiteBox
{
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
Background.Schedule(() => Background.FadeColour(Color4.DarkGray, 500));
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
Background.Schedule(() => Background.FadeColour(Color4.White, 500));
return base.OnExiting(next);

View File

@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
@ -17,7 +17,7 @@ using OpenTK.Graphics;
namespace osu.Game.Screens
{
public class GameModeWhiteBox : OsuGameMode
public class ScreenWhiteBox : OsuScreen
{
private BackButton popButton;
@ -29,9 +29,9 @@ namespace osu.Game.Screens
private Container textContainer;
private Box box;
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg2");
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg2");
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
@ -54,7 +54,7 @@ namespace osu.Game.Screens
Content.FadeIn(transition_time, EasingTypes.OutExpo);
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
textContainer.MoveTo(new Vector2((DrawSize.X / 16), 0), transition_time, EasingTypes.OutExpo);
Content.FadeOut(transition_time, EasingTypes.OutExpo);
@ -62,7 +62,7 @@ namespace osu.Game.Screens
return base.OnExiting(next);
}
protected override void OnSuspending(GameMode next)
protected override void OnSuspending(Screen next)
{
base.OnSuspending(next);
@ -70,7 +70,7 @@ namespace osu.Game.Screens
Content.FadeOut(transition_time, EasingTypes.OutExpo);
}
protected override void OnResuming(GameMode last)
protected override void OnResuming(Screen last)
{
base.OnResuming(last);
@ -78,7 +78,7 @@ namespace osu.Game.Screens
Content.FadeIn(transition_time, EasingTypes.OutExpo);
}
public GameModeWhiteBox()
public ScreenWhiteBox()
{
Children = new Drawable[]
{
@ -148,7 +148,7 @@ namespace osu.Game.Screens
BackgroundColour = getColourFor(t),
Action = delegate
{
Push(Activator.CreateInstance(t) as GameMode);
Push(Activator.CreateInstance(t) as Screen);
}
});
}

View File

@ -0,0 +1,28 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Screens;
using osu.Game.Screens.Menu;
namespace osu.Game.Screens
{
class Loader : OsuScreen
{
internal override bool ShowOverlays => false;
public Loader()
{
ValidForResume = false;
}
[BackgroundDependencyLoader]
private void load(OsuGame game)
{
if (game.IsDeployedBuild)
new Disclaimer().Preload(game, d => Push((Screen)d));
else
new Intro().Preload(game, d => Push((Screen)d));
}
}
}

View File

@ -37,7 +37,7 @@ namespace osu.Game.Screens.Menu
private readonly float extraWidth;
private Key triggerKey;
private string text;
private AudioSample sampleClick;
private SampleChannel sampleClick;
public override bool Contains(Vector2 screenSpacePos)
{

View File

@ -32,8 +32,6 @@ namespace osu.Game.Screens.Menu
public Action OnChart;
public Action OnTest;
private AudioSample sampleOsuClick;
private Toolbar toolbar;
private FlowContainerWithOrigin buttonFlow;
@ -122,7 +120,6 @@ namespace osu.Game.Screens.Menu
[BackgroundDependencyLoader(true)]
private void load(AudioManager audio, OsuGame game = null)
{
sampleOsuClick = audio.Sample.Get(@"Menu/menuhit");
toolbar = game?.Toolbar;
}
@ -181,7 +178,6 @@ namespace osu.Game.Screens.Menu
switch (state)
{
case MenuState.Initial:
sampleOsuClick.Play();
State = MenuState.TopLevel;
return;
case MenuState.TopLevel:
@ -218,6 +214,7 @@ namespace osu.Game.Screens.Menu
switch (state)
{
case MenuState.Exit:
case MenuState.Initial:
toolbar?.Hide();
@ -233,6 +230,12 @@ namespace osu.Game.Screens.Menu
foreach (Button b in buttonsPlay)
b.State = ButtonState.Contracted;
if (state == MenuState.Exit)
{
osuLogo.RotateTo(20, EXIT_DELAY * 1.5f);
osuLogo.FadeOut(EXIT_DELAY);
}
break;
case MenuState.TopLevel:
buttonArea.Flush(true);
@ -276,21 +279,6 @@ namespace osu.Game.Screens.Menu
foreach (Button b in buttonsPlay)
b.State = ButtonState.Contracted;
break;
case MenuState.Exit:
buttonArea.FadeOut(200);
foreach (Button b in buttonsTopLevel)
b.State = ButtonState.Contracted;
foreach (Button b in buttonsPlay)
b.State = ButtonState.Contracted;
osuLogo.Delay(150);
osuLogo.ScaleTo(1f, EXIT_DELAY * 1.5f);
osuLogo.RotateTo(20, EXIT_DELAY * 1.5f);
osuLogo.FadeOut(EXIT_DELAY);
break;
}
backButton.State = state == MenuState.Play ? ButtonState.Expanded : ButtonState.Contracted;

View File

@ -0,0 +1,119 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Screens;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Screens.Menu
{
class Disclaimer : OsuScreen
{
private Intro intro;
private TextAwesome icon;
private Color4 iconColour;
internal override bool ShowOverlays => false;
public Disclaimer()
{
ValidForResume = false;
Children = new Drawable[]
{
new FlowContainer
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Direction = FlowDirections.Vertical,
Spacing = new Vector2(0, 2),
Children = new Drawable[]
{
icon = new TextAwesome
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Icon = FontAwesome.fa_warning,
TextSize = 30,
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
TextSize = 30,
Text = "This is a development build",
Margin = new MarginPadding
{
Bottom = 20
},
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = "Don't expect shit to work perfectly as this is very much a work in progress."
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = "Don't report bugs because we are aware. Don't complain about missing features because we are adding them."
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = "Sit back and enjoy. Visit discord.gg/ppy if you want to help out!",
Margin = new MarginPadding { Bottom = 20 },
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
TextSize = 12,
Text = "oh and yes, you will get seizures.",
},
}
}
};
}
[BackgroundDependencyLoader]
private void load(OsuGame game, OsuColour colours)
{
(intro = new Intro()).Preload(game);
iconColour = colours.Yellow;
}
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
Content.FadeInFromZero(500);
icon.Delay(1500);
icon.FadeColour(iconColour, 200);
Delay(6000, true);
Content.FadeOut(250);
Delay(250);
Schedule(() => Push(intro));
}
}
}

View File

@ -5,7 +5,7 @@ using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Game.Graphics.Containers;
@ -14,7 +14,7 @@ using OpenTK.Graphics;
namespace osu.Game.Screens.Menu
{
class Intro : OsuGameMode
public class Intro : OsuScreen
{
private OsuLogo logo;
@ -24,13 +24,13 @@ namespace osu.Game.Screens.Menu
internal bool DidLoadMenu;
MainMenu mainMenu;
private AudioSample welcome;
private AudioSample seeya;
private AudioTrack bgm;
private SampleChannel welcome;
private SampleChannel seeya;
private Track bgm;
internal override bool ShowOverlays => (ParentGameMode as OsuGameMode)?.ShowOverlays ?? false;
internal override bool ShowOverlays => false;
protected override BackgroundMode CreateBackground() => new BackgroundModeEmpty();
protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty();
public Intro()
{
@ -65,7 +65,7 @@ namespace osu.Game.Screens.Menu
bgm.Looping = true;
}
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
@ -77,8 +77,7 @@ namespace osu.Game.Screens.Menu
{
bgm.Start();
mainMenu = new MainMenu();
mainMenu.Preload(Game);
(mainMenu = new MainMenu()).Preload(Game);
Scheduler.AddDelayed(delegate
{
@ -95,24 +94,27 @@ namespace osu.Game.Screens.Menu
logo.FadeIn(20000, EasingTypes.OutQuint);
}
protected override void OnSuspending(GameMode next)
protected override void OnSuspending(Screen next)
{
Content.FadeOut(300);
base.OnSuspending(next);
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
//cancel exiting if we haven't loaded the menu yet.
return !DidLoadMenu;
}
protected override void OnResuming(GameMode last)
protected override void OnResuming(Screen last)
{
if (!(last is MainMenu))
Content.FadeIn(300);
//we also handle the exit transition.
seeya.Play();
double fadeOutTime = (last.LifetimeEnd - Time.Current) + 100;
double fadeOutTime = 2000;
Scheduler.AddDelayed(Exit, fadeOutTime);

View File

@ -2,8 +2,8 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.GameModes;
using osu.Framework.GameModes.Testing;
using osu.Framework.Screens;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transformations;
using osu.Game.Graphics.Containers;
@ -16,20 +16,20 @@ using osu.Game.Screens.Select;
namespace osu.Game.Screens.Menu
{
public class MainMenu : OsuGameMode
public class MainMenu : OsuScreen
{
private ButtonSystem buttons;
public override string Name => @"Main Menu";
internal override bool ShowOverlays => buttons.State != MenuState.Initial;
private BackgroundMode background;
private BackgroundScreen background;
protected override BackgroundMode CreateBackground() => background;
protected override BackgroundScreen CreateBackground() => background;
public MainMenu()
{
background = new BackgroundModeDefault();
background = new BackgroundScreenDefault();
Children = new Drawable[]
{
@ -59,16 +59,15 @@ namespace osu.Game.Screens.Menu
background.Preload(game);
buttons.OnSettings = game.ToggleOptions;
}
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
buttons.FadeInFromZero(500);
}
protected override void OnSuspending(GameMode next)
protected override void OnSuspending(Screen next)
{
base.OnSuspending(next);
@ -80,7 +79,7 @@ namespace osu.Game.Screens.Menu
Content.MoveTo(new Vector2(-800, 0), length, EasingTypes.InSine);
}
protected override void OnResuming(GameMode last)
protected override void OnResuming(Screen last)
{
base.OnResuming(last);
@ -92,10 +91,10 @@ namespace osu.Game.Screens.Menu
Content.MoveTo(new Vector2(0, 0), length, EasingTypes.OutQuint);
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
buttons.State = MenuState.Exit;
Content.FadeOut(ButtonSystem.EXIT_DELAY);
Content.FadeOut(3000);
return base.OnExiting(next);
}
}

View File

@ -33,7 +33,7 @@ namespace osu.Game.Screens.Menu
private Container logoBounceContainer;
private Container logoHoverContainer;
private AudioSample sampleClick;
private SampleChannel sampleClick;
private Container colourAndTriangles;
@ -195,11 +195,12 @@ namespace osu.Game.Screens.Menu
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{
logoBounceContainer.ScaleTo(1f, 500, EasingTypes.OutElastic);
return true;
}
protected override bool OnDragStart(InputState state) => true;
protected override bool OnClick(InputState state)
{
if (!Interactive) return false;

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
namespace osu.Game.Screens.Multiplayer
{
class Lobby : GameModeWhiteBox
class Lobby : ScreenWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(MatchCreate),

View File

@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Play;
using OpenTK.Graphics;
@ -11,23 +11,23 @@ using osu.Game.Screens.Select;
namespace osu.Game.Screens.Multiplayer
{
class Match : GameModeWhiteBox
class Match : ScreenWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(MatchSongSelect),
typeof(Player),
};
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
Background.Schedule(() => Background.FadeColour(Color4.DarkGray, 500));
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
Background.Schedule(() => Background.FadeColour(Color4.White, 500));
return base.OnExiting(next);

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
namespace osu.Game.Screens.Multiplayer
{
class MatchCreate : GameModeWhiteBox
class MatchCreate : ScreenWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(Match)

View File

@ -4,21 +4,21 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
namespace osu.Game.Screens
{
public abstract class OsuGameMode : GameMode
public abstract class OsuScreen : Screen
{
internal BackgroundMode Background { get; private set; }
internal BackgroundScreen Background { get; private set; }
/// <summary>
/// Override to create a BackgroundMode for the current GameMode.
/// Note that the instance created may not be the used instance if it matches the BackgroundMode equality clause.
/// </summary>
protected virtual BackgroundMode CreateBackground() => null;
protected virtual BackgroundScreen CreateBackground() => null;
internal virtual bool ShowOverlays => true;
@ -73,15 +73,15 @@ namespace osu.Game.Screens
beatmap = game?.Beatmap;
}
public override bool Push(GameMode mode)
public override bool Push(Screen screen)
{
OsuGameMode nextOsu = mode as OsuGameMode;
OsuScreen nextOsu = screen as OsuScreen;
if (nextOsu != null)
{
nextOsu.beatmap = beatmap;
}
return base.Push(mode);
return base.Push(screen);
}
protected virtual void OnBeatmapChanged(WorkingBeatmap beatmap)
@ -89,11 +89,11 @@ namespace osu.Game.Screens
}
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
OsuGameMode lastOsu = last as OsuGameMode;
OsuScreen lastOsu = last as OsuScreen;
BackgroundMode bg = CreateBackground();
BackgroundScreen bg = CreateBackground();
if (lastOsu?.Background != null)
{
@ -120,9 +120,9 @@ namespace osu.Game.Screens
base.OnEntering(last);
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
OsuGameMode nextOsu = next as OsuGameMode;
OsuScreen nextOsu = next as OsuScreen;
if (Background != null && !Background.Equals(nextOsu?.Background))
{

View File

@ -1,7 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
@ -14,9 +14,9 @@ using OpenTK.Graphics;
namespace osu.Game.Screens.Play
{
class FailDialog : OsuGameMode
class FailDialog : OsuScreen
{
protected override BackgroundMode CreateBackground() => new BackgroundModeBeatmap(Beatmap);
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
private static readonly Vector2 background_blur = new Vector2(20);
@ -31,13 +31,13 @@ namespace osu.Game.Screens.Play
});
}
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
Background.Schedule(() => (Background as BackgroundModeBeatmap)?.BlurTo(background_blur, 1000));
Background.Schedule(() => (Background as BackgroundScreenBeatmap)?.BlurTo(background_blur, 1000));
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
Background.Schedule(() => Background.FadeColour(Color4.White, 500));
return base.OnExiting(next);

View File

@ -89,6 +89,8 @@ namespace osu.Game.Screens.Play
new OsuSpriteText
{
Text = Name,
Font = @"Venera",
TextSize = 12,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativePositionAxes = Axes.Both,

View File

@ -1,23 +1,23 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Game.Screens.Backgrounds;
using OpenTK.Graphics;
namespace osu.Game.Screens.Play
{
class ModSelect : GameModeWhiteBox
class ModSelect : ScreenWhiteBox
{
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
Background.Schedule(() => Background.FadeColour(Color4.DarkGray, 500));
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
Background.Schedule(() => Background.FadeColour(Color4.White, 500));
return base.OnExiting(next);

View File

@ -12,7 +12,7 @@ using osu.Game.Modes;
using osu.Game.Modes.Objects.Drawables;
using osu.Game.Screens.Backgrounds;
using OpenTK;
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Game.Modes.UI;
using osu.Game.Screens.Ranking;
using osu.Game.Configuration;
@ -27,11 +27,11 @@ using osu.Framework.Logging;
namespace osu.Game.Screens.Play
{
public class Player : OsuGameMode
public class Player : OsuScreen
{
public bool Autoplay;
protected override BackgroundMode CreateBackground() => new BackgroundModeBeatmap(Beatmap);
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
internal override bool ShowOverlays => false;
@ -89,7 +89,7 @@ namespace osu.Game.Screens.Play
return;
}
AudioTrack track = Beatmap.Track;
Track track = Beatmap.Track;
if (track != null)
{
@ -240,21 +240,6 @@ namespace osu.Game.Screens.Play
});
}
protected override void LoadComplete()
{
base.LoadComplete();
Content.Delay(250);
Content.FadeIn(250);
Delay(750);
Schedule(() =>
{
sourceClock.Start();
initializeSkipButton();
});
}
private void onPass()
{
Delay(1000);
@ -281,18 +266,34 @@ namespace osu.Game.Screens.Play
});
}
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
(Background as BackgroundModeBeatmap)?.BlurTo(Vector2.Zero, 1000);
(Background as BackgroundScreenBeatmap)?.BlurTo(Vector2.Zero, 1000);
Background?.FadeTo((100f - dimLevel) / 100, 1000);
Content.Alpha = 0;
dimLevel.ValueChanged += dimChanged;
Content.Delay(250);
Content.FadeIn(250);
Delay(750);
Schedule(() =>
{
sourceClock.Start();
initializeSkipButton();
});
}
protected override bool OnExiting(GameMode next)
protected override void OnSuspending(Screen next)
{
Content.FadeOut(350);
base.OnSuspending(next);
}
protected override bool OnExiting(Screen next)
{
if (pauseOverlay == null) return false;

View File

@ -1,7 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
@ -14,21 +14,21 @@ using OpenTK.Graphics;
namespace osu.Game.Screens.Ranking
{
class Results : OsuGameMode
class Results : OsuScreen
{
protected override BackgroundMode CreateBackground() => new BackgroundModeBeatmap(Beatmap);
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
private static readonly Vector2 background_blur = new Vector2(20);
ScoreDisplay scoreDisplay;
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
Background.Schedule(() => (Background as BackgroundModeBeatmap)?.BlurTo(background_blur, 1000));
Background.Schedule(() => (Background as BackgroundScreenBeatmap)?.BlurTo(background_blur, 1000));
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
Background.Schedule(() => Background.FadeColour(Color4.White, 500));
return base.OnExiting(next);

View File

@ -8,12 +8,12 @@ using osu.Game.Screens.Edit;
namespace osu.Game.Screens.Select
{
class EditSongSelect : GameModeWhiteBox
class EditSongSelect : ScreenWhiteBox
{
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(Editor)
};
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
}
}

View File

@ -47,18 +47,19 @@ namespace osu.Game.Screens.Select
Direction = FlowDirections.Vertical,
Children = new Drawable[]
{
searchTextBox = new SearchTextBox { RelativeSizeAxes = Axes.X },
searchTextBox = new SearchTextBox {
RelativeSizeAxes = Axes.X,
OnChange = (TextBox sender, bool newText) =>
{
if (newText)
FilterChanged?.Invoke();
},
Exit = () => Exit?.Invoke(),
},
new GroupSortTabs()
}
}
};
searchTextBox.OnChange += (TextBox sender, bool newText) =>
{
if (newText)
FilterChanged?.Invoke();
};
searchTextBox.Exit = () => Exit?.Invoke();
}
public void Deactivate()

View File

@ -25,6 +25,8 @@ namespace osu.Game.Screens.Select
private const float padding = 80;
public override bool Contains(Vector2 screenSpacePos) => true;
public Action OnBack;
public Action OnStart;

View File

@ -5,8 +5,8 @@ using osu.Game.Screens.Backgrounds;
namespace osu.Game.Screens.Select
{
class MatchSongSelect : GameModeWhiteBox
class MatchSongSelect : ScreenWhiteBox
{
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
}
}

View File

@ -9,7 +9,7 @@ using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Configuration;
using osu.Framework.GameModes;
using osu.Framework.Screens;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Game.Beatmaps;
@ -33,11 +33,11 @@ using osu.Game.Overlays.Mods;
namespace osu.Game.Screens.Select
{
public class PlaySongSelect : OsuGameMode
public class PlaySongSelect : OsuScreen
{
private Bindable<PlayMode> playMode;
private BeatmapDatabase database;
protected override BackgroundMode CreateBackground() => new BackgroundModeBeatmap(Beatmap);
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
private CarouselContainer carousel;
private TrackManager trackManager;
@ -50,8 +50,8 @@ namespace osu.Game.Screens.Select
private static readonly Vector2 background_blur = new Vector2(20);
private CancellationTokenSource initialAddSetsTask;
private AudioSample sampleChangeDifficulty;
private AudioSample sampleChangeBeatmap;
private SampleChannel sampleChangeDifficulty;
private SampleChannel sampleChangeBeatmap;
private List<BeatmapGroup> beatmapGroups;
@ -221,7 +221,7 @@ namespace osu.Game.Screens.Select
Schedule(() => addBeatmapSet(s, Game, true));
}
protected override void OnEntering(GameMode last)
protected override void OnEntering(Screen last)
{
base.OnEntering(last);
ensurePlayingSelected();
@ -236,7 +236,7 @@ namespace osu.Game.Screens.Select
filter.Activate();
}
protected override void OnResuming(GameMode last)
protected override void OnResuming(Screen last)
{
player = null;
@ -251,7 +251,7 @@ namespace osu.Game.Screens.Select
filter.Activate();
}
protected override void OnSuspending(GameMode next)
protected override void OnSuspending(Screen next)
{
Content.ScaleTo(1.1f, 250, EasingTypes.InSine);
@ -261,7 +261,7 @@ namespace osu.Game.Screens.Select
base.OnSuspending(next);
}
protected override bool OnExiting(GameMode next)
protected override bool OnExiting(Screen next)
{
beatmapInfoWedge.MoveToX(-100, 800, EasingTypes.InQuint);
beatmapInfoWedge.RotateTo(10, 800, EasingTypes.InQuint);
@ -290,7 +290,7 @@ namespace osu.Game.Screens.Select
private void changeBackground(WorkingBeatmap beatmap)
{
var backgroundModeBeatmap = Background as BackgroundModeBeatmap;
var backgroundModeBeatmap = Background as BackgroundScreenBeatmap;
if (backgroundModeBeatmap != null)
{
backgroundModeBeatmap.Beatmap = beatmap;
@ -336,7 +336,7 @@ namespace osu.Game.Screens.Select
private void ensurePlayingSelected(bool preview = false)
{
AudioTrack track = Beatmap?.Track;
Track track = Beatmap?.Track;
if (track != null)
{
@ -356,11 +356,13 @@ namespace osu.Game.Screens.Select
if (b.Metadata == null) b.Metadata = beatmapSet.Metadata;
});
foreach (var b in beatmapSet.Beatmaps)
b.ComputeDifficulty(database);
beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.StarDifficulty).ToList();
var beatmap = new WorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault(), beatmapSet, database);
var group = new BeatmapGroup(beatmap, beatmapSet)
var group = new BeatmapGroup(beatmap)
{
SelectionChanged = selectionChanged,
StartRequested = b => start()

View File

@ -16,26 +16,8 @@ namespace osu.Game.Screens.Select
/// <summary>
/// A textbox which holds focus eagerly.
/// </summary>
public class SearchTextBox : OsuTextBox
public class SearchTextBox : FocusedTextBox
{
protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255);
protected override Color4 BackgroundFocused => new Color4(10, 10, 10, 255);
public Action Exit;
private bool focus;
public bool HoldFocus
{
get { return focus; }
set
{
focus = value;
if (!focus)
TriggerFocusLost();
}
}
public override bool RequestingFocus => HoldFocus;
public SearchTextBox()
{
Height = 35;
@ -53,25 +35,6 @@ namespace osu.Game.Screens.Select
PlaceholderText = "type to search";
}
protected override bool OnFocus(InputState state)
{
var result = base.OnFocus(state);
BorderThickness = 0;
return result;
}
protected override void OnFocusLost(InputState state)
{
if (state.Keyboard.Keys.Any(key => key == Key.Escape))
{
if (Text.Length > 0)
Text = string.Empty;
else
Exit?.Invoke();
}
base.OnFocusLost(state);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (HandlePendingText(state)) return true;

View File

@ -66,10 +66,12 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
<Compile Include="Beatmaps\DifficultyCalculator.cs" />
<Compile Include="Graphics\Backgrounds\Triangles.cs" />
<Compile Include="Graphics\Cursor\CursorTrail.cs" />
<Compile Include="Graphics\Sprites\OsuSpriteText.cs" />
<Compile Include="Graphics\UserInterface\BackButton.cs" />
<Compile Include="Graphics\UserInterface\FocusedTextBox.cs" />
<Compile Include="Graphics\UserInterface\Nub.cs" />
<Compile Include="Graphics\UserInterface\OsuPasswordTextBox.cs" />
<Compile Include="Graphics\UserInterface\OsuSliderBar.cs" />
@ -123,15 +125,17 @@
<Compile Include="Overlays\Toolbar\ToolbarOverlayToggleButton.cs" />
<Compile Include="Overlays\Toolbar\ToolbarUserArea.cs" />
<Compile Include="Overlays\Toolbar\ToolbarUserButton.cs" />
<Compile Include="Screens\BackgroundMode.cs" />
<Compile Include="Screens\Backgrounds\BackgroundModeBeatmap.cs" />
<Compile Include="Screens\Backgrounds\BackgroundModeCustom.cs" />
<Compile Include="Screens\Backgrounds\BackgroundModeDefault.cs" />
<Compile Include="Screens\Backgrounds\BackgroundModeEmpty.cs" />
<Compile Include="Screens\BackgroundScreen.cs" />
<Compile Include="Screens\Backgrounds\BackgroundScreenBeatmap.cs" />
<Compile Include="Screens\Backgrounds\BackgroundScreenCustom.cs" />
<Compile Include="Screens\Backgrounds\BackgroundScreenDefault.cs" />
<Compile Include="Screens\Backgrounds\BackgroundScreenEmpty.cs" />
<Compile Include="Screens\Charts\ChartInfo.cs" />
<Compile Include="Screens\Edit\Editor.cs" />
<Compile Include="Screens\GameModeWhiteBox.cs" />
<Compile Include="Screens\GameScreenWhiteBox.cs" />
<Compile Include="Screens\Loader.cs" />
<Compile Include="Screens\Menu\Button.cs" />
<Compile Include="Screens\Menu\Disclaimer.cs" />
<Compile Include="Screens\Menu\FlowContainerWithOrigin.cs" />
<Compile Include="Screens\Menu\Intro.cs" />
<Compile Include="Screens\Menu\ButtonSystem.cs" />
@ -146,7 +150,7 @@
<Compile Include="Screens\Play\SkipButton.cs" />
<Compile Include="Screens\Select\CarouselContainer.cs" />
<Compile Include="Screens\Select\MatchSongSelect.cs" />
<Compile Include="Screens\OsuGameMode.cs" />
<Compile Include="Screens\OsuGameScreen.cs" />
<Compile Include="Screens\Play\ModSelect.cs" />
<Compile Include="Beatmaps\Drawables\BeatmapGroup.cs" />
<Compile Include="Beatmaps\Drawables\BeatmapPanel.cs" />
@ -187,7 +191,7 @@
<Compile Include="Online\API\SecurePassword.cs" />
<Compile Include="Online\API\Requests\ListChannels.cs" />
<Compile Include="Online\Chat\Channel.cs" />
<Compile Include="Online\Chat\Drawables\ChannelDisplay.cs" />
<Compile Include="Online\Chat\Drawables\DrawableChannel.cs" />
<Compile Include="Online\Chat\Drawables\ChatLine.cs" />
<Compile Include="Online\Chat\Message.cs" />
<Compile Include="Online\User.cs" />