1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:18:22 +08:00

ModSections in Ruleset, fixed toolbar play mode changed not firing

This commit is contained in:
DrabWeb 2017-03-01 22:05:52 -04:00
parent bb12463ae4
commit 6c680825ed
11 changed files with 494 additions and 273 deletions

View File

@ -8,6 +8,8 @@ using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.UI;
using osu.Game.Modes.UI;
using osu.Game.Beatmaps;
using osu.Game.Overlays.Mods;
using OpenTK.Input;
namespace osu.Game.Modes.Catch
{
@ -31,6 +33,111 @@ namespace osu.Game.Modes.Catch
new CatchModFlashlight(),
};
public override IEnumerable<ModSection> CreateModSections() => new ModSection[]
{
new DifficultyReductionSection
{
Buttons = new[]
{
new ModButton
{
ToggleKey = Key.Q,
Mods = new Mod[]
{
new CatchModEasy(),
},
},
new ModButton
{
ToggleKey = Key.W,
Mods = new Mod[]
{
new CatchModNoFail(),
},
},
new ModButton
{
ToggleKey = Key.E,
Mods = new Mod[]
{
new CatchModHalfTime(),
},
},
},
},
new DifficultyIncreaseSection
{
Buttons = new ModButton[]
{
new ModButton
{
ToggleKey = Key.A,
Mods = new Mod[]
{
new CatchModHardRock(),
},
},
new ModButton
{
ToggleKey = Key.S,
Mods = new Mod[]
{
new CatchModSuddenDeath(),
new ModPerfect(),
},
},
new ModButton
{
ToggleKey = Key.D,
Mods = new Mod[]
{
new CatchModDoubleTime(),
new CatchModNightcore(),
},
},
new ModButton
{
ToggleKey = Key.F,
Mods = new Mod[]
{
new CatchModHidden(),
},
},
new ModButton
{
ToggleKey = Key.G,
Mods = new Mod[]
{
new CatchModFlashlight(),
},
},
},
},
new AssistedSection
{
Buttons = new[]
{
new ModButton
{
ToggleKey = Key.Z,
Mods = new Mod[]
{
new CatchModRelax(),
},
},
new ModButton
{
ToggleKey = Key.B,
Mods = new Mod[]
{
new ModAutoplay(),
new ModCinema(),
},
},
}
},
};
protected override PlayMode PlayMode => PlayMode.Catch;
public override FontAwesome Icon => FontAwesome.fa_osu_fruits_o;

View File

@ -8,6 +8,8 @@ using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.UI;
using osu.Game.Modes.UI;
using osu.Game.Beatmaps;
using osu.Game.Overlays.Mods;
using OpenTK.Input;
namespace osu.Game.Modes.Mania
{
@ -42,6 +44,135 @@ namespace osu.Game.Modes.Mania
new ManiaModKeyCoop(),
};
public override IEnumerable<ModSection> CreateModSections() => new ModSection[]
{
new DifficultyReductionSection
{
Buttons = new[]
{
new ModButton
{
ToggleKey = Key.Q,
Mods = new Mod[]
{
new ManiaModEasy(),
},
},
new ModButton
{
ToggleKey = Key.W,
Mods = new Mod[]
{
new ManiaModNoFail(),
},
},
new ModButton
{
ToggleKey = Key.E,
Mods = new Mod[]
{
new ManiaModHalfTime(),
},
},
},
},
new DifficultyIncreaseSection
{
Buttons = new ModButton[]
{
new ModButton
{
ToggleKey = Key.A,
Mods = new Mod[]
{
new ManiaModHardRock(),
},
},
new ModButton
{
ToggleKey = Key.S,
Mods = new Mod[]
{
new ManiaModSuddenDeath(),
new ModPerfect(),
},
},
new ModButton
{
ToggleKey = Key.D,
Mods = new Mod[]
{
new ManiaModDoubleTime(),
new ManiaModNightcore(),
},
},
new ModButton
{
ToggleKey = Key.F,
Mods = new Mod[]
{
new ManiaModHidden(),
},
},
new ModButton
{
ToggleKey = Key.G,
Mods = new Mod[]
{
new ManiaModFlashlight(),
},
},
},
},
new AssistedSection
{
Buttons = new[]
{
new ModButton
{
ToggleKey = Key.Z,
Mods = new Mod[]
{
new ManiaModKey4(),
new ManiaModKey5(),
new ManiaModKey6(),
new ManiaModKey7(),
new ManiaModKey8(),
new ManiaModKey9(),
new ManiaModKey1(),
new ManiaModKey2(),
new ManiaModKey3(),
},
},
new ModButton
{
ToggleKey = Key.X,
Mods = new Mod[]
{
new ManiaModKeyCoop(),
},
},
new ModButton
{
ToggleKey = Key.C,
Mods = new Mod[]
{
new ManiaModRandom(),
},
},
new ModButton
{
ToggleKey = Key.V,
Mods = new Mod[]
{
new ModAutoplay(),
new ModCinema(),
},
},
}
},
};
protected override PlayMode PlayMode => PlayMode.Mania;
public override FontAwesome Icon => FontAwesome.fa_osu_mania_o;

