Merge pull request #589 from peppy/general-fixes

Resources + framework update
This commit is contained in:
Dan Balasescu 2017-04-04 20:32:07 +09:00 committed by GitHub
commit cbb669add3
32 changed files with 91 additions and 185 deletions

@ -1 +1 @@
Subproject commit 1c08c1fec496e9d64ba8f30ff0464cd5cdf567b6
Subproject commit e9b388934ed77cbc1af3cdfd213eb754f71554ae

@ -1 +1 @@
Subproject commit 12bbab717d372dadbd3220d38da862276ac97e98
Subproject commit 0d6dc294738d433999c6c68ff61169d3a8e6ce5f

View File

@ -3,15 +3,12 @@
using osu.Framework.Testing;
using osu.Framework.Graphics.Containers;
using osu.Framework.Threading;
using osu.Game.Overlays;
namespace osu.Desktop.VisualTests.Tests
{
internal class TestCaseChatDisplay : TestCase
{
private ScheduledDelegate messageRequest;
public override string Description => @"Testing chat api and overlay";
public override void Reset()

View File

@ -112,7 +112,7 @@ namespace osu.Desktop.VisualTests.Tests
Width = 150,
Height = 10,
SelectionColor = Color4.Orange,
Bindable = playbackSpeed
Value = playbackSpeed
}
}
});

View File

@ -57,7 +57,7 @@ namespace osu.Desktop.VisualTests.Tests
Width = 150,
Height = 10,
SelectionColor = Color4.Orange,
Bindable = bindable
Value = bindable
}
}
});

View File

@ -14,7 +14,7 @@ namespace osu.Desktop.VisualTests.Tests
{
internal class TestCasePlaySongSelect : TestCase
{
private BeatmapDatabase db, oldDb;
private BeatmapDatabase db;
private TestStorage storage;
private PlaySongSelect songSelect;
@ -44,13 +44,13 @@ namespace osu.Desktop.VisualTests.Tests
AddStep(@"Sort by Difficulty", delegate { songSelect.FilterControl.Sort = SortMode.Difficulty; });
}
protected override void Dispose(bool isDisposing)
{
if (oldDb != null)
db = null;
//protected override void Dispose(bool isDisposing)
//{
// if (oldDb != null)
// db = null;
base.Dispose(isDisposing);
}
// base.Dispose(isDisposing);
//}
private BeatmapSetInfo createTestBeatmapSet(int i)
{

View File

@ -1,24 +1,15 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Input.Handlers;
using osu.Game.Beatmaps;
using osu.Game.Modes.Mods;
using osu.Game.Modes.Osu.Mods;
using osu.Game.Screens.Play;
using System;
using System.IO;
namespace osu.Desktop.VisualTests.Tests
{
internal class TestCaseReplay : TestCasePlayer
{
private WorkingBeatmap beatmap;
private InputHandler replay;
private Func<Stream> getReplayStream;
public override string Description => @"Testing replay playback.";
protected override Player CreatePlayer(WorkingBeatmap beatmap)

View File

@ -22,8 +22,6 @@ namespace osu.Desktop.VisualTests.Tests
int numerator = 0, denominator = 0;
bool maniaHold = false;
ScoreCounter score = new ScoreCounter(7)
{
Origin = Anchor.TopRight,

View File

@ -36,9 +36,9 @@ namespace osu.Desktop.VisualTests.Tests
filter.PinItem(GroupMode.All);
filter.PinItem(GroupMode.RecentlyPlayed);
filter.ItemChanged += (sender, mode) =>
filter.SelectedItem.ValueChanged += newFilter =>
{
text.Text = "Currently Selected: " + mode.ToString();
text.Text = "Currently Selected: " + newFilter.ToString();
};
}
}

View File

@ -22,8 +22,9 @@ namespace osu.Game.Beatmaps.Drawables
public Action<BeatmapSetHeader> GainedSelection;
private readonly SpriteText title;
private readonly SpriteText artist;
private OsuConfigManager config;
private Bindable<bool> preferUnicode;
private readonly WorkingBeatmap beatmap;
private readonly FillFlowContainer difficultyIcons;
@ -83,24 +84,13 @@ namespace osu.Game.Beatmaps.Drawables
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
this.config = config;
preferUnicode = config.GetBindable<bool>(OsuConfig.ShowUnicode);
preferUnicode.ValueChanged += preferUnicode_changed;
preferUnicode_changed(preferUnicode, null);
}
private void preferUnicode_changed(object sender, EventArgs e)
{
title.Text = config.GetUnicodeString(beatmap.BeatmapSetInfo.Metadata.Title, beatmap.BeatmapSetInfo.Metadata.TitleUnicode);
artist.Text = config.GetUnicodeString(beatmap.BeatmapSetInfo.Metadata.Artist, beatmap.BeatmapSetInfo.Metadata.ArtistUnicode);
}
protected override void Dispose(bool isDisposing)
{
if (preferUnicode != null)
preferUnicode.ValueChanged -= preferUnicode_changed;
base.Dispose(isDisposing);
preferUnicode.ValueChanged += unicode =>
{
title.Text = unicode ? beatmap.BeatmapSetInfo.Metadata.TitleUnicode : beatmap.BeatmapSetInfo.Metadata.Title;
artist.Text = unicode ? beatmap.BeatmapSetInfo.Metadata.ArtistUnicode : beatmap.BeatmapSetInfo.Metadata.Artist;
};
preferUnicode.TriggerChange();
}
private class PanelBackground : BufferedContainer

View File

@ -187,10 +187,6 @@ namespace osu.Game.Configuration
#pragma warning restore CS0612 // Type or member is obsolete
}
//todo: make a UnicodeString class/struct rather than requiring this helper method.
public string GetUnicodeString(string nonunicode, string unicode)
=> Get<bool>(OsuConfig.ShowUnicode) ? unicode ?? nonunicode : nonunicode ?? unicode;
public OsuConfigManager(Storage storage) : base(storage)
{
}

View File

@ -12,7 +12,6 @@ using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input;
using osu.Game.Configuration;
using System;
namespace osu.Game.Graphics.Cursor
{
@ -116,14 +115,9 @@ namespace osu.Game.Graphics.Cursor
};
cursorScale = config.GetBindable<double>(OsuConfig.GameplayCursorSize);
cursorScale.ValueChanged += scaleChanged;
cursorScale.ValueChanged += newScale => cursorContainer.Scale = new Vector2((float)cursorScale);
cursorScale.TriggerChange();
}
private void scaleChanged(object sender, EventArgs e)
{
cursorContainer.Scale = new Vector2((float)cursorScale);
}
}
}
}

