1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-31 05:50:10 +08:00

Merge branch 'master' into fix-background-fade

This commit is contained in:
Dean Herbert
2018-03-24 03:40:13 +09:00
committed by GitHub
Unverified
7 changed files with 46 additions and 28 deletions
+1 -1
View File
@@ -988,7 +988,7 @@ namespace osu.Game.Graphics
fa_osu_expert_mania = 0xe028,
// mod icons
fa_osu_mod_perfect = 0xe02d,
fa_osu_mod_perfect = 0xe049,
fa_osu_mod_autopilot = 0xe03a,
fa_osu_mod_auto = 0xe03b,
fa_osu_mod_cinema = 0xe03c,
+8 -9
View File
@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Logging;
@@ -44,8 +45,7 @@ namespace osu.Game.Online.API
protected bool HasLogin => Token != null || !string.IsNullOrEmpty(ProvidedUsername) && !string.IsNullOrEmpty(password);
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable (should dispose of this or at very least keep a reference).
private readonly Thread thread;
private readonly CancellationTokenSource cancellationToken = new CancellationTokenSource();
private readonly Logger log;
@@ -59,8 +59,7 @@ namespace osu.Game.Online.API
ProvidedUsername = config.Get<string>(OsuSetting.Username);
Token = config.Get<string>(OsuSetting.Token);
thread = new Thread(run) { IsBackground = true };
thread.Start();
Task.Factory.StartNew(run, cancellationToken.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
}
private readonly List<IOnlineComponent> components = new List<IOnlineComponent>();
@@ -93,7 +92,7 @@ namespace osu.Game.Online.API
private void run()
{
while (thread.IsAlive)
while (!cancellationToken.IsCancellationRequested)
{
switch (State)
{
@@ -267,10 +266,7 @@ namespace osu.Game.Online.API
public bool IsLoggedIn => LocalUser.Value.Id > 1;
public void Queue(APIRequest request)
{
queue.Enqueue(request);
}
public void Queue(APIRequest request) => queue.Enqueue(request);
public event StateChangeDelegate OnStateChange;
@@ -312,6 +308,9 @@ namespace osu.Game.Online.API
config.Set(OsuSetting.Token, config.Get<bool>(OsuSetting.SavePassword) ? Token : string.Empty);
config.Save();
flushQueue();
cancellationToken.Cancel();
}
}
-12
View File
@@ -4,9 +4,6 @@
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
@@ -30,7 +27,6 @@ namespace osu.Game.Overlays.Mods
private ModIcon backgroundIcon;
private readonly SpriteText text;
private readonly Container<ModIcon> iconsContainer;
private SampleChannel sampleOn, sampleOff;
/// <summary>
/// Fired when the selection changes.
@@ -100,7 +96,6 @@ namespace osu.Game.Overlays.Mods
foregroundIcon.Highlighted = Selected;
(selectedIndex == -1 ? sampleOff : sampleOn).Play();
SelectionChanged?.Invoke(SelectedMod);
return true;
}
@@ -152,13 +147,6 @@ namespace osu.Game.Overlays.Mods
public virtual Mod SelectedMod => Mods.ElementAtOrDefault(selectedIndex);
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sampleOn = audio.Sample.Get(@"UI/check-on");
sampleOff = audio.Sample.Get(@"UI/check-off");
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
switch (args.Button)
+17 -1
View File
@@ -15,6 +15,8 @@ using osu.Game.Rulesets.Mods;
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets;
using osu.Game.Graphics.UserInterface;
@@ -49,7 +51,7 @@ namespace osu.Game.Overlays.Mods
}
[BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuColour colours, OsuGame osu, RulesetStore rulesets)
private void load(OsuColour colours, OsuGame osu, RulesetStore rulesets, AudioManager audio)
{
SelectedMods.ValueChanged += selectedModsChanged;
@@ -63,6 +65,9 @@ namespace osu.Game.Overlays.Mods
Ruleset.ValueChanged += rulesetChanged;
Ruleset.TriggerChange();
sampleOn = audio.Sample.Get(@"UI/check-on");
sampleOff = audio.Sample.Get(@"UI/check-off");
}
protected override void Dispose(bool isDisposing)
@@ -154,10 +159,21 @@ namespace osu.Game.Overlays.Mods
section.DeselectTypes(modTypes, immediate);
}
private SampleChannel sampleOn, sampleOff;
private void modButtonPressed(Mod selectedMod)
{
if (selectedMod != null)
{
if (State == Visibility.Visible) sampleOn?.Play();
DeselectTypes(selectedMod.IncompatibleMods, true);
}
else
{
if (State == Visibility.Visible) sampleOff?.Play();
}
refreshSelectedMods();
}
+1 -1
View File
@@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Mods
{
public override string Name => "Perfect";
public override string ShortenedName => "PF";
public override FontAwesome Icon => FontAwesome.fa_question;
public override FontAwesome Icon => FontAwesome.fa_osu_mod_perfect;
public override string Description => "SS or quit.";
protected override bool FailCondition(ScoreProcessor scoreProcessor) => scoreProcessor.Accuracy.Value != 1;
+15 -2
View File
@@ -1,6 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@@ -27,6 +28,8 @@ namespace osu.Game.Screens.Play
private bool showOverlays = true;
public override bool ShowOverlaysOnEnter => showOverlays;
private Task loadTask;
public PlayerLoader(Player player)
{
this.player = player;
@@ -55,7 +58,7 @@ namespace osu.Game.Screens.Play
Margin = new MarginPadding(25)
});
LoadComponentAsync(player);
loadTask = LoadComponentAsync(player);
}
protected override void OnResuming(Screen last)
@@ -65,7 +68,7 @@ namespace osu.Game.Screens.Play
contentIn();
//we will only be resumed if the player has requested a re-run (see ValidForResume setting above)
LoadComponentAsync(player = new Player
loadTask = LoadComponentAsync(player = new Player
{
RestartCount = player.RestartCount + 1,
RestartRequested = player.RestartRequested,
@@ -154,6 +157,8 @@ namespace osu.Game.Screens.Play
{
if (!IsCurrentScreen) return;
loadTask = null;
if (!Push(player))
Exit();
else
@@ -192,6 +197,14 @@ namespace osu.Game.Screens.Play
return base.OnExiting(next);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
// if the player never got pushed, we should explicitly dispose it.
loadTask?.ContinueWith(_ => player.Dispose());
}
private class BeatmapMetadataDisplay : Container
{
private class MetadataLine : Container
@@ -48,13 +48,15 @@ namespace osu.Game.Skinning
this.source = source;
}
private void onSourceChanged() => SourceChanged?.Invoke();
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent)
{
var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent));
fallbackSource = dependencies.Get<ISkinSource>();
if (fallbackSource != null)
fallbackSource.SourceChanged += () => SourceChanged?.Invoke();
fallbackSource.SourceChanged += onSourceChanged;
dependencies.CacheAs<ISkinSource>(this);
@@ -66,7 +68,7 @@ namespace osu.Game.Skinning
base.Dispose(isDisposing);
if (fallbackSource != null)
fallbackSource.SourceChanged -= SourceChanged;
fallbackSource.SourceChanged -= onSourceChanged;
}
}
}