mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
Improve PR to use GetDesign.
This commit is contained in:
parent
2642f9e7bc
commit
2e5cdc229d
1 changed files with 23 additions and 28 deletions
|
|
@ -85,7 +85,8 @@ public class CommandService : IDisposable
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
_chat.Print("Use without argument to toggle the main window.");
|
_chat.Print("Use without argument to toggle the main window.");
|
||||||
_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);
|
||||||
return;
|
return;
|
||||||
|
|
@ -415,7 +416,7 @@ public class CommandService : IDisposable
|
||||||
{
|
{
|
||||||
if (argument.Length == 0)
|
if (argument.Length == 0)
|
||||||
{
|
{
|
||||||
_chat.Print(new SeStringBuilder().AddText("Use with /glamour delete ").AddYellow("[Design Name]").BuiltString);
|
_chat.Print(new SeStringBuilder().AddText("Use with /glamour delete ").AddYellow("[Design Name, Path or Identifier]").BuiltString);
|
||||||
_chat.Print(new SeStringBuilder()
|
_chat.Print(new SeStringBuilder()
|
||||||
.AddText(
|
.AddText(
|
||||||
" 》 The design name is case-insensitive. If multiple designs of that name up to case exist, the first one is chosen.")
|
" 》 The design name is case-insensitive. If multiple designs of that name up to case exist, the first one is chosen.")
|
||||||
|
|
@ -424,23 +425,18 @@ public class CommandService : IDisposable
|
||||||
.AddText(
|
.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.")
|
" 》 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);
|
.BuiltString);
|
||||||
|
_chat.Print(new SeStringBuilder()
|
||||||
|
.AddText(" 》 The design path is the folder path in the selector, with '/' as separators. It is also case-insensitive.")
|
||||||
|
.BuiltString);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var lower = argument.ToLowerInvariant();
|
if (!GetDesign(argument, out var designBase, false) || designBase is not Design d)
|
||||||
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;
|
return false;
|
||||||
}
|
|
||||||
|
_designManager.Delete(d);
|
||||||
_objects.Update();
|
|
||||||
_designManager.Delete(design);
|
return true;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CopyState(string argument)
|
private bool CopyState(string argument)
|
||||||
|
|
@ -553,14 +549,13 @@ public class CommandService : IDisposable
|
||||||
design = leaf.Value;
|
design = leaf.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (design == null)
|
if (design != null)
|
||||||
{
|
return true;
|
||||||
_chat.Print(new SeStringBuilder().AddText("The token ").AddYellow(argument, true).AddText(" did not resolve to an existing design.")
|
|
||||||
.BuiltString);
|
_chat.Print(new SeStringBuilder().AddText("The token ").AddYellow(argument, true).AddText(" did not resolve to an existing design.")
|
||||||
return false;
|
.BuiltString);
|
||||||
}
|
return false;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe bool IdentifierHandling(string argument, out ActorIdentifier[] identifiers, bool allowAnyWorld, bool allowIndex)
|
private unsafe bool IdentifierHandling(string argument, out ActorIdentifier[] identifiers, bool allowAnyWorld, bool allowIndex)
|
||||||
|
|
@ -580,10 +575,10 @@ public class CommandService : IDisposable
|
||||||
|
|
||||||
if (allowIndex && identifier.Type is IdentifierType.Npc)
|
if (allowIndex && identifier.Type is IdentifierType.Npc)
|
||||||
identifier = _actors.CreateNpc(identifier.Kind, identifier.DataId, obj.Index);
|
identifier = _actors.CreateNpc(identifier.Kind, identifier.DataId, obj.Index);
|
||||||
identifiers = new[]
|
identifiers =
|
||||||
{
|
[
|
||||||
identifier,
|
identifier,
|
||||||
};
|
];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -600,7 +595,7 @@ public class CommandService : IDisposable
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (ActorManager.IdentifierParseError e)
|
catch (ActorIdentifierFactory.IdentifierParseError e)
|
||||||
{
|
{
|
||||||
_chat.Print(new SeStringBuilder().AddText("The argument ").AddRed(argument, true)
|
_chat.Print(new SeStringBuilder().AddText("The argument ").AddRed(argument, true)
|
||||||
.AddText($" could not be converted to an identifier. {e.Message}")
|
.AddText($" could not be converted to an identifier. {e.Message}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue