2022-01-05 14:46:15 +00:00
|
|
|
|
using CurrencyAlert.Enum;
|
|
|
|
|
using Dalamud.Game.Gui;
|
|
|
|
|
using Dalamud.IoC;
|
|
|
|
|
using FFXIVClientStructs.FFXIV.Client.Game;
|
2021-12-11 13:27:58 +00:00
|
|
|
|
using ImGuiNET;
|
|
|
|
|
using System;
|
2022-01-05 14:46:15 +00:00
|
|
|
|
using System.Collections.Generic;
|
2021-12-11 13:27:58 +00:00
|
|
|
|
using System.Numerics;
|
|
|
|
|
|
|
|
|
|
namespace CurrencyAlert
|
|
|
|
|
{
|
|
|
|
|
class PluginUI : IDisposable
|
|
|
|
|
{
|
|
|
|
|
private Configuration configuration;
|
|
|
|
|
|
|
|
|
|
private bool settingsVisible = false;
|
|
|
|
|
public bool SettingsVisible
|
|
|
|
|
{
|
2022-01-05 14:46:15 +00:00
|
|
|
|
get { return settingsVisible; }
|
|
|
|
|
set { settingsVisible = value; }
|
2021-12-11 13:27:58 +00:00
|
|
|
|
}
|
2022-01-05 14:46:15 +00:00
|
|
|
|
public Dictionary<Currency, bool> AlertVisible { get; set; } = new Dictionary<Currency, bool>();
|
2021-12-11 13:27:58 +00:00
|
|
|
|
|
|
|
|
|
public PluginUI(Configuration configuration)
|
|
|
|
|
{
|
|
|
|
|
this.configuration = configuration;
|
2022-01-05 14:46:15 +00:00
|
|
|
|
|
|
|
|
|
EnumHelper.Each<Currency>(currency => this.AlertVisible[currency] = false);
|
2021-12-11 00:28:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-11 13:27:58 +00:00
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2022-01-05 14:46:15 +00:00
|
|
|
|
|
2021-12-11 13:27:58 +00:00
|
|
|
|
public void Draw()
|
|
|
|
|
{
|
|
|
|
|
DrawMainWindow();
|
2022-01-05 14:46:15 +00:00
|
|
|
|
|
|
|
|
|
if (this.SettingsVisible)
|
|
|
|
|
DrawSettingsWindow();
|
2021-12-11 13:27:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void DrawMainWindow()
|
|
|
|
|
{
|
2022-01-05 14:46:15 +00:00
|
|
|
|
EnumHelper.Each<Currency>(currency =>
|
2021-12-11 00:28:51 +00:00
|
|
|
|
{
|
2022-01-05 14:46:15 +00:00
|
|
|
|
if (!this.AlertVisible[currency])
|
2021-12-11 00:28:51 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2022-01-05 14:46:15 +00:00
|
|
|
|
ImGui.SetNextWindowSize(new Vector2(375, 10), ImGuiCond.FirstUseEver);
|
|
|
|
|
ImGui.SetNextWindowSizeConstraints(new Vector2(375, 10), new Vector2(float.MaxValue, float.MaxValue));
|
|
|
|
|
|
|
|
|
|
var isVisible = this.AlertVisible[currency];
|
2021-12-11 11:02:01 +00:00
|
|
|
|
|
2022-01-06 09:56:52 +00:00
|
|
|
|
if (ImGui.Begin("Currency Alert", ref isVisible,
|
2022-01-05 14:46:15 +00:00
|
|
|
|
ImGuiWindowFlags.NoScrollbar |
|
|
|
|
|
ImGuiWindowFlags.NoScrollWithMouse |
|
|
|
|
|
ImGuiWindowFlags.AlwaysAutoResize |
|
|
|
|
|
ImGuiWindowFlags.NoTitleBar |
|
|
|
|
|
ImGuiWindowFlags.NoFocusOnAppearing
|
|
|
|
|
))
|
2021-12-11 00:28:51 +00:00
|
|
|
|
{
|
2022-01-06 09:56:52 +00:00
|
|
|
|
var name = EnumHelper.GetAttributeOfType<NameAttribute>(currency).Value;
|
|
|
|
|
ImGui.Text($"You need to spend your {name}");
|
2021-12-11 00:28:51 +00:00
|
|
|
|
}
|
2021-12-11 11:02:01 +00:00
|
|
|
|
|
2021-12-11 00:28:51 +00:00
|
|
|
|
ImGui.End();
|
2022-01-05 14:46:15 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
2021-12-11 13:27:58 +00:00
|
|
|
|
|
|
|
|
|
public void DrawSettingsWindow()
|
|
|
|
|
{
|
2022-01-20 10:38:04 +00:00
|
|
|
|
ImGui.SetNextWindowSize(new Vector2(700, 500), ImGuiCond.FirstUseEver);
|
|
|
|
|
if (ImGui.Begin("Currency Alert Configuration Window", ref this.settingsVisible))
|
2021-12-11 13:27:58 +00:00
|
|
|
|
{
|
2022-01-19 23:01:25 +00:00
|
|
|
|
if (ImGui.BeginTabBar("AlertsConfiguration_Tabs"))
|
2021-12-11 13:27:58 +00:00
|
|
|
|
{
|
2022-01-19 23:01:25 +00:00
|
|
|
|
EnumHelper.Each<Currency>(currency =>
|
2022-01-05 14:46:15 +00:00
|
|
|
|
{
|
2022-01-19 23:01:25 +00:00
|
|
|
|
var name = EnumHelper.GetAttributeOfType<NameAttribute>(currency).Value;
|
|
|
|
|
var category = EnumHelper.GetAttributeOfType<CategoryAttribute>(currency).Value;
|
|
|
|
|
var alertEnabled = this.configuration.AlertEnabled[currency];
|
2022-01-05 14:46:15 +00:00
|
|
|
|
|
2022-01-19 23:01:25 +00:00
|
|
|
|
if (ImGui.BeginTabItem(category))
|
|
|
|
|
{
|
|
|
|
|
if (ImGui.Checkbox($"{name} Alert Enabled", ref alertEnabled))
|
|
|
|
|
{
|
|
|
|
|
this.configuration.AlertEnabled[currency] = alertEnabled;
|
|
|
|
|
this.configuration.Save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var thresholdValue = this.configuration.Threshold[currency];
|
|
|
|
|
|
|
|
|
|
if (ImGui.InputInt($"{name} Threshold Value", ref thresholdValue, 1, 1,
|
|
|
|
|
this.configuration.AlertEnabled[currency] ? ImGuiInputTextFlags.None : ImGuiInputTextFlags.ReadOnly))
|
|
|
|
|
{
|
|
|
|
|
this.configuration.Threshold[currency] = thresholdValue;
|
|
|
|
|
this.configuration.Save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui.EndTabItem();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-01-05 14:46:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-11 13:27:58 +00:00
|
|
|
|
ImGui.End();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|