1
0

fix: final work

This commit is contained in:
Kacie 2023-01-24 22:50:56 +01:00
parent 1a0790ffd4
commit c62a553427
17 changed files with 327 additions and 402 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

View File

@ -14,6 +14,7 @@ using Dalamud.Game.Command;
using Dalamud.Game.ClientState; using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Objects; using Dalamud.Game.ClientState.Objects;
using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel;
using Dalamud.Interface.Windowing;
// FFXIV_Vibe_Plugin libs // FFXIV_Vibe_Plugin libs
using FFXIV_Vibe_Plugin.Commons; using FFXIV_Vibe_Plugin.Commons;
@ -24,7 +25,7 @@ using FFXIV_Vibe_Plugin.Migrations;
namespace FFXIV_Vibe_Plugin { namespace FFXIV_Vibe_Plugin {
internal class App { public class App {
private Dalamud.Game.Gui.ChatGui? DalamudChat { get; init; } private Dalamud.Game.Gui.ChatGui? DalamudChat { get; init; }
public Configuration Configuration { get; init; } public Configuration Configuration { get; init; }
private GameNetwork GameNetwork { get; init; } private GameNetwork GameNetwork { get; init; }
@ -35,12 +36,13 @@ namespace FFXIV_Vibe_Plugin {
private DalamudPluginInterface PluginInterface { get; init; } private DalamudPluginInterface PluginInterface { get; init; }
// Custom variables from Kacie // Custom variables from Kacie
private readonly Plugin Plugin;
private readonly bool wasInit = false; private readonly bool wasInit = false;
public readonly string CommandName = ""; public readonly string CommandName = "";
public PluginUI PluginUi { get; init; }
private readonly string ShortName = ""; private readonly string ShortName = "";
private bool _firstUpdated = false; private bool _firstUpdated = false;
private readonly PlayerStats PlayerStats; private readonly PlayerStats PlayerStats;
private PluginUI PluginUi { get; init; }
private ConfigurationProfile ConfigurationProfile; private ConfigurationProfile ConfigurationProfile;
private readonly Logger Logger; private readonly Logger Logger;
private readonly ActionEffect hook_ActionEffect; private readonly ActionEffect hook_ActionEffect;
@ -51,8 +53,8 @@ namespace FFXIV_Vibe_Plugin {
// Experiments // Experiments
private readonly NetworkCapture experiment_networkCapture; private readonly NetworkCapture experiment_networkCapture;
public App(string commandName, string shortName, GameNetwork gameNetwork, ClientState clientState, DataManager dataManager, Dalamud.Game.Gui.ChatGui? dalamudChat, Configuration configuration, SigScanner scanner, ObjectTable gameObjects, DalamudPluginInterface pluginInterface) { public App(Plugin plugin, string commandName, string shortName, GameNetwork gameNetwork, ClientState clientState, DataManager dataManager, Dalamud.Game.Gui.ChatGui? dalamudChat, Configuration configuration, SigScanner scanner, ObjectTable gameObjects, DalamudPluginInterface pluginInterface) {
return; this.Plugin = plugin;
this.CommandName = commandName; this.CommandName = commandName;
this.ShortName = shortName; this.ShortName = shortName;
this.GameNetwork = gameNetwork; this.GameNetwork = gameNetwork;
@ -63,25 +65,33 @@ namespace FFXIV_Vibe_Plugin {
this.GameObjects = gameObjects; this.GameObjects = gameObjects;
this.Scanner = scanner; this.Scanner = scanner;
this.PluginInterface = pluginInterface; this.PluginInterface = pluginInterface;
if (DalamudChat != null) { if (DalamudChat != null) {
DalamudChat.ChatMessage += ChatWasTriggered; DalamudChat.ChatMessage += ChatWasTriggered;
} }
this.Logger = new Logger(this.DalamudChat, ShortName, Logger.LogLevel.VERBOSE); this.Logger = new Logger(this.DalamudChat, ShortName, Logger.LogLevel.VERBOSE);
// Migrations // Migrations
Migration migration = new(Configuration, Logger); Migration migration = new(Configuration, Logger);
migration.Patch_0_2_0_to_1_0_0_config_profile(); migration.Patch_0_2_0_to_1_0_0_config_profile();
// Configuration Profile // Configuration Profile
this.ConfigurationProfile = this.Configuration.GetDefaultProfile(); this.ConfigurationProfile = this.Configuration.GetDefaultProfile();
// Patterns // Patterns
this.Patterns = new Patterns(); this.Patterns = new Patterns();
this.Patterns.SetCustomPatterns(this.ConfigurationProfile.PatternList); this.Patterns.SetCustomPatterns(this.ConfigurationProfile.PatternList);
// Initialize the devices Controller // Initialize the devices Controller
/* TODO: this.DeviceController = new Device.DevicesController(this.Logger, this.Configuration, this.ConfigurationProfile, this.Patterns);*/ this.DeviceController = new Device.DevicesController(this.Logger, this.Configuration, this.ConfigurationProfile, this.Patterns);
this.DeviceController = null;
if (this.ConfigurationProfile.AUTO_CONNECT) { if (this.ConfigurationProfile.AUTO_CONNECT) {
Thread t = new(delegate () { Thread t = new(delegate () {
Thread.Sleep(2000); Thread.Sleep(2000);
@ -90,10 +100,13 @@ namespace FFXIV_Vibe_Plugin {
t.Start(); t.Start();
} }
// Initialize Hook ActionEffect // Initialize Hook ActionEffect
this.hook_ActionEffect = new(this.DataManager, this.Logger, this.Scanner, clientState, gameObjects); this.hook_ActionEffect = new(this.DataManager, this.Logger, this.Scanner, clientState, gameObjects);
this.hook_ActionEffect.ReceivedEvent += SpellWasTriggered; this.hook_ActionEffect.ReceivedEvent += SpellWasTriggered;
// Init the login event. // Init the login event.
this.ClientState.Login += this.ClientState_LoginEvent; this.ClientState.Login += this.ClientState_LoginEvent;
@ -102,6 +115,7 @@ namespace FFXIV_Vibe_Plugin {
PlayerStats.Event_CurrentHpChanged += this.PlayerCurrentHPChanged; PlayerStats.Event_CurrentHpChanged += this.PlayerCurrentHPChanged;
PlayerStats.Event_MaxHpChanged += this.PlayerCurrentHPChanged; PlayerStats.Event_MaxHpChanged += this.PlayerCurrentHPChanged;
// Triggers // Triggers
this.TriggersController = new Triggers.TriggersController(this.Logger, this.PlayerStats, this.ConfigurationProfile); this.TriggersController = new Triggers.TriggersController(this.Logger, this.PlayerStats, this.ConfigurationProfile);
@ -192,13 +206,12 @@ namespace FFXIV_Vibe_Plugin {
} }
private void DisplayUI() { private void DisplayUI() {
if (this.PluginUi != null) { this.Plugin.DrawConfigUI();
this.PluginUi.Display();
}
} }
private void DisplayConfigUI() { private void DisplayConfigUI() {
this.PluginUi.Display(); this.Plugin.DrawConfigUI();
} }
public void DrawUI() { public void DrawUI() {
@ -207,8 +220,6 @@ namespace FFXIV_Vibe_Plugin {
return; return;
} }
this.PluginUi.Draw();
if (this.ClientState.IsLoggedIn) { if (this.ClientState.IsLoggedIn) {
this.PlayerStats.Update(this.ClientState); this.PlayerStats.Update(this.ClientState);
} }

View File

@ -9,7 +9,7 @@ using Dalamud.IoC;
namespace FFXIV_Vibe_Plugin.Commons { namespace FFXIV_Vibe_Plugin.Commons {
internal class Logger { public class Logger {
// Initialize the Dalamud.Gui system. // Initialize the Dalamud.Gui system.
private readonly Dalamud.Game.Gui.ChatGui? DalamudChatGui; private readonly Dalamud.Game.Gui.ChatGui? DalamudChatGui;

View File

@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace FFXIV_Vibe_Plugin.Commons { namespace FFXIV_Vibe_Plugin.Commons {
internal class Structures { public class Structures {
public enum ActionEffectType : byte { public enum ActionEffectType : byte {
Any = 0, Any = 0,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

View File

@ -14,7 +14,7 @@ using Buttplug;
#endregion #endregion
namespace FFXIV_Vibe_Plugin.Device { namespace FFXIV_Vibe_Plugin.Device {
internal class DevicesController { public class DevicesController {
private readonly Logger Logger; private readonly Logger Logger;
private readonly Configuration Configuration; private readonly Configuration Configuration;
private ConfigurationProfile Profile; private ConfigurationProfile Profile;

View File

@ -5,7 +5,7 @@ using FFXIV_Vibe_Plugin.Commons;
namespace FFXIV_Vibe_Plugin { namespace FFXIV_Vibe_Plugin {
internal class PlayerStats { public class PlayerStats {
private readonly Logger Logger; private readonly Logger Logger;
// EVENTS // EVENTS

View File

@ -7,13 +7,13 @@ using System.Threading.Tasks;
using FFXIV_Vibe_Plugin.Device; using FFXIV_Vibe_Plugin.Device;
namespace FFXIV_Vibe_Plugin.Triggers { namespace FFXIV_Vibe_Plugin.Triggers {
enum KIND { public enum KIND {
Chat, Chat,
Spell, Spell,
HPChange HPChange
} }
enum DIRECTION { public enum DIRECTION {
Any, Any,
Outgoing, Outgoing,
Incoming, Incoming,

View File

@ -12,7 +12,7 @@ using FFXIV_Vibe_Plugin.Commons;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace FFXIV_Vibe_Plugin.Triggers { namespace FFXIV_Vibe_Plugin.Triggers {
internal class TriggersController { public class TriggersController {
private readonly Logger Logger; private readonly Logger Logger;
private readonly PlayerStats PlayerStats; private readonly PlayerStats PlayerStats;
private ConfigurationProfile Profile; private ConfigurationProfile Profile;

View File

@ -1,19 +1,26 @@
using Dalamud.Game.Text; using System;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Components;
using Dalamud.Plugin;
using FFXIV_Vibe_Plugin.Commons;
using ImGuiNET;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
// Dalamud libs
using ImGuiNET;
using Dalamud.Game.Text;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Components;
using Dalamud.Plugin;
using Dalamud.Interface.Windowing;
// FFXIV_Vibe_Plugin libs
using FFXIV_Vibe_Plugin.Commons;
namespace FFXIV_Vibe_Plugin { namespace FFXIV_Vibe_Plugin {
class PluginUI : IDisposable { public class PluginUI : Window, IDisposable {
private int frameCounter = 0; private int frameCounter = 0;
@ -33,15 +40,9 @@ namespace FFXIV_Vibe_Plugin {
private readonly string DonationLink = "http://paypal.me/kaciedev"; private readonly string DonationLink = "http://paypal.me/kaciedev";
// 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 _expandedOnce = false; private bool _expandedOnce = false;
private readonly int WIDTH = 700; private readonly int WIDTH = 700;
private readonly int HEIGHT = 800; private readonly int HEIGHT = 600;
private readonly int COLUMN0_WIDTH = 130; private readonly int COLUMN0_WIDTH = 130;
private string _tmp_void = ""; private string _tmp_void = "";
@ -75,6 +76,8 @@ namespace FFXIV_Vibe_Plugin {
private string triggersViewMode = "default"; // default|edit|delete; private string triggersViewMode = "default"; // default|edit|delete;
/** Constructor */ /** Constructor */
public PluginUI( public PluginUI(
App currentPlugin, App currentPlugin,
Logger logger, Logger logger,
@ -84,7 +87,16 @@ namespace FFXIV_Vibe_Plugin {
Device.DevicesController deviceController, Device.DevicesController deviceController,
Triggers.TriggersController triggersController, Triggers.TriggersController triggersController,
Patterns Patterns Patterns Patterns
) { ) : base(
"FFXIV_Vibe_Plugin_UI",
ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar |
ImGuiWindowFlags.NoScrollWithMouse) {
this.Size = new Vector2(this.WIDTH, this.HEIGHT);
ImGui.SetNextWindowPos(new Vector2(100, 100), ImGuiCond.Appearing);
//if(ImGui.Begin("FFXIV Vibe Plugin", ref this.visible, ImGuiWindowFlags.None)) {
this.Logger = logger; this.Logger = logger;
this.Configuration = configuration; this.Configuration = configuration;
this.ConfigurationProfile = profile; this.ConfigurationProfile = profile;
@ -96,30 +108,25 @@ namespace FFXIV_Vibe_Plugin {
this.LoadImages(); this.LoadImages();
} }
public void Display() {
this.Visible = true;
this._expandedOnce = false;
}
/** /**
* Function that will load all the images so that they are usable. * Function that will load all the images so that they are usable.
* Don't forget to add the image into the project file. * Don't forget to add the image into the project file.
*/ */
private void LoadImages() { private void LoadImages() {
List<string> images = new(); List<string> images = new();
images.Add("logo.png"); images.Add("icon.png");
string assemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location; string assemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location;
foreach(string img in images) { foreach (string img in images) {
string imagePath = Path.Combine(Path.GetDirectoryName(assemblyLocation)!, $"Data\\Images\\{img}"); string imagePath = Path.Combine(Path.GetDirectoryName(assemblyLocation)!, $"{img}");
this.loadedImages.Add(img, this.PluginInterface.UiBuilder.LoadImage(imagePath)); this.loadedImages.Add(img, this.PluginInterface.UiBuilder.LoadImage(imagePath));
} }
} }
public void Dispose() { public void Dispose() {
// Dispose all loaded images. // Dispose all loaded images.
foreach(KeyValuePair<string, ImGuiScene.TextureWrap> img in this.loadedImages) { foreach (KeyValuePair<string, ImGuiScene.TextureWrap> img in this.loadedImages) {
if(img.Value != null) img.Value.Dispose(); if (img.Value != null) img.Value.Dispose();
} }
} }
@ -127,7 +134,7 @@ namespace FFXIV_Vibe_Plugin {
this.ConfigurationProfile = profile; this.ConfigurationProfile = profile;
} }
public void Draw() { public override void Draw() {
// This is our only draw handler attached to UIBuilder, so it needs to be // This is our only draw handler attached to UIBuilder, so it needs to be
// able to draw any windows we might have open. // able to draw any windows we might have open.
// Each method checks its own visibility/state to ensure it only draws when // Each method checks its own visibility/state to ensure it only draws when
@ -135,63 +142,54 @@ namespace FFXIV_Vibe_Plugin {
// There are other ways to do this, but it is generally best to keep the number of // There are other ways to do this, but it is generally best to keep the number of
// draw delegates as low as possible. // draw delegates as low as possible.
DrawMainWindow(); DrawMainWindow();
frameCounter = (frameCounter+1) % 400; frameCounter = (frameCounter + 1) % 400;
} }
public void DrawMainWindow() { public void DrawMainWindow() {
if(!Visible) {
return; if (!this._expandedOnce) {
}
if(!this._expandedOnce) {
ImGui.SetNextWindowCollapsed(false); ImGui.SetNextWindowCollapsed(false);
this._expandedOnce = true; this._expandedOnce = true;
} }
ImGui.SetNextWindowPos(new Vector2(100, 100), ImGuiCond.Appearing);
ImGui.SetNextWindowSize(new Vector2(this.WIDTH, this.HEIGHT), ImGuiCond.Appearing);
ImGui.SetNextWindowSizeConstraints(new Vector2(this.WIDTH, this.HEIGHT), new Vector2(float.MaxValue, float.MaxValue));
if(ImGui.Begin("FFXIV Vibe Plugin", ref this.visible, ImGuiWindowFlags.None)) {
ImGui.Spacing(); ImGui.Spacing();
FFXIV_Vibe_Plugin.UI.UIBanner.Draw(this.frameCounter, this.Logger, this.loadedImages["logo.png"], this.DonationLink, this.DevicesController); FFXIV_Vibe_Plugin.UI.UIBanner.Draw(this.frameCounter, this.Logger, this.loadedImages["icon.png"], this.DonationLink, this.DevicesController);
// Back to on column // Back to on column
ImGui.Columns(1); ImGui.Columns(1);
// Tab header // Tab header
if(ImGui.BeginTabBar("##ConfigTabBar", ImGuiTabBarFlags.None)) { if (ImGui.BeginTabBar("##ConfigTabBar", ImGuiTabBarFlags.None)) {
if(ImGui.BeginTabItem("Connect")) { if (ImGui.BeginTabItem("Connect")) {
FFXIV_Vibe_Plugin.UI.UIConnect.Draw(this.Configuration, this.ConfigurationProfile, this.app, this.DevicesController); FFXIV_Vibe_Plugin.UI.UIConnect.Draw(this.Configuration, this.ConfigurationProfile, this.app, this.DevicesController);
ImGui.EndTabItem(); ImGui.EndTabItem();
} }
if(ImGui.BeginTabItem("Options")) { if (ImGui.BeginTabItem("Options")) {
this.DrawOptionsTab(); this.DrawOptionsTab();
ImGui.EndTabItem(); ImGui.EndTabItem();
} }
if(ImGui.BeginTabItem("Devices")) { if (ImGui.BeginTabItem("Devices")) {
this.DrawDevicesTab(); this.DrawDevicesTab();
ImGui.EndTabItem(); ImGui.EndTabItem();
} }
if(ImGui.BeginTabItem("Triggers")) { if (ImGui.BeginTabItem("Triggers")) {
this.DrawTriggersTab(); this.DrawTriggersTab();
ImGui.EndTabItem(); ImGui.EndTabItem();
} }
if(ImGui.BeginTabItem("Patterns")) { if (ImGui.BeginTabItem("Patterns")) {
this.DrawPatternsTab(); this.DrawPatternsTab();
ImGui.EndTabItem(); ImGui.EndTabItem();
} }
if(ImGui.BeginTabItem("Help")) { if (ImGui.BeginTabItem("Help")) {
this.DrawHelpTab(); this.DrawHelpTab();
ImGui.EndTabItem(); ImGui.EndTabItem();
} }
} }
} }
ImGui.End();
}
public void DrawOptionsTab() { public void DrawOptionsTab() {
ImGui.TextColored(ImGuiColors.DalamudViolet, "Profile settings"); ImGui.TextColored(ImGuiColors.DalamudViolet, "Profile settings");
float CONFIG_PROFILE_ZONE_HEIGHT = this._tmp_currentProfile_ErrorMsg == "" ? 100f : 120f; float CONFIG_PROFILE_ZONE_HEIGHT = this._tmp_currentProfile_ErrorMsg == "" ? 100f : 120f;
@ -209,22 +207,22 @@ namespace FFXIV_Vibe_Plugin {
string[] PROFILES = this.Configuration.Profiles.Select(profile => profile.Name).ToArray(); string[] PROFILES = this.Configuration.Profiles.Select(profile => profile.Name).ToArray();
int currentProfileIndex = this.Configuration.Profiles.FindIndex(profile => profile.Name == this.Configuration.CurrentProfileName); int currentProfileIndex = this.Configuration.Profiles.FindIndex(profile => profile.Name == this.Configuration.CurrentProfileName);
ImGui.SetNextItemWidth(350); ImGui.SetNextItemWidth(350);
if(ImGui.Combo("###CONFIGURATION_CURRENT_PROFILE", ref currentProfileIndex, PROFILES, PROFILES.Length)) { if (ImGui.Combo("###CONFIGURATION_CURRENT_PROFILE", ref currentProfileIndex, PROFILES, PROFILES.Length)) {
this.Configuration.CurrentProfileName = this.Configuration.Profiles[currentProfileIndex].Name; this.Configuration.CurrentProfileName = this.Configuration.Profiles[currentProfileIndex].Name;
this.app.SetProfile(this.Configuration.CurrentProfileName); this.app.SetProfile(this.Configuration.CurrentProfileName);
this.Logger.Debug($"New profile selected: {this.Configuration.CurrentProfileName}"); this.Logger.Debug($"New profile selected: {this.Configuration.CurrentProfileName}");
this.Configuration.Save(); this.Configuration.Save();
} }
ImGui.TableNextColumn(); ImGui.TableNextColumn();
if(ImGuiComponents.IconButton(Dalamud.Interface.FontAwesomeIcon.Trash)) { if (ImGuiComponents.IconButton(Dalamud.Interface.FontAwesomeIcon.Trash)) {
if(this.Configuration.Profiles.Count <= 1) { if (this.Configuration.Profiles.Count <= 1) {
string errorMsg = "You can't delete this profile. At least one profile should exists. Create another one before deleting."; string errorMsg = "You can't delete this profile. At least one profile should exists. Create another one before deleting.";
this.Logger.Error(errorMsg); this.Logger.Error(errorMsg);
this._tmp_currentProfile_ErrorMsg = errorMsg; this._tmp_currentProfile_ErrorMsg = errorMsg;
} else { } else {
this.Configuration.RemoveProfile(this.ConfigurationProfile.Name); this.Configuration.RemoveProfile(this.ConfigurationProfile.Name);
ConfigurationProfile? newProfileToUse = this.Configuration.GetFirstProfile(); ConfigurationProfile? newProfileToUse = this.Configuration.GetFirstProfile();
if(newProfileToUse != null) { if (newProfileToUse != null) {
this.app.SetProfile(newProfileToUse.Name); this.app.SetProfile(newProfileToUse.Name);
} }
this.Configuration.Save(); this.Configuration.Save();
@ -235,15 +233,15 @@ namespace FFXIV_Vibe_Plugin {
ImGui.Text("Add new profile: "); ImGui.Text("Add new profile: ");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.SetNextItemWidth(350); ImGui.SetNextItemWidth(350);
if(ImGui.InputText("###CONFIGURATION_NEW_PROFILE_NAME", ref _tmp_currentProfileNameToAdd, 150)) { if (ImGui.InputText("###CONFIGURATION_NEW_PROFILE_NAME", ref _tmp_currentProfileNameToAdd, 150)) {
this._tmp_currentProfile_ErrorMsg = ""; this._tmp_currentProfile_ErrorMsg = "";
} }
ImGui.TableNextColumn(); ImGui.TableNextColumn();
if(this._tmp_currentProfileNameToAdd.Length > 0) { if (this._tmp_currentProfileNameToAdd.Length > 0) {
if(ImGuiComponents.IconButton(Dalamud.Interface.FontAwesomeIcon.Plus)) { if (ImGuiComponents.IconButton(Dalamud.Interface.FontAwesomeIcon.Plus)) {
if(this._tmp_currentProfileNameToAdd.Trim() != "") { if (this._tmp_currentProfileNameToAdd.Trim() != "") {
bool wasAdded = this.Configuration.AddProfile(this._tmp_currentProfileNameToAdd); bool wasAdded = this.Configuration.AddProfile(this._tmp_currentProfileNameToAdd);
if(!wasAdded) { if (!wasAdded) {
string errorMsg = $"The current profile name '{this._tmp_currentProfileNameToAdd}' already exists!"; string errorMsg = $"The current profile name '{this._tmp_currentProfileNameToAdd}' already exists!";
this.Logger.Error(errorMsg); this.Logger.Error(errorMsg);
this._tmp_currentProfile_ErrorMsg = errorMsg; this._tmp_currentProfile_ErrorMsg = errorMsg;
@ -261,14 +259,14 @@ namespace FFXIV_Vibe_Plugin {
ImGui.Text("Rename current profile"); ImGui.Text("Rename current profile");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.SetNextItemWidth(350); ImGui.SetNextItemWidth(350);
if(ImGui.InputText("###CONFIGURATION_CURRENT_PROFILE_RENAME", ref this.ConfigurationProfile.Name, 150)) { if (ImGui.InputText("###CONFIGURATION_CURRENT_PROFILE_RENAME", ref this.ConfigurationProfile.Name, 150)) {
this.Configuration.CurrentProfileName = this.ConfigurationProfile.Name; this.Configuration.CurrentProfileName = this.ConfigurationProfile.Name;
this.Configuration.Save(); this.Configuration.Save();
} }
ImGui.EndTable(); ImGui.EndTable();
if(this._tmp_currentProfile_ErrorMsg != "") { if (this._tmp_currentProfile_ErrorMsg != "") {
ImGui.TextColored(ImGuiColors.DalamudRed, this._tmp_currentProfile_ErrorMsg); ImGui.TextColored(ImGuiColors.DalamudRed, this._tmp_currentProfile_ErrorMsg);
} }
}; };
@ -288,7 +286,7 @@ namespace FFXIV_Vibe_Plugin {
bool config_AUTO_OPEN = this.ConfigurationProfile.AUTO_OPEN; bool config_AUTO_OPEN = this.ConfigurationProfile.AUTO_OPEN;
ImGui.Text("Automatically open configuration panel."); ImGui.Text("Automatically open configuration panel.");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
if(ImGui.Checkbox("###GENERAL_OPTIONS_AUTO_OPEN", ref config_AUTO_OPEN)) { if (ImGui.Checkbox("###GENERAL_OPTIONS_AUTO_OPEN", ref config_AUTO_OPEN)) {
this.ConfigurationProfile.AUTO_OPEN = config_AUTO_OPEN; this.ConfigurationProfile.AUTO_OPEN = config_AUTO_OPEN;
this.Configuration.Save(); this.Configuration.Save();
} }
@ -301,7 +299,7 @@ namespace FFXIV_Vibe_Plugin {
ImGui.TableNextColumn(); ImGui.TableNextColumn();
int config_MAX_VIBE_THRESHOLD = this.ConfigurationProfile.MAX_VIBE_THRESHOLD; int config_MAX_VIBE_THRESHOLD = this.ConfigurationProfile.MAX_VIBE_THRESHOLD;
ImGui.SetNextItemWidth(201); ImGui.SetNextItemWidth(201);
if(ImGui.SliderInt("###OPTION_MaximumThreshold", ref config_MAX_VIBE_THRESHOLD, 2, 100)) { if (ImGui.SliderInt("###OPTION_MaximumThreshold", ref config_MAX_VIBE_THRESHOLD, 2, 100)) {
this.ConfigurationProfile.MAX_VIBE_THRESHOLD = config_MAX_VIBE_THRESHOLD; this.ConfigurationProfile.MAX_VIBE_THRESHOLD = config_MAX_VIBE_THRESHOLD;
this.Configuration.Save(); this.Configuration.Save();
} }
@ -312,7 +310,7 @@ namespace FFXIV_Vibe_Plugin {
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text("Log casted spells:"); ImGui.Text("Log casted spells:");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
if(ImGui.Checkbox("###OPTION_VERBOSE_SPELL", ref this.ConfigurationProfile.VERBOSE_SPELL)) { if (ImGui.Checkbox("###OPTION_VERBOSE_SPELL", ref this.ConfigurationProfile.VERBOSE_SPELL)) {
this.Configuration.Save(); this.Configuration.Save();
} }
ImGui.SameLine(); ImGui.SameLine();
@ -323,7 +321,7 @@ namespace FFXIV_Vibe_Plugin {
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text("Log chat triggered:"); ImGui.Text("Log chat triggered:");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
if(ImGui.Checkbox("###OPTION_VERBOSE_CHAT", ref this.ConfigurationProfile.VERBOSE_CHAT)) { if (ImGui.Checkbox("###OPTION_VERBOSE_CHAT", ref this.ConfigurationProfile.VERBOSE_CHAT)) {
this.Configuration.Save(); this.Configuration.Save();
} }
ImGui.SameLine(); ImGui.SameLine();
@ -333,7 +331,7 @@ namespace FFXIV_Vibe_Plugin {
} }
ImGui.EndChild(); ImGui.EndChild();
if(this.ConfigurationProfile.VERBOSE_CHAT || this.ConfigurationProfile.VERBOSE_SPELL) { if (this.ConfigurationProfile.VERBOSE_CHAT || this.ConfigurationProfile.VERBOSE_SPELL) {
ImGui.TextColored(ImGuiColors.DalamudOrange, "Please, disabled chat and spell logs for better ingame performance."); ImGui.TextColored(ImGuiColors.DalamudOrange, "Please, disabled chat and spell logs for better ingame performance.");
} }
} }
@ -344,76 +342,76 @@ namespace FFXIV_Vibe_Plugin {
ImGui.TextColored(ImGuiColors.DalamudViolet, "Actions"); ImGui.TextColored(ImGuiColors.DalamudViolet, "Actions");
ImGui.BeginChild("###DevicesTab_General", new Vector2(-1, 40f), true); ImGui.BeginChild("###DevicesTab_General", new Vector2(-1, 40f), true);
{ {
if(this.DevicesController.IsScanning()) { if (this.DevicesController.IsScanning()) {
if(ImGui.Button("Stop scanning", new Vector2(100, 24))) { if (ImGui.Button("Stop scanning", new Vector2(100, 24))) {
this.DevicesController.StopScanningDevice(); this.DevicesController.StopScanningDevice();
} }
} else { } else {
if(ImGui.Button("Scan device", new Vector2(100, 24))) { if (ImGui.Button("Scan device", new Vector2(100, 24))) {
this.DevicesController.ScanDevice(); this.DevicesController.ScanDevice();
} }
} }
ImGui.SameLine(); ImGui.SameLine();
if(ImGui.Button("Update Battery", new Vector2(100, 24))) { if (ImGui.Button("Update Battery", new Vector2(100, 24))) {
this.DevicesController.UpdateAllBatteryLevel(); this.DevicesController.UpdateAllBatteryLevel();
} }
ImGui.SameLine(); ImGui.SameLine();
if(ImGui.Button("Stop All", new Vector2(100, 24))) { if (ImGui.Button("Stop All", new Vector2(100, 24))) {
this.DevicesController.StopAll(); this.DevicesController.StopAll();
this.simulator_currentAllIntensity = 0; this.simulator_currentAllIntensity = 0;
} }
} }
ImGui.EndChild(); ImGui.EndChild();
if(ImGui.CollapsingHeader($"All devices")) { if (ImGui.CollapsingHeader($"All devices")) {
ImGui.Text("Send to all:"); ImGui.Text("Send to all:");
ImGui.SameLine(); ImGui.SameLine();
ImGui.SetNextItemWidth(200); ImGui.SetNextItemWidth(200);
if(ImGui.SliderInt("###SendVibeAll_Intensity", ref this.simulator_currentAllIntensity, 0, 100)) { if (ImGui.SliderInt("###SendVibeAll_Intensity", ref this.simulator_currentAllIntensity, 0, 100)) {
this.DevicesController.SendVibeToAll(this.simulator_currentAllIntensity); this.DevicesController.SendVibeToAll(this.simulator_currentAllIntensity);
} }
} }
foreach(Device.Device device in this.DevicesController.GetDevices()) { foreach (Device.Device device in this.DevicesController.GetDevices()) {
if(ImGui.CollapsingHeader($"[{device.Id}] {device.Name} - Battery: {device.GetBatteryPercentage()}")) { if (ImGui.CollapsingHeader($"[{device.Id}] {device.Name} - Battery: {device.GetBatteryPercentage()}")) {
ImGui.TextWrapped(device.ToString()); ImGui.TextWrapped(device.ToString());
if(device.CanVibrate) { if (device.CanVibrate) {
ImGui.TextColored(ImGuiColors.DalamudViolet, "VIBRATE"); ImGui.TextColored(ImGuiColors.DalamudViolet, "VIBRATE");
ImGui.Indent(10); ImGui.Indent(10);
for(int i = 0; i < device.VibrateMotors; i++) { for (int i = 0; i < device.VibrateMotors; i++) {
ImGui.Text($"Motor {i + 1}: "); ImGui.Text($"Motor {i + 1}: ");
ImGui.SameLine(); ImGui.SameLine();
ImGui.SetNextItemWidth(200); ImGui.SetNextItemWidth(200);
if(ImGui.SliderInt($"###{device.Id} Intensity Vibrate Motor {i}", ref device.CurrentVibrateIntensity[i], 0, 100)) { if (ImGui.SliderInt($"###{device.Id} Intensity Vibrate Motor {i}", ref device.CurrentVibrateIntensity[i], 0, 100)) {
this.DevicesController.SendVibrate(device, device.CurrentVibrateIntensity[i], i); this.DevicesController.SendVibrate(device, device.CurrentVibrateIntensity[i], i);
} }
} }
ImGui.Unindent(10); ImGui.Unindent(10);
} }
if(device.CanRotate) { if (device.CanRotate) {
ImGui.TextColored(ImGuiColors.DalamudViolet, "ROTATE"); ImGui.TextColored(ImGuiColors.DalamudViolet, "ROTATE");
ImGui.Indent(10); ImGui.Indent(10);
for(int i = 0; i < device.RotateMotors; i++) { for (int i = 0; i < device.RotateMotors; i++) {
ImGui.Text($"Motor {i + 1}: "); ImGui.Text($"Motor {i + 1}: ");
ImGui.SameLine(); ImGui.SameLine();
ImGui.SetNextItemWidth(200); ImGui.SetNextItemWidth(200);
if(ImGui.SliderInt($"###{device.Id} Intensity Rotate Motor {i}", ref device.CurrentRotateIntensity[i], 0, 100)) { if (ImGui.SliderInt($"###{device.Id} Intensity Rotate Motor {i}", ref device.CurrentRotateIntensity[i], 0, 100)) {
this.DevicesController.SendRotate(device, device.CurrentRotateIntensity[i], i, true); this.DevicesController.SendRotate(device, device.CurrentRotateIntensity[i], i, true);
} }
} }
ImGui.Unindent(10); ImGui.Unindent(10);
} }
if(device.CanLinear) { if (device.CanLinear) {
ImGui.TextColored(ImGuiColors.DalamudViolet, "LINEAR VIBES"); ImGui.TextColored(ImGuiColors.DalamudViolet, "LINEAR VIBES");
ImGui.Indent(10); ImGui.Indent(10);
for(int i = 0; i < device.LinearMotors; i++) { for (int i = 0; i < device.LinearMotors; i++) {
ImGui.Text($"Motor {i + 1}: "); ImGui.Text($"Motor {i + 1}: ");
ImGui.SameLine(); ImGui.SameLine();
ImGui.SetNextItemWidth(200); ImGui.SetNextItemWidth(200);
if(ImGui.SliderInt($"###{device.Id} Intensity Linear Motor {i}", ref device.CurrentLinearIntensity[i], 0, 100)) { if (ImGui.SliderInt($"###{device.Id} Intensity Linear Motor {i}", ref device.CurrentLinearIntensity[i], 0, 100)) {
this.DevicesController.SendLinear(device, device.CurrentLinearIntensity[i], 500, i); this.DevicesController.SendLinear(device, device.CurrentLinearIntensity[i], 500, i);
} }
} }
@ -427,40 +425,40 @@ namespace FFXIV_Vibe_Plugin {
public unsafe void DrawTriggersTab() { public unsafe void DrawTriggersTab() {
List<Triggers.Trigger> triggers = this.TriggerController.GetTriggers(); List<Triggers.Trigger> triggers = this.TriggerController.GetTriggers();
string selectedId = this.SelectedTrigger != null ? this.SelectedTrigger.Id : ""; string selectedId = this.SelectedTrigger != null ? this.SelectedTrigger.Id : "";
if(ImGui.BeginChild("###TriggersSelector", new Vector2(ImGui.GetWindowContentRegionMax().X/3, -ImGui.GetFrameHeightWithSpacing()), true)) { if (ImGui.BeginChild("###TriggersSelector", new Vector2(ImGui.GetWindowContentRegionMax().X / 3, -ImGui.GetFrameHeightWithSpacing()), true)) {
ImGui.SetNextItemWidth(185); ImGui.SetNextItemWidth(185);
ImGui.InputText("###TriggersSelector_SearchBar", ref this.CURRENT_TRIGGER_SELECTOR_SEARCHBAR, 200); ImGui.InputText("###TriggersSelector_SearchBar", ref this.CURRENT_TRIGGER_SELECTOR_SEARCHBAR, 200);
ImGui.Spacing(); ImGui.Spacing();
for(int triggerIndex=0; triggerIndex<triggers.Count; triggerIndex++) { for (int triggerIndex = 0; triggerIndex < triggers.Count; triggerIndex++) {
Triggers.Trigger trigger = triggers[triggerIndex]; Triggers.Trigger trigger = triggers[triggerIndex];
if(trigger != null) { if (trigger != null) {
string enabled = trigger.Enabled ? "" : "[disabled]"; string enabled = trigger.Enabled ? "" : "[disabled]";
string kindStr = $"{Enum.GetName(typeof(Triggers.KIND), trigger.Kind)}"; string kindStr = $"{Enum.GetName(typeof(Triggers.KIND), trigger.Kind)}";
if(kindStr != null) { if (kindStr != null) {
kindStr = kindStr.ToUpper(); kindStr = kindStr.ToUpper();
} }
string triggerName = $"{enabled}[{ kindStr}] {trigger.Name}"; string triggerName = $"{enabled}[{kindStr}] {trigger.Name}";
string triggerNameWithId = $"{triggerName}###{ trigger.Id}"; string triggerNameWithId = $"{triggerName}###{trigger.Id}";
if(!Helpers.RegExpMatch(this.Logger, triggerName, this.CURRENT_TRIGGER_SELECTOR_SEARCHBAR)) { if (!Helpers.RegExpMatch(this.Logger, triggerName, this.CURRENT_TRIGGER_SELECTOR_SEARCHBAR)) {
continue; continue;
} }
if(ImGui.Selectable($"{triggerNameWithId}", selectedId == trigger.Id)) { // We don't want to show the ID if (ImGui.Selectable($"{triggerNameWithId}", selectedId == trigger.Id)) { // We don't want to show the ID
this.SelectedTrigger = trigger; this.SelectedTrigger = trigger;
this.triggersViewMode = "edit"; this.triggersViewMode = "edit";
} }
if(ImGui.IsItemHovered()) { if (ImGui.IsItemHovered()) {
ImGui.SetTooltip($"{triggerName}"); ImGui.SetTooltip($"{triggerName}");
} }
if(ImGui.BeginDragDropSource()) { if (ImGui.BeginDragDropSource()) {
this._tmp_currentDraggingTriggerIndex = triggerIndex; this._tmp_currentDraggingTriggerIndex = triggerIndex;
ImGui.Text($"Dragging: {triggerName}"); ImGui.Text($"Dragging: {triggerName}");
ImGui.SetDragDropPayload($"{triggerNameWithId}", (IntPtr)(&triggerIndex), sizeof(int)); ImGui.SetDragDropPayload($"{triggerNameWithId}", (IntPtr)(&triggerIndex), sizeof(int));
ImGui.EndDragDropSource(); ImGui.EndDragDropSource();
} }
if(ImGui.BeginDragDropTarget()) { if (ImGui.BeginDragDropTarget()) {
if(this._tmp_currentDraggingTriggerIndex > -1 && ImGui.IsMouseReleased(ImGuiMouseButton.Left)) { if (this._tmp_currentDraggingTriggerIndex > -1 && ImGui.IsMouseReleased(ImGuiMouseButton.Left)) {
int srcIndex = this._tmp_currentDraggingTriggerIndex; int srcIndex = this._tmp_currentDraggingTriggerIndex;
int targetIndex = triggerIndex; int targetIndex = triggerIndex;
(triggers[srcIndex], triggers[targetIndex]) = (triggers[targetIndex], triggers[srcIndex]); (triggers[srcIndex], triggers[targetIndex]) = (triggers[targetIndex], triggers[srcIndex]);
@ -476,11 +474,11 @@ namespace FFXIV_Vibe_Plugin {
} }
ImGui.SameLine(); ImGui.SameLine();
if(ImGui.BeginChild("###TriggerViewerPanel", new Vector2(0, -ImGui.GetFrameHeightWithSpacing()), true)) { if (ImGui.BeginChild("###TriggerViewerPanel", new Vector2(0, -ImGui.GetFrameHeightWithSpacing()), true)) {
if(this.triggersViewMode == "default") { if (this.triggersViewMode == "default") {
ImGui.Text("Please select or add a trigger"); ImGui.Text("Please select or add a trigger");
} else if(this.triggersViewMode == "edit") { } else if (this.triggersViewMode == "edit") {
if(this.SelectedTrigger != null) { if (this.SelectedTrigger != null) {
// Init table // Init table
ImGui.BeginTable("###TRIGGER_FORM_TABLE_GENERAL", 2); ImGui.BeginTable("###TRIGGER_FORM_TABLE_GENERAL", 2);
@ -498,7 +496,7 @@ namespace FFXIV_Vibe_Plugin {
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text("Enabled:"); ImGui.Text("Enabled:");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
if(ImGui.Checkbox("###TRIGGER_ENABLED", ref this.SelectedTrigger.Enabled)) { if (ImGui.Checkbox("###TRIGGER_ENABLED", ref this.SelectedTrigger.Enabled)) {
this.Configuration.Save(); this.Configuration.Save();
}; };
ImGui.TableNextRow(); ImGui.TableNextRow();
@ -507,8 +505,8 @@ namespace FFXIV_Vibe_Plugin {
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text("Trigger Name:"); ImGui.Text("Trigger Name:");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
if(ImGui.InputText("###TRIGGER_NAME", ref this.SelectedTrigger.Name, 99)) { if (ImGui.InputText("###TRIGGER_NAME", ref this.SelectedTrigger.Name, 99)) {
if(this.SelectedTrigger.Name == "") { if (this.SelectedTrigger.Name == "") {
this.SelectedTrigger.Name = "no_name"; this.SelectedTrigger.Name = "no_name";
} }
this.Configuration.Save(); this.Configuration.Save();
@ -534,9 +532,9 @@ namespace FFXIV_Vibe_Plugin {
ImGui.TableNextColumn(); ImGui.TableNextColumn();
string[] TRIGGER_KIND = System.Enum.GetNames(typeof(Triggers.KIND)); string[] TRIGGER_KIND = System.Enum.GetNames(typeof(Triggers.KIND));
int currentKind = (int)this.SelectedTrigger.Kind; int currentKind = (int)this.SelectedTrigger.Kind;
if(ImGui.Combo("###TRIGGER_FORM_KIND", ref currentKind, TRIGGER_KIND, TRIGGER_KIND.Length)) { if (ImGui.Combo("###TRIGGER_FORM_KIND", ref currentKind, TRIGGER_KIND, TRIGGER_KIND.Length)) {
this.SelectedTrigger.Kind = currentKind; this.SelectedTrigger.Kind = currentKind;
if(currentKind == (int)Triggers.KIND.HPChange) { if (currentKind == (int)Triggers.KIND.HPChange) {
this.SelectedTrigger.StartAfter = 0; this.SelectedTrigger.StartAfter = 0;
this.SelectedTrigger.StopAfter = 0; this.SelectedTrigger.StopAfter = 0;
} }
@ -548,7 +546,7 @@ namespace FFXIV_Vibe_Plugin {
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text("Player name:"); ImGui.Text("Player name:");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
if(ImGui.InputText("###TRIGGER_CHAT_FROM_PLAYER_NAME", ref this.SelectedTrigger.FromPlayerName, 100)) { if (ImGui.InputText("###TRIGGER_CHAT_FROM_PLAYER_NAME", ref this.SelectedTrigger.FromPlayerName, 100)) {
this.SelectedTrigger.FromPlayerName = this.SelectedTrigger.FromPlayerName.Trim(); this.SelectedTrigger.FromPlayerName = this.SelectedTrigger.FromPlayerName.Trim();
this.Configuration.Save(); this.Configuration.Save();
}; };
@ -562,14 +560,14 @@ namespace FFXIV_Vibe_Plugin {
ImGui.Text("Start after"); ImGui.Text("Start after");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.SetNextItemWidth(185); ImGui.SetNextItemWidth(185);
if(ImGui.SliderFloat("###TRIGGER_FORM_START_AFTER", ref this.SelectedTrigger.StartAfter, this.TRIGGER_MIN_AFTER, this.TRIGGER_MAX_AFTER)) { if (ImGui.SliderFloat("###TRIGGER_FORM_START_AFTER", ref this.SelectedTrigger.StartAfter, this.TRIGGER_MIN_AFTER, this.TRIGGER_MAX_AFTER)) {
this.SelectedTrigger.StartAfter = Helpers.ClampFloat(this.SelectedTrigger.StartAfter, this.TRIGGER_MIN_AFTER, this.TRIGGER_MAX_AFTER); this.SelectedTrigger.StartAfter = Helpers.ClampFloat(this.SelectedTrigger.StartAfter, this.TRIGGER_MIN_AFTER, this.TRIGGER_MAX_AFTER);
this.Configuration.Save(); this.Configuration.Save();
} }
ImGui.SameLine(); ImGui.SameLine();
ImGui.SetNextItemWidth(45); ImGui.SetNextItemWidth(45);
if(ImGui.InputFloat("###TRIGGER_FORM_START_AFTER_INPUT", ref this.SelectedTrigger.StartAfter, this.TRIGGER_MIN_AFTER, this.TRIGGER_MAX_AFTER)) { if (ImGui.InputFloat("###TRIGGER_FORM_START_AFTER_INPUT", ref this.SelectedTrigger.StartAfter, this.TRIGGER_MIN_AFTER, this.TRIGGER_MAX_AFTER)) {
this.SelectedTrigger.StartAfter = Helpers.ClampFloat(this.SelectedTrigger.StartAfter, this.TRIGGER_MIN_AFTER, this.TRIGGER_MAX_AFTER); this.SelectedTrigger.StartAfter = Helpers.ClampFloat(this.SelectedTrigger.StartAfter, this.TRIGGER_MIN_AFTER, this.TRIGGER_MAX_AFTER);
this.Configuration.Save(); this.Configuration.Save();
} }
@ -582,13 +580,13 @@ namespace FFXIV_Vibe_Plugin {
ImGui.Text("Stop after"); ImGui.Text("Stop after");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.SetNextItemWidth(185); ImGui.SetNextItemWidth(185);
if(ImGui.SliderFloat("###TRIGGER_FORM_STOP_AFTER", ref this.SelectedTrigger.StopAfter, this.TRIGGER_MIN_AFTER, this.TRIGGER_MAX_AFTER)) { if (ImGui.SliderFloat("###TRIGGER_FORM_STOP_AFTER", ref this.SelectedTrigger.StopAfter, this.TRIGGER_MIN_AFTER, this.TRIGGER_MAX_AFTER)) {
this.SelectedTrigger.StopAfter = Helpers.ClampFloat(this.SelectedTrigger.StopAfter, this.TRIGGER_MIN_AFTER, this.TRIGGER_MAX_AFTER); this.SelectedTrigger.StopAfter = Helpers.ClampFloat(this.SelectedTrigger.StopAfter, this.TRIGGER_MIN_AFTER, this.TRIGGER_MAX_AFTER);
this.Configuration.Save(); this.Configuration.Save();
} }
ImGui.SameLine(); ImGui.SameLine();
ImGui.SetNextItemWidth(45); ImGui.SetNextItemWidth(45);
if(ImGui.InputFloat("###TRIGGER_FORM_STOP_AFTER_INPUT", ref this.SelectedTrigger.StopAfter, this.TRIGGER_MIN_AFTER, this.TRIGGER_MAX_AFTER)) { if (ImGui.InputFloat("###TRIGGER_FORM_STOP_AFTER_INPUT", ref this.SelectedTrigger.StopAfter, this.TRIGGER_MIN_AFTER, this.TRIGGER_MAX_AFTER)) {
this.SelectedTrigger.StopAfter = Helpers.ClampFloat(this.SelectedTrigger.StopAfter, this.TRIGGER_MIN_AFTER, this.TRIGGER_MAX_AFTER); this.SelectedTrigger.StopAfter = Helpers.ClampFloat(this.SelectedTrigger.StopAfter, this.TRIGGER_MIN_AFTER, this.TRIGGER_MAX_AFTER);
this.Configuration.Save(); this.Configuration.Save();
} }
@ -601,7 +599,7 @@ namespace FFXIV_Vibe_Plugin {
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text("Priority"); ImGui.Text("Priority");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
if(ImGui.InputInt("###TRIGGER_FORM_PRIORITY", ref this.SelectedTrigger.Priority, 1)) { if (ImGui.InputInt("###TRIGGER_FORM_PRIORITY", ref this.SelectedTrigger.Priority, 1)) {
this.Configuration.Save(); this.Configuration.Save();
} }
ImGui.SameLine(); ImGui.SameLine();
@ -613,7 +611,7 @@ namespace FFXIV_Vibe_Plugin {
ImGui.Separator(); ImGui.Separator();
// TRIGGER KIND:CHAT OPTIONS // TRIGGER KIND:CHAT OPTIONS
if(this.SelectedTrigger.Kind == (int)Triggers.KIND.Chat) { if (this.SelectedTrigger.Kind == (int)Triggers.KIND.Chat) {
// TRIGGER FORM_TABLE_KIND_CHAT // TRIGGER FORM_TABLE_KIND_CHAT
ImGui.BeginTable("###TRIGGER_FORM_TABLE_KIND_CHAT", 2); ImGui.BeginTable("###TRIGGER_FORM_TABLE_KIND_CHAT", 2);
@ -625,7 +623,7 @@ namespace FFXIV_Vibe_Plugin {
ImGui.Text("Chat text:"); ImGui.Text("Chat text:");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
string currentChatText = this.SelectedTrigger.ChatText; string currentChatText = this.SelectedTrigger.ChatText;
if(ImGui.InputText("###TRIGGER_CHAT_TEXT", ref currentChatText, 250)) { if (ImGui.InputText("###TRIGGER_CHAT_TEXT", ref currentChatText, 250)) {
this.SelectedTrigger.ChatText = currentChatText.ToLower(); // ChatMsg is always lower this.SelectedTrigger.ChatText = currentChatText.ToLower(); // ChatMsg is always lower
this.Configuration.Save(); this.Configuration.Save();
}; };
@ -639,8 +637,8 @@ namespace FFXIV_Vibe_Plugin {
ImGui.TableNextColumn(); ImGui.TableNextColumn();
int currentTypeAllowed = 0; int currentTypeAllowed = 0;
string[] ChatTypesAllowedStrings = Enum.GetNames(typeof(XivChatType)); string[] ChatTypesAllowedStrings = Enum.GetNames(typeof(XivChatType));
if(ImGui.Combo("###TRIGGER_CHAT_TEXT_TYPE_ALLOWED", ref currentTypeAllowed, ChatTypesAllowedStrings, ChatTypesAllowedStrings.Length)) { if (ImGui.Combo("###TRIGGER_CHAT_TEXT_TYPE_ALLOWED", ref currentTypeAllowed, ChatTypesAllowedStrings, ChatTypesAllowedStrings.Length)) {
if(!this.SelectedTrigger.AllowedChatTypes.Contains(currentTypeAllowed)) { if (!this.SelectedTrigger.AllowedChatTypes.Contains(currentTypeAllowed)) {
int XivChatTypeValue = (int)(XivChatType)Enum.Parse(typeof(XivChatType), ChatTypesAllowedStrings[currentTypeAllowed]); int XivChatTypeValue = (int)(XivChatType)Enum.Parse(typeof(XivChatType), ChatTypesAllowedStrings[currentTypeAllowed]);
this.SelectedTrigger.AllowedChatTypes.Add(XivChatTypeValue); this.SelectedTrigger.AllowedChatTypes.Add(XivChatTypeValue);
} }
@ -649,14 +647,14 @@ namespace FFXIV_Vibe_Plugin {
ImGuiComponents.HelpMarker("Select some chats to observe or unselect all to watch every chats."); ImGuiComponents.HelpMarker("Select some chats to observe or unselect all to watch every chats.");
ImGui.TableNextRow(); ImGui.TableNextRow();
if(this.SelectedTrigger.AllowedChatTypes.Count > 0) { if (this.SelectedTrigger.AllowedChatTypes.Count > 0) {
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text("Allowed Type:"); ImGui.Text("Allowed Type:");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
for(int indexAllowedChatType = 0; indexAllowedChatType < this.SelectedTrigger.AllowedChatTypes.Count; indexAllowedChatType++) { for (int indexAllowedChatType = 0; indexAllowedChatType < this.SelectedTrigger.AllowedChatTypes.Count; indexAllowedChatType++) {
int XivChatTypeValue = this.SelectedTrigger.AllowedChatTypes[indexAllowedChatType]; int XivChatTypeValue = this.SelectedTrigger.AllowedChatTypes[indexAllowedChatType];
if(ImGuiComponents.IconButton(indexAllowedChatType, Dalamud.Interface.FontAwesomeIcon.Minus)) { if (ImGuiComponents.IconButton(indexAllowedChatType, Dalamud.Interface.FontAwesomeIcon.Minus)) {
this.SelectedTrigger.AllowedChatTypes.RemoveAt(indexAllowedChatType); this.SelectedTrigger.AllowedChatTypes.RemoveAt(indexAllowedChatType);
this.Configuration.Save(); this.Configuration.Save();
}; };
@ -679,14 +677,14 @@ namespace FFXIV_Vibe_Plugin {
ImGui.TableSetupColumn("###TRIGGER_FORM_TABLE_KIND_SPELL_COL2", ImGuiTableColumnFlags.WidthStretch); ImGui.TableSetupColumn("###TRIGGER_FORM_TABLE_KIND_SPELL_COL2", ImGuiTableColumnFlags.WidthStretch);
// TRIGGER KIND:SPELL OPTIONS // TRIGGER KIND:SPELL OPTIONS
if(this.SelectedTrigger.Kind == (int)Triggers.KIND.Spell){ if (this.SelectedTrigger.Kind == (int)Triggers.KIND.Spell) {
// TRIGGER TYPE // TRIGGER TYPE
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text("Type:"); ImGui.Text("Type:");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
string[] TRIGGER = System.Enum.GetNames(typeof(FFXIV_Vibe_Plugin.Commons.Structures.ActionEffectType)); string[] TRIGGER = System.Enum.GetNames(typeof(FFXIV_Vibe_Plugin.Commons.Structures.ActionEffectType));
int currentEffectType = (int)this.SelectedTrigger.ActionEffectType; int currentEffectType = (int)this.SelectedTrigger.ActionEffectType;
if(ImGui.Combo("###TRIGGER_FORM_EVENT", ref currentEffectType, TRIGGER, TRIGGER.Length)) { if (ImGui.Combo("###TRIGGER_FORM_EVENT", ref currentEffectType, TRIGGER, TRIGGER.Length)) {
this.SelectedTrigger.ActionEffectType = currentEffectType; this.SelectedTrigger.ActionEffectType = currentEffectType;
this.SelectedTrigger.Reset(); this.SelectedTrigger.Reset();
this.Configuration.Save(); this.Configuration.Save();
@ -697,7 +695,7 @@ namespace FFXIV_Vibe_Plugin {
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text("Spell Text:"); ImGui.Text("Spell Text:");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
if(ImGui.InputText("###TRIGGER_FORM_SPELLNAME", ref this.SelectedTrigger.SpellText, 100)) { if (ImGui.InputText("###TRIGGER_FORM_SPELLNAME", ref this.SelectedTrigger.SpellText, 100)) {
this.Configuration.Save(); this.Configuration.Save();
} }
ImGui.SameLine(); ImGui.SameLine();
@ -710,7 +708,7 @@ namespace FFXIV_Vibe_Plugin {
ImGui.TableNextColumn(); ImGui.TableNextColumn();
string[] DIRECTIONS = System.Enum.GetNames(typeof(Triggers.DIRECTION)); string[] DIRECTIONS = System.Enum.GetNames(typeof(Triggers.DIRECTION));
int currentDirection = (int)this.SelectedTrigger.Direction; int currentDirection = (int)this.SelectedTrigger.Direction;
if(ImGui.Combo("###TRIGGER_FORM_DIRECTION", ref currentDirection, DIRECTIONS, DIRECTIONS.Length)) { if (ImGui.Combo("###TRIGGER_FORM_DIRECTION", ref currentDirection, DIRECTIONS, DIRECTIONS.Length)) {
this.SelectedTrigger.Direction = currentDirection; this.SelectedTrigger.Direction = currentDirection;
this.Configuration.Save(); this.Configuration.Save();
} }
@ -719,23 +717,22 @@ namespace FFXIV_Vibe_Plugin {
ImGui.TableNextRow(); ImGui.TableNextRow();
} }
if( if (
this.SelectedTrigger.ActionEffectType == (int)Structures.ActionEffectType.Damage || this.SelectedTrigger.ActionEffectType == (int)Structures.ActionEffectType.Damage ||
this.SelectedTrigger.ActionEffectType == (int)Structures.ActionEffectType.Heal this.SelectedTrigger.ActionEffectType == (int)Structures.ActionEffectType.Heal
|| ||
this.SelectedTrigger.Kind == (int)Triggers.KIND.HPChange) this.SelectedTrigger.Kind == (int)Triggers.KIND.HPChange) {
{
// Min/Max amount values // Min/Max amount values
string type = ""; string type = "";
if(this.SelectedTrigger.ActionEffectType == (int)Structures.ActionEffectType.Damage) { type = "damage"; } if (this.SelectedTrigger.ActionEffectType == (int)Structures.ActionEffectType.Damage) { type = "damage"; }
if(this.SelectedTrigger.ActionEffectType == (int)Structures.ActionEffectType.Heal) { type = "heal"; } if (this.SelectedTrigger.ActionEffectType == (int)Structures.ActionEffectType.Heal) { type = "heal"; }
if(this.SelectedTrigger.Kind == (int)Triggers.KIND.HPChange) { type = "health"; } if (this.SelectedTrigger.Kind == (int)Triggers.KIND.HPChange) { type = "health"; }
// TRIGGER AMOUNT IN PERCENTAGE // TRIGGER AMOUNT IN PERCENTAGE
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text("Amount in percentage?"); ImGui.Text("Amount in percentage?");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
if(ImGui.Checkbox("###TRIGGER_AMOUNT_IN_PERCENTAGE", ref this.SelectedTrigger.AmountInPercentage)){ if (ImGui.Checkbox("###TRIGGER_AMOUNT_IN_PERCENTAGE", ref this.SelectedTrigger.AmountInPercentage)) {
this.SelectedTrigger.AmountMinValue = 0; this.SelectedTrigger.AmountMinValue = 0;
this.SelectedTrigger.AmountMaxValue = 100; this.SelectedTrigger.AmountMaxValue = 100;
this.Configuration.Save(); this.Configuration.Save();
@ -748,7 +745,7 @@ namespace FFXIV_Vibe_Plugin {
ImGui.Text($"Min {type} value:"); ImGui.Text($"Min {type} value:");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
if (this.SelectedTrigger.AmountInPercentage) { if (this.SelectedTrigger.AmountInPercentage) {
if(ImGui.SliderInt("###TRIGGER_FORM_MIN_AMOUNT", ref this.SelectedTrigger.AmountMinValue, 0, 100)) { if (ImGui.SliderInt("###TRIGGER_FORM_MIN_AMOUNT", ref this.SelectedTrigger.AmountMinValue, 0, 100)) {
this.Configuration.Save(); this.Configuration.Save();
} }
} else { } else {
@ -766,8 +763,7 @@ namespace FFXIV_Vibe_Plugin {
if (ImGui.SliderInt("###TRIGGER_FORM_MAX_AMOUNT", ref this.SelectedTrigger.AmountMaxValue, 0, 100)) { if (ImGui.SliderInt("###TRIGGER_FORM_MAX_AMOUNT", ref this.SelectedTrigger.AmountMaxValue, 0, 100)) {
this.Configuration.Save(); this.Configuration.Save();
} }
} } else {
else {
if (ImGui.InputInt("###TRIGGER_FORM_MAX_AMOUNT", ref this.SelectedTrigger.AmountMaxValue, 100)) { if (ImGui.InputInt("###TRIGGER_FORM_MAX_AMOUNT", ref this.SelectedTrigger.AmountMaxValue, 100)) {
this.Configuration.Save(); this.Configuration.Save();
} }
@ -781,15 +777,15 @@ namespace FFXIV_Vibe_Plugin {
// TRIGGER COMBO_DEVICES // TRIGGER COMBO_DEVICES
Dictionary<String, Device.Device> visitedDevice = DevicesController.GetVisitedDevices(); Dictionary<String, Device.Device> visitedDevice = DevicesController.GetVisitedDevices();
if(visitedDevice.Count == 0) { if (visitedDevice.Count == 0) {
ImGui.TextColored(ImGuiColors.DalamudRed, "Please connect yourself to intiface and add device(s)..."); ImGui.TextColored(ImGuiColors.DalamudRed, "Please connect yourself to intiface and add device(s)...");
} else { } else {
string[] devicesStrings = visitedDevice.Keys.ToArray(); string[] devicesStrings = visitedDevice.Keys.ToArray();
ImGui.Combo("###TRIGGER_FORM_COMBO_DEVICES", ref this.TRIGGER_CURRENT_SELECTED_DEVICE, devicesStrings, devicesStrings.Length); ImGui.Combo("###TRIGGER_FORM_COMBO_DEVICES", ref this.TRIGGER_CURRENT_SELECTED_DEVICE, devicesStrings, devicesStrings.Length);
ImGui.SameLine(); ImGui.SameLine();
List<Triggers.TriggerDevice> triggerDevices = this.SelectedTrigger.Devices; List<Triggers.TriggerDevice> triggerDevices = this.SelectedTrigger.Devices;
if(ImGuiComponents.IconButton(Dalamud.Interface.FontAwesomeIcon.Plus)) { if (ImGuiComponents.IconButton(Dalamud.Interface.FontAwesomeIcon.Plus)) {
if(this.TRIGGER_CURRENT_SELECTED_DEVICE >= 0) { if (this.TRIGGER_CURRENT_SELECTED_DEVICE >= 0) {
Device.Device device = visitedDevice[devicesStrings[this.TRIGGER_CURRENT_SELECTED_DEVICE]]; Device.Device device = visitedDevice[devicesStrings[this.TRIGGER_CURRENT_SELECTED_DEVICE]];
Triggers.TriggerDevice newTriggerDevice = new(device); Triggers.TriggerDevice newTriggerDevice = new(device);
triggerDevices.Add(newTriggerDevice); triggerDevices.Add(newTriggerDevice);
@ -799,35 +795,35 @@ namespace FFXIV_Vibe_Plugin {
string[] patternNames = this.Patterns.GetAllPatterns().Select(p => p.Name).ToArray(); string[] patternNames = this.Patterns.GetAllPatterns().Select(p => p.Name).ToArray();
for(int indexDevice = 0; indexDevice < triggerDevices.Count; indexDevice++) { for (int indexDevice = 0; indexDevice < triggerDevices.Count; indexDevice++) {
string prefixLabel = $"###TRIGGER_FORM_COMBO_DEVICE_${indexDevice}"; string prefixLabel = $"###TRIGGER_FORM_COMBO_DEVICE_${indexDevice}";
Triggers.TriggerDevice triggerDevice = triggerDevices[indexDevice]; Triggers.TriggerDevice triggerDevice = triggerDevices[indexDevice];
string deviceName = triggerDevice.Device != null ? triggerDevice.Device.Name : "UnknownDevice"; string deviceName = triggerDevice.Device != null ? triggerDevice.Device.Name : "UnknownDevice";
if(ImGui.CollapsingHeader($"{deviceName}")) { if (ImGui.CollapsingHeader($"{deviceName}")) {
ImGui.Indent(10); ImGui.Indent(10);
if(triggerDevice != null && triggerDevice.Device != null) { if (triggerDevice != null && triggerDevice.Device != null) {
if(triggerDevice.Device.CanVibrate) { if (triggerDevice.Device.CanVibrate) {
if(ImGui.Checkbox($"{prefixLabel}_SHOULD_VIBRATE", ref triggerDevice.ShouldVibrate)) { if (ImGui.Checkbox($"{prefixLabel}_SHOULD_VIBRATE", ref triggerDevice.ShouldVibrate)) {
triggerDevice.ShouldStop = false; triggerDevice.ShouldStop = false;
this.Configuration.Save(); this.Configuration.Save();
} }
ImGui.SameLine(); ImGui.SameLine();
ImGui.Text("Should Vibrate"); ImGui.Text("Should Vibrate");
if(triggerDevice.ShouldVibrate) { if (triggerDevice.ShouldVibrate) {
ImGui.Indent(20); ImGui.Indent(20);
for(int motorId = 0; motorId < triggerDevice.Device.VibrateMotors; motorId++) { for (int motorId = 0; motorId < triggerDevice.Device.VibrateMotors; motorId++) {
ImGui.Text($"Motor {motorId + 1}"); ImGui.Text($"Motor {motorId + 1}");
ImGui.SameLine(); ImGui.SameLine();
// Display Vibrate Motor checkbox // Display Vibrate Motor checkbox
if(ImGui.Checkbox($"{prefixLabel}_SHOULD_VIBRATE_MOTOR_{motorId}", ref triggerDevice.VibrateSelectedMotors[motorId])) { if (ImGui.Checkbox($"{prefixLabel}_SHOULD_VIBRATE_MOTOR_{motorId}", ref triggerDevice.VibrateSelectedMotors[motorId])) {
this.Configuration.Save(); this.Configuration.Save();
} }
if(triggerDevice.VibrateSelectedMotors[motorId]) { if (triggerDevice.VibrateSelectedMotors[motorId]) {
ImGui.SameLine(); ImGui.SameLine();
ImGui.SetNextItemWidth(90); ImGui.SetNextItemWidth(90);
if(ImGui.Combo($"###{prefixLabel}_VIBRATE_PATTERNS_{motorId}", ref triggerDevice.VibrateMotorsPattern[motorId], patternNames, patternNames.Length)) { if (ImGui.Combo($"###{prefixLabel}_VIBRATE_PATTERNS_{motorId}", ref triggerDevice.VibrateMotorsPattern[motorId], patternNames, patternNames.Length)) {
this.Configuration.Save(); this.Configuration.Save();
} }
@ -835,8 +831,8 @@ namespace FFXIV_Vibe_Plugin {
int currentPatternIndex = triggerDevice.VibrateMotorsPattern[motorId]; int currentPatternIndex = triggerDevice.VibrateMotorsPattern[motorId];
ImGui.SameLine(); ImGui.SameLine();
ImGui.SetNextItemWidth(180); ImGui.SetNextItemWidth(180);
if(ImGui.SliderInt($"{prefixLabel}_SHOULD_VIBRATE_MOTOR_{motorId}_THRESHOLD", ref triggerDevice.VibrateMotorsThreshold[motorId], 0, 100)) { if (ImGui.SliderInt($"{prefixLabel}_SHOULD_VIBRATE_MOTOR_{motorId}_THRESHOLD", ref triggerDevice.VibrateMotorsThreshold[motorId], 0, 100)) {
if(triggerDevice.VibrateMotorsThreshold[motorId] > 0) { if (triggerDevice.VibrateMotorsThreshold[motorId] > 0) {
triggerDevice.VibrateSelectedMotors[motorId] = true; triggerDevice.VibrateSelectedMotors[motorId] = true;
} }
this.Configuration.Save(); this.Configuration.Save();
@ -846,33 +842,33 @@ namespace FFXIV_Vibe_Plugin {
ImGui.Indent(-20); ImGui.Indent(-20);
} }
} }
if(triggerDevice.Device.CanRotate) { if (triggerDevice.Device.CanRotate) {
if(ImGui.Checkbox($"{prefixLabel}_SHOULD_ROTATE", ref triggerDevice.ShouldRotate)) { if (ImGui.Checkbox($"{prefixLabel}_SHOULD_ROTATE", ref triggerDevice.ShouldRotate)) {
triggerDevice.ShouldStop = false; triggerDevice.ShouldStop = false;
this.Configuration.Save(); this.Configuration.Save();
} }
ImGui.SameLine(); ImGui.SameLine();
ImGui.Text("Should Rotate"); ImGui.Text("Should Rotate");
if(triggerDevice.ShouldRotate) { if (triggerDevice.ShouldRotate) {
ImGui.Indent(20); ImGui.Indent(20);
for(int motorId = 0; motorId < triggerDevice.Device.RotateMotors; motorId++) { for (int motorId = 0; motorId < triggerDevice.Device.RotateMotors; motorId++) {
ImGui.Text($"Motor {motorId + 1}"); ImGui.Text($"Motor {motorId + 1}");
ImGui.SameLine(); ImGui.SameLine();
if(ImGui.Checkbox($"{prefixLabel}_SHOULD_ROTATE_MOTOR_{motorId}", ref triggerDevice.RotateSelectedMotors[motorId])) { if (ImGui.Checkbox($"{prefixLabel}_SHOULD_ROTATE_MOTOR_{motorId}", ref triggerDevice.RotateSelectedMotors[motorId])) {
this.Configuration.Save(); this.Configuration.Save();
} }
if(triggerDevice.RotateSelectedMotors[motorId]) { if (triggerDevice.RotateSelectedMotors[motorId]) {
ImGui.SameLine(); ImGui.SameLine();
ImGui.SetNextItemWidth(90); ImGui.SetNextItemWidth(90);
if(ImGui.Combo($"###{prefixLabel}_ROTATE_PATTERNS_{motorId}", ref triggerDevice.RotateMotorsPattern[motorId], patternNames, patternNames.Length)) { if (ImGui.Combo($"###{prefixLabel}_ROTATE_PATTERNS_{motorId}", ref triggerDevice.RotateMotorsPattern[motorId], patternNames, patternNames.Length)) {
this.Configuration.Save(); this.Configuration.Save();
} }
// Special intensity pattern asks for intensity param. // Special intensity pattern asks for intensity param.
int currentPatternIndex = triggerDevice.RotateMotorsPattern[motorId]; int currentPatternIndex = triggerDevice.RotateMotorsPattern[motorId];
ImGui.SameLine(); ImGui.SameLine();
ImGui.SetNextItemWidth(180); ImGui.SetNextItemWidth(180);
if(ImGui.SliderInt($"{prefixLabel}_SHOULD_ROTATE_MOTOR_{motorId}_THRESHOLD", ref triggerDevice.RotateMotorsThreshold[motorId], 0, 100)) { if (ImGui.SliderInt($"{prefixLabel}_SHOULD_ROTATE_MOTOR_{motorId}_THRESHOLD", ref triggerDevice.RotateMotorsThreshold[motorId], 0, 100)) {
if(triggerDevice.RotateMotorsThreshold[motorId] > 0) { if (triggerDevice.RotateMotorsThreshold[motorId] > 0) {
triggerDevice.RotateSelectedMotors[motorId] = true; triggerDevice.RotateSelectedMotors[motorId] = true;
} }
this.Configuration.Save(); this.Configuration.Save();
@ -883,33 +879,33 @@ namespace FFXIV_Vibe_Plugin {
ImGui.Indent(-20); ImGui.Indent(-20);
} }
} }
if(triggerDevice.Device.CanLinear) { if (triggerDevice.Device.CanLinear) {
if(ImGui.Checkbox($"{prefixLabel}_SHOULD_LINEAR", ref triggerDevice.ShouldLinear)) { if (ImGui.Checkbox($"{prefixLabel}_SHOULD_LINEAR", ref triggerDevice.ShouldLinear)) {
triggerDevice.ShouldStop = false; triggerDevice.ShouldStop = false;
this.Configuration.Save(); this.Configuration.Save();
} }
ImGui.SameLine(); ImGui.SameLine();
ImGui.Text("Should Linear"); ImGui.Text("Should Linear");
if(triggerDevice.ShouldLinear) { if (triggerDevice.ShouldLinear) {
ImGui.Indent(20); ImGui.Indent(20);
for(int motorId = 0; motorId < triggerDevice.Device.LinearMotors; motorId++) { for (int motorId = 0; motorId < triggerDevice.Device.LinearMotors; motorId++) {
ImGui.Text($"Motor {motorId + 1}"); ImGui.Text($"Motor {motorId + 1}");
ImGui.SameLine(); ImGui.SameLine();
if(ImGui.Checkbox($"{prefixLabel}_SHOULD_LINEAR_MOTOR_{motorId}", ref triggerDevice.LinearSelectedMotors[motorId])) { if (ImGui.Checkbox($"{prefixLabel}_SHOULD_LINEAR_MOTOR_{motorId}", ref triggerDevice.LinearSelectedMotors[motorId])) {
this.Configuration.Save(); this.Configuration.Save();
} }
if(triggerDevice.LinearSelectedMotors[motorId]) { if (triggerDevice.LinearSelectedMotors[motorId]) {
ImGui.SameLine(); ImGui.SameLine();
ImGui.SetNextItemWidth(90); ImGui.SetNextItemWidth(90);
if(ImGui.Combo($"###{prefixLabel}_LINEAR_PATTERNS_{motorId}", ref triggerDevice.LinearMotorsPattern[motorId], patternNames, patternNames.Length)) { if (ImGui.Combo($"###{prefixLabel}_LINEAR_PATTERNS_{motorId}", ref triggerDevice.LinearMotorsPattern[motorId], patternNames, patternNames.Length)) {
this.Configuration.Save(); this.Configuration.Save();
} }
// Special intensity pattern asks for intensity param. // Special intensity pattern asks for intensity param.
int currentPatternIndex = triggerDevice.LinearMotorsPattern[motorId]; int currentPatternIndex = triggerDevice.LinearMotorsPattern[motorId];
ImGui.SameLine(); ImGui.SameLine();
ImGui.SetNextItemWidth(180); ImGui.SetNextItemWidth(180);
if(ImGui.SliderInt($"{prefixLabel}_SHOULD_LINEAR_MOTOR_{motorId}_THRESHOLD", ref triggerDevice.LinearMotorsThreshold[motorId], 0, 100)) { if (ImGui.SliderInt($"{prefixLabel}_SHOULD_LINEAR_MOTOR_{motorId}_THRESHOLD", ref triggerDevice.LinearMotorsThreshold[motorId], 0, 100)) {
if(triggerDevice.LinearMotorsThreshold[motorId] > 0) { if (triggerDevice.LinearMotorsThreshold[motorId] > 0) {
triggerDevice.LinearSelectedMotors[motorId] = true; triggerDevice.LinearSelectedMotors[motorId] = true;
} }
this.Configuration.Save(); this.Configuration.Save();
@ -919,8 +915,8 @@ namespace FFXIV_Vibe_Plugin {
ImGui.Indent(-20); ImGui.Indent(-20);
} }
} }
if(triggerDevice.Device.CanStop) { if (triggerDevice.Device.CanStop) {
if(ImGui.Checkbox($"{prefixLabel}_SHOULD_STOP", ref triggerDevice.ShouldStop)) { if (ImGui.Checkbox($"{prefixLabel}_SHOULD_STOP", ref triggerDevice.ShouldStop)) {
triggerDevice.ShouldVibrate = false; triggerDevice.ShouldVibrate = false;
triggerDevice.ShouldRotate = false; triggerDevice.ShouldRotate = false;
triggerDevice.ShouldLinear = false; triggerDevice.ShouldLinear = false;
@ -931,7 +927,7 @@ namespace FFXIV_Vibe_Plugin {
ImGui.SameLine(); ImGui.SameLine();
ImGuiComponents.HelpMarker("Instantly stop all motors for this device."); ImGuiComponents.HelpMarker("Instantly stop all motors for this device.");
} }
if(ImGui.Button($"Remove###{prefixLabel}_REMOVE")) { if (ImGui.Button($"Remove###{prefixLabel}_REMOVE")) {
triggerDevices.RemoveAt(indexDevice); triggerDevices.RemoveAt(indexDevice);
this.Logger.Log($"DEBUG: removing {indexDevice}"); this.Logger.Log($"DEBUG: removing {indexDevice}");
this.Configuration.Save(); this.Configuration.Save();
@ -946,11 +942,11 @@ namespace FFXIV_Vibe_Plugin {
} else { } else {
ImGui.TextColored(ImGuiColors.DalamudRed, "Current selected trigger is null"); ImGui.TextColored(ImGuiColors.DalamudRed, "Current selected trigger is null");
} }
} else if(this.triggersViewMode == "delete") { } else if (this.triggersViewMode == "delete") {
if(this.SelectedTrigger != null) { if (this.SelectedTrigger != null) {
ImGui.TextColored(ImGuiColors.DalamudRed, $"Are you sure you want to delete trigger ID: {this.SelectedTrigger.Id}"); ImGui.TextColored(ImGuiColors.DalamudRed, $"Are you sure you want to delete trigger ID: {this.SelectedTrigger.Id}");
if(ImGui.Button("Yes")) { if (ImGui.Button("Yes")) {
if(this.SelectedTrigger != null) { if (this.SelectedTrigger != null) {
this.TriggerController.RemoveTrigger(this.SelectedTrigger); this.TriggerController.RemoveTrigger(this.SelectedTrigger);
this.SelectedTrigger = null; this.SelectedTrigger = null;
this.Configuration.Save(); this.Configuration.Save();
@ -958,7 +954,7 @@ namespace FFXIV_Vibe_Plugin {
this.triggersViewMode = "default"; this.triggersViewMode = "default";
}; };
ImGui.SameLine(); ImGui.SameLine();
if(ImGui.Button("No")) { if (ImGui.Button("No")) {
this.SelectedTrigger = null; this.SelectedTrigger = null;
this.triggersViewMode = "default"; this.triggersViewMode = "default";
}; };
@ -967,7 +963,7 @@ namespace FFXIV_Vibe_Plugin {
ImGui.EndChild(); ImGui.EndChild();
} }
if(ImGui.Button("Add")) { if (ImGui.Button("Add")) {
Triggers.Trigger trigger = new("New Trigger"); Triggers.Trigger trigger = new("New Trigger");
this.TriggerController.AddTrigger(trigger); this.TriggerController.AddTrigger(trigger);
this.SelectedTrigger = trigger; this.SelectedTrigger = trigger;
@ -975,7 +971,7 @@ namespace FFXIV_Vibe_Plugin {
this.Configuration.Save(); this.Configuration.Save();
}; };
ImGui.SameLine(); ImGui.SameLine();
if(ImGui.Button("Delete")) { if (ImGui.Button("Delete")) {
this.triggersViewMode = "delete"; this.triggersViewMode = "delete";
} }
@ -993,7 +989,7 @@ namespace FFXIV_Vibe_Plugin {
ImGui.Text("Pattern Name:"); ImGui.Text("Pattern Name:");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.SetNextItemWidth(300); ImGui.SetNextItemWidth(300);
if(ImGui.InputText("###PATTERNS_CURRENT_PATTERN_NAME_TO_ADD", ref this._tmp_currentPatternNameToAdd, 150)) { if (ImGui.InputText("###PATTERNS_CURRENT_PATTERN_NAME_TO_ADD", ref this._tmp_currentPatternNameToAdd, 150)) {
this._tmp_currentPatternNameToAdd = this._tmp_currentPatternNameToAdd.Trim(); this._tmp_currentPatternNameToAdd = this._tmp_currentPatternNameToAdd.Trim();
} }
ImGui.TableNextRow(); ImGui.TableNextRow();
@ -1001,10 +997,10 @@ namespace FFXIV_Vibe_Plugin {
ImGui.Text("Pattern Value:"); ImGui.Text("Pattern Value:");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.SetNextItemWidth(300); ImGui.SetNextItemWidth(300);
if(ImGui.InputText("###PATTERNS_CURRENT_PATTERN_VALUE_TO_ADD", ref this._tmp_currentPatternValueToAdd, 500)) { if (ImGui.InputText("###PATTERNS_CURRENT_PATTERN_VALUE_TO_ADD", ref this._tmp_currentPatternValueToAdd, 500)) {
this._tmp_currentPatternValueToAdd = this._tmp_currentPatternValueToAdd.Trim(); this._tmp_currentPatternValueToAdd = this._tmp_currentPatternValueToAdd.Trim();
string value = this._tmp_currentPatternValueToAdd.Trim(); string value = this._tmp_currentPatternValueToAdd.Trim();
if(value == "") { if (value == "") {
this._tmp_currentPatternValueState = "unset"; this._tmp_currentPatternValueState = "unset";
} else { } else {
this._tmp_currentPatternValueState = Helpers.RegExpMatch(this.Logger, this._tmp_currentPatternValueToAdd, this.VALID_REGEXP_PATTERN) ? "valid" : "unvalid"; this._tmp_currentPatternValueState = Helpers.RegExpMatch(this.Logger, this._tmp_currentPatternValueToAdd, this.VALID_REGEXP_PATTERN) ? "valid" : "unvalid";
@ -1014,9 +1010,9 @@ namespace FFXIV_Vibe_Plugin {
if(this._tmp_currentPatternNameToAdd.Trim() != "" && this._tmp_currentPatternValueState == "valid") { if (this._tmp_currentPatternNameToAdd.Trim() != "" && this._tmp_currentPatternValueState == "valid") {
ImGui.TableNextColumn(); ImGui.TableNextColumn();
if(ImGui.Button("Save")) { if (ImGui.Button("Save")) {
Pattern newPattern = new(this._tmp_currentPatternNameToAdd, this._tmp_currentPatternValueToAdd); Pattern newPattern = new(this._tmp_currentPatternNameToAdd, this._tmp_currentPatternValueToAdd);
this.Patterns.AddCustomPattern(newPattern); this.Patterns.AddCustomPattern(newPattern);
this.ConfigurationProfile.PatternList = this.Patterns.GetCustomPatterns(); this.ConfigurationProfile.PatternList = this.Patterns.GetCustomPatterns();
@ -1028,7 +1024,7 @@ namespace FFXIV_Vibe_Plugin {
} }
ImGui.TableNextRow(); ImGui.TableNextRow();
if(this._tmp_currentPatternValueState == "unvalid") { if (this._tmp_currentPatternValueState == "unvalid") {
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.TextColored(ImGuiColors.DalamudRed, "WRONG FORMAT!"); ImGui.TextColored(ImGuiColors.DalamudRed, "WRONG FORMAT!");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
@ -1044,7 +1040,7 @@ namespace FFXIV_Vibe_Plugin {
ImGui.Separator(); ImGui.Separator();
if(customPatterns.Count == 0) { if (customPatterns.Count == 0) {
ImGui.Text("No custom patterns, please add some"); ImGui.Text("No custom patterns, please add some");
} else { } else {
ImGui.TextColored(ImGuiColors.DalamudViolet, "Custom Patterns:"); ImGui.TextColored(ImGuiColors.DalamudViolet, "Custom Patterns:");
@ -1064,31 +1060,31 @@ namespace FFXIV_Vibe_Plugin {
ImGui.TableNextRow(); ImGui.TableNextRow();
for(int patternIndex = 0; patternIndex < customPatterns.Count; patternIndex++) { for (int patternIndex = 0; patternIndex < customPatterns.Count; patternIndex++) {
Pattern pattern = customPatterns[patternIndex]; Pattern pattern = customPatterns[patternIndex];
if(!Helpers.RegExpMatch(this.Logger, pattern.Name, this.CURRENT_PATTERN_SEARCHBAR)) { if (!Helpers.RegExpMatch(this.Logger, pattern.Name, this.CURRENT_PATTERN_SEARCHBAR)) {
continue; continue;
} }
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.Text($"{pattern.Name}"); ImGui.Text($"{pattern.Name}");
if(ImGui.IsItemHovered()) { if (ImGui.IsItemHovered()) {
ImGui.SetTooltip($"{pattern.Name}"); ImGui.SetTooltip($"{pattern.Name}");
} }
ImGui.TableNextColumn(); ImGui.TableNextColumn();
string valueShort = pattern.Value; string valueShort = pattern.Value;
if(valueShort.Length > 70) { if (valueShort.Length > 70) {
valueShort = $"{valueShort[..70]}..."; valueShort = $"{valueShort[..70]}...";
} }
ImGui.Text(valueShort); ImGui.Text(valueShort);
if(ImGui.IsItemHovered()) { if (ImGui.IsItemHovered()) {
ImGui.SetTooltip($"{pattern.Value}"); ImGui.SetTooltip($"{pattern.Value}");
} }
ImGui.TableNextColumn(); ImGui.TableNextColumn();
if(ImGuiComponents.IconButton(patternIndex, Dalamud.Interface.FontAwesomeIcon.Trash)) { if (ImGuiComponents.IconButton(patternIndex, Dalamud.Interface.FontAwesomeIcon.Trash)) {
bool ok = this.Patterns.RemoveCustomPattern(pattern); bool ok = this.Patterns.RemoveCustomPattern(pattern);
if(!ok) { if (!ok) {
this.Logger.Error($"Could not remove pattern {pattern.Name}"); this.Logger.Error($"Could not remove pattern {pattern.Name}");
} else { } else {
List<Pattern> newPatternList = this.Patterns.GetCustomPatterns(); List<Pattern> newPatternList = this.Patterns.GetCustomPatterns();
@ -1097,7 +1093,7 @@ namespace FFXIV_Vibe_Plugin {
} }
} }
ImGui.SameLine(); ImGui.SameLine();
if(ImGuiComponents.IconButton(patternIndex, Dalamud.Interface.FontAwesomeIcon.Pen)) { if (ImGuiComponents.IconButton(patternIndex, Dalamud.Interface.FontAwesomeIcon.Pen)) {
this._tmp_currentPatternNameToAdd = pattern.Name; this._tmp_currentPatternNameToAdd = pattern.Name;
this._tmp_currentPatternValueToAdd = pattern.Value; this._tmp_currentPatternValueToAdd = pattern.Value;
this._tmp_currentPatternValueState = "valid"; this._tmp_currentPatternValueState = "valid";

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<Authors></Authors> <Authors>KacieXX</Authors>
<Company></Company> <Company>Karsian</Company>
<Version>0.0.0.1</Version> <Version>1.7.0.1</Version>
<Description>A sample plugin.</Description> <Description>A plugin to help you vibe your controller or toys</Description>
<Copyright></Copyright> <Copyright>kacieXX 2023</Copyright>
<PackageProjectUrl>https://github.com/goatcorp/SamplePlugin</PackageProjectUrl> <PackageProjectUrl>https://github.com/kaciexx/FFXIV_Vibe_Plugin</PackageProjectUrl>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
@ -21,9 +21,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Content Include="..\Data\logo.png"> <Content Include="..\images\icon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible> <Visible>true</Visible>
</Content> </Content>
</ItemGroup> </ItemGroup>

View File

@ -7,7 +7,6 @@ using Dalamud.Game.Network;
using Dalamud.Interface.Windowing; using Dalamud.Interface.Windowing;
using Dalamud.IoC; using Dalamud.IoC;
using Dalamud.Plugin; using Dalamud.Plugin;
using FFXIV_Vibe_Plugin.Windows;
using System.IO; using System.IO;
namespace FFXIV_Vibe_Plugin { namespace FFXIV_Vibe_Plugin {
@ -44,13 +43,6 @@ namespace FFXIV_Vibe_Plugin {
this.Configuration = this.PluginInterface.GetPluginConfig() as Configuration ?? new Configuration(); this.Configuration = this.PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
this.Configuration.Initialize(this.PluginInterface); this.Configuration.Initialize(this.PluginInterface);
// you might normally want to embed resources and load them from the manifest stream
var imagePath = Path.Combine(PluginInterface.AssemblyLocation.Directory?.FullName!, "logo.png");
var logoImage = this.PluginInterface.UiBuilder.LoadImage(imagePath);
WindowSystem.AddWindow(new ConfigWindow(this));
WindowSystem.AddWindow(new MainWindow(this, logoImage));
this.CommandManager.AddHandler(CommandName, new CommandInfo(OnCommand) { this.CommandManager.AddHandler(CommandName, new CommandInfo(OnCommand) {
HelpMessage = "A vibe plugin for fun..." HelpMessage = "A vibe plugin for fun..."
}); });
@ -59,7 +51,10 @@ namespace FFXIV_Vibe_Plugin {
this.PluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI; this.PluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI;
// Init our own app // Init our own app
this.app = new FFXIV_Vibe_Plugin.App(CommandName, ShortName, gameNetwork, clientState, dataManager, DalamudChat, Configuration, scanner, gameObjects, pluginInterface); this.app = new FFXIV_Vibe_Plugin.App(this, CommandName, ShortName, gameNetwork, clientState, dataManager, DalamudChat, Configuration, scanner, gameObjects, pluginInterface);
// Setting the windows
WindowSystem.AddWindow(this.app.PluginUi);
} }
public void Dispose() { public void Dispose() {
@ -70,18 +65,15 @@ namespace FFXIV_Vibe_Plugin {
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
WindowSystem.GetWindow("My Amazing Window").IsOpen = true;
this.app.OnCommand(command, args); this.app.OnCommand(command, args);
} }
private void DrawUI() { private void DrawUI() {
this.WindowSystem.Draw(); this.WindowSystem.Draw();
this.app.DrawUI();
} }
public void DrawConfigUI() { public void DrawConfigUI() {
WindowSystem.GetWindow("A Wonderful Configuration Window").IsOpen = true; WindowSystem.GetWindow("FFXIV_Vibe_Plugin_UI").IsOpen = true;
} }
} }
} }

View File

@ -1,32 +0,0 @@
using System;
using System.Numerics;
using Dalamud.Interface.Windowing;
using ImGuiNET;
namespace FFXIV_Vibe_Plugin.Windows;
public class ConfigWindow : Window, IDisposable {
private Configuration Configuration;
public ConfigWindow(Plugin plugin) : base(
"A Wonderful Configuration Window",
ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar |
ImGuiWindowFlags.NoScrollWithMouse) {
this.Size = new Vector2(232, 75);
this.SizeCondition = ImGuiCond.Always;
this.Configuration = plugin.Configuration;
}
public void Dispose() { }
public override void Draw() {
// 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();
}*/
}
}

View File

@ -1,42 +0,0 @@
using System;
using System.Numerics;
using Dalamud.Interface.Windowing;
using ImGuiNET;
using ImGuiScene;
namespace FFXIV_Vibe_Plugin.Windows;
public class MainWindow : Window, IDisposable {
private TextureWrap GoatImage;
private Plugin Plugin;
public MainWindow(Plugin plugin, TextureWrap goatImage) : base(
"My Amazing Window", ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse) {
this.SizeConstraints = new WindowSizeConstraints {
MinimumSize = new Vector2(375, 330),
MaximumSize = new Vector2(float.MaxValue, float.MaxValue)
};
this.GoatImage = goatImage;
this.Plugin = plugin;
}
public void Dispose() {
this.GoatImage.Dispose();
}
public override void Draw() {
/*ImGui.Text($"The random config bool is {this.Plugin.Configuration.SomePropertyToBeSavedAndWithADefault}");*/
if (ImGui.Button("Show Settings")) {
this.Plugin.DrawConfigUI();
}
ImGui.Spacing();
ImGui.Text("Have a goat:");
ImGui.Indent(55);
ImGui.Image(this.GoatImage.ImGuiHandle, new Vector2(this.GoatImage.Width, this.GoatImage.Height));
ImGui.Unindent(55);
}
}

View File

@ -3,7 +3,7 @@
<img src="https://img.shields.io/github/downloads/kaciexx/FFXIV_Vibe_Plugin/total?label=Downloads" /> <img src="https://img.shields.io/discord/914941648859963503"/> <img src="https://img.shields.io/github/last-commit/kaciexx/FFXIV_Vibe_Plugin" /> <img src="https://img.shields.io/github/downloads/kaciexx/FFXIV_Vibe_Plugin/total?label=Downloads" /> <img src="https://img.shields.io/discord/914941648859963503"/> <img src="https://img.shields.io/github/last-commit/kaciexx/FFXIV_Vibe_Plugin" />
<p align="center"> <p align="center">
<img width="200" height="200" src="./Data/logo.png" /> <img width="200" height="200" src="./images/icon.png" />
</p> </p>
A plugin for FFXIV that will let you vibe your controller or toys. A plugin for FFXIV that will let you vibe your controller or toys.

View File

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

View File

@ -13,7 +13,7 @@
"wave" "wave"
], ],
"DalamudApiLevel": 7, "DalamudApiLevel": 7,
"IconUrl": "https://github.com/kaciexx/FFXIV_Vibe_Plugin/raw/master/Data/logo.png", "IconUrl": "https://github.com/kaciexx/FFXIV_Vibe_Plugin/raw/master/images/logo.png",
"IsHide": "False", "IsHide": "False",
"IsTestingExclusive": "False", "IsTestingExclusive": "False",
"LastUpdated": 1662225133, "LastUpdated": 1662225133,