1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 13:22:55 +08:00

Merge branch 'master' into metadata

This commit is contained in:
Dean Herbert 2017-05-11 12:23:00 +09:00 committed by GitHub
commit 70ef503403
71 changed files with 638 additions and 462 deletions

40
.vscode/launch.json vendored
View File

@ -2,46 +2,60 @@
"version": "0.2.0",
"configurations": [
{
"name": "Launch VisualTests",
"name": "VisualTests (debug)",
"windows": {
"type": "clr"
},
"type": "mono",
"request": "launch",
"program": "${workspaceRoot}/osu.Desktop.VisualTests/bin/Debug/osu!.exe",
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": "build",
"preLaunchTask": "Build (Debug)",
"runtimeExecutable": null,
"env": {},
"console": "internalConsole"
},
{
"name": "Launch Desktop",
"name": "VisualTests (release)",
"windows": {
"type": "clr"
},
"type": "mono",
"request": "launch",
"program": "${workspaceRoot}/osu.Desktop.VisualTests/bin/Release/osu!.exe",
"cwd": "${workspaceRoot}",
"preLaunchTask": "Build (Release)",
"runtimeExecutable": null,
"env": {},
"console": "internalConsole"
},
{
"name": "osu! (debug)",
"windows": {
"type": "clr"
},
"type": "mono",
"request": "launch",
"program": "${workspaceRoot}/osu.Desktop/bin/Debug/osu!.exe",
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": "build",
"preLaunchTask": "Build (Debug)",
"runtimeExecutable": null,
"env": {},
"console": "internalConsole"
},
{
"name": "Attach",
"name": "osu! (release)",
"windows": {
"type": "clr",
"request": "attach",
"processName": "osu!"
"type": "clr"
},
"type": "mono",
"request": "attach",
"address": "localhost",
"port": 55555
"request": "launch",
"program": "${workspaceRoot}/osu.Desktop/bin/Release/osu!.exe",
"cwd": "${workspaceRoot}",
"preLaunchTask": "Build (Release)",
"runtimeExecutable": null,
"env": {},
"console": "internalConsole"
}
]
}

77
.vscode/tasks.json vendored
View File

@ -1,51 +1,50 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"taskSelector": "/t:",
"version": "2.0.0",
"problemMatcher": "$msCompile",
"isShellCommand": true,
"command": "msbuild",
"suppressTaskName": true,
"showOutput": "silent",
"args": [
"/property:GenerateFullPaths=true",
"/property:DebugType=portable"
],
"windows": {
"args": [
"/property:GenerateFullPaths=true",
"/property:DebugType=portable",
"/m" //parallel compiling support. doesn't work well with mono atm
]
},
"tasks": [
{
"taskName": "build",
"isShellCommand": true,
"showOutput": "silent",
"command": "msbuild",
"args": [
"/property:GenerateFullPaths=true",
"/property:DebugType=portable"
],
"windows": {
"args": [
"/property:GenerateFullPaths=true",
"/property:DebugType=portable",
"/m" //parallel compiling support. doesn't work well with mono atm
]
},
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$msCompile",
"taskName": "Build (Debug)",
"isBuildCommand": true
},
{
"taskName": "rebuild",
"isShellCommand": true,
"showOutput": "silent",
"command": "msbuild",
"taskName": "Build (Release)",
"args": [
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true",
"/property:DebugType=portable",
"/target:Clean,Build"
],
"windows": {
"args": [
"/property:GenerateFullPaths=true",
"/property:DebugType=portable",
"/target:Clean,Build",
"/m" //parallel compiling support. doesn't work well with mono atm
]
},
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$msCompile",
"isBuildCommand": true
"/property:Configuration=Release"
]
},
{
"taskName": "Clean All",
"dependsOn": ["Clean (Debug)", "Clean (Release)"]
},
{
"taskName": "Clean (Debug)",
"args": [
"/target:Clean"
]
},
{
"taskName": "Clean (Release)",
"args": [
"/target:Clean",
"/property:Configuration=Release"
]
}
]
}

@ -1 +1 @@
Subproject commit cebdfb1bbb260e5aaca0a01e06d7128b3d1faae4
Subproject commit 1c95c94fab6852620cd82eb0899ca0132ac82667

View File

@ -6,16 +6,21 @@ using osu.Framework.Graphics;
using osu.Game.Overlays.Mods;
using osu.Framework.Testing;
using osu.Game.Database;
using osu.Game.Screens.Play.HUD;
using OpenTK;
namespace osu.Desktop.VisualTests.Tests
{
internal class TestCaseModSelectOverlay : TestCase
internal class TestCaseMods : TestCase
{
public override string Description => @"Tests the mod select overlay";
public override string Description => @"Mod select overlay and in-game display";
private ModSelectOverlay modSelect;
private ModDisplay modDisplay;
private RulesetDatabase rulesets;
[BackgroundDependencyLoader]
private void load(RulesetDatabase rulesets)
{
@ -33,6 +38,16 @@ namespace osu.Desktop.VisualTests.Tests
Anchor = Anchor.BottomCentre,
});
Add(modDisplay = new ModDisplay
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
AutoSizeAxes = Axes.Both,
Position = new Vector2(0, 25),
});
modDisplay.Current.BindTo(modSelect.SelectedMods);
AddStep("Toggle", modSelect.ToggleVisibility);
foreach (var ruleset in rulesets.AllRulesets)

View File

