1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 22:19:30 +08:00

Remove PlayMode game-wide.

This commit is contained in:
smoogipooo 2017-04-15 05:22:41 +09:00
parent a89af273be
commit 0a1376c2db
23 changed files with 52 additions and 97 deletions

View File

@ -26,10 +26,9 @@ namespace osu.Desktop.VisualTests.Tests
}); });
AddStep("Toggle", modSelect.ToggleVisibility); AddStep("Toggle", modSelect.ToggleVisibility);
AddStep("osu!", () => modSelect.PlayMode.Value = PlayMode.Osu);
AddStep("osu!taiko", () => modSelect.PlayMode.Value = PlayMode.Taiko); foreach (var ruleset in RulesetCollection.AllRulesets)
AddStep("osu!catch", () => modSelect.PlayMode.Value = PlayMode.Catch); AddStep(ruleset.Description, () => modSelect.Ruleset.Value = ruleset);
AddStep("osu!mania", () => modSelect.PlayMode.Value = PlayMode.Mania);
} }
} }
} }

View File

@ -76,8 +76,6 @@ namespace osu.Game.Modes.Catch
} }
} }
protected override PlayMode PlayMode => PlayMode.Catch;
public override string Description => "osu!catch"; public override string Description => "osu!catch";
public override FontAwesome Icon => FontAwesome.fa_osu_fruits_o; public override FontAwesome Icon => FontAwesome.fa_osu_fruits_o;

View File

@ -96,8 +96,6 @@ namespace osu.Game.Modes.Mania
} }
} }
protected override PlayMode PlayMode => PlayMode.Mania;
public override string Description => "osu!mania"; public override string Description => "osu!mania";
public override FontAwesome Icon => FontAwesome.fa_osu_mania_o; public override FontAwesome Icon => FontAwesome.fa_osu_mania_o;

View File

@ -99,8 +99,6 @@ namespace osu.Game.Modes.Osu
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new OsuDifficultyCalculator(beatmap); public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new OsuDifficultyCalculator(beatmap);
protected override PlayMode PlayMode => PlayMode.Osu;
public override string Description => "osu!"; public override string Description => "osu!";
public override IEnumerable<KeyCounter> CreateGameplayKeys() => new KeyCounter[] public override IEnumerable<KeyCounter> CreateGameplayKeys() => new KeyCounter[]

View File

@ -76,8 +76,6 @@ namespace osu.Game.Modes.Taiko
} }
} }
protected override PlayMode PlayMode => PlayMode.Taiko;
public override string Description => "osu!taiko"; public override string Description => "osu!taiko";
public override FontAwesome Icon => FontAwesome.fa_osu_taiko_o; public override FontAwesome Icon => FontAwesome.fa_osu_taiko_o;

View File

@ -58,7 +58,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.AreEqual(false, beatmapInfo.Countdown); Assert.AreEqual(false, beatmapInfo.Countdown);
Assert.AreEqual(0.7f, beatmapInfo.StackLeniency); Assert.AreEqual(0.7f, beatmapInfo.StackLeniency);
Assert.AreEqual(false, beatmapInfo.SpecialStyle); Assert.AreEqual(false, beatmapInfo.SpecialStyle);
Assert.AreEqual(PlayMode.Osu, beatmapInfo.Mode); Assert.IsTrue(beatmapInfo.Ruleset is OsuRuleset);
Assert.AreEqual(false, beatmapInfo.LetterboxInBreaks); Assert.AreEqual(false, beatmapInfo.LetterboxInBreaks);
Assert.AreEqual(false, beatmapInfo.WidescreenStoryboard); Assert.AreEqual(false, beatmapInfo.WidescreenStoryboard);
} }

View File

