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
+1 -1
View File
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.26.2</Version>
<Version>1.26.3</Version>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
+2 -1
View File
@@ -30,4 +30,5 @@ changelog: |-
- Fix flags not working in reply mode
- Force the main chat log to be always open
- Prevent emotes inside auto translation
- Make Linkshells appear in selection again
- Linkshells appear in selection again
- Fix rotate mode not working for CW and Normal Linkshells
+12 -17
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,30 +140,25 @@ internal sealed unsafe class Chat : IDisposable
return utf == null ? null : utf->ToString();
}
internal static int RotateLinkshellHistory(RotateMode mode)
{
var uiModule = UIModule.Instance();
if (mode == RotateMode.None)
uiModule->LinkshellCycle = -1;
return RotateLinkshellHistoryInternal(uiModule->RotateLinkshellHistory, 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
private static int GetRotateIdx(RotateMode mode) => mode switch
{
RotateMode.Forward => 1,
RotateMode.Reverse => -1,
_ => 0,
};
return func(idx);
internal static int RotateLinkshellHistory(RotateMode mode)
{
var uiModule = UIModule.Instance();
if (mode == RotateMode.None)
uiModule->LinkshellCycle = -1;
return uiModule->RotateLinkshellHistory(GetRotateIdx(mode));
}
internal static int RotateCrossLinkshellHistory(RotateMode mode) =>
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.
internal uint? GetChannelColor(ChatType type)
+2 -4
View File
@@ -188,7 +188,6 @@ public sealed class ChatLogWindow : Window
}
var mode = prevTemp == null ? RotateMode.None : info.Rotate;
if (info.Channel is InputChannel.Linkshell1 && info.Rotate != RotateMode.None)
{
var idx = GameFunctions.Chat.RotateLinkshellHistory(mode);
@@ -692,15 +691,14 @@ public sealed class ChatLogWindow : Window
var push = inputColour != null;
using (ImRaii.PushColor(ImGuiCol.Text, push ? ColourUtil.RgbaToAbgr(inputColour!.Value) : 0, push))
{
if (Activate || FocusedPreview)
var isChatEnabled = activeTab is { InputDisabled: false };
if (isChatEnabled && (Activate || FocusedPreview))
{
FocusedPreview = false;
ImGui.SetKeyboardFocusHere();
}
var chatCopy = Chat;
var isChatEnabled = activeTab is { InputDisabled: false };
using (ImRaii.Disabled(!isChatEnabled))
{
var flags = InputFlags | (!isChatEnabled ? ImGuiInputTextFlags.ReadOnly : ImGuiInputTextFlags.None);