@ -8,7 +8,7 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.MathUtils;
using osu.Framework.Testing;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Play.HUD;
namespace osu.Desktop.VisualTests.Tests
{

View File

@ -212,7 +212,7 @@
<Compile Include="Platform\TestStorage.cs" />
<Compile Include="Tests\TestCaseOptions.cs" />
<Compile Include="Tests\TestCaseSongProgress.cs" />
<Compile Include="Tests\TestCaseModSelectOverlay.cs" />
<Compile Include="Tests\TestCaseMods.cs" />
<Compile Include="Tests\TestCaseDialogOverlay.cs" />
<Compile Include="Tests\TestCaseBeatmapOptionsOverlay.cs" />
<Compile Include="Tests\TestCaseLeaderboard.cs" />

View File

@ -14,7 +14,7 @@ namespace osu.Desktop.Beatmaps.IO
{
public static void Register() => AddReader<LegacyFilesystemReader>((storage, path) => Directory.Exists(path));
private string basePath { get; }
private readonly string basePath;
public LegacyFilesystemReader(string path)
{

View File

@ -64,6 +64,7 @@ namespace osu.Game.Rulesets.Mania.Mods
{
public override string Name => "FadeIn";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_hidden;
public override ModType Type => ModType.DifficultyIncrease;
public override double ScoreMultiplier => 1;
public override bool Ranked => true;
public override Type[] IncompatibleMods => new[] { typeof(ModFlashlight) };

View File

@ -58,8 +58,8 @@ namespace osu.Game.Rulesets.Osu.Replays
{
public int Compare(ReplayFrame f1, ReplayFrame f2)
{
if (f1 == null) throw new NullReferenceException($@"{nameof(f1)} cannot be null");
if (f2 == null) throw new NullReferenceException($@"{nameof(f2)} cannot be null");
if (f1 == null) throw new ArgumentNullException(nameof(f1));
if (f2 == null) throw new ArgumentNullException(nameof(f2));
return f1.Time.CompareTo(f2.Time);
}

View File

@ -44,7 +44,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
protected override Beatmap<TaikoHitObject> ConvertBeatmap(Beatmap original)
{
// Rewrite the beatmap info to add the slider velocity multiplier
BeatmapInfo info = original.BeatmapInfo.DeepClone<BeatmapInfo>();
BeatmapInfo info = original.BeatmapInfo.DeepClone();
info.Difficulty.SliderMultiplier *= legacy_velocity_multiplier;
Beatmap<TaikoHitObject> converted = base.ConvertBeatmap(original);

View File

@ -109,7 +109,7 @@ namespace osu.Game.Rulesets.Taiko.Replays
Frames.Add(new ReplayFrame(h.StartTime, null, null, button));
}
else
throw new Exception("Unknown hit object type.");
throw new InvalidOperationException("Unknown hit object type.");
Frames.Add(new ReplayFrame(endTime + KEY_UP_DELAY, null, null, ReplayButtonState.None));

View File

@ -11,9 +11,8 @@ namespace osu.Game.Audio
{
}
public SampleInfoList(IEnumerable<SampleInfo> elements)
public SampleInfoList(IEnumerable<SampleInfo> elements) : base(elements)
{
AddRange(elements);
}
}
}

View File

@ -11,7 +11,7 @@ namespace osu.Game.Beatmaps.Formats
{
public abstract class BeatmapDecoder
{
private static Dictionary<string, Type> decoders { get; } = new Dictionary<string, Type>();
private static readonly Dictionary<string, Type> decoders = new Dictionary<string, Type>();
public static BeatmapDecoder GetDecoder(StreamReader stream)
{

View File

@ -13,11 +13,11 @@ namespace osu.Game.Beatmaps.IO
{
private class Reader
{
public Func<Storage, string, bool> Test { get; set; }
public Type Type { get; set; }
public Func<Storage, string, bool> Test;
public Type Type;
}
private static List<Reader> readers { get; } = new List<Reader>();
private static readonly List<Reader> readers = new List<Reader>();
public static ArchiveReader GetReader(Storage storage, string path)
{
@ -58,11 +58,9 @@ namespace osu.Game.Beatmaps.IO
if (input == null)
return null;
using (MemoryStream ms = new MemoryStream())
{
input.CopyTo(ms);
return ms.ToArray();
}
byte[] buffer = new byte[input.Length];
input.Read(buffer, 0, buffer.Length);
return buffer;
}
}
}

View File

@ -94,13 +94,13 @@ namespace osu.Game.Database
{
byte[] properties = new byte[5];
if (replayInStream.Read(properties, 0, 5) != 5)
throw new Exception("input .lzma is too short");
throw new IOException("input .lzma is too short");
long outSize = 0;
for (int i = 0; i < 8; i++)
{
int v = replayInStream.ReadByte();
if (v < 0)
throw new Exception("Can't Read 1");
throw new IOException("Can't Read 1");
outSize |= (long)(byte)v << (8 * i);
}

View File

@ -14,6 +14,7 @@ using OpenTK.Graphics.ES30;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Colour;
using osu.Framework.Timing;
using System.Diagnostics;
namespace osu.Game.Graphics.Cursor
{
@ -39,6 +40,8 @@ namespace osu.Game.Graphics.Cursor
private Vector2? lastPosition;
private readonly InputResampler resampler = new InputResampler();
protected override DrawNode CreateDrawNode() => new TrailDrawNode();
protected override void ApplyDrawNode(DrawNode node)
@ -75,7 +78,7 @@ namespace osu.Game.Graphics.Cursor
[BackgroundDependencyLoader]
private void load(ShaderManager shaders, TextureStore textures)
{
shader = shaders?.Load(@"CursorTrail", FragmentShaderDescriptor.Texture);
shader = shaders?.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE);
texture = textures.Get(@"Cursor/cursortrail");
Scale = new Vector2(1 / texture.ScaleAdjust);
}
@ -116,22 +119,26 @@ namespace osu.Game.Graphics.Cursor
if (lastPosition == null)
{
lastPosition = state.Mouse.NativeState.Position;
resampler.AddPosition(lastPosition.Value);
return base.OnMouseMove(state);
}
Vector2 pos1 = lastPosition.Value;
Vector2 pos2 = state.Mouse.NativeState.Position;
Vector2 diff = pos2 - pos1;
float distance = diff.Length;
Vector2 direction = diff / distance;
float interval = size.X / 2 * 0.9f;
for (float d = interval; d < distance; d += interval)
foreach (Vector2 pos2 in resampler.AddPosition(state.Mouse.NativeState.Position))
{
lastPosition = pos1 + direction * d;
addPosition(lastPosition.Value);
Trace.Assert(lastPosition.HasValue);
Vector2 pos1 = lastPosition.Value;
Vector2 diff = pos2 - pos1;
float distance = diff.Length;
Vector2 direction = diff / distance;
float interval = size.X / 2 * 0.9f;
for (float d = interval; d < distance; d += interval)
{
lastPosition = pos1 + direction * d;
addPosition(lastPosition.Value);
}
}
return base.OnMouseMove(state);

View File

@ -16,7 +16,7 @@ namespace osu.Game.Graphics
switch (hex.Length)
{
default:
throw new Exception(@"Invalid hex string length!");
throw new ArgumentException(@"Invalid hex string length!");
case 3:
return new Color4(
(byte)(Convert.ToByte(hex.Substring(0, 1), 16) * 17),
@ -33,57 +33,57 @@ namespace osu.Game.Graphics
}
// See https://github.com/ppy/osu-web/blob/master/resources/assets/less/colors.less
public Color4 PurpleLighter = FromHex(@"eeeeff");
public Color4 PurpleLight = FromHex(@"aa88ff");
public Color4 Purple = FromHex(@"8866ee");
public Color4 PurpleDark = FromHex(@"6644cc");
public Color4 PurpleDarker = FromHex(@"441188");
public readonly Color4 PurpleLighter = FromHex(@"eeeeff");
public readonly Color4 PurpleLight = FromHex(@"aa88ff");
public readonly Color4 Purple = FromHex(@"8866ee");
public readonly Color4 PurpleDark = FromHex(@"6644cc");
public readonly Color4 PurpleDarker = FromHex(@"441188");
public Color4 PinkLighter = FromHex(@"ffddee");
public Color4 PinkLight = FromHex(@"ff99cc");
public Color4 Pink = FromHex(@"ff66aa");
public Color4 PinkDark = FromHex(@"cc5288");
public Color4 PinkDarker = FromHex(@"bb1177");
public readonly Color4 PinkLighter = FromHex(@"ffddee");
public readonly Color4 PinkLight = FromHex(@"ff99cc");
public readonly Color4 Pink = FromHex(@"ff66aa");
public readonly Color4 PinkDark = FromHex(@"cc5288");
public readonly Color4 PinkDarker = FromHex(@"bb1177");
public Color4 BlueLighter = FromHex(@"ddffff");
public Color4 BlueLight = FromHex(@"99eeff");
public Color4 Blue = FromHex(@"66ccff");
public Color4 BlueDark = FromHex(@"44aadd");
public Color4 BlueDarker = FromHex(@"2299bb");
public readonly Color4 BlueLighter = FromHex(@"ddffff");
public readonly Color4 BlueLight = FromHex(@"99eeff");
public readonly Color4 Blue = FromHex(@"66ccff");
public readonly Color4 BlueDark = FromHex(@"44aadd");
public readonly Color4 BlueDarker = FromHex(@"2299bb");
public Color4 YellowLighter = FromHex(@"ffffdd");
public Color4 YellowLight = FromHex(@"ffdd55");
public Color4 Yellow = FromHex(@"ffcc22");
public Color4 YellowDark = FromHex(@"eeaa00");
public Color4 YellowDarker = FromHex(@"cc6600");
public readonly Color4 YellowLighter = FromHex(@"ffffdd");
public readonly Color4 YellowLight = FromHex(@"ffdd55");
public readonly Color4 Yellow = FromHex(@"ffcc22");
public readonly Color4 YellowDark = FromHex(@"eeaa00");
public readonly Color4 YellowDarker = FromHex(@"cc6600");
public Color4 GreenLighter = FromHex(@"eeffcc");
public Color4 GreenLight = FromHex(@"b3d944");
public Color4 Green = FromHex(@"88b300");
public Color4 GreenDark = FromHex(@"668800");
public Color4 GreenDarker = FromHex(@"445500");
public readonly Color4 GreenLighter = FromHex(@"eeffcc");
public readonly Color4 GreenLight = FromHex(@"b3d944");
public readonly Color4 Green = FromHex(@"88b300");
public readonly Color4 GreenDark = FromHex(@"668800");
public readonly Color4 GreenDarker = FromHex(@"445500");
public Color4 Gray0 = FromHex(@"000");
public Color4 Gray1 = FromHex(@"111");
public Color4 Gray2 = FromHex(@"222");
public Color4 Gray3 = FromHex(@"333");
public Color4 Gray4 = FromHex(@"444");
public Color4 Gray5 = FromHex(@"555");
public Color4 Gray6 = FromHex(@"666");
public Color4 Gray7 = FromHex(@"777");
public Color4 Gray8 = FromHex(@"888");
public Color4 Gray9 = FromHex(@"999");
public Color4 GrayA = FromHex(@"aaa");
public Color4 GrayB = FromHex(@"bbb");
public Color4 GrayC = FromHex(@"ccc");
public Color4 GrayD = FromHex(@"ddd");
public Color4 GrayE = FromHex(@"eee");
public Color4 GrayF = FromHex(@"fff");
public readonly Color4 Gray0 = FromHex(@"000");
public readonly Color4 Gray1 = FromHex(@"111");
public readonly Color4 Gray2 = FromHex(@"222");
public readonly Color4 Gray3 = FromHex(@"333");
public readonly Color4 Gray4 = FromHex(@"444");
public readonly Color4 Gray5 = FromHex(@"555");
public readonly Color4 Gray6 = FromHex(@"666");
public readonly Color4 Gray7 = FromHex(@"777");
public readonly Color4 Gray8 = FromHex(@"888");
public readonly Color4 Gray9 = FromHex(@"999");
public readonly Color4 GrayA = FromHex(@"aaa");
public readonly Color4 GrayB = FromHex(@"bbb");
public readonly Color4 GrayC = FromHex(@"ccc");
public readonly Color4 GrayD = FromHex(@"ddd");
public readonly Color4 GrayE = FromHex(@"eee");
public readonly Color4 GrayF = FromHex(@"fff");
public Color4 RedLighter = FromHex(@"ffeded");
public Color4 RedLight = FromHex(@"ed7787");
public Color4 Red = FromHex(@"ed1121");
public Color4 RedDark = FromHex(@"ba0011");
public Color4 RedDarker = FromHex(@"870000");
public readonly Color4 RedLighter = FromHex(@"ffeded");
public readonly Color4 RedLight = FromHex(@"ed7787");
public readonly Color4 Red = FromHex(@"ed1121");
public readonly Color4 RedDark = FromHex(@"ba0011");
public readonly Color4 RedDarker = FromHex(@"870000");
}
}

View File

@ -16,12 +16,13 @@ namespace osu.Game.IO.Serialization
return JsonConvert.SerializeObject(obj);
}
public static T Deserialize<T>(string objString)
public static T Deserialize<T>(this string objString)
{
return JsonConvert.DeserializeObject<T>(objString);
}
public static T DeepClone<T>(this IJsonSerializable obj)
public static T DeepClone<T>(this T obj)
where T : IJsonSerializable
{
return Deserialize<T>(Serialize(obj));
}

View File

@ -23,7 +23,7 @@ namespace osu.Game.Online.Chat
[JsonProperty(@"channel_id")]
public int Id;
public SortedList<Message> Messages = new SortedList<Message>((m1, m2) => m1.Id.CompareTo(m2.Id));
public readonly SortedList<Message> Messages = new SortedList<Message>((m1, m2) => m1.Id.CompareTo(m2.Id));
//internal bool Joined;

View File

@ -16,7 +16,6 @@ namespace osu.Game.Overlays.Mods
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
ButtonColour = colours.Blue;
SelectedColour = colours.BlueLight;
}

View File

@ -16,7 +16,6 @@ namespace osu.Game.Overlays.Mods
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
ButtonColour = colours.Yellow;
SelectedColour = colours.YellowLight;
}

View File

@ -16,7 +16,6 @@ namespace osu.Game.Overlays.Mods
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
ButtonColour = colours.Green;
SelectedColour = colours.GreenLight;
}

View File

@ -19,9 +19,13 @@ using System.Linq;
namespace osu.Game.Overlays.Mods
{
public class ModButton : FillFlowContainer
/// <summary>
/// Represents a clickable button which can cycle through one of more mods.
/// </summary>
public class ModButton : ModButtonEmpty
{
private ModIcon foregroundIcon { get; set; }
private ModIcon foregroundIcon;
private readonly SpriteText text;
private readonly Container<ModIcon> iconsContainer;
private SampleChannel sampleOn, sampleOff;
@ -51,7 +55,7 @@ namespace osu.Game.Overlays.Mods
iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic);
iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, EasingTypes.OutElastic);
foregroundIcon.Colour = Selected ? SelectedColour : ButtonColour;
foregroundIcon.Highlighted = Selected;
if (mod != null)
displayMod(SelectedMod ?? Mods[0]);
@ -60,23 +64,6 @@ namespace osu.Game.Overlays.Mods
public bool Selected => selectedIndex != -1;
private Color4 buttonColour;
public Color4 ButtonColour
{
get
{
return buttonColour;
}
set
{
if (value == buttonColour) return;
buttonColour = value;
foreach (ModIcon icon in iconsContainer.Children)
{
icon.Colour = value;
}
}
}
private Color4 selectedColour;
public Color4 SelectedColour
@ -127,7 +114,7 @@ namespace osu.Game.Overlays.Mods
// the mods from Mod, only multiple if Mod is a MultiMod
public Mod SelectedMod => Mods.ElementAtOrDefault(selectedIndex);
public override Mod SelectedMod => Mods.ElementAtOrDefault(selectedIndex);
[BackgroundDependencyLoader]
private void load(AudioManager audio)
@ -180,50 +167,35 @@ namespace osu.Game.Overlays.Mods
{
iconsContainer.Add(new[]
{
new ModIcon
new ModIcon(Mods[0])
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Position = new Vector2(1.5f),
Colour = ButtonColour
},
foregroundIcon = new ModIcon
foregroundIcon = new ModIcon(Mods[0])
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Position = new Vector2(-1.5f),
Colour = ButtonColour
},
});
}
else
{
iconsContainer.Add(foregroundIcon = new ModIcon
iconsContainer.Add(foregroundIcon = new ModIcon(Mod)
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Colour = ButtonColour
});
}
}
protected override void LoadComplete()
public ModButton(Mod mod)
{
base.LoadComplete();
foreach (ModIcon icon in iconsContainer.Children)
icon.Colour = ButtonColour;
}
public ModButton(Mod m)
{
Direction = FillDirection.Vertical;
Spacing = new Vector2(0f, -5f);
Size = new Vector2(100f);
AlwaysPresent = true;
Children = new Drawable[]
{
new Container
@ -243,13 +215,14 @@ namespace osu.Game.Overlays.Mods
},
text = new OsuSpriteText
{
Y = 75,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
TextSize = 18,
},
};
Mod = m;
Mod = mod;
}
}
}

