mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
Add support for "Clipboard" as an application source in chat commands.
This commit is contained in:
parent
bd21425fdf
commit
c051c2f891
1 changed files with 26 additions and 3 deletions
|
|
@ -329,7 +329,8 @@ public class CommandService : IDisposable
|
||||||
var split = arguments.Split('|', 2, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
var split = arguments.Split('|', 2, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||||
if (split.Length != 2)
|
if (split.Length != 2)
|
||||||
{
|
{
|
||||||
_chat.Print(new SeStringBuilder().AddText("Use with /glamour apply ").AddYellow("[Design Name, Path or Identifier]").AddText(" | ")
|
_chat.Print(new SeStringBuilder().AddText("Use with /glamour apply ").AddYellow("[Design Name, Path or Identifier, or Clipboard]")
|
||||||
|
.AddText(" | ")
|
||||||
.AddGreen("[Character Identifier]").BuiltString);
|
.AddGreen("[Character Identifier]").BuiltString);
|
||||||
_chat.Print(new SeStringBuilder()
|
_chat.Print(new SeStringBuilder()
|
||||||
.AddText(
|
.AddText(
|
||||||
|
|
@ -342,10 +343,12 @@ public class CommandService : IDisposable
|
||||||
_chat.Print(new SeStringBuilder()
|
_chat.Print(new SeStringBuilder()
|
||||||
.AddText(" 》 The design path is the folder path in the selector, with '/' as separators. It is also case-insensitive.")
|
.AddText(" 》 The design path is the folder path in the selector, with '/' as separators. It is also case-insensitive.")
|
||||||
.BuiltString);
|
.BuiltString);
|
||||||
|
_chat.Print(new SeStringBuilder()
|
||||||
|
.AddText(" 》 Clipboard as a single word will try to apply a design string currently in your clipboard.").BuiltString);
|
||||||
PlayerIdentifierHelp(false);
|
PlayerIdentifierHelp(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GetDesign(split[0], out var design) || !IdentifierHandling(split[1], out var identifier, false))
|
if (!GetDesign(split[0], out var design, true) || !IdentifierHandling(split[1], out var identifier, false))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_objects.Update();
|
_objects.Update();
|
||||||
|
|
@ -441,12 +444,32 @@ public class CommandService : IDisposable
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool GetDesign(string argument, [NotNullWhen(true)] out Design? design)
|
private bool GetDesign(string argument, [NotNullWhen(true)] out DesignBase? design, bool allowClipboard)
|
||||||
{
|
{
|
||||||
design = null;
|
design = null;
|
||||||
if (argument.Length == 0)
|
if (argument.Length == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (allowClipboard && string.Equals("clipboard", argument, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var clipboardText = ImGui.GetClipboardText();
|
||||||
|
if (clipboardText.Length > 0)
|
||||||
|
design = _converter.FromBase64(clipboardText, true, true, out _);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
|
|
||||||
|
if (design != null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
_chat.Print(new SeStringBuilder().AddText("Your current clipboard did not contain a valid design string.").BuiltString);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (Guid.TryParse(argument, out var guid))
|
if (Guid.TryParse(argument, out var guid))
|
||||||
{
|
{
|
||||||
design = _designManager.Designs.FirstOrDefault(d => d.Identifier == guid);
|
design = _designManager.Designs.FirstOrDefault(d => d.Identifier == guid);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue