diff --git a/LuaMenu/widgets/chobby/components/chat_windows.lua b/LuaMenu/widgets/chobby/components/chat_windows.lua index 70c1dc68e..cfea8fd8f 100644 --- a/LuaMenu/widgets/chobby/components/chat_windows.lua +++ b/LuaMenu/widgets/chobby/components/chat_windows.lua @@ -360,11 +360,24 @@ function ChatWindows:init() lobby:AddListener("OnDisconnected", function () if self.tabPanel.tabBar.visible then - self.tabPanel.tabBar:Hide() - self.joinButton:Hide() + -- self.tabPanel.tabBar:Hide() + -- self.joinButton:Hide() end - self.window:ClearChildren() - self.window:AddChild(self.loginButton) + + -- self.window:ClearChildren() + -- self.window:AddChild(self.loginButton) + -- Instead of showing this, how about disabling the text entry boxen with "Login required for chat" + -- The point being that they need to be enabled again :D + + for chanName, channelConsole in pairs(self.channelConsoles) do + if channelConsole.ebInputText then + channelConsole.ebInputText.hint = "Login required for chat." + channelConsole.ebInputText.editable = false + channelConsole.ebInputText.selectable = false + channelConsole.ebInputText:Update() + end + end + end ) @@ -373,6 +386,16 @@ function ChatWindows:init() self.tabPanel.tabBar:Show() self.joinButton:Show() end + + for chanName, channelConsole in pairs(self.channelConsoles) do + if channelConsole.ebInputText then + channelConsole.ebInputText.hint = "" + channelConsole.ebInputText.editable = true + channelConsole.ebInputText.selectable = true + channelConsole.ebInputText:Update() + end + end + self.window:ClearChildren() self.window:AddChild(self.chatWindow) end @@ -777,7 +800,7 @@ function ChatWindows:GetChannelConsole(chanName) -- keep it nil like scum -- userListPanel = UserListPanel(function() return {} end, 22, true) else - userListPanel = UserListPanel(function() return lobby:GetChannel(chanName) end, 22, true) + userListPanel = UserListPanel(function() return lobby:GetChannel(chanName) end, 22, true, nil, chanName) end self.userListPanels[chanName] = userListPanel local caption = "#" .. chanName diff --git a/LuaMenu/widgets/chobby/components/configuration.lua b/LuaMenu/widgets/chobby/components/configuration.lua index e10208c08..e7b2e7dff 100644 --- a/LuaMenu/widgets/chobby/components/configuration.lua +++ b/LuaMenu/widgets/chobby/components/configuration.lua @@ -1076,11 +1076,18 @@ function Configuration:GetPlayerName(allowBlank) end function Configuration:GetDefaultGameName() + local rapidTag = "byar:test" if not self.gameConfig then + Spring.Log(LOG_SECTION, LOG.ERROR, "self.gameConfig not present in Configuration:GetDefaultGameName()") return false end + + if self.gameConfig and self.gameConfig._defaultGameRapidTag then + rapidTag = self.gameConfig._defaultGameRapidTag + else + Spring.Log(LOG_SECTION, LOG.ERROR, "self.gameConfig._defaultGameRapidTag not present in Configuration:GetDefaultGameName()") + end - local rapidTag = self.gameConfig._defaultGameRapidTag if rapidTag and VFS.GetNameFromRapidTag then local rapidName = VFS.GetNameFromRapidTag(rapidTag) if rapidName then diff --git a/LuaMenu/widgets/chobby/components/interface_root.lua b/LuaMenu/widgets/chobby/components/interface_root.lua index a466d3b2e..4fc257f25 100644 --- a/LuaMenu/widgets/chobby/components/interface_root.lua +++ b/LuaMenu/widgets/chobby/components/interface_root.lua @@ -498,6 +498,7 @@ function GetInterfaceRoot(optionsParent, mainWindowParent, fontFunction) name = "singleplayer", tabs = Configuration.gameConfig.singleplayerConfig, titleText = i18n("singleplayercoop"), + --startWithTabOpen = 1, }, { name = "multiplayer_and_coop", @@ -505,6 +506,7 @@ function GetInterfaceRoot(optionsParent, mainWindowParent, fontFunction) tabs = multiPlayerTabs, cleanupFunction = Configuration.leaveMultiplayerOnMainMenu and CleanMultiplayerState or nil, twoline = true, + --startWithTabOpen = 1, }, { name = "replays", @@ -515,7 +517,8 @@ function GetInterfaceRoot(optionsParent, mainWindowParent, fontFunction) }, { name = "help", - tabs = Configuration.gameConfig.helpSubmenuConfig + tabs = Configuration.gameConfig.helpSubmenuConfig, + --startWithTabOpen = 1, }, } diff --git a/LuaMenu/widgets/chobby/components/user_list_panel.lua b/LuaMenu/widgets/chobby/components/user_list_panel.lua index 010185b7f..1c08b588a 100644 --- a/LuaMenu/widgets/chobby/components/user_list_panel.lua +++ b/LuaMenu/widgets/chobby/components/user_list_panel.lua @@ -2,10 +2,11 @@ UserListPanel = LCS.class {} LOG_SECTION = "UserListPanel" -function UserListPanel:init(userUpdateFunction, spacing, showCount, getUserFunction) +function UserListPanel:init(userUpdateFunction, spacing, showCount, getUserFunction, channelName) self.userUpdateFunction = userUpdateFunction self.spacing = spacing self.getUserFunction = getUserFunction + self.channelName = channelName self.userComponentMap = {} self.users = {} @@ -169,6 +170,7 @@ function UserListPanel:AddUser(userName, alignComponents) end index = index + 1 end + --Spring.Echo("Added user ", userName, "to channel", self.channelName) table.insert(self.users, index, userName) local userControl = @@ -194,7 +196,7 @@ function UserListPanel:RemoveUser(userName, alignComponents) end if index == nil then if WG.Chobby.Configuration and WG.Chobby.Configuration.devMode then - Spring.Log(LOG_SECTION, LOG.ERROR, "Cannot find user to remove: " .. tostring(userName)) -- only show to devs for now + --Spring.Log(LOG_SECTION, LOG.ERROR, self.channelName ,"Cannot find user to remove: " .. tostring(userName)) -- only show to devs for now end return end diff --git a/LuaMenu/widgets/gui_login_window.lua b/LuaMenu/widgets/gui_login_window.lua index d5de81f1a..8bf6e3da1 100644 --- a/LuaMenu/widgets/gui_login_window.lua +++ b/LuaMenu/widgets/gui_login_window.lua @@ -182,7 +182,9 @@ local function InitializeListeners() local queueTime = 1 local function OnQueued(listener) - currentLoginWindow.txtError:SetText("Waiting in Login Queue for "..tostring(queueTime) .. " seconds (~7)") + if currentLoginWindow then + currentLoginWindow.txtError:SetText("Waiting in Login Queue for "..tostring(queueTime) .. " seconds (~7)") + end queueTime = queueTime + 1 if WG and WG.Delay then local function login_queue_heartbeat() @@ -194,11 +196,23 @@ local function InitializeListeners() end end + function OnLoginInfoEnd() + -- Activate the multiplayer battle tab when login data is done + if WG and WG.Chobby and WG.Chobby.interfaceRoot and WG.Chobby.interfaceRoot.OpenMultiplayerTabByName then + -- Pass the name of the tab + WG.Chobby.interfaceRoot.OpenMultiplayerTabByName("battle_list") + lobby:RemoveListener("OnLoginInfoEnd", OnLoginInfoEnd) + end + + end + + lobby:AddListener("OnRegistrationAccepted", OnRegistrationAccepted) lobby:AddListener("OnRegistrationDenied", OnRegistrationDenied) lobby:AddListener("OnAccepted", OnLoginAccepted) lobby:AddListener("OnDenied", OnLoginDenied) lobby:AddListener("OnQueued", OnQueued) + lobby:AddListener("OnLoginInfoEnd", OnLoginInfoEnd) -- Stored register on connect local function OnConnect() @@ -250,6 +264,8 @@ end -------------------------------------------------------------------------------- -- Widget Interface + + function widget:Initialize() CHOBBY_DIR = LUA_DIRNAME .. "widgets/chobby/" VFS.Include(LUA_DIRNAME .. "widgets/chobby/headers/exports.lua", nil, VFS.RAW_FIRST) @@ -261,7 +277,7 @@ function widget:Initialize() end function widget:Update() - --WG.Delay(CheckAutologin, 1.5) + WG.Delay(CheckAutologin, 1.5) WG.Delay(CheckFirstTimeRegister, 1.8) widgetHandler:RemoveCallIn("Update") end diff --git a/libs/liblobby/lobby/lobby.lua b/libs/liblobby/lobby/lobby.lua index 39657e878..4b5a0dbd7 100644 --- a/libs/liblobby/lobby/lobby.lua +++ b/libs/liblobby/lobby/lobby.lua @@ -615,8 +615,10 @@ function Lobby:_OnAddUser(userName, status) -- -- self.users[userName] = nil -- delete outdated user completly -- end + -- Strange bug, Teiserver seems to send ADDUSER twice for each user. The first time with CLIENTSTATUS, then second time without + local userInfo = self.users[userName] - self.userCount = self.userCount + 1 -- correctly fix because lobby didnt clear user count on onAccepted + if not userInfo then userInfo = { userName = userName, @@ -625,7 +627,14 @@ function Lobby:_OnAddUser(userName, status) hasOutgoingFriendRequest = status and status.accountID and self.hasOutgoingFriendRequestsByID[status.accountID] or nil, } self.users[userName] = userInfo + + -- New user we definitely didnt know about before + self.userCount = self.userCount + 1 else + -- A user we knew about, who went offline, but now has come back online again + if userInfo.isOffline == true then + self.userCount = self.userCount + 1 + end userInfo.isOffline = false end @@ -670,6 +679,8 @@ function Lobby:_OnRemoveUser(userName) userInfo.hasFriendRequest = hasFriendRequest userInfo.hasOutgoingFriendRequest = hasOutgoingFriendRequest end + + userInfo.isOffline = true self.userCount = self.userCount - 1 -- this shows: userCount reflects the "online users" self:_CallListeners("OnRemoveUser", userName) end