View File

@ -0,0 +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 OpenTK;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Overlays.Mods
{
/// <summary>
/// A mod button used exclusively for providing an empty space the size of a mod button.
/// </summary>
public class ModButtonEmpty : Container
{
public virtual Mod SelectedMod => null;
public ModButtonEmpty()
{
Size = new Vector2(100f);
AlwaysPresent = true;
}
}
}

View File

@ -11,6 +11,8 @@ using osu.Framework.Input;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Mods;
using System;
using System.Linq;
using System.Collections.Generic;
namespace osu.Game.Overlays.Mods
{
@ -18,7 +20,7 @@ namespace osu.Game.Overlays.Mods
{
private readonly OsuSpriteText headerLabel;
public FillFlowContainer<ModButton> ButtonsContainer { get; }
public FillFlowContainer<ModButtonEmpty> ButtonsContainer { get; }
public Action<Mod> Action;
protected abstract Key[] ToggleKeys { get; }
@ -36,47 +38,30 @@ namespace osu.Game.Overlays.Mods
}
}
public IEnumerable<Mod> SelectedMods => buttons.Select(b => b.SelectedMod).Where(m => m != null);
public IEnumerable<Mod> Mods
{
set
{
var modContainers = value.Select(m =>
{
if (m == null)
return new ModButtonEmpty();
else
return new ModButton(m)
{
SelectedColour = selectedColour,
Action = Action,
};
}).ToArray();
ButtonsContainer.Children = modContainers;
buttons = modContainers.OfType<ModButton>().ToArray();
}
}
private ModButton[] buttons = { };
public ModButton[] Buttons
{
get
{
return buttons;
}
set
{
if (value == buttons) return;
buttons = value;
foreach (ModButton button in value)
{
button.ButtonColour = ButtonColour;
button.SelectedColour = selectedColour;
button.Action = Action;
}
ButtonsContainer.Children = value;
}
}
private Color4 buttonsBolour = Color4.White;
public Color4 ButtonColour
{
get
{
return buttonsBolour;
}
set
{
if (value == buttonsBolour) return;
buttonsBolour = value;
foreach (ModButton button in buttons)
{
button.ButtonColour = value;
}
}
}
private Color4 selectedColour = Color4.White;
public Color4 SelectedColour
@ -91,17 +76,15 @@ namespace osu.Game.Overlays.Mods
selectedColour = value;
foreach (ModButton button in buttons)
{
button.SelectedColour = value;
}
}
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
var index = Array.IndexOf(ToggleKeys, args.Key);
if (index > -1 && index < Buttons.Length)
Buttons[index].SelectNext();
if (index > -1 && index < buttons.Length)
buttons[index].SelectNext();
return base.OnKeyDown(state, args);
}
@ -109,8 +92,18 @@ namespace osu.Game.Overlays.Mods
public void DeselectAll()
{
foreach (ModButton button in buttons)
{
button.Deselect();
}
public void DeselectTypes(Type[] modTypes)
{
foreach (var button in buttons)
{
Mod selected = button.SelectedMod;
if (selected == null) continue;
foreach (Type type in modTypes)
if (type.IsInstanceOfType(selected))
button.Deselect();
}
}
@ -127,7 +120,7 @@ namespace osu.Game.Overlays.Mods
Position = new Vector2(0f, 0f),
Font = @"Exo2.0-Bold"
},
ButtonsContainer = new FillFlowContainer<ModButton>
ButtonsContainer = new FillFlowContainer<ModButtonEmpty>
{
AutoSizeAxes = Axes.Both,
Origin = Anchor.BottomLeft,

View File

@ -44,7 +44,7 @@ namespace osu.Game.Overlays.Mods
var instance = newRuleset.CreateInstance();
foreach (ModSection section in modSectionsContainer.Children)
section.Buttons = instance.GetModsFor(section.ModType).Select(m => new ModButton(m)).ToArray();
section.Mods = instance.GetModsFor(section.ModType);
refreshSelectedMods();
}
@ -103,14 +103,7 @@ namespace osu.Game.Overlays.Mods
{
if (modTypes.Length == 0) return;
foreach (ModSection section in modSectionsContainer.Children)
foreach (ModButton button in section.Buttons)
{
Mod selected = button.SelectedMod;
if (selected == null) continue;
foreach (Type type in modTypes)
if (type.IsInstanceOfType(selected))
button.Deselect();
}
section.DeselectTypes(modTypes);
}
private void modButtonPressed(Mod selectedMod)
@ -122,7 +115,7 @@ namespace osu.Game.Overlays.Mods
private void refreshSelectedMods()
{
SelectedMods.Value = modSectionsContainer.Children.SelectMany(s => s.Buttons.Select(x => x.SelectedMod).Where(x => x != null)).ToArray();
SelectedMods.Value = modSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray();
double multiplier = 1.0;
bool ranked = true;

View File

@ -0,0 +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 osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Options
{
public class OptionCheckbox : OptionItem<bool>
{
private OsuCheckbox checkbox;
protected override Drawable CreateControl() => checkbox = new OsuCheckbox();
public override string LabelText
{
get { return checkbox.LabelText; }
set { checkbox.LabelText = value; }
}
}
}

View File

@ -2,45 +2,18 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Options
{
public class OptionDropdown<T> : FillFlowContainer
public class OptionDropdown<T> : OptionItem<T>
{
private readonly Dropdown<T> dropdown;
private readonly SpriteText text;
private Dropdown<T> dropdown;
public string LabelText
{
get { return text.Text; }
set
{
text.Text = value;
text.Alpha = !string.IsNullOrEmpty(value) ? 1 : 0;
}
}
public Bindable<T> Bindable
{
get { return bindable; }
set
{
bindable = value;
dropdown.Current.BindTo(bindable);
}
}
private Bindable<T> bindable;
private IEnumerable<KeyValuePair<string, T>> items;
private IEnumerable<KeyValuePair<string, T>> items = new KeyValuePair<string, T>[] { };
public IEnumerable<KeyValuePair<string, T>> Items
{
get
@ -55,30 +28,11 @@ namespace osu.Game.Overlays.Options
}
}
public OptionDropdown()
protected override Drawable CreateControl() => dropdown = new OsuDropdown<T>
{
Items = new KeyValuePair<string, T>[0];
Direction = FillDirection.Vertical;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Children = new Drawable[]
{
text = new OsuSpriteText {
Alpha = 0,
},
dropdown = new OsuDropdown<T>
{
Margin = new MarginPadding { Top = 5 },
RelativeSizeAxes = Axes.X,
Items = Items,
}
};
dropdown.Current.DisabledChanged += disabled =>
{
Alpha = disabled ? 0.3f : 1;
};
}
Margin = new MarginPadding { Top = 5 },
RelativeSizeAxes = Axes.X,
Items = Items,
};
}
}

