Skip to content

Commit

Permalink
fix(Studio): "Insert other Command" menu being broken
Browse files Browse the repository at this point in the history
  • Loading branch information
psyGamer committed Nov 15, 2024
1 parent 1e8d39c commit b42314a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions Studio/CelesteStudio/Editing/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,9 @@ void GenerateCommandMenu() {
commandsMenu.Items.Clear();

foreach (string? commandName in CommandInfo.CommandOrder) {
if (commandName == null) {
if (commandName == null && commandsMenu.Items.Count != 0) {
commandsMenu.Items.Add(new SeparatorMenuItem());
} else if (CommunicationWrapper.Commands.FirstOrDefault(cmd => cmd.Name == commandName) is var command) {
} else if (CommunicationWrapper.Commands.FirstOrDefault(cmd => cmd.Name == commandName) is var command && !string.IsNullOrEmpty(command.Name)) {
commandsMenu.Items.Add(CreateCommandInsert(command));
}
}
Expand All @@ -416,11 +416,15 @@ void GenerateCommandMenu() {
.ToArray();

if (thirdPartyCommands.Any()) {
commandsMenu.Items.Add(new SeparatorMenuItem());
if (commandsMenu.Items.Count != 0) {
commandsMenu.Items.Add(new SeparatorMenuItem());
}
foreach (var command in thirdPartyCommands) {
commandsMenu.Items.Add(CreateCommandInsert(command));
}
}

commandsMenu.Enabled = commandsMenu.Items.Count != 0;
}

ContextMenu = CreateMenu();
Expand Down
4 changes: 2 additions & 2 deletions StudioCommunication/CommandInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bool HasArguments
public const string Separator = "##SEPARATOR##"; // Placeholder to-be replaced by the actual value

/// Groups command into a meaningful order with null as a separator
public static string?[] CommandOrder = [
public static readonly string?[] CommandOrder = [
"console", "Set", "Invoke", "EvalLua",
null,
"Repeat", "EndRepeat", "StunPause", "EndStunPause", "SkipInput", "StunPauseMode", "AnalogMode",
Expand All @@ -37,7 +37,7 @@ bool HasArguments
];

/// Commands which don't make sense to display to the user
public static string[] HiddenCommands = [
public static readonly string[] HiddenCommands = [
"Author:", "FrameCount:", "TotalRecordCount:",
"ExportLibTAS", "EndExportLibTAS", "Add", "Skip", "Marker",
"ExitGame"
Expand Down

0 comments on commit b42314a

Please sign in to comment.