diff --git a/MareSynchronos.sln b/MareSynchronos.sln new file mode 100644 index 0000000..656c710 --- /dev/null +++ b/MareSynchronos.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32328.378 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MareSynchronos", "MareSynchronos\MareSynchronos.csproj", "{13C812E9-0D42-4B95-8646-40EEBF30636F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|x64.ActiveCfg = Debug|x64 + {13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|x64.Build.0 = Debug|x64 + {13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|x64.ActiveCfg = Release|x64 + {13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B17E85B1-5F60-4440-9F9A-3DDE877E8CDF} + EndGlobalSection +EndGlobal diff --git a/MareSynchronos/Configuration.cs b/MareSynchronos/Configuration.cs new file mode 100644 index 0000000..f71a1b9 --- /dev/null +++ b/MareSynchronos/Configuration.cs @@ -0,0 +1,29 @@ +using Dalamud.Configuration; +using Dalamud.Plugin; +using System; + +namespace SamplePlugin +{ + [Serializable] + public class Configuration : IPluginConfiguration + { + public int Version { get; set; } = 0; + + public bool SomePropertyToBeSavedAndWithADefault { get; set; } = true; + + // the below exist just to make saving less cumbersome + + [NonSerialized] + private DalamudPluginInterface? pluginInterface; + + public void Initialize(DalamudPluginInterface pluginInterface) + { + this.pluginInterface = pluginInterface; + } + + public void Save() + { + this.pluginInterface!.SavePluginConfig(this); + } + } +} diff --git a/MareSynchronos/MareSynchronos.csproj b/MareSynchronos/MareSynchronos.csproj new file mode 100644 index 0000000..bf057d7 --- /dev/null +++ b/MareSynchronos/MareSynchronos.csproj @@ -0,0 +1,64 @@ + + + + + + 0.0.0.1 + + + https://github.com/Penumbra-Sync/client + + + + net5.0-windows7.0 + x64 + enable + latest + true + false + false + true + + + + $(appdata)\XIVLauncher\addon\Hooks\dev\ + + + + + + + + + + + $(DalamudLibPath)FFXIVClientStructs.dll + false + + + $(DalamudLibPath)Newtonsoft.Json.dll + false + + + $(DalamudLibPath)Dalamud.dll + false + + + $(DalamudLibPath)ImGui.NET.dll + false + + + $(DalamudLibPath)ImGuiScene.dll + false + + + $(DalamudLibPath)Lumina.dll + false + + + $(DalamudLibPath)Lumina.Excel.dll + false + + + + diff --git a/MareSynchronos/MareSynchronos.json b/MareSynchronos/MareSynchronos.json new file mode 100644 index 0000000..84ddd63 --- /dev/null +++ b/MareSynchronos/MareSynchronos.json @@ -0,0 +1,13 @@ +{ + "Author": "your name here", + "Name": "Mare Synchronos", + "Punchline": "", + "Description": "", + "InternalName": "mareSynchronos", + "ApplicableVersion": "any", + "Tags": [ + "sample", + "plugin", + "goats" + ] +} diff --git a/MareSynchronos/Plugin.cs b/MareSynchronos/Plugin.cs new file mode 100644 index 0000000..4383b7a --- /dev/null +++ b/MareSynchronos/Plugin.cs @@ -0,0 +1,65 @@ +using Dalamud.Game.Command; +using Dalamud.IoC; +using Dalamud.Plugin; +using System.IO; +using System.Reflection; +//using System.Data.SQLite; + +namespace SamplePlugin +{ + public sealed class Plugin : IDalamudPlugin + { + public string Name => "Mare Synchronos"; + + private const string commandName = "/pscan"; + + private DalamudPluginInterface PluginInterface { get; init; } + private CommandManager CommandManager { get; init; } + private Configuration Configuration { get; init; } + private PluginUI PluginUi { get; init; } + + public Plugin( + [RequiredVersion("1.0")] DalamudPluginInterface pluginInterface, + [RequiredVersion("1.0")] CommandManager commandManager) + { + this.PluginInterface = pluginInterface; + this.CommandManager = commandManager; + + this.Configuration = this.PluginInterface.GetPluginConfig() as Configuration ?? new Configuration(); + this.Configuration.Initialize(this.PluginInterface); + + // you might normally want to embed resources and load them from the manifest stream + this.PluginUi = new PluginUI(this.Configuration); + + this.CommandManager.AddHandler(commandName, new CommandInfo(OnCommand) + { + HelpMessage = "A useful message to display in /xlhelp" + }); + + this.PluginInterface.UiBuilder.Draw += DrawUI; + this.PluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI; + } + + public void Dispose() + { + this.PluginUi.Dispose(); + this.CommandManager.RemoveHandler(commandName); + } + + private void OnCommand(string command, string args) + { + //using var connection = new SQLiteConnection("Data Source=penumbracache.db"); + //connection.Open(); + } + + private void DrawUI() + { + this.PluginUi.Draw(); + } + + private void DrawConfigUI() + { + this.PluginUi.SettingsVisible = true; + } + } +} diff --git a/MareSynchronos/PluginUI.cs b/MareSynchronos/PluginUI.cs new file mode 100644 index 0000000..a0b3baa --- /dev/null +++ b/MareSynchronos/PluginUI.cs @@ -0,0 +1,97 @@ +using ImGuiNET; +using System; +using System.Numerics; + +namespace SamplePlugin +{ + // It is good to have this be disposable in general, in case you ever need it + // to do any cleanup + class PluginUI : IDisposable + { + private Configuration configuration; + + // this extra bool exists for ImGui, since you can't ref a property + private bool visible = false; + public bool Visible + { + get { return this.visible; } + set { this.visible = value; } + } + + private bool settingsVisible = false; + public bool SettingsVisible + { + get { return this.settingsVisible; } + set { this.settingsVisible = value; } + } + + // passing in the image here just for simplicity + public PluginUI(Configuration configuration) + { + this.configuration = configuration; + } + + public void Dispose() + { + } + + public void Draw() + { + // This is our only draw handler attached to UIBuilder, so it needs to be + // able to draw any windows we might have open. + // Each method checks its own visibility/state to ensure it only draws when + // it actually makes sense. + // There are other ways to do this, but it is generally best to keep the number of + // draw delegates as low as possible. + + DrawMainWindow(); + DrawSettingsWindow(); + } + + public void DrawMainWindow() + { + if (!Visible) + { + return; + } + + ImGui.SetNextWindowSize(new Vector2(375, 330), ImGuiCond.FirstUseEver); + ImGui.SetNextWindowSizeConstraints(new Vector2(375, 330), new Vector2(float.MaxValue, float.MaxValue)); + if (ImGui.Begin("My Amazing Window", ref this.visible, ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse)) + { + ImGui.Text($"The random config bool is {this.configuration.SomePropertyToBeSavedAndWithADefault}"); + + if (ImGui.Button("Show Settings")) + { + SettingsVisible = true; + } + + ImGui.Spacing(); + } + ImGui.End(); + } + + public void DrawSettingsWindow() + { + if (!SettingsVisible) + { + return; + } + + ImGui.SetNextWindowSize(new Vector2(232, 75), ImGuiCond.Always); + if (ImGui.Begin("A Wonderful Configuration Window", ref this.settingsVisible, + ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse)) + { + // can't ref a property, so use a local copy + var configValue = this.configuration.SomePropertyToBeSavedAndWithADefault; + if (ImGui.Checkbox("Random Config Bool", ref configValue)) + { + this.configuration.SomePropertyToBeSavedAndWithADefault = configValue; + // can save immediately on change, if you don't want to provide a "Save and Close" button + this.configuration.Save(); + } + } + ImGui.End(); + } + } +} diff --git a/MareSynchronos/filecache.db b/MareSynchronos/filecache.db new file mode 100644 index 0000000..90c8852 Binary files /dev/null and b/MareSynchronos/filecache.db differ