This commit is contained in:
Camille 2021-12-11 12:02:01 +01:00
parent 0d68ee0a54
commit 8fcc186566
5 changed files with 38 additions and 86 deletions

View File

@ -1,31 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29709.97
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamplePlugin", "SamplePlugin\SamplePlugin.csproj", "{13C812E9-0D42-4B95-8646-40EEBF30636F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UIDev", "UIDev\UIDev.csproj", "{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}"
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
{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}.Debug|x64.ActiveCfg = Debug|x64
{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}.Debug|x64.Build.0 = Debug|x64
{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}.Release|x64.ActiveCfg = Release|x64
{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B17E85B1-5F60-4440-9F9A-3DDE877E8CDF}
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31919.166
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SamplePlugin", "SamplePlugin\SamplePlugin.csproj", "{13C812E9-0D42-4B95-8646-40EEBF30636F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UIDev", "UIDev\UIDev.csproj", "{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}"
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
{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}.Debug|x64.ActiveCfg = Debug|x64
{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}.Debug|x64.Build.0 = Debug|x64
{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}.Release|x64.ActiveCfg = Release|x64
{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B17E85B1-5F60-4440-9F9A-3DDE877E8CDF}
EndGlobalSection
EndGlobal

View File

@ -1,40 +0,0 @@
# SamplePlugin
Simple example plugin for XivLauncher/Dalamud, that shows both a working plugin and an associated UI test project, to allow for building and tweaking the UI without having to run the game.
This is not designed to be the simplest possible example, but neither is it designed to cover everything you might want to do.
I'm mostly hoping this helps some people to build out their UIs without having to constantly jump in and out of game.
### Main Points
* Simple functional plugin
* Slash command
* Main UI
* Settings UI
* Image loading
* Plugin json
* Simple, slightly-improved plugin configuration handling
* Basic ImGui testbed application project
* Allows testing UI changes without needing to run the game
* UI environment provided should match what is seen in game
* Defaults to an invisible fullscreen overlay; can easily be changed to use an opaque window etc
* Currently relies more on copy/paste of your UI code than fully generic objects (though this could be done)
* Project organization
* Copies all necessary plugin files to the output directory
* Does not copy dependencies that are provided by dalamud
* Output directory can be zipped directly and have exactly what is required
* Hides data files from visual studio to reduce clutter
* Also allows having data files in different paths than VS would usually allow if done in the IDE directly
The intention is less that any of this is used directly in other projects, and more to show how similar things can be done.
The UIDev project could be used as-is, with just the UITest.cs file needing to be redone for your specific project UI.
### To Use
You'll need to fixup the library dependencies (for both projects), to point at your local dalamud binary directory.
This will either be a custom dalamud build, or `%APPDATA%\XivLauncher\addon\Hooks\` for the current live release.
After that, clear out what you don't need in UITest.cs, and implement your own local UI under Draw()

View File

@ -8,9 +8,9 @@ namespace SamplePlugin
{
public sealed class Plugin : IDalamudPlugin
{
public string Name => "Sample Plugin";
public string Name => "Currency Alert";
private const string commandName = "/tsalert";
private const string commandName = "/currencyalert";
private DalamudPluginInterface PluginInterface { get; init; }
private CommandManager CommandManager { get; init; }
@ -29,9 +29,7 @@ namespace SamplePlugin
// you might normally want to embed resources and load them from the manifest stream
var assemblyLocation = Assembly.GetExecutingAssembly().Location;
var imagePath = Path.Combine(Path.GetDirectoryName(assemblyLocation)!, "goat.png");
var goatImage = this.PluginInterface.UiBuilder.LoadImage(imagePath);
this.PluginUi = new PluginUI(this.Configuration, goatImage);
this.PluginUi = new PluginUI(this.Configuration);
this.CommandManager.AddHandler(commandName, new CommandInfo(OnCommand)
{

View File

@ -11,8 +11,6 @@ namespace SamplePlugin
{
private Configuration configuration;
private ImGuiScene.TextureWrap goatImage;
// this extra bool exists for ImGui, since you can't ref a property
private bool visible = false;
public bool Visible
@ -31,16 +29,15 @@ namespace SamplePlugin
//public unsafe InventoryManager* InventoryManager { get; }
// passing in the image here just for simplicity
public PluginUI(Configuration configuration, ImGuiScene.TextureWrap goatImage)
public PluginUI(Configuration configuration)
{
this.configuration = configuration;
this.goatImage = goatImage;
//this.InventoryManager = InventoryManager.Instance();
}
public void Dispose()
{
this.goatImage.Dispose();
}
public void Draw()
@ -83,11 +80,6 @@ namespace SamplePlugin
Visible = true;
}
//if (wolfMarks >= 15000)
//{
// ImGui.Text("Wolf Marks: " + wolfMarks);
//}
if (!Visible)
{
return;
@ -95,6 +87,7 @@ namespace SamplePlugin
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))
{
if (ImGui.Button("Show Settings"))
@ -107,6 +100,7 @@ namespace SamplePlugin
ImGui.Text("DEPENSE TES POETICS MERDE");
}
}
ImGui.End();
}
}