mirror of
https://github.com/osukey/osukey.git
synced 2025-05-11 16:47:19 +09:00
Merge branch 'master' into populate-missing-online-ids
This commit is contained in:
commit
0a35a81c2d
@ -26,7 +26,7 @@
|
|||||||
<ProjectReference Include="..\osu.Game.Rulesets.Mania\osu.Game.Rulesets.Mania.csproj" />
|
<ProjectReference Include="..\osu.Game.Rulesets.Mania\osu.Game.Rulesets.Mania.csproj" />
|
||||||
<ProjectReference Include="..\osu.Game.Rulesets.Taiko\osu.Game.Rulesets.Taiko.csproj" />
|
<ProjectReference Include="..\osu.Game.Rulesets.Taiko\osu.Game.Rulesets.Taiko.csproj" />
|
||||||
<ProjectReference Include="..\osu-resources\osu.Game.Resources\osu.Game.Resources.csproj" />
|
<ProjectReference Include="..\osu-resources\osu.Game.Resources\osu.Game.Resources.csproj" />
|
||||||
<PackageReference Include="Microsoft.Win32.Registry" Version="4.4.0" />
|
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Package References">
|
<ItemGroup Label="Package References">
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.0" />
|
||||||
@ -35,4 +35,4 @@
|
|||||||
<ItemGroup Label="Resources">
|
<ItemGroup Label="Resources">
|
||||||
<EmbeddedResource Include="lazer.ico" />
|
<EmbeddedResource Include="lazer.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -82,56 +82,25 @@ namespace osu.Game.Rulesets.Catch
|
|||||||
{
|
{
|
||||||
new CatchModEasy(),
|
new CatchModEasy(),
|
||||||
new CatchModNoFail(),
|
new CatchModNoFail(),
|
||||||
new MultiMod
|
new MultiMod(new CatchModHalfTime(), new CatchModDaycore())
|
||||||
{
|
|
||||||
Mods = new Mod[]
|
|
||||||
{
|
|
||||||
new CatchModHalfTime(),
|
|
||||||
new CatchModDaycore(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
case ModType.DifficultyIncrease:
|
case ModType.DifficultyIncrease:
|
||||||
return new Mod[]
|
return new Mod[]
|
||||||
{
|
{
|
||||||
new CatchModHardRock(),
|
new CatchModHardRock(),
|
||||||
new MultiMod
|
new MultiMod(new CatchModSuddenDeath(), new CatchModPerfect()),
|
||||||
{
|
new MultiMod(new CatchModDoubleTime(), new CatchModNightcore()),
|
||||||
Mods = new Mod[]
|
|
||||||
{
|
|
||||||
new CatchModSuddenDeath(),
|
|
||||||
new CatchModPerfect(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new MultiMod
|
|
||||||
{
|
|
||||||
Mods = new Mod[]
|
|
||||||
{
|
|
||||||
new CatchModDoubleTime(),
|
|
||||||
new CatchModNightcore(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new CatchModHidden(),
|
new CatchModHidden(),
|
||||||
new CatchModFlashlight(),
|
new CatchModFlashlight(),
|
||||||
};
|
};
|
||||||
|
|
||||||
case ModType.Special:
|
case ModType.Special:
|
||||||
return new Mod[]
|
return new Mod[]
|
||||||
{
|
{
|
||||||
new CatchModRelax(),
|
new CatchModRelax(),
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
new MultiMod
|
new MultiMod(new CatchModAutoplay(), new ModCinema()),
|
||||||
{
|
|
||||||
Mods = new Mod[]
|
|
||||||
{
|
|
||||||
new CatchModAutoplay(),
|
|
||||||
new ModCinema(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return new Mod[] { };
|
return new Mod[] { };
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using System.Linq;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Difficulty;
|
using osu.Game.Rulesets.Difficulty;
|
||||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Mania.Mods;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
|
|
||||||
@ -141,5 +142,22 @@ namespace osu.Game.Rulesets.Mania.Difficulty
|
|||||||
|
|
||||||
return difficulty;
|
return difficulty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override Mod[] DifficultyAdjustmentMods => new Mod[]
|
||||||
|
{
|
||||||
|
new ManiaModDoubleTime(),
|
||||||
|
new ManiaModHalfTime(),
|
||||||
|
new ManiaModEasy(),
|
||||||
|
new ManiaModHardRock(),
|
||||||
|
new ManiaModKey1(),
|
||||||
|
new ManiaModKey2(),
|
||||||
|
new ManiaModKey3(),
|
||||||
|
new ManiaModKey4(),
|
||||||
|
new ManiaModKey5(),
|
||||||
|
new ManiaModKey6(),
|
||||||
|
new ManiaModKey7(),
|
||||||
|
new ManiaModKey8(),
|
||||||
|
new ManiaModKey9(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,78 +105,34 @@ namespace osu.Game.Rulesets.Mania
|
|||||||
{
|
{
|
||||||
new ManiaModEasy(),
|
new ManiaModEasy(),
|
||||||
new ManiaModNoFail(),
|
new ManiaModNoFail(),
|
||||||
new MultiMod
|
new MultiMod(new ManiaModHalfTime(), new ManiaModDaycore()),
|
||||||
{
|
|
||||||
Mods = new Mod[]
|
|
||||||
{
|
|
||||||
new ManiaModHalfTime(),
|
|
||||||
new ManiaModDaycore(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
case ModType.DifficultyIncrease:
|
case ModType.DifficultyIncrease:
|
||||||
return new Mod[]
|
return new Mod[]
|
||||||
{
|
{
|
||||||
new ManiaModHardRock(),
|
new ManiaModHardRock(),
|
||||||
new MultiMod
|
new MultiMod(new ManiaModSuddenDeath(), new ManiaModPerfect()),
|
||||||
{
|
new MultiMod(new ManiaModDoubleTime(), new ManiaModNightcore()),
|
||||||
Mods = new Mod[]
|
new MultiMod(new ManiaModFadeIn(), new ManiaModHidden()),
|
||||||
{
|
|
||||||
new ManiaModSuddenDeath(),
|
|
||||||
new ManiaModPerfect(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new MultiMod
|
|
||||||
{
|
|
||||||
Mods = new Mod[]
|
|
||||||
{
|
|
||||||
new ManiaModDoubleTime(),
|
|
||||||
new ManiaModNightcore(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new MultiMod
|
|
||||||
{
|
|
||||||
Mods = new Mod[]
|
|
||||||
{
|
|
||||||
new ManiaModFadeIn(),
|
|
||||||
new ManiaModHidden(),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new ManiaModFlashlight(),
|
new ManiaModFlashlight(),
|
||||||
};
|
};
|
||||||
|
|
||||||
case ModType.Special:
|
case ModType.Special:
|
||||||
return new Mod[]
|
return new Mod[]
|
||||||
{
|
{
|
||||||
new MultiMod
|
new MultiMod(new ManiaModKey4(),
|
||||||
{
|
new ManiaModKey5(),
|
||||||
Mods = new Mod[]
|
new ManiaModKey6(),
|
||||||
{
|
new ManiaModKey7(),
|
||||||
new ManiaModKey4(),
|
new ManiaModKey8(),
|
||||||
new ManiaModKey5(),
|
new ManiaModKey9(),
|
||||||
new ManiaModKey6(),
|
new ManiaModKey1(),
|
||||||
new ManiaModKey7(),
|
new ManiaModKey2(),
|
||||||
new ManiaModKey8(),
|
new ManiaModKey3()),
|
||||||
new ManiaModKey9(),
|
|
||||||
new ManiaModKey1(),
|
|
||||||
new ManiaModKey2(),
|
|
||||||
new ManiaModKey3(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new ManiaModRandom(),
|
new ManiaModRandom(),
|
||||||
new ManiaModDualStages(),
|
new ManiaModDualStages(),
|
||||||
new ManiaModMirror(),
|
new ManiaModMirror(),
|
||||||
new MultiMod
|
new MultiMod(new ManiaModAutoplay(), new ModCinema()),
|
||||||
{
|
|
||||||
Mods = new Mod[]
|
|
||||||
{
|
|
||||||
new ManiaModAutoplay(),
|
|
||||||
new ModCinema(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return new Mod[] { };
|
return new Mod[] { };
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
@ -24,5 +26,18 @@ namespace osu.Game.Rulesets.Mania.Mods
|
|||||||
|
|
||||||
mbc.TargetColumns = KeyCount;
|
mbc.TargetColumns = KeyCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Type[] IncompatibleMods => new[]
|
||||||
|
{
|
||||||
|
typeof(ManiaModKey1),
|
||||||
|
typeof(ManiaModKey2),
|
||||||
|
typeof(ManiaModKey3),
|
||||||
|
typeof(ManiaModKey4),
|
||||||
|
typeof(ManiaModKey5),
|
||||||
|
typeof(ManiaModKey6),
|
||||||
|
typeof(ManiaModKey7),
|
||||||
|
typeof(ManiaModKey8),
|
||||||
|
typeof(ManiaModKey9),
|
||||||
|
}.Except(new[] { GetType() }).ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,8 +277,13 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
if (action != Action)
|
if (action != Action)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var hitObject = HitObjects.Objects.LastOrDefault(h => h.HitObject.StartTime > Time.Current) ?? HitObjects.Objects.FirstOrDefault();
|
var nextObject =
|
||||||
hitObject?.PlaySamples();
|
HitObjects.AliveObjects.FirstOrDefault(h => h.HitObject.StartTime > Time.Current) ??
|
||||||
|
// fallback to non-alive objects to find next off-screen object
|
||||||
|
HitObjects.Objects.FirstOrDefault(h => h.HitObject.StartTime > Time.Current) ??
|
||||||
|
HitObjects.Objects.LastOrDefault();
|
||||||
|
|
||||||
|
nextObject?.PlaySamples();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ using osu.Game.Rulesets.Difficulty;
|
|||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
|
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
|
||||||
using osu.Game.Rulesets.Osu.Difficulty.Skills;
|
using osu.Game.Rulesets.Osu.Difficulty.Skills;
|
||||||
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Difficulty
|
namespace osu.Game.Rulesets.Osu.Difficulty
|
||||||
@ -71,5 +72,13 @@ namespace osu.Game.Rulesets.Osu.Difficulty
|
|||||||
|
|
||||||
return starRating;
|
return starRating;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override Mod[] DifficultyAdjustmentMods => new Mod[]
|
||||||
|
{
|
||||||
|
new OsuModDoubleTime(),
|
||||||
|
new OsuModHalfTime(),
|
||||||
|
new OsuModEasy(),
|
||||||
|
new OsuModHardRock(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,57 +93,26 @@ namespace osu.Game.Rulesets.Osu
|
|||||||
{
|
{
|
||||||
new OsuModEasy(),
|
new OsuModEasy(),
|
||||||
new OsuModNoFail(),
|
new OsuModNoFail(),
|
||||||
new MultiMod
|
new MultiMod(new OsuModHalfTime(), new OsuModDaycore()),
|
||||||
{
|
|
||||||
Mods = new Mod[]
|
|
||||||
{
|
|
||||||
new OsuModHalfTime(),
|
|
||||||
new OsuModDaycore(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
case ModType.DifficultyIncrease:
|
case ModType.DifficultyIncrease:
|
||||||
return new Mod[]
|
return new Mod[]
|
||||||
{
|
{
|
||||||
new OsuModHardRock(),
|
new OsuModHardRock(),
|
||||||
new MultiMod
|
new MultiMod(new OsuModSuddenDeath(), new OsuModPerfect()),
|
||||||
{
|
new MultiMod(new OsuModDoubleTime(), new OsuModNightcore()),
|
||||||
Mods = new Mod[]
|
|
||||||
{
|
|
||||||
new OsuModSuddenDeath(),
|
|
||||||
new OsuModPerfect(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new MultiMod
|
|
||||||
{
|
|
||||||
Mods = new Mod[]
|
|
||||||
{
|
|
||||||
new OsuModDoubleTime(),
|
|
||||||
new OsuModNightcore(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new OsuModHidden(),
|
new OsuModHidden(),
|
||||||
new OsuModFlashlight(),
|
new OsuModFlashlight(),
|
||||||
};
|
};
|
||||||
|
|
||||||
case ModType.Special:
|
case ModType.Special:
|
||||||
return new Mod[]
|
return new Mod[]
|
||||||
{
|
{
|
||||||
new OsuModRelax(),
|
new OsuModRelax(),
|
||||||
new OsuModAutopilot(),
|
new OsuModAutopilot(),
|
||||||
new OsuModSpunOut(),
|
new OsuModSpunOut(),
|
||||||
new MultiMod
|
new MultiMod(new OsuModAutoplay(), new ModCinema()),
|
||||||
{
|
|
||||||
Mods = new Mod[]
|
|
||||||
{
|
|
||||||
new OsuModAutoplay(),
|
|
||||||
new ModCinema(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new OsuModTarget(),
|
new OsuModTarget(),
|
||||||
};
|
};
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return new Mod[] { };
|
return new Mod[] { };
|
||||||
}
|
}
|
||||||
|
@ -64,9 +64,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
|
|
||||||
public override void PostProcess()
|
public override void PostProcess()
|
||||||
{
|
{
|
||||||
connectionLayer.HitObjects = HitObjects.Objects
|
connectionLayer.HitObjects = HitObjects.Objects.Select(d => d.HitObject).OfType<OsuHitObject>();
|
||||||
.Select(d => d.HitObject)
|
|
||||||
.OrderBy(h => h.StartTime).OfType<OsuHitObject>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onJudgement(DrawableHitObject judgedObject, Judgement judgement)
|
private void onJudgement(DrawableHitObject judgedObject, Judgement judgement)
|
||||||
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Difficulty;
|
using osu.Game.Rulesets.Difficulty;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Taiko.Mods;
|
||||||
using osu.Game.Rulesets.Taiko.Objects;
|
using osu.Game.Rulesets.Taiko.Objects;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Difficulty
|
namespace osu.Game.Rulesets.Taiko.Difficulty
|
||||||
@ -62,6 +63,14 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
|
|||||||
return starRating;
|
return starRating;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override Mod[] DifficultyAdjustmentMods => new Mod[]
|
||||||
|
{
|
||||||
|
new TaikoModDoubleTime(),
|
||||||
|
new TaikoModHalfTime(),
|
||||||
|
new TaikoModEasy(),
|
||||||
|
new TaikoModHardRock(),
|
||||||
|
};
|
||||||
|
|
||||||
private bool calculateStrainValues()
|
private bool calculateStrainValues()
|
||||||
{
|
{
|
||||||
// Traverse hitObjects in pairs to calculate the strain value of NextHitObject from the strain value of CurrentHitObject and environment.
|
// Traverse hitObjects in pairs to calculate the strain value of NextHitObject from the strain value of CurrentHitObject and environment.
|
||||||
|
@ -84,56 +84,25 @@ namespace osu.Game.Rulesets.Taiko
|
|||||||
{
|
{
|
||||||
new TaikoModEasy(),
|
new TaikoModEasy(),
|
||||||
new TaikoModNoFail(),
|
new TaikoModNoFail(),
|
||||||
new MultiMod
|
new MultiMod(new TaikoModHalfTime(), new TaikoModDaycore()),
|
||||||
{
|
|
||||||
Mods = new Mod[]
|
|
||||||
{
|
|
||||||
new TaikoModHalfTime(),
|
|
||||||
new TaikoModDaycore(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
case ModType.DifficultyIncrease:
|
case ModType.DifficultyIncrease:
|
||||||
return new Mod[]
|
return new Mod[]
|
||||||
{
|
{
|
||||||
new TaikoModHardRock(),
|
new TaikoModHardRock(),
|
||||||
new MultiMod
|
new MultiMod(new TaikoModSuddenDeath(), new TaikoModPerfect()),
|
||||||
{
|
new MultiMod(new TaikoModDoubleTime(), new TaikoModDaycore()),
|
||||||
Mods = new Mod[]
|
|
||||||
{
|
|
||||||
new TaikoModSuddenDeath(),
|
|
||||||
new TaikoModPerfect(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new MultiMod
|
|
||||||
{
|
|
||||||
Mods = new Mod[]
|
|
||||||
{
|
|
||||||
new TaikoModDoubleTime(),
|
|
||||||
new TaikoModNightcore(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new TaikoModHidden(),
|
new TaikoModHidden(),
|
||||||
new TaikoModFlashlight(),
|
new TaikoModFlashlight(),
|
||||||
};
|
};
|
||||||
|
|
||||||
case ModType.Special:
|
case ModType.Special:
|
||||||
return new Mod[]
|
return new Mod[]
|
||||||
{
|
{
|
||||||
new TaikoModRelax(),
|
new TaikoModRelax(),
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
new MultiMod
|
new MultiMod(new TaikoModAutoplay(), new ModCinema()),
|
||||||
{
|
|
||||||
Mods = new Mod[]
|
|
||||||
{
|
|
||||||
new TaikoModAutoplay(),
|
|
||||||
new ModCinema(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return new Mod[] { };
|
return new Mod[] { };
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,152 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Game.Rulesets.Difficulty;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.NonVisual
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class DifficultyAdjustmentModCombinationsTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestNoMods()
|
||||||
|
{
|
||||||
|
var combinations = new TestDifficultyCalculator().CreateDifficultyAdjustmentModCombinations();
|
||||||
|
|
||||||
|
Assert.AreEqual(1, combinations.Length);
|
||||||
|
Assert.IsTrue(combinations[0] is NoModMod);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSingleMod()
|
||||||
|
{
|
||||||
|
var combinations = new TestDifficultyCalculator(new ModA()).CreateDifficultyAdjustmentModCombinations();
|
||||||
|
|
||||||
|
Assert.AreEqual(2, combinations.Length);
|
||||||
|
Assert.IsTrue(combinations[0] is NoModMod);
|
||||||
|
Assert.IsTrue(combinations[1] is ModA);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDoubleMod()
|
||||||
|
{
|
||||||
|
var combinations = new TestDifficultyCalculator(new ModA(), new ModB()).CreateDifficultyAdjustmentModCombinations();
|
||||||
|
|
||||||
|
Assert.AreEqual(4, combinations.Length);
|
||||||
|
Assert.IsTrue(combinations[0] is NoModMod);
|
||||||
|
Assert.IsTrue(combinations[1] is ModA);
|
||||||
|
Assert.IsTrue(combinations[2] is MultiMod);
|
||||||
|
Assert.IsTrue(combinations[3] is ModB);
|
||||||
|
|
||||||
|
Assert.IsTrue(((MultiMod)combinations[2]).Mods[0] is ModA);
|
||||||
|
Assert.IsTrue(((MultiMod)combinations[2]).Mods[1] is ModB);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestIncompatibleMods()
|
||||||
|
{
|
||||||
|
var combinations = new TestDifficultyCalculator(new ModA(), new ModIncompatibleWithA()).CreateDifficultyAdjustmentModCombinations();
|
||||||
|
|
||||||
|
Assert.AreEqual(3, combinations.Length);
|
||||||
|
Assert.IsTrue(combinations[0] is NoModMod);
|
||||||
|
Assert.IsTrue(combinations[1] is ModA);
|
||||||
|
Assert.IsTrue(combinations[2] is ModIncompatibleWithA);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDoubleIncompatibleMods()
|
||||||
|
{
|
||||||
|
var combinations = new TestDifficultyCalculator(new ModA(), new ModB(), new ModIncompatibleWithA(), new ModIncompatibleWithAAndB()).CreateDifficultyAdjustmentModCombinations();
|
||||||
|
|
||||||
|
Assert.AreEqual(8, combinations.Length);
|
||||||
|
Assert.IsTrue(combinations[0] is NoModMod);
|
||||||
|
Assert.IsTrue(combinations[1] is ModA);
|
||||||
|
Assert.IsTrue(combinations[2] is MultiMod);
|
||||||
|
Assert.IsTrue(combinations[3] is ModB);
|
||||||
|
Assert.IsTrue(combinations[4] is MultiMod);
|
||||||
|
Assert.IsTrue(combinations[5] is ModIncompatibleWithA);
|
||||||
|
Assert.IsTrue(combinations[6] is MultiMod);
|
||||||
|
Assert.IsTrue(combinations[7] is ModIncompatibleWithAAndB);
|
||||||
|
|
||||||
|
Assert.IsTrue(((MultiMod)combinations[2]).Mods[0] is ModA);
|
||||||
|
Assert.IsTrue(((MultiMod)combinations[2]).Mods[1] is ModB);
|
||||||
|
Assert.IsTrue(((MultiMod)combinations[4]).Mods[0] is ModB);
|
||||||
|
Assert.IsTrue(((MultiMod)combinations[4]).Mods[1] is ModIncompatibleWithA);
|
||||||
|
Assert.IsTrue(((MultiMod)combinations[6]).Mods[0] is ModIncompatibleWithA);
|
||||||
|
Assert.IsTrue(((MultiMod)combinations[6]).Mods[1] is ModIncompatibleWithAAndB);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestIncompatibleThroughBaseType()
|
||||||
|
{
|
||||||
|
var combinations = new TestDifficultyCalculator(new ModAofA(), new ModIncompatibleWithAofA()).CreateDifficultyAdjustmentModCombinations();
|
||||||
|
|
||||||
|
Assert.AreEqual(3, combinations.Length);
|
||||||
|
Assert.IsTrue(combinations[0] is NoModMod);
|
||||||
|
Assert.IsTrue(combinations[1] is ModAofA);
|
||||||
|
Assert.IsTrue(combinations[2] is ModIncompatibleWithAofA);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ModA : Mod
|
||||||
|
{
|
||||||
|
public override string Name => nameof(ModA);
|
||||||
|
public override string ShortenedName => nameof(ModA);
|
||||||
|
public override double ScoreMultiplier => 1;
|
||||||
|
|
||||||
|
public override Type[] IncompatibleMods => new[] { typeof(ModIncompatibleWithA), typeof(ModIncompatibleWithAAndB) };
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ModB : Mod
|
||||||
|
{
|
||||||
|
public override string Name => nameof(ModB);
|
||||||
|
public override string ShortenedName => nameof(ModB);
|
||||||
|
public override double ScoreMultiplier => 1;
|
||||||
|
|
||||||
|
public override Type[] IncompatibleMods => new[] { typeof(ModIncompatibleWithAAndB) };
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ModIncompatibleWithA : Mod
|
||||||
|
{
|
||||||
|
public override string Name => $"Incompatible With {nameof(ModA)}";
|
||||||
|
public override string ShortenedName => $"Incompatible With {nameof(ModA)}";
|
||||||
|
public override double ScoreMultiplier => 1;
|
||||||
|
|
||||||
|
public override Type[] IncompatibleMods => new[] { typeof(ModA) };
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ModAofA : ModA
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ModIncompatibleWithAofA : ModIncompatibleWithA
|
||||||
|
{
|
||||||
|
// Incompatible through base type
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ModIncompatibleWithAAndB : Mod
|
||||||
|
{
|
||||||
|
public override string Name => $"Incompatible With {nameof(ModA)} and {nameof(ModB)}";
|
||||||
|
public override string ShortenedName => $"Incompatible With {nameof(ModA)} and {nameof(ModB)}";
|
||||||
|
public override double ScoreMultiplier => 1;
|
||||||
|
|
||||||
|
public override Type[] IncompatibleMods => new[] { typeof(ModA), typeof(ModB) };
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestDifficultyCalculator : DifficultyCalculator
|
||||||
|
{
|
||||||
|
public TestDifficultyCalculator(params Mod[] mods)
|
||||||
|
: base(null)
|
||||||
|
{
|
||||||
|
DifficultyAdjustmentMods = mods;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override double Calculate(Dictionary<string, double> categoryDifficulty = null) => throw new NotImplementedException();
|
||||||
|
|
||||||
|
protected override Mod[] DifficultyAdjustmentMods { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,7 +15,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestCaseEditorComposeTimeline : OsuTestCase
|
public class TestCaseEditorComposeTimeline : OsuTestCase
|
||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(ScrollableTimeline), typeof(ScrollingTimelineContainer), typeof(BeatmapWaveformGraph), typeof(TimelineButton) };
|
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(TimelineArea), typeof(Timeline), typeof(TimelineButton) };
|
||||||
|
|
||||||
public TestCaseEditorComposeTimeline()
|
public TestCaseEditorComposeTimeline()
|
||||||
{
|
{
|
||||||
@ -27,11 +27,12 @@ namespace osu.Game.Tests.Visual
|
|||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
State = Visibility.Visible
|
State = Visibility.Visible
|
||||||
},
|
},
|
||||||
new ScrollableTimeline
|
new TimelineArea
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Size = new Vector2(1000, 100)
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Size = new Vector2(0.8f, 100)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,11 @@ using OpenTK;
|
|||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Audio;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Screens.Edit.Screens.Compose.Timeline;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
@ -40,14 +40,13 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
for (int i = 1; i <= 16; i *= 2)
|
for (int i = 1; i <= 16; i *= 2)
|
||||||
{
|
{
|
||||||
var newDisplay = new BeatmapWaveformGraph
|
var newDisplay = new WaveformGraph
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Resolution = 1f / i,
|
Resolution = 1f / i,
|
||||||
Beatmap = Beatmap
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Beatmap.ValueChanged += b => newDisplay.Beatmap = b;
|
Beatmap.ValueChanged += b => newDisplay.Waveform = b.Waveform;
|
||||||
|
|
||||||
flow.Add(new Container
|
flow.Add(new Container
|
||||||
{
|
{
|
||||||
|
142
osu.Game.Tests/Visual/TestCaseZoomableScrollContainer.cs
Normal file
142
osu.Game.Tests/Visual/TestCaseZoomableScrollContainer.cs
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Colour;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.MathUtils;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Cursor;
|
||||||
|
using osu.Game.Screens.Edit.Screens.Compose.Timeline;
|
||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
using OpenTK.Input;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual
|
||||||
|
{
|
||||||
|
public class TestCaseZoomableScrollContainer : ManualInputManagerTestCase
|
||||||
|
{
|
||||||
|
private readonly ZoomableScrollContainer scrollContainer;
|
||||||
|
private readonly Drawable innerBox;
|
||||||
|
|
||||||
|
public TestCaseZoomableScrollContainer()
|
||||||
|
{
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 250,
|
||||||
|
Width = 0.75f,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = OsuColour.Gray(30)
|
||||||
|
},
|
||||||
|
scrollContainer = new ZoomableScrollContainer { RelativeSizeAxes = Axes.Both }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new MenuCursor()
|
||||||
|
};
|
||||||
|
|
||||||
|
scrollContainer.Add(innerBox = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = ColourInfo.GradientHorizontal(new Color4(0.8f, 0.6f, 0.4f, 1f), new Color4(0.4f, 0.6f, 0.8f, 1f))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestZoom0()
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
AddAssert("Box at 0", () => Precision.AlmostEquals(boxQuad.TopLeft, scrollQuad.TopLeft));
|
||||||
|
AddAssert("Box width = 1x", () => Precision.AlmostEquals(boxQuad.Size, scrollQuad.Size));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestZoom10()
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
AddStep("Set zoom = 10", () => scrollContainer.Zoom = 10);
|
||||||
|
AddAssert("Box at 1/2", () => Precision.AlmostEquals(boxQuad.Centre, scrollQuad.Centre));
|
||||||
|
AddAssert("Box width = 10x", () => Precision.AlmostEquals(boxQuad.Size.X, 10 * scrollQuad.Size.X));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMouseZoomInOnceOutOnce()
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
|
||||||
|
// Scroll in at 0.25
|
||||||
|
AddStep("Move mouse to 0.25x", () => InputManager.MoveMouseTo(new Vector2(scrollQuad.TopLeft.X + 0.25f * scrollQuad.Size.X, scrollQuad.Centre.Y)));
|
||||||
|
AddStep("Press ctrl", () => InputManager.PressKey(Key.LControl));
|
||||||
|
AddStep("Scroll by 3", () => InputManager.ScrollBy(new Vector2(3, 0)));
|
||||||
|
AddStep("Release ctrl", () => InputManager.ReleaseKey(Key.LControl));
|
||||||
|
AddAssert("Box not at 0", () => !Precision.AlmostEquals(boxQuad.TopLeft, scrollQuad.TopLeft));
|
||||||
|
AddAssert("Box 1/4 at 1/4", () => Precision.AlmostEquals(boxQuad.TopLeft.X + 0.25f * boxQuad.Size.X, scrollQuad.TopLeft.X + 0.25f * scrollQuad.Size.X));
|
||||||
|
|
||||||
|
// Scroll out at 0.25
|
||||||
|
AddStep("Press ctrl", () => InputManager.PressKey(Key.LControl));
|
||||||
|
AddStep("Scroll by -3", () => InputManager.ScrollBy(new Vector2(-3, 0)));
|
||||||
|
AddStep("Release ctrl", () => InputManager.ReleaseKey(Key.LControl));
|
||||||
|
AddAssert("Box at 0", () => Precision.AlmostEquals(boxQuad.TopLeft, scrollQuad.TopLeft));
|
||||||
|
AddAssert("Box 1/4 at 1/4", () => Precision.AlmostEquals(boxQuad.TopLeft.X + 0.25f * boxQuad.Size.X, scrollQuad.TopLeft.X + 0.25f * scrollQuad.Size.X));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMouseZoomInTwiceOutTwice()
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
|
||||||
|
// Scroll in at 0.25
|
||||||
|
AddStep("Move mouse to 0.25x", () => InputManager.MoveMouseTo(new Vector2(scrollQuad.TopLeft.X + 0.25f * scrollQuad.Size.X, scrollQuad.Centre.Y)));
|
||||||
|
AddStep("Press ctrl", () => InputManager.PressKey(Key.LControl));
|
||||||
|
AddStep("Scroll by 1", () => InputManager.ScrollBy(new Vector2(1, 0)));
|
||||||
|
AddStep("Release ctrl", () => InputManager.ReleaseKey(Key.LControl));
|
||||||
|
|
||||||
|
// Scroll in at 0.6
|
||||||
|
AddStep("Move mouse to 0.75x", () => InputManager.MoveMouseTo(new Vector2(scrollQuad.TopLeft.X + 0.75f * scrollQuad.Size.X, scrollQuad.Centre.Y)));
|
||||||
|
AddStep("Press ctrl", () => InputManager.PressKey(Key.LControl));
|
||||||
|
AddStep("Scroll by 1", () => InputManager.ScrollBy(new Vector2(1, 0)));
|
||||||
|
AddStep("Release ctrl", () => InputManager.ReleaseKey(Key.LControl));
|
||||||
|
AddAssert("Box not at 0", () => !Precision.AlmostEquals(boxQuad.TopLeft, scrollQuad.TopLeft));
|
||||||
|
|
||||||
|
// Very hard to determine actual position, so approximate
|
||||||
|
AddAssert("Box at correct position (1)", () => Precision.DefinitelyBigger(scrollQuad.TopLeft.X + 0.25f * scrollQuad.Size.X, boxQuad.TopLeft.X + 0.25f * boxQuad.Size.X));
|
||||||
|
AddAssert("Box at correct position (2)", () => Precision.DefinitelyBigger(scrollQuad.TopLeft.X + 0.6f * scrollQuad.Size.X, boxQuad.TopLeft.X + 0.3f * boxQuad.Size.X));
|
||||||
|
AddAssert("Box at correct position (3)", () => Precision.DefinitelyBigger(boxQuad.TopLeft.X + 0.6f * boxQuad.Size.X, scrollQuad.TopLeft.X + 0.6f * scrollQuad.Size.X));
|
||||||
|
|
||||||
|
// Scroll out at 0.6
|
||||||
|
AddStep("Press ctrl", () => InputManager.PressKey(Key.LControl));
|
||||||
|
AddStep("Scroll by -1", () => InputManager.ScrollBy(new Vector2(-1, 0)));
|
||||||
|
AddStep("Release ctrl", () => InputManager.ReleaseKey(Key.LControl));
|
||||||
|
|
||||||
|
// Scroll out at 0.25
|
||||||
|
AddStep("Move mouse to 0.25x", () => InputManager.MoveMouseTo(new Vector2(scrollQuad.TopLeft.X + 0.25f * scrollQuad.Size.X, scrollQuad.Centre.Y)));
|
||||||
|
AddStep("Press ctrl", () => InputManager.PressKey(Key.LControl));
|
||||||
|
AddStep("Scroll by -1", () => InputManager.ScrollBy(new Vector2(-1, 0)));
|
||||||
|
AddStep("Release ctrl", () => InputManager.ReleaseKey(Key.LControl));
|
||||||
|
AddAssert("Box at 0", () => Precision.AlmostEquals(boxQuad.TopLeft, scrollQuad.TopLeft));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reset()
|
||||||
|
{
|
||||||
|
AddStep("Reset", () =>
|
||||||
|
{
|
||||||
|
scrollContainer.Zoom = 0;
|
||||||
|
scrollContainer.ScrollTo(0, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private Quad scrollQuad => scrollContainer.ScreenSpaceDrawQuad;
|
||||||
|
private Quad boxQuad => innerBox.ScreenSpaceDrawQuad;
|
||||||
|
}
|
||||||
|
}
|
84
osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs
Normal file
84
osu.Game/Beatmaps/Drawables/BeatmapSetDownloader.cs
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Beatmaps.Drawables
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A component to allow downloading of a beatmap set. Automatically handles state syncing between other instances.
|
||||||
|
/// </summary>
|
||||||
|
public class BeatmapSetDownloader : Component
|
||||||
|
{
|
||||||
|
private readonly BeatmapSetInfo set;
|
||||||
|
private readonly bool noVideo;
|
||||||
|
|
||||||
|
private BeatmapManager beatmaps;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the associated beatmap set has been downloading (by this instance or any other instance).
|
||||||
|
/// </summary>
|
||||||
|
public readonly BindableBool Downloaded = new BindableBool();
|
||||||
|
|
||||||
|
public BeatmapSetDownloader(BeatmapSetInfo set, bool noVideo = false)
|
||||||
|
{
|
||||||
|
this.set = set;
|
||||||
|
this.noVideo = noVideo;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(BeatmapManager beatmaps)
|
||||||
|
{
|
||||||
|
this.beatmaps = beatmaps;
|
||||||
|
|
||||||
|
beatmaps.ItemAdded += setAdded;
|
||||||
|
beatmaps.ItemRemoved += setRemoved;
|
||||||
|
|
||||||
|
// initial value
|
||||||
|
if (set.OnlineBeatmapSetID != null)
|
||||||
|
Downloaded.Value = beatmaps.QueryBeatmapSets(s => s.OnlineBeatmapSetID == set.OnlineBeatmapSetID && !s.DeletePending).Any();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
|
if (beatmaps != null)
|
||||||
|
{
|
||||||
|
beatmaps.ItemAdded -= setAdded;
|
||||||
|
beatmaps.ItemRemoved -= setRemoved;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Begin downloading the associated beatmap set.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True if downloading began. False if an existing download is active or completed.</returns>
|
||||||
|
public bool Download()
|
||||||
|
{
|
||||||
|
if (Downloaded.Value)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (beatmaps.GetExistingDownload(set) != null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
beatmaps.Download(set, noVideo);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAdded(BeatmapSetInfo s)
|
||||||
|
{
|
||||||
|
if (s.OnlineBeatmapSetID == set.OnlineBeatmapSetID)
|
||||||
|
Downloaded.Value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setRemoved(BeatmapSetInfo s)
|
||||||
|
{
|
||||||
|
if (s.OnlineBeatmapSetID == set.OnlineBeatmapSetID)
|
||||||
|
Downloaded.Value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ using osu.Framework.Configuration;
|
|||||||
using osu.Framework.Configuration.Tracking;
|
using osu.Framework.Configuration.Tracking;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
|
|
||||||
namespace osu.Game.Configuration
|
namespace osu.Game.Configuration
|
||||||
@ -80,6 +81,8 @@ namespace osu.Game.Configuration
|
|||||||
|
|
||||||
Set(OsuSetting.FloatingComments, false);
|
Set(OsuSetting.FloatingComments, false);
|
||||||
|
|
||||||
|
Set(OsuSetting.ScoreDisplayMode, ScoringMode.Standardised);
|
||||||
|
|
||||||
Set(OsuSetting.SpeedChangeVisualisation, SpeedChangeVisualisationMethod.Sequential);
|
Set(OsuSetting.SpeedChangeVisualisation, SpeedChangeVisualisationMethod.Sequential);
|
||||||
|
|
||||||
Set(OsuSetting.IncreaseFirstObjectVisibility, true);
|
Set(OsuSetting.IncreaseFirstObjectVisibility, true);
|
||||||
@ -147,6 +150,7 @@ namespace osu.Game.Configuration
|
|||||||
SongSelectRightMouseScroll,
|
SongSelectRightMouseScroll,
|
||||||
BeatmapSkins,
|
BeatmapSkins,
|
||||||
BeatmapHitsounds,
|
BeatmapHitsounds,
|
||||||
IncreaseFirstObjectVisibility
|
IncreaseFirstObjectVisibility,
|
||||||
|
ScoreDisplayMode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.Drawables;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
@ -11,10 +13,11 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
|
|||||||
{
|
{
|
||||||
public class DownloadButton : HeaderButton
|
public class DownloadButton : HeaderButton
|
||||||
{
|
{
|
||||||
public DownloadButton(string title, string subtitle)
|
public DownloadButton(BeatmapSetInfo set, bool noVideo = false)
|
||||||
{
|
{
|
||||||
Width = 120;
|
Width = 120;
|
||||||
|
|
||||||
|
BeatmapSetDownloader downloader;
|
||||||
Add(new Container
|
Add(new Container
|
||||||
{
|
{
|
||||||
Depth = -1,
|
Depth = -1,
|
||||||
@ -22,6 +25,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
|
|||||||
Padding = new MarginPadding { Horizontal = 10 },
|
Padding = new MarginPadding { Horizontal = 10 },
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
|
downloader = new BeatmapSetDownloader(set, noVideo),
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
@ -32,13 +36,13 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
|
|||||||
{
|
{
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = title,
|
Text = "Download",
|
||||||
TextSize = 13,
|
TextSize = 13,
|
||||||
Font = @"Exo2.0-Bold",
|
Font = @"Exo2.0-Bold",
|
||||||
},
|
},
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = subtitle,
|
Text = set.OnlineInfo.HasVideo && noVideo ? "without Video" : string.Empty,
|
||||||
TextSize = 11,
|
TextSize = 11,
|
||||||
Font = @"Exo2.0-Bold",
|
Font = @"Exo2.0-Bold",
|
||||||
},
|
},
|
||||||
@ -54,6 +58,25 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Action = () =>
|
||||||
|
{
|
||||||
|
if (!downloader.Download())
|
||||||
|
{
|
||||||
|
Content.MoveToX(-5, 50, Easing.OutSine).Then()
|
||||||
|
.MoveToX(5, 100, Easing.InOutSine).Then()
|
||||||
|
.MoveToX(-5, 100, Easing.InOutSine).Then()
|
||||||
|
.MoveToX(0, 50, Easing.InSine);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
downloader.Downloaded.ValueChanged += d =>
|
||||||
|
{
|
||||||
|
if (d)
|
||||||
|
this.FadeOut(200);
|
||||||
|
else
|
||||||
|
this.FadeIn(200);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,6 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
private readonly BeatmapSetOnlineStatusPill onlineStatusPill;
|
private readonly BeatmapSetOnlineStatusPill onlineStatusPill;
|
||||||
public Details Details;
|
public Details Details;
|
||||||
|
|
||||||
private BeatmapManager beatmaps;
|
|
||||||
|
|
||||||
public readonly BeatmapPicker Picker;
|
public readonly BeatmapPicker Picker;
|
||||||
|
|
||||||
private BeatmapSetInfo beatmapSet;
|
private BeatmapSetInfo beatmapSet;
|
||||||
@ -68,8 +66,24 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
downloadButtonsContainer.FadeIn(transition_duration);
|
downloadButtonsContainer.FadeIn(transition_duration);
|
||||||
favouriteButton.FadeIn(transition_duration);
|
favouriteButton.FadeIn(transition_duration);
|
||||||
|
|
||||||
noVideoButtons.FadeTo(BeatmapSet.OnlineInfo.HasVideo ? 0 : 1, transition_duration);
|
if (BeatmapSet.OnlineInfo.HasVideo)
|
||||||
videoButtons.FadeTo(BeatmapSet.OnlineInfo.HasVideo ? 1 : 0, transition_duration);
|
{
|
||||||
|
videoButtons.Children = new[]
|
||||||
|
{
|
||||||
|
new DownloadButton(BeatmapSet),
|
||||||
|
new DownloadButton(BeatmapSet, true),
|
||||||
|
};
|
||||||
|
|
||||||
|
videoButtons.FadeIn(transition_duration);
|
||||||
|
noVideoButtons.FadeOut(transition_duration);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
noVideoButtons.Child = new DownloadButton(BeatmapSet);
|
||||||
|
|
||||||
|
noVideoButtons.FadeIn(transition_duration);
|
||||||
|
videoButtons.FadeOut(transition_duration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -192,27 +206,12 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Alpha = 0f,
|
Alpha = 0f,
|
||||||
Child = new DownloadButton("Download", @"")
|
|
||||||
{
|
|
||||||
Action = () => download(false),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
videoButtons = new FillFlowContainer
|
videoButtons = new FillFlowContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Spacing = new Vector2(buttons_spacing),
|
Spacing = new Vector2(buttons_spacing),
|
||||||
Alpha = 0f,
|
Alpha = 0f,
|
||||||
Children = new[]
|
|
||||||
{
|
|
||||||
new DownloadButton("Download", "with Video")
|
|
||||||
{
|
|
||||||
Action = () => download(false),
|
|
||||||
},
|
|
||||||
new DownloadButton("Download", "without Video")
|
|
||||||
{
|
|
||||||
Action = () => download(true),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -248,41 +247,10 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, BeatmapManager beatmaps)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
tabsBg.Colour = colours.Gray3;
|
tabsBg.Colour = colours.Gray3;
|
||||||
this.beatmaps = beatmaps;
|
|
||||||
|
|
||||||
beatmaps.ItemAdded += handleBeatmapAdd;
|
|
||||||
|
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
|
||||||
{
|
|
||||||
base.Dispose(isDisposing);
|
|
||||||
if (beatmaps != null) beatmaps.ItemAdded -= handleBeatmapAdd;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleBeatmapAdd(BeatmapSetInfo beatmap) => Schedule(() =>
|
|
||||||
{
|
|
||||||
if (beatmap.OnlineBeatmapSetID == BeatmapSet?.OnlineBeatmapSetID)
|
|
||||||
downloadButtonsContainer.FadeOut(transition_duration);
|
|
||||||
});
|
|
||||||
|
|
||||||
private void download(bool noVideo)
|
|
||||||
{
|
|
||||||
if (beatmaps.GetExistingDownload(BeatmapSet) != null)
|
|
||||||
{
|
|
||||||
downloadButtonsContainer.MoveToX(-5, 50, Easing.OutSine).Then()
|
|
||||||
.MoveToX(5, 100, Easing.InOutSine).Then()
|
|
||||||
.MoveToX(-5, 100, Easing.InOutSine).Then()
|
|
||||||
.MoveToX(0, 50, Easing.InSine).Then();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
beatmaps.Download(BeatmapSet, noVideo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,14 +166,13 @@ namespace osu.Game.Overlays.Direct
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new DownloadButton
|
new DownloadButton(SetInfo)
|
||||||
{
|
{
|
||||||
Size = new Vector2(30),
|
Size = new Vector2(30),
|
||||||
Margin = new MarginPadding(horizontal_padding),
|
Margin = new MarginPadding(horizontal_padding),
|
||||||
Anchor = Anchor.CentreRight,
|
Anchor = Anchor.CentreRight,
|
||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
Colour = colours.Gray5,
|
Colour = colours.Gray5,
|
||||||
Action = StartDownload
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -12,28 +12,31 @@ using osu.Game.Graphics.Sprites;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Input;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Direct
|
namespace osu.Game.Overlays.Direct
|
||||||
{
|
{
|
||||||
public class DirectListPanel : DirectPanel
|
public class DirectListPanel : DirectPanel
|
||||||
{
|
{
|
||||||
|
private const float transition_duration = 120;
|
||||||
private const float horizontal_padding = 10;
|
private const float horizontal_padding = 10;
|
||||||
private const float vertical_padding = 5;
|
private const float vertical_padding = 5;
|
||||||
private const float height = 70;
|
private const float height = 70;
|
||||||
|
|
||||||
|
private PlayButton playButton;
|
||||||
|
private Box progressBar;
|
||||||
|
private Container downloadContainer;
|
||||||
|
|
||||||
|
protected override PlayButton PlayButton => playButton;
|
||||||
|
protected override Box PreviewBar => progressBar;
|
||||||
|
|
||||||
public DirectListPanel(BeatmapSetInfo beatmap) : base(beatmap)
|
public DirectListPanel(BeatmapSetInfo beatmap) : base(beatmap)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
Height = height;
|
Height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayButton playButton;
|
|
||||||
private Box progressBar;
|
|
||||||
|
|
||||||
protected override PlayButton PlayButton => playButton;
|
|
||||||
protected override Box PreviewBar => progressBar;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(LocalisationEngine localisation, OsuColour colours)
|
private void load(LocalisationEngine localisation, OsuColour colours)
|
||||||
{
|
{
|
||||||
@ -59,7 +62,7 @@ namespace osu.Game.Overlays.Direct
|
|||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Horizontal,
|
||||||
LayoutEasing = Easing.OutQuint,
|
LayoutEasing = Easing.OutQuint,
|
||||||
LayoutDuration = 120,
|
LayoutDuration = transition_duration,
|
||||||
Spacing = new Vector2(10, 0),
|
Spacing = new Vector2(10, 0),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -104,53 +107,69 @@ namespace osu.Game.Overlays.Direct
|
|||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Horizontal,
|
||||||
Margin = new MarginPadding { Right = height - vertical_padding * 2 + vertical_padding },
|
LayoutEasing = Easing.OutQuint,
|
||||||
|
LayoutDuration = transition_duration,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Statistic(FontAwesome.fa_play_circle, SetInfo.OnlineInfo?.PlayCount ?? 0)
|
downloadContainer = new Container
|
||||||
{
|
{
|
||||||
Margin = new MarginPadding { Right = 1 },
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0,
|
||||||
|
Child = new DownloadButton(SetInfo)
|
||||||
|
{
|
||||||
|
Size = new Vector2(height - vertical_padding * 2),
|
||||||
|
Margin = new MarginPadding { Left = vertical_padding },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
new Statistic(FontAwesome.fa_heart, SetInfo.OnlineInfo?.FavouriteCount ?? 0),
|
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Vertical,
|
||||||
Children = new[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new OsuSpriteText
|
new Statistic(FontAwesome.fa_play_circle, SetInfo.OnlineInfo?.PlayCount ?? 0)
|
||||||
{
|
{
|
||||||
Text = "mapped by ",
|
Margin = new MarginPadding { Right = 1 },
|
||||||
TextSize = 14,
|
},
|
||||||
|
new Statistic(FontAwesome.fa_heart, SetInfo.OnlineInfo?.FavouriteCount ?? 0),
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = "mapped by ",
|
||||||
|
TextSize = 14,
|
||||||
|
},
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = SetInfo.Metadata.Author.Username,
|
||||||
|
TextSize = 14,
|
||||||
|
Font = @"Exo2.0-SemiBoldItalic",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = SetInfo.Metadata.Author.Username,
|
Text = $"from {SetInfo.Metadata.Source}",
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
TextSize = 14,
|
TextSize = 14,
|
||||||
Font = @"Exo2.0-SemiBoldItalic",
|
Alpha = string.IsNullOrEmpty(SetInfo.Metadata.Source) ? 0f : 1f,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new OsuSpriteText
|
|
||||||
{
|
|
||||||
Text = $"from {SetInfo.Metadata.Source}",
|
|
||||||
Anchor = Anchor.TopRight,
|
|
||||||
Origin = Anchor.TopRight,
|
|
||||||
TextSize = 14,
|
|
||||||
Alpha = string.IsNullOrEmpty(SetInfo.Metadata.Source) ? 0f : 1f,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new DownloadButton
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopRight,
|
|
||||||
Origin = Anchor.TopRight,
|
|
||||||
Size = new Vector2(height - vertical_padding * 2),
|
|
||||||
Action = StartDownload
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
progressBar = new Box
|
progressBar = new Box
|
||||||
@ -165,5 +184,17 @@ namespace osu.Game.Overlays.Direct
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnHover(InputState state)
|
||||||
|
{
|
||||||
|
downloadContainer.FadeIn(transition_duration, Easing.InOutQuint);
|
||||||
|
return base.OnHover(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnHoverLost(InputState state)
|
||||||
|
{
|
||||||
|
downloadContainer.FadeOut(transition_duration, Easing.InOutQuint);
|
||||||
|
base.OnHoverLost(state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,22 +147,6 @@ namespace osu.Game.Overlays.Direct
|
|||||||
|
|
||||||
protected void ShowInformation() => beatmapSetOverlay?.ShowBeatmapSet(SetInfo);
|
protected void ShowInformation() => beatmapSetOverlay?.ShowBeatmapSet(SetInfo);
|
||||||
|
|
||||||
protected void StartDownload()
|
|
||||||
{
|
|
||||||
if (beatmaps.GetExistingDownload(SetInfo) != null)
|
|
||||||
{
|
|
||||||
// we already have an active download running.
|
|
||||||
content.MoveToX(-5, 50, Easing.OutSine).Then()
|
|
||||||
.MoveToX(5, 100, Easing.InOutSine).Then()
|
|
||||||
.MoveToX(-5, 100, Easing.InOutSine).Then()
|
|
||||||
.MoveToX(0, 50, Easing.InSine).Then();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
beatmaps.Download(SetInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void attachDownload(DownloadBeatmapSetRequest request)
|
private void attachDownload(DownloadBeatmapSetRequest request)
|
||||||
{
|
{
|
||||||
if (request.BeatmapSet.OnlineBeatmapSetID != SetInfo.OnlineBeatmapSetID)
|
if (request.BeatmapSet.OnlineBeatmapSetID != SetInfo.OnlineBeatmapSetID)
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.Drawables;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
@ -13,10 +15,12 @@ namespace osu.Game.Overlays.Direct
|
|||||||
{
|
{
|
||||||
private readonly SpriteIcon icon;
|
private readonly SpriteIcon icon;
|
||||||
|
|
||||||
public DownloadButton()
|
public DownloadButton(BeatmapSetInfo set, bool noVideo = false)
|
||||||
{
|
{
|
||||||
|
BeatmapSetDownloader downloader;
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
|
downloader = new BeatmapSetDownloader(set, noVideo),
|
||||||
icon = new SpriteIcon
|
icon = new SpriteIcon
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
@ -25,6 +29,25 @@ namespace osu.Game.Overlays.Direct
|
|||||||
Icon = FontAwesome.fa_osu_chevron_down_o,
|
Icon = FontAwesome.fa_osu_chevron_down_o,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Action = () =>
|
||||||
|
{
|
||||||
|
if (!downloader.Download())
|
||||||
|
{
|
||||||
|
Content.MoveToX(-5, 50, Easing.OutSine).Then()
|
||||||
|
.MoveToX(5, 100, Easing.InOutSine).Then()
|
||||||
|
.MoveToX(-5, 100, Easing.InOutSine).Then()
|
||||||
|
.MoveToX(0, 50, Easing.InSine);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
downloader.Downloaded.ValueChanged += d =>
|
||||||
|
{
|
||||||
|
if (d)
|
||||||
|
this.FadeOut(200);
|
||||||
|
else
|
||||||
|
this.FadeIn(200);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||||
|
@ -28,7 +28,6 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private APIAccess api;
|
private APIAccess api;
|
||||||
private RulesetStore rulesets;
|
private RulesetStore rulesets;
|
||||||
private BeatmapManager beatmaps;
|
|
||||||
|
|
||||||
private readonly FillFlowContainer resultCountsContainer;
|
private readonly FillFlowContainer resultCountsContainer;
|
||||||
private readonly OsuSpriteText resultCountsText;
|
private readonly OsuSpriteText resultCountsText;
|
||||||
@ -177,24 +176,14 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, APIAccess api, RulesetStore rulesets, BeatmapManager beatmaps)
|
private void load(OsuColour colours, APIAccess api, RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.rulesets = rulesets;
|
this.rulesets = rulesets;
|
||||||
this.beatmaps = beatmaps;
|
|
||||||
|
|
||||||
resultCountsContainer.Colour = colours.Yellow;
|
resultCountsContainer.Colour = colours.Yellow;
|
||||||
|
|
||||||
beatmaps.ItemAdded += setAdded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setAdded(BeatmapSetInfo set) => Schedule(() =>
|
|
||||||
{
|
|
||||||
// if a new map was imported, we should remove it from search results (download completed etc.)
|
|
||||||
panels?.FirstOrDefault(p => p.SetInfo.OnlineBeatmapSetID == set.OnlineBeatmapSetID)?.FadeOut(400).Expire();
|
|
||||||
BeatmapSets = BeatmapSets?.Where(b => b.OnlineBeatmapSetID != set.OnlineBeatmapSetID);
|
|
||||||
});
|
|
||||||
|
|
||||||
private void updateResultCounts()
|
private void updateResultCounts()
|
||||||
{
|
{
|
||||||
resultCountsContainer.FadeTo(ResultAmounts == null ? 0f : 1f, 200, Easing.OutQuint);
|
resultCountsContainer.FadeTo(ResultAmounts == null ? 0f : 1f, 200, Easing.OutQuint);
|
||||||
@ -297,9 +286,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
var onlineIds = response.Select(r => r.OnlineBeatmapSetID).ToList();
|
var sets = response.Select(r => r.ToBeatmapSet(rulesets)).ToList();
|
||||||
var presentOnlineIds = beatmaps.QueryBeatmapSets(s => onlineIds.Contains(s.OnlineBeatmapSetID) && !s.DeletePending).Select(r => r.OnlineBeatmapSetID).ToList();
|
|
||||||
var sets = response.Select(r => r.ToBeatmapSet(rulesets)).Where(b => !presentOnlineIds.Contains(b.OnlineBeatmapSetID)).ToList();
|
|
||||||
|
|
||||||
// may not need scheduling; loads async internally.
|
// may not need scheduling; loads async internally.
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
@ -323,14 +310,6 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private int distinctCount(List<string> list) => list.Distinct().ToArray().Length;
|
private int distinctCount(List<string> list) => list.Distinct().ToArray().Length;
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
|
||||||
{
|
|
||||||
base.Dispose(isDisposing);
|
|
||||||
|
|
||||||
if (beatmaps != null)
|
|
||||||
beatmaps.ItemAdded -= setAdded;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ResultCounts
|
public class ResultCounts
|
||||||
{
|
{
|
||||||
public readonly int Artists;
|
public readonly int Artists;
|
||||||
|
@ -107,13 +107,20 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
visibleBadge = 0;
|
visibleBadge = 0;
|
||||||
|
|
||||||
badgeFlowContainer.Clear();
|
badgeFlowContainer.Clear();
|
||||||
foreach (var badge in badges)
|
for (var index = 0; index < badges.Length; index++)
|
||||||
{
|
{
|
||||||
LoadComponentAsync(new DrawableBadge(badge)
|
int displayIndex = index;
|
||||||
|
LoadComponentAsync(new DrawableBadge(badges[index])
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
}, badgeFlowContainer.Add);
|
}, asyncBadge =>
|
||||||
|
{
|
||||||
|
badgeFlowContainer.Add(asyncBadge);
|
||||||
|
|
||||||
|
// load in stable order regardless of async load order.
|
||||||
|
badgeFlowContainer.SetLayoutPosition(asyncBadge, displayIndex);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||||
{
|
{
|
||||||
@ -38,6 +39,11 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
|||||||
LabelText = "Always show key overlay",
|
LabelText = "Always show key overlay",
|
||||||
Bindable = config.GetBindable<bool>(OsuSetting.KeyOverlay)
|
Bindable = config.GetBindable<bool>(OsuSetting.KeyOverlay)
|
||||||
},
|
},
|
||||||
|
new SettingsEnumDropdown<ScoringMode>
|
||||||
|
{
|
||||||
|
LabelText = "Score display mode",
|
||||||
|
Bindable = config.GetBindable<ScoringMode>(OsuSetting.ScoreDisplayMode)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,9 +167,25 @@ namespace osu.Game.Overlays.Volume
|
|||||||
private set => Bindable.Value = value;
|
private set => Bindable.Value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Increase() => Volume += 0.05f;
|
private const float adjust_step = 0.05f;
|
||||||
|
|
||||||
public void Decrease() => Volume -= 0.05f;
|
public void Increase() => adjust(1);
|
||||||
|
public void Decrease() => adjust(-1);
|
||||||
|
|
||||||
|
private void adjust(int direction)
|
||||||
|
{
|
||||||
|
float amount = adjust_step * direction;
|
||||||
|
|
||||||
|
var mouse = GetContainingInputManager().CurrentState.Mouse;
|
||||||
|
if (mouse.HasPreciseScroll)
|
||||||
|
{
|
||||||
|
float scrollDelta = mouse.ScrollDelta.Y;
|
||||||
|
if (scrollDelta != 0)
|
||||||
|
amount *= Math.Abs(scrollDelta / 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
Volume += amount;
|
||||||
|
}
|
||||||
|
|
||||||
public bool OnPressed(GlobalAction action)
|
public bool OnPressed(GlobalAction action)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
@ -36,6 +37,44 @@ namespace osu.Game.Rulesets.Difficulty
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates all <see cref="Mod"/> combinations which adjust the <see cref="Beatmap"/> difficulty.
|
||||||
|
/// </summary>
|
||||||
|
public Mod[] CreateDifficultyAdjustmentModCombinations()
|
||||||
|
{
|
||||||
|
return createDifficultyAdjustmentModCombinations(Enumerable.Empty<Mod>(), DifficultyAdjustmentMods).ToArray();
|
||||||
|
|
||||||
|
IEnumerable<Mod> createDifficultyAdjustmentModCombinations(IEnumerable<Mod> currentSet, Mod[] adjustmentSet, int currentSetCount = 0, int adjustmentSetStart = 0)
|
||||||
|
{
|
||||||
|
// Initial-case: Empty current set
|
||||||
|
if (currentSetCount == 0)
|
||||||
|
yield return new NoModMod();
|
||||||
|
|
||||||
|
if (currentSetCount == 1)
|
||||||
|
yield return currentSet.Single();
|
||||||
|
|
||||||
|
if (currentSetCount > 1)
|
||||||
|
yield return new MultiMod(currentSet.ToArray());
|
||||||
|
|
||||||
|
// Apply mods in the adjustment set recursively. Using the entire adjustment set would result in duplicate multi-mod mod
|
||||||
|
// combinations in further recursions, so a moving subset is used to eliminate this effect
|
||||||
|
for (int i = adjustmentSetStart; i < adjustmentSet.Length; i++)
|
||||||
|
{
|
||||||
|
var adjustmentMod = adjustmentSet[i];
|
||||||
|
if (currentSet.Any(c => c.IncompatibleMods.Any(m => m.IsInstanceOfType(adjustmentMod))))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach (var combo in createDifficultyAdjustmentModCombinations(currentSet.Append(adjustmentMod), adjustmentSet, currentSetCount + 1, i + 1))
|
||||||
|
yield return combo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves all <see cref="Mod"/>s which adjust the <see cref="Beatmap"/> difficulty.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual Mod[] DifficultyAdjustmentMods => Array.Empty<Mod>();
|
||||||
|
|
||||||
public abstract double Calculate(Dictionary<string, double> categoryDifficulty = null);
|
public abstract double Calculate(Dictionary<string, double> categoryDifficulty = null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
|
|
||||||
public virtual void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
|
public virtual void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
|
||||||
{
|
{
|
||||||
// todo: fix ordering of objects so we don't have to do this (#2740).
|
foreach (var d in drawables.Skip(IncreaseFirstObjectVisibility ? 1 : 0))
|
||||||
foreach (var d in drawables.Reverse().Skip(IncreaseFirstObjectVisibility ? 1 : 0))
|
|
||||||
d.ApplyCustomUpdateState += ApplyHiddenState;
|
d.ApplyCustomUpdateState += ApplyHiddenState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
{
|
{
|
||||||
DifficultyReduction,
|
DifficultyReduction,
|
||||||
DifficultyIncrease,
|
DifficultyIncrease,
|
||||||
Special,
|
Special
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mods
|
namespace osu.Game.Rulesets.Mods
|
||||||
{
|
{
|
||||||
public class MultiMod : Mod
|
public class MultiMod : Mod
|
||||||
@ -10,6 +13,13 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
public override string Description => string.Empty;
|
public override string Description => string.Empty;
|
||||||
public override double ScoreMultiplier => 0;
|
public override double ScoreMultiplier => 0;
|
||||||
|
|
||||||
public Mod[] Mods;
|
public Mod[] Mods { get; }
|
||||||
|
|
||||||
|
public MultiMod(params Mod[] mods)
|
||||||
|
{
|
||||||
|
Mods = mods;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Type[] IncompatibleMods => Mods.SelectMany(m => m.IncompatibleMods).ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
osu.Game/Rulesets/Mods/NoModMod.cs
Normal file
15
osu.Game/Rulesets/Mods/NoModMod.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright (c) 2007-2018 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>
|
||||||
|
/// Indicates a type of mod that doesn't do anything.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class NoModMod : Mod
|
||||||
|
{
|
||||||
|
public override string Name => "No Mod";
|
||||||
|
public override string ShortenedName => "NM";
|
||||||
|
public override double ScoreMultiplier => 1;
|
||||||
|
}
|
||||||
|
}
|
@ -65,6 +65,11 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly BindableInt HighestCombo = new BindableInt();
|
public readonly BindableInt HighestCombo = new BindableInt();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The <see cref="ScoringMode"/> used to calculate scores.
|
||||||
|
/// </summary>
|
||||||
|
public readonly Bindable<ScoringMode> Mode = new Bindable<ScoringMode>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether all <see cref="Judgement"/>s have been processed.
|
/// Whether all <see cref="Judgement"/>s have been processed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -169,8 +174,6 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
private const double combo_portion = 0.7;
|
private const double combo_portion = 0.7;
|
||||||
private const double max_score = 1000000;
|
private const double max_score = 1000000;
|
||||||
|
|
||||||
public readonly Bindable<ScoringMode> Mode = new Bindable<ScoringMode>();
|
|
||||||
|
|
||||||
protected sealed override bool HasCompleted => JudgedHits == MaxHits;
|
protected sealed override bool HasCompleted => JudgedHits == MaxHits;
|
||||||
|
|
||||||
protected int MaxHits { get; private set; }
|
protected int MaxHits { get; private set; }
|
||||||
@ -199,16 +202,18 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
|
|
||||||
if (maxBaseScore == 0 || maxHighestCombo == 0)
|
if (maxBaseScore == 0 || maxHighestCombo == 0)
|
||||||
{
|
{
|
||||||
Mode.Value = ScoringMode.Exponential;
|
Mode.Value = ScoringMode.Classic;
|
||||||
Mode.Disabled = true;
|
Mode.Disabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mode.ValueChanged += _ => updateScore();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Simulates an autoplay of <see cref="HitObject"/>s that will be judged by this <see cref="ScoreProcessor{TObject}"/>
|
/// Simulates an autoplay of <see cref="HitObject"/>s that will be judged by this <see cref="ScoreProcessor{TObject}"/>
|
||||||
/// by adding <see cref="Judgement"/>s for each <see cref="HitObject"/> in the <see cref="Beatmap{TObject}"/>.
|
/// by adding <see cref="Judgement"/>s for each <see cref="HitObject"/> in the <see cref="Beatmap{TObject}"/>.
|
||||||
/// <para>
|
/// <para>
|
||||||
/// This is required for <see cref="ScoringMode.Standardised"/> to work, otherwise <see cref="ScoringMode.Exponential"/> will be used.
|
/// This is required for <see cref="ScoringMode.Standardised"/> to work, otherwise <see cref="ScoringMode.Classic"/> will be used.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmap">The <see cref="Beatmap{TObject}"/> containing the <see cref="HitObject"/>s that will be judged by this <see cref="ScoreProcessor{TObject}"/>.</param>
|
/// <param name="beatmap">The <see cref="Beatmap{TObject}"/> containing the <see cref="HitObject"/>s that will be judged by this <see cref="ScoreProcessor{TObject}"/>.</param>
|
||||||
@ -295,8 +300,9 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
case ScoringMode.Standardised:
|
case ScoringMode.Standardised:
|
||||||
TotalScore.Value = max_score * (base_portion * baseScore / maxBaseScore + combo_portion * HighestCombo / maxHighestCombo) + bonusScore;
|
TotalScore.Value = max_score * (base_portion * baseScore / maxBaseScore + combo_portion * HighestCombo / maxHighestCombo) + bonusScore;
|
||||||
break;
|
break;
|
||||||
case ScoringMode.Exponential:
|
case ScoringMode.Classic:
|
||||||
TotalScore.Value = (baseScore + bonusScore) * Math.Log(HighestCombo + 1, 2);
|
// should emulate osu-stable's scoring as closely as we can (https://osu.ppy.sh/help/wiki/Score/ScoreV1)
|
||||||
|
TotalScore.Value = bonusScore + baseScore * (1 + Math.Max(0, HighestCombo - 1) / 25);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,6 +328,6 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
public enum ScoringMode
|
public enum ScoringMode
|
||||||
{
|
{
|
||||||
Standardised,
|
Standardised,
|
||||||
Exponential
|
Classic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ namespace osu.Game.Rulesets.UI
|
|||||||
{
|
{
|
||||||
public class HitObjectContainer : CompositeDrawable
|
public class HitObjectContainer : CompositeDrawable
|
||||||
{
|
{
|
||||||
public virtual IEnumerable<DrawableHitObject> Objects => InternalChildren.Cast<DrawableHitObject>();
|
public IEnumerable<DrawableHitObject> Objects => InternalChildren.Cast<DrawableHitObject>().OrderBy(h => h.HitObject.StartTime);
|
||||||
public virtual IEnumerable<DrawableHitObject> AliveObjects => AliveInternalChildren.Cast<DrawableHitObject>();
|
public IEnumerable<DrawableHitObject> AliveObjects => AliveInternalChildren.Cast<DrawableHitObject>().OrderBy(h => h.HitObject.StartTime);
|
||||||
|
|
||||||
public virtual void Add(DrawableHitObject hitObject) => AddInternal(hitObject);
|
public virtual void Add(DrawableHitObject hitObject) => AddInternal(hitObject);
|
||||||
public virtual bool Remove(DrawableHitObject hitObject) => RemoveInternal(hitObject);
|
public virtual bool Remove(DrawableHitObject hitObject) => RemoveInternal(hitObject);
|
||||||
|
@ -121,6 +121,8 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private bool validState;
|
private bool validState;
|
||||||
|
|
||||||
|
protected override bool RequiresChildrenUpdate => base.RequiresChildrenUpdate && validState;
|
||||||
|
|
||||||
private bool isAttached => replayInputHandler != null && !UseParentState;
|
private bool isAttached => replayInputHandler != null && !UseParentState;
|
||||||
|
|
||||||
private const int max_catch_up_updates_per_frame = 50;
|
private const int max_catch_up_updates_per_frame = 50;
|
||||||
|
@ -64,7 +64,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding { Right = 5 },
|
Padding = new MarginPadding { Right = 5 },
|
||||||
Child = new ScrollableTimeline { RelativeSizeAxes = Axes.Both }
|
Child = new TimelineArea { RelativeSizeAxes = Axes.Both }
|
||||||
},
|
},
|
||||||
new BeatDivisorControl(beatDivisor) { RelativeSizeAxes = Axes.Both }
|
new BeatDivisorControl(beatDivisor) { RelativeSizeAxes = Axes.Both }
|
||||||
},
|
},
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
// Copyright (c) 2007-2018 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.Framework.Graphics.Audio;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Screens.Compose.Timeline
|
|
||||||
{
|
|
||||||
public class BeatmapWaveformGraph : CompositeDrawable
|
|
||||||
{
|
|
||||||
public WorkingBeatmap Beatmap { set => graph.Waveform = value.Waveform; }
|
|
||||||
|
|
||||||
private readonly WaveformGraph graph;
|
|
||||||
|
|
||||||
public BeatmapWaveformGraph()
|
|
||||||
{
|
|
||||||
InternalChild = graph = new WaveformGraph { RelativeSizeAxes = Axes.Both };
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the <see cref="WaveformGraph.Resolution"/>.
|
|
||||||
/// </summary>
|
|
||||||
public float Resolution
|
|
||||||
{
|
|
||||||
get { return graph.Resolution; }
|
|
||||||
set { graph.Resolution = value; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,126 +0,0 @@
|
|||||||
// Copyright (c) 2007-2018 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.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Graphics.UserInterface;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Screens.Compose.Timeline
|
|
||||||
{
|
|
||||||
public class ScrollableTimeline : CompositeDrawable
|
|
||||||
{
|
|
||||||
private readonly ScrollingTimelineContainer timelineContainer;
|
|
||||||
|
|
||||||
public ScrollableTimeline()
|
|
||||||
{
|
|
||||||
Masking = true;
|
|
||||||
CornerRadius = 5;
|
|
||||||
|
|
||||||
OsuCheckbox hitObjectsCheckbox;
|
|
||||||
OsuCheckbox hitSoundsCheckbox;
|
|
||||||
OsuCheckbox waveformCheckbox;
|
|
||||||
InternalChildren = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = OsuColour.FromHex("111")
|
|
||||||
},
|
|
||||||
new FillFlowContainer
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Container
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.X,
|
|
||||||
RelativeSizeAxes = Axes.Y,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = OsuColour.FromHex("222")
|
|
||||||
},
|
|
||||||
new FillFlowContainer
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Width = 160,
|
|
||||||
Padding = new MarginPadding { Horizontal = 15 },
|
|
||||||
Direction = FillDirection.Vertical,
|
|
||||||
Spacing = new Vector2(0, 4),
|
|
||||||
Children = new[]
|
|
||||||
{
|
|
||||||
hitObjectsCheckbox = new OsuCheckbox { LabelText = "Hitobjects" },
|
|
||||||
hitSoundsCheckbox = new OsuCheckbox { LabelText = "Hitsounds" },
|
|
||||||
waveformCheckbox = new OsuCheckbox { LabelText = "Waveform" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Container
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.X,
|
|
||||||
RelativeSizeAxes = Axes.Y,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = OsuColour.FromHex("333")
|
|
||||||
},
|
|
||||||
new Container<TimelineButton>
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
RelativeSizeAxes = Axes.Y,
|
|
||||||
AutoSizeAxes = Axes.X,
|
|
||||||
Masking = true,
|
|
||||||
Children = new[]
|
|
||||||
{
|
|
||||||
new TimelineButton
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Y,
|
|
||||||
Height = 0.5f,
|
|
||||||
Icon = FontAwesome.fa_search_plus,
|
|
||||||
Action = () => timelineContainer.Zoom++
|
|
||||||
},
|
|
||||||
new TimelineButton
|
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomLeft,
|
|
||||||
Origin = Anchor.BottomLeft,
|
|
||||||
RelativeSizeAxes = Axes.Y,
|
|
||||||
Height = 0.5f,
|
|
||||||
Icon = FontAwesome.fa_search_minus,
|
|
||||||
Action = () => timelineContainer.Zoom--
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
timelineContainer = new ScrollingTimelineContainer { RelativeSizeAxes = Axes.Y }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
hitObjectsCheckbox.Current.Value = true;
|
|
||||||
hitSoundsCheckbox.Current.Value = true;
|
|
||||||
waveformCheckbox.Current.Value = true;
|
|
||||||
|
|
||||||
timelineContainer.WaveformVisible.BindTo(waveformCheckbox.Current);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
|
|
||||||
timelineContainer.Size = new Vector2(DrawSize.X - timelineContainer.DrawPosition.X, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,151 +0,0 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using OpenTK;
|
|
||||||
using osu.Framework.Configuration;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Input;
|
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Graphics;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Screens.Compose.Timeline
|
|
||||||
{
|
|
||||||
public class ScrollingTimelineContainer : ScrollContainer
|
|
||||||
{
|
|
||||||
public readonly Bindable<bool> HitObjectsVisible = new Bindable<bool>();
|
|
||||||
public readonly Bindable<bool> HitSoundsVisible = new Bindable<bool>();
|
|
||||||
public readonly Bindable<bool> WaveformVisible = new Bindable<bool>();
|
|
||||||
|
|
||||||
private readonly IBindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
|
||||||
|
|
||||||
private readonly BeatmapWaveformGraph waveform;
|
|
||||||
|
|
||||||
public ScrollingTimelineContainer()
|
|
||||||
: base(Direction.Horizontal)
|
|
||||||
{
|
|
||||||
Masking = true;
|
|
||||||
|
|
||||||
Add(waveform = new BeatmapWaveformGraph
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = OsuColour.FromHex("222"),
|
|
||||||
Depth = float.MaxValue
|
|
||||||
});
|
|
||||||
|
|
||||||
Content.AutoSizeAxes = Axes.None;
|
|
||||||
Content.RelativeSizeAxes = Axes.Both;
|
|
||||||
|
|
||||||
WaveformVisible.ValueChanged += waveformVisibilityChanged;
|
|
||||||
|
|
||||||
Zoom = 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(IBindableBeatmap beatmap)
|
|
||||||
{
|
|
||||||
this.beatmap.BindTo(beatmap);
|
|
||||||
this.beatmap.BindValueChanged(beatmapChanged, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void beatmapChanged(WorkingBeatmap beatmap) => waveform.Beatmap = beatmap;
|
|
||||||
|
|
||||||
private float minZoom = 1;
|
|
||||||
/// <summary>
|
|
||||||
/// The minimum zoom level allowed.
|
|
||||||
/// </summary>
|
|
||||||
public float MinZoom
|
|
||||||
{
|
|
||||||
get { return minZoom; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value <= 0)
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(value));
|
|
||||||
if (minZoom == value)
|
|
||||||
return;
|
|
||||||
minZoom = value;
|
|
||||||
|
|
||||||
// Update the zoom level
|
|
||||||
Zoom = Zoom;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private float maxZoom = 30;
|
|
||||||
/// <summary>
|
|
||||||
/// The maximum zoom level allowed.
|
|
||||||
/// </summary>
|
|
||||||
public float MaxZoom
|
|
||||||
{
|
|
||||||
get { return maxZoom; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value <= 0)
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(value));
|
|
||||||
if (maxZoom == value)
|
|
||||||
return;
|
|
||||||
maxZoom = value;
|
|
||||||
|
|
||||||
// Update the zoom level
|
|
||||||
Zoom = Zoom;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private float zoom = 1;
|
|
||||||
/// <summary>
|
|
||||||
/// The current zoom level.
|
|
||||||
/// </summary>
|
|
||||||
public float Zoom
|
|
||||||
{
|
|
||||||
get { return zoom; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
value = MathHelper.Clamp(value, MinZoom, MaxZoom);
|
|
||||||
if (zoom == value)
|
|
||||||
return;
|
|
||||||
zoom = value;
|
|
||||||
|
|
||||||
// Make the zoom target default to the center of the graph if it hasn't been set
|
|
||||||
if (relativeContentZoomTarget == null)
|
|
||||||
relativeContentZoomTarget = ToSpaceOfOtherDrawable(DrawSize / 2, Content).X / Content.DrawSize.X;
|
|
||||||
if (localZoomTarget == null)
|
|
||||||
localZoomTarget = DrawSize.X / 2;
|
|
||||||
|
|
||||||
Content.ResizeWidthTo(Zoom);
|
|
||||||
|
|
||||||
// Update the scroll position to focus on the zoom target
|
|
||||||
float scrollPos = Content.DrawSize.X * relativeContentZoomTarget.Value - localZoomTarget.Value;
|
|
||||||
ScrollTo(scrollPos, false);
|
|
||||||
|
|
||||||
relativeContentZoomTarget = null;
|
|
||||||
localZoomTarget = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Zoom target as a relative position in the <see cref="ScrollingTimelineContainer.Content"/> space.
|
|
||||||
/// </summary>
|
|
||||||
private float? relativeContentZoomTarget;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Zoom target as a position in our local space.
|
|
||||||
/// </summary>
|
|
||||||
private float? localZoomTarget;
|
|
||||||
|
|
||||||
protected override bool OnScroll(InputState state)
|
|
||||||
{
|
|
||||||
if (!state.Keyboard.ControlPressed)
|
|
||||||
return base.OnScroll(state);
|
|
||||||
|
|
||||||
relativeContentZoomTarget = Content.ToLocalSpace(state.Mouse.NativeState.Position).X / Content.DrawSize.X;
|
|
||||||
localZoomTarget = ToLocalSpace(state.Mouse.NativeState.Position).X;
|
|
||||||
|
|
||||||
Zoom += state.Mouse.ScrollDelta.Y;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void waveformVisibilityChanged(bool visible) => waveform.FadeTo(visible ? 1 : 0, 200, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
}
|
|
57
osu.Game/Screens/Edit/Screens/Compose/Timeline/Timeline.cs
Normal file
57
osu.Game/Screens/Edit/Screens/Compose/Timeline/Timeline.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
// Copyright (c) 2007-2018 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.Framework.Configuration;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Audio;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit.Screens.Compose.Timeline
|
||||||
|
{
|
||||||
|
public class Timeline : ZoomableScrollContainer
|
||||||
|
{
|
||||||
|
public readonly Bindable<bool> WaveformVisible = new Bindable<bool>();
|
||||||
|
public readonly IBindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
|
||||||
|
|
||||||
|
public Timeline()
|
||||||
|
{
|
||||||
|
ZoomDuration = 200;
|
||||||
|
ZoomEasing = Easing.OutQuint;
|
||||||
|
Zoom = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
private WaveformGraph waveform;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(IBindableBeatmap beatmap)
|
||||||
|
{
|
||||||
|
Child = waveform = new WaveformGraph
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = OsuColour.FromHex("222"),
|
||||||
|
Depth = float.MaxValue
|
||||||
|
};
|
||||||
|
|
||||||
|
WaveformVisible.ValueChanged += visible => waveform.FadeTo(visible ? 1 : 0, 200, Easing.OutQuint);
|
||||||
|
|
||||||
|
Beatmap.BindTo(beatmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
Beatmap.BindValueChanged(b => waveform.Waveform = b.Waveform);
|
||||||
|
waveform.Waveform = Beatmap.Value.Waveform;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
// We want time = 0 to be at the centre of the container when scrolled to the start
|
||||||
|
Content.Margin = new MarginPadding { Horizontal = DrawWidth / 2 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
128
osu.Game/Screens/Edit/Screens/Compose/Timeline/TimelineArea.cs
Normal file
128
osu.Game/Screens/Edit/Screens/Compose/Timeline/TimelineArea.cs
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
// Copyright (c) 2007-2018 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.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit.Screens.Compose.Timeline
|
||||||
|
{
|
||||||
|
public class TimelineArea : CompositeDrawable
|
||||||
|
{
|
||||||
|
private readonly Timeline timeline;
|
||||||
|
|
||||||
|
public TimelineArea()
|
||||||
|
{
|
||||||
|
Masking = true;
|
||||||
|
CornerRadius = 5;
|
||||||
|
|
||||||
|
OsuCheckbox hitObjectsCheckbox;
|
||||||
|
OsuCheckbox hitSoundsCheckbox;
|
||||||
|
OsuCheckbox waveformCheckbox;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = OsuColour.FromHex("111")
|
||||||
|
},
|
||||||
|
new GridContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Content = new[]
|
||||||
|
{
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
AutoSizeAxes = Axes.X,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = OsuColour.FromHex("222")
|
||||||
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Width = 160,
|
||||||
|
Padding = new MarginPadding { Horizontal = 15 },
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Spacing = new Vector2(0, 4),
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
hitObjectsCheckbox = new OsuCheckbox { LabelText = "Hitobjects" },
|
||||||
|
hitSoundsCheckbox = new OsuCheckbox { LabelText = "Hitsounds" },
|
||||||
|
waveformCheckbox = new OsuCheckbox { LabelText = "Waveform" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
AutoSizeAxes = Axes.X,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = OsuColour.FromHex("333")
|
||||||
|
},
|
||||||
|
new Container<TimelineButton>
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
AutoSizeAxes = Axes.X,
|
||||||
|
Masking = true,
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new TimelineButton
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
Height = 0.5f,
|
||||||
|
Icon = FontAwesome.fa_search_plus,
|
||||||
|
Action = () => timeline.Zoom++
|
||||||
|
},
|
||||||
|
new TimelineButton
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
Height = 0.5f,
|
||||||
|
Icon = FontAwesome.fa_search_minus,
|
||||||
|
Action = () => timeline.Zoom--
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
timeline = new Timeline { RelativeSizeAxes = Axes.Both }
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ColumnDimensions = new[]
|
||||||
|
{
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
new Dimension(GridSizeMode.Distributed),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
hitObjectsCheckbox.Current.Value = true;
|
||||||
|
hitSoundsCheckbox.Current.Value = true;
|
||||||
|
waveformCheckbox.Current.Value = true;
|
||||||
|
|
||||||
|
timeline.WaveformVisible.BindTo(waveformCheckbox.Current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,174 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Transforms;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
using osu.Framework.MathUtils;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit.Screens.Compose.Timeline
|
||||||
|
{
|
||||||
|
public class ZoomableScrollContainer : ScrollContainer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The time to zoom into/out of a point.
|
||||||
|
/// All user scroll input will be overwritten during the zoom transform.
|
||||||
|
/// </summary>
|
||||||
|
public double ZoomDuration;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The easing with which to transform the zoom.
|
||||||
|
/// </summary>
|
||||||
|
public Easing ZoomEasing;
|
||||||
|
|
||||||
|
private readonly Container zoomedContent;
|
||||||
|
protected override Container<Drawable> Content => zoomedContent;
|
||||||
|
|
||||||
|
private float currentZoom = 1;
|
||||||
|
|
||||||
|
public ZoomableScrollContainer()
|
||||||
|
: base(Direction.Horizontal)
|
||||||
|
{
|
||||||
|
base.Content.Add(zoomedContent = new Container { RelativeSizeAxes = Axes.Y });
|
||||||
|
}
|
||||||
|
|
||||||
|
private int minZoom = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The minimum zoom level allowed.
|
||||||
|
/// </summary>
|
||||||
|
public int MinZoom
|
||||||
|
{
|
||||||
|
get => minZoom;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value < 1)
|
||||||
|
throw new ArgumentException($"{nameof(MinZoom)} must be >= 1.", nameof(value));
|
||||||
|
minZoom = value;
|
||||||
|
|
||||||
|
if (Zoom < value)
|
||||||
|
Zoom = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int maxZoom = 60;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The maximum zoom level allowed.
|
||||||
|
/// </summary>
|
||||||
|
public int MaxZoom
|
||||||
|
{
|
||||||
|
get => maxZoom;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value < 1)
|
||||||
|
throw new ArgumentException($"{nameof(MaxZoom)} must be >= 1.", nameof(value));
|
||||||
|
maxZoom = value;
|
||||||
|
|
||||||
|
if (Zoom > value)
|
||||||
|
Zoom = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the content zoom level of this <see cref="ZoomableScrollContainer"/>.
|
||||||
|
/// </summary>
|
||||||
|
public float Zoom
|
||||||
|
{
|
||||||
|
get => zoomTarget;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
value = MathHelper.Clamp(value, MinZoom, MaxZoom);
|
||||||
|
|
||||||
|
if (IsLoaded)
|
||||||
|
setZoomTarget(value, ToSpaceOfOtherDrawable(new Vector2(DrawWidth / 2, 0), zoomedContent).X);
|
||||||
|
else
|
||||||
|
currentZoom = zoomTarget = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
zoomedContent.Width = DrawWidth * currentZoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnScroll(InputState state)
|
||||||
|
{
|
||||||
|
if (!state.Keyboard.ControlPressed)
|
||||||
|
return base.OnScroll(state);
|
||||||
|
|
||||||
|
setZoomTarget(zoomTarget + state.Mouse.ScrollDelta.X, zoomedContent.ToLocalSpace(state.Mouse.NativeState.Position).X);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float zoomTarget = 1;
|
||||||
|
private void setZoomTarget(float newZoom, float focusPoint)
|
||||||
|
{
|
||||||
|
zoomTarget = MathHelper.Clamp(newZoom, MinZoom, MaxZoom);
|
||||||
|
transformZoomTo(zoomTarget, focusPoint, ZoomDuration, ZoomEasing);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void transformZoomTo(float newZoom, float focusPoint, double duration = 0, Easing easing = Easing.None)
|
||||||
|
=> this.TransformTo(this.PopulateTransform(new TransformZoom(focusPoint, zoomedContent.DrawWidth, Current), newZoom, duration, easing));
|
||||||
|
|
||||||
|
private class TransformZoom : Transform<float, ZoomableScrollContainer>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The focus point in absolute coordinates local to the content.
|
||||||
|
/// </summary>
|
||||||
|
private readonly float focusPoint;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The size of the content.
|
||||||
|
/// </summary>
|
||||||
|
private readonly float contentSize;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The scroll offset at the start of the transform.
|
||||||
|
/// </summary>
|
||||||
|
private readonly float scrollOffset;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Transforms <see cref="TimeTimelinem"/> to a new value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="focusPoint">The focus point in absolute coordinates local to the content.</param>
|
||||||
|
/// <param name="contentSize">The size of the content.</param>
|
||||||
|
/// <param name="scrollOffset">The scroll offset at the start of the transform.</param>
|
||||||
|
public TransformZoom(float focusPoint, float contentSize, float scrollOffset)
|
||||||
|
{
|
||||||
|
this.focusPoint = focusPoint;
|
||||||
|
this.contentSize = contentSize;
|
||||||
|
this.scrollOffset = scrollOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string TargetMember => nameof(currentZoom);
|
||||||
|
|
||||||
|
private float valueAt(double time)
|
||||||
|
{
|
||||||
|
if (time < StartTime) return StartValue;
|
||||||
|
if (time >= EndTime) return EndValue;
|
||||||
|
|
||||||
|
return Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Apply(ZoomableScrollContainer d, double time)
|
||||||
|
{
|
||||||
|
float newZoom = valueAt(time);
|
||||||
|
|
||||||
|
float focusOffset = focusPoint - scrollOffset;
|
||||||
|
float expectedWidth = d.DrawWidth * newZoom;
|
||||||
|
float targetOffset = expectedWidth * (focusPoint / contentSize) - focusOffset;
|
||||||
|
|
||||||
|
d.currentZoom = newZoom;
|
||||||
|
d.ScrollTo(targetOffset, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void ReadIntoStartValue(ZoomableScrollContainer d) => StartValue = d.currentZoom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -158,6 +158,7 @@ namespace osu.Game.Screens.Play
|
|||||||
userAudioOffset.TriggerChange();
|
userAudioOffset.TriggerChange();
|
||||||
|
|
||||||
ScoreProcessor = RulesetContainer.CreateScoreProcessor();
|
ScoreProcessor = RulesetContainer.CreateScoreProcessor();
|
||||||
|
config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode);
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
<PackageReference Include="Humanizer" Version="2.2.0" />
|
<PackageReference Include="Humanizer" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.1.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.1.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2018.607.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2018.611.1" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.18.1" />
|
<PackageReference Include="SharpCompress" Version="0.18.1" />
|
||||||
<PackageReference Include="NUnit" Version="3.10.1" />
|
<PackageReference Include="NUnit" Version="3.10.1" />
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="4.5.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="4.5.0" />
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
<ItemGroup Label="Package References">
|
<ItemGroup Label="Package References">
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.0" />
|
||||||
<PackageReference Include="DeepEqual" Version="1.6.0" />
|
<PackageReference Include="DeepEqual" Version="1.6.0" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.1" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
|
||||||
<PackageReference Include="NUnit" Version="3.10.1" />
|
<PackageReference Include="NUnit" Version="3.10.1" />
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
|
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user