OrangeGuidanceTomestone/client/Plugin.cs

107 lines
3.1 KiB
C#
Raw Normal View History

2023-09-29 00:53:50 +00:00
using Dalamud.IoC;
2022-09-03 02:59:45 +00:00
using Dalamud.Plugin;
2023-09-29 00:53:50 +00:00
using Dalamud.Plugin.Services;
2022-09-05 09:56:13 +00:00
using OrangeGuidanceTomestone.MiniPenumbra;
2023-01-29 09:26:58 +00:00
using XivCommon;
2022-09-03 02:59:45 +00:00
namespace OrangeGuidanceTomestone;
public class Plugin : IDalamudPlugin {
2023-09-29 00:53:50 +00:00
internal static string Name => "Orange Guidance Tomestone";
[PluginService]
internal static IPluginLog Log { get; private set; }
2022-09-03 02:59:45 +00:00
[PluginService]
internal DalamudPluginInterface Interface { get; init; }
2022-09-03 13:55:36 +00:00
2022-09-05 08:02:34 +00:00
[PluginService]
2023-09-29 00:53:50 +00:00
internal IChatGui ChatGui { get; init; }
[PluginService]
internal IClientState ClientState { get; init; }
2022-09-05 08:02:34 +00:00
2022-09-03 13:55:36 +00:00
[PluginService]
2023-09-29 00:53:50 +00:00
internal ICommandManager CommandManager { get; init; }
2022-09-03 13:55:36 +00:00
2022-09-04 03:23:19 +00:00
[PluginService]
2023-09-29 00:53:50 +00:00
internal ICondition Condition { get; init; }
2022-09-04 03:23:19 +00:00
2022-09-04 22:19:16 +00:00
[PluginService]
2023-09-29 00:53:50 +00:00
internal IDataManager DataManager { get; init; }
2022-09-04 22:19:16 +00:00
2022-09-04 07:12:51 +00:00
[PluginService]
2023-09-29 00:53:50 +00:00
internal IFramework Framework { get; init; }
2022-09-04 07:12:51 +00:00
2022-09-03 23:45:16 +00:00
[PluginService]
2023-09-29 00:53:50 +00:00
internal IGameGui GameGui { get; init; }
2022-09-03 23:45:16 +00:00
2022-09-07 05:46:30 +00:00
[PluginService]
2023-09-29 00:53:50 +00:00
internal IGameInteropProvider GameInteropProvider { get; init; }
2022-09-07 05:46:30 +00:00
2022-09-03 13:55:36 +00:00
internal Configuration Config { get; }
2023-01-29 09:26:58 +00:00
internal XivCommonBase Common { get; }
2022-09-03 23:45:16 +00:00
internal Vfx Vfx { get; }
2022-09-03 03:24:01 +00:00
internal PluginUi Ui { get; }
2022-09-03 23:45:16 +00:00
internal Messages Messages { get; }
2022-09-05 09:56:13 +00:00
internal VfxReplacer VfxReplacer { get; }
2022-09-04 03:23:19 +00:00
internal Commands Commands { get; }
2022-09-06 12:07:23 +00:00
internal Pinger Pinger { get; }
2022-09-03 13:55:36 +00:00
2022-09-05 09:56:13 +00:00
internal string AvfxFilePath { get; }
2022-09-03 02:59:45 +00:00
public Plugin() {
2022-09-05 09:56:13 +00:00
this.AvfxFilePath = this.CopyAvfxFile();
2022-09-03 13:55:36 +00:00
this.Config = this.Interface!.GetPluginConfig() as Configuration ?? new Configuration();
2023-10-03 21:45:28 +00:00
this.Common = new XivCommonBase(this.Interface);
2023-09-29 00:53:50 +00:00
this.Vfx = new Vfx(this);
2022-09-04 20:39:09 +00:00
this.Messages = new Messages(this);
this.Ui = new PluginUi(this);
2022-09-05 09:56:13 +00:00
this.VfxReplacer = new VfxReplacer(this);
2022-09-04 20:39:09 +00:00
this.Commands = new Commands(this);
2022-09-06 12:07:23 +00:00
this.Pinger = new Pinger(this);
2022-09-04 20:39:09 +00:00
2022-09-03 13:55:36 +00:00
if (this.Config.ApiKey == string.Empty) {
2022-09-05 23:23:55 +00:00
this.GetApiKey();
2022-09-03 13:55:36 +00:00
}
2022-09-03 02:59:45 +00:00
}
2022-09-03 13:55:36 +00:00
2022-09-03 02:59:45 +00:00
public void Dispose() {
2022-09-06 12:07:23 +00:00
this.Pinger.Dispose();
2022-09-04 03:23:19 +00:00
this.Commands.Dispose();
2022-09-05 09:56:13 +00:00
this.VfxReplacer.Dispose();
2022-09-03 03:24:01 +00:00
this.Ui.Dispose();
2022-09-04 19:19:38 +00:00
this.Messages.Dispose();
2022-09-04 02:11:18 +00:00
this.Vfx.Dispose();
2023-01-29 09:26:58 +00:00
this.Common.Dispose();
2022-09-03 02:59:45 +00:00
}
2022-09-03 13:55:36 +00:00
internal void SaveConfig() {
this.Interface.SavePluginConfig(this.Config);
}
2022-09-05 09:56:13 +00:00
private string CopyAvfxFile() {
var configDir = this.Interface!.GetPluginConfigDirectory();
Directory.CreateDirectory(configDir);
2022-09-09 09:35:10 +00:00
for (var i = 0; i < Messages.VfxPaths.Length; i++) {
2022-09-06 04:24:32 +00:00
var letter = (char) ('a' + i);
2022-09-06 04:37:17 +00:00
var stream = Resourcer.Resource.AsStreamUnChecked($"OrangeGuidanceTomestone.vfx.b0941trp1{letter}_o.avfx");
2022-09-06 04:24:32 +00:00
var path = Path.Join(configDir, $"sign_{letter}.avfx");
stream.CopyTo(File.Create(path));
}
return configDir;
2022-09-05 09:56:13 +00:00
}
2022-09-05 23:23:55 +00:00
internal void GetApiKey() {
Task.Run(async () => {
var resp = await new HttpClient().PostAsync("https://tryfingerbuthole.anna.lgbt/account", null);
var key = await resp.Content.ReadAsStringAsync();
this.Config.ApiKey = key;
this.SaveConfig();
this.Messages.SpawnVfx();
});
}
2022-09-03 02:59:45 +00:00
}