mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 05:22:54 +08:00
Merge pull request #31220 from normalid-awa/feature/skin/rename-skin
Add ability to rename the skin
This commit is contained in:
commit
362311d040
@ -54,16 +54,6 @@ namespace osu.Game.Localisation
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static LocalisableString BeatmapHitsounds => new TranslatableString(getKey(@"beatmap_hitsounds"), @"Beatmap hitsounds");
|
public static LocalisableString BeatmapHitsounds => new TranslatableString(getKey(@"beatmap_hitsounds"), @"Beatmap hitsounds");
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// "Export selected skin"
|
|
||||||
/// </summary>
|
|
||||||
public static LocalisableString ExportSkinButton => new TranslatableString(getKey(@"export_skin_button"), @"Export selected skin");
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// "Delete selected skin"
|
|
||||||
/// </summary>
|
|
||||||
public static LocalisableString DeleteSkinButton => new TranslatableString(getKey(@"delete_skin_button"), @"Delete selected skin");
|
|
||||||
|
|
||||||
private static string getKey(string key) => $"{prefix}:{key}";
|
private static string getKey(string key) => $"{prefix}:{key}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,17 +9,23 @@ using System.Linq;
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
using osu.Game.Overlays.SkinEditor;
|
using osu.Game.Overlays.SkinEditor;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
using osuTK;
|
||||||
using Realms;
|
using Realms;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Settings.Sections
|
namespace osu.Game.Overlays.Settings.Sections
|
||||||
@ -64,13 +70,26 @@ namespace osu.Game.Overlays.Settings.Sections
|
|||||||
Current = skins.CurrentSkinInfo,
|
Current = skins.CurrentSkinInfo,
|
||||||
Keywords = new[] { @"skins" },
|
Keywords = new[] { @"skins" },
|
||||||
},
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Spacing = new Vector2(5, 0),
|
||||||
|
Padding = new MarginPadding { Left = SettingsPanel.CONTENT_MARGINS, Right = SettingsPanel.CONTENT_MARGINS },
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
// This is all super-temporary until we move skin settings to their own panel / overlay.
|
||||||
|
new RenameSkinButton { Padding = new MarginPadding(), RelativeSizeAxes = Axes.None, Width = 120 },
|
||||||
|
new ExportSkinButton { Padding = new MarginPadding(), RelativeSizeAxes = Axes.None, Width = 120 },
|
||||||
|
new DeleteSkinButton { Padding = new MarginPadding(), RelativeSizeAxes = Axes.None, Width = 110 },
|
||||||
|
}
|
||||||
|
},
|
||||||
new SettingsButton
|
new SettingsButton
|
||||||
{
|
{
|
||||||
Text = SkinSettingsStrings.SkinLayoutEditor,
|
Text = SkinSettingsStrings.SkinLayoutEditor,
|
||||||
Action = () => skinEditor?.ToggleVisibility(),
|
Action = () => skinEditor?.ToggleVisibility(),
|
||||||
},
|
},
|
||||||
new ExportSkinButton(),
|
|
||||||
new DeleteSkinButton(),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,6 +155,34 @@ namespace osu.Game.Overlays.Settings.Sections
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public partial class RenameSkinButton : SettingsButton, IHasPopover
|
||||||
|
{
|
||||||
|
[Resolved]
|
||||||
|
private SkinManager skins { get; set; }
|
||||||
|
|
||||||
|
private Bindable<Skin> currentSkin;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
Text = "Rename";
|
||||||
|
Action = this.ShowPopover;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
currentSkin = skins.CurrentSkin.GetBoundCopy();
|
||||||
|
currentSkin.BindValueChanged(skin => Enabled.Value = skin.NewValue.SkinInfo.PerformRead(s => !s.Protected), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Popover GetPopover()
|
||||||
|
{
|
||||||
|
return new RenameSkinPopover();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public partial class ExportSkinButton : SettingsButton
|
public partial class ExportSkinButton : SettingsButton
|
||||||
{
|
{
|
||||||
[Resolved]
|
[Resolved]
|
||||||
@ -146,7 +193,7 @@ namespace osu.Game.Overlays.Settings.Sections
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
Text = SkinSettingsStrings.ExportSkinButton;
|
Text = "Export";
|
||||||
Action = export;
|
Action = export;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +231,7 @@ namespace osu.Game.Overlays.Settings.Sections
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
Text = SkinSettingsStrings.DeleteSkinButton;
|
Text = "Delete";
|
||||||
Action = delete;
|
Action = delete;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,5 +248,63 @@ namespace osu.Game.Overlays.Settings.Sections
|
|||||||
dialogOverlay?.Push(new SkinDeleteDialog(currentSkin.Value));
|
dialogOverlay?.Push(new SkinDeleteDialog(currentSkin.Value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public partial class RenameSkinPopover : OsuPopover
|
||||||
|
{
|
||||||
|
[Resolved]
|
||||||
|
private SkinManager skins { get; set; }
|
||||||
|
|
||||||
|
private readonly FocusedTextBox textBox;
|
||||||
|
|
||||||
|
public RenameSkinPopover()
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
Origin = Anchor.TopCentre;
|
||||||
|
|
||||||
|
RoundedButton renameButton;
|
||||||
|
|
||||||
|
Child = new FillFlowContainer
|
||||||
|
{
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Width = 250,
|
||||||
|
Spacing = new Vector2(10f),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
textBox = new FocusedTextBox
|
||||||
|
{
|
||||||
|
PlaceholderText = @"Skin name",
|
||||||
|
FontSize = OsuFont.DEFAULT_FONT_SIZE,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
SelectAllOnFocus = true,
|
||||||
|
},
|
||||||
|
renameButton = new RoundedButton
|
||||||
|
{
|
||||||
|
Height = 40,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
MatchingFilter = true,
|
||||||
|
Text = "Save",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
renameButton.Action += rename;
|
||||||
|
textBox.OnCommit += (_, _) => rename();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void PopIn()
|
||||||
|
{
|
||||||
|
textBox.Text = skins.CurrentSkinInfo.Value.Value.Name;
|
||||||
|
textBox.TakeFocus();
|
||||||
|
|
||||||
|
base.PopIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rename() => skins.CurrentSkinInfo.Value.PerformWrite(skin =>
|
||||||
|
{
|
||||||
|
skin.Name = textBox.Text;
|
||||||
|
PopOut();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user