mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Add hotkey to select random skin
This commit is contained in:
@ -189,7 +189,7 @@ namespace osu.Game.Configuration
|
|||||||
new TrackedSetting<int>(OsuSetting.Skin, m =>
|
new TrackedSetting<int>(OsuSetting.Skin, m =>
|
||||||
{
|
{
|
||||||
string skinName = LookupSkinName(m) ?? string.Empty;
|
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.Space, GlobalAction.Select),
|
||||||
new KeyBinding(InputKey.Enter, GlobalAction.Select),
|
new KeyBinding(InputKey.Enter, GlobalAction.Select),
|
||||||
new KeyBinding(InputKey.KeypadEnter, GlobalAction.Select),
|
new KeyBinding(InputKey.KeypadEnter, GlobalAction.Select),
|
||||||
|
|
||||||
|
new KeyBinding(new[] { InputKey.Control, InputKey.Shift, InputKey.R }, GlobalAction.RandomSkin),
|
||||||
};
|
};
|
||||||
|
|
||||||
public IEnumerable<KeyBinding> EditorKeyBindings => new[]
|
public IEnumerable<KeyBinding> EditorKeyBindings => new[]
|
||||||
@ -191,5 +193,8 @@ namespace osu.Game.Input.Bindings
|
|||||||
|
|
||||||
[Description("Hold for HUD")]
|
[Description("Hold for HUD")]
|
||||||
HoldForHUD,
|
HoldForHUD,
|
||||||
|
|
||||||
|
[Description("Random Skin")]
|
||||||
|
RandomSkin,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -887,6 +887,10 @@ namespace osu.Game
|
|||||||
case GlobalAction.ToggleGameplayMouseButtons:
|
case GlobalAction.ToggleGameplayMouseButtons:
|
||||||
LocalConfig.Set(OsuSetting.MouseDisableButtons, !LocalConfig.Get<bool>(OsuSetting.MouseDisableButtons));
|
LocalConfig.Set(OsuSetting.MouseDisableButtons, !LocalConfig.Get<bool>(OsuSetting.MouseDisableButtons));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case GlobalAction.RandomSkin:
|
||||||
|
SkinManager.SelectRandomSkin();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -9,7 +9,6 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Utils;
|
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
@ -103,7 +102,7 @@ namespace osu.Game.Overlays.Settings.Sections
|
|||||||
{
|
{
|
||||||
if (skin.NewValue == random_skin_info)
|
if (skin.NewValue == random_skin_info)
|
||||||
{
|
{
|
||||||
randomizeSkin();
|
skins.SelectRandomSkin();
|
||||||
return;
|
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()
|
private void updateItems()
|
||||||
{
|
{
|
||||||
skinItems = skins.GetAllUsableSkins();
|
skinItems = skins.GetAllUsableSkins();
|
||||||
|
@ -19,6 +19,7 @@ using osu.Framework.Graphics.Textures;
|
|||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.IO.Archives;
|
using osu.Game.IO.Archives;
|
||||||
@ -87,6 +88,20 @@ namespace osu.Game.Skinning
|
|||||||
/// <returns>A newly allocated list of available <see cref="SkinInfo"/>.</returns>
|
/// <returns>A newly allocated list of available <see cref="SkinInfo"/>.</returns>
|
||||||
public List<SkinInfo> GetAllUserSkins() => ModelStore.ConsumableItems.Where(s => !s.DeletePending).ToList();
|
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 };
|
protected override SkinInfo CreateModel(ArchiveReader archive) => new SkinInfo { Name = archive.Name };
|
||||||
|
|
||||||
private const string unknown_creator_string = "Unknown";
|
private const string unknown_creator_string = "Unknown";
|
||||||
|
Reference in New Issue
Block a user