mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 13:33:03 +08:00
Merge pull request #10789 from peppy/add-random-skin-hotkey
Add hotkey to select a new random skin
This commit is contained in:
commit
31dcdb4427
@ -189,7 +189,7 @@ namespace osu.Game.Configuration
|
||||
new TrackedSetting<int>(OsuSetting.Skin, m =>
|
||||
{
|
||||
string skinName = LookupSkinName(m) ?? string.Empty;
|
||||
return new SettingDescription(skinName, "skin", skinName);
|
||||
return new SettingDescription(skinName, "skin", skinName, $"random: {LookupKeyBindings(GlobalAction.RandomSkin)}");
|
||||
})
|
||||
};
|
||||
}
|
||||
|
@ -48,6 +48,8 @@ namespace osu.Game.Input.Bindings
|
||||
new KeyBinding(InputKey.Space, GlobalAction.Select),
|
||||
new KeyBinding(InputKey.Enter, GlobalAction.Select),
|
||||
new KeyBinding(InputKey.KeypadEnter, GlobalAction.Select),
|
||||
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.Shift, InputKey.R }, GlobalAction.RandomSkin),
|
||||
};
|
||||
|
||||
public IEnumerable<KeyBinding> EditorKeyBindings => new[]
|
||||
@ -191,5 +193,8 @@ namespace osu.Game.Input.Bindings
|
||||
|
||||
[Description("Hold for HUD")]
|
||||
HoldForHUD,
|
||||
|
||||
[Description("Random Skin")]
|
||||
RandomSkin,
|
||||
}
|
||||
}
|
||||
|
@ -892,6 +892,10 @@ namespace osu.Game
|
||||
case GlobalAction.ToggleGameplayMouseButtons:
|
||||
LocalConfig.Set(OsuSetting.MouseDisableButtons, !LocalConfig.Get<bool>(OsuSetting.MouseDisableButtons));
|
||||
return true;
|
||||
|
||||
case GlobalAction.RandomSkin:
|
||||
SkinManager.SelectRandomSkin();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -9,7 +9,6 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Skinning;
|
||||
@ -103,7 +102,7 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
{
|
||||
if (skin.NewValue == random_skin_info)
|
||||
{
|
||||
randomizeSkin();
|
||||
skins.SelectRandomSkin();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -111,20 +110,6 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
});
|
||||
}
|
||||
|
||||
private void randomizeSkin()
|
||||
{
|
||||
// choose from only user skins, removing the current selection to ensure a new one is chosen.
|
||||
var randomChoices = skinItems.Where(s => s.ID > 0 && s.ID != configBindable.Value).ToArray();
|
||||
|
||||
if (randomChoices.Length == 0)
|
||||
{
|
||||
configBindable.Value = SkinInfo.Default.ID;
|
||||
return;
|
||||
}
|
||||
|
||||
configBindable.Value = randomChoices.ElementAt(RNG.Next(0, randomChoices.Length)).ID;
|
||||
}
|
||||
|
||||
private void updateItems()
|
||||
{
|
||||
skinItems = skins.GetAllUsableSkins();
|
||||
|
@ -19,6 +19,7 @@ using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.IO.Archives;
|
||||
@ -87,6 +88,20 @@ namespace osu.Game.Skinning
|
||||
/// <returns>A newly allocated list of available <see cref="SkinInfo"/>.</returns>
|
||||
public List<SkinInfo> GetAllUserSkins() => ModelStore.ConsumableItems.Where(s => !s.DeletePending).ToList();
|
||||
|
||||
public void SelectRandomSkin()
|
||||
{
|
||||
// choose from only user skins, removing the current selection to ensure a new one is chosen.
|
||||
var randomChoices = GetAllUsableSkins().Where(s => s.ID > 0 && s.ID != CurrentSkinInfo.Value.ID).ToArray();
|
||||
|
||||
if (randomChoices.Length == 0)
|
||||
{
|
||||
CurrentSkinInfo.Value = SkinInfo.Default;
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentSkinInfo.Value = randomChoices.ElementAt(RNG.Next(0, randomChoices.Length));
|
||||
}
|
||||
|
||||
protected override SkinInfo CreateModel(ArchiveReader archive) => new SkinInfo { Name = archive.Name };
|
||||
|
||||
private const string unknown_creator_string = "Unknown";
|
||||
|
Loading…
Reference in New Issue
Block a user