Merge branch 'master' into fix-catch-droplets

This commit is contained in:
Dean Herbert 2018-03-16 19:05:58 +09:00 committed by GitHub
commit 7c7f2e2dce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 31 deletions

View File

@ -27,14 +27,8 @@ namespace osu.Game.Overlays.Mods
public string Header
{
get
{
return headerLabel.Text;
}
set
{
headerLabel.Text = value;
}
get => headerLabel.Text;
set => headerLabel.Text = value;
}
public IEnumerable<Mod> SelectedMods => buttons.Select(b => b.SelectedMod).Where(m => m != null);
@ -47,12 +41,12 @@ namespace osu.Game.Overlays.Mods
{
if (m == null)
return new ModButtonEmpty();
else
return new ModButton(m)
{
SelectedColour = selectedColour,
SelectionChanged = Action,
};
return new ModButton(m)
{
SelectedColour = selectedColour,
SelectionChanged = Action,
};
}).ToArray();
ButtonsContainer.Children = modContainers;
@ -65,10 +59,7 @@ namespace osu.Game.Overlays.Mods
private Color4 selectedColour = Color4.White;
public Color4 SelectedColour
{
get
{
return selectedColour;
}
get => selectedColour;
set
{
if (value == selectedColour) return;
@ -102,31 +93,31 @@ namespace osu.Game.Overlays.Mods
{
Mod selected = button.SelectedMod;
if (selected == null) continue;
foreach (Type type in modTypes)
foreach (var type in modTypes)
if (type.IsInstanceOfType(selected))
{
if (immediate)
button.Deselect();
else
Scheduler.AddDelayed(() => button.Deselect(), delay += 50);
Scheduler.AddDelayed(button.Deselect, delay += 50);
}
}
}
/// <summary>
/// Select one or more mods in this section.
/// Select one or more mods in this section and deselects all other ones.
/// </summary>
/// <param name="mods">The types of <see cref="Mod"/>s which should be deselected.</param>
public void SelectTypes(IEnumerable<Mod> mods)
/// <param name="modTypes">The types of <see cref="Mod"/>s which should be selected.</param>
public void SelectTypes(IEnumerable<Type> modTypes)
{
foreach (var button in buttons)
{
for (int i = 0; i < button.Mods.Length; i++)
{
foreach (var mod in mods)
if (mod.GetType().IsInstanceOfType(button.Mods[i]))
button.SelectAt(i);
}
int i = Array.FindIndex(button.Mods, m => modTypes.Any(t => t.IsInstanceOfType(m)));
if (i >= 0)
button.SelectAt(i);
else
button.Deselect();
}
}

View File

@ -76,7 +76,7 @@ namespace osu.Game.Overlays.Mods
private void selectedModsChanged(IEnumerable<Mod> obj)
{
foreach (ModSection section in ModSectionsContainer.Children)
section.SelectTypes(obj);
section.SelectTypes(obj.Select(m => m.GetType()).ToList());
updateMods();
}

View File

@ -99,7 +99,7 @@ namespace osu.Game.Screens.Select
if (removeAutoModOnResume)
{
var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod().GetType();
SelectedMods.Value = SelectedMods.Value.Where(m => m.GetType() != autoType).ToArray();
modSelect.DeselectTypes(new[] { autoType }, true);
removeAutoModOnResume = false;
}