1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 12:22:57 +08:00
This commit is contained in:
EVAST9919 2017-05-04 17:29:52 +03:00
parent 57c4232416
commit 475eb6fe5f
5 changed files with 31 additions and 50 deletions

View File

@ -16,31 +16,16 @@ using OpenTK;
namespace osu.Desktop.VisualTests.Tests namespace osu.Desktop.VisualTests.Tests
{ {
internal class TestCaseIngameModsContainer : TestCase internal class TestCaseIngameModsContainer : TestCaseModSelectOverlay
{ {
public override string Description => @"Ingame mods visualization"; public override string Description => @"Ingame mods visualization";
private ModSelectOverlay modSelect;
private ModsContainer modsContainer; private ModsContainer modsContainer;
private RulesetDatabase rulesets;
[BackgroundDependencyLoader]
private void load(RulesetDatabase rulesets)
{
this.rulesets = rulesets;
}
public override void Reset() public override void Reset()
{ {
base.Reset(); base.Reset();
Add(modSelect = new ModSelectOverlay
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre,
});
Add(modsContainer = new ModsContainer Add(modsContainer = new ModsContainer
{ {
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
@ -49,19 +34,7 @@ namespace osu.Desktop.VisualTests.Tests
Position = new Vector2(0, 25), Position = new Vector2(0, 25),
}); });
modSelect.SelectedMods.ValueChanged += SelectedMods_ValueChanged; modsContainer.Mods.BindTo(modSelect.SelectedMods);
modSelect.SelectedMods.TriggerChange();
AddStep("ToggleModSelect", modSelect.ToggleVisibility);
foreach (var ruleset in rulesets.AllRulesets)
AddStep(ruleset.CreateInstance().Description, () => modSelect.Ruleset.Value = ruleset);
}
private void SelectedMods_ValueChanged(System.Collections.Generic.IEnumerable<Mod> newValue)
{
modsContainer.Clear();
foreach (Mod mod in modSelect.SelectedMods.Value)
modsContainer.Add(mod);
} }
} }
} }

View File

@ -13,7 +13,7 @@ namespace osu.Desktop.VisualTests.Tests
{ {
public override string Description => @"Tests the mod select overlay"; public override string Description => @"Tests the mod select overlay";
private ModSelectOverlay modSelect; protected ModSelectOverlay modSelect;
private RulesetDatabase rulesets; private RulesetDatabase rulesets;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.UI
set { modIcon.Icon = value; } set { modIcon.Icon = value; }
} }
public ModIcon(Mod m) public ModIcon(Mod mod)
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.UI
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Icon = FontAwesome.fa_osu_mod_bg, Icon = FontAwesome.fa_osu_mod_bg,
Colour = pickColour(m), Colour = getBackgroundColourFromMod(mod),
Shadow = true, Shadow = true,
TextSize = 20 TextSize = 20
}, },
@ -59,7 +59,7 @@ namespace osu.Game.Rulesets.UI
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Colour = OsuColour.Gray(84), Colour = OsuColour.Gray(84),
TextSize = 20, TextSize = 20,
Icon = m?.Icon ?? FontAwesome.fa_question, Icon = (mod != null) ? mod.Icon : FontAwesome.fa_question,
}, },
}; };
@ -72,7 +72,7 @@ namespace osu.Game.Rulesets.UI
modIcon.TextSize = iconSize - 35; modIcon.TextSize = iconSize - 35;
} }
private Color4 pickColour(Mod mod) private Color4 getBackgroundColourFromMod(Mod mod)
{ {
switch (mod?.Type) switch (mod?.Type)
{ {

View File

@ -7,6 +7,8 @@ using osu.Game.Rulesets.UI;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using OpenTK; using OpenTK;
using System.Collections.Generic;
using osu.Framework.Configuration;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
{ {
@ -14,15 +16,23 @@ namespace osu.Game.Screens.Play
{ {
private readonly FillFlowContainer<ModIcon> iconsContainer; private readonly FillFlowContainer<ModIcon> iconsContainer;
public readonly Bindable<IEnumerable<Mod>> Mods = new Bindable<IEnumerable<Mod>>();
private bool showMods; private bool showMods;
public bool ShowMods public bool ShowMods
{ {
get
{
return showMods;
}
set set
{ {
showMods = value; showMods = value;
if (!showMods) Hide(); if (!showMods)
Hide();
else
Show();
} }
get { return showMods; }
} }
public ModsContainer() public ModsContainer()
@ -46,20 +56,19 @@ namespace osu.Game.Screens.Play
TextSize = 12, TextSize = 12,
} }
}; };
}
public void Add(Mod mod) Mods.ValueChanged += mods =>
{
iconsContainer.Add(new ModIcon(mod)
{ {
AutoSizeAxes = Axes.Both, iconsContainer.Clear();
Scale = new Vector2(0.7f), foreach (Mod mod in mods)
}); {
} iconsContainer.Add(new ModIcon(mod)
{
public void Clear() AutoSizeAxes = Axes.Both,
{ Scale = new Vector2(0.7f),
iconsContainer.Clear(); });
}
};
} }
} }
} }

View File

@ -170,8 +170,7 @@ namespace osu.Game.Screens.Play
hudOverlay.Progress.OnSeek = pos => decoupledClock.Seek(pos); hudOverlay.Progress.OnSeek = pos => decoupledClock.Seek(pos);
hudOverlay.ModsContainer.ShowMods = HitRenderer.HasReplayLoaded; hudOverlay.ModsContainer.ShowMods = HitRenderer.HasReplayLoaded;
foreach (var mod in Beatmap.Mods.Value) hudOverlay.ModsContainer.Mods.BindTo(Beatmap.Mods);
hudOverlay.ModsContainer.Add(mod);
//bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation)
HitRenderer.OnAllJudged += onCompletion; HitRenderer.OnAllJudged += onCompletion;