Character Switch
This commit is contained in:
commit
5bbc75f527
340
.gitignore
vendored
Normal file
340
.gitignore
vendored
Normal file
@ -0,0 +1,340 @@
|
|||||||
|
## 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
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# 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/
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# JustCode is a .NET coding add-in
|
||||||
|
.JustCode
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# 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
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
*- Backup*.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/
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
.idea/
|
||||||
|
*.sln.iml
|
||||||
|
|
||||||
|
# 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
|
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[submodule "AutoRetainerAPI"]
|
||||||
|
path = AutoRetainerAPI
|
||||||
|
url = https://github.com/PunishXIV/AutoRetainerAPI.git
|
||||||
|
[submodule "ECommons"]
|
||||||
|
path = ECommons
|
||||||
|
url = https://github.com/NightmareXIV/ECommons.git
|
1
AutoRetainerAPI
Submodule
1
AutoRetainerAPI
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 6f0aaa55bce6ec79fd4d72f84f21597b39e5445d
|
1
ECommons
Submodule
1
ECommons
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit f11764e4654148c5d891273053ec02649a5ee9c5
|
28
KitchenSink.sln
Normal file
28
KitchenSink.sln
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KitchenSink", "KitchenSink\KitchenSink.csproj", "{22877AC5-8397-44ED-950C-C4D4BBD8B4CB}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ECommons", "ECommons\ECommons\ECommons.csproj", "{006EBE8E-F14D-48D2-B7E0-C0E4D41BD15E}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoRetainerAPI", "AutoRetainerAPI\AutoRetainerAPI\AutoRetainerAPI.csproj", "{FD2D72FE-F7AE-43AF-8453-66A830AA38D7}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{22877AC5-8397-44ED-950C-C4D4BBD8B4CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{22877AC5-8397-44ED-950C-C4D4BBD8B4CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{22877AC5-8397-44ED-950C-C4D4BBD8B4CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{22877AC5-8397-44ED-950C-C4D4BBD8B4CB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{006EBE8E-F14D-48D2-B7E0-C0E4D41BD15E}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||||
|
{006EBE8E-F14D-48D2-B7E0-C0E4D41BD15E}.Debug|Any CPU.Build.0 = Debug|x64
|
||||||
|
{006EBE8E-F14D-48D2-B7E0-C0E4D41BD15E}.Release|Any CPU.ActiveCfg = Release|x64
|
||||||
|
{006EBE8E-F14D-48D2-B7E0-C0E4D41BD15E}.Release|Any CPU.Build.0 = Release|x64
|
||||||
|
{FD2D72FE-F7AE-43AF-8453-66A830AA38D7}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||||
|
{FD2D72FE-F7AE-43AF-8453-66A830AA38D7}.Debug|Any CPU.Build.0 = Debug|x64
|
||||||
|
{FD2D72FE-F7AE-43AF-8453-66A830AA38D7}.Release|Any CPU.ActiveCfg = Release|x64
|
||||||
|
{FD2D72FE-F7AE-43AF-8453-66A830AA38D7}.Release|Any CPU.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
1017
KitchenSink/.editorconfig
Normal file
1017
KitchenSink/.editorconfig
Normal file
File diff suppressed because it is too large
Load Diff
1
KitchenSink/.gitignore
vendored
Normal file
1
KitchenSink/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/dist
|
202
KitchenSink/Commands/CharacterSwitch.cs
Normal file
202
KitchenSink/Commands/CharacterSwitch.cs
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
using AutoRetainerAPI;
|
||||||
|
using AutoRetainerAPI.Configuration;
|
||||||
|
using Dalamud.Game.ClientState.Conditions;
|
||||||
|
using Dalamud.Game.Command;
|
||||||
|
using Dalamud.Game.Gui.Dtr;
|
||||||
|
using Dalamud.Game.Text;
|
||||||
|
using Dalamud.Interface.ImGuiNotification;
|
||||||
|
using Dalamud.Interface.Internal.Notifications;
|
||||||
|
using Dalamud.Plugin.Services;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||||
|
|
||||||
|
namespace KitchenSink.Commands;
|
||||||
|
|
||||||
|
internal sealed class CharacterSwitch : IDisposable
|
||||||
|
{
|
||||||
|
private const string DtrBarTitle = "Character Index";
|
||||||
|
|
||||||
|
private readonly AutoRetainerApi _autoRetainerApi;
|
||||||
|
private readonly ICommandManager _commandManager;
|
||||||
|
private readonly IClientState _clientState;
|
||||||
|
private readonly IChatGui _chatGui;
|
||||||
|
private readonly INotificationManager _notificationManager;
|
||||||
|
private readonly ICondition _condition;
|
||||||
|
private readonly IPluginLog _pluginLog;
|
||||||
|
private readonly DtrBarEntry _dtrBarEntry;
|
||||||
|
|
||||||
|
public CharacterSwitch(AutoRetainerApi autoRetainerApi, ICommandManager commandManager, IClientState clientState,
|
||||||
|
IChatGui chatGui, INotificationManager notificationManager, IDtrBar dtrBar, ICondition condition,
|
||||||
|
IPluginLog pluginLog)
|
||||||
|
{
|
||||||
|
_autoRetainerApi = autoRetainerApi;
|
||||||
|
_commandManager = commandManager;
|
||||||
|
_clientState = clientState;
|
||||||
|
_chatGui = chatGui;
|
||||||
|
_notificationManager = notificationManager;
|
||||||
|
_condition = condition;
|
||||||
|
_pluginLog = pluginLog;
|
||||||
|
|
||||||
|
_commandManager.AddHandler("/k+",
|
||||||
|
new CommandInfo(NextCharacter) { HelpMessage = "Switch to the next AR-enabled character." });
|
||||||
|
_commandManager.AddHandler("/k-",
|
||||||
|
new CommandInfo(PreviousCharacter) { HelpMessage = "Switch to the previous AR-enabled character." });
|
||||||
|
_commandManager.AddHandler("/ks",
|
||||||
|
new CommandInfo(PickCharacter)
|
||||||
|
{
|
||||||
|
HelpMessage =
|
||||||
|
$"Switch to a specific character,{Environment.NewLine}\t/ks [partial character name] - switch to the first character with a matching name.{Environment.NewLine}\t/ks [world name] [index] - switch to the Nth character on the specified world."
|
||||||
|
});
|
||||||
|
|
||||||
|
_dtrBarEntry = dtrBar.Get(DtrBarTitle, "Unknown Character Index");
|
||||||
|
_dtrBarEntry.OnClick = () =>
|
||||||
|
{
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
UIInputData* uiInputData = UIInputData.Instance();
|
||||||
|
MouseButtonFlags mouseButtonFlags =
|
||||||
|
uiInputData != null ? uiInputData->MouseButtonReleasedFlags : MouseButtonFlags.LBUTTON;
|
||||||
|
var target = FindCharacter(mouseButtonFlags.HasFlag(MouseButtonFlags.RBUTTON) ? -1 : 1);
|
||||||
|
SwitchCharacter(target);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
_clientState.Login += UpdateDtrBar;
|
||||||
|
if (_clientState.IsLoggedIn)
|
||||||
|
UpdateDtrBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Target? FindCharacter(int direction)
|
||||||
|
{
|
||||||
|
_pluginLog.Verbose($"Switching characters ({direction})");
|
||||||
|
|
||||||
|
var characterIds = _autoRetainerApi.GetRegisteredCharacters();
|
||||||
|
int index = characterIds.IndexOf(_clientState.LocalContentId);
|
||||||
|
if (index < 0)
|
||||||
|
{
|
||||||
|
_chatGui.PrintError("[KitchenSink] Current character not known.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
OfflineCharacterData? target;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
index = (index + direction + characterIds.Count) % characterIds.Count;
|
||||||
|
target = _autoRetainerApi.GetOfflineCharacterData(characterIds[index]);
|
||||||
|
if (target?.CID == _clientState.LocalContentId)
|
||||||
|
{
|
||||||
|
_chatGui.PrintError("[KitchenSink] No character to switch to found.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target is { ExcludeRetainer: true, ExcludeWorkshop: true })
|
||||||
|
target = null;
|
||||||
|
} while (target == null);
|
||||||
|
|
||||||
|
return new Target(target.Name, target.World);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NextCharacter(string command, string arguments) => SwitchCharacter(FindCharacter(1));
|
||||||
|
|
||||||
|
private void PreviousCharacter(string command, string arguments) => SwitchCharacter(FindCharacter(-1));
|
||||||
|
|
||||||
|
private void PickCharacter(string command, string arguments)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(arguments))
|
||||||
|
{
|
||||||
|
_chatGui.PrintError("[KitchenSink] Usage: /ks <world/name> [index]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] args = arguments.Split(' ', 2);
|
||||||
|
if (args.Length < 2 || !int.TryParse(args[1], CultureInfo.InvariantCulture, out int index))
|
||||||
|
index = 1;
|
||||||
|
|
||||||
|
var targets = _autoRetainerApi.GetRegisteredCharacters()
|
||||||
|
.Select(characterId => _autoRetainerApi.GetOfflineCharacterData(characterId))
|
||||||
|
.Where(x => !x.ExcludeRetainer || !x.ExcludeWorkshop)
|
||||||
|
.Select(x => new { x.Name, x.World })
|
||||||
|
.ToList();
|
||||||
|
var target = targets.Where(x => x.World.StartsWith(args[0], StringComparison.OrdinalIgnoreCase)).Skip(index - 1)
|
||||||
|
.FirstOrDefault() ??
|
||||||
|
targets.FirstOrDefault(x => x.Name.Contains(arguments, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
if (target == null)
|
||||||
|
{
|
||||||
|
_chatGui.PrintError($"[KitchenSink] No character found on world {args[0]} with #{index}.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SwitchCharacter(new Target(target.Name, target.World));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SwitchCharacter(Target? target)
|
||||||
|
{
|
||||||
|
if (target == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_condition[ConditionFlag.BoundByDuty] || _condition[ConditionFlag.BoundByDuty56] ||
|
||||||
|
_condition[ConditionFlag.BoundByDuty95] || _condition[ConditionFlag.InDutyQueue] ||
|
||||||
|
_condition[ConditionFlag.Occupied] || _condition[ConditionFlag.Occupied30] ||
|
||||||
|
_condition[ConditionFlag.Occupied33] || _condition[ConditionFlag.Occupied38] ||
|
||||||
|
_condition[ConditionFlag.Occupied39] || _condition[ConditionFlag.OccupiedInEvent] ||
|
||||||
|
_condition[ConditionFlag.OccupiedSummoningBell] || _condition[ConditionFlag.OccupiedInQuestEvent] ||
|
||||||
|
_condition[ConditionFlag.OccupiedInCutSceneEvent] || _condition[ConditionFlag.WatchingCutscene] ||
|
||||||
|
_condition[ConditionFlag.WatchingCutscene78] || _condition[ConditionFlag.InCombat])
|
||||||
|
{
|
||||||
|
_notificationManager.AddNotification(new Notification
|
||||||
|
{
|
||||||
|
Title = "KitchenSink",
|
||||||
|
Content = "Can't switch characters (bound by duty or occupied)",
|
||||||
|
Type = NotificationType.Error
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_notificationManager.AddNotification(new Notification
|
||||||
|
{
|
||||||
|
Title = "KitchenSink",
|
||||||
|
Content = $"Switch to {target}.",
|
||||||
|
Type = NotificationType.Success,
|
||||||
|
});
|
||||||
|
_commandManager.ProcessCommand($"/ays relog {target}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateDtrBar()
|
||||||
|
{
|
||||||
|
string? currentWorld = _clientState.LocalPlayer?.CurrentWorld.GameData?.Name?.ToString();
|
||||||
|
var characterIds = _autoRetainerApi.GetRegisteredCharacters() ?? new();
|
||||||
|
var characterIdsOnCurrentWorld = characterIds
|
||||||
|
.Where(x => _autoRetainerApi.GetOfflineCharacterData(x)?.World == currentWorld).ToList();
|
||||||
|
|
||||||
|
SeIconChar seIconChar = SeIconChar.Instance1 + characterIdsOnCurrentWorld.IndexOf(_clientState.LocalContentId);
|
||||||
|
_dtrBarEntry.Text = seIconChar.ToIconString();
|
||||||
|
|
||||||
|
var previous = FindCharacter(-1);
|
||||||
|
var next = FindCharacter(1);
|
||||||
|
if (previous != null && next != null)
|
||||||
|
_dtrBarEntry.Tooltip = $"Prev: {previous.Name}\nNext: {next.Name}";
|
||||||
|
else if (previous != null)
|
||||||
|
_dtrBarEntry.Tooltip = $"Prev: {previous.Name}";
|
||||||
|
else if (next != null)
|
||||||
|
_dtrBarEntry.Tooltip = $"Next: {next.Name}";
|
||||||
|
else
|
||||||
|
_dtrBarEntry.Tooltip = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_clientState.Login -= UpdateDtrBar;
|
||||||
|
_dtrBarEntry.Dispose();
|
||||||
|
_commandManager.RemoveHandler("/ks");
|
||||||
|
_commandManager.RemoveHandler("/k-");
|
||||||
|
_commandManager.RemoveHandler("/k+");
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed record Target(string Name, string World)
|
||||||
|
{
|
||||||
|
public override string ToString() => $"{Name}@{World}";
|
||||||
|
}
|
||||||
|
}
|
21
KitchenSink/DalamudPackager.targets
Normal file
21
KitchenSink/DalamudPackager.targets
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project>
|
||||||
|
<Target Name="PackagePlugin" AfterTargets="Build" Condition="'$(Configuration)' == 'Debug'">
|
||||||
|
<DalamudPackager
|
||||||
|
ProjectDir="$(ProjectDir)"
|
||||||
|
OutputPath="$(OutputPath)"
|
||||||
|
AssemblyName="$(AssemblyName)"
|
||||||
|
MakeZip="false"
|
||||||
|
VersionComponents="2"/>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="PackagePlugin" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'">
|
||||||
|
<DalamudPackager
|
||||||
|
ProjectDir="$(ProjectDir)"
|
||||||
|
OutputPath="$(OutputPath)"
|
||||||
|
AssemblyName="$(AssemblyName)"
|
||||||
|
MakeZip="true"
|
||||||
|
VersionComponents="2"
|
||||||
|
Exclude="AutoRetainerAPI.pdb;ECommons.xml;ECommons.pdb;KitchenSink.deps.json;LLib.pdb"/>
|
||||||
|
</Target>
|
||||||
|
</Project>
|
64
KitchenSink/KitchenSink.csproj
Normal file
64
KitchenSink/KitchenSink.csproj
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<Version>0.1</Version>
|
||||||
|
<LangVersion>12</LangVersion>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
|
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||||
|
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||||
|
<OutputPath>dist</OutputPath>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<PathMap Condition="$(SolutionDir) != ''">$(SolutionDir)=X:\</PathMap>
|
||||||
|
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||||
|
<DebugType>portable</DebugType>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">
|
||||||
|
<DalamudLibPath>$(DALAMUD_HOME)/</DalamudLibPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="DalamudPackager" Version="2.1.12"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Dalamud">
|
||||||
|
<HintPath>$(DalamudLibPath)Dalamud.dll</HintPath>
|
||||||
|
<Private>false</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="ImGui.NET">
|
||||||
|
<HintPath>$(DalamudLibPath)ImGui.NET.dll</HintPath>
|
||||||
|
<Private>false</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Lumina">
|
||||||
|
<HintPath>$(DalamudLibPath)Lumina.dll</HintPath>
|
||||||
|
<Private>false</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Lumina.Excel">
|
||||||
|
<HintPath>$(DalamudLibPath)Lumina.Excel.dll</HintPath>
|
||||||
|
<Private>false</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json">
|
||||||
|
<HintPath>$(DalamudLibPath)Newtonsoft.Json.dll</HintPath>
|
||||||
|
<Private>false</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="FFXIVClientStructs">
|
||||||
|
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
|
||||||
|
<Private>false</Private>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\AutoRetainerAPI\AutoRetainerAPI\AutoRetainerAPI.csproj"/>
|
||||||
|
<ProjectReference Include="..\ECommons\ECommons\ECommons.csproj"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="RenameLatestZip" AfterTargets="PackagePlugin">
|
||||||
|
<Exec Command="rename $(OutDir)$(AssemblyName)\latest.zip $(AssemblyName)-$(Version).zip"/>
|
||||||
|
</Target>
|
||||||
|
</Project>
|
8
KitchenSink/KitchenSink.json
Normal file
8
KitchenSink/KitchenSink.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Name": "KitchenSink",
|
||||||
|
"Author": "Liza Carvelli",
|
||||||
|
"Punchline": "A plugin for things that aren't worth their own plugins.",
|
||||||
|
"Description": "A plugin for things that aren't worth their own plugins; see commands for details.",
|
||||||
|
"Tags": ["character switch"],
|
||||||
|
"IconUrl": "https://plugins.carvel.li/icons/KitchenSink.png"
|
||||||
|
}
|
33
KitchenSink/KitchenSinkPlugin.cs
Normal file
33
KitchenSink/KitchenSinkPlugin.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using AutoRetainerAPI;
|
||||||
|
using Dalamud.Plugin;
|
||||||
|
using Dalamud.Plugin.Services;
|
||||||
|
using ECommons;
|
||||||
|
using KitchenSink.Commands;
|
||||||
|
|
||||||
|
namespace KitchenSink;
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "UnusedType.Global")]
|
||||||
|
[SuppressMessage("Performance", "CA1812")]
|
||||||
|
internal sealed class KitchenSinkPlugin : IDalamudPlugin
|
||||||
|
{
|
||||||
|
private readonly AutoRetainerApi _autoRetainerApi;
|
||||||
|
private readonly CharacterSwitch _characterSwitch;
|
||||||
|
|
||||||
|
public KitchenSinkPlugin(DalamudPluginInterface pluginInterface, ICommandManager commandManager,
|
||||||
|
IClientState clientState, IChatGui chatGui, INotificationManager notificationManager, IDtrBar dtrBar,
|
||||||
|
ICondition condition, IPluginLog pluginLog)
|
||||||
|
{
|
||||||
|
ECommonsMain.Init(pluginInterface, this);
|
||||||
|
_autoRetainerApi = new AutoRetainerApi();
|
||||||
|
_characterSwitch = new CharacterSwitch(_autoRetainerApi, commandManager, clientState, chatGui,
|
||||||
|
notificationManager, dtrBar, condition, pluginLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_characterSwitch.Dispose();
|
||||||
|
_autoRetainerApi.Dispose();
|
||||||
|
ECommonsMain.Dispose();
|
||||||
|
}
|
||||||
|
}
|
22
KitchenSink/packages.lock.json
Normal file
22
KitchenSink/packages.lock.json
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"dependencies": {
|
||||||
|
"net8.0-windows7.0": {
|
||||||
|
"DalamudPackager": {
|
||||||
|
"type": "Direct",
|
||||||
|
"requested": "[2.1.12, )",
|
||||||
|
"resolved": "2.1.12",
|
||||||
|
"contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
|
||||||
|
},
|
||||||
|
"autoretainerapi": {
|
||||||
|
"type": "Project",
|
||||||
|
"dependencies": {
|
||||||
|
"ECommons": "[2.2.0.1, )"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ecommons": {
|
||||||
|
"type": "Project"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user