Fix linkshell rotation

This commit is contained in:
Infi
2024-06-17 19:21:17 +02:00
parent 625d7596d3
commit 7a27ca8ea8
4 changed files with 15 additions and 21 deletions
+10 -15
View File
@@ -129,7 +129,7 @@ internal sealed unsafe class Chat : IDisposable
if (lsInfo == null)
return null;
// TODO APIX: lsInfo type changed to Entry
// TODO APIX: use infoproxychat
var utf = instance->GetLinkshellName(*(ulong**)lsInfo);
return utf == null ? null : MemoryHelper.ReadStringNullTerminated((nint) utf);
}
@@ -140,29 +140,24 @@ internal sealed unsafe class Chat : IDisposable
return utf == null ? null : utf->ToString();
}
private static int GetRotateIdx(RotateMode mode) => mode switch
{
RotateMode.Forward => 1,
RotateMode.Reverse => -1,
_ => 0,
};
internal static int RotateLinkshellHistory(RotateMode mode)
{
var uiModule = UIModule.Instance();
if (mode == RotateMode.None)
uiModule->LinkshellCycle = -1;
return RotateLinkshellHistoryInternal(uiModule->RotateLinkshellHistory, mode);
return uiModule->RotateLinkshellHistory(GetRotateIdx(mode));
}
internal static int RotateCrossLinkshellHistory(RotateMode mode) =>
RotateLinkshellHistoryInternal(UIModule.Instance()->RotateCrossLinkshellHistory, mode);
private static int RotateLinkshellHistoryInternal(Func<int, int> func, RotateMode mode)
{
var idx = mode switch
{
RotateMode.Forward => 1,
RotateMode.Reverse => -1,
_ => 0,
};
return func(idx);
}
UIModule.Instance()->RotateCrossLinkshellHistory(GetRotateIdx(mode));
// This function looks up a channel's user-defined color.
// If this function ever returns 0, it returns null instead.