1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 14:53:01 +08:00

Use bindable for PlayMode.

This commit is contained in:
Dean Herbert 2017-03-02 21:14:06 +09:00
parent ab91333b21
commit e399d6c6d1
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
3 changed files with 43 additions and 47 deletions

View File

@ -28,14 +28,13 @@ namespace osu.Desktop.VisualTests.Tests
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Origin = Anchor.BottomCentre, Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
ModMode = PlayMode.Osu,
}); });
AddButton("Toggle", modSelect.ToggleVisibility); AddButton("Toggle", modSelect.ToggleVisibility);
AddButton("osu!", () => modSelect.ModMode = PlayMode.Osu); AddButton("osu!", () => modSelect.PlayMode.Value = PlayMode.Osu);
AddButton("osu!taiko", () => modSelect.ModMode = PlayMode.Taiko); AddButton("osu!taiko", () => modSelect.PlayMode.Value = PlayMode.Taiko);
AddButton("osu!catch", () => modSelect.ModMode = PlayMode.Catch); AddButton("osu!catch", () => modSelect.PlayMode.Value = PlayMode.Catch);
AddButton("osu!mania", () => modSelect.ModMode = PlayMode.Mania); AddButton("osu!mania", () => modSelect.PlayMode.Value = PlayMode.Mania);
} }
} }
} }

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using OpenTK; using OpenTK;
@ -34,53 +35,51 @@ namespace osu.Game.Overlays.Mods
public Bindable<Mod[]> SelectedMods = new Bindable<Mod[]>(); public Bindable<Mod[]> SelectedMods = new Bindable<Mod[]>();
private PlayMode modMode; public readonly Bindable<PlayMode> PlayMode = new Bindable<PlayMode>();
public PlayMode ModMode
{
get
{
return modMode;
}
set
{
modMode = value;
var ruleset = Ruleset.GetRuleset(value);
modSectionsContainer.Children = new ModSection[] private void modeChanged(object sender, EventArgs eventArgs)
{
var ruleset = Ruleset.GetRuleset(PlayMode);
modSectionsContainer.Children = new ModSection[]
{
new DifficultyReductionSection
{ {
new DifficultyReductionSection RelativeSizeAxes = Axes.X,
{ Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Action = modButtonPressed,
Anchor = Anchor.TopCentre, Buttons = ruleset.GetModsFor(ModType.DifficultyReduction).Select(m => new ModButton(m)).ToArray(),
Action = modButtonPressed, },
Buttons = ruleset.GetModsFor(ModType.DifficultyReduction).Select(m => new ModButton(m)).ToArray(), new DifficultyIncreaseSection
}, {
new DifficultyIncreaseSection RelativeSizeAxes = Axes.X,
{ Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Action = modButtonPressed,
Anchor = Anchor.TopCentre, Buttons = ruleset.GetModsFor(ModType.DifficultyIncrease).Select(m => new ModButton(m)).ToArray(),
Action = modButtonPressed, },
Buttons = ruleset.GetModsFor(ModType.DifficultyIncrease).Select(m => new ModButton(m)).ToArray(), new AssistedSection
}, {
new AssistedSection RelativeSizeAxes = Axes.X,
{ Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Action = modButtonPressed,
Anchor = Anchor.TopCentre, Buttons = ruleset.GetModsFor(ModType.Special).Select(m => new ModButton(m)).ToArray(),
Action = modButtonPressed, },
Buttons = ruleset.GetModsFor(ModType.Special).Select(m => new ModButton(m)).ToArray(), };
},
};
}
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader(permitNulls:true)]
private void load(OsuColour colours) private void load(OsuColour colours, OsuGame osu)
{ {
lowMultiplierColour = colours.Red; lowMultiplierColour = colours.Red;
highMultiplierColour = colours.Green; highMultiplierColour = colours.Green;
if (osu != null)
PlayMode.BindTo(osu.PlayMode);
PlayMode.ValueChanged += modeChanged;
PlayMode.TriggerChange();
} }
protected override void PopOut() protected override void PopOut()

View File

@ -162,7 +162,6 @@ namespace osu.Game.Screens.Select
if (osuGame != null) if (osuGame != null)
{ {
playMode = osuGame.PlayMode; playMode = osuGame.PlayMode;
modSelect.ModMode = playMode;
playMode.ValueChanged += playMode_ValueChanged; playMode.ValueChanged += playMode_ValueChanged;
} }
@ -287,7 +286,6 @@ namespace osu.Game.Screens.Select
private void playMode_ValueChanged(object sender, EventArgs e) private void playMode_ValueChanged(object sender, EventArgs e)
{ {
modSelect.ModMode = playMode;
} }
private void changeBackground(WorkingBeatmap beatmap) private void changeBackground(WorkingBeatmap beatmap)