code cleanup
This commit is contained in:
parent
8fcc186566
commit
58b870b99f
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.0.31919.166
|
VisualStudioVersion = 17.0.31919.166
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SamplePlugin", "SamplePlugin\SamplePlugin.csproj", "{13C812E9-0D42-4B95-8646-40EEBF30636F}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CurrencyAlert", "SamplePlugin\CurrencyAlert.csproj", "{13C812E9-0D42-4B95-8646-40EEBF30636F}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UIDev", "UIDev\UIDev.csproj", "{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UIDev", "UIDev\UIDev.csproj", "{4FEC9558-EB25-419F-B86E-51B8CFDA32B7}"
|
||||||
EndProject
|
EndProject
|
||||||
|
@ -2,14 +2,17 @@
|
|||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace SamplePlugin
|
namespace CurrencyAlert
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class Configuration : IPluginConfiguration
|
public class Configuration : IPluginConfiguration
|
||||||
{
|
{
|
||||||
public int Version { get; set; } = 1;
|
public int Version { get; set; } = 1;
|
||||||
|
|
||||||
|
public bool PoeticsThresholdEnabled { get; set; } = true;
|
||||||
public int PoeticsThreshold { get; set; } = 1500;
|
public int PoeticsThreshold { get; set; } = 1500;
|
||||||
|
public bool StormSealsThresholdEnabled { get; set; } = true;
|
||||||
|
public int StormSealsThreshold { get; set; } = 40000;
|
||||||
|
|
||||||
// the below exist just to make saving less cumbersome
|
// the below exist just to make saving less cumbersome
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ using Dalamud.Plugin;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace SamplePlugin
|
namespace CurrencyAlert
|
||||||
{
|
{
|
||||||
public sealed class Plugin : IDalamudPlugin
|
public sealed class Plugin : IDalamudPlugin
|
||||||
{
|
{
|
||||||
@ -48,8 +48,7 @@ namespace SamplePlugin
|
|||||||
|
|
||||||
private void OnCommand(string command, string args)
|
private void OnCommand(string command, string args)
|
||||||
{
|
{
|
||||||
// in response to the slash command, just display our main ui
|
this.DrawConfigUI();
|
||||||
this.PluginUi.Visible = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawUI()
|
private void DrawUI()
|
||||||
|
@ -1,60 +1,63 @@
|
|||||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using System;
|
using System;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
|
||||||
namespace SamplePlugin
|
namespace CurrencyAlert
|
||||||
{
|
{
|
||||||
// It is good to have this be disposable in general, in case you ever need it
|
public enum CurrencySlot
|
||||||
// to do any cleanup
|
{
|
||||||
class PluginUI : IDisposable
|
StormSeals = 1,
|
||||||
{
|
WolfMarks = 4,
|
||||||
private Configuration configuration;
|
Poetics = 6,
|
||||||
|
AlliedSeals = 8
|
||||||
// this extra bool exists for ImGui, since you can't ref a property
|
};
|
||||||
private bool visible = false;
|
|
||||||
public bool Visible
|
// It is good to have this be disposable in general, in case you ever need it
|
||||||
{
|
// to do any cleanup
|
||||||
get { return this.visible; }
|
class PluginUI : IDisposable
|
||||||
set { this.visible = value; }
|
{
|
||||||
}
|
private Configuration configuration;
|
||||||
|
|
||||||
private bool settingsVisible = false;
|
private bool settingsVisible = false;
|
||||||
public bool SettingsVisible
|
public bool SettingsVisible
|
||||||
{
|
{
|
||||||
get { return this.settingsVisible; }
|
get { return this.settingsVisible; }
|
||||||
set { this.settingsVisible = value; }
|
set { this.settingsVisible = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
//public unsafe InventoryManager* InventoryManager { get; }
|
private bool poeticsAlertVisible = false;
|
||||||
|
public bool PoeticsAlertVisible
|
||||||
|
{
|
||||||
|
get { return this.poeticsAlertVisible; }
|
||||||
|
set { this.poeticsAlertVisible = value; }
|
||||||
|
}
|
||||||
|
|
||||||
// passing in the image here just for simplicity
|
public PluginUI(Configuration configuration)
|
||||||
public PluginUI(Configuration configuration)
|
{
|
||||||
{
|
this.configuration = configuration;
|
||||||
this.configuration = configuration;
|
}
|
||||||
//this.InventoryManager = InventoryManager.Instance();
|
|
||||||
}
|
public void Dispose()
|
||||||
|
{
|
||||||
public void Dispose()
|
|
||||||
{
|
}
|
||||||
|
|
||||||
}
|
public void Draw()
|
||||||
|
{
|
||||||
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.
|
||||||
// This is our only draw handler attached to UIBuilder, so it needs to be
|
// Each method checks its own visibility/state to ensure it only draws when
|
||||||
// able to draw any windows we might have open.
|
// it actually makes sense.
|
||||||
// Each method checks its own visibility/state to ensure it only draws when
|
// There are other ways to do this, but it is generally best to keep the number of
|
||||||
// it actually makes sense.
|
// draw delegates as low as possible.
|
||||||
// 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();
|
||||||
DrawMainWindow();
|
}
|
||||||
DrawSettingsWindow();
|
|
||||||
}
|
public void DrawMainWindow()
|
||||||
|
{
|
||||||
public void DrawMainWindow()
|
|
||||||
{
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
InventoryManager* inventoryManager = InventoryManager.Instance();
|
InventoryManager* inventoryManager = InventoryManager.Instance();
|
||||||
@ -65,22 +68,14 @@ namespace SamplePlugin
|
|||||||
// Allied Seal: 8
|
// Allied Seal: 8
|
||||||
// Company Seals: 1,2,3
|
// Company Seals: 1,2,3
|
||||||
|
|
||||||
uint poetics = currencyContainer->GetInventorySlot(6)->Quantity;
|
uint poetics = currencyContainer->GetInventorySlot((int) CurrencySlot.Poetics)->Quantity;
|
||||||
uint wolfMarks = currencyContainer->GetInventorySlot(4)->Quantity;
|
|
||||||
uint stormSeals = currencyContainer->GetInventorySlot(1)->Quantity;
|
|
||||||
uint serpentSeals = currencyContainer->GetInventorySlot(2)->Quantity;
|
|
||||||
uint flameSeals = currencyContainer->GetInventorySlot(3)->Quantity;
|
|
||||||
|
|
||||||
|
bool poeticsThresholdEnabled = this.configuration.PoeticsThresholdEnabled;
|
||||||
uint poeticsThreshold = (uint) this.configuration.PoeticsThreshold;
|
uint poeticsThreshold = (uint) this.configuration.PoeticsThreshold;
|
||||||
|
|
||||||
Visible = false;
|
PoeticsAlertVisible = poeticsThresholdEnabled && poetics >= poeticsThreshold;
|
||||||
|
|
||||||
if (poetics >= poeticsThreshold)
|
if (!PoeticsAlertVisible)
|
||||||
{
|
|
||||||
Visible = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Visible)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -88,44 +83,43 @@ namespace SamplePlugin
|
|||||||
ImGui.SetNextWindowSize(new Vector2(375, 330), ImGuiCond.FirstUseEver);
|
ImGui.SetNextWindowSize(new Vector2(375, 330), ImGuiCond.FirstUseEver);
|
||||||
ImGui.SetNextWindowSizeConstraints(new Vector2(375, 330), new Vector2(float.MaxValue, float.MaxValue));
|
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.Begin("DEPENSE TES POETICS MERDE", ref this.poeticsAlertVisible, ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse | ImGuiWindowFlags.AlwaysAutoResize))
|
||||||
{
|
{
|
||||||
if (ImGui.Button("Show Settings"))
|
ImGui.Text("DEPENSE TES POETICS MEEEEERDE");
|
||||||
{
|
|
||||||
SettingsVisible = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (poetics >= poeticsThreshold)
|
|
||||||
{
|
|
||||||
ImGui.Text("DEPENSE TES POETICS MERDE");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.End();
|
ImGui.End();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSettingsWindow()
|
public void DrawSettingsWindow()
|
||||||
{
|
{
|
||||||
if (!SettingsVisible)
|
if (!SettingsVisible)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.SetNextWindowSize(new Vector2(232, 75), ImGuiCond.Always);
|
ImGui.SetNextWindowSize(new Vector2(330, 120), ImGuiCond.Always);
|
||||||
if (ImGui.Begin("A Wonderful Configuration Window", ref this.settingsVisible,
|
if (ImGui.Begin("Currency Alert Configuration Window", ref this.settingsVisible,
|
||||||
ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse))
|
ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse))
|
||||||
{
|
{
|
||||||
// can't ref a property, so use a local copy
|
var poeticsThresholdEnabledConfig = this.configuration.PoeticsThresholdEnabled;
|
||||||
var configValue = this.configuration.PoeticsThreshold;
|
|
||||||
if (ImGui.InputInt("Poetics Threshold", ref configValue))
|
if (ImGui.Checkbox("Poetics Threshold Enabled", ref poeticsThresholdEnabledConfig))
|
||||||
{
|
{
|
||||||
this.configuration.PoeticsThreshold = configValue;
|
this.configuration.PoeticsThresholdEnabled = poeticsThresholdEnabledConfig;
|
||||||
// can save immediately on change, if you don't want to provide a "Save and Close" button
|
this.configuration.Save();
|
||||||
this.configuration.Save();
|
}
|
||||||
}
|
|
||||||
}
|
var poeticsThresholdConfig = this.configuration.PoeticsThreshold;
|
||||||
ImGui.End();
|
|
||||||
}
|
if (ImGui.InputInt("Poetics Threshold", ref poeticsThresholdConfig, 1, 1, this.configuration.PoeticsThresholdEnabled ? ImGuiInputTextFlags.None : ImGuiInputTextFlags.ReadOnly))
|
||||||
}
|
{
|
||||||
}
|
this.configuration.PoeticsThreshold = poeticsThresholdConfig;
|
||||||
|
this.configuration.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui.End();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user