selectedMod -> selectedIndex

This commit is contained in:
Huo Yaoyuan
2017-03-06 17:21:25 +08:00
parent c2cf5242e1
commit ad75ead665

View File

@ -31,25 +31,25 @@ namespace osu.Game.Overlays.Mods
public Action<Mod> Action; // Passed the selected mod or null if none public Action<Mod> Action; // Passed the selected mod or null if none
private int _selectedMod = -1; private int _selectedIndex = -1;
private int selectedMod private int selectedIndex
{ {
get get
{ {
return _selectedMod; return _selectedIndex;
} }
set set
{ {
if (value == _selectedMod) return; if (value == _selectedIndex) return;
_selectedMod = value; _selectedIndex = value;
if (value >= Mods.Length) if (value >= Mods.Length)
{ {
_selectedMod = -1; _selectedIndex = -1;
} }
else if (value <= -2) else if (value <= -2)
{ {
_selectedMod = Mods.Length - 1; _selectedIndex = Mods.Length - 1;
} }
iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic); iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic);
@ -64,7 +64,7 @@ namespace osu.Game.Overlays.Mods
} }
} }
public bool Selected => selectedMod != -1; public bool Selected => selectedIndex != -1;
private Color4 backgroundColour; private Color4 backgroundColour;
public new Color4 Colour public new Color4 Colour
@ -131,7 +131,7 @@ namespace osu.Game.Overlays.Mods
private Mod[] mods; private Mod[] mods;
public Mod[] Mods => mods; // the mods from Mod, only multiple if Mod is a MultiMod public Mod[] Mods => mods; // the mods from Mod, only multiple if Mod is a MultiMod
public Mod SelectedMod => Mods.ElementAtOrDefault(selectedMod); public Mod SelectedMod => Mods.ElementAtOrDefault(selectedIndex);
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio)
@ -148,8 +148,7 @@ namespace osu.Game.Overlays.Mods
public void SelectNext() public void SelectNext()
{ {
selectedMod++; if (++selectedIndex == -1)
if (selectedMod == -1)
{ {
sampleOff.Play(); sampleOff.Play();
} }
@ -163,8 +162,7 @@ namespace osu.Game.Overlays.Mods
public void SelectPrevious() public void SelectPrevious()
{ {
selectedMod--; if (--selectedIndex == -1)
if (selectedMod == -1)
{ {
sampleOff.Play(); sampleOff.Play();
} }
@ -178,7 +176,7 @@ namespace osu.Game.Overlays.Mods
public void Deselect() public void Deselect()
{ {
selectedMod = -1; selectedIndex = -1;
} }
private void displayMod(Mod mod) private void displayMod(Mod mod)
@ -189,7 +187,7 @@ namespace osu.Game.Overlays.Mods
private void displaySelectedMod() private void displaySelectedMod()
{ {
var modIndex = selectedMod; var modIndex = selectedIndex;
if (modIndex <= -1) if (modIndex <= -1)
{ {
modIndex = 0; modIndex = 0;