Handle/fix DTR bar when not on homeworld
This commit is contained in:
parent
5bbc75f527
commit
ccfb53df2e
@ -54,6 +54,10 @@ internal sealed class CharacterSwitch : IDisposable
|
||||
_dtrBarEntry.OnClick = () =>
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
uint? homeWorldId = _clientState.LocalPlayer?.HomeWorld.Id;
|
||||
uint? currentWorldId = _clientState.LocalPlayer?.CurrentWorld.Id;
|
||||
if (homeWorldId == currentWorldId)
|
||||
{
|
||||
UIInputData* uiInputData = UIInputData.Instance();
|
||||
MouseButtonFlags mouseButtonFlags =
|
||||
@ -61,6 +65,9 @@ internal sealed class CharacterSwitch : IDisposable
|
||||
var target = FindCharacter(mouseButtonFlags.HasFlag(MouseButtonFlags.RBUTTON) ? -1 : 1);
|
||||
SwitchCharacter(target);
|
||||
}
|
||||
else
|
||||
_commandManager.ProcessCommand("/li");
|
||||
}
|
||||
};
|
||||
|
||||
_clientState.Login += UpdateDtrBar;
|
||||
@ -167,11 +174,14 @@ internal sealed class CharacterSwitch : IDisposable
|
||||
private void UpdateDtrBar()
|
||||
{
|
||||
string? currentWorld = _clientState.LocalPlayer?.CurrentWorld.GameData?.Name?.ToString();
|
||||
string? homeWorld = _clientState.LocalPlayer?.HomeWorld.GameData?.Name?.ToString();
|
||||
var characterIds = _autoRetainerApi.GetRegisteredCharacters() ?? new();
|
||||
var characterIdsOnCurrentWorld = characterIds
|
||||
.Where(x => _autoRetainerApi.GetOfflineCharacterData(x)?.World == currentWorld).ToList();
|
||||
var characterIdsOnHomeWorld = characterIds
|
||||
.Where(x => _autoRetainerApi.GetOfflineCharacterData(x)?.World == homeWorld).ToList();
|
||||
|
||||
SeIconChar seIconChar = SeIconChar.Instance1 + characterIdsOnCurrentWorld.IndexOf(_clientState.LocalContentId);
|
||||
SeIconChar seIconChar = SeIconChar.Instance1 + characterIdsOnHomeWorld.IndexOf(_clientState.LocalContentId);
|
||||
if (currentWorld == homeWorld)
|
||||
{
|
||||
_dtrBarEntry.Text = seIconChar.ToIconString();
|
||||
|
||||
var previous = FindCharacter(-1);
|
||||
@ -185,6 +195,12 @@ internal sealed class CharacterSwitch : IDisposable
|
||||
else
|
||||
_dtrBarEntry.Tooltip = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_dtrBarEntry.Text = $"{homeWorld} {seIconChar.ToIconString()}";
|
||||
_dtrBarEntry.Tooltip = $"Return to {homeWorld}";
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Version>0.1</Version>
|
||||
<Version>0.2</Version>
|
||||
<LangVersion>12</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
|
@ -4,5 +4,6 @@
|
||||
"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"],
|
||||
"RepoUrl": "https://git.carvel.li/liza/KitchenSink",
|
||||
"IconUrl": "https://plugins.carvel.li/icons/KitchenSink.png"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user