mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 09:42:55 +08:00
Move PresentSkinsImport
to OsuGame
. Replace switch with if statement
This commit is contained in:
parent
10ab228d76
commit
f8f485e4c8
@ -49,6 +49,7 @@ using osu.Game.Overlays;
|
|||||||
using osu.Game.Overlays.BeatmapListing;
|
using osu.Game.Overlays.BeatmapListing;
|
||||||
using osu.Game.Overlays.Music;
|
using osu.Game.Overlays.Music;
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
|
using osu.Game.Overlays.Settings.Sections;
|
||||||
using osu.Game.Overlays.SkinEditor;
|
using osu.Game.Overlays.SkinEditor;
|
||||||
using osu.Game.Overlays.Toolbar;
|
using osu.Game.Overlays.Toolbar;
|
||||||
using osu.Game.Overlays.Volume;
|
using osu.Game.Overlays.Volume;
|
||||||
@ -60,6 +61,7 @@ using osu.Game.Screens.Menu;
|
|||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Screens.Ranking;
|
using osu.Game.Screens.Ranking;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
|
using osu.Game.Skinning;
|
||||||
using osu.Game.Updater;
|
using osu.Game.Updater;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
@ -501,6 +503,23 @@ namespace osu.Game
|
|||||||
/// <param name="version">The build version of the update stream</param>
|
/// <param name="version">The build version of the update stream</param>
|
||||||
public void ShowChangelogBuild(string updateStream, string version) => waitForReady(() => changelogOverlay, _ => changelogOverlay.ShowBuild(updateStream, version));
|
public void ShowChangelogBuild(string updateStream, string version) => waitForReady(() => changelogOverlay, _ => changelogOverlay.ShowBuild(updateStream, version));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Present ether a skin select if one skin was imported or navigate to the skin selection menu if multiple skins were imported immediately.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="importedSkins">List of imported skins</param>
|
||||||
|
public void PresentSkins(IEnumerable<Live<SkinInfo>> importedSkins)
|
||||||
|
{
|
||||||
|
int importedSkinsCount = importedSkins.Count();
|
||||||
|
|
||||||
|
if (importedSkinsCount == 1)
|
||||||
|
SkinManager.CurrentSkinInfo.Value = importedSkins.Single();
|
||||||
|
else if (importedSkinsCount > 1)
|
||||||
|
{
|
||||||
|
Settings.Show();
|
||||||
|
Settings.SectionsContainer.ScrollTo(Settings.SectionsContainer.Single(container => container is SkinSection));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Present a beatmap at song select immediately.
|
/// Present a beatmap at song select immediately.
|
||||||
/// The user should have already requested this interactively.
|
/// The user should have already requested this interactively.
|
||||||
@ -777,6 +796,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
// todo: all archive managers should be able to be looped here.
|
// todo: all archive managers should be able to be looped here.
|
||||||
SkinManager.PostNotification = n => Notifications.Post(n);
|
SkinManager.PostNotification = n => Notifications.Post(n);
|
||||||
|
SkinManager.PresentImport = PresentSkins;
|
||||||
|
|
||||||
BeatmapManager.PostNotification = n => Notifications.Post(n);
|
BeatmapManager.PostNotification = n => Notifications.Post(n);
|
||||||
BeatmapManager.PresentImport = items => PresentBeatmap(items.First().Value);
|
BeatmapManager.PresentImport = items => PresentBeatmap(items.First().Value);
|
||||||
|
@ -10,7 +10,6 @@ using JetBrains.Annotations;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
@ -92,27 +91,6 @@ namespace osu.Game.Overlays.Settings.Sections
|
|||||||
skins.SelectRandomSkin();
|
skins.SelectRandomSkin();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
skins.PresentSkinsImport += presentSkinsImport;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void presentSkinsImport(IEnumerable<Live<SkinInfo>> importedSkins)
|
|
||||||
{
|
|
||||||
SettingsOverlay settings = this.FindClosestParent<SettingsOverlay>();
|
|
||||||
|
|
||||||
switch (importedSkins.Count())
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
skins.CurrentSkinInfo.Value = importedSkins.Last();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case > 1:
|
|
||||||
if (settings.State.Value == Visibility.Hidden)
|
|
||||||
settings.ToggleVisibility();
|
|
||||||
|
|
||||||
settings.SectionsContainer.ScrollTo(this);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void skinsChanged(IRealmCollection<SkinInfo> sender, ChangeSet changes, Exception error)
|
private void skinsChanged(IRealmCollection<SkinInfo> sender, ChangeSet changes, Exception error)
|
||||||
|
@ -44,11 +44,6 @@ namespace osu.Game.Skinning
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Skin DefaultClassicSkin { get; }
|
public Skin DefaultClassicSkin { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Presents imported skin(s) to a user
|
|
||||||
/// </summary>
|
|
||||||
public Action<IEnumerable<Live<SkinInfo>>> PresentSkinsImport { get; set; }
|
|
||||||
|
|
||||||
private readonly AudioManager audio;
|
private readonly AudioManager audio;
|
||||||
|
|
||||||
private readonly Scheduler scheduler;
|
private readonly Scheduler scheduler;
|
||||||
@ -92,7 +87,6 @@ namespace osu.Game.Skinning
|
|||||||
skinImporter = new SkinImporter(storage, realm, this)
|
skinImporter = new SkinImporter(storage, realm, this)
|
||||||
{
|
{
|
||||||
PostNotification = obj => PostNotification?.Invoke(obj),
|
PostNotification = obj => PostNotification?.Invoke(obj),
|
||||||
PresentImport = skins => PresentSkinsImport?.Invoke(skins),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var defaultSkins = new[]
|
var defaultSkins = new[]
|
||||||
|
Loading…
Reference in New Issue
Block a user