View File

@ -3,12 +3,14 @@
using System.Collections.Generic;
using System.Linq;
using OpenTK.Input;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Osu.Objects;
using osu.Game.Modes.Osu.UI;
using osu.Game.Modes.UI;
using osu.Game.Overlays.Mods;
namespace osu.Game.Modes.Osu
{
@ -51,6 +53,135 @@ namespace osu.Game.Modes.Osu
new OsuModTarget(),
};
public override IEnumerable<ModSection> CreateModSections() => new ModSection[]
{
new DifficultyReductionSection
{
Buttons = new[]
{
new ModButton
{
ToggleKey = Key.Q,
Mods = new Mod[]
{
new OsuModEasy(),
},
},
new ModButton
{
ToggleKey = Key.W,
Mods = new Mod[]
{
new OsuModNoFail(),
},
},
new ModButton
{
ToggleKey = Key.E,
Mods = new Mod[]
{
new OsuModHalfTime(),
},
},
},
},
new DifficultyIncreaseSection
{
Buttons = new ModButton[]
{
new ModButton
{
ToggleKey = Key.A,
Mods = new Mod[]
{
new OsuModHardRock(),
},
},
new ModButton
{
ToggleKey = Key.S,
Mods = new Mod[]
{
new OsuModSuddenDeath(),
new ModPerfect(),
},
},
new ModButton
{
ToggleKey = Key.D,
Mods = new Mod[]
{
new OsuModDoubleTime(),
new OsuModNightcore(),
},
},
new ModButton
{
ToggleKey = Key.F,
Mods = new Mod[]
{
new OsuModHidden(),
},
},
new ModButton
{
ToggleKey = Key.G,
Mods = new Mod[]
{
new OsuModFlashlight(),
},
},
},
},
new AssistedSection
{
Buttons = new[]
{
new ModButton
{
ToggleKey = Key.Z,
Mods = new Mod[]
{
new OsuModRelax(),
},
},
new ModButton
{
ToggleKey = Key.X,
Mods = new Mod[]
{
new OsuModAutopilot(),
},
},
new ModButton
{
ToggleKey = Key.C,
Mods = new Mod[]
{
new OsuModTarget(),
},
},
new ModButton
{
ToggleKey = Key.V,
Mods = new Mod[]
{
new OsuModSpunOut(),
},
},
new ModButton
{
ToggleKey = Key.B,
Mods = new Mod[]
{
new ModAutoplay(),
new ModCinema(),
},
},
}
},
};
public override FontAwesome Icon => FontAwesome.fa_osu_osu_o;
public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();

View File

@ -8,6 +8,8 @@ using osu.Game.Modes.Osu.UI;
using osu.Game.Modes.Taiko.UI;
using osu.Game.Modes.UI;
using osu.Game.Beatmaps;
using osu.Game.Overlays.Mods;
using OpenTK.Input;
namespace osu.Game.Modes.Taiko
{
@ -31,6 +33,111 @@ namespace osu.Game.Modes.Taiko
new TaikoModFlashlight(),
};
public override IEnumerable<ModSection> CreateModSections() => new ModSection[]
{
new DifficultyReductionSection
{
Buttons = new[]
{
new ModButton
{
ToggleKey = Key.Q,
Mods = new Mod[]
{
new TaikoModEasy(),
},
},
new ModButton
{
ToggleKey = Key.W,
Mods = new Mod[]
{
new TaikoModNoFail(),
},
},
new ModButton
{
ToggleKey = Key.E,
Mods = new Mod[]
{
new TaikoModHalfTime(),
},
},
},
},
new DifficultyIncreaseSection
{
Buttons = new ModButton[]
{
new ModButton
{
ToggleKey = Key.A,
Mods = new Mod[]
{
new TaikoModHardRock(),
},
},
new ModButton
{
ToggleKey = Key.S,
Mods = new Mod[]
{
new TaikoModSuddenDeath(),
new ModPerfect(),
},
},
new ModButton
{
ToggleKey = Key.D,
Mods = new Mod[]
{
new TaikoModDoubleTime(),
new TaikoModNightcore(),
},
},
new ModButton
{
ToggleKey = Key.F,
Mods = new Mod[]
{
new TaikoModHidden(),
},
},
new ModButton
{
ToggleKey = Key.G,
Mods = new Mod[]
{
new TaikoModFlashlight(),
},
},
},
},
new AssistedSection
{
Buttons = new[]
{
new ModButton
{
ToggleKey = Key.Z,
Mods = new Mod[]
{
new TaikoModRelax(),
},
},
new ModButton
{
ToggleKey = Key.B,
Mods = new Mod[]
{
new ModAutoplay(),
new ModCinema(),
},
},
}
},
};
protected override PlayMode PlayMode => PlayMode.Taiko;
public override FontAwesome Icon => FontAwesome.fa_osu_taiko_o;