View File

@ -0,0 +1,82 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Graphics;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.Options
{
public abstract class OptionItem<T> : FillFlowContainer, IFilterable
{
protected abstract Drawable CreateControl();
protected Drawable Control { get; }
private IHasCurrentValue<T> controlWithCurrent => Control as IHasCurrentValue<T>;
private SpriteText text;
public virtual string LabelText
{
get { return text?.Text ?? string.Empty; }
set
{
if (text == null)
{
// construct lazily for cases where the label is not needed (may be provided by the Control).
Add(text = new OsuSpriteText() { Depth = 1 });
}
text.Text = value;
}
}
// hold a reference to the provided bindable so we don't have to in every options section.
private Bindable<T> bindable;
public Bindable<T> Bindable
{
get
{
return bindable;
}
set
{
bindable = value;
controlWithCurrent?.Current.BindTo(bindable);
}
}
public string[] FilterTerms => new[] { LabelText };
public bool MatchingCurrentFilter
{
set
{
// probably needs a better transition.
FadeTo(value ? 1 : 0);
}
}
protected OptionItem()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Padding = new MarginPadding { Right = 5 };
if ((Control = CreateControl()) != null)
{
if (controlWithCurrent != null)
controlWithCurrent.Current.DisabledChanged += disabled => { Colour = disabled ? Color4.Gray : Color4.White; };
Add(Control);
}
}
}
}

