mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 15:53:51 +08:00
Add hotkey hints to editor menus
This commit is contained in:
parent
0c4f5bcdaa
commit
130802e480
@ -8,6 +8,7 @@ using osu.Framework.Caching;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Catch.Edit.Blueprints.Components;
|
||||
@ -172,7 +173,10 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints
|
||||
yield return new OsuMenuItem("Add vertex", MenuItemType.Standard, () =>
|
||||
{
|
||||
editablePath.AddVertex(rightMouseDownPosition);
|
||||
});
|
||||
})
|
||||
{
|
||||
Hotkey = new Hotkey(new KeyCombination(InputKey.Control, InputKey.MouseLeft))
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
|
@ -488,8 +488,10 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
|
||||
curveTypeItems = new List<MenuItem>();
|
||||
|
||||
foreach (PathType? type in path_types)
|
||||
for (int i = 0; i < path_types.Length; ++i)
|
||||
{
|
||||
var type = path_types[i];
|
||||
|
||||
// special inherit case
|
||||
if (type == null)
|
||||
{
|
||||
@ -499,7 +501,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
curveTypeItems.Add(new OsuMenuItemSpacer());
|
||||
}
|
||||
|
||||
curveTypeItems.Add(createMenuItemForPathType(type));
|
||||
curveTypeItems.Add(createMenuItemForPathType(type, InputKey.Number1 + i));
|
||||
}
|
||||
|
||||
if (selectedPieces.Any(piece => piece.ControlPoint.Type?.Type == SplineType.Catmull))
|
||||
@ -533,7 +535,15 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
|
||||
return menuItems.ToArray();
|
||||
|
||||
CurveTypeMenuItem createMenuItemForPathType(PathType? type) => new CurveTypeMenuItem(type, _ => updatePathTypeOfSelectedPieces(type));
|
||||
CurveTypeMenuItem createMenuItemForPathType(PathType? type, InputKey? key = null)
|
||||
{
|
||||
Hotkey hotkey = default;
|
||||
|
||||
if (key != null)
|
||||
hotkey = new Hotkey(new KeyCombination(InputKey.Alt, key.Value));
|
||||
|
||||
return new CurveTypeMenuItem(type, _ => updatePathTypeOfSelectedPieces(type)) { Hotkey = hotkey };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ using osu.Framework.Caching;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Audio;
|
||||
@ -593,8 +594,14 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
changeHandler?.BeginChange();
|
||||
addControlPoint(lastRightClickPosition);
|
||||
changeHandler?.EndChange();
|
||||
}),
|
||||
new OsuMenuItem("Convert to stream", MenuItemType.Destructive, convertToStream),
|
||||
})
|
||||
{
|
||||
Hotkey = new Hotkey(new KeyCombination(InputKey.Control, InputKey.MouseLeft))
|
||||
},
|
||||
new OsuMenuItem("Convert to stream", MenuItemType.Destructive, convertToStream)
|
||||
{
|
||||
Hotkey = new Hotkey(new KeyCombination(InputKey.Control, InputKey.Shift, InputKey.F))
|
||||
},
|
||||
};
|
||||
|
||||
// Always refer to the drawable object's slider body so subsequent movement deltas are calculated with updated positions.
|
||||
|
@ -6,6 +6,7 @@ using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
@ -86,10 +87,22 @@ namespace osu.Game.Rulesets.Taiko.Edit
|
||||
protected override IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint<HitObject>> selection)
|
||||
{
|
||||
if (selection.All(s => s.Item is Hit))
|
||||
yield return new TernaryStateToggleMenuItem("Rim") { State = { BindTarget = selectionRimState } };
|
||||
{
|
||||
yield return new TernaryStateToggleMenuItem("Rim")
|
||||
{
|
||||
State = { BindTarget = selectionRimState },
|
||||
Hotkey = new Hotkey(new KeyCombination(InputKey.W), new KeyCombination(InputKey.R)),
|
||||
};
|
||||
}
|
||||
|
||||
if (selection.All(s => s.Item is TaikoHitObject))
|
||||
yield return new TernaryStateToggleMenuItem("Strong") { State = { BindTarget = selectionStrongState } };
|
||||
{
|
||||
yield return new TernaryStateToggleMenuItem("Strong")
|
||||
{
|
||||
State = { BindTarget = selectionStrongState },
|
||||
Hotkey = new Hotkey(new KeyCombination(InputKey.E)),
|
||||
};
|
||||
}
|
||||
|
||||
foreach (var item in base.GetContextMenuItemsForSelection(selection))
|
||||
yield return item;
|
||||
|
@ -13,9 +13,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public struct Hotkey
|
||||
{
|
||||
public KeyCombination[]? KeyCombinations { get; }
|
||||
public GlobalAction? GlobalAction { get; }
|
||||
public PlatformAction? PlatformAction { get; }
|
||||
public KeyCombination[]? KeyCombinations { get; init; }
|
||||
public GlobalAction? GlobalAction { get; init; }
|
||||
public PlatformAction? PlatformAction { get; init; }
|
||||
|
||||
public Hotkey(params KeyCombination[] keyCombinations)
|
||||
{
|
||||
@ -34,20 +34,26 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
public IEnumerable<string> ResolveKeyCombination(ReadableKeyCombinationProvider keyCombinationProvider, RealmKeyBindingStore keyBindingStore, GameHost gameHost)
|
||||
{
|
||||
var result = new List<string>();
|
||||
|
||||
if (KeyCombinations != null)
|
||||
return KeyCombinations.Select(keyCombinationProvider.GetReadableString);
|
||||
{
|
||||
result.AddRange(KeyCombinations.Select(keyCombinationProvider.GetReadableString));
|
||||
}
|
||||
|
||||
if (GlobalAction != null)
|
||||
return keyBindingStore.GetReadableKeyCombinationsFor(GlobalAction.Value);
|
||||
{
|
||||
result.AddRange(keyBindingStore.GetReadableKeyCombinationsFor(GlobalAction.Value));
|
||||
}
|
||||
|
||||
if (PlatformAction != null)
|
||||
{
|
||||
var action = PlatformAction.Value;
|
||||
var bindings = gameHost.PlatformKeyBindings.Where(kb => (PlatformAction)kb.Action == action);
|
||||
return bindings.Select(b => keyCombinationProvider.GetReadableString(b.KeyCombination));
|
||||
result.AddRange(bindings.Select(b => keyCombinationProvider.GetReadableString(b.KeyCombination)));
|
||||
}
|
||||
|
||||
return Enumerable.Empty<string>();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ using Humanizer;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
@ -350,19 +351,69 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
if (SelectedBlueprints.All(b => b.Item is IHasComboInformation))
|
||||
{
|
||||
yield return new TernaryStateToggleMenuItem("New combo") { State = { BindTarget = SelectionNewComboState } };
|
||||
yield return new TernaryStateToggleMenuItem("New combo")
|
||||
{
|
||||
State = { BindTarget = SelectionNewComboState },
|
||||
Hotkey = new Hotkey(new KeyCombination(InputKey.Q))
|
||||
};
|
||||
}
|
||||
|
||||
yield return new OsuMenuItem("Sample")
|
||||
yield return new OsuMenuItem("Sample") { Items = getSampleSubmenuItems().ToArray(), };
|
||||
yield return new OsuMenuItem("Bank") { Items = getBankSubmenuItems().ToArray(), };
|
||||
}
|
||||
|
||||
private IEnumerable<MenuItem> getSampleSubmenuItems()
|
||||
{
|
||||
var whistle = SelectionSampleStates[HitSampleInfo.HIT_WHISTLE];
|
||||
yield return new TernaryStateToggleMenuItem(whistle.Description)
|
||||
{
|
||||
Items = SelectionSampleStates.Select(kvp =>
|
||||
new TernaryStateToggleMenuItem(kvp.Value.Description) { State = { BindTarget = kvp.Value } }).ToArray()
|
||||
State = { BindTarget = whistle },
|
||||
Hotkey = new Hotkey(new KeyCombination(InputKey.W))
|
||||
};
|
||||
|
||||
yield return new OsuMenuItem("Bank")
|
||||
var finish = SelectionSampleStates[HitSampleInfo.HIT_FINISH];
|
||||
yield return new TernaryStateToggleMenuItem(finish.Description)
|
||||
{
|
||||
Items = SelectionBankStates.Select(kvp =>
|
||||
new TernaryStateToggleMenuItem(kvp.Value.Description) { State = { BindTarget = kvp.Value } }).ToArray()
|
||||
State = { BindTarget = finish },
|
||||
Hotkey = new Hotkey(new KeyCombination(InputKey.E))
|
||||
};
|
||||
|
||||
var clap = SelectionSampleStates[HitSampleInfo.HIT_CLAP];
|
||||
yield return new TernaryStateToggleMenuItem(clap.Description)
|
||||
{
|
||||
State = { BindTarget = clap },
|
||||
Hotkey = new Hotkey(new KeyCombination(InputKey.R))
|
||||
};
|
||||
}
|
||||
|
||||
private IEnumerable<MenuItem> getBankSubmenuItems()
|
||||
{
|
||||
var auto = SelectionBankStates[HIT_BANK_AUTO];
|
||||
yield return new TernaryStateToggleMenuItem(auto.Description)
|
||||
{
|
||||
State = { BindTarget = auto },
|
||||
Hotkey = new Hotkey(new KeyCombination(InputKey.Shift, InputKey.Q))
|
||||
};
|
||||
|
||||
var normal = SelectionBankStates[HitSampleInfo.BANK_NORMAL];
|
||||
yield return new TernaryStateToggleMenuItem(normal.Description)
|
||||
{
|
||||
State = { BindTarget = normal },
|
||||
Hotkey = new Hotkey(new KeyCombination(InputKey.Shift, InputKey.W))
|
||||
};
|
||||
|
||||
var soft = SelectionBankStates[HitSampleInfo.BANK_SOFT];
|
||||
yield return new TernaryStateToggleMenuItem(soft.Description)
|
||||
{
|
||||
State = { BindTarget = soft },
|
||||
Hotkey = new Hotkey(new KeyCombination(InputKey.Shift, InputKey.E))
|
||||
};
|
||||
|
||||
var drum = SelectionBankStates[HitSampleInfo.BANK_DRUM];
|
||||
yield return new TernaryStateToggleMenuItem(drum.Description)
|
||||
{
|
||||
State = { BindTarget = drum },
|
||||
Hotkey = new Hotkey(new KeyCombination(InputKey.Shift, InputKey.R))
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -415,7 +415,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
if (SelectedBlueprints.Count == 1)
|
||||
items.AddRange(SelectedBlueprints[0].ContextMenuItems);
|
||||
|
||||
items.Add(new OsuMenuItem(CommonStrings.ButtonsDelete, MenuItemType.Destructive, DeleteSelected));
|
||||
items.Add(new OsuMenuItem(CommonStrings.ButtonsDelete, MenuItemType.Destructive, DeleteSelected)
|
||||
{
|
||||
Hotkey = new Hotkey { PlatformAction = PlatformAction.Delete, KeyCombinations = [new KeyCombination(InputKey.Shift, InputKey.MouseRight), new KeyCombination(InputKey.MouseMiddle)] }
|
||||
});
|
||||
|
||||
return items.ToArray();
|
||||
}
|
||||
|
@ -362,13 +362,13 @@ namespace osu.Game.Screens.Edit
|
||||
{
|
||||
Items = new[]
|
||||
{
|
||||
undoMenuItem = new EditorMenuItem(CommonStrings.Undo, MenuItemType.Standard, Undo),
|
||||
redoMenuItem = new EditorMenuItem(CommonStrings.Redo, MenuItemType.Standard, Redo),
|
||||
undoMenuItem = new EditorMenuItem(CommonStrings.Undo, MenuItemType.Standard, Undo) { Hotkey = new Hotkey(PlatformAction.Undo) },
|
||||
redoMenuItem = new EditorMenuItem(CommonStrings.Redo, MenuItemType.Standard, Redo) { Hotkey = new Hotkey(PlatformAction.Redo) },
|
||||
new OsuMenuItemSpacer(),
|
||||
cutMenuItem = new EditorMenuItem(CommonStrings.Cut, MenuItemType.Standard, Cut),
|
||||
copyMenuItem = new EditorMenuItem(CommonStrings.Copy, MenuItemType.Standard, Copy),
|
||||
pasteMenuItem = new EditorMenuItem(CommonStrings.Paste, MenuItemType.Standard, Paste),
|
||||
cloneMenuItem = new EditorMenuItem(CommonStrings.Clone, MenuItemType.Standard, Clone),
|
||||
cutMenuItem = new EditorMenuItem(CommonStrings.Cut, MenuItemType.Standard, Cut) { Hotkey = new Hotkey(PlatformAction.Cut) },
|
||||
copyMenuItem = new EditorMenuItem(CommonStrings.Copy, MenuItemType.Standard, Copy) { Hotkey = new Hotkey(PlatformAction.Copy) },
|
||||
pasteMenuItem = new EditorMenuItem(CommonStrings.Paste, MenuItemType.Standard, Paste) { Hotkey = new Hotkey(PlatformAction.Paste) },
|
||||
cloneMenuItem = new EditorMenuItem(CommonStrings.Clone, MenuItemType.Standard, Clone) { Hotkey = new Hotkey(GlobalAction.EditorCloneSelection) },
|
||||
}
|
||||
},
|
||||
new MenuItem(CommonStrings.MenuBarView)
|
||||
@ -1194,7 +1194,7 @@ namespace osu.Game.Screens.Edit
|
||||
yield return new EditorMenuItem(EditorStrings.DeleteDifficulty, MenuItemType.Standard, deleteDifficulty) { Action = { Disabled = Beatmap.Value.BeatmapSetInfo.Beatmaps.Count < 2 } };
|
||||
yield return new OsuMenuItemSpacer();
|
||||
|
||||
var save = new EditorMenuItem(WebCommonStrings.ButtonsSave, MenuItemType.Standard, () => attemptMutationOperation(Save));
|
||||
var save = new EditorMenuItem(WebCommonStrings.ButtonsSave, MenuItemType.Standard, () => attemptMutationOperation(Save)) { Hotkey = new Hotkey(PlatformAction.Save) };
|
||||
saveRelatedMenuItems.Add(save);
|
||||
yield return save;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user