1
0
Fork 0

fix: final work

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

View File

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

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

View File

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

View File

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

View File

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

View File

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

View File

@ -1,19 +1,26 @@
using Dalamud.Game.Text;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Components;
using Dalamud.Plugin;
using FFXIV_Vibe_Plugin.Commons;
using ImGuiNET;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
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 {
class PluginUI : IDisposable {
public class PluginUI : Window, IDisposable {
private int frameCounter = 0;
@ -33,15 +40,9 @@ namespace FFXIV_Vibe_Plugin {
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 readonly int WIDTH = 700;
private readonly int HEIGHT = 800;
private readonly int HEIGHT = 600;
private readonly int COLUMN0_WIDTH = 130;
private string _tmp_void = "";
@ -75,6 +76,8 @@ namespace FFXIV_Vibe_Plugin {
private string triggersViewMode = "default"; // default|edit|delete;
/** Constructor */
public PluginUI(
App currentPlugin,
Logger logger,
@ -84,7 +87,16 @@ namespace FFXIV_Vibe_Plugin {
Device.DevicesController deviceController,
Triggers.TriggersController triggersController,
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.Configuration = configuration;
this.ConfigurationProfile = profile;
@ -96,22 +108,17 @@ namespace FFXIV_Vibe_Plugin {
this.LoadImages();
}
public void Display() {
this.Visible = true;
this._expandedOnce = false;
}
/**
* Function that will load all the images so that they are usable.
* Don't forget to add the image into the project file.
*/
private void LoadImages() {
List<string> images = new();
images.Add("logo.png");
images.Add("icon.png");
string assemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location;
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));
}
}
@ -127,7 +134,7 @@ namespace FFXIV_Vibe_Plugin {
this.ConfigurationProfile = profile;
}
public void Draw() {
public override void Draw() {
// This is our only draw handler attached to UIBuilder, so it needs to be
// able to draw any windows we might have open.
// Each method checks its own visibility/state to ensure it only draws when
@ -140,21 +147,15 @@ namespace FFXIV_Vibe_Plugin {
}
public void DrawMainWindow() {
if(!Visible) {
return;
}
if (!this._expandedOnce) {
ImGui.SetNextWindowCollapsed(false);
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();
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
ImGui.Columns(1);
@ -189,9 +190,6 @@ namespace FFXIV_Vibe_Plugin {
}
}
ImGui.End();
}
public void DrawOptionsTab() {
ImGui.TextColored(ImGuiColors.DalamudViolet, "Profile settings");
float CONFIG_PROFILE_ZONE_HEIGHT = this._tmp_currentProfile_ErrorMsg == "" ? 100f : 120f;
@ -723,8 +721,7 @@ namespace FFXIV_Vibe_Plugin {
this.SelectedTrigger.ActionEffectType == (int)Structures.ActionEffectType.Damage ||
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
string type = "";
if (this.SelectedTrigger.ActionEffectType == (int)Structures.ActionEffectType.Damage) { type = "damage"; }
@ -766,8 +763,7 @@ namespace FFXIV_Vibe_Plugin {
if (ImGui.SliderInt("###TRIGGER_FORM_MAX_AMOUNT", ref this.SelectedTrigger.AmountMaxValue, 0, 100)) {
this.Configuration.Save();
}
}
else {
} else {
if (ImGui.InputInt("###TRIGGER_FORM_MAX_AMOUNT", ref this.SelectedTrigger.AmountMaxValue, 100)) {
this.Configuration.Save();
}

View File

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

View File

@ -7,7 +7,6 @@ using Dalamud.Game.Network;
using Dalamud.Interface.Windowing;
using Dalamud.IoC;
using Dalamud.Plugin;
using FFXIV_Vibe_Plugin.Windows;
using System.IO;
namespace FFXIV_Vibe_Plugin {
@ -44,13 +43,6 @@ namespace FFXIV_Vibe_Plugin {
this.Configuration = this.PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
this.Configuration.Initialize(this.PluginInterface);
// you might normally want to embed resources and load them from the manifest stream
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) {
HelpMessage = "A vibe plugin for fun..."
});
@ -59,7 +51,10 @@ namespace FFXIV_Vibe_Plugin {
this.PluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI;
// 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() {
@ -70,18 +65,15 @@ namespace FFXIV_Vibe_Plugin {
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);
}
private void DrawUI() {
this.WindowSystem.Draw();
this.app.DrawUI();
}
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" />
<p align="center">
<img width="200" height="200" src="./Data/logo.png" />
<img width="200" height="200" src="./images/icon.png" />
</p>
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"
],
"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",
"IsTestingExclusive": "False",
"LastUpdated": 1662225133,