1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-23 18:10:01 +08:00

Merge branch 'master' into counters-a

This commit is contained in:
Adonais Romero González 2016-10-15 13:45:55 -05:00
commit 9241287c79
19 changed files with 210 additions and 89 deletions

24
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "mono",
"request": "launch",
"program": "${workspaceRoot}/osu.Desktop.VisualTests/bin/Debug/osu!.exe",
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": "",
"runtimeExecutable": null,
"env": {},
"externalConsole": false
},
{
"name": "Attach",
"type": "mono",
"request": "attach",
"address": "localhost",
"port": 55555
}
]
}

26
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"windows": {
"command": "msbuild"
},
"linux": {
"command": "xbuild"
},
"args": [
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true"
],
"taskSelector": "/t:",
"showOutput": "silent",
"tasks": [
{
"taskName": "build",
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$msCompile"
}
]
}

@ -1 +1 @@
Subproject commit 3629521379bea5d79cd41e35ad6c6dfe21b4f9e7
Subproject commit cb420e7f7f4ef9cdda8ae8336d997946384d3732

View File

@ -25,7 +25,7 @@ namespace osu.Game.Beatmaps.Objects.Catch
{
OsuBaseHit o = i as OsuBaseHit;
if (o == null) throw new Exception(@"Can't convert!");
if (o == null) throw new HitObjectConvertException(@"Catch", i);
h = new Fruit
{

View File

@ -1,6 +1,7 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
namespace osu.Game.Beatmaps.Objects
@ -10,4 +11,13 @@ namespace osu.Game.Beatmaps.Objects
{
public abstract List<T> Convert(List<HitObject> input);
}
public class HitObjectConvertException : Exception
{
public HitObject Input { get; }
public HitObjectConvertException(string modeName, HitObject input)
: base($@"Can't convert from {input.GetType().Name} to {modeName} HitObject!")
{
Input = input;
}
}
}

View File

@ -28,7 +28,7 @@ namespace osu.Game.Beatmaps.Objects.Mania
{
OsuBaseHit o = i as OsuBaseHit;
if (o == null) throw new Exception(@"Can't convert!");
if (o == null) throw new HitObjectConvertException(@"Mania", i);
h = new Note
{

View File

@ -21,7 +21,7 @@ namespace osu.Game.Beatmaps.Objects.Taiko
{
OsuBaseHit o = i as OsuBaseHit;
if (o == null) throw new Exception(@"Can't convert!");
if (o == null) throw new HitObjectConvertException(@"Taiko", i);
h = new TaikoBaseHit
{

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Input;
using osu.Framework;
using OpenTK;
namespace osu.Game.GameModes.Menu
{
@ -16,7 +17,7 @@ namespace osu.Game.GameModes.Menu
/// </summary>
public partial class OsuLogo : AutoSizeContainer
{
private Sprite logo;
private SpriteCircular logo;
private Container logoBounceContainer;
private MenuVisualisation vis;
@ -37,6 +38,11 @@ namespace osu.Game.GameModes.Menu
}
}
public override bool Contains(Vector2 screenSpacePos)
{
return logo.Contains(screenSpacePos);
}
public bool Interactive = true;
public OsuLogo()
@ -50,7 +56,7 @@ namespace osu.Game.GameModes.Menu
{
Children = new Drawable[]
{
logo = new Sprite()
logo = new SpriteCircular()
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre

View File

@ -1,7 +1,6 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Catch;
@ -11,9 +10,9 @@ namespace osu.Game.GameModes.Play.Catch
{
public class CatchHitRenderer : HitRenderer<CatchBaseHit>
{
protected override Playfield CreatePlayfield() => new CatchPlayfield();
protected override HitObjectConverter<CatchBaseHit> Converter => new CatchConverter();
protected override List<CatchBaseHit> Convert(List<HitObject> objects) => new CatchConverter().Convert(objects);
protected override Playfield CreatePlayfield() => new CatchPlayfield();
protected override Drawable GetVisualRepresentation(CatchBaseHit h) => new DrawableFruit(h);
}

View File

@ -10,6 +10,7 @@ using osu.Framework;
namespace osu.Game.GameModes.Play
{
public abstract class HitRenderer<T> : Container
where T : HitObject
{
private List<T> objects;
@ -27,7 +28,9 @@ namespace osu.Game.GameModes.Play
protected abstract Playfield CreatePlayfield();
protected abstract List<T> Convert(List<HitObject> objects);
protected abstract HitObjectConverter<T> Converter { get; }
protected virtual List<T> Convert(List<HitObject> objects) => Converter.Convert(objects);
public override void Load(BaseGame game)
{

View File

@ -1,12 +1,11 @@
//Copyright (c) 2007-2016 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;
using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Mania;
using OpenTK;
using osu.Game.Beatmaps.Objects.Mania.Drawable;
using System.Collections.Generic;
namespace osu.Game.GameModes.Play.Mania
{
@ -19,11 +18,7 @@ namespace osu.Game.GameModes.Play.Mania
this.columns = columns;
}
protected override List<ManiaBaseHit> Convert(List<HitObject> objects)
{
ManiaConverter converter = new ManiaConverter(columns);
return converter.Convert(objects);
}
protected override HitObjectConverter<ManiaBaseHit> Converter => new ManiaConverter(columns);
protected override Playfield CreatePlayfield() => new ManiaPlayfield(columns);

View File

@ -1,7 +1,6 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Osu;
@ -11,9 +10,9 @@ namespace osu.Game.GameModes.Play.Osu
{
public class OsuHitRenderer : HitRenderer<OsuBaseHit>
{
protected override Playfield CreatePlayfield() => new OsuPlayfield();
protected override HitObjectConverter<OsuBaseHit> Converter => new OsuConverter();
protected override List<OsuBaseHit> Convert(List<HitObject> objects) => new OsuConverter().Convert(objects);
protected override Playfield CreatePlayfield() => new OsuPlayfield();
protected override Drawable GetVisualRepresentation(OsuBaseHit h) => new DrawableCircle(h);
}

View File

@ -1,7 +1,6 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Taiko;
@ -11,10 +10,10 @@ namespace osu.Game.GameModes.Play.Taiko
{
public class TaikoHitRenderer : HitRenderer<TaikoBaseHit>
{
protected override List<TaikoBaseHit> Convert(List<HitObject> objects) => new TaikoConverter().Convert(objects);
protected override HitObjectConverter<TaikoBaseHit> Converter => new TaikoConverter();
protected override Playfield CreatePlayfield() => new TaikoPlayfield();
protected override Drawable GetVisualRepresentation(TaikoBaseHit h) => new DrawableTaikoHit(h);
}
}
}

View File

@ -43,7 +43,7 @@ namespace osu.Game.Online.Chat.Display
{
new SpriteText
{
Text = Message.Timestamp.ToLocalTime().ToLongTimeString(),
Text = Message.Timestamp.LocalDateTime.ToLongTimeString(),
TextSize = text_size,
Colour = new Color4(128, 128, 128, 255)
},

View File

@ -18,7 +18,7 @@ namespace osu.Game.Online.Chat
public int ChannelId;
[JsonProperty(@"timestamp")]
public DateTime Timestamp;
public DateTimeOffset Timestamp;
[JsonProperty(@"content")]
public string Content;

View File

@ -22,6 +22,7 @@ using osu.Game.Input;
using OpenTK.Input;
using System.IO;
using osu.Game.Beatmaps.IO;
using osu.Framework.Logging;
namespace osu.Game
{
@ -62,10 +63,10 @@ namespace osu.Game
if (args.Length == 1 && File.Exists(args[0]))
{
BeatmapIPC.SendMessage(new ImportBeatmap { Path = args[0] }).Wait();
Console.WriteLine(@"Sent file to running instance");
Logger.Log(@"Sent file to running instance");
}
else
Console.WriteLine(@"osu! does not support multiple running instances.");
Logger.Log(@"osu! does not support multiple running instances.", LoggingTarget.Runtime, LogLevel.Error);
Environment.Exit(0);
}
@ -79,7 +80,7 @@ namespace osu.Game
catch (Exception ex)
{
// TODO: Show the user some info?
Console.WriteLine($@"Failed to import beatmap: {ex}");
Logger.Log($@"Failed to import beatmap: {ex}", LoggingTarget.Runtime, LogLevel.Error);
}
};

View File

@ -1,21 +1,16 @@
using System;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Drawables;
using osu.Framework.Input;
using osu.Framework.Graphics.Transformations;
using osu.Framework;
using OpenTK;
namespace osu.Game
{
internal class VolumeControl : Container
{
private Box meterFill;
private Container meterContainer;
private FlowContainer volumeMetersContainer;
private VolumeMeter volumeMeterMaster;
public BindableDouble VolumeGlobal { get; set; }
public BindableDouble VolumeSample { get; set; }
public BindableDouble VolumeTrack { get; set; }
@ -25,84 +20,63 @@ namespace osu.Game
RelativeSizeAxes = Axes.Both;
}
private void volumeChanged(object sender, System.EventArgs e)
{
appear();
}
public override void Load(BaseGame game)
{
base.Load(game);
VolumeGlobal.ValueChanged += volumeChanged;
VolumeSample.ValueChanged += volumeChanged;
VolumeTrack.ValueChanged += volumeChanged;
Children = new Drawable[]
{
meterContainer = new Container {
volumeMetersContainer = new FlowContainer
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Position = new Vector2(10, 10),
Size = new Vector2(40, 180),
Position = new Vector2(10, 30),
Spacing = new Vector2(15,0),
Alpha = 0,
Children = new Drawable[]
{
new Box
{
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both,
},
new Container
{
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.5f, 0.9f),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
new Box
{
Colour = Color4.DarkGray,
RelativeSizeAxes = Axes.Both,
},
meterFill = new Box
{
Colour = Color4.White,
RelativeSizeAxes = Axes.Both,
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre
},
}
}
volumeMeterMaster = new VolumeMeter("Master", VolumeGlobal),
new VolumeMeter("Effects", VolumeSample),
new VolumeMeter("Music", VolumeTrack)
}
}
};
}
updateFill();
protected override void Dispose(bool isDisposing)
{
VolumeGlobal.ValueChanged -= volumeChanged;
VolumeSample.ValueChanged -= volumeChanged;
VolumeTrack.ValueChanged -= volumeChanged;
base.Dispose(isDisposing);
}
protected override bool OnWheelDown(InputState state)
{
appear();
VolumeGlobal.Value -= 0.05f;
updateFill();
return base.OnWheelDown(state);
volumeMeterMaster.TriggerWheelDown(state);
return true;
}
protected override bool OnWheelUp(InputState state)
{
appear();
VolumeGlobal.Value += 0.05f;
updateFill();
return base.OnWheelUp(state);
}
private void updateFill()
{
meterFill.ScaleTo(new Vector2(1, (float)VolumeGlobal.Value), 300, EasingTypes.OutQuint);
volumeMeterMaster.TriggerWheelUp(state);
return true;
}
private void appear()
{
meterContainer.ClearTransformations();
meterContainer.FadeIn(100);
meterContainer.Delay(1000);
meterContainer.FadeOut(100);
volumeMetersContainer.ClearTransformations();
volumeMetersContainer.FadeIn(100);
volumeMetersContainer.Delay(1000);
volumeMetersContainer.FadeOut(100);
}
}
}

84
osu.Game/VolumeMeter.cs Normal file
View File

@ -0,0 +1,84 @@
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Drawables;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Framework.Input;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game
{
internal class VolumeMeter : Container
{
private Box meterFill;
private BindableDouble volume;
public VolumeMeter(string meterName, BindableDouble volume)
{
this.volume = volume;
Size = new Vector2(40, 180);
Children = new Drawable[]
{
new Box
{
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both
},
new Container
{
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.5f, 0.9f),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
{
new Box
{
Colour = Color4.DarkGray,
RelativeSizeAxes = Axes.Both
},
meterFill = new Box
{
Colour = Color4.White,
RelativeSizeAxes = Axes.Both,
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre
}
}
},
new SpriteText
{
Text = meterName,
Anchor = Anchor.BottomCentre,
Origin = Anchor.TopCentre
}
};
}
public double Volume
{
get { return volume.Value; }
private set
{
volume.Value = value;
updateFill();
}
}
protected override bool OnWheelUp(InputState state)
{
Volume += 0.05f;
return true;
}
protected override bool OnWheelDown(InputState state)
{
Volume -= 0.05f;
return true;
}
private void updateFill() => meterFill.ScaleTo(new Vector2(1, (float)Volume), 300, EasingTypes.OutQuint);
}
}

View File

@ -180,6 +180,7 @@
<Compile Include="Beatmaps\IO\OszArchiveReader.cs" />
<Compile Include="Beatmaps\BaseDifficulty.cs" />
<Compile Include="Beatmaps\Events\EventType.cs" />
<Compile Include="VolumeMeter.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">