From 8df7bfebef02105637f7d98272c9efba450ba065 Mon Sep 17 00:00:00 2001 From: Kane Valentine Date: Sat, 4 Nov 2023 22:04:00 +0000 Subject: [PATCH] meta: fix EC --- .gitmodules | 2 +- ECommons | 1 + ECommons/.gitattributes | 63 - ECommons/.github/FUNDING.yml | 3 - ECommons/.gitignore | 363 ------ ECommons/ECommons.sln | 25 - .../Automation/AutoCutsceneSkipper.cs | 92 -- ECommons/ECommons/Automation/Callback.cs | 212 ---- ECommons/ECommons/Automation/Chat.cs | 178 --- ECommons/ECommons/Automation/Macro.cs | 38 - ECommons/ECommons/Automation/MacroManager.cs | 52 - ECommons/ECommons/Automation/TaskManager.cs | 306 ----- .../ECommons/Automation/TaskManagerTask.cs | 25 - ECommons/ECommons/Automation/UTF8String.cs | 53 - .../ECommons/Automation/WindowsKeypress.cs | 61 - ECommons/ECommons/ChatMethods/ChatPrinter.cs | 26 - ECommons/ECommons/ChatMethods/Sender.cs | 72 -- ECommons/ECommons/ChatMethods/UIColor.cs | 149 --- .../ECommons/CircularBuffers/CircularArray.cs | 66 - .../CircularBuffers/CircularBuffer.cs | 417 ------ ECommons/ECommons/Commands/CmdAttribute.cs | 28 - ECommons/ECommons/Commands/CmdManager.cs | 121 -- ECommons/ECommons/Commands/SubCmdAttribute.cs | 17 - ECommons/ECommons/Configuration/EzConfig.cs | 89 -- ECommons/ECommons/Configuration/IEzConfig.cs | 5 - .../IgnoreDefaultValueAttribute.cs | 14 - ECommons/ECommons/Constants.cs | 39 - .../DalamudServices/Legacy/LegacyHelpers.cs | 22 - .../DalamudServices/Legacy/SignatureHelper.cs | 16 - ECommons/ECommons/DalamudServices/Svc.cs | 81 -- ECommons/ECommons/ECommons.csproj | 100 -- ECommons/ECommons/ECommonsMain.cs | 102 -- ECommons/ECommons/Events/ProperOnLogin.cs | 87 -- ECommons/ECommons/ExcelResolver.cs | 84 -- .../ExcelServices/ExcelActionHelper.cs | 13 - .../ECommons/ExcelServices/ExcelJobHelper.cs | 38 - .../ExcelServices/ExcelTerritoryHelper.cs | 76 -- .../ExcelServices/ExcelWorldHelper.cs | 55 - ECommons/ECommons/ExcelServices/Job.cs | 212 ---- ECommons/ECommons/ExcelServices/Region.cs | 9 - .../TerritoryEnumeration/AllianceRaids.cs | 42 - .../TerritoryEnumeration/Dungeons.cs | 134 -- .../TerritoryEnumeration/Houses.cs | 64 - .../TerritoryEnumeration/Inns.cs | 36 - .../TerritoryEnumeration/MainCities.cs | 47 - .../TerritoryEnumeration/OpenAreas.cs | 73 -- .../TerritoryEnumeration/Prisons.cs | 30 - .../TerritoryEnumeration/Raids.cs | 141 --- .../TerritoryEnumeration/ResidentalAreas.cs | 34 - .../TerritoryEnumeration/Trials.cs | 111 -- .../TerritoryEnumeration/VariantDungeons.cs | 30 - .../ExcelServices/TerritoryIntendedUse.cs | 27 - ECommons/ECommons/EzCmd.cs | 29 - .../GameFunctions/CharacterFunctions.cs | 76 -- ECommons/ECommons/GameFunctions/CombatRole.cs | 6 - ECommons/ECommons/GameFunctions/FakeParty.cs | 33 - .../ECommons/GameFunctions/FakePronoun.cs | 81 -- .../ECommons/GameFunctions/ObjectFunctions.cs | 102 -- .../ECommons/GameFunctions/PlayerFunctions.cs | 41 - ECommons/ECommons/GameHelpers/Player.cs | 32 - ECommons/ECommons/Gamepad/GamePad.cs | 60 - ECommons/ECommons/GenericHelpers.cs | 1027 --------------- ECommons/ECommons/Hooks/ActionEffect.cs | 128 -- .../ActionEffectTypes/ActionEffectSet.cs | 113 -- .../ActionEffectTypes/ActionEffectType.cs | 59 - .../Hooks/ActionEffectTypes/AttackType.cs | 16 - .../Hooks/ActionEffectTypes/EffectEntry.cs | 25 - .../Hooks/ActionEffectTypes/EffectHeader.cs | 21 - .../Hooks/ActionEffectTypes/TargetEffect.cs | 64 - ECommons/ECommons/Hooks/DirectorUpdate.cs | 108 -- .../ECommons/Hooks/DirectorUpdateCategory.cs | 16 - ECommons/ECommons/Hooks/MapEffect.cs | 73 -- ECommons/ECommons/Hooks/SendAction.cs | 74 -- ECommons/ECommons/ImGuiMethods/Box.cs | 11 - ECommons/ECommons/ImGuiMethods/CImGui.cs | 24 - .../ECommons/ImGuiMethods/ChangelogWindow.cs | 74 -- ECommons/ECommons/ImGuiMethods/Donation.cs | 34 - ECommons/ECommons/ImGuiMethods/EColor.cs | 38 - .../ECommons/ImGuiMethods/GradientColor.cs | 22 - ECommons/ECommons/ImGuiMethods/ImGuiBB.cs | 95 -- .../ECommons/ImGuiMethods/ImGuiDragDrop.cs | 47 - ECommons/ECommons/ImGuiMethods/ImGuiEx.cs | 1115 ----------------- ECommons/ECommons/ImGuiMethods/ImGuiNoRef.cs | 23 - ECommons/ECommons/ImGuiMethods/ImGuiTrans.cs | 50 - .../ImGuiMethods/ImageLoadingResult.cs | 10 - ECommons/ECommons/ImGuiMethods/KoFiButton.cs | 69 - .../ImGuiMethods/MiddleOverlayWindow.cs | 70 -- ECommons/ECommons/ImGuiMethods/Notify.cs | 49 - ECommons/ECommons/ImGuiMethods/PopupWindow.cs | 32 - .../ImGuiMethods/ThreadLoadImageHandler.cs | 153 --- .../ImGuiMethods/TimedMiddleOverlayWindow.cs | 21 - ECommons/ECommons/Interop/LimitedKeys.cs | 692 ---------- ECommons/ECommons/Interop/OpenFileDialog.cs | 91 -- ECommons/ECommons/Interop/OpenFileName.cs | 78 -- ECommons/ECommons/Interop/WindowFunctions.cs | 59 - .../ECommons/LanguageHelpers/Localization.cs | 110 -- .../LanguageHelpers/LocalizationExtensions.cs | 36 - ECommons/ECommons/Loader/ILoadable.cs | 13 - ECommons/ECommons/Loader/MicroServices.cs | 42 - ECommons/ECommons/Loader/PluginLoader.cs | 194 --- ECommons/ECommons/Logging/DuoLog.cs | 87 -- ECommons/ECommons/Logging/InternalLog.cs | 104 -- .../ECommons/Logging/InternalLogMessage.cs | 15 - ECommons/ECommons/Logging/PluginLog.cs | 86 -- ECommons/ECommons/MathHelpers/Bitmask.cs | 29 - .../ECommons/MathHelpers/CardinalDirection.cs | 9 - ECommons/ECommons/MathHelpers/Endianness.cs | 19 - ECommons/ECommons/MathHelpers/MathHelper.cs | 133 -- ECommons/ECommons/Module.cs | 6 - ECommons/ECommons/Numeric/Int2.cs | 31 - .../ECommons/ObjectLifeTracker/ObjectLife.cs | 88 -- ECommons/ECommons/Opcodes/OpcodeUpdater.cs | 76 -- .../ECommons/PartyFunctions/UniversalParty.cs | 58 - .../PartyFunctions/UniversalPartyMember.cs | 31 - ECommons/ECommons/PointerHelpers.cs | 11 - .../ECommons/Reflection/DalamudReflector.cs | 191 --- .../ECommons/Reflection/ReflectionHelper.cs | 79 -- .../Schedulers/ExecuteForScheduler.cs | 44 - ECommons/ECommons/Schedulers/IScheduler.cs | 7 - ECommons/ECommons/Schedulers/TickScheduler.cs | 42 - ECommons/ECommons/SimpleGui/ConfigWindow.cs | 43 - ECommons/ECommons/SimpleGui/EzConfigGui.cs | 45 - ECommons/ECommons/SimpleLogger.cs | 73 -- ECommons/ECommons/SplatoonAPI/Element.cs | 490 -------- ECommons/ECommons/SplatoonAPI/ElementType.cs | 19 - .../SplatoonAPI/RefActorComparisonType.cs | 23 - ECommons/ECommons/SplatoonAPI/RefActorType.cs | 11 - ECommons/ECommons/SplatoonAPI/Splatoon.cs | 309 ----- .../ECommons/StringHelpers/EqualStrings.cs | 65 - ECommons/ECommons/TerritoryName.cs | 41 - ECommons/ECommons/Throttlers/EzThrottler.cs | 26 - .../ECommons/Throttlers/EzThrottler{T}.cs | 62 - .../ECommons/Throttlers/FrameThrottler.cs | 26 - .../ECommons/Throttlers/FrameThrottler{T}.cs | 66 - ECommons/ECommons/UIHelpers/AtkReader.cs | 112 -- .../Implementations/ReaderRetainerList.cs | 24 - .../Implementations/ReaderSelectString.cs | 21 - ECommons/ECommons/packages.lock.json | 6 - ECommons/LICENSE.md | 661 ---------- ECommons/README.md | 45 - 140 files changed, 2 insertions(+), 12929 deletions(-) create mode 160000 ECommons delete mode 100644 ECommons/.gitattributes delete mode 100644 ECommons/.github/FUNDING.yml delete mode 100644 ECommons/.gitignore delete mode 100644 ECommons/ECommons.sln delete mode 100644 ECommons/ECommons/Automation/AutoCutsceneSkipper.cs delete mode 100644 ECommons/ECommons/Automation/Callback.cs delete mode 100644 ECommons/ECommons/Automation/Chat.cs delete mode 100644 ECommons/ECommons/Automation/Macro.cs delete mode 100644 ECommons/ECommons/Automation/MacroManager.cs delete mode 100644 ECommons/ECommons/Automation/TaskManager.cs delete mode 100644 ECommons/ECommons/Automation/TaskManagerTask.cs delete mode 100644 ECommons/ECommons/Automation/UTF8String.cs delete mode 100644 ECommons/ECommons/Automation/WindowsKeypress.cs delete mode 100644 ECommons/ECommons/ChatMethods/ChatPrinter.cs delete mode 100644 ECommons/ECommons/ChatMethods/Sender.cs delete mode 100644 ECommons/ECommons/ChatMethods/UIColor.cs delete mode 100644 ECommons/ECommons/CircularBuffers/CircularArray.cs delete mode 100644 ECommons/ECommons/CircularBuffers/CircularBuffer.cs delete mode 100644 ECommons/ECommons/Commands/CmdAttribute.cs delete mode 100644 ECommons/ECommons/Commands/CmdManager.cs delete mode 100644 ECommons/ECommons/Commands/SubCmdAttribute.cs delete mode 100644 ECommons/ECommons/Configuration/EzConfig.cs delete mode 100644 ECommons/ECommons/Configuration/IEzConfig.cs delete mode 100644 ECommons/ECommons/Configuration/IgnoreDefaultValueAttribute.cs delete mode 100644 ECommons/ECommons/Constants.cs delete mode 100644 ECommons/ECommons/DalamudServices/Legacy/LegacyHelpers.cs delete mode 100644 ECommons/ECommons/DalamudServices/Legacy/SignatureHelper.cs delete mode 100644 ECommons/ECommons/DalamudServices/Svc.cs delete mode 100644 ECommons/ECommons/ECommons.csproj delete mode 100644 ECommons/ECommons/ECommonsMain.cs delete mode 100644 ECommons/ECommons/Events/ProperOnLogin.cs delete mode 100644 ECommons/ECommons/ExcelResolver.cs delete mode 100644 ECommons/ECommons/ExcelServices/ExcelActionHelper.cs delete mode 100644 ECommons/ECommons/ExcelServices/ExcelJobHelper.cs delete mode 100644 ECommons/ECommons/ExcelServices/ExcelTerritoryHelper.cs delete mode 100644 ECommons/ECommons/ExcelServices/ExcelWorldHelper.cs delete mode 100644 ECommons/ECommons/ExcelServices/Job.cs delete mode 100644 ECommons/ECommons/ExcelServices/Region.cs delete mode 100644 ECommons/ECommons/ExcelServices/TerritoryEnumeration/AllianceRaids.cs delete mode 100644 ECommons/ECommons/ExcelServices/TerritoryEnumeration/Dungeons.cs delete mode 100644 ECommons/ECommons/ExcelServices/TerritoryEnumeration/Houses.cs delete mode 100644 ECommons/ECommons/ExcelServices/TerritoryEnumeration/Inns.cs delete mode 100644 ECommons/ECommons/ExcelServices/TerritoryEnumeration/MainCities.cs delete mode 100644 ECommons/ECommons/ExcelServices/TerritoryEnumeration/OpenAreas.cs delete mode 100644 ECommons/ECommons/ExcelServices/TerritoryEnumeration/Prisons.cs delete mode 100644 ECommons/ECommons/ExcelServices/TerritoryEnumeration/Raids.cs delete mode 100644 ECommons/ECommons/ExcelServices/TerritoryEnumeration/ResidentalAreas.cs delete mode 100644 ECommons/ECommons/ExcelServices/TerritoryEnumeration/Trials.cs delete mode 100644 ECommons/ECommons/ExcelServices/TerritoryEnumeration/VariantDungeons.cs delete mode 100644 ECommons/ECommons/ExcelServices/TerritoryIntendedUse.cs delete mode 100644 ECommons/ECommons/EzCmd.cs delete mode 100644 ECommons/ECommons/GameFunctions/CharacterFunctions.cs delete mode 100644 ECommons/ECommons/GameFunctions/CombatRole.cs delete mode 100644 ECommons/ECommons/GameFunctions/FakeParty.cs delete mode 100644 ECommons/ECommons/GameFunctions/FakePronoun.cs delete mode 100644 ECommons/ECommons/GameFunctions/ObjectFunctions.cs delete mode 100644 ECommons/ECommons/GameFunctions/PlayerFunctions.cs delete mode 100644 ECommons/ECommons/GameHelpers/Player.cs delete mode 100644 ECommons/ECommons/Gamepad/GamePad.cs delete mode 100644 ECommons/ECommons/GenericHelpers.cs delete mode 100644 ECommons/ECommons/Hooks/ActionEffect.cs delete mode 100644 ECommons/ECommons/Hooks/ActionEffectTypes/ActionEffectSet.cs delete mode 100644 ECommons/ECommons/Hooks/ActionEffectTypes/ActionEffectType.cs delete mode 100644 ECommons/ECommons/Hooks/ActionEffectTypes/AttackType.cs delete mode 100644 ECommons/ECommons/Hooks/ActionEffectTypes/EffectEntry.cs delete mode 100644 ECommons/ECommons/Hooks/ActionEffectTypes/EffectHeader.cs delete mode 100644 ECommons/ECommons/Hooks/ActionEffectTypes/TargetEffect.cs delete mode 100644 ECommons/ECommons/Hooks/DirectorUpdate.cs delete mode 100644 ECommons/ECommons/Hooks/DirectorUpdateCategory.cs delete mode 100644 ECommons/ECommons/Hooks/MapEffect.cs delete mode 100644 ECommons/ECommons/Hooks/SendAction.cs delete mode 100644 ECommons/ECommons/ImGuiMethods/Box.cs delete mode 100644 ECommons/ECommons/ImGuiMethods/CImGui.cs delete mode 100644 ECommons/ECommons/ImGuiMethods/ChangelogWindow.cs delete mode 100644 ECommons/ECommons/ImGuiMethods/Donation.cs delete mode 100644 ECommons/ECommons/ImGuiMethods/EColor.cs delete mode 100644 ECommons/ECommons/ImGuiMethods/GradientColor.cs delete mode 100644 ECommons/ECommons/ImGuiMethods/ImGuiBB.cs delete mode 100644 ECommons/ECommons/ImGuiMethods/ImGuiDragDrop.cs delete mode 100644 ECommons/ECommons/ImGuiMethods/ImGuiEx.cs delete mode 100644 ECommons/ECommons/ImGuiMethods/ImGuiNoRef.cs delete mode 100644 ECommons/ECommons/ImGuiMethods/ImGuiTrans.cs delete mode 100644 ECommons/ECommons/ImGuiMethods/ImageLoadingResult.cs delete mode 100644 ECommons/ECommons/ImGuiMethods/KoFiButton.cs delete mode 100644 ECommons/ECommons/ImGuiMethods/MiddleOverlayWindow.cs delete mode 100644 ECommons/ECommons/ImGuiMethods/Notify.cs delete mode 100644 ECommons/ECommons/ImGuiMethods/PopupWindow.cs delete mode 100644 ECommons/ECommons/ImGuiMethods/ThreadLoadImageHandler.cs delete mode 100644 ECommons/ECommons/ImGuiMethods/TimedMiddleOverlayWindow.cs delete mode 100644 ECommons/ECommons/Interop/LimitedKeys.cs delete mode 100644 ECommons/ECommons/Interop/OpenFileDialog.cs delete mode 100644 ECommons/ECommons/Interop/OpenFileName.cs delete mode 100644 ECommons/ECommons/Interop/WindowFunctions.cs delete mode 100644 ECommons/ECommons/LanguageHelpers/Localization.cs delete mode 100644 ECommons/ECommons/LanguageHelpers/LocalizationExtensions.cs delete mode 100644 ECommons/ECommons/Loader/ILoadable.cs delete mode 100644 ECommons/ECommons/Loader/MicroServices.cs delete mode 100644 ECommons/ECommons/Loader/PluginLoader.cs delete mode 100644 ECommons/ECommons/Logging/DuoLog.cs delete mode 100644 ECommons/ECommons/Logging/InternalLog.cs delete mode 100644 ECommons/ECommons/Logging/InternalLogMessage.cs delete mode 100644 ECommons/ECommons/Logging/PluginLog.cs delete mode 100644 ECommons/ECommons/MathHelpers/Bitmask.cs delete mode 100644 ECommons/ECommons/MathHelpers/CardinalDirection.cs delete mode 100644 ECommons/ECommons/MathHelpers/Endianness.cs delete mode 100644 ECommons/ECommons/MathHelpers/MathHelper.cs delete mode 100644 ECommons/ECommons/Module.cs delete mode 100644 ECommons/ECommons/Numeric/Int2.cs delete mode 100644 ECommons/ECommons/ObjectLifeTracker/ObjectLife.cs delete mode 100644 ECommons/ECommons/Opcodes/OpcodeUpdater.cs delete mode 100644 ECommons/ECommons/PartyFunctions/UniversalParty.cs delete mode 100644 ECommons/ECommons/PartyFunctions/UniversalPartyMember.cs delete mode 100644 ECommons/ECommons/PointerHelpers.cs delete mode 100644 ECommons/ECommons/Reflection/DalamudReflector.cs delete mode 100644 ECommons/ECommons/Reflection/ReflectionHelper.cs delete mode 100644 ECommons/ECommons/Schedulers/ExecuteForScheduler.cs delete mode 100644 ECommons/ECommons/Schedulers/IScheduler.cs delete mode 100644 ECommons/ECommons/Schedulers/TickScheduler.cs delete mode 100644 ECommons/ECommons/SimpleGui/ConfigWindow.cs delete mode 100644 ECommons/ECommons/SimpleGui/EzConfigGui.cs delete mode 100644 ECommons/ECommons/SimpleLogger.cs delete mode 100644 ECommons/ECommons/SplatoonAPI/Element.cs delete mode 100644 ECommons/ECommons/SplatoonAPI/ElementType.cs delete mode 100644 ECommons/ECommons/SplatoonAPI/RefActorComparisonType.cs delete mode 100644 ECommons/ECommons/SplatoonAPI/RefActorType.cs delete mode 100644 ECommons/ECommons/SplatoonAPI/Splatoon.cs delete mode 100644 ECommons/ECommons/StringHelpers/EqualStrings.cs delete mode 100644 ECommons/ECommons/TerritoryName.cs delete mode 100644 ECommons/ECommons/Throttlers/EzThrottler.cs delete mode 100644 ECommons/ECommons/Throttlers/EzThrottler{T}.cs delete mode 100644 ECommons/ECommons/Throttlers/FrameThrottler.cs delete mode 100644 ECommons/ECommons/Throttlers/FrameThrottler{T}.cs delete mode 100644 ECommons/ECommons/UIHelpers/AtkReader.cs delete mode 100644 ECommons/ECommons/UIHelpers/Implementations/ReaderRetainerList.cs delete mode 100644 ECommons/ECommons/UIHelpers/Implementations/ReaderSelectString.cs delete mode 100644 ECommons/ECommons/packages.lock.json delete mode 100644 ECommons/LICENSE.md delete mode 100644 ECommons/README.md diff --git a/.gitmodules b/.gitmodules index 6f57d42..e21a5bb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,4 @@ url = https://github.com/Limiana/ClickLib.git [submodule "ECommons"] path = ECommons - url = https://github.com/NightmareXIV/ECommons.git + url = https://github.com/NightmareXIV/ECommons diff --git a/ECommons b/ECommons new file mode 160000 index 0000000..d4e6477 --- /dev/null +++ b/ECommons @@ -0,0 +1 @@ +Subproject commit d4e6477c7ff6d66eb13b506915d8aae65df6dffb diff --git a/ECommons/.gitattributes b/ECommons/.gitattributes deleted file mode 100644 index 1ff0c42..0000000 --- a/ECommons/.gitattributes +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto - -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain diff --git a/ECommons/.github/FUNDING.yml b/ECommons/.github/FUNDING.yml deleted file mode 100644 index 0d918c0..0000000 --- a/ECommons/.github/FUNDING.yml +++ /dev/null @@ -1,3 +0,0 @@ -# These are supported funding model platforms - -ko_fi: nightmarexiv diff --git a/ECommons/.gitignore b/ECommons/.gitignore deleted file mode 100644 index 9491a2f..0000000 --- a/ECommons/.gitignore +++ /dev/null @@ -1,363 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Mono auto generated files -mono_crash.* - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Ww][Ii][Nn]32/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Oo]ut/ -[Ll]og/ -[Ll]ogs/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUnit -*.VisualState.xml -TestResult.xml -nunit-*.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# ASP.NET Scaffolding -ScaffoldingReadMe.txt - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Coverlet is a free, cross platform Code Coverage Tool -coverage*.json -coverage*.xml -coverage*.info - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# NuGet Symbol Packages -*.snupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx -*.appxbundle -*.appxupload - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!?*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser -*- [Bb]ackup.rdl -*- [Bb]ackup ([0-9]).rdl -*- [Bb]ackup ([0-9][0-9]).rdl - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ - -# BeatPulse healthcheck temp database -healthchecksdb - -# Backup folder for Package Reference Convert tool in Visual Studio 2017 -MigrationBackup/ - -# Ionide (cross platform F# VS Code tools) working folder -.ionide/ - -# Fody - auto-generated XML schema -FodyWeavers.xsd \ No newline at end of file diff --git a/ECommons/ECommons.sln b/ECommons/ECommons.sln deleted file mode 100644 index d4d49dd..0000000 --- a/ECommons/ECommons.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.2.32414.248 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ECommons", "ECommons\ECommons.csproj", "{96659C70-8A8B-49E6-9AB4-DAE48CB55826}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {96659C70-8A8B-49E6-9AB4-DAE48CB55826}.Debug|Any CPU.ActiveCfg = Debug|x64 - {96659C70-8A8B-49E6-9AB4-DAE48CB55826}.Debug|Any CPU.Build.0 = Debug|x64 - {96659C70-8A8B-49E6-9AB4-DAE48CB55826}.Release|Any CPU.ActiveCfg = Release|x64 - {96659C70-8A8B-49E6-9AB4-DAE48CB55826}.Release|Any CPU.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {508CD94E-4841-4EBF-B848-72965E7FF9B1} - EndGlobalSection -EndGlobal diff --git a/ECommons/ECommons/Automation/AutoCutsceneSkipper.cs b/ECommons/ECommons/Automation/AutoCutsceneSkipper.cs deleted file mode 100644 index f03f18d..0000000 --- a/ECommons/ECommons/Automation/AutoCutsceneSkipper.cs +++ /dev/null @@ -1,92 +0,0 @@ -using Dalamud.Hooking; -using Dalamud.Utility.Signatures; -using Dalamud; -using ECommons.DalamudServices; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ECommons.DalamudServices.Legacy; -using ECommons.Logging; -using System.Runtime.CompilerServices; -using System.Data.SqlTypes; - -namespace ECommons.Automation -{ - /// - /// Provides automatic cutscene skipping trigger. Does not includes cutscene skipping confirmation. - /// - public unsafe class AutoCutsceneSkipper - { - delegate void CutsceneHandleInputDelegate(nint a1); - [Signature("40 53 48 83 EC 20 80 79 29 00 48 8B D9 0F 85", DetourName = nameof(CutsceneHandleInputDetour))] - static Hook CutsceneHandleInputHook; - - static readonly string ConditionSig = "75 11 BA ?? ?? ?? ?? 48 8B CF E8 ?? ?? ?? ?? 84 C0 74 52"; - static int ConditionOriginalValuesLen => ConditionSig.Split(" ").Length; - static nint ConditionAddr; - /// - /// Condition which will be checked to determine if the cutscene should be skipped. Can be null to skip everything unconditionally. - /// - public static Func Condition; - - /// - /// Initializes cutscene skipper trigger. - /// - /// Condition which will be checked to determine if the cutscene should be skipped. Can be null to skip everything unconditionally. - /// If already initialized - public static void Init(Func cutsceneSkipCondition) - { - if (CutsceneHandleInputHook != null) throw new Exception($"{nameof(AutoCutsceneSkipper)} module is already initialized!"); - PluginLog.Information($"AutoCutsceneSkipper requested"); - Condition = cutsceneSkipCondition; - SignatureHelper.Initialise(new AutoCutsceneSkipper()); - ConditionAddr = Svc.SigScanner.ScanText(ConditionSig); - PluginLog.Information($"Found cutscene skip condition address at {ConditionAddr}"); - CutsceneHandleInputHook?.Enable(); - PluginLog.Information($"AutoCutsceneSkipper initialized"); - } - - /// - /// Disables cutscene skipper trigger. Note that you do not need to call this in Dispose of the plugin, it is disposed automatically. - /// - public static void Disable() => CutsceneHandleInputHook.Disable(); - /// - /// Enables previously disabled cutscene trigger. Note that you do not have to call this in constructor of the plugin, it is enabled automatically. - /// - public static void Enable() => CutsceneHandleInputHook.Enable(); - - internal static void Dispose() - { - CutsceneHandleInputHook?.Dispose(); - } - - internal static void CutsceneHandleInputDetour(nint a1) - { - var called = false; - try - { - if (Condition?.Invoke(a1) != false) - { - var skippable = *(nint*)(a1 + 56) != 0; - if (skippable) - { - SafeMemory.WriteBytes(ConditionAddr, [0xEB]); - CutsceneHandleInputHook.Original(a1); - called = true; - SafeMemory.WriteBytes(ConditionAddr, [0x75]); - } - } - } - catch (Exception e) - { - e.Log(); - } - if (!called) - { - CutsceneHandleInputHook.Original(a1); - } - } - } -} diff --git a/ECommons/ECommons/Automation/Callback.cs b/ECommons/ECommons/Automation/Callback.cs deleted file mode 100644 index cf6fe09..0000000 --- a/ECommons/ECommons/Automation/Callback.cs +++ /dev/null @@ -1,212 +0,0 @@ -using ECommons.Logging; -using Dalamud.Memory; -using ECommons.DalamudServices; -using FFXIVClientStructs.FFXIV.Component.GUI; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Markup; -using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType; -using Dalamud.Hooking; - -namespace ECommons.Automation -{ - public unsafe static class Callback - { - const string Sig = "E8 ?? ?? ?? ?? 8B 4C 24 20 0F B6 D8"; - internal delegate byte AtkUnitBase_FireCallbackDelegate(AtkUnitBase* Base, int valueCount, AtkValue* values, byte updateState); - internal static AtkUnitBase_FireCallbackDelegate FireCallback = null; - static Hook AtkUnitBase_FireCallbackHook; - - public static readonly AtkValue ZeroAtkValue = new() { Type = 0, Int = 0 }; - - internal static void Initialize() - { - var ptr = Svc.SigScanner.ScanText(Sig); - FireCallback = Marshal.GetDelegateForFunctionPointer(ptr); - PluginLog.Information($"Initialized Callback module, FireCallback = 0x{ptr:X16}"); - } - - public static void InstallHook() - { - if (FireCallback == null) Initialize(); - AtkUnitBase_FireCallbackHook ??= Svc.Hook.HookFromSignature(Sig, AtkUnitBase_FireCallbackDetour); - if (AtkUnitBase_FireCallbackHook.IsEnabled) - { - PluginLog.Error("AtkUnitBase_FireCallbackHook is already enabled"); - } - else - { - AtkUnitBase_FireCallbackHook.Enable(); - PluginLog.Information("AtkUnitBase_FireCallbackHook enabled"); - } - } - - public static void UninstallHook() - { - if (FireCallback == null) - { - PluginLog.Error("AtkUnitBase_FireCallbackHook not initialized yet"); - } - if (!AtkUnitBase_FireCallbackHook.IsEnabled) - { - PluginLog.Error("AtkUnitBase_FireCallbackHook is already disabled"); - } - else - { - AtkUnitBase_FireCallbackHook.Disable(); - PluginLog.Information("AtkUnitBase_FireCallbackHook disabled"); - } - } - - static byte AtkUnitBase_FireCallbackDetour(AtkUnitBase* Base, int valueCount, AtkValue* values, byte updateState) - { - var ret = AtkUnitBase_FireCallbackHook?.Original(Base, valueCount, values, updateState); - try - { - PluginLog.Debug($"Callback on {MemoryHelper.ReadStringNullTerminated((nint)Base->Name)}, valueCount={valueCount}, updateState={updateState}\n{DecodeValues(valueCount, values).Select(x => $" {x}").Join("\n")}"); - } - catch(Exception e) - { - e.Log(); - } - return ret ?? 0; - } - - public static void FireRaw(AtkUnitBase* Base, int valueCount, AtkValue* values, byte updateState = 0) - { - if (FireCallback == null) Initialize(); - FireCallback(Base, valueCount, values, updateState); - } - - public static void Fire(AtkUnitBase* Base, bool updateState, params object[] values) - { - if (Base == null) throw new Exception("Null UnitBase"); - var atkValues = (AtkValue*)Marshal.AllocHGlobal(values.Length * sizeof(AtkValue)); - if (atkValues == null) return; - try - { - for (var i = 0; i < values.Length; i++) - { - var v = values[i]; - switch (v) - { - case uint uintValue: - atkValues[i].Type = ValueType.UInt; - atkValues[i].UInt = uintValue; - break; - case int intValue: - atkValues[i].Type = ValueType.Int; - atkValues[i].Int = intValue; - break; - case float floatValue: - atkValues[i].Type = ValueType.Float; - atkValues[i].Float = floatValue; - break; - case bool boolValue: - atkValues[i].Type = ValueType.Bool; - atkValues[i].Byte = (byte)(boolValue ? 1 : 0); - break; - case string stringValue: - { - atkValues[i].Type = ValueType.String; - var stringBytes = Encoding.UTF8.GetBytes(stringValue); - var stringAlloc = Marshal.AllocHGlobal(stringBytes.Length + 1); - Marshal.Copy(stringBytes, 0, stringAlloc, stringBytes.Length); - Marshal.WriteByte(stringAlloc, stringBytes.Length, 0); - atkValues[i].String = (byte*)stringAlloc; - break; - } - case AtkValue rawValue: - { - atkValues[i] = rawValue; - break; - } - default: - throw new ArgumentException($"Unable to convert type {v.GetType()} to AtkValue"); - } - } - List CallbackValues = new(); - for(var i = 0; i < values.Length; i++) - { - CallbackValues.Add($" Value {i}: [input: {values[i]}/{values[i]?.GetType().Name}] -> {DecodeValue(atkValues[i])})"); - } - PluginLog.Verbose($"Firing callback: {MemoryHelper.ReadStringNullTerminated((nint)Base->Name)}, valueCount = {values.Length}, updateStatte = {updateState}, values:\n"); - FireRaw(Base, values.Length, atkValues, (byte)(updateState ?1:0)); - } - finally - { - for (var i = 0; i < values.Length; i++) - { - if (atkValues[i].Type == ValueType.String) - { - Marshal.FreeHGlobal(new IntPtr(atkValues[i].String)); - } - } - Marshal.FreeHGlobal(new IntPtr(atkValues)); - } - } - - public static List DecodeValues(int cnt, AtkValue* values) - { - var atkValueList = new List(); - try - { - for (var i = 0; i < cnt; i++) - { - atkValueList.Add(DecodeValue(values[i])); - } - } - catch (Exception e) - { - e.Log(); - } - return atkValueList; - } - - public static string DecodeValue(AtkValue a) - { - var str = new StringBuilder(a.Type.ToString()).Append(": "); - switch (a.Type) - { - case ValueType.Int: - { - str.Append(a.Int); - break; - } - case ValueType.String: - { - str.Append(Marshal.PtrToStringUTF8(new IntPtr(a.String))); - break; - } - case ValueType.UInt: - { - str.Append(a.UInt); - break; - } - case ValueType.Bool: - { - str.Append(a.Byte != 0); - break; - } - default: - { - str.Append($"Unknown Type: {a.Int}"); - break; - } - } - return str.ToString(); - } - - internal static void Dispose() - { - AtkUnitBase_FireCallbackHook?.Dispose(); - AtkUnitBase_FireCallbackHook = null; - FireCallback = null; - } - } -} diff --git a/ECommons/ECommons/Automation/Chat.cs b/ECommons/ECommons/Automation/Chat.cs deleted file mode 100644 index e3ab6a7..0000000 --- a/ECommons/ECommons/Automation/Chat.cs +++ /dev/null @@ -1,178 +0,0 @@ -/* -https://git.annaclemens.io/ascclemens/XivCommon/src/branch/main/XivCommon/Functions/Chat.cs -MIT License -Copyright (c) 2021 Anna Clemens -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ -using System; -using System.Runtime.InteropServices; -using System.Text; -using ECommons.DalamudServices; -using FFXIVClientStructs.FFXIV.Client.System.Memory; -using FFXIVClientStructs.FFXIV.Client.System.String; -using Framework = FFXIVClientStructs.FFXIV.Client.System.Framework.Framework; -namespace ECommons.Automation; - -/// -/// A class containing chat functionality -/// -public class Chat -{ - private static class Signatures - { - internal const string SendChat = "48 89 5C 24 ?? 57 48 83 EC 20 48 8B FA 48 8B D9 45 84 C9"; - internal const string SanitiseString = "E8 ?? ?? ?? ?? EB 0A 48 8D 4C 24 ?? E8 ?? ?? ?? ?? 48 8D 8D"; - } - private delegate void ProcessChatBoxDelegate(IntPtr uiModule, IntPtr message, IntPtr unused, byte a4); - private ProcessChatBoxDelegate ProcessChatBox { get; } - private readonly unsafe delegate* unmanaged _sanitiseString = null!; - - internal static Chat instance; - public static Chat Instance - { - get - { - instance ??= new(); - return instance; - } - } - - public Chat() - { - if (Svc.SigScanner.TryScanText(Signatures.SendChat, out var processChatBoxPtr)) - { - ProcessChatBox = Marshal.GetDelegateForFunctionPointer(processChatBoxPtr); - } - unsafe - { - if (Svc.SigScanner.TryScanText(Signatures.SanitiseString, out var sanitisePtr)) - { - _sanitiseString = (delegate* unmanaged)sanitisePtr; - } - } - } - /// - /// - /// Send a given message to the chat box. This can send chat to the server. - /// - /// - /// This method is unsafe. This method does no checking on your input and - /// may send content to the server that the normal client could not. You must - /// verify what you're sending and handle content and length to properly use - /// this. - /// - /// - /// Message to send - /// If the signature for this function could not be found - [Obsolete("Use safe message sending")] - public unsafe void SendMessageUnsafe(byte[] message) - { - if (ProcessChatBox == null) - { - throw new InvalidOperationException("Could not find signature for chat sending"); - } - var uiModule = (IntPtr)Framework.Instance()->GetUiModule(); - using var payload = new ChatPayload(message); - var mem1 = Marshal.AllocHGlobal(400); - Marshal.StructureToPtr(payload, mem1, false); - ProcessChatBox(uiModule, mem1, IntPtr.Zero, 0); - Marshal.FreeHGlobal(mem1); - } - /// - /// - /// Send a given message to the chat box. This can send chat to the server. - /// - /// - /// This method is slightly less unsafe than . It - /// will throw exceptions for certain inputs that the client can't normally send, - /// but it is still possible to make mistakes. Use with caution. - /// - /// - /// message to send - /// If is empty, longer than 500 bytes in UTF-8, or contains invalid characters. - /// If the signature for this function could not be found - public void SendMessage(string message) - { - var bytes = Encoding.UTF8.GetBytes(message); - if (bytes.Length == 0) - { - throw new ArgumentException("message is empty", nameof(message)); - } - if (bytes.Length > 500) - { - throw new ArgumentException("message is longer than 500 bytes", nameof(message)); - } - if (message.Length != SanitiseText(message).Length) - { - throw new ArgumentException("message contained invalid characters", nameof(message)); - } -#pragma warning disable CS0618 // Type or member is obsolete - SendMessageUnsafe(bytes); -#pragma warning restore CS0618 // Type or member is obsolete - } - /// - /// - /// Sanitises a string by removing any invalid input. - /// - /// - /// The result of this method is safe to use with - /// , provided that it is not empty or too - /// long. - /// - /// - /// text to sanitise - /// sanitised text - /// If the signature for this function could not be found - public unsafe string SanitiseText(string text) - { - if (_sanitiseString == null) - { - throw new InvalidOperationException("Could not find signature for chat sanitisation"); - } - var uText = Utf8String.FromString(text); - _sanitiseString(uText, 0x27F, IntPtr.Zero); - var sanitised = uText->ToString(); - uText->Dtor(); - IMemorySpace.Free(uText); - return sanitised; - } - [StructLayout(LayoutKind.Explicit)] - private readonly struct ChatPayload : IDisposable - { - [FieldOffset(0)] - private readonly IntPtr textPtr; - [FieldOffset(16)] - private readonly ulong textLen; - [FieldOffset(8)] - private readonly ulong unk1; - [FieldOffset(24)] - private readonly ulong unk2; - internal ChatPayload(byte[] stringBytes) - { - textPtr = Marshal.AllocHGlobal(stringBytes.Length + 30); - Marshal.Copy(stringBytes, 0, textPtr, stringBytes.Length); - Marshal.WriteByte(textPtr + stringBytes.Length, 0); - textLen = (ulong)(stringBytes.Length + 1); - unk1 = 64; - unk2 = 0; - } - public void Dispose() - { - Marshal.FreeHGlobal(textPtr); - } - } -} \ No newline at end of file diff --git a/ECommons/ECommons/Automation/Macro.cs b/ECommons/ECommons/Automation/Macro.cs deleted file mode 100644 index ce0d2c2..0000000 --- a/ECommons/ECommons/Automation/Macro.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; - -namespace ECommons.Automation; - -[StructLayout(LayoutKind.Sequential, Size = 0x688)] -public readonly struct Macro : IDisposable -{ - public const int numLines = 15; - public const int size = 0x8 + (UTF8String.size * (numLines + 1)); - - public readonly uint icon; - public readonly uint key; - public readonly UTF8String title; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = numLines)] - public readonly UTF8String[] lines; - - public Macro(IntPtr loc, string t, IReadOnlyList commands) - { - icon = 0x101D1; // 66001 - key = 1; - title = new UTF8String(loc + 0x8, t); - lines = new UTF8String[numLines]; - for (int i = 0; i < numLines; i++) - { - var command = (commands.Count > i) ? commands[i] : string.Empty; - lines[i] = new UTF8String(loc + 0x8 + (UTF8String.size * (i + 1)), command); - } - } - - public void Dispose() - { - title.Dispose(); - for (int i = 0; i < numLines; i++) - lines[i].Dispose(); - } -} diff --git a/ECommons/ECommons/Automation/MacroManager.cs b/ECommons/ECommons/Automation/MacroManager.cs deleted file mode 100644 index 1b2e255..0000000 --- a/ECommons/ECommons/Automation/MacroManager.cs +++ /dev/null @@ -1,52 +0,0 @@ -using FFXIVClientStructs.FFXIV.Client.UI.Shell; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; - -namespace ECommons.Automation; - -public unsafe static class MacroManager -{ - private static Chat chat = null; - - public static void Execute(string multilineString) - { - Execute(multilineString.Replace("\r", "").Split("\n")); - } - - public static void Execute(params string[] commands) - { - Execute(commands); - } - - public static void Execute(IEnumerable commands) - { - var macroPtr = IntPtr.Zero; - chat ??= new(); - GenericHelpers.Safe(delegate - { - var count = (byte)Math.Max(Macro.numLines, commands.Count()); - if (count > Macro.numLines) - { - throw new InvalidOperationException("Macro was more than 15 lines!"); - } - if (commands.Any(x => x.Length > 180)) - { - throw new InvalidOperationException("Macro contained lines more than 180 symbols!"); - } - if (commands.Any(x => x.Contains("\n") || x.Contains("\r") || x.Contains("\0") || chat.SanitiseText(x).Length != x.Length)) - { - throw new InvalidOperationException("Macro contained invalid symbols!"); - } - macroPtr = Marshal.AllocHGlobal(Macro.size); - using var macro = new Macro(macroPtr, string.Empty, commands.ToArray()); - Marshal.StructureToPtr(macro, macroPtr, false); - - RaptureShellModule.Instance()->ExecuteMacro((FFXIVClientStructs.FFXIV.Client.UI.Misc.RaptureMacroModule.Macro*)macroPtr); - }); - - Marshal.FreeHGlobal(macroPtr); - } - -} diff --git a/ECommons/ECommons/Automation/TaskManager.cs b/ECommons/ECommons/Automation/TaskManager.cs deleted file mode 100644 index f10bd75..0000000 --- a/ECommons/ECommons/Automation/TaskManager.cs +++ /dev/null @@ -1,306 +0,0 @@ -using ECommons.DalamudServices; -using ECommons.Logging; -using ECommons.Throttlers; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; - -namespace ECommons.Automation -{ - public class TaskManager : IDisposable - { - private static readonly List Instances = new(); - /// - /// Number of tasks that were registered in current cycle. Increases each time a task is enqueued and resets once there are no more tasks. - /// - public int MaxTasks { get; private set; } = 0; - /// - /// After this time limit has passed, a task will be given up. - /// - public int TimeLimitMS = 10000; - /// - /// Whether to abort execution on timeout and clear all remaining tasks or not. - /// - public bool AbortOnTimeout = false; - /// - /// Tick count () at which current task will be aborted - /// - public long AbortAt { get; private set; } = 0; - TaskManagerTask CurrentTask = null; - public string? CurrentTaskName => CurrentTask?.Name; - public List TaskStack => ImmediateTasks.Select(x => x.Name).Union(Tasks.Select(x => x.Name)).ToList(); - /// - /// Amount of currently queued tasks, including one that is currently being executed - /// - public int NumQueuedTasks => Tasks.Count + ImmediateTasks.Count + (CurrentTask == null ? 0 : 1); - /// - /// Whether to redirect timeout errors into Verbose channel - /// - public bool TimeoutSilently = false; - /// - /// Whether to output debug information into PluginLog - /// - public bool ShowDebug = true; - Action LogTimeout => TimeoutSilently ? PluginLog.Verbose : PluginLog.Warning; - - Queue Tasks = new(); - Queue ImmediateTasks = new(); - - /// - /// Initializes new instance of . - /// - public TaskManager() - { - Svc.Framework.Update += Tick; - Instances.Add(this); - } - - - /// - /// Sets step mode, when enabled task manager won't execute tasks automatically and will wait for Step command from you. - /// - /// - public void SetStepMode(bool enabled) - { - Svc.Framework.Update -= Tick; - if (!enabled) - { - Svc.Framework.Update += Tick; - } - } - - /// - /// Manually execute task manager cycle. - /// - public void Step() => Tick(null); - - /// - /// Disposes task manager, stopping all tasks immediately. - /// - [Obsolete($"Task managers will be disposed automatically on {nameof(ECommonsMain.Dispose)} call. Use this if you need to dispose task manager before that.")] - public void Dispose() - { - Svc.Framework.Update -= Tick; - Instances.Remove(this); - } - - internal static void DisposeAll() - { - int i = 0; - foreach (var manager in Instances) - { - i++; - Svc.Framework.Update -= manager.Tick; - } - if (i > 0) - { - PluginLog.Debug($"Auto-disposing {i} task managers"); - } - Instances.Clear(); - } - - /// - /// Whether TaskManager is currently executing a task. - /// - public bool IsBusy => CurrentTask != null || Tasks.Count > 0 || ImmediateTasks.Count > 0; - - public void Enqueue(Func task, string name = null) - { - Tasks.Enqueue(new(task, TimeLimitMS, AbortOnTimeout, name)); - MaxTasks++; - } - - public void Enqueue(Func task, int timeLimitMs, string name = null) - { - Tasks.Enqueue(new(task, timeLimitMs, AbortOnTimeout, name)); - MaxTasks++; - } - - public void Enqueue(Func task, bool abortOnTimeout, string name = null) - { - Tasks.Enqueue(new(task, TimeLimitMS, abortOnTimeout, name)); - MaxTasks++; - } - - public void Enqueue(Func task, int timeLimitMs, bool abortOnTimeout, string name = null) - { - Tasks.Enqueue(new(task, timeLimitMs, abortOnTimeout, name)); - MaxTasks++; - } - public void Enqueue(Action task, string name = null) - { - Tasks.Enqueue(new(() => { task(); return true; }, TimeLimitMS, AbortOnTimeout, name)); - MaxTasks++; - } - - public void Enqueue(Action task, int timeLimitMs, string name = null) - { - Tasks.Enqueue(new(() => { task(); return true; }, timeLimitMs, AbortOnTimeout, name)); - MaxTasks++; - } - - public void Enqueue(Action task, bool abortOnTimeout, string name = null) - { - Tasks.Enqueue(new(() => { task(); return true; }, TimeLimitMS, abortOnTimeout, name)); - MaxTasks++; - } - - public void Enqueue(Action task, int timeLimitMs, bool abortOnTimeout, string name = null) - { - Tasks.Enqueue(new(() => { task(); return true; }, timeLimitMs, abortOnTimeout, name)); - MaxTasks++; - } - - public void DelayNext(int delayMS, bool useFrameThrottler = false) => DelayNext("ECommonsGenericDelay", delayMS, useFrameThrottler); - public void DelayNext(string uniqueName, int delayMS, bool useFrameThrottler = false) - { - if (useFrameThrottler) - { - Enqueue(() => FrameThrottler.Throttle(uniqueName, delayMS), $"FrameThrottler.Throttle({uniqueName}, {delayMS})"); - Enqueue(() => FrameThrottler.Check(uniqueName), $"FrameThrottler.Check({uniqueName})"); - } - else - { - Enqueue(() => EzThrottler.Throttle(uniqueName, delayMS), $"EzThrottler.Throttle({uniqueName}, {delayMS})"); - Enqueue(() => EzThrottler.Check(uniqueName), $"EzThrottler.Check({uniqueName})"); - } - MaxTasks += 2; - } - - public void DelayNextImmediate(int delayMS, bool useFrameThrottler = false) => DelayNextImmediate("ECommonsGenericDelay", delayMS, useFrameThrottler); - public void DelayNextImmediate(string uniqueName, int delayMS, bool useFrameThrottler = false) - { - if (useFrameThrottler) - { - EnqueueImmediate(() => FrameThrottler.Throttle(uniqueName, delayMS), $"FrameThrottler.Throttle({uniqueName}, {delayMS})"); - EnqueueImmediate(() => FrameThrottler.Check(uniqueName), $"FrameThrottler.Check({uniqueName})"); - } - else - { - EnqueueImmediate(() => EzThrottler.Throttle(uniqueName, delayMS), $"EzThrottler.Throttle({uniqueName}, {delayMS})"); - EnqueueImmediate(() => EzThrottler.Check(uniqueName), $"EzThrottler.Check({uniqueName})"); - } - MaxTasks += 2; - } - - public void Abort() - { - Tasks.Clear(); - ImmediateTasks.Clear(); - CurrentTask = null; - } - - public void EnqueueImmediate(Func task, string name = null) - { - ImmediateTasks.Enqueue(new(task, TimeLimitMS, AbortOnTimeout, name)); - MaxTasks++; - } - - public void EnqueueImmediate(Func task, int timeLimitMs, string name = null) - { - ImmediateTasks.Enqueue(new(task, timeLimitMs, AbortOnTimeout, name)); - MaxTasks++; - } - - public void EnqueueImmediate(Func task, bool abortOnTimeout, string name = null) - { - ImmediateTasks.Enqueue(new(task, TimeLimitMS, abortOnTimeout, name)); - MaxTasks++; - } - - public void EnqueueImmediate(Func task, int timeLimitMs, bool abortOnTimeout, string name = null) - { - ImmediateTasks.Enqueue(new(task, timeLimitMs, abortOnTimeout, name)); - MaxTasks++; - } - - public void EnqueueImmediate(Action task, string name = null) - { - ImmediateTasks.Enqueue(new(() => { task(); return true; }, TimeLimitMS, AbortOnTimeout, name)); - MaxTasks++; - } - - public void EnqueueImmediate(Action task, int timeLimitMs, string name = null) - { - ImmediateTasks.Enqueue(new(() => { task(); return true; }, timeLimitMs, AbortOnTimeout, name)); - MaxTasks++; - } - - public void EnqueueImmediate(Action task, bool abortOnTimeout, string name = null) - { - ImmediateTasks.Enqueue(new(() => { task(); return true; }, TimeLimitMS, abortOnTimeout, name)); - MaxTasks++; - } - - public void EnqueueImmediate(Action task, int timeLimitMs, bool abortOnTimeout, string name = null) - { - ImmediateTasks.Enqueue(new(() => { task(); return true; }, timeLimitMs, abortOnTimeout, name)); - MaxTasks++; - } - - void Tick(object _) - { - if (CurrentTask == null) - { - if (ImmediateTasks.TryDequeue(out CurrentTask)) - { - if (ShowDebug) - PluginLog.Debug($"Starting to execute immediate task: {CurrentTask.Name ?? CurrentTask.Action.GetMethodInfo()?.Name}"); - AbortAt = Environment.TickCount64 + CurrentTask.TimeLimitMS; - } - else if (Tasks.TryDequeue(out CurrentTask)) - { - if (ShowDebug) - PluginLog.Debug($"Starting to execute task: {CurrentTask.Name ?? CurrentTask.Action.GetMethodInfo()?.Name}"); - AbortAt = Environment.TickCount64 + CurrentTask.TimeLimitMS; - } - else - { - MaxTasks = 0; - } - } - else - { - try - { - var result = CurrentTask.Action(); - if (result == true) - { - if (ShowDebug) - PluginLog.Debug($"Task {CurrentTask.Name ?? CurrentTask.Action.GetMethodInfo()?.Name} completed successfully"); - CurrentTask = null; - } - else if (result == false) - { - if (Environment.TickCount64 > AbortAt) - { - if (CurrentTask.AbortOnTimeout) - { - LogTimeout($"Clearing {Tasks.Count} remaining tasks because of timeout"); - Tasks.Clear(); - ImmediateTasks.Clear(); - } - throw new TimeoutException($"Task {CurrentTask.Name ?? CurrentTask.Action.GetMethodInfo()?.Name} took too long to execute"); - } - } - else - { - PluginLog.Warning($"Clearing {Tasks.Count} remaining tasks because there was a signal from task {CurrentTask.Name ?? CurrentTask.Action.GetMethodInfo()?.Name} to abort"); - Abort(); - } - } - catch (TimeoutException e) - { - LogTimeout($"{e.Message}\n{e.StackTrace}"); - CurrentTask = null; - } - catch (Exception e) - { - e.Log(); - CurrentTask = null; - } - } - } - } -} diff --git a/ECommons/ECommons/Automation/TaskManagerTask.cs b/ECommons/ECommons/Automation/TaskManagerTask.cs deleted file mode 100644 index 99ce387..0000000 --- a/ECommons/ECommons/Automation/TaskManagerTask.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.Automation -{ - internal record class TaskManagerTask - { - internal Func Action; - internal int TimeLimitMS; - internal bool AbortOnTimeout; - internal string Name; - - internal TaskManagerTask(Func action, int timeLimitMS, bool abortOnTimeout, string name) - { - Action = action; - TimeLimitMS = timeLimitMS; - AbortOnTimeout = abortOnTimeout; - Name = name;// ?? new StackTrace().GetFrames().Select(x => x.GetMethod()?.Name ?? "").Join(" <- "); - } - } -} diff --git a/ECommons/ECommons/Automation/UTF8String.cs b/ECommons/ECommons/Automation/UTF8String.cs deleted file mode 100644 index 59c84cd..0000000 --- a/ECommons/ECommons/Automation/UTF8String.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using System.Text; - -namespace ECommons.Automation; - -[StructLayout(LayoutKind.Sequential, Size = 0x68)] -public readonly struct UTF8String : IDisposable -{ - public const int size = 0x68; - - public readonly IntPtr stringPtr; - public readonly ulong capacity; - public readonly ulong length; - public readonly ulong unknown; - public readonly byte isEmpty; - public readonly byte notReallocated; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x40)] - public readonly byte[] str; - - public UTF8String(IntPtr loc, string text) : this(loc, Encoding.UTF8.GetBytes(text)) { } - - public UTF8String(IntPtr loc, byte[] text) - { - capacity = 0x40; - length = (ulong)text.Length + 1; - str = new byte[capacity]; - - if (length > capacity) - { - stringPtr = Marshal.AllocHGlobal(text.Length + 1); - capacity = length; - Marshal.Copy(text, 0, stringPtr, text.Length); - Marshal.WriteByte(stringPtr, text.Length, 0); - notReallocated = 0; - } - else - { - stringPtr = loc + 0x22; - text.CopyTo(str, 0); - notReallocated = 1; - } - - isEmpty = (byte)((length == 1) ? 1 : 0); - unknown = 0; - } - - public void Dispose() - { - if (notReallocated == 0) - Marshal.FreeHGlobal(stringPtr); - } -} diff --git a/ECommons/ECommons/Automation/WindowsKeypress.cs b/ECommons/ECommons/Automation/WindowsKeypress.cs deleted file mode 100644 index 82d61a5..0000000 --- a/ECommons/ECommons/Automation/WindowsKeypress.cs +++ /dev/null @@ -1,61 +0,0 @@ -using ECommons.Interop; -using ECommons.Logging; -using PInvoke; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace ECommons.Automation -{ - public static class WindowsKeypress - { - public static bool SendKeypress(Keys key) - { - if (WindowFunctions.TryFindGameWindow(out var h)) - { - InternalLog.Verbose($"Sending key {key}"); - User32.SendMessage(h, User32.WindowMessage.WM_KEYDOWN, (int)key, 0); - User32.SendMessage(h, User32.WindowMessage.WM_KEYUP, (int)key, 0); - return true; - } - else - { - PluginLog.Error("Couldn't find game window!"); - } - return false; - } - public static void SendMousepress(Keys key) - { - if (WindowFunctions.TryFindGameWindow(out var h)) - { - if (key == Keys.XButton1) - { - var wparam = MAKEWPARAM(0, 0x0001); - User32.SendMessage(h, User32.WindowMessage.WM_XBUTTONDOWN, wparam, 0); - User32.SendMessage(h, User32.WindowMessage.WM_XBUTTONUP, wparam, 0); - } - else if (key == Keys.XButton2) - { - var wparam = MAKEWPARAM(0, 0x0002); - User32.SendMessage(h, User32.WindowMessage.WM_XBUTTONDOWN, wparam, 0); - User32.SendMessage(h, User32.WindowMessage.WM_XBUTTONUP, wparam, 0); - } - else - { - PluginLog.Error($"Invalid key: {key}"); - } - } - else - { - PluginLog.Error("Couldn't find game window!"); - } - } - internal static int MAKEWPARAM(int l, int h) - { - return (l & 0xFFFF) | (h << 16); - } - } -} diff --git a/ECommons/ECommons/ChatMethods/ChatPrinter.cs b/ECommons/ECommons/ChatMethods/ChatPrinter.cs deleted file mode 100644 index e3f0b2c..0000000 --- a/ECommons/ECommons/ChatMethods/ChatPrinter.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Dalamud.Game.Text.SeStringHandling; -using ECommons.DalamudServices; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.ChatMethods -{ - public static class ChatPrinter - { - public static void Red(string text) => PrintColored(UIColor.Red, text); - public static void Orange(string text) => PrintColored(UIColor.Orange, text); - public static void Yellow(string text) => PrintColored(UIColor.Yellow, text); - public static void Green(string text) => PrintColored(UIColor.Green, text); - - public static void PrintColored(UIColor col, string text) - { - Svc.Chat.Print(new() - { - Message = new SeStringBuilder().AddUiForeground(text, (ushort)col).Build() - }); - } - } -} diff --git a/ECommons/ECommons/ChatMethods/Sender.cs b/ECommons/ECommons/ChatMethods/Sender.cs deleted file mode 100644 index 59bdda3..0000000 --- a/ECommons/ECommons/ChatMethods/Sender.cs +++ /dev/null @@ -1,72 +0,0 @@ -using Dalamud.Game.ClientState.Objects.SubKinds; -using Dalamud.Game.Text.SeStringHandling; -using ECommons.DalamudServices; -using Lumina.Excel.GeneratedSheets; -using System; -using System.Reflection; - -namespace ECommons.ChatMethods; - -[Obfuscation(Exclude = true, ApplyToMembers = true)] -public struct Sender : IEquatable -{ - public string Name; - public uint HomeWorld; - - public Sender(string Name, uint HomeWorld) - { - this.Name = Name; - this.HomeWorld = HomeWorld; - } - - public Sender(SeString Name, uint HomeWorld) - { - this = new(Name.ToString(), HomeWorld); - } - - public Sender(SeString Name, Dalamud.Game.ClientState.Resolvers.ExcelResolver HomeWorld) - { - this = new(Name.ToString(), HomeWorld.Id); - } - - public Sender(string Name, Dalamud.Game.ClientState.Resolvers.ExcelResolver HomeWorld) - { - this = new(Name, HomeWorld.Id); - } - - public Sender(PlayerCharacter pc) - { - this = new(pc.Name, pc.HomeWorld); - } - - public override bool Equals(object obj) - { - return obj is Sender sender && Equals(sender); - } - - public bool Equals(Sender other) - { - return Name == other.Name && - HomeWorld == other.HomeWorld; - } - - public override int GetHashCode() - { - return HashCode.Combine(Name, HomeWorld); - } - - public override string ToString() - { - return $"{this.Name}@{Svc.Data.GetExcelSheet().GetRow(this.HomeWorld).Name}"; - } - - public static bool operator ==(Sender left, Sender right) - { - return left.Equals(right); - } - - public static bool operator !=(Sender left, Sender right) - { - return !(left == right); - } -} diff --git a/ECommons/ECommons/ChatMethods/UIColor.cs b/ECommons/ECommons/ChatMethods/UIColor.cs deleted file mode 100644 index 9920d11..0000000 --- a/ECommons/ECommons/ChatMethods/UIColor.cs +++ /dev/null @@ -1,149 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.ChatMethods -{ - //https://i.imgur.com/cZceCI3.png - [Obfuscation(Exclude = true, ApplyToMembers = true)] - public enum UIColor : short - { - WhiteNormal = 0, - White = 1, - Grey1 = 2, - Grey2 = 3, - Grey3 = 4, - Grey4 = 5, - Grey5 = 6, - Black = 7, - LightYellow = 8, - _color9 = 9, - _color10 = 10, - _color11 = 11, - _color12 = 12, - _color13 = 13, - _color14 = 14, - _color15 = 15, - _color16 = 16, - Red = 17, - _color18 = 18, - DarkRed = 19, - _color20 = 20, - _color21 = 21, - _color22 = 22, - _color23 = 23, - _color24 = 24, - _color25 = 25, - _color26 = 26, - _color27 = 27, - _color28 = 28, - _color29 = 29, - _color30 = 30, - _color31 = 31, - _color32 = 32, - _color33 = 33, - _color34 = 34, - _color35 = 35, - _color36 = 36, - _color37 = 37, - _color38 = 38, - _color39 = 39, - _color40 = 40, - _color41 = 41, - _color42 = 42, - _color43 = 43, - _color44 = 44, - Green = 45, - _color46 = 46, - DarkGreen = 47, - _color48 = 48, - _color49 = 49, - _color50 = 50, - _color52 = 52, - _color53 = 53, - _color54 = 54, - _color55 = 55, - _color56 = 56, - _color57 = 57, - _color58 = 58, - _color59 = 59, - _color60 = 60, - _color61 = 61, - _color62 = 62, - _color63 = 63, - _color64 = 64, - _color65 = 65, - _color66 = 66, - _color67 = 67, - _color68 = 68, - Orange = 500, - LightBlue = 502, - _color504 = 504, - _color506 = 506, - _color508 = 508, - _color510 = 510, - _color511 = 511, - _color512 = 512, - _color513 = 513, - Yellow = 514, - _color515 = 515, - _color516 = 516, - _color517 = 517, - _color518 = 518, - _color519 = 519, - _color520 = 520, - _color521 = 521, - _color522 = 522, - _color523 = 523, - _color524 = 524, - _color525 = 525, - _color526 = 526, - _color527 = 527, - _color528 = 528, - _color529 = 529, - _color530 = 530, - _color531 = 531, - _color532 = 532, - _color533 = 533, - _color534 = 534, - _color535 = 535, - _color536 = 536, - _color537 = 537, - _color538 = 538, - _color539 = 539, - Gold = 540, - _color541 = 541, - _color542 = 542, - DarkBlue = 543, - _color544 = 544, - _color545 = 545, - _color546 = 546, - _color547 = 547, - _color548 = 548, - _color549 = 549, - LightGreen = 551, - _color553 = 553, - _color555 = 555, - _color557 = 557, - _color559 = 559, - Pink = 561, - _color563 = 563, - _color565 = 565, - _color566 = 566, - _color567 = 567, - _color568 = 568, - _color569 = 569, - _color570 = 570, - _color571 = 571, - _color573 = 573, - _color575 = 575, - _color576 = 576, - _color577 = 577, - _color578 = 578, - _color579 = 579, - _color580 = 580, - } -} diff --git a/ECommons/ECommons/CircularBuffers/CircularArray.cs b/ECommons/ECommons/CircularBuffers/CircularArray.cs deleted file mode 100644 index 7f07a46..0000000 --- a/ECommons/ECommons/CircularBuffers/CircularArray.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; - -namespace ECommons; - -public class CircularArray : IEnumerable -{ - T[] values; - bool[] isFilled; - public CircularArray(int capacity) - { - if (capacity < 2) - { - throw new Exception("Capacity must be at least 2"); - } - values = new T[capacity]; - isFilled = new bool[capacity]; - for (var i = 0; i < isFilled.Length; i++) - { - isFilled[i] = false; - } - } - - public void Push(T value) - { - for (var i = 0; i < isFilled.Length; i++) - { - if (!isFilled[i]) - { - isFilled[i] = true; - values[i] = value; - return; - } - } - for (var i = 1; i < values.Length; i++) - { - values[i - 1] = values[i]; - } - values[^1] = value; - } - - public T this[int index] - { - get - { - return values[index]; - } - } - - public IEnumerator GetEnumerator() - { - for (var i = 0; i < values.Length; i++) - { - if (isFilled[i]) - { - yield return values[i]; - } - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - return values.GetEnumerator(); - } -} \ No newline at end of file diff --git a/ECommons/ECommons/CircularBuffers/CircularBuffer.cs b/ECommons/ECommons/CircularBuffers/CircularBuffer.cs deleted file mode 100644 index 62d371d..0000000 --- a/ECommons/ECommons/CircularBuffers/CircularBuffer.cs +++ /dev/null @@ -1,417 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; - -namespace ECommons.CircularBuffers; - -/// -/// -/// Circular buffer. -/// -/// When writing to a full buffer: -/// PushBack -> removes this[0] / Front() -/// PushFront -> removes this[Size-1] / Back() -/// -/// this implementation is inspired by -/// http://www.boost.org/doc/libs/1_53_0/libs/circular_buffer/doc/circular_buffer.html -/// because I liked their interface. -/// -public class CircularBuffer : IEnumerable -{ - private readonly T[] _buffer; - - /// - /// The _start. Index of the first element in buffer. - /// - private int _start; - - /// - /// The _end. Index after the last element in the buffer. - /// - private int _end; - - /// - /// The _size. Buffer size. - /// - private int _size; - - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// Buffer capacity. Must be positive. - /// - public CircularBuffer(int capacity) - : this(capacity, new T[] { }) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// Buffer capacity. Must be positive. - /// - /// - /// Items to fill buffer with. Items length must be less than capacity. - /// Suggestion: use Skip(x).Take(y).ToArray() to build this argument from - /// any enumerable. - /// - public CircularBuffer(int capacity, T[] items) - { - if (capacity < 1) - { - throw new ArgumentException( - "Circular buffer cannot have negative or zero capacity.", nameof(capacity)); - } - if (items == null) - { - throw new ArgumentNullException(nameof(items)); - } - if (items.Length > capacity) - { - throw new ArgumentException( - "Too many items to fit circular buffer", nameof(items)); - } - - _buffer = new T[capacity]; - - Array.Copy(items, _buffer, items.Length); - _size = items.Length; - - _start = 0; - _end = _size == capacity ? 0 : _size; - } - - /// - /// Maximum capacity of the buffer. Elements pushed into the buffer after - /// maximum capacity is reached (IsFull = true), will remove an element. - /// - public int Capacity { get { return _buffer.Length; } } - - /// - /// Boolean indicating if Circular is at full capacity. - /// Adding more elements when the buffer is full will - /// cause elements to be removed from the other end - /// of the buffer. - /// - public bool IsFull - { - get - { - return Size == Capacity; - } - } - - /// - /// True if has no elements. - /// - public bool IsEmpty - { - get - { - return Size == 0; - } - } - - /// - /// Current buffer size (the number of elements that the buffer has). - /// - public int Size { get { return _size; } } - - /// - /// Element at the front of the buffer - this[0]. - /// - /// The value of the element of type T at the front of the buffer. - public T Front() - { - ThrowIfEmpty(); - return _buffer[_start]; - } - - /// - /// Element at the back of the buffer - this[Size - 1]. - /// - /// The value of the element of type T at the back of the buffer. - public T Back() - { - ThrowIfEmpty(); - return _buffer[(_end != 0 ? _end : Capacity) - 1]; - } - - /// - /// Index access to elements in buffer. - /// Index does not loop around like when adding elements, - /// valid interval is [0;Size[ - /// - /// Index of element to access. - /// Thrown when index is outside of [; Size[ interval. - public T this[int index] - { - get - { - if (IsEmpty) - { - throw new IndexOutOfRangeException(string.Format("Cannot access index {0}. Buffer is empty", index)); - } - if (index >= _size) - { - throw new IndexOutOfRangeException(string.Format("Cannot access index {0}. Buffer size is {1}", index, _size)); - } - int actualIndex = InternalIndex(index); - return _buffer[actualIndex]; - } - set - { - if (IsEmpty) - { - throw new IndexOutOfRangeException(string.Format("Cannot access index {0}. Buffer is empty", index)); - } - if (index >= _size) - { - throw new IndexOutOfRangeException(string.Format("Cannot access index {0}. Buffer size is {1}", index, _size)); - } - int actualIndex = InternalIndex(index); - _buffer[actualIndex] = value; - } - } - - /// - /// Pushes a new element to the back of the buffer. Back()/this[Size-1] - /// will now return this element. - /// - /// When the buffer is full, the element at Front()/this[0] will be - /// popped to allow for this new element to fit. - /// - /// Item to push to the back of the buffer - public void PushBack(T item) - { - if (IsFull) - { - _buffer[_end] = item; - Increment(ref _end); - _start = _end; - } - else - { - _buffer[_end] = item; - Increment(ref _end); - ++_size; - } - } - - /// - /// Pushes a new element to the front of the buffer. Front()/this[0] - /// will now return this element. - /// - /// When the buffer is full, the element at Back()/this[Size-1] will be - /// popped to allow for this new element to fit. - /// - /// Item to push to the front of the buffer - public void PushFront(T item) - { - if (IsFull) - { - Decrement(ref _start); - _end = _start; - _buffer[_start] = item; - } - else - { - Decrement(ref _start); - _buffer[_start] = item; - ++_size; - } - } - - /// - /// Removes the element at the back of the buffer. Decreasing the - /// Buffer size by 1. - /// - public void PopBack() - { - ThrowIfEmpty("Cannot take elements from an empty buffer."); - Decrement(ref _end); - _buffer[_end] = default; - --_size; - } - - /// - /// Removes the element at the front of the buffer. Decreasing the - /// Buffer size by 1. - /// - public void PopFront() - { - ThrowIfEmpty("Cannot take elements from an empty buffer."); - _buffer[_start] = default; - Increment(ref _start); - --_size; - } - - /// - /// Clears the contents of the array. Size = 0, Capacity is unchanged. - /// - /// - public void Clear() - { - // to clear we just reset everything. - _start = 0; - _end = 0; - _size = 0; - Array.Clear(_buffer, 0, _buffer.Length); - } - - /// - /// Copies the buffer contents to an array, according to the logical - /// contents of the buffer (i.e. independent of the internal - /// order/contents) - /// - /// A new array with a copy of the buffer contents. - public T[] ToArray() - { - T[] newArray = new T[Size]; - int newArrayOffset = 0; - var segments = ToArraySegments(); - foreach (ArraySegment segment in segments) - { - Array.Copy(segment.Array, segment.Offset, newArray, newArrayOffset, segment.Count); - newArrayOffset += segment.Count; - } - return newArray; - } - - /// - /// Get the contents of the buffer as 2 ArraySegments. - /// Respects the logical contents of the buffer, where - /// each segment and items in each segment are ordered - /// according to insertion. - /// - /// Fast: does not copy the array elements. - /// Useful for methods like Send(IList<ArraySegment<Byte>>). - /// - /// Segments may be empty. - /// - /// An IList with 2 segments corresponding to the buffer content. - public IList> ToArraySegments() - { - return new[] { ArrayOne(), ArrayTwo() }; - } - - #region IEnumerable implementation - /// - /// Returns an enumerator that iterates through this buffer. - /// - /// An enumerator that can be used to iterate this collection. - public IEnumerator GetEnumerator() - { - var segments = ToArraySegments(); - foreach (ArraySegment segment in segments) - { - for (int i = 0; i < segment.Count; i++) - { - yield return segment.Array[segment.Offset + i]; - } - } - } - #endregion - #region IEnumerable implementation - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - #endregion - - private void ThrowIfEmpty(string message = "Cannot access an empty buffer.") - { - if (IsEmpty) - { - throw new InvalidOperationException(message); - } - } - - /// - /// Increments the provided index variable by one, wrapping - /// around if necessary. - /// - /// - private void Increment(ref int index) - { - if (++index == Capacity) - { - index = 0; - } - } - - /// - /// Decrements the provided index variable by one, wrapping - /// around if necessary. - /// - /// - private void Decrement(ref int index) - { - if (index == 0) - { - index = Capacity; - } - index--; - } - - /// - /// Converts the index in the argument to an index in _buffer - /// - /// - /// The transformed index. - /// - /// - /// External index. - /// - private int InternalIndex(int index) - { - return _start + (index < Capacity - _start ? index : index - Capacity); - } - - // doing ArrayOne and ArrayTwo methods returning ArraySegment as seen here: - // http://www.boost.org/doc/libs/1_37_0/libs/circular_buffer/doc/circular_buffer.html#classboost_1_1circular__buffer_1957cccdcb0c4ef7d80a34a990065818d - // http://www.boost.org/doc/libs/1_37_0/libs/circular_buffer/doc/circular_buffer.html#classboost_1_1circular__buffer_1f5081a54afbc2dfc1a7fb20329df7d5b - // should help a lot with the code. - - #region Array items easy access. - // The array is composed by at most two non-contiguous segments, - // the next two methods allow easy access to those. - - private ArraySegment ArrayOne() - { - if (IsEmpty) - { - return new ArraySegment(new T[0]); - } - else if (_start < _end) - { - return new ArraySegment(_buffer, _start, _end - _start); - } - else - { - return new ArraySegment(_buffer, _start, _buffer.Length - _start); - } - } - - private ArraySegment ArrayTwo() - { - if (IsEmpty) - { - return new ArraySegment(new T[0]); - } - else if (_start < _end) - { - return new ArraySegment(_buffer, _end, 0); - } - else - { - return new ArraySegment(_buffer, 0, _end); - } - } - #endregion -} - diff --git a/ECommons/ECommons/Commands/CmdAttribute.cs b/ECommons/ECommons/Commands/CmdAttribute.cs deleted file mode 100644 index 68e7f31..0000000 --- a/ECommons/ECommons/Commands/CmdAttribute.cs +++ /dev/null @@ -1,28 +0,0 @@ -using ECommons.LanguageHelpers; -using System; - -namespace ECommons.Commands; - -[AttributeUsage(AttributeTargets.Method)] -public class CmdAttribute : Attribute -{ - public string Command { get; } - public string HelpMessage { get; } - public bool ShowInHelp { get; } - public bool ShowInHelpPanel { get; } - - /// - /// - /// - /// - /// - /// - /// Whether show the major command help on the window - public CmdAttribute(string command, string helpMessage = "", bool showInHelp = true, bool showInHelpPanel = true) - { - Command = command; - HelpMessage = helpMessage.Loc(); - ShowInHelp = showInHelp; - ShowInHelpPanel = showInHelpPanel; - } -} diff --git a/ECommons/ECommons/Commands/CmdManager.cs b/ECommons/ECommons/Commands/CmdManager.cs deleted file mode 100644 index db0c067..0000000 --- a/ECommons/ECommons/Commands/CmdManager.cs +++ /dev/null @@ -1,121 +0,0 @@ -using ECommons.DalamudServices; -using ImGuiNET; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; - -namespace ECommons.Commands; - -public static class CmdManager -{ - static Dictionary _commandsAttribute = new Dictionary(); - - internal static void Init() - { - var plugin = ECommonsMain.Instance; - if (plugin == null) return; - - foreach (var m in plugin.GetType().GetRuntimeMethods()) - { - var types = m.GetParameters(); - if (types.Length != 2 - || types[0].ParameterType != typeof(string) - || types[1].ParameterType != typeof(string)) continue; - - var cmdAttr = m.GetCustomAttribute(); - if (cmdAttr == null) continue; - - Svc.Commands.AddHandler(cmdAttr.Command, new Dalamud.Game.Command.CommandInfo((string command, string arguments) => - { - m.Invoke(plugin, new object[] { command, arguments }); - }) - { - HelpMessage = cmdAttr.HelpMessage, - ShowInHelp = cmdAttr.ShowInHelp, - }); - - _commandsAttribute[cmdAttr] = m.GetCustomAttributes().ToArray(); - } - } - - /// - /// Draw the help panel into the window. - /// - /// The indent of value. 0 means no index, -1 means next line. - public static void DrawHelp(float indent = 0) - { - bool isFirst = true; - foreach (var pair in _commandsAttribute) - { - if (isFirst) isFirst = false; - else ImGui.Spacing(); - - if (pair.Key.ShowInHelpPanel) - { - DisplayCommandHelp(pair.Key.Command, "", pair.Key.HelpMessage, indent); - } - foreach (var sub in pair.Value) - { - if (sub == null) continue; - DisplayCommandHelp(pair.Key.Command, sub.SubCommand, sub.HelpMessage, indent); - } - } - } - - public static void DisplayCommandHelp(string command, string extraCommand = "", string helpMessage = "", float indent = 0) - { - if (string.IsNullOrEmpty(command)) return; - if (!string.IsNullOrEmpty(extraCommand)) - { - command += " " + extraCommand; - } - - if (ImGui.Button(command)) - { - Svc.Commands.ProcessCommand(command); - } - if (ImGui.IsItemHovered()) - { - ImGui.SetTooltip($"Click to execute the command: {command}\nRight-click to copy the command: {command}"); - - if (ImGui.IsMouseClicked(ImGuiMouseButton.Right)) - { - ImGui.SetClipboardText(command); - } - } - - if (!string.IsNullOrEmpty(helpMessage)) - { - if (indent > 0) - { - ImGui.SameLine(); - ImGui.Indent(indent); - } - else - { - if (indent < 0) - { - ImGui.Text(" "); - } - ImGui.SameLine(); - } - - ImGui.Text(" → "); - ImGui.SameLine(); - ImGui.TextWrapped(helpMessage); - - if (indent > 0) - { - ImGui.Unindent(indent); - } - } - } - - internal static void Dispose() - { - foreach (var cmd in _commandsAttribute.Keys) - { - Svc.Commands.RemoveHandler(cmd.Command); - } - } -} diff --git a/ECommons/ECommons/Commands/SubCmdAttribute.cs b/ECommons/ECommons/Commands/SubCmdAttribute.cs deleted file mode 100644 index a8df1fb..0000000 --- a/ECommons/ECommons/Commands/SubCmdAttribute.cs +++ /dev/null @@ -1,17 +0,0 @@ -using ECommons.LanguageHelpers; -using System; - -namespace ECommons.Commands; - -[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] -public class SubCmdAttribute : Attribute -{ - public string SubCommand { get; } - public string HelpMessage { get; } - - public SubCmdAttribute(string subCommand, string helpMessage = "") - { - SubCommand = subCommand; - HelpMessage = helpMessage.Loc(); - } -} \ No newline at end of file diff --git a/ECommons/ECommons/Configuration/EzConfig.cs b/ECommons/ECommons/Configuration/EzConfig.cs deleted file mode 100644 index 4b1e1c3..0000000 --- a/ECommons/ECommons/Configuration/EzConfig.cs +++ /dev/null @@ -1,89 +0,0 @@ -using ECommons.Logging; -using ECommons.DalamudServices; -using ECommons.ImGuiMethods; -using Newtonsoft.Json; -using System; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; - -namespace ECommons.Configuration; - -public static class EzConfig -{ - const string DefaultConfigurationName = "DefaultConfig.json"; - public static string DefaultConfigurationFileName => Path.Combine(Svc.PluginInterface.GetPluginConfigDirectory(), DefaultConfigurationName); - public static IEzConfig Config { get; private set; } - - public static T Init() where T : IEzConfig, new() - { - Config = LoadConfiguration(DefaultConfigurationName); - return (T)Config; - } - - public static void Migrate() where T : IEzConfig, new() - { - if(Config != null) - { - throw new NullReferenceException("Migrate must be called instead of initialization"); - } - var path = DefaultConfigurationFileName; - if(!File.Exists(path) && Svc.PluginInterface.ConfigFile.Exists) - { - PluginLog.Warning($"Migrating {Svc.PluginInterface.ConfigFile} into EzConfig system"); - Config = LoadConfiguration(Svc.PluginInterface.ConfigFile.FullName, false); - Save(); - Config = null; - File.Move(Svc.PluginInterface.ConfigFile.FullName, $"{Svc.PluginInterface.ConfigFile}.old"); - } - else - { - PluginLog.Information($"Migrating conditions are not met, skipping..."); - } - } - - public static void Save() - { - if (Config != null) - { - SaveConfiguration(Config, DefaultConfigurationName, true); - } - } - - public static void SaveConfiguration(this IEzConfig Configuration, string path, bool indented = false, bool appendConfigDirectory = true) - { - if (appendConfigDirectory) path = Path.Combine(Svc.PluginInterface.GetPluginConfigDirectory(), path); - var antiCorruptionPath = $"{path}.new"; - if (File.Exists(antiCorruptionPath)) - { - var saveTo = $"{antiCorruptionPath}.{DateTimeOffset.Now.ToUnixTimeMilliseconds()}"; - PluginLog.Warning($"Detected unsuccessfully saved file {antiCorruptionPath}: moving to {saveTo}"); - Notify.Warning("Detected unsuccessfully saved configuration file."); - File.Move(antiCorruptionPath, saveTo); - PluginLog.Warning($"Success. Please manually check {saveTo} file contents."); - } - PluginLog.Verbose($"From caller {new StackTrace().GetFrames().Select(x => x.GetMethod()?.Name ?? "").Join(" <- ")} engaging anti-corruption mechanism, writing file to {antiCorruptionPath}"); - File.WriteAllText(antiCorruptionPath, JsonConvert.SerializeObject(Configuration, new JsonSerializerSettings() - { - Formatting = indented ? Formatting.Indented : Formatting.None, - DefaultValueHandling = Configuration.GetType().IsDefined(typeof(IgnoreDefaultValueAttribute), false) ?DefaultValueHandling.Ignore:DefaultValueHandling.Include - }), Encoding.UTF8); - PluginLog.Verbose($"Now moving {antiCorruptionPath} to {path}"); - File.Move(antiCorruptionPath, path, true); - PluginLog.Verbose($"Configuration successfully saved."); - } - - public static T LoadConfiguration(string path, bool appendConfigDirectory = true) where T : IEzConfig, new() - { - if (appendConfigDirectory) path = Path.Combine(Svc.PluginInterface.GetPluginConfigDirectory(), path); - if (!File.Exists(path)) - { - return new T(); - } - return JsonConvert.DeserializeObject(File.ReadAllText(path, Encoding.UTF8), new JsonSerializerSettings() - { - ObjectCreationHandling = ObjectCreationHandling.Replace, - }) ?? new T(); - } -} diff --git a/ECommons/ECommons/Configuration/IEzConfig.cs b/ECommons/ECommons/Configuration/IEzConfig.cs deleted file mode 100644 index 80f8254..0000000 --- a/ECommons/ECommons/Configuration/IEzConfig.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace ECommons.Configuration; - -public interface IEzConfig -{ -} diff --git a/ECommons/ECommons/Configuration/IgnoreDefaultValueAttribute.cs b/ECommons/ECommons/Configuration/IgnoreDefaultValueAttribute.cs deleted file mode 100644 index 248375d..0000000 --- a/ECommons/ECommons/Configuration/IgnoreDefaultValueAttribute.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.Configuration -{ - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct) -] - public class IgnoreDefaultValueAttribute : Attribute - { - } -} diff --git a/ECommons/ECommons/Constants.cs b/ECommons/ECommons/Constants.cs deleted file mode 100644 index 0cbd336..0000000 --- a/ECommons/ECommons/Constants.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Dalamud.Game.Text; - -namespace ECommons; - -public class Constants -{ - public readonly static XivChatType[] NormalChatTypes = - { - XivChatType.Party, - XivChatType.Alliance, - XivChatType.Say, - XivChatType.Yell, - XivChatType.Shout, - XivChatType.CrossParty, - XivChatType.CustomEmote, - XivChatType.StandardEmote, - XivChatType.TellOutgoing, - XivChatType.TellIncoming, - XivChatType.FreeCompany, - XivChatType.NoviceNetwork, - XivChatType.PvPTeam, - XivChatType.Ls1, - XivChatType.Ls2, - XivChatType.Ls3, - XivChatType.Ls4, - XivChatType.Ls5, - XivChatType.Ls6, - XivChatType.Ls7, - XivChatType.Ls8, - XivChatType.CrossLinkShell1, - XivChatType.CrossLinkShell2, - XivChatType.CrossLinkShell3, - XivChatType.CrossLinkShell4, - XivChatType.CrossLinkShell5, - XivChatType.CrossLinkShell6, - XivChatType.CrossLinkShell7, - XivChatType.CrossLinkShell8, - }; -} diff --git a/ECommons/ECommons/DalamudServices/Legacy/LegacyHelpers.cs b/ECommons/ECommons/DalamudServices/Legacy/LegacyHelpers.cs deleted file mode 100644 index 2af6bf9..0000000 --- a/ECommons/ECommons/DalamudServices/Legacy/LegacyHelpers.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Dalamud.Game.ClientState.Objects; -using Dalamud.Game.ClientState.Objects.Types; -using Dalamud.Game.Text; -using Dalamud.Plugin.Services; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.DalamudServices.Legacy -{ - public static class LegacyHelpers - { - public static void PrintChat(this IChatGui chatGui, XivChatEntry entry) => Svc.Chat.Print(entry); - - public static void SetTarget(this ITargetManager targetManager, GameObject obj) - { - targetManager.Target = obj; - } - } -} diff --git a/ECommons/ECommons/DalamudServices/Legacy/SignatureHelper.cs b/ECommons/ECommons/DalamudServices/Legacy/SignatureHelper.cs deleted file mode 100644 index cfc9c4c..0000000 --- a/ECommons/ECommons/DalamudServices/Legacy/SignatureHelper.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.DalamudServices.Legacy -{ - public static class SignatureHelper - { - public static void Initialise(object which, bool log = false) - { - Svc.Hook.InitializeFromAttributes(which); - } - } -} diff --git a/ECommons/ECommons/DalamudServices/Svc.cs b/ECommons/ECommons/DalamudServices/Svc.cs deleted file mode 100644 index 67293bd..0000000 --- a/ECommons/ECommons/DalamudServices/Svc.cs +++ /dev/null @@ -1,81 +0,0 @@ -using Dalamud.Data; -using Dalamud.Game; -using Dalamud.Game.ClientState; -using Dalamud.Game.ClientState.Buddy; -using Dalamud.Game.ClientState.Conditions; -using Dalamud.Game.ClientState.Fates; -using Dalamud.Game.ClientState.GamePad; -using Dalamud.Game.ClientState.JobGauge; -using Dalamud.Game.ClientState.Keys; -using Dalamud.Game.ClientState.Objects; -using Dalamud.Game.ClientState.Party; -using Dalamud.Game.Command; -using Dalamud.Game.Config; -using Dalamud.Game.DutyState; -using Dalamud.Game.Gui; -using Dalamud.Game.Gui.Dtr; -using Dalamud.Game.Gui.FlyText; -using Dalamud.Game.Gui.PartyFinder; -using Dalamud.Game.Gui.Toast; -using Dalamud.Game.Libc; -using Dalamud.Game.Network; -using Dalamud.IoC; -using Dalamud.Plugin; -using Dalamud.Plugin.Services; -using ECommons.Logging; -using System; - -namespace ECommons.DalamudServices; - -//If one of services is not ready, whole service class will be unavailable. -//This is inconvenient. Let's bypass it. -public class Svc -{ - [PluginService] public static DalamudPluginInterface PluginInterface { get; private set; } - [PluginService] public static IBuddyList Buddies { get; private set; } - [PluginService] public static IChatGui Chat { get; private set; } - [PluginService] public static IClientState ClientState { get; private set; } - [PluginService] public static ICommandManager Commands { get; private set; } - [PluginService] public static ICondition Condition { get; private set; } - [PluginService] public static IDataManager Data { get; private set; } - [PluginService] public static IFateTable Fates { get; private set; } - [PluginService] public static IFlyTextGui FlyText { get; private set; } - [PluginService] public static IFramework Framework { get; private set; } - [PluginService] public static IGameGui GameGui { get; private set; } - [PluginService] public static IGameNetwork GameNetwork { get; private set; } - [PluginService] public static IJobGauges Gauges { get; private set; } - [PluginService] public static IKeyState KeyState { get; private set; } - [PluginService] public static ILibcFunction LibcFunction { get; private set; } - [PluginService] public static IObjectTable Objects { get; private set; } - [PluginService] public static IPartyFinderGui PfGui { get; private set; } - [PluginService] public static IPartyList Party { get; private set; } - [PluginService] public static ISigScanner SigScanner { get; private set; } - [PluginService] public static ITargetManager Targets { get; private set; } - [PluginService] public static IToastGui Toasts { get; private set; } - [PluginService] public static IGameConfig GameConfig { get; private set; } - [PluginService] public static IGameLifecycle GameLifecycle { get; private set; } - [PluginService] public static IGamepadState GamepadState { get; private set; } - [PluginService] public static IDtrBar DtrBar { get; private set; } - [PluginService] public static IDutyState DutyState { get; private set; } - [PluginService] public static IGameInteropProvider Hook { get; private set; } - [PluginService] public static ITextureProvider Texture { get; private set; } - [PluginService] public static IPluginLog Log { get; private set; } - - internal static bool IsInitialized = false; - public static void Init(DalamudPluginInterface pi) - { - if (IsInitialized) - { - PluginLog.Debug("Services already initialized, skipping"); - } - IsInitialized = true; - try - { - pi.Create(); - } - catch(Exception ex) - { - ex.Log(); - } - } -} \ No newline at end of file diff --git a/ECommons/ECommons/ECommons.csproj b/ECommons/ECommons/ECommons.csproj deleted file mode 100644 index 64f0904..0000000 --- a/ECommons/ECommons/ECommons.csproj +++ /dev/null @@ -1,100 +0,0 @@ - - - - NightmareXIV - 2.1.0.1 - - - - net7.0-windows - x64 - preview - true - false - true - false - bin\$(Configuration)\ - CS1591;CA1401 - true - True - true - true - - - - - true - - - - $(appdata)\xivlauncher\Addon\Hooks\dev\ - - - - $(DALAMUD_HOME)/ - true - - - - preview - - - - - - - - - $(DalamudLibPath)Newtonsoft.Json.dll - False - - - $(DalamudLibPath)Dalamud.dll - False - - - $(DalamudLibPath)Dalamud.Common.dll - False - - - $(DalamudLibPath)ImGui.NET.dll - False - - - $(DalamudLibPath)ImGuiScene.dll - False - - - $(DalamudLibPath)Lumina.dll - False - - - $(DalamudLibPath)Lumina.Excel.dll - False - - - $(DalamudLibPath)FFXIVClientStructs.dll - False - - - $(DalamudLibPath)PInvoke.User32.dll - False - - - $(DalamudLibPath)PInvoke.Windows.Core.dll - False - - - $(DalamudLibPath)SharpDX.Mathematics.dll - False - - - $(DalamudLibPath)Reloaded.Hooks.Definitions.dll - False - - - $(DalamudLibPath)Serilog.dll - False - - - diff --git a/ECommons/ECommons/ECommonsMain.cs b/ECommons/ECommons/ECommonsMain.cs deleted file mode 100644 index 237b799..0000000 --- a/ECommons/ECommons/ECommonsMain.cs +++ /dev/null @@ -1,102 +0,0 @@ -using ECommons.Logging; -using Dalamud.Plugin; -using ECommons.DalamudServices; -using ECommons.GameFunctions; -using ECommons.ImGuiMethods; -using ECommons.ObjectLifeTracker; -using ECommons.Reflection; -using ECommons.SimpleGui; -using ECommons.SplatoonAPI; -using ECommons.Events; -using ECommons.Configuration; -using ECommons.Hooks; -using ECommons.Loader; -using ECommons.Automation; -using ECommons.StringHelpers; -using Dalamud.Utility; -using ECommons.Commands; -using ECommons.Throttlers; - -namespace ECommons; - -public static class ECommonsMain -{ - public static IDalamudPlugin Instance = null; - public static bool Disposed { get; private set; } = false; - //test - public static void Init(DalamudPluginInterface pluginInterface, IDalamudPlugin instance, params Module[] modules) - { - Instance = instance; - GenericHelpers.Safe(() => Svc.Init(pluginInterface)); - GenericHelpers.Safe(CmdManager.Init); - if (modules.ContainsAny(Module.All, Module.ObjectFunctions)) - { - PluginLog.Information("Object functions module has been requested"); - GenericHelpers.Safe(ObjectFunctions.Init); - } - if (modules.ContainsAny(Module.All, Module.DalamudReflector, Module.SplatoonAPI)) - { - PluginLog.Information("Advanced Dalamud reflection module has been requested"); - GenericHelpers.Safe(DalamudReflector.Init); - } - if (modules.ContainsAny(Module.All, Module.ObjectLife)) - { - PluginLog.Information("Object life module has been requested"); - GenericHelpers.Safe(ObjectLife.Init); - } - if(modules.ContainsAny(Module.All, Module.SplatoonAPI)) - { - PluginLog.Information("Splatoon API module has been requested"); - GenericHelpers.Safe(Splatoon.Init); - } - } - - public static void Dispose() - { - Disposed = true; - GenericHelpers.Safe(PluginLoader.Dispose); - GenericHelpers.Safe(CmdManager.Dispose); - if (EzConfig.Config != null) - { - GenericHelpers.Safe(EzConfig.Save); - } - GenericHelpers.Safe(ThreadLoadImageHandler.Dispose); - GenericHelpers.Safe(ObjectLife.Dispose); - GenericHelpers.Safe(DalamudReflector.Dispose); - if (EzConfigGui.WindowSystem != null) - { - Svc.PluginInterface.UiBuilder.OpenConfigUi -= EzConfigGui.Open; - Svc.PluginInterface.UiBuilder.Draw -= EzConfigGui.Draw; - if (EzConfigGui.Config != null) - { - Svc.PluginInterface.SavePluginConfig(EzConfigGui.Config); - Notify.Info("Configuration saved"); - } - EzConfigGui.WindowSystem.RemoveAllWindows(); - EzConfigGui.WindowSystem = null; - } - foreach (var x in EzCmd.RegisteredCommands) - { - Svc.Commands.RemoveHandler(x); - } - if (Splatoon.Instance != null) - { - GenericHelpers.Safe(Splatoon.Reset); - } - GenericHelpers.Safe(Splatoon.Shutdown); - GenericHelpers.Safe(ProperOnLogin.Dispose); - GenericHelpers.Safe(DirectorUpdate.Dispose); - GenericHelpers.Safe(ActionEffect.Dispose); - GenericHelpers.Safe(MapEffect.Dispose); - GenericHelpers.Safe(SendAction.Dispose); - GenericHelpers.Safe(TaskManager.DisposeAll); - GenericHelpers.Safe(EqualStrings.Dispose); - GenericHelpers.Safe(AutoCutsceneSkipper.Dispose); - GenericHelpers.Safe(() => ThreadLoadImageHandler.httpClient?.Dispose()); - EzThrottler.Throttler = null; - FrameThrottler.Throttler = null; - GenericHelpers.Safe(Callback.Dispose); - Chat.instance = null; - Instance = null; - } -} diff --git a/ECommons/ECommons/Events/ProperOnLogin.cs b/ECommons/ECommons/Events/ProperOnLogin.cs deleted file mode 100644 index dd1a965..0000000 --- a/ECommons/ECommons/Events/ProperOnLogin.cs +++ /dev/null @@ -1,87 +0,0 @@ -using ECommons.Logging; -using ECommons.DalamudServices; -using System; -using System.Collections.Generic; - -namespace ECommons.Events; - -public static class ProperOnLogin -{ - static HashSet RegisteredActions = new(); - static bool EventRegistered = false; - - public static bool PlayerPresent => Svc.ClientState.LocalPlayer != null && Svc.ClientState.LocalContentId != 0; - - public static void Register(Action action, bool fireImmediately = false) - { - if (RegisteredActions.Contains(action)) - { - PluginLog.Warning($"{action.GetType().FullName} ProperOnLogin event is already registered!"); - } - else - { - RegisteredActions.Add(action); - PluginLog.Debug($"Registered ProperOnLogin event: {action.GetType().FullName}"); - if (!EventRegistered) - { - EventRegistered = true; - Svc.ClientState.Login += OnLogin; - PluginLog.Debug("ProperOnLogin master event registered"); - } - if(fireImmediately && PlayerPresent) - { - GenericHelpers.Safe(action); - } - } - } - - [Obsolete("This event is automatically disposed together with ECommons")] - public static void Unregister(Action action) - { - if (!RegisteredActions.Contains(action)) - { - PluginLog.Warning($"{action.GetType().FullName} ProperOnLogin event is not registered!"); - } - else - { - RegisteredActions.Remove(action); - PluginLog.Debug($"Unregistered ProperOnLogin event: {action.GetType().FullName}"); - } - } - - static void OnLogin() - { - Svc.Framework.Update += OnUpdate; - PluginLog.Debug("Registering ProperOnLogin event's framework update"); - } - - static void OnUpdate(object _) - { - if(PlayerPresent) - { - PluginLog.Debug("Firing ProperOnLogin event and unregistering framework update"); - Svc.Framework.Update -= OnUpdate; - foreach(var x in RegisteredActions) - { - try - { - x(); - } - catch(Exception e) - { - PluginLog.Error($"Exception while processing ProperOnLogin event in {x.GetType().FullName}"); - e.Log(); - } - } - } - } - - internal static void Dispose() - { - if (EventRegistered) - { - Svc.ClientState.Login -= OnLogin; - PluginLog.Debug("ProperOnLogin master event unregistered"); - } - } -} diff --git a/ECommons/ECommons/ExcelResolver.cs b/ECommons/ECommons/ExcelResolver.cs deleted file mode 100644 index 0a6dc4b..0000000 --- a/ECommons/ECommons/ExcelResolver.cs +++ /dev/null @@ -1,84 +0,0 @@ -using Dalamud; -using Lumina.Excel; -using System; -using System.Collections.Generic; -using ECommons.DalamudServices; - -#nullable enable -namespace ECommons; - -/// -/// This object resolves a rowID within an Excel sheet. -/// -/// The type of Lumina sheet to resolve. -public class ExcelResolver : IEquatable> where T : ExcelRow -{ - /// - /// Initializes a new instance of the class. - /// - /// The ID of the classJob. - public ExcelResolver(uint id) - { - this.Id = id; - } - - public ExcelResolver(Dalamud.Game.ClientState.Resolvers.ExcelResolver dalamudResolver) - { - this.Id = dalamudResolver.Id; - } - - /// - /// Gets the ID to be resolved. - /// - public uint Id { get; } - - /// - /// Gets GameData linked to this excel row. - /// - public T? GameData => Svc.Data.GetExcelSheet()?.GetRow(this.Id); - - public override bool Equals(object? obj) - { - return obj is ExcelResolver resolver && - Id == resolver.Id; - } - public bool Equals(ExcelResolver? resolver) - { - return resolver != null && Id == resolver.Id; - } - - public override int GetHashCode() - { - return HashCode.Combine(Id); - } - - /// - /// Gets GameData linked to this excel row with the specified language. - /// - /// The language. - /// The ExcelRow in the specified language. - public T? GetWithLanguage(ClientLanguage language) => Svc.Data.GetExcelSheet(language)?.GetRow(this.Id); - - public static bool operator ==(ExcelResolver? left, ExcelResolver? right) - { - return EqualityComparer>.Default.Equals(left, right); - } - - public static bool operator !=(ExcelResolver? left, ExcelResolver? right) - { - return !(left == right); - } - - public bool ShouldSerializeGameData() - { - return false; - } -} - -public static class ExcelResolverExtensions -{ - public static ExcelResolver ToECommons(this Dalamud.Game.ClientState.Resolvers.ExcelResolver dalamudResolver) where T : ExcelRow - { - return new ExcelResolver(dalamudResolver); - } -} diff --git a/ECommons/ECommons/ExcelServices/ExcelActionHelper.cs b/ECommons/ECommons/ExcelServices/ExcelActionHelper.cs deleted file mode 100644 index 8ae5905..0000000 --- a/ECommons/ECommons/ExcelServices/ExcelActionHelper.cs +++ /dev/null @@ -1,13 +0,0 @@ -using ECommons.DalamudServices; -using FFXIVClientStructs.FFXIV.Client.Game; - -namespace ECommons.ExcelServices; - -public unsafe static class ExcelActionHelper -{ - public static float GetActionCooldown(uint id) - { - var detail = ActionManager.Instance()->GetRecastGroupDetail(Svc.Data.GetExcelSheet().GetRow(id).CooldownGroup - 1); - return detail->IsActive == 1 ? detail->Total - detail->Elapsed : 0; - } -} diff --git a/ECommons/ECommons/ExcelServices/ExcelJobHelper.cs b/ECommons/ECommons/ExcelServices/ExcelJobHelper.cs deleted file mode 100644 index f70a5a7..0000000 --- a/ECommons/ECommons/ExcelServices/ExcelJobHelper.cs +++ /dev/null @@ -1,38 +0,0 @@ -using ECommons.DalamudServices; -using Lumina.Excel.GeneratedSheets; -using System.Linq; - -namespace ECommons.ExcelServices; - -public static class ExcelJobHelper -{ - public static ClassJob GetJobByName(string name) - { - if (Svc.Data.GetExcelSheet().TryGetFirst(x => x.Name.ToString().EqualsIgnoreCase(name), out var result)) - { - return result; - } - return null; - } - - public static bool TryGetJobByName(string name, out ClassJob result) - { - result = GetJobByName(name); - return result != null; - } - - public static ClassJob GetJobById(uint id) - { - return Svc.Data.GetExcelSheet().GetRow(id); - } - - public static string GetJobNameById(uint id) - { - return GetJobById(id)?.Name.ToString(); - } - - public static ClassJob[] GetCombatJobs() - { - return Svc.Data.GetExcelSheet().Where(x => x.Role.EqualsAny(2, 3)).ToArray(); - } -} diff --git a/ECommons/ECommons/ExcelServices/ExcelTerritoryHelper.cs b/ECommons/ECommons/ExcelServices/ExcelTerritoryHelper.cs deleted file mode 100644 index e62294c..0000000 --- a/ECommons/ECommons/ExcelServices/ExcelTerritoryHelper.cs +++ /dev/null @@ -1,76 +0,0 @@ -using ECommons.Logging; -using ECommons.ExcelServices.TerritoryEnumeration; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using ECommons.DalamudServices; -using Lumina.Excel.GeneratedSheets; - -namespace ECommons.ExcelServices -{ - public static class ExcelTerritoryHelper - { - static uint[] Sanctuaries = null; - - /// - /// Checks if territory belongs to main cities, inns, residential areas or houses. - /// - /// - /// - public static bool IsSanctuary(uint territoryType) - { - if(Sanctuaries == null) - { - var f = BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy; - var s = new List(); - typeof(MainCities).GetFields(f) - .Union(typeof(Inns).GetFields(f)) - .Union(typeof(ResidentalAreas).GetFields(f)) - .Union(typeof(Houses).GetFields(f)) - .Each(x => - { - var v = (ushort)x.GetValue(null); - s.Add(v); - PluginLog.Verbose($"Sanctuary territory added: {x.Name} = {v}"); - }); - - Sanctuaries = s.ToArray(); - } - - return Sanctuaries.Contains(territoryType); - } - - /// - /// Gets fancy name for a territory. - /// - /// Zone ID - /// Whether to include an ID into name - /// Content finder condition if exists; otherwise - zone name if exists; otherwise - zone ID as a string - public static string GetName(uint TerritoryType, bool includeID = false) - { - var data = Svc.Data.GetExcelSheet().GetRow(TerritoryType); - string id = includeID?$"#{TerritoryType} | ":""; - if (data == null) return $"#{TerritoryType}"; - var tname = data.PlaceName.Value?.Name?.ToString(); - var cfc = data.ContentFinderCondition.Value.Name?.ToString(); - if (cfc.IsNullOrEmpty()) - { - if (tname.IsNullOrEmpty()) - { - return $"#{TerritoryType}"; - } - else - { - return $"{id}{tname}"; - } - } - else - { - return $"{id}{cfc}"; - } - } - } -} diff --git a/ECommons/ECommons/ExcelServices/ExcelWorldHelper.cs b/ECommons/ECommons/ExcelServices/ExcelWorldHelper.cs deleted file mode 100644 index eb7da5f..0000000 --- a/ECommons/ECommons/ExcelServices/ExcelWorldHelper.cs +++ /dev/null @@ -1,55 +0,0 @@ -using ECommons.DalamudServices; -using Lumina.Excel.GeneratedSheets; -using System; -using System.Linq; - -namespace ECommons.ExcelServices; - -public static class ExcelWorldHelper -{ - public static World GetWorldByName(string name) - { - if(Svc.Data.GetExcelSheet().TryGetFirst(x => x.Name.ToString().EqualsIgnoreCase(name), out var result)) - { - return result; - } - return null; - } - - public static bool? TryGetWorldByName(string name, out World result) - { - result = GetWorldByName(name); - return result != null; - } - - public static World[] GetPublicWorlds(Region? region) - { - return Svc.Data.GetExcelSheet().Where(x => ((region == null && x.Region.EqualsAny(Enum.GetValues().Select(z => (byte)z).ToArray())) || (region.HasValue && x.Region == (byte)region.Value)) && x.IsPublic).ToArray(); - } - - public static World GetWorldById(uint id) - { - return Svc.Data.GetExcelSheet().GetRow(id); - } - - public static string GetWorldNameById(uint id) - { - return GetWorldById(id)?.Name.ToString(); - } - - public static World GetPublicWorldById(uint id) - { - var data = Svc.Data.GetExcelSheet().GetRow(id); - if (data.Region.EqualsAny(Enum.GetValues().Select(z => (byte)z).ToArray())) - { - return data; - } - return null; - } - - - public static string GetPublicWorldNameById(uint id) - { - return GetPublicWorldById(id)?.Name.ToString(); - } -} diff --git a/ECommons/ECommons/ExcelServices/Job.cs b/ECommons/ECommons/ExcelServices/Job.cs deleted file mode 100644 index 4980585..0000000 --- a/ECommons/ECommons/ExcelServices/Job.cs +++ /dev/null @@ -1,212 +0,0 @@ -using System.Reflection; - -namespace ECommons.ExcelServices; - -[Obfuscation(Exclude = true, ApplyToMembers = true)] -public enum Job : uint -{ - /// - /// Adventurer - /// - ADV = 0, - - /// - /// Gladiator - /// - GLA = 1, - - /// - /// Pugilist - /// - PGL = 2, - - /// - /// Marauder - /// - MRD = 3, - - /// - /// Lancer - /// - LNC = 4, - - /// - /// Archer - /// - ARC = 5, - - /// - /// Conjurer - /// - CNJ = 6, - - /// - /// Thaumaturge - /// - THM = 7, - - /// - /// Carpenter - /// - CRP = 8, - - /// - /// Blacksmith - /// - BSM = 9, - - /// - /// Armorer - /// - ARM = 10, - - /// - /// Goldsmith - /// - GSM = 11, - - /// - /// Leatherworker - /// - LTW = 12, - - /// - /// Weaver - /// - WVR = 13, - - /// - /// Alchemist - /// - ALC = 14, - - /// - /// Culinarian - /// - CUL = 15, - - /// - /// Miner - /// - MIN = 16, - - /// - /// Botanist - /// - BTN = 17, - - /// - /// Fisher - /// - FSH = 18, - - /// - /// Paladin - /// - PLD = 19, - - /// - /// Monk - /// - MNK = 20, - - /// - /// Warrior - /// - WAR = 21, - - /// - /// Dragoon - /// - DRG = 22, - - /// - /// Bard - /// - BRD = 23, - - /// - /// WhiteMage - /// - WHM = 24, - - /// - /// BlackMage - /// - BLM = 25, - - /// - /// Arcanist - /// - ACN = 26, - - /// - /// Summoner - /// - SMN = 27, - - /// - /// Scholar - /// - SCH = 28, - - /// - /// Rogue - /// - ROG = 29, - - /// - /// Ninja - /// - NIN = 30, - - /// - /// Machinist - /// - MCH = 31, - - /// - /// DarkKnight - /// - DRK = 32, - - /// - /// Astrologian - /// - AST = 33, - - /// - /// Samurai - /// - SAM = 34, - - /// - /// RedMage - /// - RDM = 35, - - /// - /// BlueMage - /// - BLU = 36, - - /// - /// Gunbreaker - /// - GNB = 37, - - /// - /// Dancer - /// - DNC = 38, - - /// - /// Reaper - /// - RPR = 39, - - /// - /// Sage - /// - SGE = 40, -} diff --git a/ECommons/ECommons/ExcelServices/Region.cs b/ECommons/ECommons/ExcelServices/Region.cs deleted file mode 100644 index e4c0b4a..0000000 --- a/ECommons/ECommons/ExcelServices/Region.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Reflection; - -namespace ECommons.ExcelServices; - -[Obfuscation(Exclude = true, ApplyToMembers = true)] -public enum Region -{ - JP = 1, NA = 2, EU = 3, OC = 4 -} diff --git a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/AllianceRaids.cs b/ECommons/ECommons/ExcelServices/TerritoryEnumeration/AllianceRaids.cs deleted file mode 100644 index f5bc693..0000000 --- a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/AllianceRaids.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.ExcelServices.TerritoryEnumeration -{ - [Obfuscation(Exclude = true, ApplyToMembers = true)] - public static class AllianceRaids - { - public const ushort the_World_of_Darkness = 151; - public const ushort the_Labyrinth_of_the_Ancients = 174; - public const ushort Syrcus_Tower = 372; - public const ushort the_Void_Ark = 508; - public const ushort the_Weeping_City_of_Mhach = 556; - public const ushort Dun_Scaith = 627; - public const ushort the_Royal_City_of_Rabanastre = 734; - public const ushort the_Ridorana_Lighthouse = 776; - public const ushort the_Orbonne_Monastery = 826; - public const ushort The_Copied_Factory = 882; - public const ushort the_Puppets_Bunker = 917; - public const ushort The_Tower_at_Paradigms_Breach = 966; - public const ushort Aglaia = 1054; - - static ushort[] list = null; - public static ushort[] List - { - get - { - if (list == null) - { - var s = new List(); - typeof(AllianceRaids).GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).Each(x => s.Add((ushort)x.GetValue(null))); - list = s.ToArray(); - } - return list; - } - } - } -} diff --git a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/Dungeons.cs b/ECommons/ECommons/ExcelServices/TerritoryEnumeration/Dungeons.cs deleted file mode 100644 index d55983a..0000000 --- a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/Dungeons.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.ExcelServices.TerritoryEnumeration -{ - [Obfuscation(Exclude = true, ApplyToMembers = true)] - public static class Dungeons - { - public const ushort the_Wanderers_Palace = 159; - public const ushort Pharos_Sirius = 160; - public const ushort Halatali = 162; - public const ushort the_Sunken_Temple_of_Qarn = 163; - public const ushort Amdapor_Keep = 167; - public const ushort Cutters_Cry = 170; - public const ushort Dzemael_Darkhold = 171; - public const ushort the_Aurum_Vale = 172; - public const ushort the_Wanderers_Palace_Hard = 188; - public const ushort Amdapor_Keep_Hard = 189; - public const ushort Under_the_Armor = 190; - public const ushort Pulling_Poison_Posies = 191; - public const ushort Stinging_Back = 192; - public const ushort Basic_Training_Enemy_Parties = 214; - public const ushort Basic_Training_Enemy_Strongholds = 215; - public const ushort Hero_on_the_Half_Shell = 216; - public const ushort Flicking_Sticks_and_Taking_Names = 219; - public const ushort Alls_Well_that_Ends_in_the_Well = 220; - public const ushort More_than_a_Feeler = 221; - public const ushort Annoy_the_Void = 222; - public const ushort Shadow_and_Claw = 223; - public const ushort Long_Live_the_Queen = 298; - public const ushort Ward_Up = 299; - public const ushort Solemn_Trinity = 300; - public const ushort Copperbell_Mines_Hard = 349; - public const ushort Haukke_Manor_Hard = 350; - public const ushort Halatali_Hard = 360; - public const ushort Hullbreaker_Isle = 361; - public const ushort Brayfloxs_Longstop_Hard = 362; - public const ushort the_Lost_City_of_Amdapor = 363; - public const ushort the_Stone_Vigil_Hard = 365; - public const ushort Battle_on_the_Big_Bridge = 366; - public const ushort the_Sunken_Temple_of_Qarn_Hard = 367; - public const ushort the_Tam_Tara_Deepcroft_Hard = 373; - public const ushort Sastasha_Hard = 387; - public const ushort Battle_in_the_Big_Keep = 396; - public const ushort the_Great_Gubal_Library = 416; - public const ushort Neverreap = 420; - public const ushort the_Fractal_Continuum = 430; - public const ushort the_Dusk_Vigil = 434; - public const ushort the_Aetherochemical_Research_Facility = 438; - public const ushort Pharos_Sirius_Hard = 510; - public const ushort Saint_Mociannes_Arboretum = 511; - public const ushort the_Antitower = 516; - public const ushort the_Lost_City_of_Amdapor_Hard = 519; - public const ushort Sohr_Khai = 555; - public const ushort Hullbreaker_Isle_Hard = 557; - public const ushort Xelphatol = 572; - public const ushort the_Great_Gubal_Library_Hard = 578; - public const ushort Baelsars_Wall = 615; - public const ushort Shisui_of_the_Violet_Tides = 616; - public const ushort Sohm_Al_Hard = 617; - public const ushort Bardams_Mettle = 623; - public const ushort The_Sirensong_Sea = 626; - public const ushort Doma_Castle = 660; - public const ushort Castrum_Abania = 661; - public const ushort Kugane_Castle = 662; - public const ushort The_Temple_of_the_Fist = 663; - public const ushort Ala_Mhigo = 689; - public const ushort the_Drowned_City_of_Skalla = 731; - public const ushort Hells_Lid = 742; - public const ushort the_Fractal_Continuum_Hard = 743; - public const ushort the_Swallows_Compass = 768; - public const ushort Saint_Mociannes_Arboretum_Hard = 788; - public const ushort the_Burn = 789; - public const ushort the_Ghimlyt_Dark = 793; - public const ushort Dohn_Mheg = 821; - public const ushort Mt_Gulg = 822; - public const ushort the_Qitana_Ravel = 823; - public const ushort The_Manderville_Tables = 831; - public const ushort The_Gold_Saucer = 832; - public const ushort Malikahs_Well = 836; - public const ushort Holminster_Switch = 837; - public const ushort Amaurot = 838; - public const ushort the_Twinning = 840; - public const ushort Akadaemia_Anyder = 841; - public const ushort The_Grand_Cosmos = 884; - public const ushort Anamnesis_Anyder = 898; - public const ushort the_Heroes_Gauntlet = 916; - public const ushort Matoyas_Relict = 933; - public const ushort Paglthan = 938; - public const ushort The_Tower_of_Zot = 952; - public const ushort The_Tower_of_Babil = 969; - public const ushort Vanaspati = 970; - public const ushort The_Dead_Ends = 973; - public const ushort Ktisis_Hyperboreia = 974; - public const ushort Smileton = 976; - public const ushort The_Aitiascope = 978; - public const ushort The_Stigma_Dreamscape = 986; - public const ushort Sastasha = 1036; - public const ushort the_Tam_Tara_Deepcroft = 1037; - public const ushort Copperbell_Mines = 1038; - public const ushort the_Thousand_Maws_of_Toto_Rak = 1039; - public const ushort Haukke_Manor = 1040; - public const ushort Brayfloxs_Longstop = 1041; - public const ushort the_Stone_Vigil = 1042; - public const ushort Castrum_Meridianum = 1043; - public const ushort the_Praetorium = 1044; - public const ushort Alzadaals_Legacy = 1050; - public const ushort Snowcloak = 1062; - public const ushort the_Keeper_of_the_Lake = 1063; - public const ushort Sohm_Al = 1064; - public const ushort the_Aery = 1065; - public const ushort the_Vault = 1066; - public const ushort the_Fell_Court_of_Troia = 1070; - - static ushort[] list = null; - public static ushort[] List - { - get - { - if (list == null) - { - var s = new List(); - typeof(Dungeons).GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).Each(x => s.Add((ushort)x.GetValue(null))); - list = s.ToArray(); - } - return list; - } - } - } -} diff --git a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/Houses.cs b/ECommons/ECommons/ExcelServices/TerritoryEnumeration/Houses.cs deleted file mode 100644 index 7d351bf..0000000 --- a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/Houses.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.ExcelServices.TerritoryEnumeration -{ - [Obfuscation(Exclude = true, ApplyToMembers = true)] - public static class Houses - { - public const ushort Private_Cottage_Mist = 282; - public const ushort Private_House_Mist = 283; - public const ushort Private_Mansion_Mist = 284; - public const ushort Private_Cottage_The_Lavender_Beds = 342; - public const ushort Private_House_The_Lavender_Beds = 343; - public const ushort Private_Mansion_The_Lavender_Beds = 344; - public const ushort Private_Cottage_The_Goblet = 345; - public const ushort Private_House_The_Goblet = 346; - public const ushort Private_Mansion_The_Goblet = 347; - public const ushort Private_Chambers_Mist = 384; - public const ushort Private_Chambers_The_Lavender_Beds = 385; - public const ushort Private_Chambers_The_Goblet = 386; - public const ushort Company_Workshop_Mist = 423; - public const ushort Company_Workshop_The_Goblet = 424; - public const ushort Company_Workshop_The_Lavender_Beds = 425; - public const ushort Topmast_Apartment_Lobby = 573; - public const ushort Lily_Hills_Apartment_Lobby = 574; - public const ushort Sultanas_Breath_Apartment_Lobby = 575; - public const ushort Topmast_Apartment = 608; - public const ushort Lily_Hills_Apartment = 609; - public const ushort Sultanas_Breath_Apartment = 610; - public const ushort Private_Cottage_Shirogane = 649; - public const ushort Private_House_Shirogane = 650; - public const ushort Private_Mansion_Shirogane = 651; - public const ushort Private_Chambers_Shirogane = 652; - public const ushort Company_Workshop_Shirogane = 653; - public const ushort Kobai_Goten_Apartment_Lobby = 654; - public const ushort Kobai_Goten_Apartment = 655; - public const ushort Private_Cottage_Empyreum = 980; - public const ushort Private_House_Empyreum = 981; - public const ushort Private_Mansion_Empyreum = 982; - public const ushort Private_Chambers_Empyreum = 983; - public const ushort Company_Workshop_Empyreum = 984; - public const ushort Ingleside_Apartment_Lobby = 985; - public const ushort Ingleside_Apartment = 999; - - static ushort[] list = null; - public static ushort[] List - { - get - { - if (list == null) - { - var s = new List(); - typeof(Houses).GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).Each(x => s.Add((ushort)x.GetValue(null))); - list = s.ToArray(); - } - return list; - } - } - } -} diff --git a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/Inns.cs b/ECommons/ECommons/ExcelServices/TerritoryEnumeration/Inns.cs deleted file mode 100644 index 2b2b189..0000000 --- a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/Inns.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.ExcelServices.TerritoryEnumeration -{ - [Obfuscation(Exclude = true, ApplyToMembers = true)] - public static class Inns - { - public const ushort Mizzenmast_Inn = 177; - public const ushort The_Hourglass = 178; - public const ushort The_Roost = 179; - public const ushort Cloud_Nine = 429; - public const ushort Bokairo_Inn = 629; - public const ushort The_Pendants_Personal_Suite = 843; - public const ushort Andron = 990; - - static ushort[] list = null; - public static ushort[] List - { - get - { - if (list == null) - { - var s = new List(); - typeof(Inns).GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).Each(x => s.Add((ushort)x.GetValue(null))); - list = s.ToArray(); - } - return list; - } - } - } -} diff --git a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/MainCities.cs b/ECommons/ECommons/ExcelServices/TerritoryEnumeration/MainCities.cs deleted file mode 100644 index 08a89ea..0000000 --- a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/MainCities.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.ExcelServices.TerritoryEnumeration -{ - [Obfuscation(Exclude = true, ApplyToMembers = true)] - //intended use 0 - public static class MainCities - { - public const ushort Limsa_Lominsa_Upper_Decks = 128; - public const ushort Limsa_Lominsa_Lower_Decks = 129; - public const ushort Uldah_Steps_of_Nald = 130; - public const ushort Uldah_Steps_of_Thal = 131; - public const ushort New_Gridania = 132; - public const ushort Old_Gridania = 133; - public const ushort Mist = 136; - public const ushort Foundation = 418; - public const ushort The_Pillars = 419; - public const ushort Idyllshire = 478; - public const ushort Kugane = 628; - public const ushort Rhalgrs_Reach = 635; - public const ushort The_Doman_Enclave = 759; - public const ushort The_Crystarium = 819; - public const ushort Eulmore = 820; - public const ushort Old_Sharlayan = 962; - public const ushort Radz_at_Han = 963; - - static ushort[] list = null; - public static ushort[] List - { - get - { - if (list == null) - { - var s = new List(); - typeof(MainCities).GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).Each(x => s.Add((ushort)x.GetValue(null))); - list = s.ToArray(); - } - return list; - } - } - } -} diff --git a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/OpenAreas.cs b/ECommons/ECommons/ExcelServices/TerritoryEnumeration/OpenAreas.cs deleted file mode 100644 index 5c05f64..0000000 --- a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/OpenAreas.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.ExcelServices.TerritoryEnumeration -{ - [Obfuscation(Exclude = true, ApplyToMembers = true)] - public static class OpenAreas // 1 - { - public const ushort Middle_La_Noscea = 134; - public const ushort Lower_La_Noscea = 135; - public const ushort Eastern_La_Noscea = 137; - public const ushort Western_La_Noscea = 138; - public const ushort Upper_La_Noscea = 139; - public const ushort Western_Thanalan = 140; - public const ushort Central_Thanalan = 141; - public const ushort Eastern_Thanalan = 145; - public const ushort Southern_Thanalan = 146; - public const ushort Northern_Thanalan = 147; - public const ushort Central_Shroud = 148; - public const ushort East_Shroud = 152; - public const ushort South_Shroud = 153; - public const ushort North_Shroud = 154; - public const ushort Coerthas_Central_Highlands = 155; - public const ushort Mor_Dhona = 156; - public const ushort Outer_La_Noscea = 180; - public const ushort Wolves_Den_Pier = 250; - public const ushort Coerthas_Western_Highlands = 397; - public const ushort The_Dravanian_Forelands = 398; - public const ushort The_Dravanian_Hinterlands = 399; - public const ushort The_Churning_Mists = 400; - public const ushort The_Sea_of_Clouds = 401; - public const ushort Azys_Lla = 402; - public const ushort The_Fringes = 612; - public const ushort The_Ruby_Sea = 613; - public const ushort Yanxia = 614; - public const ushort The_Peaks = 620; - public const ushort The_Lochs = 621; - public const ushort The_Azim_Steppe = 622; - public const ushort The_Diadem = 630; - public const ushort Lakeland = 813; - public const ushort Kholusia = 814; - public const ushort Amh_Araeng = 815; - public const ushort Il_Mheg = 816; - public const ushort The_Raktika_Greatwood = 817; - public const ushort The_Tempest = 818; - public const ushort Labyrinthos = 956; - public const ushort Thavnair = 957; - public const ushort Garlemald = 958; - public const ushort Mare_Lamentorum = 959; - public const ushort Ultima_Thule = 960; - public const ushort Elpis = 961; - public const ushort Castrum_Marinum_Drydocks = 967; - - static ushort[] list = null; - public static ushort[] List - { - get - { - if (list == null) - { - var s = new List(); - typeof(OpenAreas).GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).Each(x => s.Add((ushort)x.GetValue(null))); - list = s.ToArray(); - } - return list; - } - } - } -} diff --git a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/Prisons.cs b/ECommons/ECommons/ExcelServices/TerritoryEnumeration/Prisons.cs deleted file mode 100644 index fb27064..0000000 --- a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/Prisons.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.ExcelServices.TerritoryEnumeration -{ - [Obfuscation(Exclude = true, ApplyToMembers = true)] - public static class Prisons - { - public const ushort Mordion_Gaol = 176; - - static ushort[] list = null; - public static ushort[] List - { - get - { - if (list == null) - { - var s = new List(); - typeof(Prisons).GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).Each(x => s.Add((ushort)x.GetValue(null))); - list = s.ToArray(); - } - return list; - } - } - } -} diff --git a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/Raids.cs b/ECommons/ECommons/ExcelServices/TerritoryEnumeration/Raids.cs deleted file mode 100644 index f373966..0000000 --- a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/Raids.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.ExcelServices.TerritoryEnumeration -{ - [Obfuscation(Exclude = true, ApplyToMembers = true)] - public static class Raids - { - public const ushort the_Final_Coil_of_Bahamut_Turn_1 = 193; - public const ushort the_Final_Coil_of_Bahamut_Turn_2 = 194; - public const ushort the_Binding_Coil_of_Bahamut_Turn_1 = 241; - public const ushort the_Binding_Coil_of_Bahamut_Turn_3 = 243; - public const ushort the_Binding_Coil_of_Bahamut_Turn_5 = 245; - public const ushort the_Second_Coil_of_Bahamut_Turn_1 = 355; - public const ushort the_Second_Coil_of_Bahamut_Turn_2 = 356; - public const ushort the_Second_Coil_of_Bahamut_Turn_3 = 357; - public const ushort the_Second_Coil_of_Bahamut_Savage_Turn_1 = 380; - public const ushort the_Second_Coil_of_Bahamut_Savage_Turn_2 = 381; - public const ushort the_Second_Coil_of_Bahamut_Savage_Turn_3 = 382; - public const ushort Alexander_The_Fist_of_the_Father = 442; - public const ushort Alexander_The_Cuff_of_the_Father = 443; - public const ushort Alexander_The_Arm_of_the_Father = 444; - public const ushort Alexander_The_Fist_of_the_Father_Savage = 449; - public const ushort Alexander_The_Cuff_of_the_Father_Savage = 450; - public const ushort Alexander_The_Arm_of_the_Father_Savage = 451; - public const ushort Alexander_The_Fist_of_the_Son = 520; - public const ushort Alexander_The_Cuff_of_the_Son = 521; - public const ushort Alexander_The_Arm_of_the_Son = 522; - public const ushort Alexander_The_Fist_of_the_Son_Savage = 529; - public const ushort Alexander_The_Arm_of_the_Son_Savage = 531; - public const ushort Alexander_The_Eyes_of_the_Creator = 580; - public const ushort Alexander_The_Breath_of_the_Creator = 581; - public const ushort Alexander_The_Heart_of_the_Creator = 582; - public const ushort Alexander_The_Eyes_of_the_Creator_Savage = 584; - public const ushort Alexander_The_Breath_of_the_Creator_Savage = 585; - public const ushort Alexander_The_Heart_of_the_Creator_Savage = 586; - - - public const ushort the_Final_Coil_of_Bahamut_Turn_3 = 195; - public const ushort the_Final_Coil_of_Bahamut_Turn_4 = 196; - public const ushort the_Binding_Coil_of_Bahamut_Turn_2 = 242; - public const ushort the_Binding_Coil_of_Bahamut_Turn_4 = 244; - public const ushort the_Second_Coil_of_Bahamut_Turn_4 = 358; - public const ushort the_Second_Coil_of_Bahamut_Savage_Turn_4 = 383; - public const ushort Alexander_The_Burden_of_the_Father = 445; - public const ushort Alexander_The_Burden_of_the_Father_Savage = 452; - public const ushort Alexander_The_Burden_of_the_Son = 523; - public const ushort Alexander_The_Cuff_of_the_Son_Savage = 530; - public const ushort Alexander_The_Burden_of_the_Son_Savage = 532; - public const ushort Alexander_The_Soul_of_the_Creator = 583; - public const ushort Alexander_The_Soul_of_the_Creator_Savage = 587; - public const ushort Deltascape_V1_0 = 691; - public const ushort Deltascape_V2_0 = 692; - public const ushort Deltascape_V3_0 = 693; - public const ushort Deltascape_V4_0 = 694; - public const ushort Deltascape_V1_0_Savage = 695; - public const ushort Deltascape_V2_0_Savage = 696; - public const ushort Deltascape_V3_0_Savage = 697; - public const ushort Deltascape_V4_0_Savage = 698; - public const ushort the_Unending_Coil_of_Bahamut_Ultimate = 733; - public const ushort Sigmascape_V1_0 = 748; - public const ushort Sigmascape_V2_0 = 749; - public const ushort Sigmascape_V3_0 = 750; - public const ushort Sigmascape_V4_0 = 751; - public const ushort Sigmascape_V1_0_Savage = 752; - public const ushort Sigmascape_V2_0_Savage = 753; - public const ushort Sigmascape_V3_0_Savage = 754; - public const ushort Sigmascape_V4_0_Savage = 755; - public const ushort the_Weapons_Refrain_Ultimate = 777; - public const ushort Alphascape_V1_0 = 798; - public const ushort Alphascape_V2_0 = 799; - public const ushort Alphascape_V3_0 = 800; - public const ushort Alphascape_V4_0 = 801; - public const ushort Alphascape_V1_0_Savage = 802; - public const ushort Alphascape_V2_0_Savage = 803; - public const ushort Alphascape_V3_0_Savage = 804; - public const ushort Alphascape_V4_0_Savage = 805; - public const ushort Edens_Gate_Resurrection = 849; - public const ushort Edens_Gate_Descent = 850; - public const ushort Edens_Gate_Inundation = 851; - public const ushort Edens_Gate_Sepulture = 852; - public const ushort Edens_Gate_Resurrection_Savage = 853; - public const ushort Edens_Gate_Descent_Savage = 854; - public const ushort Edens_Gate_Inundation_Savage = 855; - public const ushort Edens_Gate_Sepulture_Savage = 856; - public const ushort The_Epic_of_Alexander_Ultimate = 887; - public const ushort Edens_Verse_Fulmination = 902; - public const ushort Edens_Verse_Furor = 903; - public const ushort Edens_Verse_Iconoclasm = 904; - public const ushort Edens_Verse_Refulgence = 905; - public const ushort Edens_Verse_Fulmination_Savage = 906; - public const ushort Edens_Verse_Furor_Savage = 907; - public const ushort Edens_Verse_Iconoclasm_Savage = 908; - public const ushort Edens_Verse_Refulgence_Savage = 909; - public const ushort Edens_Promise_Umbra = 942; - public const ushort Edens_Promise_Litany = 943; - public const ushort Edens_Promise_Anamorphosis = 944; - public const ushort Edens_Promise_Eternity = 945; - public const ushort Edens_Promise_Umbra_Savage = 946; - public const ushort Edens_Promise_Litany_Savage = 947; - public const ushort Edens_Promise_Anamorphosis_Savage = 948; - public const ushort Edens_Promise_Eternity_Savage = 949; - public const ushort Dragonsongs_Reprise_Ultimate = 968; - public const ushort Asphodelos_The_First_Circle = 1002; - public const ushort Asphodelos_The_First_Circle_Savage = 1003; - public const ushort Asphodelos_The_Second_Circle = 1004; - public const ushort Asphodelos_The_Second_Circle_Savage = 1005; - public const ushort Asphodelos_The_Third_Circle = 1006; - public const ushort Asphodelos_The_Third_Circle_Savage = 1007; - public const ushort Asphodelos_The_Fourth_Circle = 1008; - public const ushort Asphodelos_The_Fourth_Circle_Savage = 1009; - public const ushort Abyssos_The_Fifth_Circle = 1081; - public const ushort Abyssos_The_Fifth_Circle_Savage = 1082; - public const ushort Abyssos_The_Sixth_Circle = 1083; - public const ushort Abyssos_The_Sixth_Circle_Savage = 1084; - public const ushort Abyssos_The_Seventh_Circle = 1085; - public const ushort Abyssos_The_Seventh_Circle_Savage = 1086; - public const ushort Abyssos_The_Eighth_Circle = 1087; - public const ushort Abyssos_The_Eighth_Circle_Savage = 1088; - public const ushort The_Omega_Protocol_Ultimate = 1122; - - static ushort[] list = null; - public static ushort[] List - { - get - { - if (list == null) - { - var s = new List(); - typeof(Raids).GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).Each(x => s.Add((ushort)x.GetValue(null))); - list = s.ToArray(); - } - return list; - } - } - } -} diff --git a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/ResidentalAreas.cs b/ECommons/ECommons/ExcelServices/TerritoryEnumeration/ResidentalAreas.cs deleted file mode 100644 index 5b12768..0000000 --- a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/ResidentalAreas.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.ExcelServices.TerritoryEnumeration -{ - [Obfuscation(Exclude = true, ApplyToMembers = true)] - public static class ResidentalAreas - { - public const ushort Mist = 339; - public const ushort The_Lavender_Beds = 340; - public const ushort The_Goblet = 341; - public const ushort Shirogane = 641; - public const ushort Empyreum = 979; - - static ushort[] list = null; - public static ushort[] List - { - get - { - if (list == null) - { - var s = new List(); - typeof(ResidentalAreas).GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).Each(x => s.Add((ushort)x.GetValue(null))); - list = s.ToArray(); - } - return list; - } - } - } -} diff --git a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/Trials.cs b/ECommons/ECommons/ExcelServices/TerritoryEnumeration/Trials.cs deleted file mode 100644 index 9fc2c73..0000000 --- a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/Trials.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.ExcelServices.TerritoryEnumeration -{ - [Obfuscation(Exclude = true, ApplyToMembers = true)] - public static class Trials - { - public const ushort the_Dragons_Neck = 142; - public const ushort the_Whorleater_Hard = 281; - public const ushort the_Bowl_of_Embers_Hard = 292; - public const ushort the_Navel_Hard = 293; - public const ushort the_Howling_Eye_Hard = 294; - public const ushort the_Bowl_of_Embers_Extreme = 295; - public const ushort the_Navel_Extreme = 296; - public const ushort the_Howling_Eye_Extreme = 297; - public const ushort the_Minstrels_Ballad_Ultimas_Bane = 348; - public const ushort Special_Event_I = 353; - public const ushort Special_Event_II = 354; - public const ushort the_Whorleater_Extreme = 359; - public const ushort Thornmarch_Extreme = 364; - public const ushort A_Relic_Reborn_the_Chimera = 368; - public const ushort A_Relic_Reborn_the_Hydra = 369; - public const ushort the_Striking_Tree_Hard = 374; - public const ushort the_Striking_Tree_Extreme = 375; - public const ushort the_Akh_Afah_Amphitheatre_Hard = 377; - public const ushort the_Akh_Afah_Amphitheatre_Extreme = 378; - public const ushort Urths_Fount = 394; - public const ushort the_Chrysalis = 426; - public const ushort Thok_ast_Thok_Hard = 432; - public const ushort the_Limitless_Blue_Hard = 436; - public const ushort the_Singularity_Reactor = 437; - public const ushort Thok_ast_Thok_Extreme = 446; - public const ushort the_Limitless_Blue_Extreme = 447; - public const ushort the_Minstrels_Ballad_Thordans_Reign = 448; - public const ushort Special_Event_III = 509; - public const ushort Containment_Bay_S1T7 = 517; - public const ushort Containment_Bay_S1T7_Extreme = 524; - public const ushort the_Final_Steps_of_Faith = 559; - public const ushort the_Minstrels_Ballad_Nidhoggs_Rage = 566; - public const ushort Containment_Bay_P1T6 = 576; - public const ushort Containment_Bay_P1T6_Extreme = 577; - public const ushort Containment_Bay_Z1T9 = 637; - public const ushort Containment_Bay_Z1T9_Extreme = 638; - public const ushort the_Pool_of_Tribute = 674; - public const ushort the_Pool_of_Tribute_Extreme = 677; - public const ushort the_Royal_Menagerie = 679; - public const ushort Emanation = 719; - public const ushort Emanation_Extreme = 720; - public const ushort the_Minstrels_Ballad_Shinryus_Domain = 730; - public const ushort the_Jade_Stoa = 746; - public const ushort the_Jade_Stoa_Extreme = 758; - public const ushort the_Great_Hunt = 761; - public const ushort the_Great_Hunt_Extreme = 762; - public const ushort Castrum_Fluminis = 778; - public const ushort the_Minstrels_Ballad_Tsukuyomis_Pain = 779; - public const ushort Kugane_Ohashi = 806; - public const ushort Hells_Kier = 810; - public const ushort Hells_Kier_Extreme = 811; - public const ushort the_Wreath_of_Snakes = 824; - public const ushort the_Wreath_of_Snakes_Extreme = 825; - public const ushort The_Dancing_Plague = 845; - public const ushort The_Crown_of_the_Immaculate = 846; - public const ushort The_Dying_Gasp = 847; - public const ushort the_Crown_of_the_Immaculate_Extreme = 848; - public const ushort the_Dancing_Plague_Extreme = 858; - public const ushort The_Minstrels_Ballad_Hadess_Elegy = 885; - public const ushort Cinder_Drift = 897; - public const ushort Cinder_Drift_Extreme = 912; - public const ushort Memoria_Misera_Extreme = 913; - public const ushort the_Seat_of_Sacrifice = 922; - public const ushort the_Seat_of_Sacrifice_Extreme = 923; - public const ushort Castrum_Marinum = 934; - public const ushort Castrum_Marinum_Extreme = 935; - public const ushort The_Cloud_Deck = 950; - public const ushort The_Cloud_Deck_Extreme = 951; - public const ushort The_Dark_Inside = 992; - public const ushort The_Minstrels_Ballad_Zodiarks_Fall = 993; - public const ushort The_Mothercrystal = 995; - public const ushort The_Minstrels_Ballad_Hydaelyns_Call = 996; - public const ushort The_Final_Day = 997; - public const ushort The_Minstrels_Ballad_Endsingers_Aria = 998; - public const ushort the_Bowl_of_Embers = 1045; - public const ushort the_Navel = 1046; - public const ushort the_Howling_Eye = 1047; - public const ushort the_Porta_Decumana = 1048; - public const ushort Thornmarch_Hard = 1067; - public const ushort Storms_Crown = 1071; - public const ushort Storms_Crown_Extreme = 1072; - public const ushort Containment_Bay_S1T7_Unreal = 1090; - - static ushort[] list = null; - public static ushort[] List - { - get - { - if (list == null) - { - var s = new List(); - typeof(Trials).GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).Each(x => s.Add((ushort)x.GetValue(null))); - list = s.ToArray(); - } - return list; - } - } - } -} diff --git a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/VariantDungeons.cs b/ECommons/ECommons/ExcelServices/TerritoryEnumeration/VariantDungeons.cs deleted file mode 100644 index 6184adb..0000000 --- a/ECommons/ECommons/ExcelServices/TerritoryEnumeration/VariantDungeons.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.ExcelServices.TerritoryEnumeration -{ - [Obfuscation(Exclude = true, ApplyToMembers = true)] - public static class VariantDungeons - { - public const ushort The_Sildihn_Subterrane = 1069; - - static ushort[] list = null; - public static ushort[] List - { - get - { - if (list == null) - { - var s = new List(); - typeof(VariantDungeons).GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).Each(x => s.Add((ushort)x.GetValue(null))); - list = s.ToArray(); - } - return list; - } - } - } -} diff --git a/ECommons/ECommons/ExcelServices/TerritoryIntendedUse.cs b/ECommons/ECommons/ExcelServices/TerritoryIntendedUse.cs deleted file mode 100644 index 8626eec..0000000 --- a/ECommons/ECommons/ExcelServices/TerritoryIntendedUse.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.ExcelServices -{ - [Obfuscation(Exclude = true, ApplyToMembers = true)] - public enum TerritoryIntendedUse : uint - { - Unknown = 0, - AllianceRaid, - Dungeon, - House, - Inn, - MainCity, - OpenArea, - Prison, - Raid, - OldRaid, - Residential, - Trial, - Variant - } -} diff --git a/ECommons/ECommons/EzCmd.cs b/ECommons/ECommons/EzCmd.cs deleted file mode 100644 index 118c237..0000000 --- a/ECommons/ECommons/EzCmd.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Dalamud.Game.Command; -using ECommons.DalamudServices; -using ECommons.Reflection; -using System; -using System.Collections.Generic; -using static Dalamud.Game.Command.CommandInfo; - -namespace ECommons; - -public static class EzCmd -{ - internal static List RegisteredCommands = new(); - - //[Obsolete("Please use Cmd Attribute to the method in IDalamudPlugin to Add your command.")] - public static void Add(string command, HandlerDelegate action, string helpMessage = null) - { - RegisteredCommands.Add(command); - var cInfo = new CommandInfo(action) - { - HelpMessage = helpMessage ?? "", - ShowInHelp = helpMessage != null - }; - GenericHelpers.Safe(delegate - { - cInfo.SetFoP("LoaderAssemblyName", Svc.PluginInterface.InternalName); - }); - Svc.Commands.AddHandler(command, cInfo); - } -} diff --git a/ECommons/ECommons/GameFunctions/CharacterFunctions.cs b/ECommons/ECommons/GameFunctions/CharacterFunctions.cs deleted file mode 100644 index cbe3882..0000000 --- a/ECommons/ECommons/GameFunctions/CharacterFunctions.cs +++ /dev/null @@ -1,76 +0,0 @@ -using Dalamud.Game.ClientState.Objects.Types; -using ECommons.MathHelpers; -using System; -using System.Collections.Generic; - -namespace ECommons.GameFunctions; - -public static unsafe class CharacterFunctions -{ - public static ushort GetVFXId(void* VfxData) - { - if (VfxData == null) return 0; - return *(ushort*)((IntPtr)(VfxData) + 8); - } - - public static FFXIVClientStructs.FFXIV.Client.Game.Character.Character* Struct(this Character o) - { - return (FFXIVClientStructs.FFXIV.Client.Game.Character.Character*)o.Address; - } - - public static FFXIVClientStructs.FFXIV.Client.Game.Character.BattleChara* Struct(this BattleChara o) - { - return (FFXIVClientStructs.FFXIV.Client.Game.Character.BattleChara*)o.Address; - } - - public static FFXIVClientStructs.FFXIV.Client.Game.Character.Character* Character(this BattleChara o) - { - return (FFXIVClientStructs.FFXIV.Client.Game.Character.Character*)o.Address; - } - - public static FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* GameObject(this BattleChara o) - { - return (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)o.Address; - } - - public static FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* GameObject(this Character o) - { - return (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)o.Address; - } - - public static bool IsCharacterVisible(this Character chr) - { - var v = (IntPtr)(((FFXIVClientStructs.FFXIV.Client.Game.Character.Character*)chr.Address)->GameObject.DrawObject); - if (v == IntPtr.Zero) return false; - return Bitmask.IsBitSet(*(byte*)(v + 136), 0); - } - - public static byte GetTransformationID(this Character chr) - { - return *(byte*)(chr.Address + 3120); - } - - public static CombatRole GetRole(this Character c) - { - if (c.ClassJob.GameData.Role == 1) return CombatRole.Tank; - if (c.ClassJob.GameData.Role == 2) return CombatRole.DPS; - if (c.ClassJob.GameData.Role == 3) return CombatRole.DPS; - if (c.ClassJob.GameData.Role == 4) return CombatRole.Healer; - return CombatRole.NonCombat; - } - - public static bool IsCasting(this BattleChara c, uint spellId = 0) - { - return c.IsCasting && (spellId == 0 || c.CastActionId.EqualsAny(spellId)); - } - - public static bool IsCasting(this BattleChara c, params uint[] spellId) - { - return c.IsCasting && c.CastActionId.EqualsAny(spellId); - } - - public static bool IsCasting(this BattleChara c, IEnumerable spellId) - { - return c.IsCasting && c.CastActionId.EqualsAny(spellId); - } -} diff --git a/ECommons/ECommons/GameFunctions/CombatRole.cs b/ECommons/ECommons/GameFunctions/CombatRole.cs deleted file mode 100644 index 0503d7c..0000000 --- a/ECommons/ECommons/GameFunctions/CombatRole.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace ECommons.GameFunctions; - -public enum CombatRole -{ - NonCombat, Tank, Healer, DPS -} diff --git a/ECommons/ECommons/GameFunctions/FakeParty.cs b/ECommons/ECommons/GameFunctions/FakeParty.cs deleted file mode 100644 index 18bbf2c..0000000 --- a/ECommons/ECommons/GameFunctions/FakeParty.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Dalamud.Game.ClientState.Conditions; -using Dalamud.Game.ClientState.Objects.SubKinds; -using ECommons.DalamudServices; -using System.Collections.Generic; - -namespace ECommons.GameFunctions; - -public static class FakeParty -{ - public static IEnumerable Get() - { - if (Svc.Condition[ConditionFlag.DutyRecorderPlayback]) - { - foreach (var x in Svc.Objects) - { - if (x is PlayerCharacter pc) - { - yield return pc; - } - } - } - else - { - foreach(var x in Svc.Party) - { - if(x.GameObject is PlayerCharacter pc) - { - yield return pc; - } - } - } - } -} diff --git a/ECommons/ECommons/GameFunctions/FakePronoun.cs b/ECommons/ECommons/GameFunctions/FakePronoun.cs deleted file mode 100644 index 09bef31..0000000 --- a/ECommons/ECommons/GameFunctions/FakePronoun.cs +++ /dev/null @@ -1,81 +0,0 @@ -using Dalamud.Game.ClientState.Conditions; -using Dalamud.Game.ClientState.Objects.SubKinds; -using ECommons.DalamudServices; -using FFXIVClientStructs.FFXIV.Client.Game.Object; -using System; - -namespace ECommons.GameFunctions; - -public static unsafe class FakePronoun -{ - public static GameObject* Resolve(string pronoun) - { - try - { - if (Svc.Condition[ConditionFlag.DutyRecorderPlayback]) - { - if (uint.TryParse(pronoun[1..2], out var pos)) - { - var i = 0; - foreach (var x in Svc.Objects) - { - if (x is PlayerCharacter pc) - { - i++; - if (i == pos) - { - return (GameObject*)pc.Address; - } - } - } - return null; - } - else - { - if (pronoun.StartsWith("GetUiModule()->GetPronounModule()->ResolvePlaceholder($"{pronoun}", 0, 0); - } - } - catch(Exception e) - { - e.Log(); - return null; - } - } - - static GameObject* GetRolePlaceholder(CombatRole role, int pos) - { - var i = 0; - foreach (var x in Svc.Objects) - { - if (x is PlayerCharacter pc) - { - if (pc.GetRole() == role) - { - i++; - if (i == pos) - { - return (GameObject*)pc.Address; - } - } - } - } - return null; - } -} diff --git a/ECommons/ECommons/GameFunctions/ObjectFunctions.cs b/ECommons/ECommons/GameFunctions/ObjectFunctions.cs deleted file mode 100644 index 12a1093..0000000 --- a/ECommons/ECommons/GameFunctions/ObjectFunctions.cs +++ /dev/null @@ -1,102 +0,0 @@ -using Dalamud.Game.ClientState.Objects.Types; -using Dalamud.Logging; -using ECommons.DalamudServices; -using System; -using System.Numerics; -using System.Runtime.InteropServices; - -namespace ECommons.GameFunctions; - -public static unsafe class ObjectFunctions -{ - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate long GetNameplateColorDelegate(IntPtr ptr); - public static GetNameplateColorDelegate GetNameplateColor; - - public static FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* Struct(this GameObject o) - { - return (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)o.Address; - } - - internal static void Init() - { - GetNameplateColor = Marshal.GetDelegateForFunctionPointer(Svc.SigScanner.ScanText("48 89 74 24 ?? 57 48 83 EC 20 48 8B 35 ?? ?? ?? ?? 48 8B F9 48 85 F6 75 0D")); - } - - [Obsolete($"Use {nameof(GameObject.IsTargetable)}")] - public static bool IsTargetable(this GameObject o) - { - return o.Struct()->GetIsTargetable(); - } - - public static bool IsHostile(this GameObject a) - { - if (GetNameplateColor == null) - { - throw new Exception("GetNameplateColor is null. Have you initialised the ObjectFunctions module on ECommons initialisation?"); - } - var plateType = GetNameplateColor(a.Address); - //7: yellow, can be attacked, not engaged - //8: dead - //9: red, engaged with your party - //11: orange, aggroed to your party but not attacked yet - //10: purple, engaged with other party - return plateType == 7 || plateType == 9 || plateType == 11 || plateType == 10; - } - - public static int GetAttackableEnemyCountAroundPoint(Vector3 point, float radius) - { - int num = 0; - foreach(var o in Svc.Objects) - { - if(o is BattleNpc) - { - var oStruct = (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)o.Address; - if(oStruct->GetIsTargetable() && o.IsHostile() - && Vector3.Distance(point, o.Position) <= radius + o.HitboxRadius) - { - num++; - } - } - } - return num; - } - - public static bool TryGetPartyMemberObjectByObjectId(uint objectId, out GameObject partyMemberObject) - { - if (objectId == Svc.ClientState.LocalPlayer?.ObjectId) - { - partyMemberObject = Svc.ClientState.LocalPlayer; - return true; - } - foreach (var p in Svc.Party) - { - if (p.GameObject?.ObjectId == objectId) - { - partyMemberObject = p.GameObject; - return true; - } - } - partyMemberObject = default; - return false; - } - - public static bool TryGetPartyMemberObjectByAddress(IntPtr address, out GameObject partyMemberObject) - { - if (address == Svc.ClientState.LocalPlayer?.Address) - { - partyMemberObject = Svc.ClientState.LocalPlayer; - return true; - } - foreach (var p in Svc.Party) - { - if (p.GameObject?.Address == address) - { - partyMemberObject = p.GameObject; - return true; - } - } - partyMemberObject = default; - return false; - } -} diff --git a/ECommons/ECommons/GameFunctions/PlayerFunctions.cs b/ECommons/ECommons/GameFunctions/PlayerFunctions.cs deleted file mode 100644 index 399bf09..0000000 --- a/ECommons/ECommons/GameFunctions/PlayerFunctions.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Dalamud.Game.ClientState.Objects.SubKinds; -using Dalamud.Game.ClientState.Objects.Types; -using ECommons.Logging; -using FFXIVClientStructs.FFXIV.Client.System.Framework; -using System; - -namespace ECommons.GameFunctions; - -public unsafe static class PlayerFunctions -{ - public static bool TryGetPlaceholder(this GameObject pc, out int number, bool verbose = false) - { - for(var i = 1; i <= 8; i++) - { - var optr = Framework.Instance()->GetUiModule()->GetPronounModule()->ResolvePlaceholder($"<{i}>", 0, 0); - if(verbose) PluginLog.Debug($"Placeholder {i} value {(optr == null ? "null" : optr->ObjectID)}"); - if (pc.Address == (IntPtr)optr) - { - number = i; - return true; - } - } - number = default; - return false; - } - - public static FFXIVClientStructs.FFXIV.Client.Game.Character.BattleChara* BattleChara(this PlayerCharacter o) - { - return (FFXIVClientStructs.FFXIV.Client.Game.Character.BattleChara*)o.Address; - } - - public static FFXIVClientStructs.FFXIV.Client.Game.Character.Character* Character(this PlayerCharacter o) - { - return (FFXIVClientStructs.FFXIV.Client.Game.Character.Character*)o.Address; - } - - public static FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* GameObject(this PlayerCharacter o) - { - return (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)o.Address; - } -} diff --git a/ECommons/ECommons/GameHelpers/Player.cs b/ECommons/ECommons/GameHelpers/Player.cs deleted file mode 100644 index 857f598..0000000 --- a/ECommons/ECommons/GameHelpers/Player.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Dalamud.Game.ClientState.Objects.SubKinds; -using Dalamud.Game.ClientState.Statuses; -using ECommons.DalamudServices; -using ECommons.GameFunctions; -using FFXIVClientStructs.FFXIV.Client.Game.Character; -using FFXIVClientStructs.FFXIV.Client.Game.Object; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Numerics; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.GameHelpers -{ - public unsafe static class Player - { - public static PlayerCharacter Object => Svc.ClientState.LocalPlayer; - public static bool Available => Svc.ClientState.LocalPlayer != null; - public static bool Interactable => Available && Object.IsTargetable(); - public static ulong CID => Svc.ClientState.LocalContentId; - public static StatusList Status => Svc.ClientState.LocalPlayer.StatusList; - public static string Name => Svc.ClientState.LocalPlayer?.Name.ToString(); - public static int Level => Svc.ClientState.LocalPlayer?.Level ?? 0; - public static bool IsInHomeWorld => Svc.ClientState.LocalPlayer.HomeWorld.Id == Svc.ClientState.LocalPlayer.CurrentWorld.Id; - public static string HomeWorld => Svc.ClientState.LocalPlayer?.HomeWorld.GameData.Name.ToString(); - public static string CurrentWorld => Svc.ClientState.LocalPlayer?.CurrentWorld.GameData.Name.ToString(); - public static Character* Character => (Character*)Svc.ClientState.LocalPlayer.Address; - public static BattleChara* BattleChara => (BattleChara*)Svc.ClientState.LocalPlayer.Address; - public static GameObject* GameObject => (GameObject*)Svc.ClientState.LocalPlayer.Address; - } -} diff --git a/ECommons/ECommons/Gamepad/GamePad.cs b/ECommons/ECommons/Gamepad/GamePad.cs deleted file mode 100644 index fdccf56..0000000 --- a/ECommons/ECommons/Gamepad/GamePad.cs +++ /dev/null @@ -1,60 +0,0 @@ -using Dalamud.Game.ClientState.GamePad; -using ECommons.DalamudServices; -using System.Collections.Generic; - -namespace ECommons.Gamepad -{ - public static class GamePad - { - /// - /// Dictionary containing a mapping of to Playstation / Xbox button names. - /// - public static Dictionary ControllerButtons = new Dictionary() - { - { GamepadButtons.None, "None" }, - { GamepadButtons.DpadUp, "D-Pad Up"}, - { GamepadButtons.DpadLeft, "D-Pad Left" }, - { GamepadButtons.DpadDown, "D-Pad Down" }, - { GamepadButtons.DpadRight, "D-Pad Right" }, - { GamepadButtons.North, "△ / Y" }, - { GamepadButtons.West, "□ / X" }, - { GamepadButtons.South, "X / A" }, - { GamepadButtons.East, "○ / B" }, - { GamepadButtons.L1, "L1 / LB" }, - { GamepadButtons.L2, "L2 / LT" }, - { GamepadButtons.R1, "R1 / RB" }, - { GamepadButtons.R2, "R2 / RT" }, - { GamepadButtons.L3, "L3 / LS" }, - { GamepadButtons.R3, "R3 / RS" }, - { GamepadButtons.Start, "Options / Start" }, - { GamepadButtons.Select, "Share / Back" } - }; - /// - /// Gets the "Enable gamepad" option from FFXIV to indicate if the gamepad has been enabled in FFXIV. - /// - /// FFXIV is using a controller. - public static bool IsControllerEnabled() { Svc.GameConfig.TryGet(Dalamud.Game.Config.SystemConfigOption.PadAvailable, out bool enabled); return enabled; } - - /// - /// Checks if a controller button has been pressed. Only true on the first frame it has been pressed. - /// - /// Button to check. - /// Button has just been pressed. - public static bool IsButtonPressed(GamepadButtons button) => Svc.GamepadState.Pressed(button) == 1; - - /// - /// Checks if a controller button is currently held. Returns true for every frame it's held down. - /// - /// Button to check. - /// Button is being held down. - public static bool IsButtonHeld(GamepadButtons button) => Svc.GamepadState.Raw(button) == 1; - - /// - /// Checks if a controller button has just been released. Only true on the first frame after releasing. - /// - /// Button to check. - /// Button has just been released. - public static bool IsButtonJustReleased(GamepadButtons button) => Svc.GamepadState.Released(button) == 1; - - } -} diff --git a/ECommons/ECommons/GenericHelpers.cs b/ECommons/ECommons/GenericHelpers.cs deleted file mode 100644 index e5eb84a..0000000 --- a/ECommons/ECommons/GenericHelpers.cs +++ /dev/null @@ -1,1027 +0,0 @@ -using Dalamud.Game.ClientState.Conditions; -using Dalamud.Game.Text.SeStringHandling; -using Dalamud.Game.Text.SeStringHandling.Payloads; -using ECommons.Logging; -using Dalamud.Utility; -using ECommons.ChatMethods; -using ECommons.DalamudServices; -using ECommons.ImGuiMethods; -using FFXIVClientStructs.FFXIV.Component.GUI; -using ImGuiNET; -using Lumina.Excel.GeneratedSheets; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Numerics; -using System.Text; -using System.Diagnostics.CodeAnalysis; -using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType; -using ECommons.ExcelServices.TerritoryEnumeration; -using Newtonsoft.Json; -using FFXIVClientStructs.FFXIV.Client.System.String; -using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; -using Dalamud.Memory; -using Dalamud.Game.ClientState.Objects.Types; -using ECommons.MathHelpers; -using PInvoke; -using System.Windows.Forms; -using System.Threading; -using ECommons.Interop; -using System.Drawing; -using ImGuiScene; -using Dalamud.Game.ClientState.Objects; -using Dalamud.Plugin.Services; -using Dalamud.Game.Text; - -namespace ECommons; - -public static unsafe class GenericHelpers -{ - - public static T[] Together(this T[] array, params T[] additionalValues) - { - return array.Union(additionalValues).ToArray(); - } - - /// - /// Returns when is , otherwise - /// - /// - /// - /// - public static string NullWhenFalse(this string s, bool b) - { - return b?s:null; - } - - /// - /// Returns representation of . - /// - /// - /// - public static uint AsUInt32(this float f) - { - return *(uint*)&f; - } - - /// - /// Converts representation of into . - /// - /// - /// - public static float AsFloat(this uint u) - { - return *(float*)&u; - } - - /// - /// Tries to add multiple items to collection - /// - /// Collection type - /// Collection - /// Items - public static void Add(this ICollection collection, params T[] values) - { - foreach (var x in values) - { - collection.Add(x); - } - } - - /// - /// Tries to remove multiple items to collection. In case if few of the same values are present in the collection, only first will be removed. - /// - /// Collection type - /// Collection - /// Items - public static void Remove(this ICollection collection, params T[] values) - { - foreach (var x in values) - { - collection.Remove(x); - } - } - - /// - /// Sets whether or will be used when calling or - /// - public static bool UseAsyncKeyCheck = false; - - /// - /// Checks if a key is pressed via winapi. - /// - /// Key - /// Whether the key is currently pressed - public static bool IsKeyPressed(Keys key) - { - if (key == Keys.None) return false; - if (UseAsyncKeyCheck) - { - return Bitmask.IsBitSet(User32.GetKeyState((int)key), 15); - } - else - { - return Bitmask.IsBitSet(User32.GetAsyncKeyState((int)key), 15); - } - } - - /// - /// Checks if a key is pressed via winapi. - /// - /// Key - /// Whether the key is currently pressed - public static bool IsKeyPressed(LimitedKeys key) - { - if (key == LimitedKeys.None) return false; - if (UseAsyncKeyCheck) - { - return Bitmask.IsBitSet(User32.GetKeyState((int)key), 15); - } - else - { - return Bitmask.IsBitSet(User32.GetAsyncKeyState((int)key), 15); - } - } - - /// - /// Checks if you are targeting object . - /// - /// Object to check - /// Whether you are targeting object ; if is - public static bool IsTarget(this GameObject obj) - { - return Svc.Targets.Target != null && Svc.Targets.Target.Address == obj.Address; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsNullOr(this T source, Predicate testFunction) - { - return source == null || testFunction(source); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static T[] CreateArray(this T o, uint num) - { - var arr = new T[num]; - for (int i = 0; i < arr.Length; i++) - { - arr[i] = o; - } - return arr; - } - - public static V GetOrDefault(this IDictionary dic, K key) - { - if(dic.TryGetValue(key, out V value)) return value; - return default; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static int IncrementOrSet(this IDictionary dic, K key, int increment = 1) - { - if(dic.ContainsKey(key)) - { - dic[key] += increment; - } - else - { - dic[key] = increment; - } - return dic[key]; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static string RemoveOtherChars(this string s, string charsToKeep) - { - return new string(s.ToArray().Where(charsToKeep.Contains).ToArray()); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static string ReplaceByChar(this string s, string replaceWhat, string replaceWith, bool replaceWithWhole = false) - { - if(replaceWhat.Length != replaceWith.Length && !replaceWithWhole) - { - PluginLog.Error($"{nameof(replaceWhat)} and {nameof(replaceWith)} must be same length"); - return s; - } - for (int i = 0; i < replaceWhat.Length; i++) - { - if (replaceWithWhole) - { - s = s.Replace(replaceWhat[i].ToString(), replaceWith); - } - else - { - s = s.Replace(replaceWhat[i], replaceWith[i]); - } - } - return s; - } - - /// - /// Serializes and then deserializes object, returning result of deserialization using - /// - /// - /// - /// Deserialized copy of - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static T JSONClone(this T obj) - { - return JsonConvert.DeserializeObject(JsonConvert.SerializeObject(obj)); - } - - /// - /// Attempts to parse integer - /// - /// Input string - /// Integer if parsing was successful, if failed - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static int? ParseInt(this string number) - { - if(int.TryParse(number, out var result)) - { - return result; - } - return null; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static string Print(this IEnumerable x, string separator = ", ") - { - return x.Select(x => x.ToString()).Join(separator); - } - - public static void DeleteFileToRecycleBin(string path) - { - try - { - Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(path, Microsoft.VisualBasic.FileIO.UIOption.OnlyErrorDialogs, Microsoft.VisualBasic.FileIO.RecycleOption.SendToRecycleBin); - } - catch(Exception e) - { - e.LogWarning(); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static V GetSafe(this IDictionary dic, K key, V Default = default) - { - if(dic?.TryGetValue(key, out var value) == true) - { - return value; - } - return Default; - } - - /// - /// Retrieves a value from dictionary, adding it first if it doesn't exists yet. - /// - /// - /// - /// - /// - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static V GetOrCreate(this IDictionary dictionary, K key) where V:new() - { - if (dictionary.TryGetValue(key, out var result)) - { - return result; - } - var newValue = new V(); - dictionary.Add(key, newValue); - return newValue; - } - - /// - /// Executes action for each element of collection. - /// - /// - /// - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Each(this IEnumerable collection, Action function) - { - foreach(var x in collection) - { - function(x); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool If(this T obj, Func func) - { - return func(obj); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool NotNull(this T obj, [NotNullWhen(true)]out T outobj) - { - outobj = obj; - return obj != null; - } - - public static bool IsOccupied() - { - return Svc.Condition[ConditionFlag.Occupied] - || Svc.Condition[ConditionFlag.Occupied30] - || Svc.Condition[ConditionFlag.Occupied33] - || Svc.Condition[ConditionFlag.Occupied38] - || Svc.Condition[ConditionFlag.Occupied39] - || Svc.Condition[ConditionFlag.OccupiedInCutSceneEvent] - || Svc.Condition[ConditionFlag.OccupiedInEvent] - || Svc.Condition[ConditionFlag.OccupiedInQuestEvent] - || Svc.Condition[ConditionFlag.OccupiedSummoningBell] - || Svc.Condition[ConditionFlag.WatchingCutscene] - || Svc.Condition[ConditionFlag.WatchingCutscene78] - || Svc.Condition[ConditionFlag.BetweenAreas] - || Svc.Condition[ConditionFlag.BetweenAreas51] - || Svc.Condition[ConditionFlag.InThatPosition] - || Svc.Condition[ConditionFlag.TradeOpen] - || Svc.Condition[ConditionFlag.Crafting] - || Svc.Condition[ConditionFlag.InThatPosition] - || Svc.Condition[ConditionFlag.Unconscious] - || Svc.Condition[ConditionFlag.MeldingMateria] - || Svc.Condition[ConditionFlag.Gathering] - || Svc.Condition[ConditionFlag.OperatingSiegeMachine] - || Svc.Condition[ConditionFlag.CarryingItem] - || Svc.Condition[ConditionFlag.CarryingObject] - || Svc.Condition[ConditionFlag.BeingMoved] - || Svc.Condition[ConditionFlag.Emoting] - || Svc.Condition[ConditionFlag.Mounted2] - || Svc.Condition[ConditionFlag.Mounting] - || Svc.Condition[ConditionFlag.Mounting71] - || Svc.Condition[ConditionFlag.ParticipatingInCustomMatch] - || Svc.Condition[ConditionFlag.PlayingLordOfVerminion] - || Svc.Condition[ConditionFlag.ChocoboRacing] - || Svc.Condition[ConditionFlag.PlayingMiniGame] - || Svc.Condition[ConditionFlag.Performing] - || Svc.Condition[ConditionFlag.PreparingToCraft] - || Svc.Condition[ConditionFlag.Fishing] - || Svc.Condition[ConditionFlag.Transformed] - || Svc.Condition[ConditionFlag.UsingHousingFunctions] - || Svc.ClientState.LocalPlayer?.IsTargetable != true; - } - - public static string ReplaceFirst(this string text, string search, string replace) - { - int pos = text.IndexOf(search); - if (pos < 0) - { - return text; - } - return text.Substring(0, pos) + replace + text.Substring(pos + search.Length); - } - - /// - /// Attempts to parse player in a . - /// - /// from which to read player - /// Resulting player data - /// Whether operation succeeded - public static bool TryDecodeSender(SeString sender, out Sender senderStruct) - { - if (sender == null) - { - senderStruct = default; - return false; - } - foreach (var x in sender.Payloads) - { - if (x is PlayerPayload p) - { - senderStruct = new(p.PlayerName, p.World.RowId); - return true; - } - } - senderStruct = default; - return false; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsAddonReady(AtkUnitBase* Addon) - { - return Addon->IsVisible && Addon->UldManager.LoadedState == AtkLoadState.Loaded; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsAddonReady(AtkComponentNode* Addon) - { - return Addon->AtkResNode.IsVisible && Addon->Component->UldManager.LoadedState == AtkLoadState.Loaded; - } - - /// - /// Discards any non-text payloads from - /// - /// - /// Whether to find first text payload and only return it - /// String that only includes text payloads - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static string ExtractText(this Lumina.Text.SeString s, bool onlyFirst = false) - { - return s.ToDalamudString().ExtractText(onlyFirst); - } - - /// - /// Reads SeString from unmanaged memory and discards any non-text payloads from - /// - /// - /// Whether to find first text payload and only return it - /// String that only includes text payloads - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static string ExtractText(this Utf8String s, bool onlyFirst = false) - { - var str = MemoryHelper.ReadSeString(&s); - return str.ExtractText(false); - } - - /// - /// Discards any non-text payloads from - /// - /// - /// Whether to find first text payload and only return it - /// String that only includes text payloads - public static string ExtractText(this SeString seStr, bool onlyFirst = false) - { - StringBuilder sb = new(); - foreach(var x in seStr.Payloads) - { - if(x is TextPayload tp) - { - sb.Append(tp.Text); - if (onlyFirst) break; - } - } - return sb.ToString(); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool StartsWithAny(this string source, params string[] values) - { - return source.StartsWithAny(values, StringComparison.Ordinal); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool StartsWithAny(this string source, StringComparison stringComparison = StringComparison.Ordinal, params string[] values) - { - return source.StartsWithAny(values, stringComparison); - } - - public static bool StartsWithAny(this string source, IEnumerable compareTo, StringComparison stringComparison = StringComparison.Ordinal) - { - foreach(var x in compareTo) - { - if (source.StartsWith(x, stringComparison)) return true; - } - return false; - } - - public static SeStringBuilder Add(this SeStringBuilder b, IEnumerable payloads) - { - foreach(var x in payloads) - { - b = b.Add(x); - } - return b; - } - - /// - /// Adds into if it doesn't exists yet or removes if it exists. - /// - /// - /// - /// - /// Whether contains after function has been executed. - public static bool Toggle(this HashSet hashSet, T value) - { - if (hashSet.Contains(value)) - { - hashSet.Remove(value); - return false; - } - else - { - hashSet.Add(value); - return true; - } - } - - public static bool Toggle(this List list, T value) - { - if (list.Contains(value)) - { - list.RemoveAll(x => x.Equals(value)); - return false; - } - else - { - list.Add(value); - return true; - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static IEnumerable Split(this string str, int chunkSize) - { - return Enumerable.Range(0, str.Length / chunkSize) - .Select(i => str.Substring(i * chunkSize, chunkSize)); - } - - public static string GetTerritoryName(this uint terr) - { - var t = Svc.Data.GetExcelSheet().GetRow(terr); - return $"{terr} | {t?.ContentFinderCondition?.Value?.Name?.ToString().Default(t?.PlaceName.Value?.Name?.ToString())}"; - } - - public static T FirstOr0(this IEnumerable collection, Func predicate) - { - foreach(var x in collection) - { - if (predicate(x)) - { - return x; - } - } - return collection.First(); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static string Default(this string s, string defaultValue) - { - if (string.IsNullOrEmpty(s)) return defaultValue; - return s; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool EqualsIgnoreCase(this string s, string other) - { - return s.Equals(other, StringComparison.OrdinalIgnoreCase); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static string NullWhenEmpty(this string s) - { - return s == string.Empty ? null : s; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsNullOrEmpty(this string s) - { - return string.IsNullOrEmpty(s); - } - - public static IEnumerable SelectMulti(this IEnumerable values, params Func[] funcs) - { - foreach(var v in values) - foreach(var x in funcs) - { - yield return x(v); - } - } - - public static bool TryGetWorldByName(string world, out Lumina.Excel.GeneratedSheets.World worldId) - { - if(Svc.Data.GetExcelSheet().TryGetFirst(x => x.Name.ToString().Equals(world, StringComparison.OrdinalIgnoreCase), out var w)) - { - worldId = w; - return true; - } - worldId = default; - return false; - } - - public static Vector4 Invert(this Vector4 v) - { - return v with { X = 1f - v.X, Y = 1f - v.Y, Z = 1f - v.Z }; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static uint ToUint(this Vector4 color) - { - return ImGui.ColorConvertFloat4ToU32(color); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 ToVector4(this uint color) - { - return ImGui.ColorConvertU32ToFloat4(color); - } - - public static ref int ValidateRange(this ref int i, int min, int max) - { - if (i > max) i = max; - if (i < min) i = min; - return ref i; - } - - public static ref float ValidateRange(this ref float i, float min, float max) - { - if (i > max) i = max; - if (i < min) i = min; - return ref i; - } - - public static void LogWarning(this Exception e) - { - PluginLog.Warning($"{e.Message}\n{e.StackTrace ?? ""}"); - } - - public static void Log(this Exception e) - { - PluginLog.Error($"{e.Message}\n{e.StackTrace ?? ""}"); - } - - public static void Log(this Exception e, string ErrorMessage) - { - PluginLog.Error($"{ErrorMessage}\n{e.Message}\n{e.StackTrace ?? ""}"); - } - - public static void LogDuo(this Exception e) - { - DuoLog.Error($"{e.Message}\n{e.StackTrace ?? ""}"); - } - - public static bool IsNoConditions() - { - if (!Svc.Condition[ConditionFlag.NormalConditions]) return false; - for(var i = 2; i < 100; i++) - { - if (i == (int)ConditionFlag.ParticipatingInCrossWorldPartyOrAlliance) continue; - if (Svc.Condition[i]) return false; - } - return true; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool Invert(this bool b, bool invert) - { - return invert ? !b : b; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool ContainsAll(this IEnumerable source, IEnumerable values) - { - foreach(var x in values) - { - if (!source.Contains(x)) return false; - } - return true; - } - - public static void ShellStart(string s) - { - Safe(delegate - { - Process.Start(new ProcessStartInfo() - { - FileName = s, - UseShellExecute = true - }); - }, (e) => - { - Notify.Error($"Could not open {s.Cut(60)}\n{e}"); - }); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static string Cut(this string s, int num) - { - if (s.Length <= num) return s; - return s[0..num] + "..."; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ushort GetParsedSeSetingColor(int percent) - { - if(percent < 25) - { - return 3; - } - else if(percent < 50) - { - return 45; - } - else if(percent < 75) - { - return 37; - } - else if(percent < 95) - { - return 541; - } - else if(percent < 99) - { - return 500; - } - else if (percent == 99) - { - return 561; - } - else if (percent == 100) - { - return 573; - } - else - { - return 518; - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static string Repeat(this string s, int num) - { - StringBuilder str = new(); - for(var i = 0; i < num; i++) - { - str.Append(s); - } - return str.ToString(); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static string Join(this IEnumerable e, string separator) - { - return string.Join(separator, e); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Safe(System.Action a, bool suppressErrors = false) - { - try - { - a(); - } - catch (Exception e) - { - if (!suppressErrors) PluginLog.Error($"{e.Message}\n{e.StackTrace ?? ""}"); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Safe(System.Action a, Action logAction) - { - try - { - a(); - } - catch (Exception e) - { - logAction($"{e.Message}\n{e.StackTrace ?? ""}", Array.Empty()); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Safe(System.Action a, Action fail, bool suppressErrors = false) - { - try - { - a(); - } - catch (Exception e) - { - try - { - fail(e.Message); - } - catch(Exception ex) - { - PluginLog.Error("Error while trying to process error handler:"); - PluginLog.Error($"{ex.Message}\n{ex.StackTrace ?? ""}"); - suppressErrors = false; - } - if (!suppressErrors) PluginLog.Error($"{e.Message}\n{e.StackTrace ?? ""}"); - } - } - - public static bool TryExecute(System.Action a) - { - try - { - a(); - return true; - } - catch (Exception e) - { - PluginLog.Error($"{e.Message}\n{e.StackTrace ?? ""}"); - return false; - } - } - - public static bool TryExecute(Func a, out T result) - { - try - { - result = a(); - return true; - } - catch (Exception e) - { - PluginLog.Error($"{e.Message}\n{e.StackTrace ?? ""}"); - result = default; - return false; - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool ContainsAny(this IEnumerable obj, params T[] values) - { - foreach (var x in values) - { - if (obj.Contains(x)) - { - return true; - } - } - return false; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool ContainsAny(this IEnumerable obj, IEnumerable values) - { - foreach (var x in values) - { - if (obj.Contains(x)) - { - return true; - } - } - return false; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool ContainsAny(this string obj, IEnumerable values) - { - foreach (var x in values) - { - if (obj.Contains(x)) - { - return true; - } - } - return false; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool ContainsAny(this string obj, params string[] values) - { - foreach (var x in values) - { - if (obj.Contains(x)) - { - return true; - } - } - return false; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool ContainsAny(this string obj, StringComparison comp, params string[] values) - { - foreach (var x in values) - { - if (obj.Contains(x, comp)) - { - return true; - } - } - return false; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool EqualsAny(this T obj, params T[] values) - { - return values.Any(x => x.Equals(obj)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool EqualsIgnoreCaseAny(this string obj, params string[] values) - { - return values.Any(x => x.Equals(obj, StringComparison.OrdinalIgnoreCase)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool EqualsIgnoreCaseAny(this string obj, IEnumerable values) - { - return values.Any(x => x.Equals(obj, StringComparison.OrdinalIgnoreCase)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool EqualsAny(this T obj, IEnumerable values) - { - return values.Any(x => x.Equals(obj)); - } - - public static IEnumerable FindKeysByValue(this IDictionary dictionary, V value) - { - foreach(var x in dictionary) - { - if (value.Equals(x.Value)) - { - yield return x.Key; - } - } - } - - public static bool TryGetFirst(this IDictionary dictionary, Func, bool> predicate, out KeyValuePair keyValuePair) - { - try - { - keyValuePair = dictionary.First(predicate); - return true; - } - catch(Exception) - { - keyValuePair = default; - return false; - } - } - - public static bool TryGetFirst(this IEnumerable enumerable, out K value) - { - try - { - value = enumerable.First(); - return true; - } - catch (Exception) - { - value = default; - return false; - } - } - - public static bool TryGetFirst(this IEnumerable enumerable, Func predicate, out K value) - { - try - { - value = enumerable.First(predicate); - return true; - } - catch (Exception) - { - value = default; - return false; - } - } - - public static bool TryGetLast(this IEnumerable enumerable, Func predicate, out K value) - { - try - { - value = enumerable.Last(predicate); - return true; - } - catch (Exception) - { - value = default; - return false; - } - } - - public static bool TryGetAddonByName(string Addon, out T* AddonPtr) where T : unmanaged - { - var a = Svc.GameGui.GetAddonByName(Addon, 1); - if (a == IntPtr.Zero) - { - AddonPtr = null; - return false; - } - else - { - AddonPtr = (T*)a; - return true; - } - } - - public static bool IsSelectItemEnabled(AtkTextNode* textNodePtr) - { - var col = textNodePtr->TextColor; - //EEE1C5FF - return (col.A == 0xFF && col.R == 0xEE && col.G == 0xE1 && col.B == 0xC5) - //7D523BFF - || (col.A == 0xFF && col.R == 0x7D && col.G == 0x52 && col.B == 0x3B) - || (col.A == 0xFF && col.R == 0xFF && col.G == 0xFF && col.B == 0xFF) - // EEE1C5FF - || (col.A == 0xFF && col.R == 0xEE && col.G == 0xE1 && col.B == 0xC5); - } - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - [Obsolete($"Use MemoryHelper.ReadSeString")] - public static unsafe SeString ReadSeString(Utf8String* utf8String) => MemoryHelper.ReadSeString(utf8String); - - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - [Obsolete($"Use MemoryHelper.ReadSeString")] - public static SeString ReadSeString(IntPtr memoryAddress, int maxLength) => MemoryHelper.ReadSeString(memoryAddress, maxLength); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - [Obsolete($"Use MemoryHelper.ReadRaw")] - public static void ReadRaw(IntPtr memoryAddress, int length, out byte[] value) => value = MemoryHelper.ReadRaw(memoryAddress, length); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - [Obsolete($"Use MemoryHelper.ReadRaw")] - public static byte[] ReadRaw(IntPtr memoryAddress, int length) => MemoryHelper.ReadRaw(memoryAddress, length); -} diff --git a/ECommons/ECommons/Hooks/ActionEffect.cs b/ECommons/ECommons/Hooks/ActionEffect.cs deleted file mode 100644 index ee00c53..0000000 --- a/ECommons/ECommons/Hooks/ActionEffect.cs +++ /dev/null @@ -1,128 +0,0 @@ -using Dalamud.Hooking; -using ECommons.Logging; -using ECommons.DalamudServices; -using ECommons.Hooks.ActionEffectTypes; -using FFXIVClientStructs.FFXIV.Client.Game.Character; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Numerics; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.Hooks -{ - public static unsafe class ActionEffect - { - const string Sig = "40 55 53 57 41 54 41 55 41 56 41 57 48 8D AC 24 ?? ?? ?? ?? 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 45 70"; - - public delegate void ProcessActionEffect(uint sourceId, Character* sourceCharacter, Vector3* pos, EffectHeader* effectHeader, EffectEntry* effectArray, ulong* effectTail); - internal static Hook ProcessActionEffectHook = null; - - public delegate void ActionEffectCallback(ActionEffectSet set); - - static event ActionEffectCallback _actionEffectEvent; - public static event ActionEffectCallback ActionEffectEvent - { - add - { - Hook(); - _actionEffectEvent += value; - } - remove => _actionEffectEvent -= value; - } - - static event Action _actionEffectEntryEvent; - public static event Action ActionEffectEntryEvent - { - add - { - Hook(); - _actionEffectEntryEvent += value; - } - remove => _actionEffectEntryEvent -= value; - } - - static bool doLogging = false; - - private static void Hook() - { - if (ProcessActionEffectHook == null) - { - if (Svc.SigScanner.TryScanText(Sig, out var ptr)) - { - ProcessActionEffectHook = Svc.Hook.HookFromAddress(ptr, ProcessActionEffectDetour); - Enable(); - PluginLog.Information($"Requested Action Effect hook and successfully initialized"); - } - else - { - PluginLog.Error($"Could not find ActionEffect signature"); - } - } - } - - /// - /// - /// - /// uint ActionID, ushort animationID, ActionEffectType type, uint sourceID, ulong targetOID, uint damage - /// - /// - [Obsolete($"Please use {nameof(ActionEffectEntryEvent)} instead.")] - public static void Init(Action fullParamsCallback, bool logging = false) - { - ActionEffectEntryEvent += fullParamsCallback; - } - - public static void Enable() - { - if (ProcessActionEffectHook?.IsEnabled == false) ProcessActionEffectHook?.Enable(); - } - - public static void Disable() - { - if (ProcessActionEffectHook?.IsEnabled == true) ProcessActionEffectHook?.Disable(); - } - - internal static void Dispose() - { - if (ProcessActionEffectHook != null) - { - PluginLog.Information($"Disposing Action Effect Hook"); - Disable(); - ProcessActionEffectHook?.Dispose(); - ProcessActionEffectHook = null; - } - } - - internal static void ProcessActionEffectDetour(uint sourceID, Character* sourceCharacter, Vector3* pos, EffectHeader* effectHeader, EffectEntry* effectArray, ulong* effectTail) - { - try - { - if(doLogging) PluginLog.Verbose($"--- source actor: {sourceCharacter->GameObject.ObjectID}, action id {effectHeader->ActionID}, anim id {effectHeader->AnimationId} numTargets: {effectHeader->TargetCount} ---"); - - // TODO: Reimplement opcode logging, if it's even useful. Original code follows - // ushort op = *((ushort*) effectHeader.ToPointer() - 0x7); - // DebugLog(Effect, $"--- source actor: {sourceId}, action id {id}, anim id {animId}, opcode: {op:X} numTargets: {targetCount} ---"); - - var set = new ActionEffectSet(sourceID, sourceCharacter, pos, effectHeader, effectArray, effectTail); - _actionEffectEvent?.Invoke(set); - - foreach( var effect in set.TargetEffects) - { - effect.ForEach(entry => - { - if (entry.type == ActionEffectType.Nothing) return; - _actionEffectEntryEvent?.Invoke(effectHeader->ActionID, effectHeader->AnimationId, entry.type, sourceID, effect.TargetID, entry.Damage); - }); - } - } - catch (Exception e) - { - PluginLog.Error($"An error has occurred in Action Effect hook.\n{e}"); - } - - ProcessActionEffectHook.Original(sourceID, sourceCharacter, pos, effectHeader, effectArray, effectTail); - } - } -} diff --git a/ECommons/ECommons/Hooks/ActionEffectTypes/ActionEffectSet.cs b/ECommons/ECommons/Hooks/ActionEffectTypes/ActionEffectSet.cs deleted file mode 100644 index f05bc78..0000000 --- a/ECommons/ECommons/Hooks/ActionEffectTypes/ActionEffectSet.cs +++ /dev/null @@ -1,113 +0,0 @@ -using Dalamud.Game.ClientState.Objects.Types; -using ECommons.DalamudServices; -using FFXIVClientStructs.FFXIV.Client.Game; -using Lumina.Excel.GeneratedSheets; -using System.Collections.Generic; -using System.Numerics; -using Action = Lumina.Excel.GeneratedSheets.Action; -using Character = FFXIVClientStructs.FFXIV.Client.Game.Character.Character; - -namespace ECommons.Hooks.ActionEffectTypes; - -public unsafe struct ActionEffectSet -{ - public Action Action { get; } - - public Item Item { get; } - - public EventItem EventItem { get; } - - public Mount Mount { get; } - - public ushort IconId { get; } - - public string Name { get; } - - public GameObject Target { get; } - - public GameObject Source { get; } - - public Character SourceCharacter { get; } - - public TargetEffect[] TargetEffects { get; } - - public Vector3 Position { get; } - - public EffectHeader Header { get; } - - public ActionEffectSet(uint sourceID, Character* sourceCharacter, Vector3* pos, EffectHeader* effectHeader, EffectEntry* effectArray, ulong* effectTail) - { - switch (effectHeader->ActionType) - { - case ActionType.KeyItem: - EventItem = Svc.Data.GetExcelSheet().GetRow(effectHeader->ActionID); - Name = EventItem?.Singular ?? string.Empty; - IconId = EventItem?.Icon ?? 0; - break; - - case ActionType.Item: - var id = effectHeader->ActionID > 1000000 ? effectHeader->ActionID - 1000000 : effectHeader->ActionID; - Item = Svc.Data.GetExcelSheet().GetRow(id); - Name = Item?.Name ?? string.Empty; - IconId = Item?.Icon ?? 0; - break; - - case ActionType.Mount: - Mount = Svc.Data.GetExcelSheet().GetRow(effectHeader->ActionID); - Name = Mount?.Singular ?? string.Empty; - IconId = Mount?.Icon ?? 0; - break; - - default: - Action = Svc.Data.GetExcelSheet().GetRow(effectHeader->ActionID); - Name = Action?.Name ?? string.Empty; ; - - var actionCate = Action?.ActionCategory.Value?.RowId ?? 0; - - IconId = actionCate == 1 ? (ushort)101 // Auto Attack - : effectHeader->ActionID == 3 ? (ushort)104 //Sprint - : effectHeader->ActionID == 4 ? (ushort)118 //Mount - : Action?.Icon ?? 0; - break; - } - Target = Svc.Objects.SearchById(effectHeader->AnimationTargetId); - Source = Svc.Objects.SearchById(sourceID); - SourceCharacter = *sourceCharacter; - Position = *pos; - Header = *effectHeader; - - TargetEffects = new TargetEffect[effectHeader->TargetCount]; - for (int i = 0; i < effectHeader->TargetCount; i++) - { - TargetEffects[i] = new TargetEffect(effectTail[i], effectArray + 8 * i); - } - } - - public Dictionary GetSpecificTypeEffect(ActionEffectType type) - { - var result = new Dictionary(); - foreach (var effect in TargetEffects) - { - if (effect.GetSpecificTypeEffect(type, out var e)) - { - //Is this value or Damage? IDK about it. - result[effect.TargetID] = e.value; - } - } - return result; - } - - public override string ToString() - { - var str = $"S:{Source?.Name}, T:{Target?.Name}, Lock:{Header.AnimationLockTime}"; - str += $"\nType: {Header.ActionType}, Name: {Action?.Name}({Action?.RowId})"; - if (TargetEffects != null) - { - foreach (var effect in TargetEffects) - { - str += "\n" + effect.ToString(); - } - } - return str; - } -} diff --git a/ECommons/ECommons/Hooks/ActionEffectTypes/ActionEffectType.cs b/ECommons/ECommons/Hooks/ActionEffectTypes/ActionEffectType.cs deleted file mode 100644 index c90b147..0000000 --- a/ECommons/ECommons/Hooks/ActionEffectTypes/ActionEffectType.cs +++ /dev/null @@ -1,59 +0,0 @@ -//This file is authored by lmcintyre and distributed under GNU GPL v3 license. https://github.com/lmcintyre/ - -using System; - -namespace ECommons.Hooks.ActionEffectTypes; - -public enum ActionEffectType : byte -{ - Nothing = 0, - Miss = 1, - FullResist = 2, - Damage = 3, - Heal = 4, - BlockedDamage = 5, - ParriedDamage = 6, - Invulnerable = 7, - NoEffectText = 8, - Unknown_0 = 9, - MpLoss = 10, - MpGain = 11, - TpLoss = 12, - TpGain = 13, - - ApplyStatusEffectTarget = 14, - [Obsolete("Please use ApplyStatusEffectTarget instead.")] - GpGain = ApplyStatusEffectTarget, - - ApplyStatusEffectSource = 15, - RecoveredFromStatusEffect = 16, - LoseStatusEffectTarget = 17, - LoseStatusEffectSource = 18, - StatusNoEffect = 20, - ThreatPosition = 24, - EnmityAmountUp = 25, - EnmityAmountDown = 26, - - StartActionCombo = 27, - [Obsolete("Please use StartActionCombo instead.")] - Unknown0 = StartActionCombo, - - ComboSucceed = 28, - [Obsolete("Please use ComboSucceed instead.")] - Unknown1 = ComboSucceed, - - Retaliation = 29, - Knockback = 32, - Attract1 = 33, //Here is an issue bout knockback. some is 32 some is 33. - Attract2 = 34, - Mount = 40, - FullResistStatus = 52, - FullResistStatus2 = 55, - VFX = 59, - Gauge = 60, - JobGauge = 61, - SetModelState = 72, - SetHP = 73, - PartialInvulnerable = 74, - Interrupt = 75, -}; diff --git a/ECommons/ECommons/Hooks/ActionEffectTypes/AttackType.cs b/ECommons/ECommons/Hooks/ActionEffectTypes/AttackType.cs deleted file mode 100644 index 30da32d..0000000 --- a/ECommons/ECommons/Hooks/ActionEffectTypes/AttackType.cs +++ /dev/null @@ -1,16 +0,0 @@ -//This file is authored by lmcintyre and distributed under GNU GPL v3 license. https://github.com/lmcintyre/ - -namespace ECommons.Hooks.ActionEffectTypes; - -public enum AttackType -{ - Unknown = 0, - Slashing = 1, - Piercing = 2, - Blunt = 3, - Shot = 4, - Magical = 5, - Unique = 6, - Physical = 7, - LimitBreak = 8, -} diff --git a/ECommons/ECommons/Hooks/ActionEffectTypes/EffectEntry.cs b/ECommons/ECommons/Hooks/ActionEffectTypes/EffectEntry.cs deleted file mode 100644 index 08e2464..0000000 --- a/ECommons/ECommons/Hooks/ActionEffectTypes/EffectEntry.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace ECommons.Hooks.ActionEffectTypes -{ - public struct EffectEntry - { - public ActionEffectType type; - public byte param0; - public byte param1; - public byte param2; - public byte mult; - public byte flags; - public ushort value; - - public byte AttackType => (byte)(param1 & 0xF); - - public uint Damage => mult == 0 ? value : value + ((uint)ushort.MaxValue + 1) * mult; - - public override string ToString() - { - return - $"Type: {type}, p0: {param0:D3}, p1: {param1:D3}, p2: {param2:D3} 0x{param2:X2} '{Convert.ToString(param2, 2).PadLeft(8, '0')}', mult: {mult:D3}, flags: {flags:D3} | {Convert.ToString(flags, 2).PadLeft(8, '0')}, value: {value:D6} ATTACK TYPE: {AttackType}"; - } - } -} diff --git a/ECommons/ECommons/Hooks/ActionEffectTypes/EffectHeader.cs b/ECommons/ECommons/Hooks/ActionEffectTypes/EffectHeader.cs deleted file mode 100644 index 9db1b27..0000000 --- a/ECommons/ECommons/Hooks/ActionEffectTypes/EffectHeader.cs +++ /dev/null @@ -1,21 +0,0 @@ -using FFXIVClientStructs.FFXIV.Client.Game; -using System.Runtime.InteropServices; - -namespace ECommons.Hooks.ActionEffectTypes -{ - [StructLayout(LayoutKind.Explicit)] - public struct EffectHeader - { - [FieldOffset(0)] public ulong AnimationTargetId; - [FieldOffset(8)] public uint ActionID; - [FieldOffset(12)] public uint GlobalEffectCounter; - [FieldOffset(16)] public float AnimationLockTime; - [FieldOffset(20)] public uint SomeTargetID; - [FieldOffset(24)] public ushort SourceSequence; - [FieldOffset(26)] public ushort Rotation; - [FieldOffset(28)] public ushort AnimationId; - [FieldOffset(30)] public byte Variation; - [FieldOffset(31)] public ActionType ActionType; - [FieldOffset(33)] public byte TargetCount; - } -} diff --git a/ECommons/ECommons/Hooks/ActionEffectTypes/TargetEffect.cs b/ECommons/ECommons/Hooks/ActionEffectTypes/TargetEffect.cs deleted file mode 100644 index 56bee7f..0000000 --- a/ECommons/ECommons/Hooks/ActionEffectTypes/TargetEffect.cs +++ /dev/null @@ -1,64 +0,0 @@ -using ECommons.DalamudServices; -using System; - -namespace ECommons.Hooks.ActionEffectTypes; - -public unsafe struct TargetEffect -{ - private readonly EffectEntry* _effects; - - public ulong TargetID { get; } - - public TargetEffect(ulong targetId, EffectEntry* effects) - { - TargetID = targetId; - _effects = effects; - } - - /// - /// Get Effect. - /// - /// - /// - public EffectEntry this[int index] - { - get - { - if (index < 0 || index > 7) return default; - return _effects[index]; - } - } - - public override string ToString() - { - var str = Svc.Objects.SearchById(TargetID)?.Name?.ToString(); - ForEach(e => str += "\n " + e.ToString()); - return str; - } - - public bool GetSpecificTypeEffect(ActionEffectType type, out EffectEntry effect) - { - bool find = false; - EffectEntry result = default; - ForEach(e => - { - if (!find && e.type == type) - { - find = true; - result = e; - } - }); - effect = result; - return find; - } - - public void ForEach(Action act) - { - if (act == null) return; - for (int i = 0; i < 8; i++) - { - var e = this[i]; - act(e); - } - } -} diff --git a/ECommons/ECommons/Hooks/DirectorUpdate.cs b/ECommons/ECommons/Hooks/DirectorUpdate.cs deleted file mode 100644 index 51772fa..0000000 --- a/ECommons/ECommons/Hooks/DirectorUpdate.cs +++ /dev/null @@ -1,108 +0,0 @@ -using Dalamud.Hooking; -using ECommons.Logging; -using Dalamud.Utility.Signatures; -using ECommons.DalamudServices; -using Serilog.Core; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.Hooks -{ - public static class DirectorUpdate - { - const string Sig = "48 89 5C 24 ?? 57 48 83 EC 30 41 8B D9"; - - public delegate long ProcessDirectorUpdate(long a1, long a2, DirectorUpdateCategory a3, uint a4, uint a5, int a6, int a7); - internal static Hook ProcessDirectorUpdateHook = null; - static Action FullParamsCallback = null; - static Action CategoryOnlyCallback = null; - - internal static long ProcessDirectorUpdateDetour_Full(long a1, long a2, DirectorUpdateCategory a3, uint a4, uint a5, int a6, int a7) - { - try - { - FullParamsCallback(a1, a2, a3, a4, a5, a6, a7); - } - catch (Exception e) - { - e.Log(); - } - return ProcessDirectorUpdateHook.Original(a1, a2, a3, a4, a5, a6, a7); - } - - internal static long ProcessDirectorUpdateDetour_Category(long a1, long a2, DirectorUpdateCategory a3, uint a4, uint a5, int a6, int a7) - { - try - { - CategoryOnlyCallback(a3); - } - catch (Exception e) - { - e.Log(); - } - return ProcessDirectorUpdateHook.Original(a1, a2, a3, a4, a5, a6, a7); - } - - public static void Init(Action fullParamsCallback) - { - if(ProcessDirectorUpdateHook != null) - { - throw new Exception("Director Update Hook is already initialized!"); - } - if (Svc.SigScanner.TryScanText(Sig, out var ptr)) - { - FullParamsCallback = fullParamsCallback; - ProcessDirectorUpdateHook = Svc.Hook.HookFromAddress(ptr, ProcessDirectorUpdateDetour_Full); - Enable(); - PluginLog.Information($"Requested Director Update hook and successfully initialized with FULL data"); - } - else - { - PluginLog.Error($"Could not find DirectorUpdate signature"); - } - } - - public static void Init(Action categoryOnlyCallback) - { - if (ProcessDirectorUpdateHook != null) - { - throw new Exception("Director Update Hook is already initialized!"); - } - if (Svc.SigScanner.TryScanText(Sig, out var ptr)) - { - CategoryOnlyCallback = categoryOnlyCallback; - ProcessDirectorUpdateHook = Svc.Hook.HookFromAddress(ptr, ProcessDirectorUpdateDetour_Category); - Enable(); - PluginLog.Information($"Requested Director Update hook and successfully initialized with CATEGORY ONLY data"); - } - else - { - PluginLog.Error($"Could not find DirectorUpdate signature"); - } - } - - public static void Enable() - { - if (ProcessDirectorUpdateHook?.IsEnabled == false) ProcessDirectorUpdateHook?.Enable(); - } - - public static void Disable() - { - if (ProcessDirectorUpdateHook?.IsEnabled == true) ProcessDirectorUpdateHook?.Disable(); - } - - public static void Dispose() - { - if(ProcessDirectorUpdateHook != null) - { - PluginLog.Information($"Disposing Director Update Hook"); - Disable(); - ProcessDirectorUpdateHook?.Dispose(); - ProcessDirectorUpdateHook = null; - } - } - } -} diff --git a/ECommons/ECommons/Hooks/DirectorUpdateCategory.cs b/ECommons/ECommons/Hooks/DirectorUpdateCategory.cs deleted file mode 100644 index c985c3b..0000000 --- a/ECommons/ECommons/Hooks/DirectorUpdateCategory.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.Hooks -{ - public enum DirectorUpdateCategory : uint - { - Commence = 0x40000001, - Recommence = 0x40000006, - Complete = 0x40000003, - Wipe = 0x40000005 - } -} diff --git a/ECommons/ECommons/Hooks/MapEffect.cs b/ECommons/ECommons/Hooks/MapEffect.cs deleted file mode 100644 index 6626f74..0000000 --- a/ECommons/ECommons/Hooks/MapEffect.cs +++ /dev/null @@ -1,73 +0,0 @@ -using Dalamud.Hooking; -using ECommons.DalamudServices; -using ECommons.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.Hooks -{ - public static class MapEffect - { - const string Sig = "48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 8B FA 41 0F B7 E8"; - - public delegate long ProcessMapEffect(long a1, uint a2, ushort a3, ushort a4); - internal static Hook ProcessMapEffectHook = null; - static Action Callback = null; - - internal static long ProcessMapEffectDetour(long a1, uint a2, ushort a3, ushort a4) - { - try - { - Callback(a1, a2, a3, a4); - } - catch (Exception e) - { - e.Log(); - } - return ProcessMapEffectHook.Original(a1, a2, a3, a4); - } - - public static void Init(Action fullParamsCallback) - { - if (ProcessMapEffectHook != null) - { - throw new Exception("MapEffect is already initialized!"); - } - if (Svc.SigScanner.TryScanText(Sig, out var ptr)) - { - Callback = fullParamsCallback; - ProcessMapEffectHook = Svc.Hook.HookFromAddress(ptr, ProcessMapEffectDetour); - Enable(); - PluginLog.Information($"Requested MapEffect hook and successfully initialized"); - } - else - { - PluginLog.Error($"Could not find MapEffect signature"); - } - } - - public static void Enable() - { - if (ProcessMapEffectHook?.IsEnabled == false) ProcessMapEffectHook?.Enable(); - } - - public static void Disable() - { - if (ProcessMapEffectHook?.IsEnabled == true) ProcessMapEffectHook?.Disable(); - } - - public static void Dispose() - { - if (ProcessMapEffectHook != null) - { - PluginLog.Information($"Disposing MapEffect Hook"); - Disable(); - ProcessMapEffectHook?.Dispose(); - ProcessMapEffectHook = null; - } - } - } -} diff --git a/ECommons/ECommons/Hooks/SendAction.cs b/ECommons/ECommons/Hooks/SendAction.cs deleted file mode 100644 index 98d53cc..0000000 --- a/ECommons/ECommons/Hooks/SendAction.cs +++ /dev/null @@ -1,74 +0,0 @@ -using Dalamud.Hooking; -using ECommons.DalamudServices; -using ECommons.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.Hooks -{ - public static class SendAction - { - const string Sig = "E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? F3 0F 10 3D ?? ?? ?? ?? 48 8D 4D BF"; - - public delegate long SendActionDelegate(long targetObjectId, byte actionType, uint actionId, ushort sequence, long a5, long a6, long a7, long a8, long a9); - public delegate void SendActionCallbackDelegate(long targetObjectId, byte actionType, uint actionId, ushort sequence, long a5, long a6, long a7, long a8, long a9); - internal static Hook SendActionHook = null; - static SendActionCallbackDelegate Callback = null; - - internal static long SendActionDetour(long targetObjectId, byte actionType, uint actionId, ushort sequence, long a5, long a6, long a7, long a8, long a9) - { - try - { - Callback(targetObjectId, actionType, actionId, sequence, a5, a6, a7, a8, a9); - } - catch (Exception e) - { - e.Log(); - } - return SendActionHook.Original(targetObjectId, actionType, actionId, sequence, a5, a6, a7, a8, a9); - } - - public static void Init(SendActionCallbackDelegate fullParamsCallback) - { - if (SendActionHook != null) - { - throw new Exception("SendAction Hook is already initialized!"); - } - if (Svc.SigScanner.TryScanText(Sig, out var ptr)) - { - Callback = fullParamsCallback; - SendActionHook = Svc.Hook.HookFromAddress(ptr, SendActionDetour); - Enable(); - PluginLog.Information($"Requested SendAction hook and successfully initialized"); - } - else - { - PluginLog.Error($"Could not find SendAction signature"); - } - } - - public static void Enable() - { - if (SendActionHook?.IsEnabled == false) SendActionHook?.Enable(); - } - - public static void Disable() - { - if (SendActionHook?.IsEnabled == true) SendActionHook?.Disable(); - } - - public static void Dispose() - { - if (SendActionHook != null) - { - PluginLog.Information($"Disposing SendAction Hook"); - Disable(); - SendActionHook?.Dispose(); - SendActionHook = null; - } - } - } -} diff --git a/ECommons/ECommons/ImGuiMethods/Box.cs b/ECommons/ECommons/ImGuiMethods/Box.cs deleted file mode 100644 index 6949048..0000000 --- a/ECommons/ECommons/ImGuiMethods/Box.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace ECommons.ImGuiMethods; - -public class Box -{ - public T Value; - - public Box(T value) - { - Value = value; - } -} diff --git a/ECommons/ECommons/ImGuiMethods/CImGui.cs b/ECommons/ECommons/ImGuiMethods/CImGui.cs deleted file mode 100644 index 9080c2e..0000000 --- a/ECommons/ECommons/ImGuiMethods/CImGui.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; - -namespace ECommons.ImGuiMethods; - -public partial class CImGui -{ - [LibraryImport("cimgui")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] - public static partial void igBringWindowToDisplayFront(nint ptr); - - [LibraryImport("cimgui")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] - public static partial void igBringWindowToDisplayBack(nint ptr); - - [LibraryImport("cimgui")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] - public static partial nint igGetCurrentWindow(); - - [LibraryImport("cimgui")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] - public static partial int igFindWindowDisplayIndex(nint ptr); -} diff --git a/ECommons/ECommons/ImGuiMethods/ChangelogWindow.cs b/ECommons/ECommons/ImGuiMethods/ChangelogWindow.cs deleted file mode 100644 index 3ac4c5d..0000000 --- a/ECommons/ECommons/ImGuiMethods/ChangelogWindow.cs +++ /dev/null @@ -1,74 +0,0 @@ -using Dalamud.Configuration; -using Dalamud.Interface.Windowing; -using Dalamud.Plugin; -using ECommons.DalamudServices; -using ECommons.Reflection; -using ImGuiNET; -using System; - -namespace ECommons.ImGuiMethods; - -public class ChangelogWindow : Window -{ - Action func; - Action onClose; - IPluginConfiguration config; - WindowSystem ws = new(); - int version; - - public ChangelogWindow(IPluginConfiguration Configuration, int version, Action func, Action onClose = null) : base($"{DalamudReflector.GetPluginName()} was updated", - ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse) - { - try - { - this.config = Configuration; - this.version = version; - this.func = func; - this.onClose = onClose; - if (Svc.PluginInterface.Reason == PluginLoadReason.Installer) - { - this.OnClose(); - } - else - { - if ((int)Configuration.GetType().GetField("ChangelogWindowVer").GetValue(Configuration) != version) - { - this.IsOpen = true; - ws.AddWindow(this); - Svc.PluginInterface.UiBuilder.Draw += ws.Draw; - } - } - } - catch(Exception ex) - { - ex.Log(); - } - } - - public override bool DrawConditions() - { - return Svc.ClientState.IsLoggedIn; - } - - public override void Draw() - { - func(); - } - - public override void OnClose() - { - GenericHelpers.Safe(delegate { - config.GetType().GetField("ChangelogWindowVer").SetValue(config, this.version); - base.OnClose(); - if(onClose != null) - { - onClose(); - } - else - { - Svc.PluginInterface.SavePluginConfig(config); - } - }); - Svc.PluginInterface.UiBuilder.Draw -= ws.Draw; - } -} diff --git a/ECommons/ECommons/ImGuiMethods/Donation.cs b/ECommons/ECommons/ImGuiMethods/Donation.cs deleted file mode 100644 index 6faeca1..0000000 --- a/ECommons/ECommons/ImGuiMethods/Donation.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Dalamud.Interface.Colors; -using ImGuiNET; - -namespace ECommons.ImGuiMethods; - -public static class Donation -{ - public static void PrintDonationInfo() - { - ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow); - ImGuiEx.ButtonCopy("Bitcoin (BTC): $COPY (preferred)", "bc1qwzh7mc3glcdemyg9xpvr7cfuc2nxl8u87x73e4"); - ImGuiEx.ButtonCopy("USDT (TRC20): $COPY (preferred)", "TBNN99wdCzPX4HavCjiooq3NjvujLgqfoK"); - ImGuiEx.ButtonCopy("USDC (TRC20): $COPY (preferred)", "TBNN99wdCzPX4HavCjiooq3NjvujLgqfoK"); - ImGui.PopStyleColor(); - if (ImGui.CollapsingHeader("Other wallets:")) - { - ImGuiEx.ButtonCopy("USDT (ERC20): $COPY", "0xA46D5cD23C7586b0817413682cdeCC8E3CdB590F"); - ImGuiEx.ButtonCopy("USDC (ERC20): $COPY", "0xA46D5cD23C7586b0817413682cdeCC8E3CdB590F"); - ImGuiEx.ButtonCopy("USDC (SPL): $COPY", "GZtgrwgMM1MAgCBnDa5JJoFsuCLN9iRhGYFDzd8u7d3j"); - ImGuiEx.ButtonCopy("Litecoin (LTC): $COPY", "ltc1qrgc802qzdez2q2v6ds293qrglfzj2kvwm5dl4f"); - ImGuiEx.ButtonCopy("Ethereum (ETH): $COPY", "0xA46D5cD23C7586b0817413682cdeCC8E3CdB590F"); - ImGuiEx.ButtonCopy("BUSD (BEP20): $COPY", "0xA46D5cD23C7586b0817413682cdeCC8E3CdB590F"); - } - ImGuiEx.TextWrapped(ImGuiColors.DalamudRed, "Attention! Malware programs may replace crypto wallet address inside your clipboard. ALWAYS double-check destination address before sending any funds."); - - } - - public static void DonationTabDraw() - { - ImGuiEx.TextWrapped("If you have found this plugin useful and wish to thank me for making it, you may send any amount of any of the following cryptocurrencies to any of the following wallets:"); - PrintDonationInfo(); - ImGuiEx.TextWrapped("Regardless of donations, plugin will continue to be supported and updated."); - } -} diff --git a/ECommons/ECommons/ImGuiMethods/EColor.cs b/ECommons/ECommons/ImGuiMethods/EColor.cs deleted file mode 100644 index c824c7f..0000000 --- a/ECommons/ECommons/ImGuiMethods/EColor.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Dalamud.Interface.Colors; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Numerics; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.ImGuiMethods -{ - /// - /// A set of fancy color for use in plugins. You can redefine them to match necessary style! - /// - public static class EColor - { - public static Vector4 RedBright = ImGuiEx.Vector4FromRGB(0xFF0000); - public static Vector4 Red = ImGuiEx.Vector4FromRGB(0xAA0000); - public static Vector4 GreenBright = ImGuiEx.Vector4FromRGB(0x00ff00); - public static Vector4 Green = ImGuiEx.Vector4FromRGB(0x00aa00); - public static Vector4 BlueBright = ImGuiEx.Vector4FromRGB(0x0000ff); - public static Vector4 Blue = ImGuiEx.Vector4FromRGB(0x0000aa); - public static Vector4 White = ImGuiEx.Vector4FromRGB(0xFFFFFF); - public static Vector4 Black = ImGuiEx.Vector4FromRGB(0x000000); - public static Vector4 YellowBright = ImGuiEx.Vector4FromRGB(0xFFFF00); - public static Vector4 Yellow = ImGuiEx.Vector4FromRGB(0xAAAA00); - public static Vector4 OrangeBright = ImGuiEx.Vector4FromRGB(0xFF7F00); - public static Vector4 Orange = ImGuiEx.Vector4FromRGB(0xAA5400); - public static Vector4 CyanBright = ImGuiEx.Vector4FromRGB(0x00FFFF); - public static Vector4 Cya = ImGuiEx.Vector4FromRGB(0x00aaaa); - public static Vector4 VioletBright = ImGuiEx.Vector4FromRGB(0xFF00FF); - public static Vector4 Violet = ImGuiEx.Vector4FromRGB(0xAA00AA); - public static Vector4 BlueSky = ImGuiEx.Vector4FromRGB(0x0085FF); - public static Vector4 BlueSea = ImGuiEx.Vector4FromRGB(0x0058AA); - public static Vector4 PurpleBright = ImGuiEx.Vector4FromRGB(0xFF0084); - public static Vector4 Purple = ImGuiEx.Vector4FromRGB(0xAA0058); - public static Vector4 PinkLight = ImGuiEx.Vector4FromRGB(0xFFABD6); - } -} diff --git a/ECommons/ECommons/ImGuiMethods/GradientColor.cs b/ECommons/ECommons/ImGuiMethods/GradientColor.cs deleted file mode 100644 index 4a59e5c..0000000 --- a/ECommons/ECommons/ImGuiMethods/GradientColor.cs +++ /dev/null @@ -1,22 +0,0 @@ -using ECommons.MathHelpers; -using System; -using System.Numerics; - -namespace ECommons.ImGuiMethods; - -public static class GradientColor -{ - public static Vector4 Get(Vector4 start, Vector4 end, int Milliseconds = 1000) - { - var delta = (end - start) / (int)Milliseconds; - var time = Environment.TickCount64 % (Milliseconds * 2); - if (time < Milliseconds) - { - return start + delta * (float)(time % Milliseconds); - } - else - { - return end - delta * ((float)(time % Milliseconds)); - } - } -} diff --git a/ECommons/ECommons/ImGuiMethods/ImGuiBB.cs b/ECommons/ECommons/ImGuiMethods/ImGuiBB.cs deleted file mode 100644 index 2517116..0000000 --- a/ECommons/ECommons/ImGuiMethods/ImGuiBB.cs +++ /dev/null @@ -1,95 +0,0 @@ -using ImGuiNET; -using System; -using System.Collections.Generic; -using System.Numerics; -using System.Text.RegularExpressions; -using static ECommons.GenericHelpers; - -namespace ECommons.ImGuiMethods; - -public static class ImGuiBB -{ - static Dictionary> Cache = new(); - - public static void Text(string str, bool ignoreCache = false) - { - Safe(delegate - { - var result = Regex.Split(str, @"(\[color=[0-9a-z#]+\])|(\[\/color\])|(\[size=[0-9\.\,]+\])|(\[\/size\])|(\[img\].*?\[\/img\])|(\n)", RegexOptions.IgnoreCase); - var first = false; - foreach (var s in result) - { - //PluginLog.Information($"{s.Replace("\n", @"\n")}"); - if (s == "\n") - { - first = false; - continue; - } - if (s == String.Empty) continue; - if (s.StartsWith("[color=", StringComparison.OrdinalIgnoreCase)) - { - var col = s[7..^1].Replace("#", ""); - int r = 0, g = 0, b = 0; - if(col.Length == 3) - { - int.TryParse(col[0..1] + col[0..1], System.Globalization.NumberStyles.HexNumber, null, out r); - int.TryParse(col[1..2] + col[1..2], System.Globalization.NumberStyles.HexNumber, null, out g); - int.TryParse(col[2..3] + col[2..3], System.Globalization.NumberStyles.HexNumber, null, out b); - } - else if(col.Length == 6) - { - int.TryParse(col[0..2], System.Globalization.NumberStyles.HexNumber, null, out r); - int.TryParse(col[2..4], System.Globalization.NumberStyles.HexNumber, null, out g); - int.TryParse(col[4..6], System.Globalization.NumberStyles.HexNumber, null, out b); - } - var col4 = new Vector4((float)r/255f, (float)g/255f, (float)b/255f, 1f); - ImGui.PushStyleColor(ImGuiCol.Text, col4); - } - else if(s.Equals("[/color]", StringComparison.OrdinalIgnoreCase)) - { - ImGui.PopStyleColor(); - } - else if (s.StartsWith("[size=", StringComparison.OrdinalIgnoreCase)) - { - if(float.TryParse(s[6..^1], out var size) && size >= 0.1 && size <= 50) - { - ImGui.SetWindowFontScale(size); - } - } - else if (s.Equals("[/size]", StringComparison.OrdinalIgnoreCase)) - { - ImGui.SetWindowFontScale(1f); - } - else if (s.StartsWith("[img]", StringComparison.OrdinalIgnoreCase)) - { - - var imageUrl = s[5..^6]; - if (ThreadLoadImageHandler.TryGetTextureWrap(imageUrl, out var texture)) - { - if (first) - { - ImGui.SameLine(0, 0); - } - else - { - first = true; - } - ImGui.Image(texture.ImGuiHandle, new(texture.Width, texture.Height)); - } - } - else - { - if (first) - { - ImGui.SameLine(0, 0); - } - else - { - first = true; - } - ImGui.Text(s); - } - } - }); - } -} diff --git a/ECommons/ECommons/ImGuiMethods/ImGuiDragDrop.cs b/ECommons/ECommons/ImGuiMethods/ImGuiDragDrop.cs deleted file mode 100644 index 6f31a07..0000000 --- a/ECommons/ECommons/ImGuiMethods/ImGuiDragDrop.cs +++ /dev/null @@ -1,47 +0,0 @@ -using ImGuiNET; -using System; -using System.Runtime.CompilerServices; -using System.Text; - -namespace ECommons.ImGuiMethods; - -// ImGui extra functionality related with Drag and Drop -public static class ImGuiDragDrop -{ - // TODO: review - // can now pass refs with Unsafe.AsRef - - public static unsafe void SetDragDropPayload(string type, T data, ImGuiCond cond = 0) - where T : unmanaged - { - void* ptr = Unsafe.AsPointer(ref data); - ImGui.SetDragDropPayload(type, new IntPtr(ptr), (uint)Unsafe.SizeOf(), cond); - } - - public static unsafe bool AcceptDragDropPayload(string type, out T payload, ImGuiDragDropFlags flags = ImGuiDragDropFlags.None) - where T : unmanaged - { - ImGuiPayload* pload = ImGui.AcceptDragDropPayload(type, flags); - payload = (pload != null) ? Unsafe.Read(pload->Data) : default; - return pload != null; - } - - public static unsafe void SetDragDropPayload(string type, string data, ImGuiCond cond = 0) - { - fixed (char* chars = data) - { - int byteCount = Encoding.Default.GetByteCount(data); - byte* bytes = stackalloc byte[byteCount]; - Encoding.Default.GetBytes(chars, data.Length, bytes, byteCount); - - ImGui.SetDragDropPayload(type, new IntPtr(bytes), (uint)byteCount, cond); - } - } - - public static unsafe bool AcceptDragDropPayload(string type, out string payload, ImGuiDragDropFlags flags = ImGuiDragDropFlags.None) - { - ImGuiPayload* pload = ImGui.AcceptDragDropPayload(type, flags); - payload = (pload != null) ? Encoding.Default.GetString((byte*)pload->Data, pload->DataSize) : null; - return pload != null; - } -} diff --git a/ECommons/ECommons/ImGuiMethods/ImGuiEx.cs b/ECommons/ECommons/ImGuiMethods/ImGuiEx.cs deleted file mode 100644 index 4218a0e..0000000 --- a/ECommons/ECommons/ImGuiMethods/ImGuiEx.cs +++ /dev/null @@ -1,1115 +0,0 @@ -using Dalamud.Interface; -using Dalamud.Interface.Colors; -using Dalamud.Interface.Internal.Notifications; -using Dalamud.Interface.Style; -using Dalamud.Interface.Utility; -using Dalamud.Interface.Utility.Raii; -using Dalamud.Logging; -using ECommons.DalamudServices; -using ECommons.Reflection; -using ImGuiNET; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.Linq; -using System.Numerics; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Text; -using System.Xml.Linq; - -namespace ECommons.ImGuiMethods; - -public static unsafe partial class ImGuiEx -{ - public static bool ButtonCond(string name, Func condition) - { - var dis = !condition(); - if (dis) ImGui.BeginDisabled(); - var ret = ImGui.Button(name); - if (dis) ImGui.EndDisabled(); - return ret; - } - - public static bool InputLong(string id, ref long num) - { - var txt = num.ToString(); - var ret = ImGui.InputText(id, ref txt, 50); - long.TryParse(txt, out num); - return ret; - } - - public static bool CollapsingHeader(string text, Vector4? col = null) - { - if (col != null) ImGui.PushStyleColor(ImGuiCol.Text, col.Value); - var ret = ImGui.CollapsingHeader(text); - if (col != null) ImGui.PopStyleColor(); - return ret; - } - - - /// - /// Provides a button that can be used to switch ? variables. Left click - to toggle between and , right click - to toggle between and . - /// - /// - /// - /// Color when is true - /// Color when is false - /// Whether a button should be small - /// - public static bool ButtonCheckbox(string name, ref bool? value, Vector4? TrueColor = null, Vector4? FalseColor = null, bool smallButton = false) - { - TrueColor ??= EColor.Green; - FalseColor ??= EColor.Red; - var col = value; - var ret = false; - if (col == true) - { - ImGui.PushStyleColor(ImGuiCol.Button, TrueColor.Value); - ImGui.PushStyleColor(ImGuiCol.ButtonHovered, TrueColor.Value); - ImGui.PushStyleColor(ImGuiCol.ButtonActive, TrueColor.Value); - } - else if(col == false) - { - ImGui.PushStyleColor(ImGuiCol.Button, FalseColor.Value); - ImGui.PushStyleColor(ImGuiCol.ButtonHovered, FalseColor.Value); - ImGui.PushStyleColor(ImGuiCol.ButtonActive, FalseColor.Value); - } - if (smallButton ? ImGui.SmallButton(name) : ImGui.Button(name)) - { - if (value == null || value == false) - { - value = true; - } - else - { - value = false; - } - ret = true; - } - if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) - { - if (value == null || value == true) - { - value = false; - } - else - { - value = true; - } - ret = true; - } - if (col != null) ImGui.PopStyleColor(3); - return ret; - } - - /// - /// Converts RGB color to for ImGui - /// - /// Color in format 0xRRGGBB - /// Optional transparency value between 0 and 1 - /// Color in format ready to be used with functions - public static Vector4 Vector4FromRGB(this uint col, float alpha = 1.0f) - { - byte* bytes = (byte*)&col; - return new Vector4((float)bytes[2] / 255f, (float)bytes[1] / 255f, (float)bytes[0] / 255f, alpha); - } - - - /// - /// Converts RGBA color to for ImGui - /// - /// Color in format 0xRRGGBBAA - /// Color in format ready to be used with functions - public static Vector4 Vector4FromRGBA(this uint col) - { - byte* bytes = (byte*)&col; - return new Vector4((float)bytes[3] / 255f, (float)bytes[2] / 255f, (float)bytes[1] / 255f, (float)bytes[0] / 255f); - } - - /// - /// Draws a button that acts like a checkbox. - /// - /// Button text - /// Value - /// Whether button should be small - /// true when clicked, otherwise false - public static bool ButtonCheckbox(string name, ref bool value, bool smallButton = false) => ButtonCheckbox(name, ref value, EColor.Red, smallButton); - - /// - /// Draws a button that acts like a checkbox. - /// - /// Button text - /// Value - /// Active button color - /// Whether button should be small - /// true when clicked, otherwise false - public static bool ButtonCheckbox(string name, ref bool value, uint color, bool smallButton = false) => ButtonCheckbox(name, ref value, color.ToVector4(), smallButton); - - /// - /// Draws a button that acts like a checkbox. - /// - /// Button text - /// Value - /// Active button color - /// Whether button should be small - /// true when clicked, otherwise false - public static bool ButtonCheckbox(string name, ref bool value, Vector4 color, bool smallButton = false) - { - var col = value; - var ret = false; - if (col) - { - ImGui.PushStyleColor(ImGuiCol.Button, color); - ImGui.PushStyleColor(ImGuiCol.ButtonHovered, color); - ImGui.PushStyleColor(ImGuiCol.ButtonActive, color); - } - if (smallButton?ImGui.SmallButton(name):ImGui.Button(name)) - { - value = !value; - ret = true; - } - if (col) ImGui.PopStyleColor(3); - return ret; - } - - public static bool CollectionButtonCheckbox(string name, T value, HashSet collection, bool smallButton = false) => CollectionButtonCheckbox(name, value, collection, EColor.Red, smallButton); - - public static bool CollectionButtonCheckbox(string name, T value, HashSet collection, Vector4 color, bool smallButton = false) - { - var col = collection.Contains(value); - var ret = false; - if (col) - { - ImGui.PushStyleColor(ImGuiCol.Button, color); - ImGui.PushStyleColor(ImGuiCol.ButtonHovered, color); - ImGui.PushStyleColor(ImGuiCol.ButtonActive, color); - } - if (smallButton ? ImGui.SmallButton(name) : ImGui.Button(name)) - { - if (col) - { - collection.Remove(value); - } - else - { - collection.Add(value); - } - ret = true; - } - if (col) ImGui.PopStyleColor(3); - return ret; - } - - /// - /// Draws two radio buttons for a boolean value. - /// - /// True choice radio button text - /// False choice radio button text - /// Value - /// Whether to draw radio buttons on the same line - /// Will be invoked before each radio button draw - /// Will be invoked after each radio button draw - public static void RadioButtonBool(string labelTrue, string labelFalse, ref bool value, bool sameLine = false, Action prefix = null, Action suffix = null) - { - prefix?.Invoke(); - if (ImGui.RadioButton(labelTrue, value)) value = true; - suffix?.Invoke(); - if (sameLine) ImGui.SameLine(); - prefix?.Invoke(); - if (ImGui.RadioButton(labelFalse, !value)) value = false; - suffix?.Invoke(); - } - - /// - /// Draws equally sized columns without ability to resize - /// - /// Unique ImGui ID - /// List of actions for each column - public static void EzTableColumns(string id, Action[] values) - { - if (values.Length == 1) - { - GenericHelpers.Safe(values[0]); - } - else - { - if (ImGui.BeginTable(id, values.Length, ImGuiTableFlags.SizingStretchSame)) - { - foreach (Action action in values) - { - ImGui.TableNextColumn(); - GenericHelpers.Safe(action); - } - ImGui.EndTable(); - } - } - } - - public static bool ButtonCtrl(string text, string affix = " (Hold CTRL)") => ButtonCtrl(text, null, affix); - - /// - /// Button that is disabled unless CTRL key is held - /// - /// Button ID - /// Button affix - /// - public static bool ButtonCtrl(string text, Vector2? size, string affix = " (Hold CTRL)") - { - var disabled = !ImGui.GetIO().KeyCtrl; - if (disabled) - { - ImGui.BeginDisabled(); - } - var name = string.Empty; - if (text.Contains($"###")) - { - var p = text.Split($"###"); - name = $"{p[0]}{affix}###{p[1]}"; - } - else if (text.Contains($"##")) - { - var p = text.Split($"##"); - name = $"{p[0]}{affix}##{p[1]}"; - } - else - { - name = $"{text}{affix}"; - } - var ret = size == null?ImGui.Button(name):ImGui.Button(name, size.Value); - if (disabled) - { - ImGui.EndDisabled(); - } - return ret; - } - - public static bool BeginPopupNextToElement(string popupId) - { - ImGui.SameLine(0, 0); - var pos = ImGui.GetCursorScreenPos(); - ImGui.Dummy(Vector2.Zero); - ImGui.SetNextWindowPos(pos, ImGuiCond.Appearing); - return ImGui.BeginPopup(popupId); - } - - [Obsolete("Please switch to CollectionCheckbox")] - public static bool HashSetCheckbox(string label, T value, HashSet collection) => CollectionCheckbox(label, value, collection); - - public static bool CollectionCheckbox(string label, T value, HashSet collection) - { - var x = collection.Contains(value); - if (ImGui.Checkbox(label, ref x)) - { - if (x) - { - collection.Add(value); - } - else - { - collection.Remove(value); - } - return true; - } - return false; - } - - public record HeaderIconOptions - { - public Vector2 Offset { get; init; } = Vector2.Zero; - public ImGuiMouseButton MouseButton { get; init; } = ImGuiMouseButton.Left; - public string Tooltip { get; init; } = string.Empty; - public uint Color { get; init; } = 0xFFFFFFFF; - public bool ToastTooltipOnClick { get; init; } = false; - public ImGuiMouseButton ToastTooltipOnClickButton { get; init; } = ImGuiMouseButton.Left; - } - - private static uint headerLastWindowID = 0; - private static ulong headerLastFrame = 0; - private static float headerCurrentPos = 0; - private static float headerImGuiButtonWidth = 0; - - public static bool AddHeaderIcon(string id, FontAwesomeIcon icon, HeaderIconOptions options = null) - { - if (ImGui.IsWindowCollapsed()) return false; - - var scale = ImGuiHelpers.GlobalScale; - var currentID = ImGui.GetID(0); - if (currentID != headerLastWindowID || headerLastFrame != Svc.PluginInterface.UiBuilder.FrameCount) - { - headerLastWindowID = currentID; - headerLastFrame = Svc.PluginInterface.UiBuilder.FrameCount; - headerCurrentPos = 0.25f * ImGui.GetStyle().FramePadding.Length(); - if (!GetCurrentWindowFlags().HasFlag(ImGuiWindowFlags.NoTitleBar)) - headerCurrentPos = 1; - headerImGuiButtonWidth = 0f; - if (CurrentWindowHasCloseButton()) - headerImGuiButtonWidth += 17 * scale; - if (!GetCurrentWindowFlags().HasFlag(ImGuiWindowFlags.NoCollapse)) - headerImGuiButtonWidth += 17 * scale; - } - - options ??= new(); - var prevCursorPos = ImGui.GetCursorPos(); - var buttonSize = new Vector2(20 * scale); - var buttonPos = new Vector2((ImGui.GetWindowWidth() - buttonSize.X - headerImGuiButtonWidth * scale * headerCurrentPos) - (ImGui.GetStyle().FramePadding.X * scale), ImGui.GetScrollY() + 1); - ImGui.SetCursorPos(buttonPos); - var drawList = ImGui.GetWindowDrawList(); - drawList.PushClipRectFullScreen(); - - var pressed = false; - ImGui.InvisibleButton(id, buttonSize); - var itemMin = ImGui.GetItemRectMin(); - var itemMax = ImGui.GetItemRectMax(); - var halfSize = ImGui.GetItemRectSize() / 2; - var center = itemMin + halfSize; - if (ImGui.IsWindowHovered() && ImGui.IsMouseHoveringRect(itemMin, itemMax, false)) - { - if (!string.IsNullOrEmpty(options.Tooltip)) - ImGui.SetTooltip(options.Tooltip); - ImGui.GetWindowDrawList().AddCircleFilled(center, halfSize.X, ImGui.GetColorU32(ImGui.IsMouseDown(ImGuiMouseButton.Left) ? ImGuiCol.ButtonActive : ImGuiCol.ButtonHovered)); - if (ImGui.IsMouseReleased(options.MouseButton)) - pressed = true; - if (options.ToastTooltipOnClick && ImGui.IsMouseReleased(options.ToastTooltipOnClickButton)) - Svc.PluginInterface.UiBuilder.AddNotification(options.Tooltip!, null, NotificationType.Info); - } - - ImGui.SetCursorPos(buttonPos); - ImGui.PushFont(UiBuilder.IconFont); - var iconString = icon.ToIconString(); - drawList.AddText(UiBuilder.IconFont, ImGui.GetFontSize(), itemMin + halfSize - ImGui.CalcTextSize(iconString) / 2 + options.Offset, options.Color, iconString); - ImGui.PopFont(); - - ImGui.PopClipRect(); - ImGui.SetCursorPos(prevCursorPos); - - return pressed; - } - - public static bool CollectionCheckbox(string label, T value, List collection, bool inverted = false) - { - var x = collection.Contains(value); - if (inverted) x = !x; - if (ImGui.Checkbox(label, ref x)) - { - if (inverted) x = !x; - if (x) - { - collection.Add(value); - } - else - { - collection.RemoveAll(x => x.Equals(value)); - } - return true; - } - return false; - } - - public static Vector4 MutateColor(ImGuiCol col, byte r, byte g, byte b) - { - return ImGui.GetStyle().Colors[(int)col] with { X = (float)r / 255f, Y = (float)g / 255f, Z = (float)b / 255f }; - } - - /// - /// Displays ImGui.SliderFloat for internal int value. - /// - /// ImGui ID - /// Integer value - /// Minimal value - /// Maximum value - /// Value is divided by divider before being presented to user - /// - public static bool SliderIntAsFloat(string id, ref int value, int min, int max, float divider = 1000) - { - var f = (float)value / divider; - var ret = ImGui.SliderFloat(id, ref f, (float)min / divider, (float)max / divider); - if (ret) - { - value = (int)(f * divider); - } - return ret; - } - - public static bool IsKeyPressed(int key, bool repeat) - { - byte repeat2 = (byte)(repeat ? 1 : 0); - return ImGuiNative.igIsKeyPressed((ImGuiKey)key, repeat2) != 0; - } - - public static void TextUnderlined(uint color, string text) - { - ImGui.PushStyleColor(ImGuiCol.Text, color); - TextUnderlined(text); - ImGui.PopStyleColor(); - } - - public static void TextUnderlined(Vector4 color, string text) - { - ImGui.PushStyleColor(ImGuiCol.Text, color); - TextUnderlined(text); - ImGui.PopStyleColor(); - } - - public static void TextUnderlined(string text) - { - var size = ImGui.CalcTextSize(text); - var cur = ImGui.GetCursorScreenPos(); - cur.Y += size.Y; - ImGui.GetWindowDrawList().PathLineTo(cur); - cur.X += size.X; - ImGui.GetWindowDrawList().PathLineTo(cur); - ImGui.GetWindowDrawList().PathStroke(ImGuiColors.DalamudWhite.ToUint()); - ImGuiEx.Text(text); - } - - public static float GetWindowContentRegionWidth() - { - return ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X; - } - - public static void Spacing(float pix = 10f, bool accountForScale = true) - { - ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (accountForScale ? pix : pix * ImGuiHelpers.GlobalScale)); - } - - public static float Scale(this float f) - { - return f * ImGuiHelpers.GlobalScale; - } - - public static void SetTooltip(string text) - { - ImGui.BeginTooltip(); - ImGui.TextUnformatted(text); - ImGui.EndTooltip(); - } - - static readonly Dictionary CenteredLineWidths = new(); - public static void ImGuiLineCentered(string id, Action func) - { - if (CenteredLineWidths.TryGetValue(id, out var dims)) - { - ImGui.SetCursorPosX(ImGui.GetContentRegionAvail().X / 2 - dims / 2); - } - var oldCur = ImGui.GetCursorPosX(); - func(); - ImGui.SameLine(0, 0); - CenteredLineWidths[id] = ImGui.GetCursorPosX() - oldCur; - ImGui.Dummy(Vector2.Zero); - } - - public static void SetNextItemFullWidth(int mod = 0) - { - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X + mod); - } - - public static void SetNextItemWidth(float percent, int mod = 0) - { - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X * percent + mod); - } - - static Dictionary InputWithRightButtonsAreaValues = new(); - /// - /// Convenient way to display stretched input with button or other elements on it's right side. - /// - /// Unique ID - /// A single element that accepts transformation by ImGui.SetNextItemWidth method - /// A line of elements on the right side. Can contain multiple elements but only one line. - public static void InputWithRightButtonsArea(string id, Action inputAction, Action rightAction) - { - if (InputWithRightButtonsAreaValues.ContainsKey(id)) - { - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X - InputWithRightButtonsAreaValues[id]); - } - inputAction(); - ImGui.SameLine(); - var cur1 = ImGui.GetCursorPosX(); - rightAction(); - ImGui.SameLine(0, 0); - InputWithRightButtonsAreaValues[id] = ImGui.GetCursorPosX() - cur1 + ImGui.GetStyle().ItemSpacing.X; - ImGui.Dummy(Vector2.Zero); - } - - static Dictionary> InputListValuesString = new(); - public static void InputListString(string name, List list, Dictionary overrideValues = null) - { - if (!InputListValuesString.ContainsKey(name)) InputListValuesString[name] = new(""); - InputList(name, list, overrideValues, delegate - { - var buttonSize = ImGuiHelpers.GetButtonSize("Add"); - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X - buttonSize.X - ImGui.GetStyle().ItemSpacing.X); - ImGui.InputText($"##{name.Replace("#", "_")}", ref InputListValuesString[name].Value, 100); - ImGui.SameLine(); - if (ImGui.Button("Add")) - { - list.Add(InputListValuesString[name].Value); - InputListValuesString[name].Value = ""; - } - }); - } - - static Dictionary> InputListValuesUint = new(); - public static void InputListUint(string name, List list, Dictionary overrideValues = null) - { - if (!InputListValuesUint.ContainsKey(name)) InputListValuesUint[name] = new(0); - InputList(name, list, overrideValues, delegate - { - var buttonSize = ImGuiHelpers.GetButtonSize("Add"); - ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X - buttonSize.X - ImGui.GetStyle().ItemSpacing.X); - ImGuiEx.InputUint($"##{name.Replace("#", "_")}", ref InputListValuesUint[name].Value); - ImGui.SameLine(); - if (ImGui.Button("Add")) - { - list.Add(InputListValuesUint[name].Value); - InputListValuesUint[name].Value = 0; - } - }); - } - - public static void InputList(string name, List list, Dictionary overrideValues, Action addFunction) - { - var text = list.Count == 0 ? "- No values -" : (list.Count == 1 ? $"{(overrideValues != null && overrideValues.ContainsKey(list[0]) ? overrideValues[list[0]] : list[0])}" : $"- {list.Count} elements -"); - if (ImGui.BeginCombo(name, text)) - { - addFunction(); - var rem = -1; - for (var i = 0; i < list.Count; i++) - { - var id = $"{name}ECommonsDeleItem{i}"; - var x = list[i]; - ImGui.Selectable($"{(overrideValues != null && overrideValues.ContainsKey(x) ? overrideValues[x] : x)}"); - if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) - { - ImGui.OpenPopup(id); - } - if (ImGui.BeginPopup(id)) - { - if (ImGui.Selectable("Delete##ECommonsDeleItem")) - { - rem = i; - } - if (ImGui.Selectable("Clear (hold shift+ctrl)##ECommonsDeleItem") - && ImGui.GetIO().KeyShift && ImGui.GetIO().KeyCtrl) - { - rem = -2; - } - ImGui.EndPopup(); - } - } - if (rem > -1) - { - list.RemoveAt(rem); - } - if (rem == -2) - { - list.Clear(); - } - ImGui.EndCombo(); - } - } - - public static void WithTextColor(Vector4 col, Action func) - { - ImGui.PushStyleColor(ImGuiCol.Text, col); - GenericHelpers.Safe(func); - ImGui.PopStyleColor(); - } - - public static void Tooltip(string s) - { - if (ImGui.IsItemHovered()) - { - ImGui.SetTooltip(s); - } - } - - /// - /// Aligns text vertically to a standard size button. - /// - /// Color - /// Text - public static void TextV(Vector4? col, string s) - { - if(col != null) ImGui.PushStyleColor(ImGuiCol.Text, col.Value); - ImGuiEx.TextV(s); - if(col != null) ImGui.PopStyleColor(); - } - - /// - /// Aligns text vertically to a standard size button. - /// - /// Text - public static void TextV(string s) - { - var cur = ImGui.GetCursorPos(); - ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0); - ImGui.Button(""); - ImGui.PopStyleVar(); - ImGui.SameLine(); - ImGui.SetCursorPos(cur); - ImGui.TextUnformatted(s); - } - - public static void Text(string s) - { - ImGui.TextUnformatted(s); - } - - public static void Text(Vector4 col, string s) - { - ImGui.PushStyleColor(ImGuiCol.Text, col); - ImGui.TextUnformatted(s); - ImGui.PopStyleColor(); - } - - public static void Text(uint col, string s) - { - ImGui.PushStyleColor(ImGuiCol.Text, col); - ImGui.TextUnformatted(s); - ImGui.PopStyleColor(); - } - - public static void TextWrapped(string s) - { - ImGui.PushTextWrapPos(); - ImGui.TextUnformatted(s); - ImGui.PopTextWrapPos(); - } - - public static void TextWrapped(Vector4 col, string s) - { - ImGui.PushTextWrapPos(0); - ImGuiEx.Text(col, s); - ImGui.PopTextWrapPos(); - } - - public static void TextWrapped(uint col, string s) - { - ImGui.PushTextWrapPos(); - ImGuiEx.Text(col, s); - ImGui.PopTextWrapPos(); - } - - public static Vector4 GetParsedColor(int percent) - { - if (percent < 25) - { - return ImGuiColors.ParsedGrey; - } - else if (percent < 50) - { - return ImGuiColors.ParsedGreen; - } - else if (percent < 75) - { - return ImGuiColors.ParsedBlue; - } - else if (percent < 95) - { - return ImGuiColors.ParsedPurple; - } - else if (percent < 99) - { - return ImGuiColors.ParsedOrange; - } - else if (percent == 99) - { - return ImGuiColors.ParsedPink; - } - else if (percent == 100) - { - return ImGuiColors.ParsedGold; - } - else - { - return ImGuiColors.DalamudRed; - } - } - - public static void EzTabBar(string id, params (string name, Action function, Vector4? color, bool child)[] tabs) => EzTabBar(id, false, tabs); - - public static void EzTabBar(string id, bool KoFiTransparent, params (string name, Action function, Vector4? color, bool child)[] tabs) - { - ImGui.BeginTabBar(id); - foreach (var x in tabs) - { - if (x.name == null) continue; - if (x.color != null) - { - ImGui.PushStyleColor(ImGuiCol.Text, x.color.Value); - } - if (ImGui.BeginTabItem(x.name)) - { - if (x.color != null) - { - ImGui.PopStyleColor(); - } - if (x.child) ImGui.BeginChild(x.name + "child"); - x.function(); - if (x.child) ImGui.EndChild(); - ImGui.EndTabItem(); - } - else - { - if (x.color != null) - { - ImGui.PopStyleColor(); - } - } - } - if (KoFiTransparent) KoFiButton.RightTransparentTab(); - ImGui.EndTabBar(); - } - - public static void InvisibleButton(int width = 0) - { - ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0); - ImGui.Button(" "); - ImGui.PopStyleVar(); - } - - public static Dictionary> EnumComboSearch = new(); - /// - /// Draws an easy combo selector for an enum with a search field for long lists. - /// - /// Enum - /// ImGui ID - /// Value - /// Optional Name overrides - public static bool EnumCombo(string name, ref T refConfigField, IDictionary names) where T : IConvertible - { - return EnumCombo(name, ref refConfigField, null, names); - } - - /// - /// Draws an easy combo selector for an enum with a search field for long lists. - /// - /// Enum - /// ImGui ID - /// Value - /// Optional filter - /// Optional Name overrides - /// - public static bool EnumCombo(string name, ref T refConfigField, Func filter = null, IDictionary names = null) where T : IConvertible - { - var ret = false; - if (ImGui.BeginCombo(name, (names != null && names.TryGetValue(refConfigField, out var n)) ? n : refConfigField.ToString().Replace("_", " "))) - { - var values = Enum.GetValues(typeof(T)); - Box fltr = null; - if (values.Length > 10) - { - if (!EnumComboSearch.ContainsKey(name)) EnumComboSearch.Add(name, new("")); - fltr = EnumComboSearch[name]; - ImGuiEx.SetNextItemFullWidth(); - ImGui.InputTextWithHint($"##{name.Replace("#", "_")}", "Filter...", ref fltr.Value, 50); - } - foreach (var x in values) - { - var equals = EqualityComparer.Default.Equals((T)x, refConfigField); - var element = (names != null && names.TryGetValue((T)x, out n)) ? n : x.ToString().Replace("_", " "); - if ((filter == null || filter((T)x)) - && (fltr == null || element.Contains(fltr.Value, StringComparison.OrdinalIgnoreCase)) - && ImGui.Selectable(element, equals) - ) - { - ret = true; - refConfigField = (T)x; - } - if (ImGui.IsWindowAppearing() && equals) ImGui.SetScrollHereY(); - } - ImGui.EndCombo(); - } - return ret; - } - - public static Dictionary> ComboSearch = new(); - public static bool Combo(string name, ref T refConfigField, IEnumerable values, Func filter = null, Dictionary names = null) - { - var ret = false; - if (ImGui.BeginCombo(name, (names != null && names.TryGetValue(refConfigField, out var n)) ? n : refConfigField.ToString())) - { - Box fltr = null; - if (values.Count() > 10) - { - if (!ComboSearch.ContainsKey(name)) ComboSearch.Add(name, new("")); - fltr = ComboSearch[name]; - ImGuiEx.SetNextItemFullWidth(); - ImGui.InputTextWithHint($"##{name}fltr", "Filter...", ref fltr.Value, 50); - } - foreach (var x in values) - { - var equals = EqualityComparer.Default.Equals(x, refConfigField); - var element = (names != null && names.TryGetValue(x, out n)) ? n : x.ToString(); - if ((filter == null || filter(x)) - && (fltr == null || element.Contains(fltr.Value, StringComparison.OrdinalIgnoreCase)) - && ImGui.Selectable(element, equals) - ) - { - ret = true; - refConfigField = x; - } - if (ImGui.IsWindowAppearing() && equals) ImGui.SetScrollHereY(); - } - ImGui.EndCombo(); - } - return ret; - } - - public static bool IconButton(FontAwesomeIcon icon, string id = "ECommonsButton", Vector2 size = default) - { - ImGui.PushFont(UiBuilder.IconFont); - var result = ImGui.Button($"{icon.ToIconString()}##{icon.ToIconString()}-{id}", size); - ImGui.PopFont(); - return result; - } - - public static bool SmallIconButton(string icon, string id = "ECommonsButton") - { - ImGui.PushFont(UiBuilder.IconFont); - var result = ImGui.SmallButton($"{icon}##{icon}-{id}"); - ImGui.PopFont(); - return result; - } - - public static bool IconButton(string icon, string id = "ECommonsButton") - { - ImGui.PushFont(UiBuilder.IconFont); - var result = ImGui.Button($"{icon}##{icon}-{id}"); - ImGui.PopFont(); - return result; - } - - public static Vector2 CalcIconSize(FontAwesomeIcon icon) - { - ImGui.PushFont(UiBuilder.IconFont); - var result = ImGui.CalcTextSize($"{icon.ToIconString()}"); - ImGui.PopFont(); - return result; - } - - public static float Measure(Action func, bool includeSpacing = true) - { - var pos = ImGui.GetCursorPosX(); - func(); - ImGui.SameLine(0, 0); - var diff = ImGui.GetCursorPosX() - pos; - ImGui.Dummy(Vector2.Zero); - return diff + (includeSpacing ? ImGui.GetStyle().ItemSpacing.X : 0); - } - - public static void InputHex(string name, ref uint hexInt) - { - var text = $"{hexInt:X}"; - if (ImGui.InputText(name, ref text, 8)) - { - if (uint.TryParse(text.Replace("0x", ""), NumberStyles.HexNumber, null, out var num)) - { - hexInt = num; - } - } - } - - public static void InputHex(string name, ref byte hexByte) - { - var text = $"{hexByte:X}"; - if (ImGui.InputText(name, ref text, 2)) - { - if (byte.TryParse(text, NumberStyles.HexNumber, null, out var num)) - { - hexByte = num; - } - } - } - - public static void InputUint(string name, ref uint uInt) - { - var text = $"{uInt}"; - if (ImGui.InputText(name, ref text, 16)) - { - if (uint.TryParse(text, out var num)) - { - uInt = num; - } - } - } - - public static void TextCopy(Vector4 col, string text) - { - ImGui.PushStyleColor(ImGuiCol.Text, col); - TextCopy(text); - ImGui.PopStyleColor(); - } - - public static void TextCopy(string text) - { - ImGui.TextUnformatted(text); - if (ImGui.IsItemHovered()) - { - ImGui.SetMouseCursor(ImGuiMouseCursor.Hand); - } - if (ImGui.IsItemClicked(ImGuiMouseButton.Left)) - { - ImGui.SetClipboardText(text); - Svc.PluginInterface.UiBuilder.AddNotification("Text copied to clipboard", null, NotificationType.Success); - } - } - - public static void TextWrappedCopy(string text) - { - ImGuiEx.TextWrapped(text); - if (ImGui.IsItemHovered()) - { - ImGui.SetMouseCursor(ImGuiMouseCursor.Hand); - } - if (ImGui.IsItemClicked(ImGuiMouseButton.Left)) - { - ImGui.SetClipboardText(text); - Svc.PluginInterface.UiBuilder.AddNotification("Text copied to clipboard", DalamudReflector.GetPluginName(), NotificationType.Success); - } - } - - public static void TextWrappedCopy(Vector4 col, string text) - { - ImGuiEx.TextWrapped(col, text); - if (ImGui.IsItemHovered()) - { - ImGui.SetMouseCursor(ImGuiMouseCursor.Hand); - } - if (ImGui.IsItemClicked(ImGuiMouseButton.Left)) - { - ImGui.SetClipboardText(text); - Svc.PluginInterface.UiBuilder.AddNotification("Text copied to clipboard", DalamudReflector.GetPluginName(), NotificationType.Success); - } - } - - public static void TextCentered(string text) - { - ImGui.SetCursorPosX(ImGui.GetCursorPosX() + ImGui.GetContentRegionAvail().X / 2 - ImGui.CalcTextSize(text).X / 2); - Text(text); - } - - public static void TextCentered(Vector4 col, string text) - { - ImGui.PushStyleColor(ImGuiCol.Text, col); - TextCentered(text); - ImGui.PopStyleColor(); - } - - public static void Text(Vector4? col, string text) - { - if(col == null) - { - Text(text); - } - else - { - Text(col.Value, text); - } - } - - public static void TextCentered(Vector4? col, string text) - { - if (col == null) - { - TextCentered(text); - } - else - { - TextCentered(col.Value, text); - } - } - - public static void ButtonCopy(string buttonText, string copy) - { - if (ImGui.Button(buttonText.Replace("$COPY", copy))) - { - ImGui.SetClipboardText(copy); - Svc.PluginInterface.UiBuilder.AddNotification("Text copied to clipboard", null, NotificationType.Success); - } - } - - public static void CenterColumnText(string text, bool underlined = false) - { - ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (ImGui.GetColumnWidth() * 0.5f) - (ImGui.CalcTextSize(text).X * 0.5f)); - if (underlined) - TextUnderlined(text); - else - Text(text); - } - - public static void CenterColumnText(Vector4 colour, string text, bool underlined = false) - { - ImGui.PushStyleColor(ImGuiCol.Text, colour); - CenterColumnText(text, underlined); - ImGui.PopStyleColor(); - } - - public unsafe static bool BeginTabItem(string label, ImGuiTabItemFlags flags) - { - int num = 0; - byte* ptr; - if (label != null) - { - num = Encoding.UTF8.GetByteCount(label); - ptr = Allocate(num + 1); - int utf = GetUtf8(label, ptr, num); - ptr[utf] = 0; - } - else - { - ptr = null; - } - - byte* p_open2 = null; - byte num2 = ImGuiNative.igBeginTabItem(ptr, p_open2, flags); - if (num > 2048) - { - Free(ptr); - } - return num2 != 0; - } - - internal unsafe static byte* Allocate(int byteCount) - { - return (byte*)(void*)Marshal.AllocHGlobal(byteCount); - } - - internal unsafe static void Free(byte* ptr) - { - Marshal.FreeHGlobal((IntPtr)ptr); - } - - internal unsafe static int GetUtf8(string s, byte* utf8Bytes, int utf8ByteCount) - { - fixed (char* chars = s) - { - return Encoding.UTF8.GetBytes(chars, s.Length, utf8Bytes, utf8ByteCount); - } - } -} - -[StructLayout(LayoutKind.Explicit)] -public struct ImGuiWindow -{ - [FieldOffset(0xC)] public ImGuiWindowFlags Flags; - - [FieldOffset(0xD5)] public byte HasCloseButton; - - // 0x118 is the start of ImGuiWindowTempData - [FieldOffset(0x130)] public Vector2 CursorMaxPos; -} - -public static partial class ImGuiEx -{ - [LibraryImport("cimgui")] - [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] - private static partial nint igGetCurrentWindow(); - public static unsafe ImGuiWindow* GetCurrentWindow() => (ImGuiWindow*)igGetCurrentWindow(); - public static unsafe ImGuiWindowFlags GetCurrentWindowFlags() => GetCurrentWindow()->Flags; - public static unsafe bool CurrentWindowHasCloseButton() => GetCurrentWindow()->HasCloseButton != 0; - -} - diff --git a/ECommons/ECommons/ImGuiMethods/ImGuiNoRef.cs b/ECommons/ECommons/ImGuiMethods/ImGuiNoRef.cs deleted file mode 100644 index f4921cb..0000000 --- a/ECommons/ECommons/ImGuiMethods/ImGuiNoRef.cs +++ /dev/null @@ -1,23 +0,0 @@ -using ImGuiNET; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.ImGuiMethods -{ - public static class ImGuiNoRef - { - public static bool Checkbox(string label, bool value, out bool newResult) - { - if(ImGui.Checkbox(label, ref value)) - { - newResult = value; - return true; - } - newResult = default; - return false; - } - } -} diff --git a/ECommons/ECommons/ImGuiMethods/ImGuiTrans.cs b/ECommons/ECommons/ImGuiMethods/ImGuiTrans.cs deleted file mode 100644 index 32d6805..0000000 --- a/ECommons/ECommons/ImGuiMethods/ImGuiTrans.cs +++ /dev/null @@ -1,50 +0,0 @@ -using ImGuiNET; -using System; -using System.Numerics; - -namespace ECommons.ImGuiMethods; - -[Obsolete("Deprecated", true)] -public class ImGuiTrans -{ - public static void PushStyleColor(ImGuiCol target, Vector4 value) - { - ImGui.PushStyleColor(target, value with { W = ImGui.GetStyle().Colors[(int)target].W }); - } - - public static void PushTransparency(float v) - { - foreach (var c in Enum.GetValues()) - { - if (c == ImGuiCol.COUNT) continue; - var col = ImGui.GetStyle().Colors[(int)c]; - ImGui.PushStyleColor(c, col with { W = col.W * v }); - } - } - - public static void PopTransparency() - { - ImGui.PopStyleColor(Enum.GetValues().Length - 1); - } - - public static void WithTextColor(Vector4 col, Action func) - { - ImGuiTrans.PushStyleColor(ImGuiCol.Text, col); - GenericHelpers.Safe(func); - ImGui.PopStyleColor(); - } - - public static void Text(Vector4 col, string s) - { - ImGuiTrans.PushStyleColor(ImGuiCol.Text, col); - ImGui.TextUnformatted(s); - ImGui.PopStyleColor(); - } - - public static void TextWrapped(Vector4 col, string s) - { - ImGui.PushTextWrapPos(0); - ImGuiTrans.Text(col, s); - ImGui.PopTextWrapPos(); - } -} diff --git a/ECommons/ECommons/ImGuiMethods/ImageLoadingResult.cs b/ECommons/ECommons/ImGuiMethods/ImageLoadingResult.cs deleted file mode 100644 index 0eaded8..0000000 --- a/ECommons/ECommons/ImGuiMethods/ImageLoadingResult.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Dalamud.Interface.Internal; -using ImGuiScene; - -namespace ECommons.ImGuiMethods; - -internal class ImageLoadingResult -{ - internal IDalamudTextureWrap texture = null; - internal bool isCompleted = false; -} diff --git a/ECommons/ECommons/ImGuiMethods/KoFiButton.cs b/ECommons/ECommons/ImGuiMethods/KoFiButton.cs deleted file mode 100644 index 8370565..0000000 --- a/ECommons/ECommons/ImGuiMethods/KoFiButton.cs +++ /dev/null @@ -1,69 +0,0 @@ -using Dalamud.Interface; -using Dalamud.Interface.Colors; -using Dalamud.Interface.Utility; -using ECommons.DalamudServices; -using ImGuiNET; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Numerics; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.ImGuiMethods -{ - public static class KoFiButton - { - public static bool IsOfficialPlugin = false; - public const string Text = "Support on Ko-fi"; - public static string DonateLink => "https://nightmarexiv.github.io/donate.html" + (IsOfficialPlugin ? "?official" : ""); - public static void DrawRaw() - { - DrawButton(); - } - - const uint ColorNormal = 0xFF942502; - const uint ColorHovered = 0xFF942502; - const uint ColorActive = 0xFF942502; - const uint ColorText = 0xFFFFFFFF; - - public static void DrawButton() - { - ImGui.PushStyleColor(ImGuiCol.Button, ColorNormal); - ImGui.PushStyleColor(ImGuiCol.ButtonHovered, ColorHovered); - ImGui.PushStyleColor(ImGuiCol.ButtonActive, ColorActive); - ImGui.PushStyleColor(ImGuiCol.Text, ColorText); - if (ImGui.Button(Text)) - { - GenericHelpers.ShellStart(DonateLink); - } - if (ImGui.IsItemHovered()) - { - ImGui.SetMouseCursor(ImGuiMouseCursor.Hand); - } - ImGui.PopStyleColor(4); - } - - public static void RightTransparentTab() - { - var textWidth = ImGui.CalcTextSize(KoFiButton.Text).X; - var spaceWidth = ImGui.CalcTextSize(" ").X; - ImGui.BeginDisabled(); - ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0f); - if (ImGuiEx.BeginTabItem(" ".Repeat((int)MathF.Ceiling(textWidth / spaceWidth)), ImGuiTabItemFlags.Trailing)) - { - ImGui.EndTabItem(); - } - ImGui.PopStyleVar(); - ImGui.EndDisabled(); - } - - public static void DrawRight() - { - var cur = ImGui.GetCursorPos(); - ImGui.SetCursorPosX(cur.X + ImGui.GetContentRegionAvail().X - ImGuiHelpers.GetButtonSize(Text).X); - DrawRaw(); - ImGui.SetCursorPos(cur); - } - } -} diff --git a/ECommons/ECommons/ImGuiMethods/MiddleOverlayWindow.cs b/ECommons/ECommons/ImGuiMethods/MiddleOverlayWindow.cs deleted file mode 100644 index 1ed5f0e..0000000 --- a/ECommons/ECommons/ImGuiMethods/MiddleOverlayWindow.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Numerics; -using Dalamud.Interface; -using Dalamud.Interface.Utility; -using Dalamud.Interface.Windowing; -using ECommons.DalamudServices; -using ImGuiNET; - -namespace ECommons.ImGuiMethods; - -public class MiddleOverlayWindow:Window, IDisposable -{ - int? TopOffset = null; - Vector4? bgCol = null; - Vector2 pos = Vector2.Zero; - WindowSystem ws = new(); - Action draw; - bool disposed = false; - public MiddleOverlayWindow(string name, Action draw, int? topOffset = null, Vector4? bgCol = null) : base(name, ImGuiWindowFlags.NoInputs - | ImGuiWindowFlags.NoNav - | ImGuiWindowFlags.NoTitleBar - | ImGuiWindowFlags.NoFocusOnAppearing - | ImGuiWindowFlags.NoSavedSettings - | ImGuiWindowFlags.NoScrollbar - | ImGuiWindowFlags.AlwaysAutoResize, true) - { - TopOffset = topOffset; - this.bgCol = bgCol; - this.draw = draw; - ws.AddWindow(this); - this.IsOpen = true; - Svc.PluginInterface.UiBuilder.Draw += ws.Draw; - } - - public override bool DrawConditions() - { - return Svc.ClientState.LocalPlayer != null; - } - - public override void Draw() - { - this.draw(); - pos = ImGui.GetWindowSize(); - } - - public override void PreDraw() - { - base.PreDraw(); - ImGui.SetNextWindowPos(new Vector2(ImGuiHelpers.MainViewport.Size.X / 2 - pos.X / 2, - TopOffset ?? ImGuiHelpers.MainViewport.Size.Y / 3)); - if (bgCol.HasValue) ImGui.PushStyleColor(ImGuiCol.WindowBg, bgCol.Value); - } - - public override void PostDraw() - { - base.PostDraw(); - if (bgCol.HasValue) ImGui.PopStyleColor(); - } - - public void Dispose() - { - if (!disposed) - { - disposed = true; - Svc.PluginInterface.UiBuilder.Draw -= ws.Draw; - ws.RemoveWindow(this); - } - } - -} diff --git a/ECommons/ECommons/ImGuiMethods/Notify.cs b/ECommons/ECommons/ImGuiMethods/Notify.cs deleted file mode 100644 index dd0eb26..0000000 --- a/ECommons/ECommons/ImGuiMethods/Notify.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Dalamud.Interface.Internal.Notifications; -using ECommons.DalamudServices; -using ECommons.Reflection; -using ECommons.Schedulers; - -namespace ECommons.ImGuiMethods; - -public static class Notify -{ - public static void Success(string s) - { - _ = new TickScheduler(delegate - { - Svc.PluginInterface.UiBuilder.AddNotification(s, DalamudReflector.GetPluginName(), NotificationType.Success); - }); - } - - public static void Info(string s) - { - _ = new TickScheduler(delegate - { - Svc.PluginInterface.UiBuilder.AddNotification(s, DalamudReflector.GetPluginName(), NotificationType.Info); - }); - } - - public static void Error(string s) - { - _ = new TickScheduler(delegate - { - Svc.PluginInterface.UiBuilder.AddNotification(s, DalamudReflector.GetPluginName(), NotificationType.Error); - }); - } - - public static void Warning(string s) - { - _ = new TickScheduler(delegate - { - Svc.PluginInterface.UiBuilder.AddNotification(s, DalamudReflector.GetPluginName(), NotificationType.Warning); - }); - } - - public static void Plain(string s) - { - _ = new TickScheduler(delegate - { - Svc.PluginInterface.UiBuilder.AddNotification(s, DalamudReflector.GetPluginName(), NotificationType.None); - }); - } -} diff --git a/ECommons/ECommons/ImGuiMethods/PopupWindow.cs b/ECommons/ECommons/ImGuiMethods/PopupWindow.cs deleted file mode 100644 index e866e50..0000000 --- a/ECommons/ECommons/ImGuiMethods/PopupWindow.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Dalamud.Interface; -using Dalamud.Interface.Utility; -using ECommons.DalamudServices; -using ImGuiNET; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.ImGuiMethods -{ - public class PopupWindow : IDisposable - { - public string Text = ""; - public PopupWindow(string Text) - { - this.Text = Text; - Svc.PluginInterface.UiBuilder.Draw += UiBuilder_Draw; - } - - public void Dispose() - { - Svc.PluginInterface.UiBuilder.Draw -= UiBuilder_Draw; - } - - private void UiBuilder_Draw() - { - ImGuiHelpers.ForceNextWindowMainViewport(); - } - } -} diff --git a/ECommons/ECommons/ImGuiMethods/ThreadLoadImageHandler.cs b/ECommons/ECommons/ImGuiMethods/ThreadLoadImageHandler.cs deleted file mode 100644 index 01eac75..0000000 --- a/ECommons/ECommons/ImGuiMethods/ThreadLoadImageHandler.cs +++ /dev/null @@ -1,153 +0,0 @@ -using Dalamud.Interface.Internal; -using ECommons.DalamudServices; -using ECommons.Logging; -using ImGuiScene; -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.IO; -using System.Net.Http; -using System.Threading; -using static Dalamud.Plugin.Services.ITextureProvider; -using static ECommons.GenericHelpers; - -namespace ECommons.ImGuiMethods; - -public class ThreadLoadImageHandler -{ - internal static ConcurrentDictionary CachedTextures = new(); - internal static ConcurrentDictionary<(uint ID, bool HQ), ImageLoadingResult> CachedIcons = new(); - - private static readonly List> _conversionsToBitmap = new() { b => b, }; - - static volatile bool ThreadRunning = false; - internal static HttpClient httpClient = new() - { - Timeout = TimeSpan.FromSeconds(10), - }; - - internal static void Dispose() - { - foreach (var x in CachedTextures) - { - Safe(() => { x.Value.texture?.Dispose(); }); - } - Safe(CachedTextures.Clear); - foreach (var x in CachedIcons) - { - Safe(() => { x.Value.texture?.Dispose(); }); - } - Safe(CachedIcons.Clear); - } - - public static bool TryGetIconTextureWrap(uint icon, bool hq, out IDalamudTextureWrap textureWrap) - { - ImageLoadingResult result; - if (!CachedIcons.TryGetValue((icon, hq), out result)) - { - result = new(); - CachedIcons[(icon, hq)] = result; - BeginThreadIfNotRunning(); - } - textureWrap = result.texture; - return result.texture != null; - } - - public static bool TryGetTextureWrap(string url, out IDalamudTextureWrap textureWrap) - { - ImageLoadingResult result; - if (!CachedTextures.TryGetValue(url, out result)) - { - result = new(); - CachedTextures[url] = result; - BeginThreadIfNotRunning(); - } - textureWrap = result.texture; - return result.texture != null; - } - - internal static void BeginThreadIfNotRunning() - { - if (ThreadRunning) return; - PluginLog.Information("Starting ThreadLoadImageHandler"); - ThreadRunning = true; - new Thread(() => - { - int idleTicks = 0; - Safe(delegate - { - while (idleTicks < 100) - { - Safe(delegate - { - { - if (CachedTextures.TryGetFirst(x => x.Value.isCompleted == false, out var keyValuePair)) - { - idleTicks = 0; - keyValuePair.Value.isCompleted = true; - PluginLog.Information("Loading image " + keyValuePair.Key); - if (keyValuePair.Key.StartsWith("http:", StringComparison.OrdinalIgnoreCase) || keyValuePair.Key.StartsWith("https:", StringComparison.OrdinalIgnoreCase)) - { - var result = httpClient.GetAsync(keyValuePair.Key).Result; - result.EnsureSuccessStatusCode(); - var content = result.Content.ReadAsByteArrayAsync().Result; - - IDalamudTextureWrap texture = null; - foreach (var conversion in _conversionsToBitmap) - { - if (conversion == null) continue; - - try - { - texture = Svc.PluginInterface.UiBuilder.LoadImage(conversion(content)); - if (texture != null) break; - } - catch (Exception ex) - { - //TODO: I don't know how to log exception in ECommons. - } - } - keyValuePair.Value.texture = texture; - } - else - { - if (File.Exists(keyValuePair.Key)) - { - keyValuePair.Value.texture = Svc.PluginInterface.UiBuilder.LoadImage(keyValuePair.Key); - } - else - { - keyValuePair.Value.texture = Svc.Texture.GetTextureFromGame(keyValuePair.Key); - } - } - } - } - { - if (CachedIcons.TryGetFirst(x => x.Value.isCompleted == false, out var keyValuePair)) - { - idleTicks = 0; - keyValuePair.Value.isCompleted = true; - PluginLog.Information($"Loading icon {keyValuePair.Key.ID}, hq={keyValuePair.Key.HQ}"); - keyValuePair.Value.texture = Svc.Texture.GetIcon(keyValuePair.Key.ID, keyValuePair.Key.HQ?IconFlags.HiRes:IconFlags.None); - } - } - }); - idleTicks++; - Thread.Sleep(100); - } - }); - PluginLog.Information($"Stopping ThreadLoadImageHandler, ticks={idleTicks}"); - ThreadRunning = false; - }).Start(); - } - - public static void AddConversionToBitmap(Func conversion) - { - _conversionsToBitmap.Add(conversion); - } - - public static void RemoveConversionToBitmap(Func conversion) - { - _conversionsToBitmap.Remove(conversion); - } -} \ No newline at end of file diff --git a/ECommons/ECommons/ImGuiMethods/TimedMiddleOverlayWindow.cs b/ECommons/ECommons/ImGuiMethods/TimedMiddleOverlayWindow.cs deleted file mode 100644 index a581907..0000000 --- a/ECommons/ECommons/ImGuiMethods/TimedMiddleOverlayWindow.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Numerics; - -namespace ECommons.ImGuiMethods; - -public class TimedMiddleOverlayWindow : MiddleOverlayWindow -{ - long destroyAt; - public TimedMiddleOverlayWindow(string name, long destroyAfterMS, Action draw, int? topOffset = null, Vector4? bgCol = null) : base(name, draw, topOffset, bgCol) - { - this.destroyAt = Environment.TickCount64 + destroyAfterMS; - } - - public override void Update() - { - if (Environment.TickCount64 > destroyAt) - { - Dispose(); - } - } -} diff --git a/ECommons/ECommons/Interop/LimitedKeys.cs b/ECommons/ECommons/Interop/LimitedKeys.cs deleted file mode 100644 index 0793e77..0000000 --- a/ECommons/ECommons/Interop/LimitedKeys.cs +++ /dev/null @@ -1,692 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace ECommons.Interop -{ - - [Obfuscation(Exclude = true, ApplyToMembers = true)] - public enum LimitedKeys - { - // - // Summary: - // No key pressed. - None = 0, - // - // Summary: - // The left mouse button. - LeftMouseButton = 1, - // - // Summary: - // The right mouse button. - RightMouseButton = 2, - // - // Summary: - // The CANCEL key. - Cancel = 3, - // - // Summary: - // The middle mouse button (three-button mouse). - MiddleMouseButton = 4, - // - // Summary: - // The first x mouse button (five-button mouse). - XMouseButton1 = 5, - // - // Summary: - // The second x mouse button (five-button mouse). - XMouseButton2 = 6, - // - // Summary: - // The BACKSPACE key. - Back = 8, - // - // Summary: - // The TAB key. - Tab = 9, - // - // Summary: - // The LINEFEED key. - LineFeed = 10, - // - // Summary: - // The CLEAR key. - Clear = 12, - // - // Summary: - // The ENTER key. - Enter = 13, - // - // Summary: - // The PAUSE key. - Pause = 19, - // - // Summary: - // The CAPS LOCK key. - CapsLock = 20, - // - // Summary: - // The IME Kana mode key. - KanaMode = 21, - // - // Summary: - // The IME Hangul mode key. - HangulMode = 21, - // - // Summary: - // The IME Junja mode key. - JunjaMode = 23, - // - // Summary: - // The IME final mode key. - FinalMode = 24, - // - // Summary: - // The IME Kanji mode key. - KanjiMode = 25, - // - // Summary: - // The ESC key. - Escape = 27, - // - // Summary: - // The IME convert key. - IMEConvert = 28, - // - // Summary: - // The IME nonconvert key. - IMENonconvert = 29, - // - // Summary: - // The IME accept key, replaces System.Windows.Forms.Keys.IMEAceept. - IMEAccept = 30, - // - // Summary: - // The IME mode change key. - IMEModeChange = 31, - // - // Summary: - // The SPACEBAR key. - Space = 32, - // - // Summary: - // The PAGE UP key. - PageUp = 33, - // - // Summary: - // The PAGE DOWN key. - PageDown = 34, - // - // Summary: - // The END key. - End = 35, - // - // Summary: - // The HOME key. - Home = 36, - // - // Summary: - // The LEFT ARROW key. - Left = 37, - // - // Summary: - // The UP ARROW key. - Up = 38, - // - // Summary: - // The RIGHT ARROW key. - Right = 39, - // - // Summary: - // The DOWN ARROW key. - Down = 40, - // - // Summary: - // The SELECT key. - Select = 41, - // - // Summary: - // The PRINT key. - Print = 42, - // - // Summary: - // The EXECUTE key. - Execute = 43, - // Summary: - // The PRINT SCREEN key. - PrintScreen = 44, - // - // Summary: - // The INS key. - Insert = 45, - // - // Summary: - // The DEL key. - Delete = 46, - // - // Summary: - // The HELP key. - Help = 47, - // - // Summary: - // The 0 key. - Digit_0 = 48, - // - // Summary: - // The 1 key. - Digit_1 = 49, - // - // Summary: - // The 2 key. - Digit_2 = 50, - // - // Summary: - // The 3 key. - Digit_3 = 51, - // - // Summary: - // The 4 key. - Digit_4 = 52, - // - // Summary: - // The 5 key. - Digit_5 = 53, - // - // Summary: - // The 6 key. - Digit_6 = 54, - // - // Summary: - // The 7 key. - Digit_7 = 55, - // - // Summary: - // The 8 key. - Digit_8 = 56, - // - // Summary: - // The 9 key. - Digit_9 = 57, - // - // Summary: - // The A key. - A = 65, - // - // Summary: - // The B key. - B = 66, - // - // Summary: - // The C key. - C = 67, - // - // Summary: - // The D key. - D = 68, - // - // Summary: - // The E key. - E = 69, - // - // Summary: - // The F key. - F = 70, - // - // Summary: - // The G key. - G = 71, - // - // Summary: - // The H key. - H = 72, - // - // Summary: - // The I key. - I = 73, - // - // Summary: - // The J key. - J = 74, - // - // Summary: - // The K key. - K = 75, - // - // Summary: - // The L key. - L = 76, - // - // Summary: - // The M key. - M = 77, - // - // Summary: - // The N key. - N = 78, - // - // Summary: - // The O key. - O = 79, - // - // Summary: - // The P key. - P = 80, - // - // Summary: - // The Q key. - Q = 81, - // - // Summary: - // The R key. - R = 82, - // - // Summary: - // The S key. - S = 83, - // - // Summary: - // The T key. - T = 84, - // - // Summary: - // The U key. - U = 85, - // - // Summary: - // The V key. - V = 86, - // - // Summary: - // The W key. - W = 87, - // - // Summary: - // The X key. - X = 88, - // - // Summary: - // The Y key. - Y = 89, - // - // Summary: - // The Z key. - Z = 90, - // - // Summary: - // The left Windows logo key (Microsoft Natural Keyboard). - LeftWin = 91, - // - // Summary: - // The right Windows logo key (Microsoft Natural Keyboard). - RightWin = 92, - // - // Summary: - // The application key (Microsoft Natural Keyboard). - Apps = 93, - // - // Summary: - // The computer sleep key. - Sleep = 95, - // - // Summary: - // The 0 key on the numeric keypad. - NumPad0 = 96, - // - // Summary: - // The 1 key on the numeric keypad. - NumPad1 = 97, - // - // Summary: - // The 2 key on the numeric keypad. - NumPad2 = 98, - // - // Summary: - // The 3 key on the numeric keypad. - NumPad3 = 99, - // - // Summary: - // The 4 key on the numeric keypad. - NumPad4 = 100, - // - // Summary: - // The 5 key on the numeric keypad. - NumPad5 = 101, - // - // Summary: - // The 6 key on the numeric keypad. - NumPad6 = 102, - // - // Summary: - // The 7 key on the numeric keypad. - NumPad7 = 103, - // - // Summary: - // The 8 key on the numeric keypad. - NumPad8 = 104, - // - // Summary: - // The 9 key on the numeric keypad. - NumPad9 = 105, - // - // Summary: - // The multiply key. - Multiply = 106, - // - // Summary: - // The add key. - Add = 107, - // - // Summary: - // The separator key. - Separator = 108, - // - // Summary: - // The subtract key. - Subtract = 109, - // - // Summary: - // The decimal key. - Decimal = 110, - // - // Summary: - // The divide key. - Divide = 111, - // - // Summary: - // The F1 key. - F1 = 112, - // - // Summary: - // The F2 key. - F2 = 113, - // - // Summary: - // The F3 key. - F3 = 114, - // - // Summary: - // The F4 key. - F4 = 115, - // - // Summary: - // The F5 key. - F5 = 116, - // - // Summary: - // The F6 key. - F6 = 117, - // - // Summary: - // The F7 key. - F7 = 118, - // - // Summary: - // The F8 key. - F8 = 119, - // - // Summary: - // The F9 key. - F9 = 120, - // - // Summary: - // The F10 key. - F10 = 121, - // - // Summary: - // The F11 key. - F11 = 122, - // - // Summary: - // The F12 key. - F12 = 123, - // - // Summary: - // The F13 key. - F13 = 124, - // - // Summary: - // The F14 key. - F14 = 125, - // - // Summary: - // The F15 key. - F15 = 126, - // - // Summary: - // The F16 key. - F16 = 127, - // - // Summary: - // The F17 key. - F17 = 128, - // - // Summary: - // The F18 key. - F18 = 129, - // - // Summary: - // The F19 key. - F19 = 130, - // - // Summary: - // The F20 key. - F20 = 131, - // - // Summary: - // The F21 key. - F21 = 132, - // - // Summary: - // The F22 key. - F22 = 133, - // - // Summary: - // The F23 key. - F23 = 134, - // - // Summary: - // The F24 key. - F24 = 135, - // - // Summary: - // The NUM LOCK key. - NumLock = 144, - // - // Summary: - // The SCROLL LOCK key. - Scroll = 145, - // - // Summary: - // The left SHIFT key. - LeftShiftKey = 160, - // - // Summary: - // The right SHIFT key. - RightShiftKey = 161, - // - // Summary: - // The left CTRL key. - LeftControlKey = 162, - // - // Summary: - // The right CTRL key. - RightControlKey = 163, - // - // Summary: - // The left ALT key. - LeftAltKey = 164, - // - // Summary: - // The right ALT key. - RightAltKey = 165, - // - // Summary: - // The browser back key. - BrowserBack = 166, - // - // Summary: - // The browser forward key. - BrowserForward = 167, - // - // Summary: - // The browser refresh key. - BrowserRefresh = 168, - // - // Summary: - // The browser stop key. - BrowserStop = 169, - // - // Summary: - // The browser search key. - BrowserSearch = 170, - // - // Summary: - // The browser favorites key. - BrowserFavorites = 171, - // - // Summary: - // The browser home key. - BrowserHome = 172, - // - // Summary: - // The volume mute key. - VolumeMute = 173, - // - // Summary: - // The volume down key. - VolumeDown = 174, - // - // Summary: - // The volume up key. - VolumeUp = 175, - // - // Summary: - // The media next track key. - MediaNextTrack = 176, - // - // Summary: - // The media previous track key. - MediaPreviousTrack = 177, - // - // Summary: - // The media Stop key. - MediaStop = 178, - // - // Summary: - // The media play pause key. - MediaPlayPause = 179, - // - // Summary: - // The launch mail key. - LaunchMail = 180, - // - // Summary: - // The select media key. - SelectMedia = 181, - // - // Summary: - // The start application one key. - LaunchApplication1 = 182, - // - // Summary: - // The start application two key. - LaunchApplication2 = 183, - // - // Summary: - // The OEM Semicolon key on a US standard keyboard. - OemSemicolon = 186, - // - // Summary: - // The OEM plus key on any country/region keyboard. - Oemplus = 187, - // - // Summary: - // The OEM comma key on any country/region keyboard. - Oemcomma = 188, - // - // Summary: - // The OEM minus key on any country/region keyboard. - OemMinus = 189, - // - // Summary: - // The OEM period key on any country/region keyboard. - OemPeriod = 190, - // - // Summary: - // The OEM question mark key on a US standard keyboard. - OemQuestion = 191, - // - // Summary: - // The OEM tilde key on a US standard keyboard. - Oemtilde = 192, - // - // Summary: - // The OEM open bracket key on a US standard keyboard. - OemOpenBrackets = 219, - // - // Summary: - // The OEM pipe key on a US standard keyboard. - OemPipe = 220, - // - // Summary: - // The OEM close bracket key on a US standard keyboard. - OemCloseBrackets = 221, - // - // Summary: - // The OEM singled/double quote key on a US standard keyboard. - OemQuotes = 222, - // - // Summary: - // The OEM 8 key. - Oem8 = 223, - // - // Summary: - // The OEM angle bracket or backslash key on the RT 102 key keyboard. - OemBackslash = 226, - // - // Summary: - // The PROCESS KEY key. - ProcessKey = 229, - // - // Summary: - // Used to pass Unicode characters as if they were keystrokes. The Packet key value - // is the low word of a 32-bit virtual-key value used for non-keyboard input methods. - Packet = 231, - // - // Summary: - // The ATTN key. - Attn = 246, - // - // Summary: - // The CRSEL key. - Crsel = 247, - // - // Summary: - // The EXSEL key. - Exsel = 248, - // - // Summary: - // The ERASE EOF key. - EraseEof = 249, - // - // Summary: - // The PLAY key. - Play = 250, - // - // Summary: - // The ZOOM key. - Zoom = 251, - // - // Summary: - // The PA1 key. - Pa1 = 253, - // - // Summary: - // The CLEAR key. - OemClear = 254, - } -} diff --git a/ECommons/ECommons/Interop/OpenFileDialog.cs b/ECommons/ECommons/Interop/OpenFileDialog.cs deleted file mode 100644 index bde9ef1..0000000 --- a/ECommons/ECommons/Interop/OpenFileDialog.cs +++ /dev/null @@ -1,91 +0,0 @@ -using ECommons.Logging; -using ECommons.ImGuiMethods; -using ECommons.Schedulers; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Threading; - -namespace ECommons.Interop; - -public class OpenFileDialog -{ - static SemaphoreSlim SelectorSemaphore = new(1, 1); - public static bool IsSelecting() - { - return SelectorSemaphore.CurrentCount == 0; - } - - [DllImport("Comdlg32.dll", CharSet = CharSet.Auto)] - static extern bool GetOpenFileName([In, Out] OpenFileName ofn); - - public static void SelectFile(Action successCallback, Action cancelCallback = null, string initialDir = null, string title = "Select a file...", IEnumerable<(string Description, IEnumerable Extensions)> fileTypes = null) - { - if (SelectorSemaphore.Wait(0)) - { - new Thread((ThreadStart)delegate - { - PluginLog.Debug("Starting file selection"); - try - { - OpenFileName ofn = new OpenFileName(); - - if (WindowFunctions.TryFindGameWindow(out var hwnd)) - { - PluginLog.Information($"With owner: {hwnd:X16}"); - ofn.dlgOwner = hwnd; - } - - ofn.structSize = Marshal.SizeOf(ofn); - - List FileTypes = new(); - if(fileTypes != null) - { - foreach(var x in fileTypes) - { - FileTypes.Add($"{x.Description}\0{x.Extensions.Select(x => $"*.{x}").Join(";")}"); - } - FileTypes.Add("\0All files\0*\0"); - } - - ofn.filter = FileTypes.Join("\0"); - - ofn.file = new String(new char[1024]); - ofn.maxFile = ofn.file.Length; - - ofn.fileTitle = new String(new char[256]); - ofn.maxFileTitle = ofn.fileTitle.Length; - - ofn.initialDir = initialDir; - ofn.title = title; - - PluginLog.Debug("Preparing to call winapi"); - if (GetOpenFileName(ofn)) - { - successCallback(ofn); - } - else - { - cancelCallback(); - } - PluginLog.Debug("Dialog closed"); - } - catch (Exception e) - { - PluginLog.Error(e.Message + "\n" + e.StackTrace ?? ""); - new TickScheduler(delegate - { - Notify.Error($"Error: {e.Message}"); - }); - } - SelectorSemaphore.Release(); - PluginLog.Debug("Ending file selection"); - }).Start(); - } - else - { - Notify.Error("Failed to open file dialog"); - } - } -} diff --git a/ECommons/ECommons/Interop/OpenFileName.cs b/ECommons/ECommons/Interop/OpenFileName.cs deleted file mode 100644 index c6ebc01..0000000 --- a/ECommons/ECommons/Interop/OpenFileName.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright -// Microsoft Corporation -// All rights reserved - -// OpenFileDlg.cs - -using System; -using System.Runtime.InteropServices; - -/* -typedef struct tagOFN { - DWORD lStructSize; - HWND hwndOwner; - HINSTANCE hInstance; - LPCTSTR lpstrFilter; - LPTSTR lpstrCustomFilter; - DWORD nMaxCustFilter; - DWORD nFilterIndex; - LPTSTR lpstrFile; - DWORD nMaxFile; - LPTSTR lpstrFileTitle; - DWORD nMaxFileTitle; - LPCTSTR lpstrInitialDir; - LPCTSTR lpstrTitle; - DWORD Flags; - WORD nFileOffset; - WORD nFileExtension; - LPCTSTR lpstrDefExt; - LPARAM lCustData; - LPOFNHOOKPROC lpfnHook; - LPCTSTR lpTemplateName; -#if (_WIN32_WINNT >= 0x0500) - void * pvReserved; - DWORD dwReserved; - DWORD FlagsEx; -#endif // (_WIN32_WINNT >= 0x0500) -} OPENFILENAME, *LPOPENFILENAME; -*/ - -namespace ECommons.Interop; - -[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] -public class OpenFileName -{ - public int structSize = 0; - public IntPtr dlgOwner = IntPtr.Zero; - public IntPtr instance = IntPtr.Zero; - - public String filter = null; - public String customFilter = null; - public int maxCustFilter = 0; - public int filterIndex = 0; - - public String file = null; - public int maxFile = 0; - - public String fileTitle = null; - public int maxFileTitle = 0; - - public String initialDir = null; - - public String title = null; - - public int flags = 0; - public short fileOffset = 0; - public short fileExtension = 0; - - public String defExt = null; - - public IntPtr custData = IntPtr.Zero; - public IntPtr hook = IntPtr.Zero; - - public String templateName = null; - - public IntPtr reservedPtr = IntPtr.Zero; - public int reservedInt = 0; - public int flagsEx = 0; -} \ No newline at end of file diff --git a/ECommons/ECommons/Interop/WindowFunctions.cs b/ECommons/ECommons/Interop/WindowFunctions.cs deleted file mode 100644 index beb2d87..0000000 --- a/ECommons/ECommons/Interop/WindowFunctions.cs +++ /dev/null @@ -1,59 +0,0 @@ -using PInvoke; -using System; -//using System.Windows.Forms; -using static PInvoke.User32; - -namespace ECommons.Interop; - -public static class WindowFunctions -{ - public const int SW_MINIMIZE = 6; - public const int SW_FORCEMINIMIZE = 11; - public const int SW_HIDE = 0; - public const int SW_SHOW = 5; - public const int SW_SHOWNA = 8; - - public static bool TryFindGameWindow(out IntPtr hwnd) - { - hwnd = IntPtr.Zero; - while (true) - { - hwnd = FindWindowEx(IntPtr.Zero, hwnd, "FFXIVGAME", null); - if (hwnd == IntPtr.Zero) break; - GetWindowThreadProcessId(hwnd, out var pid); - if (pid == Environment.ProcessId) break; - } - return hwnd != IntPtr.Zero; - } - - /// Returns true if the current application has focus, false otherwise - public static bool ApplicationIsActivated() - { - var activatedHandle = GetForegroundWindow(); - if (activatedHandle == IntPtr.Zero) - { - return false; // No window is currently activated - } - - var procId = Environment.ProcessId; - GetWindowThreadProcessId(activatedHandle, out int activeProcId); - - return activeProcId == procId; - } - - public static bool SendKeypress(int keycode) - { - if (TryFindGameWindow(out var hwnd)) - { - User32.SendMessage(hwnd, WindowMessage.WM_KEYDOWN, (IntPtr)keycode, (IntPtr)0); - User32.SendMessage(hwnd, WindowMessage.WM_KEYUP, (IntPtr)keycode, (IntPtr)0); - return true; - } - return false; - } - - /*public static bool SendKeypress(Keys key) - { - return SendKeypress((int)key); - }*/ -} diff --git a/ECommons/ECommons/LanguageHelpers/Localization.cs b/ECommons/ECommons/LanguageHelpers/Localization.cs deleted file mode 100644 index a920515..0000000 --- a/ECommons/ECommons/LanguageHelpers/Localization.cs +++ /dev/null @@ -1,110 +0,0 @@ -using Dalamud; -using ECommons.Logging; -using ECommons.DalamudServices; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; - -namespace ECommons.LanguageHelpers; - -public static class Localization -{ - public static string PararmeterSymbol = "??"; - public static string Separator = "=="; - internal static Dictionary CurrentLocalization = new(); - internal static List AvailableLanguages; - public static string CurrentLanguage { get; internal set; } = null; - public static bool Logging = false; - - public static void Init(string Language = null) - { - CurrentLocalization.Clear(); - CurrentLanguage = null; - if (Language != null) - { - var file = GetLocFileLocation(Language); - if (File.Exists(file)) - { - CurrentLanguage = Language; - var text = File.ReadAllText(file, Encoding.UTF8); - var list = text.Replace("\r\n", "\n").Replace("\r", "").Split("\n"); - for (var i = 0; i < list.Length; i++) - { - var x = list[i].Replace("\\n", "\n"); - var e = x.Split(Separator); - if (e.Length == 2) - { - if (CurrentLocalization.ContainsKey(e[0])) - { - PluginLog.Warning($"[Localization] Duplicate localization entry {e[0]} found in localization file {file}"); - } - CurrentLocalization[e[0]] = e[1]; - } - else - { - PluginLog.Warning($"[Localization] Invalid entry {x} (line {i}) found in localization file {file}"); - } - } - PluginLog.Information($"[Localization] Loaded {CurrentLocalization.Count} entries"); - } - else - { - PluginLog.Information($"[Localization] Requested localization file {file} does not exists"); - } - } - else - { - PluginLog.Information("[Localization] No special localization"); - } - } - - public static List GetAvaliableLanguages(bool rescan = false) - { - if(AvailableLanguages == null || rescan) - { - AvailableLanguages = new() { "English" }; - foreach (var x in Directory.GetFiles(Svc.PluginInterface.AssemblyLocation.DirectoryName)) - { - var name = Path.GetFileName(x); - if (name.StartsWith("Language") && name.EndsWith(".ini")) - { - var lang = name[8..^4]; - if(!AvailableLanguages.Contains(lang)) AvailableLanguages.Add(lang); - PluginLog.Information($"[Localization] Found language data {lang}"); - } - } - } - return AvailableLanguages; - } - - public static string GameLanguageString => Svc.Data.Language switch - { - ClientLanguage.Japanese => "Japanese", - ClientLanguage.French => "French", - ClientLanguage.German => "German", - (ClientLanguage)4 => "Chinese", - _ => "English" - }; - - public static void Save(string lang) - { - var file = GetLocFileLocation(lang); - File.WriteAllText(file, CurrentLocalization.Select(x => $"{x.Key.Replace("\n", "\\n")}{Separator}{x.Value.Replace("\n", "\\n")}").Join("\n")); - } - - public static string GetLocFileLocation(string lang) - { - return Path.Combine(Svc.PluginInterface.AssemblyLocation.DirectoryName, $"Language{lang}.ini"); - } - - public static string Loc(string s) - { - return s.Loc(); - } - - public static string Loc(string s, params object[] values) - { - return s.Loc(values); - } -} diff --git a/ECommons/ECommons/LanguageHelpers/LocalizationExtensions.cs b/ECommons/ECommons/LanguageHelpers/LocalizationExtensions.cs deleted file mode 100644 index 3b1f442..0000000 --- a/ECommons/ECommons/LanguageHelpers/LocalizationExtensions.cs +++ /dev/null @@ -1,36 +0,0 @@ -using static ECommons.LanguageHelpers.Localization; - -namespace ECommons.LanguageHelpers; - -public static class LocalizationExtensions -{ - public static string Loc(this string s) - { - if (CurrentLocalization.TryGetValue(s, out var locs) && locs != "" && locs != null) - { - return locs; - } - else if (Localization.Logging) - { - CurrentLocalization[s] = ""; - } - return s; - } - - public static string Loc(this string s, params object[] values) - { - if (CurrentLocalization.TryGetValue(s, out var locs) && locs != "" && locs != null) - { - s = locs; - } - else if (Localization.Logging) - { - CurrentLocalization[s] = ""; - } - foreach (var x in values) - { - s = s.ReplaceFirst(PararmeterSymbol, x.ToString()); - } - return s; - } -} diff --git a/ECommons/ECommons/Loader/ILoadable.cs b/ECommons/ECommons/Loader/ILoadable.cs deleted file mode 100644 index 5cd2016..0000000 --- a/ECommons/ECommons/Loader/ILoadable.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.Loader -{ - public interface ILoadable - { - public bool IsDisposed { get; } - } -} diff --git a/ECommons/ECommons/Loader/MicroServices.cs b/ECommons/ECommons/Loader/MicroServices.cs deleted file mode 100644 index 82c9161..0000000 --- a/ECommons/ECommons/Loader/MicroServices.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Dalamud.Data; -using Dalamud.Game.ClientState; -using Dalamud.Game.Command; -using Dalamud.Game; -using Dalamud.IoC; -using Dalamud.Plugin; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Dalamud.Plugin.Services; - -namespace ECommons.Loader -{ - internal class MicroServices - { - [PluginService] static internal DalamudPluginInterface PluginInterface { get; private set; } - //[PluginService] static internal BuddyList Buddies { get; private set; } - //[PluginService] static internal ChatGui Chat { get; private set; } - //[PluginService] static internal ChatHandlers ChatHandlers { get; private set; } - //[PluginService] static internal ClientState ClientState { get; private set; } - [PluginService] static internal ICommandManager Commands { get; private set; } - //[PluginService] static internal Condition Condition { get; private set; } - //[PluginService] static internal DataManager Data { get; private set; } - //[PluginService] static internal FateTable Fates { get; private set; } - //[PluginService] static internal FlyTextGui FlyText { get; private set; } - [PluginService] static internal IFramework Framework { get; private set; } - //[PluginService] static internal GameGui GameGui { get; private set; } - //[PluginService] static internal GameNetwork GameNetwork { get; private set; } - //[PluginService] static internal JobGauges Gauges { get; private set; } - //[PluginService] static internal KeyState KeyState { get; private set; } - //[PluginService] static internal LibcFunction LibcFunction { get; private set; } - //[PluginService] static internal ObjectTable Objects { get; private set; } - //[PluginService] static internal PartyFinderGui PfGui { get; private set; } - //[PluginService] static internal PartyList Party { get; private set; } - //[PluginService] static internal SeStringManager SeStringManager { get; private set; } - //[PluginService] static internal SigScanner SigScanner { get; private set; } - //[PluginService] static internal TargetManager Targets { get; private set; } - //[PluginService] static internal ToastGui Toasts { get; private set; } - } -} diff --git a/ECommons/ECommons/Loader/PluginLoader.cs b/ECommons/ECommons/Loader/PluginLoader.cs deleted file mode 100644 index bbaef80..0000000 --- a/ECommons/ECommons/Loader/PluginLoader.cs +++ /dev/null @@ -1,194 +0,0 @@ -using Dalamud.Game.Command; -using Dalamud.Interface; -using Dalamud.Interface.Utility; -using ECommons.Logging; -using Dalamud.Plugin; -using ECommons.DalamudServices; -using ECommons.ImGuiMethods; -using ECommons.Reflection; -using ImGuiNET; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net.Http; -using System.Numerics; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.Loader -{ - public static class PluginLoader - { - internal static bool IsUsed = false; - public static bool IsLoaded { get; internal set; } = false; - - private static Action Success = null; - private static string PluginLoadCommand = null; - private static ILoadable Plugin; - - static Vector2 Pos = Vector2.Zero; - - public static void Init(ILoadable plugin, DalamudPluginInterface pluginInterface, string blacklistURL, Action success) - { - if (IsUsed) - { - throw new Exception($"Loader has been already called before"); - } - Plugin = plugin; - IsUsed = true; - pluginInterface.Create(); - Success = success; - PluginLoadCommand = $"/load_{MicroServices.PluginInterface.InternalName}"; - var cInfo = new CommandInfo(Load) { HelpMessage = $"Load plugin skipping version check" }; - GenericHelpers.Safe(delegate - { - cInfo.SetFoP("LoaderAssemblyName", MicroServices.PluginInterface.InternalName); - }); - MicroServices.Commands.AddHandler(PluginLoadCommand, cInfo); - - var currentVersion = AssemblyName.GetAssemblyName(MicroServices.PluginInterface.AssemblyLocation.FullName).Version ?? new Version(0,0,0,0); - - Task.Run(delegate - { - var verdict = true; - try - { - HttpClient client = new() - { - Timeout = TimeSpan.FromSeconds(5), - }; - var res = client.GetAsync(blacklistURL).Result; - res.EnsureSuccessStatusCode(); - using var stream = res.Content.ReadAsStream(); - using var streamReader = new StreamReader(stream); - var lines = streamReader.ReadToEnd().Split("\n"); - - - foreach(var x in lines) - { - try - { - PluginLog.Debug($"Parsing line {x}"); - var versions = x.Split(",").Select(z => z.Trim()).Select(z => Version.Parse(z)).ToArray(); - if(versions.Length == 1) - { - if(currentVersion == versions[0]) - { - verdict = false; - PluginLog.Debug($"Blacklisted current version from line {x} (match {versions[0]})"); - } - } - else if(versions.Length > 1) - { - if (currentVersion >= versions[0] && currentVersion <= versions[1]) - { - verdict = false; - PluginLog.Debug($"Blacklisted current version from line {x} (match {versions[0]}-{versions[1]})"); - } - } - } - catch(Exception e) - { - PluginLog.Debug($"Invalid line received: {x}"); - PluginLog.Debug($"{e.Message} \n{e.StackTrace}"); - } - } - - } - catch(Exception e) - { - PluginLog.Error($"Error during loader call"); - e.Log(); - } - if (verdict) - { - MicroServices.Framework.Update += CallLoad; - } - else - { - MicroServices.PluginInterface.UiBuilder.Draw += Draw; - } - }); - } - - private static void Load(object _, object __) - { - if (Plugin.IsDisposed) - { - PluginLog.Error($"Plugin is already disposed, won't call load"); - return; - } - if (IsLoaded) - { - PluginLog.Error($"Loading already called before, won't load again"); - } - else - { - try - { - Success(); - } - catch (Exception e) - { - e.Log(); - } - } - } - - private static void CallLoad(object _) - { - if (Plugin.IsDisposed) - { - PluginLog.Error($"Plugin is already disposed, won't call load"); - return; - } - Load(null, null); - Dispose(); - } - - public static void Dispose() - { - if (IsUsed) - { - MicroServices.Framework.Update -= CallLoad; - MicroServices.PluginInterface.UiBuilder.Draw -= Draw; - if (PluginLoadCommand != null) MicroServices.Commands.RemoveHandler(PluginLoadCommand); - Plugin = null; - } - } - - private static void Draw() - { - if (Plugin.IsDisposed) - { - PluginLog.Error($"Plugin is already disposed, won't show UI"); - Dispose(); - return; - } - ImGui.SetNextWindowSizeConstraints(new(500, 100), new(500, 500)); - ImGuiHelpers.SetNextWindowPosRelativeMainViewport(Pos); - ImGuiHelpers.ForceNextWindowMainViewport(); - if (ImGui.Begin($"{MicroServices.PluginInterface.InternalName} - version revoked", ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings)) - { - ImGuiEx.TextWrapped("Current version of the plugin has been marked as revoked."); - ImGuiEx.TextWrapped("This means that there is an issue that can cause problems. Usually, updated version either already available or will be available as soon as possible. "); - if (ImGui.Button("Open plugin installer")) - { - MicroServices.PluginInterface.OpenPluginInstaller(); - } - if (ImGui.Button("Close this window")) - { - MicroServices.PluginInterface.UiBuilder.Draw -= Draw; - } - if(ImGui.Button("Load the plugin anyway")) - { - MicroServices.Framework.Update += CallLoad; - } - } - Pos = ImGuiHelpers.MainViewport.Size / 2 - ImGui.GetWindowSize() / 2; - ImGui.End(); - } - } -} diff --git a/ECommons/ECommons/Logging/DuoLog.cs b/ECommons/ECommons/Logging/DuoLog.cs deleted file mode 100644 index f62fc13..0000000 --- a/ECommons/ECommons/Logging/DuoLog.cs +++ /dev/null @@ -1,87 +0,0 @@ -using Dalamud.Game.Text.SeStringHandling; -using ECommons.DalamudServices; -using ECommons.Reflection; -using ECommons.Schedulers; - -namespace ECommons.Logging; - -public static class DuoLog -{ - public static void Information(string s) - { - var str = $"[{DalamudReflector.GetPluginName()}] {s}"; - PluginLog.Information(str); - _ = new TickScheduler(delegate - { - Svc.Chat.Print(new() - { - Message = new SeStringBuilder().AddUiForeground(str, 3).Build() - }); - }); - } - - public static void Debug(string s) - { - var str = $"[{DalamudReflector.GetPluginName()}] {s}"; - PluginLog.Debug(str); - _ = new TickScheduler(delegate - { - Svc.Chat.Print(new() - { - Message = new SeStringBuilder().AddUiForeground(str, 4).Build() - }); - }); - } - - public static void Verbose(string s) - { - var str = $"[{DalamudReflector.GetPluginName()}] {s}"; - PluginLog.Verbose(str); - _ = new TickScheduler(delegate - { - Svc.Chat.Print(new() - { - Message = new SeStringBuilder().AddUiForeground(str, 5).Build() - }); - }); - } - - public static void Warning(string s) - { - var str = $"[{DalamudReflector.GetPluginName()}] {s}"; - PluginLog.Warning(str); - _ = new TickScheduler(delegate - { - Svc.Chat.Print(new() - { - Message = new SeStringBuilder().AddUiForeground(str, 540).Build() - }); - }); - } - - public static void Error(string s) - { - var str = $"[{DalamudReflector.GetPluginName()}] {s}"; - PluginLog.Error(str); - _ = new TickScheduler(delegate - { - Svc.Chat.Print(new() - { - Message = new SeStringBuilder().AddUiForeground(str, 17).Build() - }); - }); - } - - public static void Fatal(string s) - { - var str = $"[{DalamudReflector.GetPluginName()}] {s}"; - PluginLog.Fatal(str); - _ = new TickScheduler(delegate - { - Svc.Chat.Print(new() - { - Message = new SeStringBuilder().AddUiForeground(str, 19).Build() - }); - }); - } -} diff --git a/ECommons/ECommons/Logging/InternalLog.cs b/ECommons/ECommons/Logging/InternalLog.cs deleted file mode 100644 index 2e23d39..0000000 --- a/ECommons/ECommons/Logging/InternalLog.cs +++ /dev/null @@ -1,104 +0,0 @@ -using Dalamud.Interface.Colors; -using ECommons.CircularBuffers; -using ECommons.ImGuiMethods; -using ECommons.Reflection; -using ImGuiNET; -using Serilog.Events; -using System; -using System.Linq; -using System.Numerics; - -namespace ECommons.Logging; - -public class InternalLog -{ - public static readonly CircularBuffer Messages = new(1000); - - public static (string, Action, Vector4, bool) ImGuiTab(bool draw = true) => (draw?"Log":null, PrintImgui, ImGuiColors.DalamudGrey, false); - - public static void Information(string s) - { - Messages.PushBack(new(s, LogEventLevel.Information)); - } - public static void Error(string s) - { - Messages.PushBack(new(s, LogEventLevel.Error)); - } - public static void Fatal(string s) - { - Messages.PushBack(new(s, LogEventLevel.Fatal)); - } - public static void Debug(string s) - { - Messages.PushBack(new(s, LogEventLevel.Debug)); - } - public static void Verbose(string s) - { - Messages.PushBack(new(s, LogEventLevel.Verbose)); - } - public static void Warning(string s) - { - Messages.PushBack(new(s, LogEventLevel.Warning)); - } - public static void LogInformation(string s) - { - Information(s); - } - public static void LogError(string s) - { - Error(s); - } - public static void LogFatal(string s) - { - Fatal(s); - } - public static void LogDebug(string s) - { - Debug(s); - } - public static void LogVerbose(string s) - { - Verbose(s); - } - public static void LogWarning(string s) - { - Warning(s); - } - public static void Log(string s) - { - Information(s); - } - - - static string Search = ""; - static bool Autoscroll = true; - public static void PrintImgui() - { - ImGui.Checkbox("Autoscroll", ref Autoscroll); - ImGui.SameLine(); - if(ImGui.Button("Copy all")) - { - ImGui.SetClipboardText(Messages.Select(x => $"[{x.Level}] {x.Message}").Join("\n")); - } - ImGui.SameLine(); - ImGuiEx.SetNextItemFullWidth(); - ImGui.InputTextWithHint("##Filter", "Filter...", ref Search, 100); - ImGui.BeginChild($"Plugin_log{DalamudReflector.GetPluginName()}"); - foreach(var x in Messages) - { - if(Search == String.Empty || x.Level.ToString().EqualsIgnoreCase(Search) || x.Message.Contains(Search, StringComparison.OrdinalIgnoreCase)) - ImGuiEx.TextWrappedCopy(x.Level == LogEventLevel.Fatal?ImGuiColors.DPSRed - :x.Level == LogEventLevel.Error?ImGuiColors.DalamudRed - :x.Level == LogEventLevel.Warning?ImGuiColors.DalamudOrange - :x.Level == LogEventLevel.Information?ImGuiColors.DalamudWhite - :x.Level == LogEventLevel.Debug?ImGuiColors.DalamudGrey - :x.Level == LogEventLevel.Verbose?ImGuiColors.DalamudGrey2 - :ImGuiColors.DalamudWhite2, x.Message); - } - if (Autoscroll) - { - ImGui.SetScrollHereY(); - } - ImGui.EndChild(); - } -} diff --git a/ECommons/ECommons/Logging/InternalLogMessage.cs b/ECommons/ECommons/Logging/InternalLogMessage.cs deleted file mode 100644 index 88b24f2..0000000 --- a/ECommons/ECommons/Logging/InternalLogMessage.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Serilog.Events; - -namespace ECommons.Logging; - -public record struct InternalLogMessage -{ - public string Message; - public LogEventLevel Level; - - public InternalLogMessage(string Message, LogEventLevel Level = LogEventLevel.Information) - { - this.Message = Message; - this.Level = Level; - } -} diff --git a/ECommons/ECommons/Logging/PluginLog.cs b/ECommons/ECommons/Logging/PluginLog.cs deleted file mode 100644 index 40c1b4c..0000000 --- a/ECommons/ECommons/Logging/PluginLog.cs +++ /dev/null @@ -1,86 +0,0 @@ -using ECommons.DalamudServices; -using ECommons.Reflection; -using Serilog.Events; - -namespace ECommons.Logging; - -public static class PluginLog -{ - - public static void Information(string s) - { - Svc.Log.Information($"{s}"); - Svc.Framework?.RunOnFrameworkThread(delegate - { - InternalLog.Messages.PushBack(new(s, LogEventLevel.Information)); - }); - } - public static void Error(string s) - { - Svc.Log.Error($"{s}"); - Svc.Framework?.RunOnFrameworkThread(delegate - { - InternalLog.Messages.PushBack(new(s, LogEventLevel.Error)); - }); - } - public static void Fatal(string s) - { - Svc.Log.Fatal($"{s}"); - Svc.Framework?.RunOnFrameworkThread(delegate - { - InternalLog.Messages.PushBack(new(s, LogEventLevel.Fatal)); - }); - } - public static void Debug(string s) - { - Svc.Log.Debug($"{s}"); - Svc.Framework?.RunOnFrameworkThread(delegate - { - InternalLog.Messages.PushBack(new(s, LogEventLevel.Debug)); - }); - } - public static void Verbose(string s) - { - Svc.Log.Verbose($"{s}"); - Svc.Framework?.RunOnFrameworkThread(delegate - { - InternalLog.Messages.PushBack(new(s, LogEventLevel.Verbose)); - }); - } - public static void Warning(string s) - { - Svc.Log.Warning($"{s}"); - Svc.Framework?.RunOnFrameworkThread(delegate - { - InternalLog.Messages.PushBack(new(s, LogEventLevel.Warning)); - }); - } - public static void LogInformation(string s) - { - Information(s); - } - public static void LogError(string s) - { - Error(s); - } - public static void LogFatal(string s) - { - Fatal(s); - } - public static void LogDebug(string s) - { - Debug(s); - } - public static void LogVerbose(string s) - { - Verbose(s); - } - public static void LogWarning(string s) - { - Warning(s); - } - public static void Log(string s) - { - Information(s); - } -} diff --git a/ECommons/ECommons/MathHelpers/Bitmask.cs b/ECommons/ECommons/MathHelpers/Bitmask.cs deleted file mode 100644 index 25d7ea5..0000000 --- a/ECommons/ECommons/MathHelpers/Bitmask.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace ECommons.MathHelpers; - -public static class Bitmask -{ - public static bool IsBitSet(ulong b, int pos) - { - return (b & (1UL << pos)) != 0; - } - - public static void SetBit(ref ulong b, int pos) - { - b |= 1UL << pos; - } - - public static void ResetBit(ref ulong b, int pos) - { - b &= ~(1UL << pos); - } - - public static bool IsBitSet(byte b, int pos) - { - return (b & (1 << pos)) != 0; - } - - public static bool IsBitSet(short b, int pos) - { - return (b & (1 << pos)) != 0; - } -} diff --git a/ECommons/ECommons/MathHelpers/CardinalDirection.cs b/ECommons/ECommons/MathHelpers/CardinalDirection.cs deleted file mode 100644 index 2d52d38..0000000 --- a/ECommons/ECommons/MathHelpers/CardinalDirection.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace ECommons.MathHelpers; - -public enum CardinalDirection -{ - North, - South, - West, - East, -} diff --git a/ECommons/ECommons/MathHelpers/Endianness.cs b/ECommons/ECommons/MathHelpers/Endianness.cs deleted file mode 100644 index 9e07c99..0000000 --- a/ECommons/ECommons/MathHelpers/Endianness.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.MathHelpers -{ - public static class Endianness - { - public static uint SwapBytes(this uint x) - { - return ((x & 0x000000ff) << 24) + - ((x & 0x0000ff00) << 8) + - ((x & 0x00ff0000) >> 8) + - ((x & 0xff000000) >> 24); - } - } -} diff --git a/ECommons/ECommons/MathHelpers/MathHelper.cs b/ECommons/ECommons/MathHelpers/MathHelper.cs deleted file mode 100644 index abe7707..0000000 --- a/ECommons/ECommons/MathHelpers/MathHelper.cs +++ /dev/null @@ -1,133 +0,0 @@ -using ECommons.DalamudServices; -using System; -using System.Numerics; - -namespace ECommons.MathHelpers; - -public static class MathHelper -{ - public static Vector3 RotateWorldPoint(Vector3 origin, float angle, Vector3 p) - { - if (angle == 0f) return p; - var s = (float)Math.Sin(angle); - var c = (float)Math.Cos(angle); - - // translate point back to origin: - p.X -= origin.X; - p.Z -= origin.Z; - - // rotate point - float xnew = p.X * c - p.Z * s; - float ynew = p.X * s + p.Z * c; - - // translate point back: - p.X = xnew + origin.X; - p.Z = ynew + origin.Z; - return p; - } - - public static float Float(this int i) - { - return (float)i; - } - - public static Vector2 ToVector2(this Vector3 vector3) - { - return new Vector2(vector3.X, vector3.Z); - } - - public static Vector3 ToVector3(this Vector2 vector2) - { - return vector2.ToVector3(Svc.ClientState.LocalPlayer?.Position.Y ?? 0); - } - - public static Vector3 ToVector3(this Vector2 vector2, float Y) - { - return new Vector3(vector2.X, Y, vector2.Y); - } - - public static float GetRelativeAngle(Vector3 origin, Vector3 target) - { - return GetRelativeAngle(origin.ToVector2(), target.ToVector2()); - } - - public static float GetRelativeAngle(Vector2 origin, Vector2 target) - { - var vector2 = target - origin; - var vector1 = new Vector2(0, 1); - return ((MathF.Atan2(vector2.Y, vector2.X) - MathF.Atan2(vector1.Y, vector1.X)) * (180 / MathF.PI) + 360 + 180) % 360; - } - - public static float RadToDeg(this float f) - { - return (f * (180 / MathF.PI) + 360) % 360; - } - - public static CardinalDirection GetCardinalDirection(Vector3 origin, Vector3 target) - { - return GetCardinalDirection(GetRelativeAngle(origin, target)); - } - - public static CardinalDirection GetCardinalDirection(Vector2 origin, Vector2 target) - { - return GetCardinalDirection(GetRelativeAngle(origin, target)); - } - - public static CardinalDirection GetCardinalDirection(float angle) - { - if (angle.InRange(45, 135)) return CardinalDirection.East; - if (angle.InRange(135, 225)) return CardinalDirection.South; - if (angle.InRange(225, 315)) return CardinalDirection.West; - return CardinalDirection.North; - } - - public static bool InRange(this double f, double inclusiveStart, double exclusiveEnd) - { - return f >= inclusiveStart && f < exclusiveEnd; - } - - public static bool InRange(this float f, float inclusiveStart, float exclusiveEnd) - { - return f >= inclusiveStart && f < exclusiveEnd; - } - - public static bool InRange(this long f, long inclusiveStart, long exclusiveEnd) - { - return f >= inclusiveStart && f < exclusiveEnd; - } - - public static bool InRange(this int f, int inclusiveStart, int exclusiveEnd) - { - return f >= inclusiveStart && f < exclusiveEnd; - } - - public static bool InRange(this short f, short inclusiveStart, short exclusiveEnd) - { - return f >= inclusiveStart && f < exclusiveEnd; - } - - public static bool InRange(this byte f, byte inclusiveStart, byte exclusiveEnd) - { - return f >= inclusiveStart && f < exclusiveEnd; - } - - public static bool InRange(this ulong f, ulong inclusiveStart, ulong exclusiveEnd) - { - return f >= inclusiveStart && f < exclusiveEnd; - } - - public static bool InRange(this uint f, uint inclusiveStart, uint exclusiveEnd) - { - return f >= inclusiveStart && f < exclusiveEnd; - } - - public static bool InRange(this ushort f, ushort inclusiveStart, ushort exclusiveEnd) - { - return f >= inclusiveStart && f < exclusiveEnd; - } - - public static bool InRange(this sbyte f, sbyte inclusiveStart, sbyte exclusiveEnd) - { - return f >= inclusiveStart && f < exclusiveEnd; - } -} diff --git a/ECommons/ECommons/Module.cs b/ECommons/ECommons/Module.cs deleted file mode 100644 index 98f1c30..0000000 --- a/ECommons/ECommons/Module.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace ECommons; - -public enum Module -{ - All, DalamudReflector, ObjectFunctions, ObjectLife, SplatoonAPI -} diff --git a/ECommons/ECommons/Numeric/Int2.cs b/ECommons/ECommons/Numeric/Int2.cs deleted file mode 100644 index dbe4e12..0000000 --- a/ECommons/ECommons/Numeric/Int2.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Numerics; - -namespace ECommons.Numeric; - -public struct Int2 -{ - public int X = 0; - public int Y = 0; - - public Int2(int X, int Y) - { - this.X = X; - this.Y = Y; - } - - public Int2(Vector2 v) - { - this.X = (int)v.X; - this.Y = (int)v.Y; - } - - public static Int2 operator+(Int2 v1, Int2 v2) - { - return new(v1.X + v2.X, v1.Y + v2.Y); - } - - public Vector2 ToVector2() - { - return new Vector2(X, Y); - } -} diff --git a/ECommons/ECommons/ObjectLifeTracker/ObjectLife.cs b/ECommons/ECommons/ObjectLifeTracker/ObjectLife.cs deleted file mode 100644 index 79d2004..0000000 --- a/ECommons/ECommons/ObjectLifeTracker/ObjectLife.cs +++ /dev/null @@ -1,88 +0,0 @@ -using Dalamud.Game.ClientState.Objects.Types; -using Dalamud.Hooking; -using ECommons.Logging; -using ECommons.DalamudServices; -using System; -using System.Collections.Generic; - -namespace ECommons.ObjectLifeTracker; - -public static class ObjectLife -{ - delegate IntPtr GameObject_ctor(IntPtr obj); - static Hook GameObject_ctor_hook = null; - static Dictionary GameObjectLifeTime = null; - public static Action OnObjectCreation = null; - - internal static void Init() - { - GameObjectLifeTime = new(); -#pragma warning disable CS0618 // Type or member is obsolete - GameObject_ctor_hook = Svc.Hook.HookFromAddress(Svc.SigScanner.ScanText("48 8D 05 ?? ?? ?? ?? C7 81 ?? ?? ?? ?? ?? ?? ?? ?? 48 89 01 48 8B C1 C3"), GameObject_ctor_detour); -#pragma warning restore CS0618 // Type or member is obsolete - GameObject_ctor_hook.Enable(); - foreach (var x in Svc.Objects) - { - GameObjectLifeTime[x.Address] = Environment.TickCount64; - } - } - - internal static void Dispose() - { - if (GameObject_ctor_hook != null) - { - GameObject_ctor_hook.Disable(); - GameObject_ctor_hook.Dispose(); - GameObject_ctor_hook = null; - } - GameObjectLifeTime = null; - } - - static IntPtr GameObject_ctor_detour(IntPtr ptr) - { - if (GameObjectLifeTime == null) - { - throw new Exception("GameObjectLifeTime is null. Have you initialised the ObjectLife module on ECommons initialisation?"); - } - GameObjectLifeTime[ptr] = Environment.TickCount64; - var ret = GameObject_ctor_hook.Original(ptr); - - if (OnObjectCreation != null) - { - try - { - OnObjectCreation(ptr); - } - catch (Exception e) - { - e.Log($"Exception in GameObject_ctor_detour"); - } - } - return ret; - } - - public static long GetLifeTime(this GameObject o) - { - return Environment.TickCount64 - GetSpawnTime(o); - } - - public static float GetLifeTimeSeconds(this GameObject o) - { - return (float)o.GetLifeTime() / 1000f; - } - - public static long GetSpawnTime(this GameObject o) - { - if (GameObject_ctor_hook == null) throw new Exception("Object life tracker was not initialized"); - if (GameObjectLifeTime.TryGetValue(o.Address, out var result)) - { - return result; - } - else - { - PluginLog.Warning($"Warning: object life data could not be found\n" + - $"Object addr: {o.Address:X16} ID: {o.ObjectId:X8} Name: {o.Name}"); - return 0; - } - } -} diff --git a/ECommons/ECommons/Opcodes/OpcodeUpdater.cs b/ECommons/ECommons/Opcodes/OpcodeUpdater.cs deleted file mode 100644 index 69ef74a..0000000 --- a/ECommons/ECommons/Opcodes/OpcodeUpdater.cs +++ /dev/null @@ -1,76 +0,0 @@ -using ECommons.Logging; -using ECommons.Schedulers; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Net.Http; -using System.Threading; - -namespace ECommons.Opcodes; - -public static class OpcodeUpdater -{ - static HttpClient client; - public static void DownloadOpcodes(string url, Action> successCallback, Action failureCallback = null) - { - client ??= new(); - new Thread(() => - { - try - { - Dictionary dic = new(); - PluginLog.Debug($"Opcode list downloading from {url}..."); - var result = client.GetAsync(url).Result; - if (!result.IsSuccessStatusCode) - { - _ = new TickScheduler(delegate - { - var error = $"{(int)result.StatusCode} {result.StatusCode}"; - if (failureCallback == null) - { - PluginLog.Warning($"Failed to download opcodes: {error}"); - } - else - { - failureCallback(error); - } - }); - } - else - { - PluginLog.Debug("Opcode list download success"); - var content = result.Content.ReadAsStringAsync().Result; - foreach (var s in content.Split("\n")) - { - var o = s.Split("|"); - if (o.Length == 2) - { - PluginLog.Debug($"Received opcode: {o[0]} = 0x{o[1]}"); - if (uint.TryParse(o[1], NumberStyles.HexNumber, null, out var code)) - { - PluginLog.Debug($"Opcode {o[0]} = 0x{code:X} ({code})"); - dic[o[0]] = code; - } - } - } - _ = new TickScheduler(delegate - { - successCallback(dic); - }); - } - } - catch(Exception e) - { - var error = $"{e.Message} \n {e.StackTrace ?? ""}"; - if(failureCallback == null) - { - PluginLog.Warning($"Failed to download opcodes: {error}"); - } - else - { - failureCallback(error); - } - } - }).Start(); - } -} diff --git a/ECommons/ECommons/PartyFunctions/UniversalParty.cs b/ECommons/ECommons/PartyFunctions/UniversalParty.cs deleted file mode 100644 index fc5b49c..0000000 --- a/ECommons/ECommons/PartyFunctions/UniversalParty.cs +++ /dev/null @@ -1,58 +0,0 @@ -using Dalamud.Game.ClientState.Conditions; -using Dalamud.Memory; -using ECommons.DalamudServices; -using FFXIVClientStructs.FFXIV.Client.UI.Info; -using System; -using System.Collections.Generic; - -namespace ECommons.PartyFunctions; - -public unsafe static class UniversalParty -{ - public static bool IsCrossWorldParty => Svc.Condition[ConditionFlag.ParticipatingInCrossWorldPartyOrAlliance]; - - public static int Length - { - get - { - var cnt = IsCrossWorldParty ? InfoProxyCrossRealm.Instance()->CrossRealmGroupArraySpan.Length : Svc.Party.Length; - return cnt > 1?cnt:0; - } - } - - public static UniversalPartyMember[] Members - { - get - { - if (Length == 0) return Array.Empty(); - var span = new List(); - if (IsCrossWorldParty) - { - for (int i = 0; i < InfoProxyCrossRealm.Instance()->CrossRealmGroupArraySpan[0].GroupMemberCount; i++) - { - var x = InfoProxyCrossRealm.Instance()->CrossRealmGroupArraySpan[0].GroupMembersSpan[i]; - span.Add(new() - { - Name = MemoryHelper.ReadStringNullTerminated((IntPtr)x.Name), - HomeWorld = new((uint)x.HomeWorld), - CurrentWorld = new((uint)x.CurrentWorld), - }); - } - } - else - { - foreach(var x in Svc.Party) - { - span.Add(new() - { - Name = x.Name.ToString(), - HomeWorld = new(x.World), - CurrentWorld = new(Svc.ClientState.LocalPlayer.CurrentWorld), - GameObjectInternal = x.GameObject - }); - } - } - return span.ToArray(); - } - } -} diff --git a/ECommons/ECommons/PartyFunctions/UniversalPartyMember.cs b/ECommons/ECommons/PartyFunctions/UniversalPartyMember.cs deleted file mode 100644 index c22fdd5..0000000 --- a/ECommons/ECommons/PartyFunctions/UniversalPartyMember.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Dalamud.Game.ClientState.Objects.SubKinds; -using Dalamud.Game.ClientState.Objects.Types; -using ECommons.DalamudServices; -using Lumina.Excel.GeneratedSheets; -using System; -using System.Linq; - -namespace ECommons.PartyFunctions; - -public class UniversalPartyMember -{ - public String Name { get; init; } - public ExcelResolver HomeWorld { get; init; } - public ExcelResolver CurrentWorld { get; init; } - - internal GameObject GameObjectInternal = null; - public GameObject GameObject - { - get - { - if (UniversalParty.IsCrossWorldParty) - { - return Svc.Objects.FirstOrDefault(x => x is PlayerCharacter pc && pc.HomeWorld.Id == this.HomeWorld.Id && x.Name.ToString() == this.Name); - } - else - { - return GameObjectInternal; - } - } - } -} diff --git a/ECommons/ECommons/PointerHelpers.cs b/ECommons/ECommons/PointerHelpers.cs deleted file mode 100644 index 3b7f47c..0000000 --- a/ECommons/ECommons/PointerHelpers.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace ECommons; - -public static unsafe class PointerHelpers -{ - public static T* As(this IntPtr ptr) where T:unmanaged - { - return (T*)ptr; - } -} diff --git a/ECommons/ECommons/Reflection/DalamudReflector.cs b/ECommons/ECommons/Reflection/DalamudReflector.cs deleted file mode 100644 index 52abefe..0000000 --- a/ECommons/ECommons/Reflection/DalamudReflector.cs +++ /dev/null @@ -1,191 +0,0 @@ -using Dalamud; -using Dalamud.Game.ClientState.Keys; -using ECommons.Logging; -using Dalamud.Plugin; -using ECommons.DalamudServices; -using ECommons.Schedulers; -using System; -using System.Collections.Generic; -using System.Reflection; -using Dalamud.Common; - -namespace ECommons.Reflection; - -public static class DalamudReflector -{ - delegate ref int GetRefValue(int vkCode); - static GetRefValue getRefValue; - static Dictionary pluginCache; - static List onPluginsChangedActions; - - internal static void Init() - { - onPluginsChangedActions = new(); - pluginCache = new(); - GenericHelpers.Safe(delegate - { - getRefValue = (GetRefValue)Delegate.CreateDelegate(typeof(GetRefValue), Svc.KeyState, - Svc.KeyState.GetType().GetMethod("GetRefValue", - BindingFlags.NonPublic | BindingFlags.Instance, - null, new Type[] { typeof(int) }, null)); - }); - Svc.PluginInterface.ActivePluginsChanged += OnInstalledPluginsChanged; - } - - internal static void Dispose() - { - if (pluginCache != null) - { - pluginCache = null; - onPluginsChangedActions = null; - } - Svc.PluginInterface.ActivePluginsChanged -= OnInstalledPluginsChanged; - } - - public static void RegisterOnInstalledPluginsChangedEvents(params Action[] actions) - { - foreach(var x in actions) - { - onPluginsChangedActions.Add(x); - } - } - - public static void SetKeyState(VirtualKey key, int state) - { - getRefValue((int)key) = state; - } - - public static object GetPluginManager() - { - return Svc.PluginInterface.GetType().Assembly. - GetType("Dalamud.Service`1", true).MakeGenericType(Svc.PluginInterface.GetType().Assembly.GetType("Dalamud.Plugin.Internal.PluginManager", true)). - GetMethod("Get").Invoke(null, BindingFlags.Default, null, Array.Empty(), null); - } - - public static object GetService(string serviceFullName) - { - return Svc.PluginInterface.GetType().Assembly. - GetType("Dalamud.Service`1", true).MakeGenericType(Svc.PluginInterface.GetType().Assembly.GetType(serviceFullName, true)). - GetMethod("Get").Invoke(null, BindingFlags.Default, null, Array.Empty(), null); - } - - public static bool TryGetLocalPlugin(out object localPlugin, out Type type) - { - try - { - if (ECommonsMain.Instance == null) - { - throw new Exception("PluginInterface is null. Did you initalise ECommons?"); - } - var pluginManager = GetPluginManager(); - var installedPlugins = (System.Collections.IList)pluginManager.GetType().GetProperty("InstalledPlugins").GetValue(pluginManager); - - foreach (var t in installedPlugins) - { - if (t != null) - { - type = t.GetType().Name == "LocalDevPlugin" ? t.GetType().BaseType : t.GetType(); - if (object.ReferenceEquals(type.GetField("instance", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(t), ECommonsMain.Instance)) - { - localPlugin = t; - return true; - } - } - } - localPlugin = type = null; - return false; - } - catch(Exception e) - { - e.Log(); - localPlugin = type = null; - return false; - } - } - - public static bool TryGetDalamudPlugin(string internalName, out IDalamudPlugin instance, bool suppressErrors = false, bool ignoreCache = false) - { - if (pluginCache == null) - { - throw new Exception("PluginCache is null. Have you initialised the DalamudReflector module on ECommons initialisation?"); - } - - if(!ignoreCache && pluginCache.TryGetValue(internalName, out instance) && instance != null) - { - return true; - } - try - { - var pluginManager = GetPluginManager(); - var installedPlugins = (System.Collections.IList)pluginManager.GetType().GetProperty("InstalledPlugins").GetValue(pluginManager); - - foreach (var t in installedPlugins) - { - if ((string)t.GetType().GetProperty("Name").GetValue(t) == internalName) - { - var type = t.GetType().Name == "LocalDevPlugin" ? t.GetType().BaseType : t.GetType(); - var plugin = (IDalamudPlugin)type.GetField("instance", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(t); - if (plugin == null) - { - InternalLog.Warning($"Found requested plugin {internalName} but it was null"); - } - else - { - instance = plugin; - pluginCache[internalName] = plugin; - return true; - } - } - } - instance = null; - return false; - } - catch (Exception e) - { - if (!suppressErrors) - { - PluginLog.Error($"Can't find {internalName} plugin: " + e.Message); - PluginLog.Error(e.StackTrace); - } - instance = null; - return false; - } - } - - public static bool TryGetDalamudStartInfo(out DalamudStartInfo dalamudStartInfo, DalamudPluginInterface pluginInterface = null) - { - try - { - if (pluginInterface == null) pluginInterface = Svc.PluginInterface; - var info = pluginInterface.GetType().Assembly. - GetType("Dalamud.Service`1", true).MakeGenericType(Svc.PluginInterface.GetType().Assembly.GetType("Dalamud.Dalamud", true)). - GetMethod("Get").Invoke(null, BindingFlags.Default, null, Array.Empty(), null); - dalamudStartInfo = info.GetFoP("StartInfo"); - return true; - } - catch (Exception e) - { - PluginLog.Error($"{e.Message}\n{e.StackTrace ?? ""}"); - dalamudStartInfo = default; - return false; - } - } - - public static string GetPluginName() - { - return Svc.PluginInterface?.InternalName ?? "Not initialized"; - } - - internal static void OnInstalledPluginsChanged(PluginListInvalidationKind kind, bool affectedThisPlugin) - { - PluginLog.Verbose("Installed plugins changed event fired"); - _ = new TickScheduler(delegate - { - pluginCache.Clear(); - foreach(var x in onPluginsChangedActions) - { - x(); - } - }); - } -} diff --git a/ECommons/ECommons/Reflection/ReflectionHelper.cs b/ECommons/ECommons/Reflection/ReflectionHelper.cs deleted file mode 100644 index d1723ba..0000000 --- a/ECommons/ECommons/Reflection/ReflectionHelper.cs +++ /dev/null @@ -1,79 +0,0 @@ -using Dalamud.Logging; -using System.Linq; -using System.Reflection; -using System.Reflection.Metadata.Ecma335; - -namespace ECommons.Reflection; - -public static class ReflectionHelper -{ - public const BindingFlags AllFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; - public const BindingFlags StaticFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static; - - public static object GetFoP(this object obj, string name) - { - return obj.GetType().GetField(name, AllFlags)?.GetValue(obj) - ?? obj.GetType().GetProperty(name, AllFlags)?.GetValue(obj); - } - - public static T GetFoP(this object obj, string name) - { - return (T)GetFoP(obj, name); - } - - public static void SetFoP(this object obj, string name, object value) - { - var field = obj.GetType().GetField(name, AllFlags); - if(field != null) - { - field.SetValue(obj, value); - } - else - { - obj.GetType().GetProperty(name, AllFlags).SetValue(obj, value); - } - } - - public static object GetStaticFoP(this object obj, string type, string name) - { - return obj.GetType().Assembly.GetType(type).GetField(name, StaticFlags)?.GetValue(null) - ?? obj.GetType().Assembly.GetType(type).GetProperty(name, StaticFlags)?.GetValue(null); - } - - public static T GetStaticFoP(this object obj, string type, string name) - { - return (T)GetStaticFoP(obj, type, name); - } - - public static void SetStaticFoP(this object obj, string type, string name, object value) - { - var field = obj.GetType().Assembly.GetType(type).GetField(name, StaticFlags); - if (field != null) - { - field.SetValue(null, value); - } - else - { - obj.GetType().Assembly.GetType(type).GetProperty(name, StaticFlags).SetValue(null, value); - } - } - - public static object Call(this object obj, string name, params object[] values) - { - var info = obj.GetType().GetMethod(name, AllFlags, values.Select(x => x.GetType()).ToArray()); - return info.Invoke(obj, values); - } - - public static T Call(this object obj, string name, params object[] values) - { - return (T)Call(obj, name, values); - } - - public static object CallStatic(this object obj, string type, string name, params object[] values) - { - var info = obj.GetType().Assembly.GetType(type).GetMethod(name, AllFlags, values.Select(x => x.GetType()).ToArray()); - return info.Invoke(obj, values); - } - - public static object CallStatic(this object obj, string type, string name, params object[] values) => CallStatic(obj, type, name, values); -} diff --git a/ECommons/ECommons/Schedulers/ExecuteForScheduler.cs b/ECommons/ECommons/Schedulers/ExecuteForScheduler.cs deleted file mode 100644 index 1ed5f4f..0000000 --- a/ECommons/ECommons/Schedulers/ExecuteForScheduler.cs +++ /dev/null @@ -1,44 +0,0 @@ -using ECommons.Logging; -using ECommons.DalamudServices; -using System; - -namespace ECommons.Schedulers; - -public class ExecuteForScheduler : IScheduler -{ - long stopExecAt; - Action function; - bool disposed = false; - - public ExecuteForScheduler(Action function, long executeForMS) - { - stopExecAt = Environment.TickCount64 + executeForMS; - this.function = function; - Svc.Framework.Update += Execute; - } - - public void Dispose() - { - if (!disposed) - { - Svc.Framework.Update -= Execute; - } - disposed = true; - } - - void Execute(object _) - { - try - { - function(); - } - catch (Exception e) - { - PluginLog.Error(e.Message + "\n" + e.StackTrace ?? ""); - } - if (Environment.TickCount64 > stopExecAt) - { - Dispose(); - } - } -} \ No newline at end of file diff --git a/ECommons/ECommons/Schedulers/IScheduler.cs b/ECommons/ECommons/Schedulers/IScheduler.cs deleted file mode 100644 index c0c8493..0000000 --- a/ECommons/ECommons/Schedulers/IScheduler.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System; - -namespace ECommons.Schedulers; - -public interface IScheduler : IDisposable -{ -} diff --git a/ECommons/ECommons/Schedulers/TickScheduler.cs b/ECommons/ECommons/Schedulers/TickScheduler.cs deleted file mode 100644 index 5d5461c..0000000 --- a/ECommons/ECommons/Schedulers/TickScheduler.cs +++ /dev/null @@ -1,42 +0,0 @@ -using ECommons.Logging; -using ECommons.DalamudServices; -using System; - -namespace ECommons.Schedulers; - -public class TickScheduler : IScheduler -{ - long executeAt; - Action function; - bool disposed = false; - - public TickScheduler(Action function, long delayMS = 0) - { - executeAt = Environment.TickCount64 + delayMS; - this.function = function; - Svc.Framework.Update += Execute; - } - - public void Dispose() - { - if (!disposed) - { - Svc.Framework.Update -= Execute; - } - disposed = true; - } - - void Execute(object _) - { - if (Environment.TickCount64 < executeAt) return; - try - { - function(); - } - catch (Exception e) - { - PluginLog.Error(e.Message + "\n" + e.StackTrace ?? ""); - } - Dispose(); - } -} \ No newline at end of file diff --git a/ECommons/ECommons/SimpleGui/ConfigWindow.cs b/ECommons/ECommons/SimpleGui/ConfigWindow.cs deleted file mode 100644 index a18ca0b..0000000 --- a/ECommons/ECommons/SimpleGui/ConfigWindow.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Dalamud.Interface.Windowing; -using ECommons.Configuration; -using ECommons.DalamudServices; -using ECommons.ImGuiMethods; - -namespace ECommons.SimpleGui; - -internal class ConfigWindow : Window -{ - public ConfigWindow(string name) : base(name) - { - this.SizeConstraints = new() - { - MinimumSize = new(200, 200), - MaximumSize = new(float.MaxValue, float.MaxValue) - }; - } - - public override void Draw() - { - GenericHelpers.Safe(EzConfigGui.Draw); - } - - public override void OnOpen() - { - EzConfigGui.OnOpen?.Invoke(); - } - - public override void OnClose() - { - if(EzConfigGui.Config != null) - { - Svc.PluginInterface.SavePluginConfig(EzConfigGui.Config); - Notify.Success("Configuration saved"); - } - if(EzConfig.Config != null) - { - EzConfig.Save(); - Notify.Success("Configuration saved"); - } - EzConfigGui.OnClose?.Invoke(); - } -} diff --git a/ECommons/ECommons/SimpleGui/EzConfigGui.cs b/ECommons/ECommons/SimpleGui/EzConfigGui.cs deleted file mode 100644 index 60d9bd1..0000000 --- a/ECommons/ECommons/SimpleGui/EzConfigGui.cs +++ /dev/null @@ -1,45 +0,0 @@ -using Dalamud.Configuration; -using Dalamud.Interface.Windowing; -using ECommons.DalamudServices; -using ECommons.Reflection; -using System; - -namespace ECommons.SimpleGui; - -public static class EzConfigGui -{ - public static WindowSystem WindowSystem { get; internal set; } - internal static Action Draw = null; - internal static Action OnClose = null; - internal static Action OnOpen = null; - internal static IPluginConfiguration Config; - static ConfigWindow configWindow; - static string Ver = string.Empty; - public static Window Window { get { return configWindow; } } - - public static void Init(Action draw, IPluginConfiguration config = null) - { - if(WindowSystem != null) - { - throw new Exception("ConfigGui already initialized"); - } - WindowSystem = new($"ECommons@{DalamudReflector.GetPluginName()}"); - Draw = draw; - Config = config; - Ver = ECommonsMain.Instance.GetType().Assembly.GetName().Version.ToString(); - configWindow = new($"{DalamudReflector.GetPluginName()} v{Ver}###{DalamudReflector.GetPluginName()}"); - WindowSystem.AddWindow(configWindow); - Svc.PluginInterface.UiBuilder.Draw += WindowSystem.Draw; - Svc.PluginInterface.UiBuilder.OpenConfigUi += Open; - } - - public static void Open() - { - configWindow.IsOpen = true; - } - - public static void Open(string cmd = null, string args = null) - { - Open(); - } -} diff --git a/ECommons/ECommons/SimpleLogger.cs b/ECommons/ECommons/SimpleLogger.cs deleted file mode 100644 index 90072e9..0000000 --- a/ECommons/ECommons/SimpleLogger.cs +++ /dev/null @@ -1,73 +0,0 @@ -using ECommons.Logging; -using System; -using System.Collections.Concurrent; -using System.IO; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace ECommons; - -public class SimpleLogger : IDisposable -{ - BlockingCollection logQueue = new(); - public SimpleLogger(string dir, string filename) - { - filename = filename.Split(Path.GetInvalidFileNameChars()).Join("_"); - new Thread((ThreadStart)delegate - { - try - { - using (StreamWriter stream = new(Path.Combine(dir, filename), true, Encoding.UTF8)) - { - stream.WriteLine($"Log begins at {DateTimeOffset.Now:s}"); - try - { - while (!logQueue.IsCompleted) - { - var str = $"{logQueue.Take()}"; - stream.WriteLine(str); - } - } - catch(InvalidOperationException e) - { - PluginLog.Information($"Not an error: {e.Message}\n{e.StackTrace ?? ""}"); - } - stream.WriteLine($"Log ends at {DateTimeOffset.Now:s}"); - } - } - catch(InvalidOperationException e) - { - PluginLog.Information($"Not an error: {e.Message}\n{e.StackTrace ?? ""}"); - } - catch (Exception e) - { - PluginLog.Error($"{e.Message}\n{e.StackTrace ?? ""}"); - } - }).Start(); - } - - public void Dispose() - { - logQueue.CompleteAdding(); - } - - public void Log(string s) - { - if (logQueue.IsAddingCompleted) - { - PluginLog.Information($"Can not log, collection is marked as completed\n{s}"); - return; - } - s = $"{DateTimeOffset.Now:s} {s}"; - if (!logQueue.TryAdd(s)) - { - Task.Run(delegate { try { logQueue.Add(s); } catch (Exception e) { e.Log(); } }); - } - } - - public void LogError(string s) - { - Log($"Error: {s}"); - } -} diff --git a/ECommons/ECommons/SplatoonAPI/Element.cs b/ECommons/ECommons/SplatoonAPI/Element.cs deleted file mode 100644 index fa814c5..0000000 --- a/ECommons/ECommons/SplatoonAPI/Element.cs +++ /dev/null @@ -1,490 +0,0 @@ -using System.Collections.Generic; -using System.Numerics; -using System.Reflection; - -namespace ECommons.SplatoonAPI; - -public class Element -{ - int Version; - internal object Instance; - public Element(ElementType type) - { - Version = Splatoon.Version; - Instance = Splatoon.Instance.GetType().Assembly.CreateInstance("Splatoon.Element", false, BindingFlags.Default, null, new object[] { (int)type }, null, null); - } - - internal Element(object Instance) - { - Version = Splatoon.Version; - this.Instance = Instance; - } - - public bool IsValid() - { - return Version == Splatoon.Version; - } - - public void SetRefCoord(Vector3 v) - { - this.refX = v.X; - this.refY = v.Z; - this.refZ = v.Y; - } - - public void SetOffCoord(Vector3 v) - { - this.offX = v.X; - this.offY = v.Z; - this.offZ = v.Y; - } - - public ElementType type - { - get => (ElementType)Instance.GetType().GetField("type").GetValue(Instance); - set => Instance.GetType().GetField("type").SetValue(Instance, (int)value); - } - public bool Enabled - { - get => (bool)Instance.GetType().GetField("Enabled").GetValue(Instance); - set => Instance.GetType().GetField("Enabled").SetValue(Instance, value); - } - /// - /// When type is fixed coordinate element: specifies coordinate of that element, otherwise has no effect - /// - public float refX - { - get => (float)Instance.GetType().GetField("refX").GetValue(Instance); - set => Instance.GetType().GetField("refX").SetValue(Instance, value); - } - /// - /// When type is fixed coordinate element: specifies coordinate of that element, otherwise has no effect - /// - public float refY - { - get => (float)Instance.GetType().GetField("refY").GetValue(Instance); - set => Instance.GetType().GetField("refY").SetValue(Instance, value); - } - /// - /// When type is fixed coordinate element: specifies coordinate of that element, otherwise has no effect - /// - public float refZ - { - get => (float)Instance.GetType().GetField("refZ").GetValue(Instance); - set => Instance.GetType().GetField("refZ").SetValue(Instance, value); - } - /// - /// Specifies offset from targeted object or fixed coordinate - /// - public float offX - { - get => (float)Instance.GetType().GetField("offX").GetValue(Instance); - set => Instance.GetType().GetField("offX").SetValue(Instance, value); - } - /// - /// Specifies offset from targeted object or fixed coordinate - /// - public float offY - { - get => (float)Instance.GetType().GetField("offY").GetValue(Instance); - set => Instance.GetType().GetField("offY").SetValue(Instance, value); - } - /// - /// Specifies offset from targeted object or fixed coordinate - /// - public float offZ - { - get => (float)Instance.GetType().GetField("offZ").GetValue(Instance); - set => Instance.GetType().GetField("offZ").SetValue(Instance, value); - } - public float radius - { - get => (float)Instance.GetType().GetField("radius").GetValue(Instance); - set => Instance.GetType().GetField("radius").SetValue(Instance, value); - } - public float Donut - { - get => (float)Instance.GetType().GetField("Donut").GetValue(Instance); - set => Instance.GetType().GetField("Donut").SetValue(Instance, value); - } - public int coneAngleMin - { - get => (int)Instance.GetType().GetField("coneAngleMin").GetValue(Instance); - set => Instance.GetType().GetField("coneAngleMin").SetValue(Instance, value); - } - public int coneAngleMax - { - get => (int)Instance.GetType().GetField("coneAngleMax").GetValue(Instance); - set => Instance.GetType().GetField("coneAngleMax").SetValue(Instance, value); - } - public uint color - { - get => (uint)Instance.GetType().GetField("color").GetValue(Instance); - set => Instance.GetType().GetField("color").SetValue(Instance, value); - } - public uint overlayBGColor - { - get => (uint)Instance.GetType().GetField("overlayBGColor").GetValue(Instance); - set => Instance.GetType().GetField("overlayBGColor").SetValue(Instance, value); - } - public uint overlayTextColor - { - get => (uint)Instance.GetType().GetField("overlayTextColor").GetValue(Instance); - set => Instance.GetType().GetField("overlayTextColor").SetValue(Instance, value); - } - public float overlayVOffset - { - get => (float)Instance.GetType().GetField("overlayVOffset").GetValue(Instance); - set => Instance.GetType().GetField("overlayVOffset").SetValue(Instance, value); - } - public float overlayFScale - { - get => (float)Instance.GetType().GetField("overlayFScale").GetValue(Instance); - set => Instance.GetType().GetField("overlayFScale").SetValue(Instance, value); - } - public bool overlayPlaceholders - { - get => (bool)Instance.GetType().GetField("overlayPlaceholders").GetValue(Instance); - set => Instance.GetType().GetField("overlayPlaceholders").SetValue(Instance, value); - } - public float thicc - { - get => (float)Instance.GetType().GetField("thicc").GetValue(Instance); - set => Instance.GetType().GetField("thicc").SetValue(Instance, value); - } - public string overlayText - { - get => (string)Instance.GetType().GetField("overlayText").GetValue(Instance); - set => Instance.GetType().GetField("overlayText").SetValue(Instance, value); - } - public string refActorName - { - get => (string)Instance.GetType().GetField("refActorName").GetValue(Instance); - set => Instance.GetType().GetField("refActorName").SetValue(Instance, value); - } - public uint refActorModelID - { - get => (uint)Instance.GetType().GetField("refActorModelID").GetValue(Instance); - set => Instance.GetType().GetField("refActorModelID").SetValue(Instance, value); - } - public uint refActorObjectID - { - get => (uint)Instance.GetType().GetField("refActorObjectID").GetValue(Instance); - set => Instance.GetType().GetField("refActorObjectID").SetValue(Instance, value); - } - public uint refActorDataID - { - get => (uint)Instance.GetType().GetField("refActorDataID").GetValue(Instance); - set => Instance.GetType().GetField("refActorDataID").SetValue(Instance, value); - } - public uint refActorNPCID - { - get => (uint)Instance.GetType().GetField("refActorNPCID").GetValue(Instance); - set => Instance.GetType().GetField("refActorNPCID").SetValue(Instance, value); - } - public List refActorPlaceholder - { - get => (List)Instance.GetType().GetField("refActorPlaceholder").GetValue(Instance); - set => Instance.GetType().GetField("refActorPlaceholder").SetValue(Instance, value); - } - public uint refActorNPCNameID - { - get => (uint)Instance.GetType().GetField("refActorNPCNameID").GetValue(Instance); - set => Instance.GetType().GetField("refActorNPCNameID").SetValue(Instance, value); - } - public bool refActorComparisonAnd - { - get => (bool)Instance.GetType().GetField("refActorComparisonAnd").GetValue(Instance); - set => Instance.GetType().GetField("refActorComparisonAnd").SetValue(Instance, value); - } - public bool refActorRequireCast - { - get => (bool)Instance.GetType().GetField("refActorRequireCast").GetValue(Instance); - set => Instance.GetType().GetField("refActorRequireCast").SetValue(Instance, value); - } - public List refActorCastId - { - get => (List)Instance.GetType().GetField("refActorCastId").GetValue(Instance); - set => Instance.GetType().GetField("refActorCastId").SetValue(Instance, value); - } - public bool refActorUseCastTime - { - get => (bool)Instance.GetType().GetField("refActorUseCastTime").GetValue(Instance); - set => Instance.GetType().GetField("refActorUseCastTime").SetValue(Instance, value); - } - public float refActorCastTimeMin - { - get => (float)Instance.GetType().GetField("refActorCastTimeMin").GetValue(Instance); - set => Instance.GetType().GetField("refActorCastTimeMin").SetValue(Instance, value); - } - public float refActorCastTimeMax - { - get => (float)Instance.GetType().GetField("refActorCastTimeMax").GetValue(Instance); - set => Instance.GetType().GetField("refActorCastTimeMax").SetValue(Instance, value); - } - public bool refActorUseOvercast - { - get => (bool)Instance.GetType().GetField("refActorUseOvercast").GetValue(Instance); - set => Instance.GetType().GetField("refActorUseOvercast").SetValue(Instance, value); - } - public bool refActorRequireBuff - { - get => (bool)Instance.GetType().GetField("refActorRequireBuff").GetValue(Instance); - set => Instance.GetType().GetField("refActorRequireBuff").SetValue(Instance, value); - } - public List refActorBuffId - { - get => (List)Instance.GetType().GetField("refActorBuffId").GetValue(Instance); - set => Instance.GetType().GetField("refActorBuffId").SetValue(Instance, value); - } - public bool refActorRequireAllBuffs - { - get => (bool)Instance.GetType().GetField("refActorRequireAllBuffs").GetValue(Instance); - set => Instance.GetType().GetField("refActorRequireAllBuffs").SetValue(Instance, value); - } - public bool refActorRequireBuffsInvert - { - get => (bool)Instance.GetType().GetField("refActorRequireBuffsInvert").GetValue(Instance); - set => Instance.GetType().GetField("refActorRequireBuffsInvert").SetValue(Instance, value); - } - public bool refActorUseBuffTime - { - get => (bool)Instance.GetType().GetField("refActorUseBuffTime").GetValue(Instance); - set => Instance.GetType().GetField("refActorUseBuffTime").SetValue(Instance, value); - } - public float refActorBuffTimeMin - { - get => (float)Instance.GetType().GetField("refActorBuffTimeMin").GetValue(Instance); - set => Instance.GetType().GetField("refActorBuffTimeMin").SetValue(Instance, value); - } - public float refActorBuffTimeMax - { - get => (float)Instance.GetType().GetField("refActorBuffTimeMax").GetValue(Instance); - set => Instance.GetType().GetField("refActorBuffTimeMax").SetValue(Instance, value); - } - public bool refActorObjectLife - { - get => (bool)Instance.GetType().GetField("refActorObjectLife").GetValue(Instance); - set => Instance.GetType().GetField("refActorObjectLife").SetValue(Instance, value); - } - public float refActorLifetimeMin - { - get => (float)Instance.GetType().GetField("refActorLifetimeMin").GetValue(Instance); - set => Instance.GetType().GetField("refActorLifetimeMin").SetValue(Instance, value); - } - public float refActorLifetimeMax - { - get => (float)Instance.GetType().GetField("refActorLifetimeMax").GetValue(Instance); - set => Instance.GetType().GetField("refActorLifetimeMax").SetValue(Instance, value); - } - public float FillStep - { - get => (float)Instance.GetType().GetField("FillStep").GetValue(Instance); - set => Instance.GetType().GetField("FillStep").SetValue(Instance, value); - } - public RefActorComparisonType refActorComparisonType - { - get => (RefActorComparisonType)Instance.GetType().GetField("refActorComparisonType").GetValue(Instance); - set => Instance.GetType().GetField("refActorComparisonType").SetValue(Instance, (int)value); - } - public RefActorType refActorType - { - get => (RefActorType)Instance.GetType().GetField("refActorType").GetValue(Instance); - set => Instance.GetType().GetField("refActorType").SetValue(Instance, (int)value); - } - public bool includeHitbox - { - get => (bool)Instance.GetType().GetField("includeHitbox").GetValue(Instance); - set => Instance.GetType().GetField("includeHitbox").SetValue(Instance, value); - } - public bool includeOwnHitbox - { - get => (bool)Instance.GetType().GetField("includeOwnHitbox").GetValue(Instance); - set => Instance.GetType().GetField("includeOwnHitbox").SetValue(Instance, value); - } - public bool includeRotation - { - get => (bool)Instance.GetType().GetField("includeRotation").GetValue(Instance); - set => Instance.GetType().GetField("includeRotation").SetValue(Instance, value); - } - public bool onlyTargetable - { - get => (bool)Instance.GetType().GetField("onlyTargetable").GetValue(Instance); - set => Instance.GetType().GetField("onlyTargetable").SetValue(Instance, value); - } - public bool onlyUnTargetable - { - get => (bool)Instance.GetType().GetField("onlyUnTargetable").GetValue(Instance); - set => Instance.GetType().GetField("onlyUnTargetable").SetValue(Instance, value); - } - public bool onlyVisible - { - get => (bool)Instance.GetType().GetField("onlyVisible").GetValue(Instance); - set => Instance.GetType().GetField("onlyVisible").SetValue(Instance, value); - } - public bool tether - { - get => (bool)Instance.GetType().GetField("tether").GetValue(Instance); - set => Instance.GetType().GetField("tether").SetValue(Instance, value); - } - public float AdditionalRotation - { - get => (float)Instance.GetType().GetField("AdditionalRotation").GetValue(Instance); - set => Instance.GetType().GetField("AdditionalRotation").SetValue(Instance, value); - } - public bool LineAddHitboxLengthX - { - get => (bool)Instance.GetType().GetField("LineAddHitboxLengthX").GetValue(Instance); - set => Instance.GetType().GetField("LineAddHitboxLengthX").SetValue(Instance, value); - } - public bool LineAddHitboxLengthY - { - get => (bool)Instance.GetType().GetField("LineAddHitboxLengthY").GetValue(Instance); - set => Instance.GetType().GetField("LineAddHitboxLengthY").SetValue(Instance, value); - } - public bool LineAddHitboxLengthZ - { - get => (bool)Instance.GetType().GetField("LineAddHitboxLengthZ").GetValue(Instance); - set => Instance.GetType().GetField("LineAddHitboxLengthZ").SetValue(Instance, value); - } - public bool LineAddHitboxLengthXA - { - get => (bool)Instance.GetType().GetField("LineAddHitboxLengthXA").GetValue(Instance); - set => Instance.GetType().GetField("LineAddHitboxLengthXA").SetValue(Instance, value); - } - public bool LineAddHitboxLengthYA - { - get => (bool)Instance.GetType().GetField("LineAddHitboxLengthYA").GetValue(Instance); - set => Instance.GetType().GetField("LineAddHitboxLengthYA").SetValue(Instance, value); - } - public bool LineAddHitboxLengthZA - { - get => (bool)Instance.GetType().GetField("LineAddHitboxLengthZA").GetValue(Instance); - set => Instance.GetType().GetField("LineAddHitboxLengthZA").SetValue(Instance, value); - } - public bool LineAddPlayerHitboxLengthX - { - get => (bool)Instance.GetType().GetField("LineAddPlayerHitboxLengthX").GetValue(Instance); - set => Instance.GetType().GetField("LineAddPlayerHitboxLengthX").SetValue(Instance, value); - } - public bool LineAddPlayerHitboxLengthY - { - get => (bool)Instance.GetType().GetField("LineAddPlayerHitboxLengthY").GetValue(Instance); - set => Instance.GetType().GetField("LineAddPlayerHitboxLengthY").SetValue(Instance, value); - } - public bool LineAddPlayerHitboxLengthZ - { - get => (bool)Instance.GetType().GetField("LineAddPlayerHitboxLengthZ").GetValue(Instance); - set => Instance.GetType().GetField("LineAddPlayerHitboxLengthZ").SetValue(Instance, value); - } - public bool LineAddPlayerHitboxLengthXA - { - get => (bool)Instance.GetType().GetField("LineAddPlayerHitboxLengthXA").GetValue(Instance); - set => Instance.GetType().GetField("LineAddPlayerHitboxLengthXA").SetValue(Instance, value); - } - public bool LineAddPlayerHitboxLengthYA - { - get => (bool)Instance.GetType().GetField("LineAddPlayerHitboxLengthYA").GetValue(Instance); - set => Instance.GetType().GetField("LineAddPlayerHitboxLengthYA").SetValue(Instance, value); - } - public bool LineAddPlayerHitboxLengthZA - { - get => (bool)Instance.GetType().GetField("LineAddPlayerHitboxLengthZA").GetValue(Instance); - set => Instance.GetType().GetField("LineAddPlayerHitboxLengthZA").SetValue(Instance, value); - } - public bool Filled - { - get => (bool)Instance.GetType().GetField("Filled").GetValue(Instance); - set => Instance.GetType().GetField("Filled").SetValue(Instance, value); - } - public bool FaceMe - { - get => (bool)Instance.GetType().GetField("FaceMe").GetValue(Instance); - set => Instance.GetType().GetField("FaceMe").SetValue(Instance, value); - } - public bool LimitDistance - { - get => (bool)Instance.GetType().GetField("LimitDistance").GetValue(Instance); - set => Instance.GetType().GetField("LimitDistance").SetValue(Instance, value); - } - public bool LimitDistanceInvert - { - get => (bool)Instance.GetType().GetField("LimitDistanceInvert").GetValue(Instance); - set => Instance.GetType().GetField("LimitDistanceInvert").SetValue(Instance, value); - } - public float DistanceSourceX - { - get => (float)Instance.GetType().GetField("DistanceSourceX").GetValue(Instance); - set => Instance.GetType().GetField("DistanceSourceX").SetValue(Instance, value); - } - public float DistanceSourceY - { - get => (float)Instance.GetType().GetField("DistanceSourceY").GetValue(Instance); - set => Instance.GetType().GetField("DistanceSourceY").SetValue(Instance, value); - } - public float DistanceSourceZ - { - get => (float)Instance.GetType().GetField("DistanceSourceZ").GetValue(Instance); - set => Instance.GetType().GetField("DistanceSourceZ").SetValue(Instance, value); - } - public float DistanceMin - { - get => (float)Instance.GetType().GetField("DistanceMin").GetValue(Instance); - set => Instance.GetType().GetField("DistanceMin").SetValue(Instance, value); - } - public float DistanceMax - { - get => (float)Instance.GetType().GetField("DistanceMax").GetValue(Instance); - set => Instance.GetType().GetField("DistanceMax").SetValue(Instance, value); - } - public string refActorVFXPath - { - get => (string)Instance.GetType().GetField("refActorVFXPath").GetValue(Instance); - set => Instance.GetType().GetField("refActorVFXPath").SetValue(Instance, value); - } - public int refActorVFXMin - { - get => (int)Instance.GetType().GetField("refActorVFXMin").GetValue(Instance); - set => Instance.GetType().GetField("refActorVFXMin").SetValue(Instance, value); - } - public int refActorVFXMax - { - get => (int)Instance.GetType().GetField("refActorVFXMax").GetValue(Instance); - set => Instance.GetType().GetField("refActorVFXMax").SetValue(Instance, value); - } - public bool LimitRotation - { - get => (bool)Instance.GetType().GetField("LimitRotation").GetValue(Instance); - set => Instance.GetType().GetField("LimitRotation").SetValue(Instance, value); - } - public float RotationMax - { - get => (float)Instance.GetType().GetField("RotationMax").GetValue(Instance); - set => Instance.GetType().GetField("RotationMax").SetValue(Instance, value); - } - public float RotationMin - { - get => (float)Instance.GetType().GetField("RotationMin").GetValue(Instance); - set => Instance.GetType().GetField("RotationMin").SetValue(Instance, value); - } - public uint refActorObjectEffectData1 - { - get => (uint)Instance.GetType().GetField("refActorObjectEffectData1").GetValue(Instance); - set => Instance.GetType().GetField("refActorObjectEffectData1").SetValue(Instance, value); - } - public uint refActorObjectEffectData2 - { - get => (uint)Instance.GetType().GetField("refActorObjectEffectData2").GetValue(Instance); - set => Instance.GetType().GetField("refActorObjectEffectData2").SetValue(Instance, value); - } - public int refActorObjectEffectMax - { - get => (int)Instance.GetType().GetField("refActorObjectEffectMax").GetValue(Instance); - set => Instance.GetType().GetField("refActorObjectEffectMax").SetValue(Instance, value); - } - public int refActorObjectEffectMin - { - get => (int)Instance.GetType().GetField("refActorObjectEffectMin").GetValue(Instance); - set => Instance.GetType().GetField("refActorObjectEffectMin").SetValue(Instance, value); - } -} diff --git a/ECommons/ECommons/SplatoonAPI/ElementType.cs b/ECommons/ECommons/SplatoonAPI/ElementType.cs deleted file mode 100644 index 6476bc0..0000000 --- a/ECommons/ECommons/SplatoonAPI/ElementType.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace ECommons.SplatoonAPI; - -/// -/// 0: Object at fixed coordinates | -/// 1: Object relative to actor position | -/// 2: Line between two fixed coordinates | -/// 3: Line relative to object pos | -/// 4: Cone relative to object position | -/// 5: Cone at fixed coordinates -/// -public enum ElementType : int -{ - CircleAtFixedCoordinates=0, - CircleRelativeToActorPosition = 1, - LineBetweenTwoFixedCoordinates=2, - LineRelativeToObjectPosition=3, - ConeRelativeToObjectPosition=4, - ConeAtFixedCoordinates=5 -} diff --git a/ECommons/ECommons/SplatoonAPI/RefActorComparisonType.cs b/ECommons/ECommons/SplatoonAPI/RefActorComparisonType.cs deleted file mode 100644 index 7d21a4b..0000000 --- a/ECommons/ECommons/SplatoonAPI/RefActorComparisonType.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace ECommons.SplatoonAPI; - -/// -/// 0: Name | -/// 1: Model ID | -/// 2: Object ID | -/// 3: Data ID | -/// 4: NPC ID | -/// 5: Placeholder | -/// 6: Name ID | -/// 7: VFX Path -/// -public enum RefActorComparisonType : int -{ - Name=0, - ModelID=1, - ObjectID=2, - DataID=3, - NpcID=4, - Placeholder=5, - NameID=6, - VfxPath=7 -} diff --git a/ECommons/ECommons/SplatoonAPI/RefActorType.cs b/ECommons/ECommons/SplatoonAPI/RefActorType.cs deleted file mode 100644 index c5a8a22..0000000 --- a/ECommons/ECommons/SplatoonAPI/RefActorType.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace ECommons.SplatoonAPI; - -/// 0: Game object with specific name | -/// 1: Self | -/// 2: Targeted enemy -public enum RefActorType -{ - GameObjectWithSpecifiedAttribute=0, - Self=1, - TargetedEnemy=2 -} diff --git a/ECommons/ECommons/SplatoonAPI/Splatoon.cs b/ECommons/ECommons/SplatoonAPI/Splatoon.cs deleted file mode 100644 index 8978b10..0000000 --- a/ECommons/ECommons/SplatoonAPI/Splatoon.cs +++ /dev/null @@ -1,309 +0,0 @@ -using ECommons.Logging; -using Dalamud.Plugin; -using ECommons.DalamudServices; -using ECommons.Reflection; -using System; -using System.Linq; -using System.Reflection; - -namespace ECommons.SplatoonAPI; - -public static class Splatoon -{ - internal static IDalamudPlugin Instance; - internal static int Version; - - internal static Action OnConnect; - - internal static void Init() - { - try - { - if (Svc.PluginInterface.GetIpcSubscriber("Splatoon.IsLoaded").InvokeFunc()) - { - Connect(); - } - } - catch { } - Svc.PluginInterface.GetIpcSubscriber("Splatoon.Loaded").Subscribe(Connect); - Svc.PluginInterface.GetIpcSubscriber("Splatoon.Unloaded").Subscribe(Reset); - } - - /// - /// Executed when connected or reconnected to Splatoon. Create and recreate your elements here. Once this event is fired, all already created elements become invalid. - /// - /// Action to be executed on connect - public static void SetOnConnect(Action action) - { - OnConnect = action; - try - { - if (Svc.PluginInterface.GetIpcSubscriber("Splatoon.IsLoaded").InvokeFunc()) - { - OnConnect(); - } - } - catch { } - } - - internal static void Shutdown() - { - Svc.PluginInterface.GetIpcSubscriber("Splatoon.Loaded").Unsubscribe(Connect); - Svc.PluginInterface.GetIpcSubscriber("Splatoon.Unloaded").Unsubscribe(Reset); - } - - internal static void Reset() - { - Instance = null; - PluginLog.Information("Disconnected from Splatoon"); - } - - static void Connect() - { - try - { - if (DalamudReflector.TryGetDalamudPlugin("Splatoon", out var plugin, false, true) && (bool)plugin.GetType().GetField("Init").GetValue(plugin)) - { - Instance = plugin; - Version++; - OnConnect?.Invoke(); - PluginLog.Information("Successfully connected to Splatoon."); - } - else - { - throw new Exception("Splatoon is not initialized"); - } - } - catch (Exception e) - { - PluginLog.Error("Can't find Splatoon plugin: " + e.Message); - PluginLog.Error(e.StackTrace); - } - } - - /// Whether currently connected to Splatoon - public static bool IsConnected() - { - return Instance != null; - } - - /// - /// Add persistent dynamic element. - /// - /// Non-unique namespace of the element - /// Element or array of elements - /// Destroy condition or array of them where: -2 is destroy on zone change; -1 is destroy on combat end; 0 is never destroy; any other number - system tick at which it should be destroyed, where current system tick can be obtained with Environment.TickCount64 parameter. - /// Whether operation was successful - public static bool AddDynamicElement(string name, Element e, long[] DestroyCondition) - { - return AddDynamicElements(name, new Element[] { e }, DestroyCondition); - } - - /// - /// Add persistent dynamic element. - /// - /// Non-unique namespace of the element - /// Element or array of elements - /// Destroy condition or array of them where: -2 is destroy on zone change; -1 is destroy on combat end; 0 is never destroy; any other number - system tick at which it should be destroyed, where current system tick can be obtained with Environment.TickCount64 parameter. - /// Whether operation was successful - public static bool AddDynamicElement(string name, Element e, long DestroyCondition) - { - return AddDynamicElements(name, new Element[] { e }, new long[] { DestroyCondition }); - } - - /// - /// Add persistent dynamic element. - /// - /// Non-unique namespace of the element - /// Element or array of elements - /// Destroy condition or array of them where: -2 is destroy on zone change; -1 is destroy on combat end; 0 is never destroy; any other number - system tick at which it should be destroyed, where current system tick can be obtained with Environment.TickCount64 parameter. - /// Whether operation was successful - public static bool AddDynamicElements(string name, Element[] e, long DestroyCondition) - { - return AddDynamicElements(name, e, new long[] { DestroyCondition }); - } - - /// - /// Add persistent dynamic element. - /// - /// Non-unique namespace of the element - /// Element or array of elements - /// Destroy condition or array of them where: -2 is destroy on zone change; -1 is destroy on combat end; 0 is never destroy; any other number - amount of seconds before element will be destroyed from the moment of it's addition. - /// Whether operation was successful - public static bool AddDynamicElement(string name, Element e, float[] DestroyCondition) - { - return AddDynamicElements(name, new Element[] { e }, DestroyCondition); - } - - /// - /// Add persistent dynamic element. - /// - /// Non-unique namespace of the element - /// Element or array of elements - /// Destroy condition or array of them where: -2 is destroy on zone change; -1 is destroy on combat end; 0 is never destroy; any other number - amount of seconds before element will be destroyed from the moment of it's addition. - /// Whether operation was successful - public static bool AddDynamicElement(string name, Element e, float DestroyCondition) - { - return AddDynamicElements(name, new Element[] { e }, new float[] { DestroyCondition }); - } - - /// - /// Add persistent dynamic element. - /// - /// Non-unique namespace of the element - /// Element or array of elements - /// Destroy condition or array of them where: -2 is destroy on zone change; -1 is destroy on combat end; 0 is never destroy; any other number - amount of seconds before element will be destroyed from the moment of it's addition. - /// Whether operation was successful - public static bool AddDynamicElements(string name, Element[] e, float DestroyCondition) - { - return AddDynamicElements(name, e, new float[] { DestroyCondition }); - } - - /// - /// Add persistent dynamic element. - /// - /// Non-unique namespace of the element - /// Element or array of elements - /// Destroy condition or array of them where: -2 is destroy on zone change; -1 is destroy on combat end; 0 is never destroy; any other number - amount of seconds before element will be destroyed from the moment of it's addition. - /// Whether operation was successful - public static bool AddDynamicElements(string name, Element[] e, float[] DestroyConditionF) - { - var dCond = DestroyConditionF.Select(x => x > 0 ? ((long)(x * 1000f) + Environment.TickCount64) : (long)x).ToArray(); - return AddDynamicElements(name, e, dCond); - } - - /// - /// Add persistent dynamic element. - /// - /// Non-unique namespace of the element - /// Element or array of elements - /// Destroy condition or array of them where: -2 is destroy on zone change; -1 is destroy on combat end; 0 is never destroy; any other number - system tick at which it should be destroyed, where current system tick can be obtained with Environment.TickCount64 parameter. - /// Whether operation was successful - public static bool AddDynamicElements(string name, Element[] e, long[] DestroyCondition) - { - if (!IsConnected()) - { - PluginLog.Warning("Not connected to Splatoon"); - return false; - } - if (!e.All(x => x.IsValid())) - { - PluginLog.Warning("Elements are no longer valid"); - return false; - } - if (e.Length == 0) - { - PluginLog.Warning("There are no elements"); - return false; - } - try - { - var array = Array.CreateInstance(e[0].Instance.GetType(), e.Length); - for (var i = 0; i < e.Length; i++) - { - array.SetValue(e[i].Instance, i); - } - Instance.GetType().GetMethod("AddDynamicElements").Invoke(Instance, new object[] { name, array, DestroyCondition }); - return true; - } - catch (Exception ex) - { - ex.Log(); - return false; - } - } - - /// - /// Display certain element in next frame only. - /// - /// Element to display - /// Whether operation was successful - public static bool DisplayOnce(Element e) - { - if (!IsConnected()) - { - PluginLog.Warning("Not connected to Splatoon"); - return false; - } - if (!e.IsValid()) - { - PluginLog.Warning("Elements are no longer valid"); - return false; - } - try - { - Instance.GetType().GetMethod("InjectElement").Invoke(Instance, new object[] { e.Instance }); - return true; - } - catch (Exception ex) - { - ex.Log(); - return false; - } - } - - /// - /// Removes dynamic elements with specific name. If more than one element was registered under certain name, all of these elements will be removed. - /// - /// Name of element(s) - /// Whether operation was successful - public static bool RemoveDynamicElements(string name) - { - if (!IsConnected()) - { - PluginLog.Warning("Not connected to Splatoon"); - return false; - } - try - { - Instance.GetType().GetMethod("RemoveDynamicElements").Invoke(Instance, new object[] { name }); - return true; - } - catch (Exception ex) - { - ex.Log(); - return false; - } - } - - /// - /// Attempts to decode element that was encoded into JSON. - /// - /// Input string, you can export it from Splatoon. Make sure element is enabled! - /// Element that is ready for use or null if failed - public static Element DecodeElement(string input) - { - var method = Instance.GetType().Assembly.GetType("Splatoon.SplatoonScripting.ScriptingEngine", true).GetMethod("TryDecodeElement", BindingFlags.Public | BindingFlags.Static); - var parameters = new object[] { input, null }; - var result = (bool)method.Invoke(null, parameters); - if (result) - { - return new Element(parameters[1]); - } - else - { - return null; - } - } - - /// - /// Work in progress on this function - /// - /// - /// - [Obsolete("Work in progress")] - public static object DecodeLayout(string input) - { - var method = Instance.GetType().Assembly.GetType("Splatoon.SplatoonScripting.ScriptingEngine", true).GetMethod("TryDecodeLayout", BindingFlags.Public | BindingFlags.Static); - var parameters = new object[] { input, null }; - var result = (bool)method.Invoke(null, parameters); - if (result) - { - return parameters[1]; - } - else - { - return null; - } - } -} diff --git a/ECommons/ECommons/StringHelpers/EqualStrings.cs b/ECommons/ECommons/StringHelpers/EqualStrings.cs deleted file mode 100644 index 337f575..0000000 --- a/ECommons/ECommons/StringHelpers/EqualStrings.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.StringHelpers -{ - public static class EqualStrings - { - static List> Equalities = new(); - - public static void RegisterEquality(IEnumerable values) - { - Equalities.Add(values.ToHashSet()); - } - - public static void RegisterEquality(params string[] values) => RegisterEquality((IEnumerable)values); - - public static bool Equals(string what, string with, StringComparison comparison = StringComparison.Ordinal) - { - if(what.Equals(with, comparison)) return true; - var equalityList = Equalities.FirstOrDefault(x => x.Any(z => z.Equals(with, comparison))); - if(equalityList != null) - { - return equalityList.Any(x => x.Equals(what, comparison)); - } - else - { - return false; - } - } - public static bool ESEquals(this string what, string with, StringComparison comparison = StringComparison.Ordinal) => Equals(what, with, comparison); - - public static bool EqualsAny(string what, IEnumerable with) - { - foreach(var x in with) - { - if (Equals(what, x)) return true; - } - return false; - } - public static bool EqualsAny(string what, params string[] with) => EqualsAny(what, (IEnumerable)with); - public static bool ESEqualsAny(this string what, IEnumerable with) => EqualsAny(what, with); - public static bool ESEqualsAny(this string what, params string[] with) => EqualsAny(what, (IEnumerable)with); - - - public static bool EqualsAnyIgnoreCase(string what, IEnumerable with) - { - foreach (var x in with) - { - if (Equals(what, x, StringComparison.OrdinalIgnoreCase)) return true; - } - return false; - } - public static bool EqualsAnyIgnoreCase(string what, params string[] with) => EqualsAnyIgnoreCase(what, (IEnumerable)with); - public static bool ESEqualsAnyIgnoreCase(this string what, IEnumerable with) => EqualsAnyIgnoreCase(what, with); - public static bool ESEqualsAnyIgnoreCase(this string what, params string[] with) => EqualsAnyIgnoreCase(what, (IEnumerable)with); - - internal static void Dispose() - { - Equalities = null; - } - } -} diff --git a/ECommons/ECommons/TerritoryName.cs b/ECommons/ECommons/TerritoryName.cs deleted file mode 100644 index 277f0f7..0000000 --- a/ECommons/ECommons/TerritoryName.cs +++ /dev/null @@ -1,41 +0,0 @@ -using ECommons.DalamudServices; -using Lumina.Excel.GeneratedSheets; -using System; -using System.Collections.Generic; - -namespace ECommons; - -public static class TerritoryName -{ - static Dictionary Cache = new(); - - public static string GetTerritoryName(uint id) - { - if(Cache.TryGetValue(id, out var val)) - { - return val; - } - var data = Svc.Data.GetExcelSheet().GetRow(id); - if(data != null) - { - var zoneName = data.PlaceName.Value.Name.ToString(); - if (zoneName != string.Empty) - { - var cfc = data.ContentFinderCondition.Value; - if(cfc != null) - { - var cfcStr = cfc.Name.ToString(); - if (cfcStr != String.Empty) - { - Cache[id] = $"{id} | {zoneName} ({cfcStr})"; - return Cache[id]; - } - } - Cache[id] = $"{id} | {zoneName}"; - return Cache[id]; - } - } - Cache[id] = $"{id}"; - return Cache[id]; - } -} diff --git a/ECommons/ECommons/Throttlers/EzThrottler.cs b/ECommons/ECommons/Throttlers/EzThrottler.cs deleted file mode 100644 index d7f5a9c..0000000 --- a/ECommons/ECommons/Throttlers/EzThrottler.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Dalamud.Interface.Colors; -using ECommons.ImGuiMethods; -using ImGuiNET; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.Throttlers -{ - public static class EzThrottler - { - internal static EzThrottler Throttler = new(); - - public static IReadOnlyCollection ThrottleNames => Throttler.ThrottleNames; - - public static bool Throttle(string name, int miliseconds = 500, bool rethrottle = false) => Throttler.Throttle(name, miliseconds, rethrottle); - - public static bool Check(string name) => Throttler.Check(name); - - public static long GetRemainingTime(string name, bool allowNegative = false) => Throttler.GetRemainingTime(name, allowNegative); - - public static void ImGuiPrintDebugInfo() => Throttler.ImGuiPrintDebugInfo(); - } -} diff --git a/ECommons/ECommons/Throttlers/EzThrottler{T}.cs b/ECommons/ECommons/Throttlers/EzThrottler{T}.cs deleted file mode 100644 index d34dcb2..0000000 --- a/ECommons/ECommons/Throttlers/EzThrottler{T}.cs +++ /dev/null @@ -1,62 +0,0 @@ -using Dalamud.Interface.Colors; -using ECommons.ImGuiMethods; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.Throttlers -{ - public class EzThrottler - { - Dictionary throttlers = new(); - public IReadOnlyCollection ThrottleNames => throttlers.Keys; - public bool Throttle(T name, int miliseconds = 500, bool rethrottle = false) - { - if (!throttlers.ContainsKey(name)) - { - throttlers[name] = Environment.TickCount64 + miliseconds; - return true; - } - if (Environment.TickCount64 > throttlers[name]) - { - throttlers[name] = Environment.TickCount64 + miliseconds; - return true; - } - else - { - if (rethrottle) throttlers[name] = Environment.TickCount64 + miliseconds; - return false; - } - } - - public bool Check(T name) - { - if (!throttlers.ContainsKey(name)) return true; - return Environment.TickCount64 > throttlers[name]; - } - - public long GetRemainingTime(T name, bool allowNegative = false) - { - if (!throttlers.ContainsKey(name)) return allowNegative ? -Environment.TickCount64 : 0; - var ret = throttlers[name] - Environment.TickCount64; - if (allowNegative) - { - return ret; - } - else - { - return ret > 0 ? ret : 0; - } - } - - public void ImGuiPrintDebugInfo() - { - foreach (var x in throttlers) - { - ImGuiEx.Text(Check(x.Key) ? ImGuiColors.HealerGreen : ImGuiColors.DalamudRed, $"{x.Key}: [{GetRemainingTime(x.Key)}ms remains] ({x.Value})"); - } - } - } -} diff --git a/ECommons/ECommons/Throttlers/FrameThrottler.cs b/ECommons/ECommons/Throttlers/FrameThrottler.cs deleted file mode 100644 index bf3a6a1..0000000 --- a/ECommons/ECommons/Throttlers/FrameThrottler.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Dalamud.Interface.Colors; -using ECommons.DalamudServices; -using ECommons.ImGuiMethods; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.Throttlers -{ - public static class FrameThrottler - { - internal static FrameThrottler Throttler = new(); - - public static IReadOnlyCollection ThrottleNames => Throttler.ThrottleNames; - - public static bool Throttle(string name, int frames = 60, bool rethrottle = false) => Throttler.Throttle(name, frames, rethrottle); - - public static bool Check(string name) => Throttler.Check(name); - - public static long GetRemainingTime(string name, bool allowNegative = false) => Throttler.GetRemainingTime(name, allowNegative); - - public static void ImGuiPrintDebugInfo() => Throttler.ImGuiPrintDebugInfo(); - } -} diff --git a/ECommons/ECommons/Throttlers/FrameThrottler{T}.cs b/ECommons/ECommons/Throttlers/FrameThrottler{T}.cs deleted file mode 100644 index 093b9f5..0000000 --- a/ECommons/ECommons/Throttlers/FrameThrottler{T}.cs +++ /dev/null @@ -1,66 +0,0 @@ -using Dalamud.Interface.Colors; -using ECommons.DalamudServices; -using ECommons.ImGuiMethods; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.Throttlers -{ - public class FrameThrottler - { - Dictionary throttlers = new(); - long SFrameCount => (long)Svc.PluginInterface.UiBuilder.FrameCount; - - public IReadOnlyCollection ThrottleNames => throttlers.Keys; - - public bool Throttle(T name, int frames = 60, bool rethrottle = false) - { - if (!throttlers.ContainsKey(name)) - { - throttlers[name] = SFrameCount + frames; - return true; - } - if (SFrameCount > throttlers[name]) - { - throttlers[name] = SFrameCount + frames; - return true; - } - else - { - if (rethrottle) throttlers[name] = SFrameCount + frames; - return false; - } - } - - public bool Check(T name) - { - if (!throttlers.ContainsKey(name)) return true; - return SFrameCount > throttlers[name]; - } - - public long GetRemainingTime(T name, bool allowNegative = false) - { - if (!throttlers.ContainsKey(name)) return allowNegative ? -SFrameCount : 0; - var ret = throttlers[name] - SFrameCount; - if (allowNegative) - { - return ret; - } - else - { - return ret > 0 ? ret : 0; - } - } - - public void ImGuiPrintDebugInfo() - { - foreach (var x in throttlers) - { - ImGuiEx.Text(Check(x.Key) ? ImGuiColors.HealerGreen : ImGuiColors.DalamudRed, $"{x.Key}: [{GetRemainingTime(x.Key)} frames remains] ({x.Value})"); - } - } - } -} diff --git a/ECommons/ECommons/UIHelpers/AtkReader.cs b/ECommons/ECommons/UIHelpers/AtkReader.cs deleted file mode 100644 index dac266c..0000000 --- a/ECommons/ECommons/UIHelpers/AtkReader.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using Dalamud.Game.Text.SeStringHandling; -using Dalamud.Memory; -using FFXIVClientStructs.FFXIV.Component.GUI; -using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType; - -namespace ECommons.UIHelpers -{ - public unsafe abstract class AtkReader(AtkUnitBase* UnitBase, int BeginOffset = 0) - { - public List Loop(int Offset, int Size, int MaxLength) where T:AtkReader - { - var ret = new List(); - for (int i = 0; i < MaxLength; i++) - { - var r = (AtkReader)Activator.CreateInstance(typeof(T), new object[] { (nint)UnitBase, Offset + i * Size }); - if (r.IsNull) break; - ret.Add((T)r); - } - return ret; - } - - public AtkReader(nint UnitBasePtr, int BeginOffset = 0) : this((AtkUnitBase*)UnitBasePtr, BeginOffset) { } - - public bool IsNull - { - get - { - if (UnitBase->AtkValuesCount == 0) return true; - var num = 0 + BeginOffset; - EnsureCount(UnitBase, num); - if (UnitBase->AtkValues[num].Type == 0) return true; - return false; - } - } - protected uint? ReadUInt(int n) - { - var num = n + BeginOffset; - EnsureCount(UnitBase, num); - var value = UnitBase->AtkValues[num]; - if (value.Type == 0) - { - return null; - } - if (value.Type != ValueType.UInt) throw new InvalidCastException($"Value {num} from Addon {MemoryHelper.ReadStringNullTerminated((nint)UnitBase->Name)} was requested as uint but it was {value.Type}"); - return value.UInt; - } - - protected int? ReadInt(int n) - { - var num = n + BeginOffset; - EnsureCount(UnitBase, num); - var value = UnitBase->AtkValues[num]; - if (value.Type == 0) - { - return null; - } - if (value.Type != ValueType.Int) throw new InvalidCastException($"Value {num} from Addon {MemoryHelper.ReadStringNullTerminated((nint)UnitBase->Name)} was requested as int but it was {value.Type}"); - return value.Int; - } - - protected bool? ReadBool(int n) - { - var num = n + BeginOffset; - EnsureCount(UnitBase, num); - var value = UnitBase->AtkValues[num]; - if (value.Type == 0) - { - return null; - } - if (value.Type != ValueType.Bool) throw new InvalidCastException($"Value {num} from Addon {MemoryHelper.ReadStringNullTerminated((nint)UnitBase->Name)} was requested as bool but it was {value.Type}"); - return value.Byte != 0; - } - - protected SeString? ReadSeString(int n) - { - var num = n + BeginOffset; - EnsureCount(UnitBase, num); - var value = UnitBase->AtkValues[num]; - if (value.Type == 0) - { - return null; - } - if (!value.Type.EqualsAny(ValueType.String, ValueType.AllocatedString)) throw new InvalidCastException($"Value {num} from Addon {MemoryHelper.ReadStringNullTerminated((nint)UnitBase->Name)} was requested as SeString but it was {value.Type}"); - return MemoryHelper.ReadSeStringNullTerminated((nint)value.String); - } - - - protected string? ReadString(int n) - { - var num = n + BeginOffset; - EnsureCount(UnitBase, num); - var value = UnitBase->AtkValues[num]; - if (value.Type == 0) - { - return null; - } - if (!value.Type.EqualsAny(ValueType.String, ValueType.AllocatedString)) throw new InvalidCastException($"Value {num} from Addon {MemoryHelper.ReadStringNullTerminated((nint)UnitBase->Name)} was requested as String but it was {value.Type}"); - return MemoryHelper.ReadStringNullTerminated((nint)value.String); - } - - void EnsureCount(AtkUnitBase* Addon, int num) - { - if (num >= Addon->AtkValuesCount) throw new ArgumentOutOfRangeException(nameof(num)); - } - } -} diff --git a/ECommons/ECommons/UIHelpers/Implementations/ReaderRetainerList.cs b/ECommons/ECommons/UIHelpers/Implementations/ReaderRetainerList.cs deleted file mode 100644 index 7be7857..0000000 --- a/ECommons/ECommons/UIHelpers/Implementations/ReaderRetainerList.cs +++ /dev/null @@ -1,24 +0,0 @@ -using FFXIVClientStructs.FFXIV.Component.GUI; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.UIHelpers.Implementations -{ - public unsafe class ReaderRetainerList(AtkUnitBase* Addon) : AtkReader(Addon) - { - public uint VentureCount => this.ReadUInt(2) ?? 0; - public List Retainers => this.Loop(3, 9, 10); - - public unsafe class Retainer(nint Addon, int start) : AtkReader(Addon, start) - { - public string Name => ReadString(0); - public uint Level => ReadUInt(2) ?? 0; - public uint Inventory => ReadUInt(3) ?? 0; - public uint Gil => ReadUInt(4) ?? 0; - public bool IsActive => ReadBool(8) ?? false; - } - } -} diff --git a/ECommons/ECommons/UIHelpers/Implementations/ReaderSelectString.cs b/ECommons/ECommons/UIHelpers/Implementations/ReaderSelectString.cs deleted file mode 100644 index a97c688..0000000 --- a/ECommons/ECommons/UIHelpers/Implementations/ReaderSelectString.cs +++ /dev/null @@ -1,21 +0,0 @@ -using FFXIVClientStructs.FFXIV.Component.GUI; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ECommons.UIHelpers.Implementations -{ - public unsafe class ReaderSelectString(AtkUnitBase* a) : AtkReader(a) - { - public string Description => ReadString(2); - public int NumEntries => ReadInt(3) ?? 0; - public List Entries => Loop(7, 1, NumEntries); - - public unsafe class Entry(nint a, int s) : AtkReader(a, s) - { - public string Text => ReadString(0); - } - } -} diff --git a/ECommons/ECommons/packages.lock.json b/ECommons/ECommons/packages.lock.json deleted file mode 100644 index 4ead528..0000000 --- a/ECommons/ECommons/packages.lock.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": 1, - "dependencies": { - "net7.0-windows7.0": {} - } -} \ No newline at end of file diff --git a/ECommons/LICENSE.md b/ECommons/LICENSE.md deleted file mode 100644 index 0ad25db..0000000 --- a/ECommons/LICENSE.md +++ /dev/null @@ -1,661 +0,0 @@ - GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -our General Public Licenses are intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - - A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - - The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - - An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU Affero General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Remote Network Interaction; Use with the GNU General Public License. - - Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your version -supports such interaction) an opportunity to receive the Corresponding -Source of your version by providing access to the Corresponding Source -from a network server at no charge, through some standard or customary -means of facilitating copying of software. This Corresponding Source -shall include the Corresponding Source for any work covered by version 3 -of the GNU General Public License that is incorporated pursuant to the -following paragraph. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the work with which it is combined will remain governed by version -3 of the GNU General Public License. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU Affero General Public License from time to time. Such new versions -will be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU Affero General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU Affero General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU Affero General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a "Source" link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for the -specific requirements. - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU AGPL, see -. diff --git a/ECommons/README.md b/ECommons/README.md deleted file mode 100644 index 91d7b70..0000000 --- a/ECommons/README.md +++ /dev/null @@ -1,45 +0,0 @@ -
-

About ECommons

-

ECommons is a multi-functional library designed to work within Dalamud Plugins. It features a variety of different systems and shortcuts which cuts out a lot of boiler plate code normally used to do standard plugin tasks.

-
- -
-

Getting Started

-Add ECommons as a submodule to your project: - -``` -git submodule add https://github.com/NightmareXIV/ECommons.git -``` -Add it to your plugin's CSProj file: - -``` - - - -``` - -Then, in the entry point of your plugin: - -``` -ECommonsMain.Init(pluginInterface, this); -``` - -where pluginInterface is a DalamudPluginInterface. -
- -
-

Using Modules

-ECommons comes with various modules which needs to be initalised at plugin runtime. To do so, modify your initalising code as follows: - -``` -ECommonsMain.Init(pluginInterface, this, Modules.); -``` - -where \ is one of the following: -- All (For all modules) -- Localization -- SplatoonAPI -- DalamudReflector -- ObjectLife -- ObjectFunctions -