View File

@ -131,14 +131,9 @@ namespace osu.Game.Graphics.Cursor
};
cursorScale = config.GetBindable<double>(OsuConfig.MenuCursorSize);
cursorScale.ValueChanged += scaleChanged;
cursorScale.ValueChanged += newScale => cursorContainer.Scale = new Vector2((float)newScale);
cursorScale.TriggerChange();
}
private void scaleChanged(object sender, EventArgs e)
{
cursorContainer.Scale = new Vector2((float)cursorScale);
}
}
}
}

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
@ -86,9 +85,9 @@ namespace osu.Game.Graphics.UserInterface
};
}
private void bindableValueChanged(object sender, EventArgs e)
private void bindableValueChanged(bool isChecked)
{
State = bindable.Value ? CheckboxState.Checked : CheckboxState.Unchecked;
State = isChecked ? CheckboxState.Checked : CheckboxState.Unchecked;
}
protected override void Dispose(bool isDisposing)

View File

@ -21,7 +21,7 @@ namespace osu.Game.Graphics.UserInterface
{
protected override Dropdown<T> CreateDropdown() => new OsuTabDropdown();
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem { Value = value };
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem(value);
protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || Dropdown.Contains(screenSpacePos);
@ -75,16 +75,6 @@ namespace osu.Game.Graphics.UserInterface
}
}
public new T Value
{
get { return base.Value; }
set
{
base.Value = value;
text.Text = (value as Enum)?.GetDescription();
}
}
public override bool Active
{
get { return base.Active; }
@ -134,30 +124,31 @@ namespace osu.Game.Graphics.UserInterface
AccentColour = colours.Blue;
}
public OsuTabItem()
public OsuTabItem(T value) : base(value)
{
AutoSizeAxes = Axes.X;
RelativeSizeAxes = Axes.Y;
Children = new Drawable[]
{
text = new OsuSpriteText
{
Margin = new MarginPadding { Top = 5, Bottom = 5 },
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
TextSize = 14,
Font = @"Exo2.0-Bold", // Font should only turn bold when active?
},
box = new Box
{
RelativeSizeAxes = Axes.X,
Height = 1,
Alpha = 0,
Colour = Color4.White,
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
}
text = new OsuSpriteText
{
Margin = new MarginPadding { Top = 5, Bottom = 5 },
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Text = (value as Enum)?.GetDescription(),
TextSize = 14,
Font = @"Exo2.0-Bold", // Font should only turn bold when active?
},
box = new Box
{
RelativeSizeAxes = Axes.X,
Height = 1,
Alpha = 0,
Colour = Color4.White,
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
}
};
}
}