View File

@ -2,13 +2,15 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.Options
{
internal class OptionLabel : OsuSpriteText
internal class OptionLabel : OptionItem<string>
{
protected override Drawable CreateControl() => null;
[BackgroundDependencyLoader]
private void load(OsuColour colour)
{

View File

@ -1,13 +1,9 @@
// 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.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Options
@ -17,52 +13,14 @@ namespace osu.Game.Overlays.Options
{
}
public class OptionSlider<T, U> : FillFlowContainer
public class OptionSlider<T, U> : OptionItem<T>
where T : struct
where U : SliderBar<T>, new()
{
private readonly SliderBar<T> slider;
private readonly SpriteText text;
public string LabelText
protected override Drawable CreateControl() => new U()
{
get { return text.Text; }
set
{
text.Text = value;
text.Alpha = string.IsNullOrEmpty(value) ? 0 : 1;
}
}
private Bindable<T> bindable;
public Bindable<T> Bindable
{
set
{
bindable = value;
slider.Current.BindTo(bindable);
}
}
public OptionSlider()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Padding = new MarginPadding { Right = 5 };
Children = new Drawable[]
{
text = new OsuSpriteText
{
Alpha = 0,
},
slider = new U()
{
Margin = new MarginPadding { Top = 5, Bottom = 5 },
RelativeSizeAxes = Axes.X
}
};
}
Margin = new MarginPadding { Top = 5, Bottom = 5 },
RelativeSizeAxes = Axes.X
};
}
}

View File

@ -1,22 +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
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Options
{
public class OptionTextBox : OsuTextBox
public class OptionTextBox : OptionItem<string>
{
private Bindable<string> bindable;
public Bindable<string> Bindable
{
set
{
bindable = value;
Current.BindTo(bindable);
}
}
protected override Drawable CreateControl() => new OsuTextBox();
}
}

View File

@ -3,7 +3,6 @@
using osu.Framework.Allocation;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Options.Sections.Audio
{
@ -16,12 +15,12 @@ namespace osu.Game.Overlays.Options.Sections.Audio
{
Children = new[]
{
new OsuCheckbox
new OptionCheckbox
{
LabelText = "Interface voices",
Bindable = config.GetBindable<bool>(OsuConfig.MenuVoice)
},
new OsuCheckbox
new OptionCheckbox
{
LabelText = "osu! music theme",
Bindable = config.GetBindable<bool>(OsuConfig.MenuMusic)
@ -29,4 +28,4 @@ namespace osu.Game.Overlays.Options.Sections.Audio
};
}
}
}
}

View File

@ -4,7 +4,6 @@
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Options.Sections.Debug
{
@ -17,7 +16,7 @@ namespace osu.Game.Overlays.Options.Sections.Debug
{
Children = new Drawable[]
{
new OsuCheckbox
new OptionCheckbox
{
LabelText = "Bypass caching",
Bindable = config.GetBindable<bool>(FrameworkDebugConfig.BypassCaching)

View File

@ -4,7 +4,6 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Options.Sections.Gameplay
{
@ -22,12 +21,12 @@ namespace osu.Game.Overlays.Options.Sections.Gameplay
LabelText = "Background dim",
Bindable = config.GetBindable<double>(OsuConfig.DimLevel)
},
new OsuCheckbox
new OptionCheckbox
{
LabelText = "Show score overlay",
Bindable = config.GetBindable<bool>(OsuConfig.ShowInterface)
},
new OsuCheckbox
new OptionCheckbox
{
LabelText = "Always show key overlay",
Bindable = config.GetBindable<bool>(OsuConfig.KeyOverlay)

View File

@ -4,7 +4,6 @@
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Options.Sections.General
{
@ -17,7 +16,7 @@ namespace osu.Game.Overlays.Options.Sections.General
{
Children = new Drawable[]
{
new OsuCheckbox
new OptionCheckbox
{
LabelText = "Prefer metadata in original language",
Bindable = frameworkConfig.GetBindable<bool>(FrameworkConfig.ShowUnicode)

View File

@ -132,12 +132,12 @@ namespace osu.Game.Overlays.Options.Sections.General
TabbableContentContainer = this,
OnCommit = (sender, newText) => performLogin()
},
new OsuCheckbox
new OptionCheckbox
{
LabelText = "Remember username",
Bindable = config.GetBindable<bool>(OsuConfig.SaveUsername),
},
new OsuCheckbox
new OptionCheckbox
{
LabelText = "Stay logged in",
Bindable = config.GetBindable<bool>(OsuConfig.SavePassword),

View File

@ -4,7 +4,6 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Options.Sections.Graphics
{
@ -17,12 +16,12 @@ namespace osu.Game.Overlays.Options.Sections.Graphics
{
Children = new Drawable[]
{
new OsuCheckbox
new OptionCheckbox
{
LabelText = "Snaking in sliders",
Bindable = config.GetBindable<bool>(OsuConfig.SnakingInSliders)
},
new OsuCheckbox
new OptionCheckbox
{
LabelText = "Snaking out sliders",
Bindable = config.GetBindable<bool>(OsuConfig.SnakingOutSliders)
@ -30,4 +29,4 @@ namespace osu.Game.Overlays.Options.Sections.Graphics
};
}
}
}
}

View File

@ -4,7 +4,6 @@
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Options.Sections.Graphics
{
@ -29,7 +28,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics
LabelText = "Screen mode",
Bindable = config.GetBindable<WindowMode>(FrameworkConfig.WindowMode),
},
new OsuCheckbox
new OptionCheckbox
{
LabelText = "Letterboxing",
Bindable = letterboxing,
@ -64,4 +63,4 @@ namespace osu.Game.Overlays.Options.Sections.Graphics
}
}
}
}
}

View File

@ -3,7 +3,6 @@
using osu.Framework.Allocation;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Options.Sections.Graphics
{
@ -16,7 +15,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics
{
Children = new[]
{
new OsuCheckbox
new OptionCheckbox
{
LabelText = "Parallax",
Bindable = config.GetBindable<bool>(OsuConfig.MenuParallax)
@ -24,4 +23,4 @@ namespace osu.Game.Overlays.Options.Sections.Graphics
};
}
}
}
}

View File

@ -5,7 +5,6 @@ using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Options.Sections.Graphics
{
@ -25,7 +24,7 @@ namespace osu.Game.Overlays.Options.Sections.Graphics
LabelText = "Frame limiter",
Bindable = config.GetBindable<FrameSync>(FrameworkConfig.FrameSync)
},
new OsuCheckbox
new OptionCheckbox
{
LabelText = "Show FPS",
Bindable = osuConfig.GetBindable<bool>(OsuConfig.ShowFpsDisplay)
@ -33,4 +32,4 @@ namespace osu.Game.Overlays.Options.Sections.Graphics
};
}
}
}
}

