feat: add option to open folder

This commit is contained in:
Anna 2024-02-18 01:16:38 -05:00
parent 4c585dc366
commit fc3ce358e5
Signed by: anna
GPG Key ID: D0943384CD9F87D1
3 changed files with 40 additions and 1 deletions

View File

@ -2,6 +2,8 @@ using System.Drawing;
using System.Drawing.Imaging;
using Blake3;
using Dalamud.Game.Command;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Newtonsoft.Json;
using WebP.Net;
@ -75,7 +77,16 @@ internal class Command : IDisposable {
// TODO: save this info to database
Plugin.Log.Info(json);
this.Plugin.ChatGui.Print("Screenshot saved.");
var message = new SeStringBuilder()
.AddText("Screenshot saved. [")
.AddUiForeground(12)
.Add(this.Plugin.LinkHandlers.OpenFolder)
.AddText("Open folder")
.Add(RawPayload.LinkTerminator)
.AddUiForegroundOff()
.AddText("]")
.Build();
this.Plugin.ChatGui.Print(message);
});
}

25
LinkHandlers.cs Normal file
View File

@ -0,0 +1,25 @@
using System.Diagnostics;
using Dalamud.Game.Text.SeStringHandling.Payloads;
namespace Screenie;
internal class LinkHandlers : IDisposable {
private Plugin Plugin { get; }
internal DalamudLinkPayload OpenFolder { get; }
internal LinkHandlers(Plugin plugin) {
this.Plugin = plugin;
this.OpenFolder = this.Plugin.Interface.AddChatLinkHandler(0x00, (_, _) => {
Process.Start(new ProcessStartInfo(this.Plugin.Config.SaveDirectory) {
UseShellExecute = true,
});
});
}
public void Dispose() {
// removes all
this.Plugin.Interface.RemoveChatLinkHandler();
}
}

View File

@ -36,12 +36,14 @@ public class Plugin : IDalamudPlugin {
internal IObjectTable ObjectTable { get; init; }
internal Configuration Config { get; }
internal LinkHandlers LinkHandlers { get; }
internal PluginUi Ui { get; }
private Command Command { get; }
public Plugin() {
this.Config = this.Interface!.GetPluginConfig() as Configuration ?? new Configuration();
this.LinkHandlers = new LinkHandlers(this);
this.Ui = new PluginUi(this);
this.Command = new Command(this);
}
@ -49,6 +51,7 @@ public class Plugin : IDalamudPlugin {
public void Dispose() {
this.Command.Dispose();
this.Ui.Dispose();
this.LinkHandlers.Dispose();
}
internal void SaveConfig() {