View File

@ -98,13 +98,10 @@ namespace osu.Game.Graphics.UserInterface
DisplayedCount = Current;
Current.ValueChanged += currentChanged;
}
private void currentChanged(object sender, EventArgs e)
{
if (IsLoaded)
TransformCount(displayedCount, Current);
Current.ValueChanged += newValue =>
{
if (IsLoaded) TransformCount(displayedCount, newValue);
};
}
protected override void LoadComplete()

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
@ -19,7 +18,7 @@ namespace osu.Game.Graphics.UserInterface.Volume
protected override bool HideOnEscape => false;
private void volumeChanged(object sender, EventArgs e)
private void volumeChanged(double newVolume)
{
Show();
schedulePopOut();

View File

@ -66,12 +66,7 @@ namespace osu.Game.Modes.UI
TextSize = 80;
Current.ValueChanged += comboChanged;
}
private void comboChanged(object sender, System.EventArgs e)
{
updateCount(Current.Value == 0);
Current.ValueChanged += newValue => updateCount(newValue == 0);
}
protected override void LoadComplete()

View File

@ -16,7 +16,7 @@ namespace osu.Game.Modes.UI
protected HealthDisplay()
{
Current.ValueChanged += (s, e) => SetHealth((float)Current);
Current.ValueChanged += newValue => SetHealth((float)newValue);
}
protected abstract void SetHealth(float value);

View File

@ -8,7 +8,6 @@ using osu.Framework.Graphics.Containers;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Play;
using System;
using osu.Game.Modes.Scoring;
namespace osu.Game.Modes.UI
@ -47,22 +46,18 @@ namespace osu.Game.Modes.UI
private void load(OsuConfigManager config)
{
showKeyCounter = config.GetBindable<bool>(OsuConfig.KeyOverlay);
showKeyCounter.ValueChanged += visibilityChanged;
showKeyCounter.ValueChanged += visibility =>
{
if (visibility)
KeyCounter.Show();
else
KeyCounter.Hide();
};
showKeyCounter.TriggerChange();
}
private void visibilityChanged(object sender, EventArgs e)
{
if (showKeyCounter)
KeyCounter.Show();
else
KeyCounter.Hide();
}
public void BindProcessor(ScoreProcessor processor)
{
//bind processor bindables to combocounter, score display etc.
//TODO: these should be bindable binds, not events!
ScoreCounter?.Current.BindTo(processor.TotalScore);
AccuracyCounter?.Current.BindTo(processor.Accuracy);
ComboCounter?.Current.BindTo(processor.Combo);

View File

@ -92,7 +92,10 @@ namespace osu.Game
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Medium"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-MediumItalic"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Basic"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-Hangul"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Basic"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Noto-CJK-Compatibility"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-Regular"));
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Exo2.0-RegularItalic"));

View File

@ -39,9 +39,9 @@ namespace osu.Game.Overlays.Mods
public readonly Bindable<PlayMode> PlayMode = new Bindable<PlayMode>();
private void modeChanged(object sender, EventArgs eventArgs)
private void modeChanged(PlayMode newMode)
{
var ruleset = Ruleset.GetRuleset(PlayMode);
var ruleset = Ruleset.GetRuleset(newMode);
foreach (ModSection section in modSectionsContainer.Children)
section.Buttons = ruleset.GetModsFor(section.ModType).Select(m => new ModButton(m)).ToArray();
refreshSelectedMods();
@ -56,7 +56,7 @@ namespace osu.Game.Overlays.Mods
if (osu != null)
PlayMode.BindTo(osu.PlayMode);
PlayMode.ValueChanged += modeChanged;
modeChanged(null, null);
PlayMode.TriggerChange();
}
protected override void PopOut()

View File

@ -78,8 +78,6 @@ namespace osu.Game.Overlays
[BackgroundDependencyLoader]
private void load(OsuGameBase game, OsuConfigManager config, BeatmapDatabase beatmaps, OsuColour colours)
{
unicodeString = config.GetUnicodeString;
Children = new Drawable[]
{
dragContainer = new Container
@ -210,7 +208,7 @@ namespace osu.Game.Overlays
this.beatmaps = beatmaps;
trackManager = game.Audio.Track;
preferUnicode = config.GetBindable<bool>(OsuConfig.ShowUnicode);
preferUnicode.ValueChanged += preferUnicode_changed;
preferUnicode.ValueChanged += unicode => updateDisplay(current, TransformDirection.None);
beatmapSource = game.Beatmap ?? new Bindable<WorkingBeatmap>();
playList = beatmaps.GetAllWithChildren<BeatmapSetInfo>();
@ -222,7 +220,8 @@ namespace osu.Game.Overlays
protected override void LoadComplete()
{
beatmapSource.ValueChanged += workingChanged;
workingChanged();
beatmapSource.TriggerChange();
base.LoadComplete();
}
@ -247,17 +246,12 @@ namespace osu.Game.Overlays
playButton.Icon = FontAwesome.fa_play_circle_o;
}
private void preferUnicode_changed(object sender, EventArgs e)
private void workingChanged(WorkingBeatmap beatmap)
{
updateDisplay(current, TransformDirection.None);
}
private void workingChanged(object sender = null, EventArgs e = null)
{
progress.IsEnabled = beatmapSource.Value != null;
if (beatmapSource.Value == current) return;
bool audioEquals = current?.BeatmapInfo?.AudioEquals(beatmapSource?.Value?.BeatmapInfo) ?? false;
current = beatmapSource.Value;
progress.IsEnabled = beatmap != null;
if (beatmap == current) return;
bool audioEquals = current?.BeatmapInfo?.AudioEquals(beatmap?.BeatmapInfo) ?? false;
current = beatmap;
updateDisplay(current, audioEquals ? TransformDirection.None : TransformDirection.Next);
appendToHistory(current?.BeatmapInfo);
}
@ -342,8 +336,8 @@ namespace osu.Game.Overlays
else
{
BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
title.Text = unicodeString(metadata.Title, metadata.TitleUnicode);
artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode);
title.Text = preferUnicode ? metadata.TitleUnicode : metadata.Title;
artist.Text = preferUnicode ? metadata.ArtistUnicode : metadata.Artist;
}
});
@ -374,21 +368,12 @@ namespace osu.Game.Overlays
};
}
private Func<string, string, string> unicodeString;
private void seek(float position)
{
current?.Track?.Seek(current.Track.Length * position);
current?.Track?.Start();
}
protected override void Dispose(bool isDisposing)
{
if (preferUnicode != null)
preferUnicode.ValueChanged -= preferUnicode_changed;
base.Dispose(isDisposing);
}
private const float transition_length = 800;
protected override void PopIn()

View File

@ -29,10 +29,10 @@ namespace osu.Game.Overlays.Options
public BindableNumber<T> Bindable
{
get { return slider.Bindable; }
get { return slider.Value; }
set
{
slider.Bindable = value;
slider.Value = value;
if (value?.Disabled ?? true)
Alpha = 0.3f;
}

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Configuration;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface;
@ -41,10 +40,7 @@ namespace osu.Game.Overlays.Options
bindable.Value = Text;
}
private void bindableValueChanged(object sender, EventArgs e)
{
Text = bindable.Value;
}
private void bindableValueChanged(string newValue) => Text = newValue;
protected override void Dispose(bool isDisposing)
{

View File

@ -5,7 +5,6 @@ using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
using System;
namespace osu.Game.Overlays.Options.Sections.Graphics
{
@ -52,9 +51,9 @@ namespace osu.Game.Overlays.Options.Sections.Graphics
letterboxing.TriggerChange();
}
private void visibilityChanged(object sender, EventArgs e)
private void visibilityChanged(bool newVisibility)
{
if (letterboxing)
if (newVisibility)
{
letterboxPositionX.Show();
letterboxPositionY.Show();

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Screens;
@ -40,11 +39,6 @@ namespace osu.Game.Screens
}
}
private void beatmap_ValueChanged(object sender, EventArgs e)
{
OnBeatmapChanged(beatmap.Value);
}
[BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuGameBase game)
{
@ -57,7 +51,7 @@ namespace osu.Game.Screens
beatmap.Value = localMap;
}
beatmap.ValueChanged += beatmap_ValueChanged;
beatmap.ValueChanged += OnBeatmapChanged;
}
protected virtual void OnBeatmapChanged(WorkingBeatmap beatmap)

View File

@ -275,7 +275,8 @@ namespace osu.Game.Screens.Play
Background?.FadeTo((100f - dimLevel) / 100, 1500, EasingTypes.OutQuint);
Content.Alpha = 0;
dimLevel.ValueChanged += dimChanged;
dimLevel.ValueChanged += newDim => Background?.FadeTo((100f - newDim) / 100, 800);
Content.ScaleTo(0.7f);
@ -318,18 +319,11 @@ namespace osu.Game.Screens.Play
{
FadeOut(250);
Content.ScaleTo(0.7f, 750, EasingTypes.InQuint);
dimLevel.ValueChanged -= dimChanged;
Background?.FadeTo(1f, 200);
return base.OnExiting(next);
}
}
private void dimChanged(object sender, EventArgs e)
{
Background?.FadeTo((100f - dimLevel) / 100, 800);
}
private Bindable<bool> mouseWheelDisabled;
protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !IsPaused;

View File

@ -61,10 +61,10 @@ namespace osu.Game.Screens.Select
},
};
tabs.ItemChanged += (sender, e) => invokeOnFilter();
tabs.SelectedItem.ValueChanged += item => invokeOnFilter();
modsCheckbox.Action += (sender, e) => invokeOnFilter();
tabs.SelectedItem = BeatmapDetailTab.Global;
tabs.SelectedItem.Value = BeatmapDetailTab.Global;
}
}

View File

@ -151,8 +151,8 @@ namespace osu.Game.Screens.Select
groupTabs.PinItem(GroupMode.All);
groupTabs.PinItem(GroupMode.RecentlyPlayed);
groupTabs.ItemChanged += (sender, value) => Group = value;
sortTabs.ItemChanged += (sender, value) => Sort = value;
groupTabs.SelectedItem.ValueChanged += val => Group = val;
sortTabs.SelectedItem.ValueChanged += val => Sort = val;
}
public void Deactivate()
@ -175,7 +175,7 @@ namespace osu.Game.Screens.Select
if (osu != null)
playMode.BindTo(osu.PlayMode);
playMode.ValueChanged += (s, e) => FilterChanged?.Invoke(CreateCriteria());
playMode.ValueChanged += val => FilterChanged?.Invoke(CreateCriteria());
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;

View File

@ -157,6 +157,7 @@ namespace osu.Game.Screens.Select.Leaderboards
})
{
TimeBeforeLoad = 500,
RelativeSizeAxes = Axes.None,
Size = new Vector2(HEIGHT - edge_margin * 2, HEIGHT - edge_margin * 2),
},
new Container

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using System.Threading;
using OpenTK;
@ -170,7 +169,7 @@ namespace osu.Game.Screens.Select
if (osu != null)
playMode.BindTo(osu.PlayMode);
playMode.ValueChanged += playMode_ValueChanged;
playMode.ValueChanged += val => Beatmap.PreferredPlayMode = val;
if (database == null)
database = beatmaps;
@ -276,8 +275,6 @@ namespace osu.Game.Screens.Select
initialAddSetsTask.Cancel();
}
private void playMode_ValueChanged(object sender, EventArgs e) => Beatmap.PreferredPlayMode = playMode;
private void changeBackground(WorkingBeatmap beatmap)
{
var backgroundModeBeatmap = Background as BackgroundScreenBeatmap;