View File

@ -8,6 +8,7 @@ using System;
using System.Collections.Concurrent;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Overlays.Mods;
namespace osu.Game.Modes
{
@ -28,6 +29,8 @@ namespace osu.Game.Modes
public abstract IEnumerable<Mod> AvailableMods { get; }
public abstract IEnumerable<ModSection> CreateModSections();
public abstract ScoreProcessor CreateScoreProcessor(int hitObjectCount);
public abstract HitRenderer CreateHitRendererWith(Beatmap beatmap);

View File

@ -12,16 +12,6 @@ namespace osu.Game
{
public class AssistedSection : ModSection
{
public ModButton RelaxButton { get; private set; }
public ModButton AutopilotButton { get; private set; }
public ModButton TargetPracticeButton { get; private set; }
public ModButton SpunOutButton { get; private set; }
public ModButton AutoplayCinemaButton { get; private set; }
public ModButton KeyButton { get; private set; }
public ModButton CoopButton { get; private set; }
public ModButton RandomButton { get; private set; }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
@ -29,132 +19,9 @@ namespace osu.Game
SelectedColour = colours.BlueLight;
}
public AssistedSection(PlayMode mode)
public AssistedSection()
{
Header = @"Assisted";
//switch (mode)
//{
// case PlayMode.Osu:
// Buttons = new ModButton[]
// {
// RelaxButton = new ModButton
// {
// ToggleKey = Key.Z,
// Mods = new Mod[]
// {
// new ModRelax(),
// },
// },
// AutopilotButton = new ModButton
// {
// ToggleKey = Key.X,
// Mods = new Mod[]
// {
// new OsuModAutopilot(),
// },
// },
// TargetPracticeButton = new ModButton
// {
// ToggleKey = Key.C,
// Mods = new Mod[]
// {
// new OsuModTarget(),
// },
// },
// SpunOutButton = new ModButton
// {
// ToggleKey = Key.V,
// Mods = new Mod[]
// {
// new OsuModSpunOut(),
// },
// },
// AutoplayCinemaButton = new ModButton
// {
// ToggleKey = Key.B,
// Mods = new Mod[]
// {
// new ModAutoplay(),
// new ModCinema(),
// },
// },
// };
// break;
// case PlayMode.Taiko:
// case PlayMode.Catch:
// Buttons = new ModButton[]
// {
// RelaxButton = new ModButton
// {
// ToggleKey = Key.Z,
// Mods = new Mod[]
// {
// new ModRelax(),
// },
// },
// AutoplayCinemaButton = new ModButton
// {
// ToggleKey = Key.X,
// Mods = new Mod[]
// {
// new ModAutoplay(),
// new ModCinema(),
// },
// },
// };
// break;
// case PlayMode.Mania:
// Buttons = new ModButton[]
// {
// KeyButton = new ModButton
// {
// ToggleKey = Key.Z,
// Mods = new Mod[]
// {
// new ManiaModKey4(),
// new ManiaModKey5(),
// new ManiaModKey6(),
// new ManiaModKey7(),
// new ManiaModKey8(),
// new ManiaModKey9(),
// new ManiaModKey1(),
// new ManiaModKey2(),
// new ManiaModKey3(),
// },
// },
// CoopButton = new ModButton
// {
// ToggleKey = Key.X,
// Mods = new Mod[]
// {
// new ManiaModKeyCoop(),
// },
// },
// RandomButton = new ModButton
// {
// ToggleKey = Key.C,
// Mods = new Mod[]
// {
// new ManiaModRandom(),
// },
// },
// AutoplayCinemaButton = new ModButton
// {
// ToggleKey = Key.V,
// Mods = new Mod[]
// {
// new ModAutoplay(),
// new ModCinema(),
// },
// },
// };
// break;
// default:
// throw new NotSupportedException();
//}
}
}
}

