Skip to content

Commit

Permalink
Added Alert on start poll (any change to a start poll) and game start…
Browse files Browse the repository at this point in the history
…. Alerts make a sound even if Spring is focused so I have made these alerts not occur if the cursor is on Spring.
  • Loading branch information
GoogleFrog committed Nov 23, 2017
1 parent 5c5b2d7 commit 79baa54
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions LuaMenu/widgets/api_notification_handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,30 @@ end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

local function MouseOutside()
local x, y, lmb, mmb, rmb, outsideSpring = Spring.GetMouseState()
return outsideSpring
end

local function AddListeners()
local function OnRung(_, userName, message, sayTime, source)
WG.WrapperLoopback.Alert(message)
end
lobby:AddListener("OnRung", OnRung)

local function OnVoteUpdate(listener, message, yesVotes, noVotes, votesNeeded, pollType, pollParameter)
if pollType == "start" and not lobby:GetMyIsSpectator() and MouseOutside() then
WG.WrapperLoopback.Alert("Vote to start the battle.")
end
end
lobby:AddListener("OnVoteUpdate", OnVoteUpdate)

local function OnBattleAboutToStart()
if MouseOutside() then
WG.WrapperLoopback.Alert("Zero-K battle starting!")
end
end
lobby:AddListener("OnBattleAboutToStart", OnBattleAboutToStart)
end

function widget:Initialize()
Expand Down
2 changes: 2 additions & 0 deletions libs/liblobby/lobby/interface_zerok.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,8 @@ function Interface:ProcessVote(data, battle, duplicateMessageTime)
mapStart = mapStart + 14
pollParameter = string.sub(voteMessage, mapStart, lasturl - 1)
pollType = "map"
elseif string.find(voteMessage, "start the game?") then
pollType = "start"
end

self:_OnVoteUpdate(voteMessage, yesVotes, noVotes, votesNeeded, pollType, pollParameter)
Expand Down

0 comments on commit 79baa54

Please sign in to comment.