@ -18,14 +18,6 @@ namespace osu.Game.Beatmaps
public readonly BeatmapSetInfo BeatmapSetInfo; public readonly BeatmapSetInfo BeatmapSetInfo;
/// <summary>
/// A play mode that is preferred for this beatmap. PlayMode will become this mode where conversion is feasible,
/// or otherwise to the beatmap's default.
/// </summary>
public PlayMode? PreferredPlayMode;
public PlayMode PlayMode => Beatmap?.BeatmapInfo?.Mode > (int)PlayMode.Osu ? (PlayMode)Beatmap.BeatmapInfo.Mode : PreferredPlayMode ?? PlayMode.Osu;
public readonly Bindable<IEnumerable<Mod>> Mods = new Bindable<IEnumerable<Mod>>(); public readonly Bindable<IEnumerable<Mod>> Mods = new Bindable<IEnumerable<Mod>>();
public readonly bool WithStoryboard; public readonly bool WithStoryboard;

View File

@ -17,8 +17,6 @@ namespace osu.Game.Configuration
Set(OsuConfig.Username, string.Empty); Set(OsuConfig.Username, string.Empty);
Set(OsuConfig.Token, string.Empty); Set(OsuConfig.Token, string.Empty);
Set(OsuConfig.PlayMode, PlayMode.Osu);
Set(OsuConfig.AudioDevice, string.Empty); Set(OsuConfig.AudioDevice, string.Empty);
Set(OsuConfig.SavePassword, false); Set(OsuConfig.SavePassword, false);
Set(OsuConfig.SaveUsername, true); Set(OsuConfig.SaveUsername, true);
@ -196,7 +194,7 @@ namespace osu.Game.Configuration
public enum OsuConfig public enum OsuConfig
{ {
// New osu: // New osu:
PlayMode, Ruleset,
Token, Token,
// Imported from old osu: // Imported from old osu:
BeatmapDirectory, BeatmapDirectory,

View File

@ -39,7 +39,7 @@ namespace osu.Game.Database
using (Stream s = storage.GetStream(Path.Combine(replay_folder, replayFilename))) using (Stream s = storage.GetStream(Path.Combine(replay_folder, replayFilename)))
using (SerializationReader sr = new SerializationReader(s)) using (SerializationReader sr = new SerializationReader(s))
{ {
var ruleset = RulesetCollection.GetRuleset((PlayMode)sr.ReadByte()); var ruleset = RulesetCollection.GetRuleset((int)sr.ReadByte());
score = ruleset.CreateScoreProcessor().CreateScore(); score = ruleset.CreateScoreProcessor().CreateScore();
/* score.Pass = true;*/ /* score.Pass = true;*/

View File

@ -1,13 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Modes
{
public enum PlayMode
{
Osu = 0,
Taiko = 1,
Catch = 2,
Mania = 3
}
}

View File

@ -32,8 +32,6 @@ namespace osu.Game.Modes
public abstract ScoreProcessor CreateScoreProcessor(); public abstract ScoreProcessor CreateScoreProcessor();
protected abstract PlayMode PlayMode { get; }
public virtual FontAwesome Icon => FontAwesome.fa_question_circle; public virtual FontAwesome Icon => FontAwesome.fa_question_circle;
public abstract string Description { get; } public abstract string Description { get; }

View File

@ -21,11 +21,6 @@ namespace osu.Game.Modes
available_rulesets.TryAdd(available_rulesets.Count, ruleset); available_rulesets.TryAdd(available_rulesets.Count, ruleset);
} }
public static Ruleset GetRuleset(PlayMode playMode)
{
return GetRuleset((int)playMode);
}
public static Ruleset GetRuleset(int rulesetId) public static Ruleset GetRuleset(int rulesetId)
{ {
Ruleset ruleset; Ruleset ruleset;

View File

@ -58,7 +58,7 @@ namespace osu.Game
private VolumeControl volume; private VolumeControl volume;
public Bindable<PlayMode> PlayMode; public Bindable<Ruleset> Ruleset;
private readonly string[] args; private readonly string[] args;
@ -88,7 +88,8 @@ namespace osu.Game
Dependencies.Cache(this); Dependencies.Cache(this);
PlayMode = LocalConfig.GetBindable<PlayMode>(OsuConfig.PlayMode); // Todo: I don't think this'll work, need BindableRuleset
Ruleset = new Bindable<Ruleset>();
} }
private ScheduledDelegate scoreLoad; private ScheduledDelegate scoreLoad;
@ -199,11 +200,11 @@ namespace osu.Game
{ {
Depth = -3, Depth = -3,
OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); }, OnHome = delegate { intro?.ChildScreen?.MakeCurrent(); },
OnPlayModeChange = m => PlayMode.Value = m, OnRulesetChange = r => Ruleset.Value = r,
}, t => }, t =>
{ {
PlayMode.ValueChanged += delegate { Toolbar.SetGameMode(PlayMode.Value); }; Ruleset.ValueChanged += delegate { Toolbar.SetGameMode(Ruleset.Value); };
PlayMode.TriggerChange(); Ruleset.TriggerChange();
overlayContent.Add(Toolbar); overlayContent.Add(Toolbar);
}); });

