mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Merge branch 'master' into fix-testcase-performance
This commit is contained in:
Submodule osu-framework updated: 66421b8944...6134dafccb
@ -105,6 +105,8 @@ namespace osu.Game.Rulesets.Mania.Mods
|
|||||||
|
|
||||||
public abstract class ManiaKeyMod : Mod
|
public abstract class ManiaKeyMod : Mod
|
||||||
{
|
{
|
||||||
|
// TODO: implement using the IApplicable interface. Haven't done so yet because KeyCount isn't even hooked up at the moment.
|
||||||
|
|
||||||
public override string ShortenedName => Name;
|
public override string ShortenedName => Name;
|
||||||
public abstract int KeyCount { get; }
|
public abstract int KeyCount { get; }
|
||||||
public override double ScoreMultiplier => 1; // TODO: Implement the mania key mod score multiplier
|
public override double ScoreMultiplier => 1; // TODO: Implement the mania key mod score multiplier
|
||||||
|
@ -15,6 +15,8 @@ using System.Collections.Generic;
|
|||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Rulesets.Mania;
|
||||||
|
using osu.Game.Rulesets.Mania.Mods;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
@ -68,6 +70,9 @@ namespace osu.Game.Tests.Visual
|
|||||||
case OsuRuleset or:
|
case OsuRuleset or:
|
||||||
testOsuMods(or);
|
testOsuMods(or);
|
||||||
break;
|
break;
|
||||||
|
case ManiaRuleset mr:
|
||||||
|
testManiaMods(mr);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,16 +85,27 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
var noFailMod = easierMods.FirstOrDefault(m => m is OsuModNoFail);
|
var noFailMod = easierMods.FirstOrDefault(m => m is OsuModNoFail);
|
||||||
var hiddenMod = harderMods.FirstOrDefault(m => m is OsuModHidden);
|
var hiddenMod = harderMods.FirstOrDefault(m => m is OsuModHidden);
|
||||||
|
|
||||||
var doubleTimeMod = harderMods.OfType<MultiMod>().FirstOrDefault(m => m.Mods.Any(a => a is OsuModDoubleTime));
|
var doubleTimeMod = harderMods.OfType<MultiMod>().FirstOrDefault(m => m.Mods.Any(a => a is OsuModDoubleTime));
|
||||||
|
|
||||||
var autoPilotMod = assistMods.FirstOrDefault(m => m is OsuModAutopilot);
|
var autoPilotMod = assistMods.FirstOrDefault(m => m is OsuModAutopilot);
|
||||||
|
|
||||||
|
var easy = easierMods.FirstOrDefault(m => m is OsuModEasy);
|
||||||
|
var hardRock = harderMods.FirstOrDefault(m => m is OsuModHardRock);
|
||||||
|
|
||||||
testSingleMod(noFailMod);
|
testSingleMod(noFailMod);
|
||||||
testMultiMod(doubleTimeMod);
|
testMultiMod(doubleTimeMod);
|
||||||
testIncompatibleMods(noFailMod, autoPilotMod);
|
testIncompatibleMods(easy, hardRock);
|
||||||
testDeselectAll(easierMods.Where(m => !(m is MultiMod)));
|
testDeselectAll(easierMods.Where(m => !(m is MultiMod)));
|
||||||
testMultiplierTextColour(noFailMod, modSelect.LowMultiplierColour);
|
testMultiplierTextColour(noFailMod, modSelect.LowMultiplierColour);
|
||||||
testMultiplierTextColour(hiddenMod, modSelect.HighMultiplierColour);
|
testMultiplierTextColour(hiddenMod, modSelect.HighMultiplierColour);
|
||||||
testMultiplierTextUnranked(autoPilotMod);
|
|
||||||
|
testUnimplmentedMod(autoPilotMod);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testManiaMods(ManiaRuleset ruleset)
|
||||||
|
{
|
||||||
|
testMultiplierTextUnranked(ruleset.GetModsFor(ModType.Special).First(m => m is ManiaModRandom));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testSingleMod(Mod mod)
|
private void testSingleMod(Mod mod)
|
||||||
@ -124,6 +140,12 @@ namespace osu.Game.Tests.Visual
|
|||||||
checkNotSelected(mod);
|
checkNotSelected(mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void testUnimplmentedMod(Mod mod)
|
||||||
|
{
|
||||||
|
selectNext(mod);
|
||||||
|
checkNotSelected(mod);
|
||||||
|
}
|
||||||
|
|
||||||
private void testIncompatibleMods(Mod modA, Mod modB)
|
private void testIncompatibleMods(Mod modA, Mod modB)
|
||||||
{
|
{
|
||||||
selectNext(modA);
|
selectNext(modA);
|
||||||
@ -169,9 +191,9 @@ namespace osu.Game.Tests.Visual
|
|||||||
AddAssert("check for ranked", () => !modSelect.MultiplierLabel.Text.EndsWith(unranked_suffix));
|
AddAssert("check for ranked", () => !modSelect.MultiplierLabel.Text.EndsWith(unranked_suffix));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectNext(Mod mod) => AddStep($"left click {mod.Name}", () => modSelect.GetModButton(mod)?.SelectNext());
|
private void selectNext(Mod mod) => AddStep($"left click {mod.Name}", () => modSelect.GetModButton(mod)?.SelectNext(1));
|
||||||
|
|
||||||
private void selectPrevious(Mod mod) => AddStep($"right click {mod.Name}", () => modSelect.GetModButton(mod)?.SelectPrevious());
|
private void selectPrevious(Mod mod) => AddStep($"right click {mod.Name}", () => modSelect.GetModButton(mod)?.SelectNext(-1));
|
||||||
|
|
||||||
private void checkSelected(Mod mod)
|
private void checkSelected(Mod mod)
|
||||||
{
|
{
|
||||||
|
@ -19,6 +19,7 @@ using osu.Game.Beatmaps.Formats;
|
|||||||
using osu.Game.Beatmaps.IO;
|
using osu.Game.Beatmaps.IO;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Textures;
|
||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
using osu.Game.IPC;
|
using osu.Game.IPC;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
@ -651,7 +652,7 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return new TextureStore(new RawTextureLoaderStore(store), false).Get(getPathForFile(Metadata.BackgroundFile));
|
return new LargeTextureStore(new RawTextureLoaderStore(store)).Get(getPathForFile(Metadata.BackgroundFile));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -5,8 +5,8 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Game.Graphics.Textures;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.Backgrounds
|
namespace osu.Game.Graphics.Backgrounds
|
||||||
{
|
{
|
||||||
@ -22,7 +22,6 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
|
|
||||||
this.textureName = textureName;
|
this.textureName = textureName;
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
Depth = float.MaxValue;
|
|
||||||
|
|
||||||
Add(Sprite = new Sprite
|
Add(Sprite = new Sprite
|
||||||
{
|
{
|
||||||
@ -35,7 +34,7 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(TextureStore textures)
|
private void load(LargeTextureStore textures)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(textureName))
|
if (!string.IsNullOrEmpty(textureName))
|
||||||
Sprite.Texture = textures.Get(textureName);
|
Sprite.Texture = textures.Get(textureName);
|
||||||
|
18
osu.Game/Graphics/Textures/LargeTextureStore.cs
Normal file
18
osu.Game/Graphics/Textures/LargeTextureStore.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// 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.Graphics.Textures;
|
||||||
|
using osu.Framework.IO.Stores;
|
||||||
|
|
||||||
|
namespace osu.Game.Graphics.Textures
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A texture store that bypasses atlasing.
|
||||||
|
/// </summary>
|
||||||
|
public class LargeTextureStore : TextureStore
|
||||||
|
{
|
||||||
|
public LargeTextureStore(IResourceStore<RawTexture> store = null) : base(store, false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -18,8 +18,10 @@ using osu.Game.Graphics;
|
|||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Framework.Graphics.Performance;
|
using osu.Framework.Graphics.Performance;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Graphics.Textures;
|
||||||
using osu.Game.Input;
|
using osu.Game.Input;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
@ -89,6 +91,8 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
dependencies.Cache(contextFactory = new DatabaseContextFactory(Host));
|
dependencies.Cache(contextFactory = new DatabaseContextFactory(Host));
|
||||||
|
|
||||||
|
dependencies.Cache(new LargeTextureStore(new RawTextureLoaderStore(new NamespacedResourceStore<byte[]>(Resources, @"Textures"))));
|
||||||
|
|
||||||
dependencies.Cache(this);
|
dependencies.Cache(this);
|
||||||
dependencies.Cache(LocalConfig);
|
dependencies.Cache(LocalConfig);
|
||||||
|
|
||||||
|
@ -32,7 +32,10 @@ namespace osu.Game.Overlays.Mods
|
|||||||
private readonly Container<ModIcon> iconsContainer;
|
private readonly Container<ModIcon> iconsContainer;
|
||||||
private SampleChannel sampleOn, sampleOff;
|
private SampleChannel sampleOn, sampleOff;
|
||||||
|
|
||||||
public Action<Mod> Action; // Passed the selected mod or null if none
|
/// <summary>
|
||||||
|
/// Fired when the selection changes.
|
||||||
|
/// </summary>
|
||||||
|
public Action<Mod> SelectionChanged;
|
||||||
|
|
||||||
public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? string.Empty;
|
public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? string.Empty;
|
||||||
|
|
||||||
@ -42,71 +45,73 @@ namespace osu.Game.Overlays.Mods
|
|||||||
// A selected index of -1 means not selected.
|
// A selected index of -1 means not selected.
|
||||||
private int selectedIndex = -1;
|
private int selectedIndex = -1;
|
||||||
|
|
||||||
protected int SelectedIndex
|
/// <summary>
|
||||||
|
/// Change the selected mod index of this button.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="newIndex">The new index.</param>
|
||||||
|
/// <returns>Whether the selection changed.</returns>
|
||||||
|
private bool changeSelectedIndex(int newIndex)
|
||||||
{
|
{
|
||||||
get
|
if (newIndex == selectedIndex) return false;
|
||||||
|
|
||||||
|
int direction = newIndex < selectedIndex ? -1 : 1;
|
||||||
|
bool beforeSelected = Selected;
|
||||||
|
|
||||||
|
Mod modBefore = SelectedMod ?? Mods[0];
|
||||||
|
|
||||||
|
if (newIndex >= Mods.Length)
|
||||||
|
newIndex = -1;
|
||||||
|
else if (newIndex < -1)
|
||||||
|
newIndex = Mods.Length - 1;
|
||||||
|
|
||||||
|
if (newIndex >= 0 && !Mods[newIndex].HasImplementation)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
selectedIndex = newIndex;
|
||||||
|
Mod modAfter = SelectedMod ?? Mods[0];
|
||||||
|
|
||||||
|
if (beforeSelected != Selected)
|
||||||
{
|
{
|
||||||
return selectedIndex;
|
iconsContainer.RotateTo(Selected ? 5f : 0f, 300, Easing.OutElastic);
|
||||||
|
iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, Easing.OutElastic);
|
||||||
}
|
}
|
||||||
set
|
|
||||||
|
if (modBefore != modAfter)
|
||||||
{
|
{
|
||||||
if (value == selectedIndex) return;
|
const float rotate_angle = 16;
|
||||||
|
|
||||||
int direction = value < selectedIndex ? -1 : 1;
|
foregroundIcon.RotateTo(rotate_angle * direction, mod_switch_duration, mod_switch_easing);
|
||||||
bool beforeSelected = Selected;
|
backgroundIcon.RotateTo(-rotate_angle * direction, mod_switch_duration, mod_switch_easing);
|
||||||
|
|
||||||
Mod modBefore = SelectedMod ?? Mods[0];
|
backgroundIcon.Icon = modAfter.Icon;
|
||||||
|
using (BeginDelayedSequence(mod_switch_duration, true))
|
||||||
if (value >= Mods.Length)
|
|
||||||
selectedIndex = -1;
|
|
||||||
else if (value < -1)
|
|
||||||
selectedIndex = Mods.Length - 1;
|
|
||||||
else
|
|
||||||
selectedIndex = value;
|
|
||||||
|
|
||||||
Mod modAfter = SelectedMod ?? Mods[0];
|
|
||||||
|
|
||||||
if (beforeSelected != Selected)
|
|
||||||
{
|
{
|
||||||
iconsContainer.RotateTo(Selected ? 5f : 0f, 300, Easing.OutElastic);
|
foregroundIcon
|
||||||
iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, Easing.OutElastic);
|
.RotateTo(-rotate_angle * direction)
|
||||||
|
.RotateTo(0f, mod_switch_duration, mod_switch_easing);
|
||||||
|
|
||||||
|
backgroundIcon
|
||||||
|
.RotateTo(rotate_angle * direction)
|
||||||
|
.RotateTo(0f, mod_switch_duration, mod_switch_easing);
|
||||||
|
|
||||||
|
Schedule(() => displayMod(modAfter));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modBefore != modAfter)
|
|
||||||
{
|
|
||||||
const float rotate_angle = 16;
|
|
||||||
|
|
||||||
foregroundIcon.RotateTo(rotate_angle * direction, mod_switch_duration, mod_switch_easing);
|
|
||||||
backgroundIcon.RotateTo(-rotate_angle * direction, mod_switch_duration, mod_switch_easing);
|
|
||||||
|
|
||||||
backgroundIcon.Icon = modAfter.Icon;
|
|
||||||
using (BeginDelayedSequence(mod_switch_duration, true))
|
|
||||||
{
|
|
||||||
foregroundIcon
|
|
||||||
.RotateTo(-rotate_angle * direction)
|
|
||||||
.RotateTo(0f, mod_switch_duration, mod_switch_easing);
|
|
||||||
|
|
||||||
backgroundIcon
|
|
||||||
.RotateTo(rotate_angle * direction)
|
|
||||||
.RotateTo(0f, mod_switch_duration, mod_switch_easing);
|
|
||||||
|
|
||||||
Schedule(() => displayMod(modAfter));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foregroundIcon.Highlighted = Selected;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foregroundIcon.Highlighted = Selected;
|
||||||
|
|
||||||
|
(selectedIndex == -1 ? sampleOff : sampleOn).Play();
|
||||||
|
SelectionChanged?.Invoke(SelectedMod);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Selected => SelectedIndex != -1;
|
public bool Selected => selectedIndex != -1;
|
||||||
|
|
||||||
private Color4 selectedColour;
|
private Color4 selectedColour;
|
||||||
|
|
||||||
public Color4 SelectedColour
|
public Color4 SelectedColour
|
||||||
{
|
{
|
||||||
get
|
get { return selectedColour; }
|
||||||
{
|
|
||||||
return selectedColour;
|
|
||||||
}
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value == selectedColour) return;
|
if (value == selectedColour) return;
|
||||||
@ -116,12 +121,10 @@ namespace osu.Game.Overlays.Mods
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Mod mod;
|
private Mod mod;
|
||||||
|
|
||||||
public Mod Mod
|
public Mod Mod
|
||||||
{
|
{
|
||||||
get
|
get { return mod; }
|
||||||
{
|
|
||||||
return mod;
|
|
||||||
}
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
mod = value;
|
mod = value;
|
||||||
@ -147,9 +150,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
public Mod[] Mods { get; private set; }
|
public Mod[] Mods { get; private set; }
|
||||||
|
|
||||||
// the mods from Mod, only multiple if Mod is a MultiMod
|
public virtual Mod SelectedMod => Mods.ElementAtOrDefault(selectedIndex);
|
||||||
|
|
||||||
public virtual Mod SelectedMod => Mods.ElementAtOrDefault(SelectedIndex);
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio)
|
private void load(AudioManager audio)
|
||||||
@ -163,31 +164,42 @@ namespace osu.Game.Overlays.Mods
|
|||||||
switch (args.Button)
|
switch (args.Button)
|
||||||
{
|
{
|
||||||
case MouseButton.Left:
|
case MouseButton.Left:
|
||||||
SelectNext();
|
SelectNext(1);
|
||||||
break;
|
break;
|
||||||
case MouseButton.Right:
|
case MouseButton.Right:
|
||||||
SelectPrevious();
|
SelectNext(-1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectNext()
|
/// <summary>
|
||||||
|
/// Select the next available mod in a specified direction.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="direction">1 for forwards, -1 for backwards.</param>
|
||||||
|
public void SelectNext(int direction)
|
||||||
{
|
{
|
||||||
(++SelectedIndex == Mods.Length ? sampleOff : sampleOn).Play();
|
int start = selectedIndex + direction;
|
||||||
Action?.Invoke(SelectedMod);
|
// wrap around if we are at an extremity.
|
||||||
|
if (start >= Mods.Length)
|
||||||
|
start = -1;
|
||||||
|
else if (start < -1)
|
||||||
|
start = Mods.Length - 1;
|
||||||
|
|
||||||
|
for (int i = start; i < Mods.Length && i >= 0; i += direction)
|
||||||
|
{
|
||||||
|
if (Mods[i].HasImplementation)
|
||||||
|
{
|
||||||
|
changeSelectedIndex(i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Deselect();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectPrevious()
|
public void Deselect() => changeSelectedIndex(-1);
|
||||||
{
|
|
||||||
(--SelectedIndex == -1 ? sampleOff : sampleOn).Play();
|
|
||||||
Action?.Invoke(SelectedMod);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Deselect()
|
|
||||||
{
|
|
||||||
SelectedIndex = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayMod(Mod mod)
|
private void displayMod(Mod mod)
|
||||||
{
|
{
|
||||||
@ -195,6 +207,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
backgroundIcon.Icon = foregroundIcon.Icon;
|
backgroundIcon.Icon = foregroundIcon.Icon;
|
||||||
foregroundIcon.Icon = mod.Icon;
|
foregroundIcon.Icon = mod.Icon;
|
||||||
text.Text = mod.Name;
|
text.Text = mod.Name;
|
||||||
|
Colour = mod.HasImplementation ? Color4.White : Color4.Gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createIcons()
|
private void createIcons()
|
||||||
@ -264,7 +277,8 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
public override string TooltipText => null;
|
public override string TooltipText => null;
|
||||||
|
|
||||||
public PassThroughTooltipModIcon(Mod mod) : base(mod)
|
public PassThroughTooltipModIcon(Mod mod)
|
||||||
|
: base(mod)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
return new ModButton(m)
|
return new ModButton(m)
|
||||||
{
|
{
|
||||||
SelectedColour = selectedColour,
|
SelectedColour = selectedColour,
|
||||||
Action = Action,
|
SelectionChanged = Action,
|
||||||
};
|
};
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
|
|
||||||
@ -83,26 +83,33 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
var index = Array.IndexOf(ToggleKeys, args.Key);
|
var index = Array.IndexOf(ToggleKeys, args.Key);
|
||||||
if (index > -1 && index < buttons.Length)
|
if (index > -1 && index < buttons.Length)
|
||||||
buttons[index].SelectNext();
|
buttons[index].SelectNext(state.Keyboard.ShiftPressed ? -1 : 1);
|
||||||
|
|
||||||
return base.OnKeyDown(state, args);
|
return base.OnKeyDown(state, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeselectAll()
|
public void DeselectAll() => DeselectTypes(buttons.Select(b => b.SelectedMod?.GetType()).Where(t => t != null));
|
||||||
{
|
|
||||||
foreach (ModButton button in buttons)
|
|
||||||
button.Deselect();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeselectTypes(Type[] modTypes)
|
/// <summary>
|
||||||
|
/// Deselect one or more mods in this section.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="modTypes">The types of <see cref="Mod"/>s which should be deselected.</param>
|
||||||
|
/// <param name="immediate">Set to true to bypass animations and update selections immediately.</param>
|
||||||
|
public void DeselectTypes(IEnumerable<Type> modTypes, bool immediate = false)
|
||||||
{
|
{
|
||||||
|
int delay = 0;
|
||||||
foreach (var button in buttons)
|
foreach (var button in buttons)
|
||||||
{
|
{
|
||||||
Mod selected = button.SelectedMod;
|
Mod selected = button.SelectedMod;
|
||||||
if (selected == null) continue;
|
if (selected == null) continue;
|
||||||
foreach (Type type in modTypes)
|
foreach (Type type in modTypes)
|
||||||
if (type.IsInstanceOfType(selected))
|
if (type.IsInstanceOfType(selected))
|
||||||
button.Deselect();
|
{
|
||||||
|
if (immediate)
|
||||||
|
button.Deselect();
|
||||||
|
else
|
||||||
|
Scheduler.AddDelayed(() => button.Deselect(), delay += 50);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,17 +100,22 @@ namespace osu.Game.Overlays.Mods
|
|||||||
refreshSelectedMods();
|
refreshSelectedMods();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeselectTypes(Type[] modTypes)
|
/// <summary>
|
||||||
|
/// Deselect one or more mods.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="modTypes">The types of <see cref="Mod"/>s which should be deselected.</param>
|
||||||
|
/// <param name="immediate">Set to true to bypass animations and update selections immediately.</param>
|
||||||
|
public void DeselectTypes(Type[] modTypes, bool immediate = false)
|
||||||
{
|
{
|
||||||
if (modTypes.Length == 0) return;
|
if (modTypes.Length == 0) return;
|
||||||
foreach (ModSection section in ModSectionsContainer.Children)
|
foreach (ModSection section in ModSectionsContainer.Children)
|
||||||
section.DeselectTypes(modTypes);
|
section.DeselectTypes(modTypes, immediate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void modButtonPressed(Mod selectedMod)
|
private void modButtonPressed(Mod selectedMod)
|
||||||
{
|
{
|
||||||
if (selectedMod != null)
|
if (selectedMod != null)
|
||||||
DeselectTypes(selectedMod.IncompatibleMods);
|
DeselectTypes(selectedMod.IncompatibleMods, true);
|
||||||
refreshSelectedMods();
|
refreshSelectedMods();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,10 +132,6 @@ namespace osu.Game.Overlays.Mods
|
|||||||
ranked &= mod.Ranked;
|
ranked &= mod.Ranked;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1.00x
|
|
||||||
// 1.05x
|
|
||||||
// 1.20x
|
|
||||||
|
|
||||||
MultiplierLabel.Text = $"{multiplier:N2}x";
|
MultiplierLabel.Text = $"{multiplier:N2}x";
|
||||||
if (!ranked)
|
if (!ranked)
|
||||||
MultiplierLabel.Text += " (Unranked)";
|
MultiplierLabel.Text += " (Unranked)";
|
||||||
|
16
osu.Game/Rulesets/Mods/IApplicableFailOverride.cs
Normal file
16
osu.Game/Rulesets/Mods/IApplicableFailOverride.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mods
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a mod which can override (and block) a fail.
|
||||||
|
/// </summary>
|
||||||
|
public interface IApplicableFailOverride : IApplicableMod
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Whether we should allow failing at the current point in time.
|
||||||
|
/// </summary>
|
||||||
|
bool AllowFail { get; }
|
||||||
|
}
|
||||||
|
}
|
13
osu.Game/Rulesets/Mods/IApplicableMod.cs
Normal file
13
osu.Game/Rulesets/Mods/IApplicableMod.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mods
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The base interface for a mod which can be applied in some way.
|
||||||
|
/// If this is not implemented by a mod, it will not be available for use in-game.
|
||||||
|
/// </summary>
|
||||||
|
public interface IApplicableMod
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -8,8 +8,8 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// An interface for mods that make adjustments to the track.
|
/// An interface for mods that make adjustments to the track.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IApplicableToClock
|
public interface IApplicableToClock : IApplicableMod
|
||||||
{
|
{
|
||||||
void ApplyToClock(IAdjustableClock clock);
|
void ApplyToClock(IAdjustableClock clock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,8 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// An interface for mods that make general adjustments to difficulty.
|
/// An interface for mods that make general adjustments to difficulty.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IApplicableToDifficulty
|
public interface IApplicableToDifficulty : IApplicableMod
|
||||||
{
|
{
|
||||||
void ApplyToDifficulty(BeatmapDifficulty difficulty);
|
void ApplyToDifficulty(BeatmapDifficulty difficulty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// An interface for <see cref="Mod"/>s that can be applied to <see cref="DrawableHitObject"/>s.
|
/// An interface for <see cref="Mod"/>s that can be applied to <see cref="DrawableHitObject"/>s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IApplicableToDrawableHitObjects
|
public interface IApplicableToDrawableHitObjects : IApplicableMod
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Applies this <see cref="IApplicableToDrawableHitObjects"/> to a list of <see cref="DrawableHitObject"/>s.
|
/// Applies this <see cref="IApplicableToDrawableHitObjects"/> to a list of <see cref="DrawableHitObject"/>s.
|
||||||
|
@ -8,7 +8,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// An interface for <see cref="Mod"/>s that can be applied to <see cref="HitObject"/>s.
|
/// An interface for <see cref="Mod"/>s that can be applied to <see cref="HitObject"/>s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IApplicableToHitObject<in TObject>
|
public interface IApplicableToHitObject<in TObject> : IApplicableMod
|
||||||
where TObject : HitObject
|
where TObject : HitObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// An interface for <see cref="Mod"/>s that can be applied to <see cref="RulesetContainer"/>s.
|
/// An interface for <see cref="Mod"/>s that can be applied to <see cref="RulesetContainer"/>s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IApplicableToRulesetContainer<TObject>
|
public interface IApplicableToRulesetContainer<TObject> : IApplicableMod
|
||||||
where TObject : HitObject
|
where TObject : HitObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -8,7 +8,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// An interface for mods that make general adjustments to score processor.
|
/// An interface for mods that make general adjustments to score processor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IApplicableToScoreProcessor
|
public interface IApplicableToScoreProcessor : IApplicableMod
|
||||||
{
|
{
|
||||||
void ApplyToScoreProcessor(ScoreProcessor scoreProcessor);
|
void ApplyToScoreProcessor(ScoreProcessor scoreProcessor);
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,11 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract double ScoreMultiplier { get; }
|
public abstract double ScoreMultiplier { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if this mod is implemented (and playable).
|
||||||
|
/// </summary>
|
||||||
|
public virtual bool HasImplementation => this is IApplicableMod;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns if this mod is ranked.
|
/// Returns if this mod is ranked.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -50,10 +55,5 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
/// The mods this mod cannot be enabled with.
|
/// The mods this mod cannot be enabled with.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual Type[] IncompatibleMods => new Type[] { };
|
public virtual Type[] IncompatibleMods => new Type[] { };
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether we should allow failing at the current point in time.
|
|
||||||
/// </summary>
|
|
||||||
public virtual bool AllowFail => true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ModAutoplay : Mod
|
public class ModAutoplay : Mod, IApplicableFailOverride
|
||||||
{
|
{
|
||||||
public override string Name => "Autoplay";
|
public override string Name => "Autoplay";
|
||||||
public override string ShortenedName => "AT";
|
public override string ShortenedName => "AT";
|
||||||
@ -29,6 +29,6 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
public override string Description => "Watch a perfect automated play through the song";
|
public override string Description => "Watch a perfect automated play through the song";
|
||||||
public override double ScoreMultiplier => 0;
|
public override double ScoreMultiplier => 0;
|
||||||
public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail) };
|
public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail) };
|
||||||
public override bool AllowFail => false;
|
public bool AllowFail => false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ using osu.Game.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mods
|
namespace osu.Game.Rulesets.Mods
|
||||||
{
|
{
|
||||||
public abstract class ModNoFail : Mod
|
public abstract class ModNoFail : Mod, IApplicableFailOverride
|
||||||
{
|
{
|
||||||
public override string Name => "NoFail";
|
public override string Name => "NoFail";
|
||||||
public override string ShortenedName => "NF";
|
public override string ShortenedName => "NF";
|
||||||
@ -20,6 +20,6 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// We never fail, 'yo.
|
/// We never fail, 'yo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override bool AllowFail => false;
|
public bool AllowFail => false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Graphics.Backgrounds;
|
using osu.Game.Graphics.Backgrounds;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Backgrounds
|
namespace osu.Game.Screens.Backgrounds
|
||||||
@ -24,16 +25,22 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
|
|
||||||
private void display(Background newBackground)
|
private void display(Background newBackground)
|
||||||
{
|
{
|
||||||
current?.FadeOut(800, Easing.OutQuint);
|
current?.FadeOut(800, Easing.InOutSine);
|
||||||
current?.Expire();
|
current?.Expire();
|
||||||
|
|
||||||
Add(current = newBackground);
|
Add(current = newBackground);
|
||||||
|
currentDisplay++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ScheduledDelegate nextTask;
|
||||||
|
|
||||||
public void Next()
|
public void Next()
|
||||||
{
|
{
|
||||||
currentDisplay++;
|
nextTask?.Cancel();
|
||||||
LoadComponentAsync(new Background(backgroundName) { Depth = currentDisplay }, display);
|
nextTask = Scheduler.AddDelayed(() =>
|
||||||
|
{
|
||||||
|
LoadComponentAsync(new Background(backgroundName) { Depth = currentDisplay }, display);
|
||||||
|
}, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private bool onFail()
|
private bool onFail()
|
||||||
{
|
{
|
||||||
if (Beatmap.Value.Mods.Value.Any(m => !m.AllowFail))
|
if (Beatmap.Value.Mods.Value.OfType<IApplicableFailOverride>().Any(m => !m.AllowFail))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
decoupledClock.Stop();
|
decoupledClock.Stop();
|
||||||
|
@ -267,6 +267,7 @@
|
|||||||
<Compile Include="Beatmaps\Formats\LegacyStoryboardDecoder.cs" />
|
<Compile Include="Beatmaps\Formats\LegacyStoryboardDecoder.cs" />
|
||||||
<Compile Include="Database\DatabaseContextFactory.cs" />
|
<Compile Include="Database\DatabaseContextFactory.cs" />
|
||||||
<Compile Include="Database\IHasPrimaryKey.cs" />
|
<Compile Include="Database\IHasPrimaryKey.cs" />
|
||||||
|
<Compile Include="Graphics\Textures\LargeTextureStore.cs" />
|
||||||
<Compile Include="Overlays\Profile\SupporterIcon.cs" />
|
<Compile Include="Overlays\Profile\SupporterIcon.cs" />
|
||||||
<Compile Include="Overlays\Settings\DangerousSettingsButton.cs" />
|
<Compile Include="Overlays\Settings\DangerousSettingsButton.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\HoverClickSounds.cs" />
|
<Compile Include="Graphics\UserInterface\HoverClickSounds.cs" />
|
||||||
@ -310,6 +311,8 @@
|
|||||||
<Compile Include="Overlays\Profile\Sections\Ranks\DrawableTotalScore.cs" />
|
<Compile Include="Overlays\Profile\Sections\Ranks\DrawableTotalScore.cs" />
|
||||||
<Compile Include="Overlays\Profile\Sections\Ranks\ScoreModsContainer.cs" />
|
<Compile Include="Overlays\Profile\Sections\Ranks\ScoreModsContainer.cs" />
|
||||||
<Compile Include="Overlays\Settings\Sections\Maintenance\DeleteAllBeatmapsDialog.cs" />
|
<Compile Include="Overlays\Settings\Sections\Maintenance\DeleteAllBeatmapsDialog.cs" />
|
||||||
|
<Compile Include="Rulesets\Mods\IApplicableFailOverride.cs" />
|
||||||
|
<Compile Include="Rulesets\Mods\IApplicableMod.cs" />
|
||||||
<Compile Include="Rulesets\Mods\IApplicableToDrawableHitObject.cs" />
|
<Compile Include="Rulesets\Mods\IApplicableToDrawableHitObject.cs" />
|
||||||
<Compile Include="Screens\Select\ImportFromStablePopup.cs" />
|
<Compile Include="Screens\Select\ImportFromStablePopup.cs" />
|
||||||
<Compile Include="Overlays\Settings\SettingsButton.cs" />
|
<Compile Include="Overlays\Settings\SettingsButton.cs" />
|
||||||
|
Reference in New Issue
Block a user