View File

@ -11,12 +11,6 @@ namespace osu.Game
{
public class DifficultyIncreaseSection : ModSection
{
public ModButton HardRockButton => Buttons[0];
public ModButton SuddenDeathButton => Buttons[1];
public ModButton DoubleTimeNightcoreButton => Buttons[2];
public ModButton HiddenButton => Buttons[3];
public ModButton FlashlightButton => Buttons[4];
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
@ -27,51 +21,6 @@ namespace osu.Game
public DifficultyIncreaseSection()
{
Header = @"Gameplay Difficulty Increase";
//Buttons = new ModButton[]
//{
// new ModButton
// {
// ToggleKey = Key.A,
// Mods = new Mod[]
// {
// new ModHardRock(),
// },
// },
// new ModButton
// {
// ToggleKey = Key.S,
// Mods = new Mod[]
// {
// new ModSuddenDeath(),
// new ModPerfect(),
// },
// },
// new ModButton
// {
// ToggleKey = Key.D,
// Mods = new Mod[]
// {
// new ModDoubleTime(),
// new ModNightcore(),
// },
// },
// new ModButton
// {
// ToggleKey = Key.F,
// Mods = new Mod[]
// {
// new ModHidden(),
// },
// },
// new ModButton
// {
// ToggleKey = Key.G,
// Mods = new Mod[]
// {
// new ModFlashlight(),
// },
// },
//};
}
}
}

View File

@ -11,10 +11,6 @@ namespace osu.Game
{
public class DifficultyReductionSection : ModSection
{
public ModButton EasyButton => Buttons[0];
public ModButton NoFailButton => Buttons[1];
public ModButton HalfTimeButton => Buttons[2];
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
@ -25,33 +21,6 @@ namespace osu.Game
public DifficultyReductionSection()
{
Header = @"Gameplay Difficulty Reduction";
//Buttons = new ModButton[]
//{
// new ModButton
// {
// ToggleKey = Key.Q,
// Mods = new Mod[]
// {
// new ModEasy(),
// },
// },
// new ModButton
// {
// ToggleKey = Key.W,
// Mods = new Mod[]
// {
// new ModNoFail(),
// },
// },
// new ModButton
// {
// ToggleKey = Key.E,
// Mods = new Mod[]
// {
// new ModHalfTime(),
// },
// },
//};
}
}
}

View File

@ -15,9 +15,6 @@ using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Sprites;
using osu.Game.Modes;
using osu.Framework.Allocation;
using osu.Framework.Input;
using OpenTK.Input;
using System.Linq;
namespace osu.Game.Overlays.Mods
{
@ -45,33 +42,18 @@ namespace osu.Game.Overlays.Mods
}
set
{
if (value == modMode) return;
modMode = value;
modSectionsContainer.Children = new ModSection[]
modSectionsContainer.RemoveAll(delegate (ModSection m) { return true; });
foreach (ModSection s in Ruleset.GetRuleset(value).CreateModSections())
{
new DifficultyReductionSection
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Action = modButtonPressed,
},
new DifficultyIncreaseSection
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Action = modButtonPressed,
},
new AssistedSection(value)
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Action = modButtonPressed,
},
};
s.RelativeSizeAxes = Axes.X;
s.Origin = Anchor.TopCentre;
s.Anchor = Anchor.TopCentre;
s.Action = modButtonPressed;
modSectionsContainer.Add(s);
}
}
}
@ -312,30 +294,6 @@ namespace osu.Game.Overlays.Mods
AutoSizeAxes = Axes.Y,
Spacing = new Vector2(0f, 10f),
Width = content_width,
Children = new ModSection[]
{
new DifficultyReductionSection
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Action = modButtonPressed,
},
new DifficultyIncreaseSection
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Action = modButtonPressed,
},
new AssistedSection(PlayMode.Osu)
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Action = modButtonPressed,
},
},
},
// Footer
new Container

View File

@ -55,7 +55,10 @@ namespace osu.Game.Overlays.Toolbar
},
modeSelector = new ToolbarModeSelector
{
OnPlayModeChange = OnPlayModeChange
OnPlayModeChange = (PlayMode mode) =>
{
OnPlayModeChange?.Invoke(mode);
}
}
}
},

View File

@ -145,12 +145,8 @@ namespace osu.Game.Screens.Select
if (osuGame != null)
{
playMode = osuGame.PlayMode;
playMode.ValueChanged += playMode_ValueChanged;
modSelect.ModMode = playMode;
}
else
{
modSelect.ModMode = PlayMode.Osu;
playMode.ValueChanged += playMode_ValueChanged;
}
if (database == null)