View File

@ -37,13 +37,12 @@ namespace osu.Game.Overlays.Mods
public readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>(); public readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>();
public readonly Bindable<PlayMode> PlayMode = new Bindable<PlayMode>(); public readonly Bindable<Ruleset> Ruleset = new Bindable<Ruleset>();
private void modeChanged(PlayMode newMode) private void rulesetChanged(Ruleset newRuleset)
{ {
var ruleset = RulesetCollection.GetRuleset(newMode);
foreach (ModSection section in modSectionsContainer.Children) foreach (ModSection section in modSectionsContainer.Children)
section.Buttons = ruleset.GetModsFor(section.ModType).Select(m => new ModButton(m)).ToArray(); section.Buttons = newRuleset.GetModsFor(section.ModType).Select(m => new ModButton(m)).ToArray();
refreshSelectedMods(); refreshSelectedMods();
} }
@ -54,9 +53,9 @@ namespace osu.Game.Overlays.Mods
highMultiplierColour = colours.Green; highMultiplierColour = colours.Green;
if (osu != null) if (osu != null)
PlayMode.BindTo(osu.PlayMode); Ruleset.BindTo(osu.Ruleset);
PlayMode.ValueChanged += modeChanged; Ruleset.ValueChanged += rulesetChanged;
PlayMode.TriggerChange(); Ruleset.TriggerChange();
} }
protected override void PopOut() protected override void PopOut()

View File

