mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
50
osu.Game/Beatmaps/DifficultyCalculator.cs
Normal file
50
osu.Game/Beatmaps/DifficultyCalculator.cs
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Modes.Objects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
public abstract class DifficultyCalculator
|
||||
{
|
||||
protected abstract PlayMode PlayMode { get; }
|
||||
|
||||
protected double TimeRate = 1;
|
||||
|
||||
protected abstract double ComputeDifficulty(Dictionary<String, String> categoryDifficulty);
|
||||
|
||||
private void loadTiming()
|
||||
{
|
||||
// TODO: Handle mods
|
||||
int audioRate = 100;
|
||||
TimeRate = audioRate / 100.0;
|
||||
}
|
||||
|
||||
public double GetDifficulty(Dictionary<string, string> categoryDifficulty = null)
|
||||
{
|
||||
loadTiming();
|
||||
double difficulty = ComputeDifficulty(categoryDifficulty);
|
||||
return difficulty;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class DifficultyCalculator<T> : DifficultyCalculator where T : HitObject
|
||||
{
|
||||
protected List<T> Objects;
|
||||
|
||||
protected abstract HitObjectConverter<T> Converter { get; }
|
||||
|
||||
public DifficultyCalculator(Beatmap beatmap)
|
||||
{
|
||||
Objects = Converter.Convert(beatmap);
|
||||
PreprocessHitObjects();
|
||||
}
|
||||
|
||||
protected virtual void PreprocessHitObjects()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -60,7 +60,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
public BeatmapGroup(WorkingBeatmap beatmap, BeatmapSetInfo set = null)
|
||||
public BeatmapGroup(WorkingBeatmap beatmap)
|
||||
{
|
||||
Header = new BeatmapSetHeader(beatmap)
|
||||
{
|
||||
@ -68,6 +68,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
RelativeSizeAxes = Axes.X,
|
||||
};
|
||||
|
||||
BeatmapSet = beatmap.BeatmapSetInfo;
|
||||
BeatmapPanels = beatmap.BeatmapSetInfo.Beatmaps.Select(b => new BeatmapPanel(b)
|
||||
{
|
||||
Alpha = 0,
|
||||
@ -76,7 +77,6 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
RelativeSizeAxes = Axes.X,
|
||||
}).ToList();
|
||||
|
||||
BeatmapSet = set;
|
||||
Header.AddDifficultyIcons(BeatmapPanels);
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,6 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace osu.Game.Beatmaps.Timing
|
||||
{
|
||||
class TimingChange : ControlPoint
|
||||
|
@ -68,7 +68,6 @@ namespace osu.Game.Beatmaps
|
||||
beatmap = decoder?.Decode(stream);
|
||||
}
|
||||
|
||||
|
||||
if (WithStoryboard && beatmap != null && BeatmapSetInfo.StoryboardFile != null)
|
||||
using (var stream = new StreamReader(reader.GetStream(BeatmapSetInfo.StoryboardFile)))
|
||||
decoder?.Decode(stream, beatmap);
|
||||
|
@ -31,6 +31,7 @@ namespace osu.Game.Configuration
|
||||
Set(OsuConfig.SnakingInSliders, true);
|
||||
Set(OsuConfig.SnakingOutSliders, false);
|
||||
|
||||
Set(OsuConfig.MenuParallax, true);
|
||||
//todo: implement all settings below this line (remove the Disabled set when doing so).
|
||||
|
||||
Set(OsuConfig.MouseSpeed, 1.0).Disabled = true;
|
||||
@ -143,7 +144,6 @@ namespace osu.Game.Configuration
|
||||
Set(OsuConfig.DetectPerformanceIssues, true).Disabled = true;
|
||||
Set(OsuConfig.MenuMusic, true).Disabled = true;
|
||||
Set(OsuConfig.MenuVoice, true).Disabled = true;
|
||||
Set(OsuConfig.MenuParallax, true).Disabled = true;
|
||||
Set(OsuConfig.RawInput, false).Disabled = true;
|
||||
Set(OsuConfig.AbsoluteToOsuWindow, Get<bool>(OsuConfig.RawInput)).Disabled = true;
|
||||
Set(OsuConfig.ShowMenuTips, true).Disabled = true;
|
||||
|
@ -8,6 +8,7 @@ using osu.Game.Modes;
|
||||
using osu.Game.Screens.Play;
|
||||
using SQLite.Net.Attributes;
|
||||
using SQLiteNetExtensions.Attributes;
|
||||
using osu.Game.Beatmaps;
|
||||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
@ -73,7 +74,23 @@ namespace osu.Game.Database
|
||||
// Metadata
|
||||
public string Version { get; set; }
|
||||
|
||||
public float StarDifficulty => BaseDifficulty?.OverallDifficulty ?? 5; //todo: implement properly
|
||||
//todo: background threaded computation of this
|
||||
private float starDifficulty = -1;
|
||||
public float StarDifficulty
|
||||
{
|
||||
get
|
||||
{
|
||||
return (starDifficulty < 0) ? (BaseDifficulty?.OverallDifficulty ?? 5) : starDifficulty;
|
||||
}
|
||||
|
||||
set { starDifficulty = value; }
|
||||
}
|
||||
|
||||
internal void ComputeDifficulty(BeatmapDatabase database)
|
||||
{
|
||||
WorkingBeatmap wb = new WorkingBeatmap(this, BeatmapSet, database);
|
||||
StarDifficulty = (float)Ruleset.GetRuleset(Mode).CreateDifficultyCalculator(wb.Beatmap).GetDifficulty();
|
||||
}
|
||||
|
||||
public bool Equals(BeatmapInfo other)
|
||||
{
|
||||
|
@ -8,6 +8,8 @@ using OpenTK;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Framework.Configuration;
|
||||
|
||||
namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
@ -15,6 +17,8 @@ namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
public float ParallaxAmount = 0.02f;
|
||||
|
||||
private Bindable<bool> parallaxEnabled;
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
public ParallaxContainer()
|
||||
@ -34,9 +38,18 @@ namespace osu.Game.Graphics.Containers
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(UserInputManager input)
|
||||
private void load(UserInputManager input, OsuConfigManager config)
|
||||
{
|
||||
this.input = input;
|
||||
parallaxEnabled = config.GetBindable<bool>(OsuConfig.MenuParallax);
|
||||
parallaxEnabled.ValueChanged += delegate
|
||||
{
|
||||
if (!parallaxEnabled)
|
||||
{
|
||||
content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, EasingTypes.OutQuint);
|
||||
content.Scale = new Vector2(1 + ParallaxAmount);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool firstUpdate = true;
|
||||
@ -45,9 +58,12 @@ namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
base.Update();
|
||||
|
||||
Vector2 offset = input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.NativeState.Position) - DrawSize / 2;
|
||||
content.MoveTo(offset * ParallaxAmount, firstUpdate ? 0 : 1000, EasingTypes.OutQuint);
|
||||
content.Scale = new Vector2(1 + ParallaxAmount);
|
||||
if (parallaxEnabled)
|
||||
{
|
||||
Vector2 offset = input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.NativeState.Position) - DrawSize / 2;
|
||||
content.MoveTo(offset * ParallaxAmount, firstUpdate ? 0 : 1000, EasingTypes.OutQuint);
|
||||
content.Scale = new Vector2(1 + ParallaxAmount);
|
||||
}
|
||||
|
||||
firstUpdate = false;
|
||||
}
|
||||
|
@ -13,6 +13,11 @@ namespace osu.Game.Input
|
||||
|
||||
public override bool HandleInput => true;
|
||||
|
||||
public GlobalHotkeys()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
return Handler(state, args);
|
||||
|
@ -32,6 +32,8 @@ namespace osu.Game.Modes
|
||||
|
||||
public abstract HitObjectParser CreateHitObjectParser();
|
||||
|
||||
public abstract DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap);
|
||||
|
||||
public static void Register(Ruleset ruleset) => availableRulesets.TryAdd(ruleset.PlayMode, ruleset.GetType());
|
||||
|
||||
protected abstract PlayMode PlayMode { get; }
|
||||
|
@ -89,7 +89,6 @@ namespace osu.Game.Overlays.Notifications
|
||||
IconContent = new Container
|
||||
{
|
||||
Size = new Vector2(40),
|
||||
Colour = Color4.DarkGray,
|
||||
Masking = true,
|
||||
CornerRadius = 5,
|
||||
},
|
||||
|
@ -1,7 +1,11 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
|
||||
namespace osu.Game.Overlays.Notifications
|
||||
{
|
||||
@ -14,5 +18,11 @@ namespace osu.Game.Overlays.Notifications
|
||||
this.progressNotification = progressNotification;
|
||||
Icon = FontAwesome.fa_check;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
IconBackgound.ColourInfo = ColourInfo.GradientVertical(colours.GreenDark, colours.GreenLight);
|
||||
}
|
||||
}
|
||||
}
|
@ -37,19 +37,21 @@ namespace osu.Game.Overlays.Notifications
|
||||
private SpriteText textDrawable;
|
||||
private TextAwesome iconDrawable;
|
||||
|
||||
protected Box IconBackgound;
|
||||
|
||||
public SimpleNotification()
|
||||
{
|
||||
IconContent.Add(new Drawable[]
|
||||
{
|
||||
new Box
|
||||
IconBackgound = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ColourInfo = ColourInfo.GradientVertical(OsuColour.Gray(0.2f), OsuColour.Gray(0.5f))
|
||||
ColourInfo = ColourInfo.GradientVertical(OsuColour.Gray(0.2f), OsuColour.Gray(0.6f))
|
||||
},
|
||||
iconDrawable = new TextAwesome
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Icon = icon ,
|
||||
Icon = icon,
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -59,7 +59,6 @@ namespace osu.Game.Screens.Menu
|
||||
background.Preload(game);
|
||||
|
||||
buttons.OnSettings = game.ToggleOptions;
|
||||
|
||||
}
|
||||
|
||||
protected override void OnEntering(Screen last)
|
||||
|
@ -350,11 +350,13 @@ namespace osu.Game.Screens.Select
|
||||
if (b.Metadata == null) b.Metadata = beatmapSet.Metadata;
|
||||
});
|
||||
|
||||
foreach (var b in beatmapSet.Beatmaps)
|
||||
b.ComputeDifficulty(database);
|
||||
beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.StarDifficulty).ToList();
|
||||
|
||||
var beatmap = new WorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault(), beatmapSet, database);
|
||||
|
||||
var group = new BeatmapGroup(beatmap, beatmapSet)
|
||||
var group = new BeatmapGroup(beatmap)
|
||||
{
|
||||
SelectionChanged = selectionChanged,
|
||||
StartRequested = b => start()
|
||||
|
@ -66,6 +66,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
|
||||
<Compile Include="Beatmaps\DifficultyCalculator.cs" />
|
||||
<Compile Include="Graphics\Backgrounds\Triangles.cs" />
|
||||
<Compile Include="Graphics\Cursor\CursorTrail.cs" />
|
||||
<Compile Include="Graphics\Sprites\OsuSpriteText.cs" />
|
||||
|
Reference in New Issue
Block a user