Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions lua/ui/game/chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,6 @@ function CreateChatLines()
end
end

function OnNISBegin()
CloseChat()
end

function SetupChatScroll()
GUI.chatContainer.top = 1
GUI.chatContainer.scroll = UIUtil.CreateVertScrollbarFor(GUI.chatContainer)
Expand Down Expand Up @@ -881,11 +877,13 @@ function ReceiveChatFromSim(sender, msg)
}

table.insert(chatHistory, entry)
if ChatOptions[entry.armyID] then
if table.getsize(chatHistory) == 1 then
GUI.chatContainer:CalcVisible()
else
GUI.chatContainer:ScrollToBottom()
if not import("/lua/ui/game/gamemain.lua").IsNISMode() then
if ChatOptions[entry.armyID] then
if table.getsize(chatHistory) == 1 then
GUI.chatContainer:CalcVisible()
else
GUI.chatContainer:ScrollToBottom()
end
end
end
end
Expand Down Expand Up @@ -1563,3 +1561,14 @@ function CloseChatConfig()
GUI.config = nil
end
end

function OnNISBegin()
CloseChatConfig()
GUI.bg:Hide()
GUI.chatEdit.edit:AbandonFocus()
GUI.bg:SetNeedsFrameUpdate(false)
for i, v in GUI.chatLines do
v:SetNeedsFrameUpdate(false)
v:Hide()
end
end
Comment on lines +1565 to +1574
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for registration of OnNISBegin callback
rg -n "OnNISBegin|RegisterNIS|NIS.*[Bb]egin" lua/ui/game/ -A3 -B3

Repository: FAForever/fa

Length of output: 1279


🏁 Script executed:

#!/bin/bash
# Look for OnNISEnd or chat show/restore logic
rg -n "OnNISEnd|function.*NIS.*End" lua/ui/game/ -A10

Repository: FAForever/fa

Length of output: 38


🏁 Script executed:

#!/bin/bash
# Check the broader context around OnNISBegin function
rg -n "function OnNISBegin" lua/ui/game/chat.lua -A20 -B5

Repository: FAForever/fa

Length of output: 433


🏁 Script executed:

#!/bin/bash
# Search for OnNISEnd more broadly across entire repo
rg -n "OnNISEnd|state == 'off'" lua/ -A5 -B2

Repository: FAForever/fa

Length of output: 619


🏁 Script executed:

#!/bin/bash
# Check gamemain.lua for NIS state handling when turning off
rg -n "NISActive|state == 'off'" lua/ui/game/gamemain.lua -A8 -B2

Repository: FAForever/fa

Length of output: 1690


🏁 Script executed:

#!/bin/bash
# Get the complete NISMode function to see the 'off' case
sed -n '935,1000p' lua/ui/game/gamemain.lua

Repository: FAForever/fa

Length of output: 2838


🏁 Script executed:

#!/bin/bash
# Check if OnNISBegin in chat.lua has any guards for uninitialized GUI
sed -n '1565,1574p' lua/ui/game/chat.lua

Repository: FAForever/fa

Length of output: 291


🏁 Script executed:

#!/bin/bash
# Check when chat is initialized and if there's a guard needed
rg -n "function CreateChat|GUI = |GUI\.bg = " lua/ui/game/chat.lua -B2 -A3

Repository: FAForever/fa

Length of output: 1433


🏁 Script executed:

#!/bin/bash
# Check when CreateChat is called - look for calls to it
rg -n "CreateChat\(\)" lua/ -B3 -A1

Repository: FAForever/fa

Length of output: 530


🏁 Script executed:

#!/bin/bash
# Check if there's a chat restoration or Show logic when NIS ends
rg -n "GUI.bg:Show|GUI.chatEdit.*Show|RestoreChat" lua/ui/game/chat.lua

Repository: FAForever/fa

Length of output: 149


🏁 Script executed:

#!/bin/bash
# Check how other modules handle NIS restoration (saveload and options OnNISBegin)
rg -n "function OnNISBegin" lua/ui/dialogs/ -A15

Repository: FAForever/fa

Length of output: 727


🏁 Script executed:

#!/bin/bash
# Check if PostNIS in multifunction handles chat restoration
rg -n "function PostNIS" lua/ui/game/multifunction.lua -A20

Repository: FAForever/fa

Length of output: 771


🏁 Script executed:

#!/bin/bash
# Check what happens in HideGameUI when called with 'off' - does it affect chat?
sed -n '867,900p' lua/ui/game/gamemain.lua

Repository: FAForever/fa

Length of output: 1754


🏁 Script executed:

#!/bin/bash
# Search for any mechanism that might auto-show hidden UI elements
rg -n "Show\(\)|SetNeedsFrameUpdate.*true" lua/ui/game/chat.lua | head -20

Repository: FAForever/fa

Length of output: 468


🏁 Script executed:

#!/bin/bash
# Check what function contains the Show() calls around line 893-901
sed -n '880,910p' lua/ui/game/chat.lua

Repository: FAForever/fa

Length of output: 948


🏁 Script executed:

#!/bin/bash
# Check if there's any automatic restoration logic or if chat restoration is missing
rg -n "function ReceiveChat|AddChatLine" lua/ui/game/chat.lua -A10 | head -50

Repository: FAForever/fa

Length of output: 689


🏁 Script executed:

#!/bin/bash
# Check if chat module has OnNISEnd or any restoration hook
rg -n "OnNISEnd|NIS.*End|function.*NIS" lua/ui/game/chat.lua

Repository: FAForever/fa

Length of output: 82


🏁 Script executed:

#!/bin/bash
# Check what other UI modules might be responsible for restoring chat
sed -n '969,1010p' lua/ui/game/gamemain.lua

Repository: FAForever/fa

Length of output: 1815


Add OnNISEnd function to restore chat UI when NIS ends.

The OnNISBegin() function correctly hides the chat UI, but there is no corresponding restoration when NIS ends. When NISMode() is called with state == 'off' in gamemain.lua, the chat UI remains hidden because no restoration call is made. Add an OnNISEnd() function to lua/ui/game/chat.lua that shows the chat UI and re-enables frame updates, and invoke it from the NIS end handler in gamemain.lua (similar to how OnNISBegin() is called when NIS starts).

🤖 Prompt for AI Agents
In lua/ui/game/chat.lua around lines 1565-1574, add a new OnNISEnd() function
that reverses OnNISBegin(): call GUI.bg:Show(),
GUI.bg:SetNeedsFrameUpdate(true), iterate GUI.chatLines and call
v:SetNeedsFrameUpdate(true) and v:Show() for each, and restore the chat edit
widget (e.g., ensure GUI.chatEdit.edit can receive input); then update
gamemain.lua’s NISMode handler to call OnNISEnd() when state == 'off' (mirror
the existing call to OnNISBegin() when NIS starts).

Loading