@ -27,13 +27,15 @@ namespace osu.Game.Overlays.Options
var modes = new List<Drawable>(); var modes = new List<Drawable>();
foreach (PlayMode m in Enum.GetValues(typeof(PlayMode))) foreach (var ruleset in RulesetCollection.AllRulesets)
{
modes.Add(new TextAwesome modes.Add(new TextAwesome
{ {
Icon = RulesetCollection.GetRuleset(m).Icon, Icon = ruleset.Icon,
Colour = Color4.Gray, Colour = Color4.Gray,
TextSize = 20 TextSize = 20
}); });
}
Children = new Drawable[] Children = new Drawable[]
{ {

View File

@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Toolbar
public const float TOOLTIP_HEIGHT = 30; public const float TOOLTIP_HEIGHT = 30;
public Action OnHome; public Action OnHome;
public Action<PlayMode> OnPlayModeChange; public Action<Ruleset> OnRulesetChange;
private readonly ToolbarModeSelector modeSelector; private readonly ToolbarModeSelector modeSelector;
private readonly ToolbarUserArea userArea; private readonly ToolbarUserArea userArea;
@ -55,9 +55,9 @@ namespace osu.Game.Overlays.Toolbar
}, },
modeSelector = new ToolbarModeSelector modeSelector = new ToolbarModeSelector
{ {
OnPlayModeChange = mode => OnRulesetChange = mode =>
{ {
OnPlayModeChange?.Invoke(mode); OnRulesetChange?.Invoke(mode);
} }
} }
} }
@ -129,7 +129,7 @@ namespace osu.Game.Overlays.Toolbar
} }
} }
public void SetGameMode(PlayMode mode) => modeSelector.SetGameMode(mode); public void SetGameMode(Ruleset ruleset) => modeSelector.SetGameMode(ruleset);
protected override void PopIn() protected override void PopIn()
{ {

View File

@ -9,16 +9,16 @@ namespace osu.Game.Overlays.Toolbar
{ {
public class ToolbarModeButton : ToolbarButton public class ToolbarModeButton : ToolbarButton
{ {
private PlayMode mode; private Ruleset ruleset;
public PlayMode Mode public Ruleset Ruleset
{ {
get { return mode; } get { return ruleset; }
set set
{ {
mode = value; ruleset = value;
TooltipMain = Ruleset.GetRuleset(mode).Description; TooltipMain = ruleset.Description;
TooltipSub = $"Play some {Ruleset.GetRuleset(mode).Description}"; TooltipSub = $"Play some {ruleset.Description}";
Icon = Ruleset.GetRuleset(mode).Icon; Icon = ruleset.Icon;
} }
} }

View File

@ -22,7 +22,7 @@ namespace osu.Game.Overlays.Toolbar
private readonly Drawable modeButtonLine; private readonly Drawable modeButtonLine;
private ToolbarModeButton activeButton; private ToolbarModeButton activeButton;
public Action<PlayMode> OnPlayModeChange; public Action<Ruleset> OnRulesetChange;
public ToolbarModeSelector() public ToolbarModeSelector()
{ {
@ -63,15 +63,15 @@ namespace osu.Game.Overlays.Toolbar
} }
}; };
foreach (PlayMode m in Ruleset.PlayModes) foreach (var ruleset in RulesetCollection.AllRulesets)
{ {
modeButtons.Add(new ToolbarModeButton modeButtons.Add(new ToolbarModeButton
{ {
Mode = m, Ruleset = ruleset,
Action = delegate Action = delegate
{ {
SetGameMode(m); SetGameMode(ruleset);
OnPlayModeChange?.Invoke(m); OnRulesetChange?.Invoke(ruleset);
} }
}); });
} }
@ -84,11 +84,11 @@ namespace osu.Game.Overlays.Toolbar
Size = new Vector2(modeButtons.DrawSize.X, 1); Size = new Vector2(modeButtons.DrawSize.X, 1);
} }
public void SetGameMode(PlayMode mode) public void SetGameMode(Ruleset ruleset)
{ {
foreach (ToolbarModeButton m in modeButtons.Children.Cast<ToolbarModeButton>()) foreach (ToolbarModeButton m in modeButtons.Children.Cast<ToolbarModeButton>())
{ {
bool isActive = m.Mode == mode; bool isActive = m.Ruleset == ruleset;
m.Active = isActive; m.Active = isActive;
if (isActive) if (isActive)
activeButton = m; activeButton = m;

View File

@ -63,13 +63,6 @@ namespace osu.Game.Screens.Play
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config) private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config)
{ {
if (Beatmap.Beatmap.BeatmapInfo?.Mode > (int)PlayMode.Taiko)
{
//we only support osu! mode for now because the hitobject parsing is crappy and needs a refactor.
Exit();
return;
}
dimLevel = config.GetBindable<int>(OsuConfig.DimLevel); dimLevel = config.GetBindable<int>(OsuConfig.DimLevel);
mouseWheelDisabled = config.GetBindable<bool>(OsuConfig.MouseDisableWheel); mouseWheelDisabled = config.GetBindable<bool>(OsuConfig.MouseDisableWheel);
@ -109,7 +102,7 @@ namespace osu.Game.Screens.Play
sourceClock.Reset(); sourceClock.Reset();
}); });
ruleset = RulesetCollection.GetRuleset(Beatmap.PlayMode); ruleset = Beatmap.BeatmapInfo.Ruleset;
HitRenderer = ruleset.CreateHitRendererWith(Beatmap); HitRenderer = ruleset.CreateHitRendererWith(Beatmap);
scoreProcessor = HitRenderer.CreateScoreProcessor(); scoreProcessor = HitRenderer.CreateScoreProcessor();

View File

@ -61,7 +61,7 @@ namespace osu.Game.Screens.Select
Group = group, Group = group,
Sort = sort, Sort = sort,
SearchText = searchTextBox.Text, SearchText = searchTextBox.Text,
Mode = playMode Ruleset = ruleset
}; };
public Action Exit; public Action Exit;
@ -163,16 +163,17 @@ namespace osu.Game.Screens.Select
searchTextBox.HoldFocus = true; searchTextBox.HoldFocus = true;
} }
private readonly Bindable<PlayMode> playMode = new Bindable<PlayMode>(); private readonly Bindable<Ruleset> ruleset = new Bindable<Ruleset>();
[BackgroundDependencyLoader(permitNulls:true)] [BackgroundDependencyLoader(permitNulls:true)]
private void load(OsuColour colours, OsuGame osu) private void load(OsuColour colours, OsuGame osu)
{ {
sortTabs.AccentColour = colours.GreenLight; sortTabs.AccentColour = colours.GreenLight;
if (osu != null) playMode.BindTo(osu.PlayMode); if (osu != null)
playMode.ValueChanged += val => FilterChanged?.Invoke(CreateCriteria()); ruleset.BindTo(osu.Ruleset);
playMode.TriggerChange(); ruleset.ValueChanged += val => FilterChanged?.Invoke(CreateCriteria());
ruleset.TriggerChange();
} }
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;

