mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 09:12:54 +08:00
Cleanup
This commit is contained in:
parent
57c4232416
commit
475eb6fe5f
@ -16,31 +16,16 @@ using OpenTK;
|
||||
|
||||
namespace osu.Desktop.VisualTests.Tests
|
||||
{
|
||||
internal class TestCaseIngameModsContainer : TestCase
|
||||
internal class TestCaseIngameModsContainer : TestCaseModSelectOverlay
|
||||
{
|
||||
public override string Description => @"Ingame mods visualization";
|
||||
|
||||
private ModSelectOverlay modSelect;
|
||||
private ModsContainer modsContainer;
|
||||
private RulesetDatabase rulesets;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RulesetDatabase rulesets)
|
||||
{
|
||||
this.rulesets = rulesets;
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
|
||||
Add(modSelect = new ModSelectOverlay
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
});
|
||||
|
||||
Add(modsContainer = new ModsContainer
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
@ -49,19 +34,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
Position = new Vector2(0, 25),
|
||||
});
|
||||
|
||||
modSelect.SelectedMods.ValueChanged += SelectedMods_ValueChanged;
|
||||
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);
|
||||
modsContainer.Mods.BindTo(modSelect.SelectedMods);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
{
|
||||
public override string Description => @"Tests the mod select overlay";
|
||||
|
||||
private ModSelectOverlay modSelect;
|
||||
protected ModSelectOverlay modSelect;
|
||||
private RulesetDatabase rulesets;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.UI
|
||||
set { modIcon.Icon = value; }
|
||||
}
|
||||
|
||||
public ModIcon(Mod m)
|
||||
public ModIcon(Mod mod)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.UI
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Icon = FontAwesome.fa_osu_mod_bg,
|
||||
Colour = pickColour(m),
|
||||
Colour = getBackgroundColourFromMod(mod),
|
||||
Shadow = true,
|
||||
TextSize = 20
|
||||
},
|
||||
@ -59,7 +59,7 @@ namespace osu.Game.Rulesets.UI
|
||||
Anchor = Anchor.Centre,
|
||||
Colour = OsuColour.Gray(84),
|
||||
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;
|
||||
}
|
||||
|
||||
private Color4 pickColour(Mod mod)
|
||||
private Color4 getBackgroundColourFromMod(Mod mod)
|
||||
{
|
||||
switch (mod?.Type)
|
||||
{
|
||||
|
@ -7,6 +7,8 @@ using osu.Game.Rulesets.UI;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using OpenTK;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Configuration;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
@ -14,15 +16,23 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
private readonly FillFlowContainer<ModIcon> iconsContainer;
|
||||
|
||||
public readonly Bindable<IEnumerable<Mod>> Mods = new Bindable<IEnumerable<Mod>>();
|
||||
|
||||
private bool showMods;
|
||||
public bool ShowMods
|
||||
{
|
||||
get
|
||||
{
|
||||
return showMods;
|
||||
}
|
||||
set
|
||||
{
|
||||
showMods = value;
|
||||
if (!showMods) Hide();
|
||||
if (!showMods)
|
||||
Hide();
|
||||
else
|
||||
Show();
|
||||
}
|
||||
get { return showMods; }
|
||||
}
|
||||
|
||||
public ModsContainer()
|
||||
@ -46,20 +56,19 @@ namespace osu.Game.Screens.Play
|
||||
TextSize = 12,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void Add(Mod mod)
|
||||
{
|
||||
iconsContainer.Add(new ModIcon(mod)
|
||||
Mods.ValueChanged += mods =>
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Scale = new Vector2(0.7f),
|
||||
});
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
iconsContainer.Clear();
|
||||
iconsContainer.Clear();
|
||||
foreach (Mod mod in mods)
|
||||
{
|
||||
iconsContainer.Add(new ModIcon(mod)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Scale = new Vector2(0.7f),
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,8 +170,7 @@ namespace osu.Game.Screens.Play
|
||||
hudOverlay.Progress.OnSeek = pos => decoupledClock.Seek(pos);
|
||||
|
||||
hudOverlay.ModsContainer.ShowMods = HitRenderer.HasReplayLoaded;
|
||||
foreach (var mod in Beatmap.Mods.Value)
|
||||
hudOverlay.ModsContainer.Add(mod);
|
||||
hudOverlay.ModsContainer.Mods.BindTo(Beatmap.Mods);
|
||||
|
||||
//bind HitRenderer to ScoreProcessor and ourselves (for a pass situation)
|
||||
HitRenderer.OnAllJudged += onCompletion;
|
||||
|
Loading…
Reference in New Issue
Block a user