Skip to content

Commit

Permalink
Merge pull request #759 from DeviousNull/show-mute-status
Browse files Browse the repository at this point in the history
Add a "Muted" status icon for players listed in a lobby.
  • Loading branch information
AntlerForce authored Sep 18, 2024
2 parents 35fb3cc + 61069d5 commit 72b7dd8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
Binary file added LuaMenu/images/mute.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion LuaMenu/widgets/api_user_handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ local IMAGE_ONLINE = IMAGE_DIR .. "online.png"
local IMAGE_OFFLINE = IMAGE_DIR .. "offline.png"
local IMAGE_BOSS = IMAGE_DIR .. "boss-icon.png"
local IMAGE_RUNNING_BATTLE = IMAGE_DIR .. "runningBattle.png"
local IMAGE_MUTED = IMAGE_DIR .. "mute.png"


local IMAGE_CLAN_PATH = "LuaUI/Configs/Clans/"
local RANK_DIR = LUA_DIRNAME .. "configs/gameConfig/zk/rankImages/"
Expand Down Expand Up @@ -290,12 +292,17 @@ end

local function GetUserStatusImages(userName, isInBattle, userControl)
local userInfo = userControl.replayUserInfo or userControl.lobby:GetUser(userName) or {}
local battleStatus = userControl.lobby:GetUserBattleStatus(userName) or {}
local images = {}

if userInfo.pendingPartyInvite and not userControl.hideStatusInvite then
images[#images + 1] = IMAGE_PARTY_INVITE
end

if isInBattle and battleStatus.isMuted then
images[#images + 1] = IMAGE_MUTED
end

if isInBattle and userControl.isBoss then
images[#images + 1] = IMAGE_BOSS
end
Expand Down Expand Up @@ -614,7 +621,10 @@ local function UpdateUserBattleStatus(listener, userName, battleStatusDiff)
local bs = userControls.lobby:GetUserBattleStatus(userName) or {}
userControls.isPlaying = bs.isSpectator == false
userControls.isBoss = bs.isBoss or false

userControls.isMuted = bs.isMuted or false

UpdateUserActivity(_, userName, {})

local offset = 0
if userControls.tbQueuePos then
userControls.isInQueue = bs.queuePos and bs.queuePos > 0 or false
Expand Down Expand Up @@ -889,6 +899,7 @@ local function GetUserControls(userName, opts)
userControls.isPlaying = bs.isSpectator == false
userControls.isInQueue = bs.queuePos and bs.queuePos > 0 or false
userControls.isBoss = bs.isBoss or false
userControls.isMuted = bs.isMuted or false

if reinitialize then
userControls.mainControl:ClearChildren()
Expand Down
1 change: 1 addition & 0 deletions LuaMenu/widgets/chobby/components/configuration.lua
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ function Configuration:init()
balanceMode = true,
preset = true,
boss = true,
mutes = true,
}
-- SAIDBATTLEEX Prefixes
self.BTLEX_JOINQUEUE = "You are now in the join-queue at position"
Expand Down
15 changes: 15 additions & 0 deletions libs/liblobby/lobby/lobby.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,21 @@ function Lobby:_OnSaidBattleEx(userName, message, sayTime)
end
end

if battleInfo.mutes ~= nil then
local battleMutes = {}
for mutedUserName in string.gmatch(battleInfo.mutes, "([^,]+)") do
battleMutes[mutedUserName] = true
end

local battleUsers = self.battles[battleID].users
for _, battleUserName in pairs(battleUsers) do
local battleUserIsMuted = battleMutes[battleUserName] or false
if self.userBattleStatus[battleUserName] and self.userBattleStatus[battleUserName].isMuted ~= battleUserIsMuted then
self:_OnUpdateUserBattleStatus(battleUserName, {isMuted = battleUserIsMuted})
end
end
end

end
-- 2023-07-04 FB: For now: proceed with CallListeners of SaidBattleEx, because gui_battle_room has its own parsing of barmanager message
-- return
Expand Down

0 comments on commit 72b7dd8

Please sign in to comment.