View File

@ -15,7 +15,7 @@ namespace osu.Game.Screens.Select
public GroupMode Group; public GroupMode Group;
public SortMode Sort; public SortMode Sort;
public string SearchText; public string SearchText;
public PlayMode Mode; public Ruleset Ruleset;
public void Filter(List<BeatmapGroup> groups) public void Filter(List<BeatmapGroup> groups)
{ {
@ -23,7 +23,7 @@ namespace osu.Game.Screens.Select
{ {
var set = g.BeatmapSet; var set = g.BeatmapSet;
bool hasCurrentMode = set.Beatmaps.Any(bm => bm.Mode == (int)Mode); bool hasCurrentMode = set.Beatmaps.Any(bm => bm.Ruleset == Ruleset);
bool match = hasCurrentMode; bool match = hasCurrentMode;

View File

@ -29,7 +29,7 @@ namespace osu.Game.Screens.Select
{ {
public abstract class SongSelect : OsuScreen public abstract class SongSelect : OsuScreen
{ {
private readonly Bindable<PlayMode> playMode = new Bindable<PlayMode>(); private readonly Bindable<Ruleset> ruleset = new Bindable<Ruleset>();
private BeatmapDatabase database; private BeatmapDatabase database;
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
@ -170,8 +170,8 @@ namespace osu.Game.Screens.Select
if (database == null) if (database == null)
database = beatmaps; database = beatmaps;
playMode.ValueChanged += val => { if (Beatmap != null) Beatmap.PreferredPlayMode = val; }; if (osu != null)
if (osu != null) playMode.BindTo(osu.PlayMode); ruleset.BindTo(osu.Ruleset);
database.BeatmapSetAdded += onBeatmapSetAdded; database.BeatmapSetAdded += onBeatmapSetAdded;
database.BeatmapSetRemoved += onBeatmapSetRemoved; database.BeatmapSetRemoved += onBeatmapSetRemoved;
@ -200,7 +200,6 @@ namespace osu.Game.Screens.Select
{ {
if (Beatmap == null) return; if (Beatmap == null) return;
Beatmap.PreferredPlayMode = playMode.Value;
OnSelected(); OnSelected();
} }

View File

@ -217,7 +217,6 @@
<Compile Include="Beatmaps\Drawables\BeatmapPanel.cs" /> <Compile Include="Beatmaps\Drawables\BeatmapPanel.cs" />
<Compile Include="Screens\Play\Player.cs" /> <Compile Include="Screens\Play\Player.cs" />
<Compile Include="Screens\Charts\ChartListing.cs" /> <Compile Include="Screens\Charts\ChartListing.cs" />
<Compile Include="Modes\PlayMode.cs" />
<Compile Include="Modes\Ruleset.cs" /> <Compile Include="Modes\Ruleset.cs" />
<Compile Include="Screens\Ranking\Results.cs" /> <Compile Include="Screens\Ranking\Results.cs" />
<Compile Include="Screens\Direct\OnlineListing.cs" /> <Compile Include="Screens\Direct\OnlineListing.cs" />