Created a new glamour command that lets you delete a desgin using the given designs name

This commit is contained in:
X3llus 2023-12-30 10:52:59 -05:00
parent 22ea1e344e
commit c29b6b5e57

View file

@ -84,7 +84,8 @@ public class CommandService : IDisposable
_config.Ephemeral.Save(); _config.Ephemeral.Save();
return; return;
default: default:
_chat.Print("Use without argument to toggle the main window."); _chat.Print("Use without argument to toggle the main w" +
"indow.");
_chat.Print(new SeStringBuilder().AddText("Use ").AddPurple("/glamour").AddText(" instead of ").AddRed("/glamourer").AddText(" for application commands.").BuiltString); _chat.Print(new SeStringBuilder().AddText("Use ").AddPurple("/glamour").AddText(" instead of ").AddRed("/glamourer").AddText(" for application commands.").BuiltString);
_chat.Print(new SeStringBuilder().AddCommand("qdb", "Toggles the quick design bar on or off.").BuiltString); _chat.Print(new SeStringBuilder().AddCommand("qdb", "Toggles the quick design bar on or off.").BuiltString);
_chat.Print(new SeStringBuilder().AddCommand("lock", "Toggles the lock of the main window on or off.").BuiltString); _chat.Print(new SeStringBuilder().AddCommand("lock", "Toggles the lock of the main window on or off.").BuiltString);
@ -113,6 +114,7 @@ public class CommandService : IDisposable
"automation" => SetAutomation(argument), "automation" => SetAutomation(argument),
"copy" => CopyState(argument), "copy" => CopyState(argument),
"save" => SaveState(argument), "save" => SaveState(argument),
"delete" => Delete(argument),
_ => PrintHelp(argumentList[0]), _ => PrintHelp(argumentList[0]),
}; };
} }
@ -410,6 +412,39 @@ public class CommandService : IDisposable
return true; return true;
} }
private bool Delete(string argument)
{
if (argument.Length == 0)
{
_chat.Print(new SeStringBuilder().AddText("Use with /glamour delete ").AddYellow("[Design Name]").BuiltString);
_chat.Print(new SeStringBuilder()
.AddText(
" 》 The design name is case-insensitive. If multiple designs of that name up to case exist, the first one is chosen.")
.BuiltString);
_chat.Print(new SeStringBuilder()
.AddText(
" 》 If using the design identifier, you need to specify at least 4 characters for it, and the first one starting with the provided characters is chosen.")
.BuiltString);
return false;
}
//Design? design = _designManager.Designs.FirstOrDefault(design => design.Name == arguments);
var lower = argument.ToLowerInvariant();
Design? design = _designManager.Designs.FirstOrDefault(d
=> d.Name.Lower == lower || lower.Length > 3 && d.Identifier.ToString().StartsWith(lower));
if (design == null)
{
_chat.Print(new SeStringBuilder().AddRed("Error with finding the design.").BuiltString);
return false;
}
_objects.Update();
_designManager.Delete(design);
return true;
}
private bool CopyState(string argument) private bool CopyState(string argument)
{ {
if (argument.Length == 0) if (argument.Length == 0)