View File

@ -24,12 +24,12 @@ namespace osu.Game.Overlays.Options.Sections.Input
LabelText = "Confine mouse cursor",
Bindable = config.GetBindable<ConfineMouseMode>(FrameworkConfig.ConfineMouseMode),
},
new OsuCheckbox
new OptionCheckbox
{
LabelText = "Disable mouse wheel during gameplay",
Bindable = osuConfig.GetBindable<bool>(OsuConfig.MouseDisableWheel)
},
new OsuCheckbox
new OptionCheckbox
{
LabelText = "Disable mouse buttons during gameplay",
Bindable = osuConfig.GetBindable<bool>(OsuConfig.MouseDisableButtons)

View File

@ -17,7 +17,6 @@ namespace osu.Game.Overlays.Toolbar
private void load(ChatOverlay chat)
{
StateContainer = chat;
Action = chat.ToggleVisibility;
}
}
}

View File

@ -17,7 +17,6 @@ namespace osu.Game.Overlays.Toolbar
private void load(MusicController music)
{
StateContainer = music;
Action = music.ToggleVisibility;
}
}
}

View File

@ -22,7 +22,6 @@ namespace osu.Game.Overlays.Toolbar
private void load(NotificationManager notificationManager)
{
StateContainer = notificationManager;
Action = notificationManager.ToggleVisibility;
}
}
}

View File

@ -21,6 +21,7 @@ namespace osu.Game.Overlays.Toolbar
set
{
stateContainer = value;
Action = stateContainer.ToggleVisibility;
stateContainer.StateChanged += stateChanged;
}
}

View File

@ -19,7 +19,6 @@ namespace osu.Game.Overlays.Toolbar
private void load(OptionsOverlay options)
{
StateContainer = options;
Action = options.ToggleVisibility;
}
}
}

View File

@ -21,6 +21,11 @@ namespace osu.Game.Rulesets.Mods
/// </summary>
public virtual FontAwesome Icon => FontAwesome.fa_question;
/// <summary>
/// The type of this mod.
/// </summary>
public virtual ModType Type => ModType.Special;
/// <summary>
/// The user readable description of this mod.
/// </summary>

View File

@ -11,6 +11,7 @@ namespace osu.Game.Rulesets.Mods
{
public override string Name => "Double Time";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_doubletime;
public override ModType Type => ModType.DifficultyIncrease;
public override string Description => "Zoooooooooom";
public override bool Ranked => true;
public override Type[] IncompatibleMods => new[] { typeof(ModHalfTime) };

View File

@ -10,6 +10,7 @@ namespace osu.Game.Rulesets.Mods
{
public override string Name => "Easy";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_easy;
public override ModType Type => ModType.DifficultyReduction;
public override string Description => "Reduces overall difficulty - larger circles, more forgiving HP drain, less accuracy required.";
public override double ScoreMultiplier => 0.5;
public override bool Ranked => true;

View File

@ -9,6 +9,7 @@ namespace osu.Game.Rulesets.Mods
{
public override string Name => "Flashlight";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_flashlight;
public override ModType Type => ModType.DifficultyIncrease;
public override string Description => "Restricted view area.";
public override bool Ranked => true;
}

View File

@ -11,6 +11,7 @@ namespace osu.Game.Rulesets.Mods
{
public override string Name => "Half Time";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_halftime;
public override ModType Type => ModType.DifficultyReduction;
public override string Description => "Less zoom";
public override bool Ranked => true;
public override Type[] IncompatibleMods => new[] { typeof(ModDoubleTime) };

View File

@ -10,6 +10,7 @@ namespace osu.Game.Rulesets.Mods
{
public override string Name => "Hard Rock";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_hardrock;
public override ModType Type => ModType.DifficultyIncrease;
public override string Description => "Everything just got a bit harder...";
public override Type[] IncompatibleMods => new[] { typeof(ModEasy) };
}

View File

@ -9,6 +9,7 @@ namespace osu.Game.Rulesets.Mods
{
public override string Name => "Hidden";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_hidden;
public override ModType Type => ModType.DifficultyIncrease;
public override bool Ranked => true;
}
}

View File

@ -10,6 +10,7 @@ namespace osu.Game.Rulesets.Mods
{
public override string Name => "NoFail";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_nofail;
public override ModType Type => ModType.DifficultyReduction;
public override string Description => "You can't fail, no matter what.";
public override double ScoreMultiplier => 0.5;
public override bool Ranked => true;

View File

@ -10,6 +10,7 @@ namespace osu.Game.Rulesets.Mods
{
public override string Name => "Sudden Death";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_suddendeath;
public override ModType Type => ModType.DifficultyIncrease;
public override string Description => "Miss a note and fail.";
public override double ScoreMultiplier => 1;
public override bool Ranked => true;

View File

@ -279,7 +279,7 @@ namespace osu.Game.Rulesets.UI
protected abstract Playfield<TObject, TJudgement> CreatePlayfield();
}
public class BeatmapInvalidForRulesetException : Exception
public class BeatmapInvalidForRulesetException : ArgumentException
{
public BeatmapInvalidForRulesetException(string text)
: base(text)

View File

@ -1,10 +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
using System;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Rulesets.UI
{
@ -13,72 +16,88 @@ namespace osu.Game.Rulesets.UI
private readonly TextAwesome modIcon;
private readonly TextAwesome background;
private float iconSize = 80;
public float IconSize
{
get
{
return iconSize;
}
set
{
iconSize = value;
reapplySize();
}
}
public new Color4 Colour
{
get
{
return background.Colour;
}
set
{
background.Colour = value;
}
}
private const float icon_size = 80;
public FontAwesome Icon
{
get
{
return modIcon.Icon;
}
set
{
modIcon.Icon = value;
}
get { return modIcon.Icon; }
set { modIcon.Icon = value; }
}
private void reapplySize()
{
background.TextSize = iconSize;
modIcon.TextSize = iconSize - 35;
}
private readonly ModType type;
public ModIcon()
public ModIcon(Mod mod)
{
if (mod == null) throw new ArgumentNullException(nameof(mod));
type = mod.Type;
Children = new Drawable[]
{
background = new TextAwesome
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
TextSize = icon_size,
Icon = FontAwesome.fa_osu_mod_bg,
Shadow = true,
TextSize = 20
},
modIcon = new TextAwesome
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Colour = OsuColour.Gray(84),
TextSize = 20
TextSize = icon_size - 35,
Icon = mod.Icon
},
};
}
reapplySize();
private Color4 backgroundColour;
private Color4 highlightedColour;
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
switch (type)
{
default:
case ModType.DifficultyIncrease:
backgroundColour = colours.Yellow;
highlightedColour = colours.YellowLight;
break;
case ModType.DifficultyReduction:
backgroundColour = colours.Green;
highlightedColour = colours.GreenLight;
break;
case ModType.Special:
backgroundColour = colours.Blue;
highlightedColour = colours.BlueLight;
break;
}
applyStyle();
}
private bool highlighted;
public bool Highlighted
{
get
{
return highlighted;
}
set
{
highlighted = value;
applyStyle();
}
}
private void applyStyle()
{
background.Colour = highlighted ? highlightedColour : backgroundColour;
}
}
}
}

View File

@ -22,7 +22,7 @@ namespace osu.Game.Screens.Menu
/// </summary>
public class OsuLogo : Container
{
public Color4 OsuPink = OsuColour.FromHex(@"e967a1");
public readonly Color4 OsuPink = OsuColour.FromHex(@"e967a1");
private readonly Sprite logo;
private readonly CircularContainer logoContainer;

View File

@ -11,5 +11,10 @@ namespace osu.Game.Screens.Multiplayer
protected override IEnumerable<Type> PossibleChildren => new[] {
typeof(Match)
};
public MatchCreate()
{
ValidForResume = false;
}
}
}

View File

@ -10,7 +10,7 @@ using osu.Framework.Graphics.Transforms;
using osu.Framework.MathUtils;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Rulesets.UI
namespace osu.Game.Screens.Play.HUD
{
public abstract class ComboCounter : Container
{

View File

@ -1,13 +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
using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Transforms;
using osu.Framework.MathUtils;
using osu.Game.Graphics.UserInterface;
using System;
namespace osu.Game.Rulesets.UI
namespace osu.Game.Screens.Play.HUD
{
/// <summary>
/// Used to display combo with a roll-up animation in results screen.

View File

@ -4,7 +4,7 @@
using osu.Framework.Configuration;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Rulesets.UI
namespace osu.Game.Screens.Play.HUD
{
public abstract class HealthDisplay : Container
{

View File

@ -0,0 +1,105 @@
// 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.Collections.Generic;
using System.Linq;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.UI;
using OpenTK;
using osu.Framework.Input;
namespace osu.Game.Screens.Play.HUD
{
public class ModDisplay : Container, IHasCurrentValue<IEnumerable<Mod>>
{
private readonly Bindable<IEnumerable<Mod>> mods = new Bindable<IEnumerable<Mod>>();
public Bindable<IEnumerable<Mod>> Current => mods;
private readonly FillFlowContainer<ModIcon> iconsContainer;
public ModDisplay()
{
Children = new Drawable[]
{
iconsContainer = new IconFlow
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Margin = new MarginPadding { Left = 10, Right = 10 },
},
new OsuSpriteText
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.TopCentre,
Text = @"/ UNRANKED /",
Font = @"Venera",
TextSize = 12,
}
};
mods.ValueChanged += mods =>
{
iconsContainer.Clear();
foreach (Mod mod in mods)
{
iconsContainer.Add(new ModIcon(mod)
{
AutoSizeAxes = Axes.Both,
Scale = new Vector2(0.6f),
});
}
if (IsLoaded)
appearTransform();
};
}
protected override void LoadComplete()
{
base.LoadComplete();
appearTransform();
}
private void appearTransform()
{
iconsContainer.Flush();
iconsContainer.FadeInFromZero(1000, EasingTypes.OutQuint);
expand();
using (iconsContainer.BeginDelayedSequence(1200))
contract();
}
private void expand() => iconsContainer.TransformSpacingTo(new Vector2(5, 0), 500, EasingTypes.OutQuint);
private void contract() => iconsContainer.TransformSpacingTo(new Vector2(-25, 0), 500, EasingTypes.OutQuint);
protected override bool OnHover(InputState state)
{
expand();
return base.OnHover(state);
}
protected override void OnHoverLost(InputState state)
{
contract();
base.OnHoverLost(state);
}
private class IconFlow : FillFlowContainer<ModIcon>
{
// just reverses the depth of flow contents.
protected override IComparer<Drawable> DepthComparer => new ReverseCreationOrderDepthComparer();
protected override IEnumerable<ModIcon> FlowingChildren => base.FlowingChildren.Reverse();
}
}
}

View File

@ -3,7 +3,7 @@
using OpenTK;
namespace osu.Game.Rulesets.UI
namespace osu.Game.Screens.Play.HUD
{
/// <summary>
/// Uses the 'x' symbol and has a pop-out effect while rolling over.

View File

@ -1,8 +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 OpenTK;
using OpenTK.Graphics;
using System;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -10,9 +9,10 @@ using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
using System;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Rulesets.UI
namespace osu.Game.Screens.Play.HUD
{
public class StandardHealthDisplay : HealthDisplay, IHasAccentColour
{

View File

@ -5,18 +5,19 @@ using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Play;
using osu.Game.Rulesets.Scoring;
using osu.Framework.Input;
using OpenTK.Input;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Play.HUD;
using OpenTK.Input;
namespace osu.Game.Rulesets.UI
namespace osu.Game.Screens.Play
{
public abstract class HudOverlay : Container
public abstract class HUDOverlay : Container
{
private const int duration = 100;
@ -27,6 +28,7 @@ namespace osu.Game.Rulesets.UI
public readonly RollingCounter<double> AccuracyCounter;
public readonly HealthDisplay HealthDisplay;
public readonly SongProgress Progress;
public readonly ModDisplay ModDisplay;
private Bindable<bool> showKeyCounter;
private Bindable<bool> showHud;
@ -39,8 +41,9 @@ namespace osu.Game.Rulesets.UI
protected abstract ScoreCounter CreateScoreCounter();
protected abstract HealthDisplay CreateHealthDisplay();
protected abstract SongProgress CreateProgress();
protected abstract ModDisplay CreateModsContainer();
protected HudOverlay()
protected HUDOverlay()
{
RelativeSizeAxes = Axes.Both;
@ -56,6 +59,7 @@ namespace osu.Game.Rulesets.UI
AccuracyCounter = CreateAccuracyCounter(),
HealthDisplay = CreateHealthDisplay(),
Progress = CreateProgress(),
ModDisplay = CreateModsContainer(),
}
});
}
@ -105,6 +109,11 @@ namespace osu.Game.Rulesets.UI
public virtual void BindHitRenderer(HitRenderer hitRenderer)
{
hitRenderer.InputManager.Add(KeyCounter.GetReceptor());
// in the case a replay isn't loaded, we want some elements to only appear briefly.
if (!hitRenderer.HasReplayLoaded)
using (ModDisplay.BeginDelayedSequence(2000))
ModDisplay.FadeOut(200);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)

View File

@ -72,7 +72,7 @@ namespace osu.Game.Screens.Play
private Container hitRendererContainer;
private HudOverlay hudOverlay;
private HUDOverlay hudOverlay;
private PauseOverlay pauseOverlay;
private FailOverlay failOverlay;
@ -90,7 +90,7 @@ namespace osu.Game.Screens.Play
Beatmap = beatmaps.GetWorkingBeatmap(BeatmapInfo, withStoryboard: true);
if (Beatmap?.Beatmap == null)
throw new Exception("Beatmap was not loaded");
throw new InvalidOperationException("Beatmap was not loaded");
ruleset = osu?.Ruleset.Value ?? Beatmap.BeatmapInfo.Ruleset;
rulesetInstance = ruleset.CreateInstance();
@ -109,7 +109,7 @@ namespace osu.Game.Screens.Play
}
if (!HitRenderer.Objects.Any())
throw new Exception("Beatmap contains no hit objects!");
throw new InvalidOperationException("Beatmap contains no hit objects!");
}
catch (Exception e)
{
@ -154,7 +154,7 @@ namespace osu.Game.Screens.Play
scoreProcessor = HitRenderer.CreateScoreProcessor();
hudOverlay = new StandardHudOverlay()
hudOverlay = new StandardHUDOverlay()
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre
@ -169,6 +169,8 @@ namespace osu.Game.Screens.Play
hudOverlay.Progress.AllowSeeking = HitRenderer.HasReplayLoaded;
hudOverlay.Progress.OnSeek = pos => decoupledClock.Seek(pos);
hudOverlay.ModDisplay.Current.BindTo(Beatmap.Mods);
//bind HitRenderer to ScoreProcessor and ourselves (for a pass situation)
HitRenderer.OnAllJudged += onCompletion;

View File

@ -1,18 +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 OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Screens.Play.HUD;
using OpenTK;
namespace osu.Game.Rulesets.UI
namespace osu.Game.Screens.Play
{
public class StandardHudOverlay : HudOverlay
public class StandardHUDOverlay : HUDOverlay
{
protected override RollingCounter<double> CreateAccuracyCounter() => new PercentageCounter
{
@ -64,6 +64,14 @@ namespace osu.Game.Rulesets.UI
RelativeSizeAxes = Axes.X,
};
protected override ModDisplay CreateModsContainer() => new ModDisplay
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Top = 20, Right = 10 },
};
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{

View File

@ -178,10 +178,9 @@
<Compile Include="Database\RulesetDatabase.cs" />
<Compile Include="Rulesets\Scoring\Score.cs" />
<Compile Include="Rulesets\Scoring\ScoreProcessor.cs" />
<Compile Include="Rulesets\UI\HealthDisplay.cs" />
<Compile Include="Rulesets\UI\HudOverlay.cs" />
<Compile Include="Rulesets\UI\StandardHealthDisplay.cs" />
<Compile Include="Rulesets\UI\StandardHudOverlay.cs" />
<Compile Include="Screens\Play\HUD\HealthDisplay.cs" />
<Compile Include="Screens\Play\HUDOverlay.cs" />
<Compile Include="Screens\Play\HUD\StandardHealthDisplay.cs" />
<Compile Include="Online\API\IOnlineComponent.cs" />
<Compile Include="Online\API\Requests\GetScoresRequest.cs" />
<Compile Include="Online\API\Requests\GetBeatmapDetailsRequest.cs" />
@ -228,7 +227,9 @@
<Compile Include="Screens\Charts\ChartInfo.cs" />
<Compile Include="Screens\Edit\Editor.cs" />
<Compile Include="Screens\Play\HotkeyRetryOverlay.cs" />
<Compile Include="Screens\Play\HUD\ModDisplay.cs" />
<Compile Include="Screens\Play\SquareGraph.cs" />
<Compile Include="Screens\Play\StandardHUDOverlay.cs" />
<Compile Include="Screens\Ranking\ResultsPage.cs" />
<Compile Include="Screens\Ranking\ResultsPageRanking.cs" />
<Compile Include="Screens\Ranking\ResultsPageScore.cs" />
@ -254,7 +255,7 @@
<Compile Include="Screens\Play\PlayerLoader.cs" />
<Compile Include="Screens\Play\ReplayPlayer.cs" />
<Compile Include="Screens\Play\SkipButton.cs" />
<Compile Include="Rulesets\UI\StandardComboCounter.cs" />
<Compile Include="Screens\Play\HUD\StandardComboCounter.cs" />
<Compile Include="Screens\Ranking\AspectContainer.cs" />
<Compile Include="Screens\Ranking\ResultMode.cs" />
<Compile Include="Screens\Ranking\ResultModeButton.cs" />
@ -279,8 +280,8 @@
<Compile Include="Rulesets\UI\HitRenderer.cs" />
<Compile Include="Rulesets\UI\Playfield.cs" />
<Compile Include="Screens\Select\EditSongSelect.cs" />
<Compile Include="Rulesets\UI\ComboCounter.cs" />
<Compile Include="Rulesets\UI\ComboResultCounter.cs" />
<Compile Include="Screens\Play\HUD\ComboCounter.cs" />
<Compile Include="Screens\Play\HUD\ComboResultCounter.cs" />
<Compile Include="Graphics\UserInterface\RollingCounter.cs" />
<Compile Include="Graphics\UserInterface\Volume\VolumeControlReceptor.cs" />
<Compile Include="Input\GlobalHotkeys.cs" />
@ -371,8 +372,10 @@
<Compile Include="Overlays\Options\Sections\SkinSection.cs" />
<Compile Include="Graphics\UserInterface\OsuCheckbox.cs" />
<Compile Include="Overlays\Options\SidebarButton.cs" />
<Compile Include="Overlays\Options\OptionCheckbox.cs" />
<Compile Include="Overlays\Options\OptionTextBox.cs" />
<Compile Include="Overlays\Options\OptionSlider.cs" />
<Compile Include="Overlays\Options\OptionItem.cs" />
<Compile Include="Overlays\Options\OptionEnumDropdown.cs" />
<Compile Include="Configuration\RankingType.cs" />
<Compile Include="Configuration\ScoreMeterType.cs" />
@ -390,6 +393,7 @@
<Compile Include="Screens\Play\Pause\PauseProgressGraph.cs" />
<Compile Include="Overlays\Mods\ModSelectOverlay.cs" />
<Compile Include="Rulesets\Mods\Mod.cs" />
<Compile Include="Overlays\Mods\ModButtonEmpty.cs" />
<Compile Include="Overlays\Mods\ModButton.cs" />
<Compile Include="Rulesets\UI\ModIcon.cs" />
<Compile Include="Overlays\Mods\ModSection.cs" />

View File

@ -182,6 +182,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GL/@EntryIndexedValue">GL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GLSL/@EntryIndexedValue">GLSL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HID/@EntryIndexedValue">HID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HUD/@EntryIndexedValue">HUD</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IP/@EntryIndexedValue">IP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IPC/@EntryIndexedValue">IPC</s:String>