@@ -181,6 +181,7 @@ function BattleListWindow:init(parent)
181181 return
182182 end
183183 self :OnUpdateBattleInfo (battleID )
184+ self :UpdateButtonColor (battleID )
184185 SoftUpdate ()
185186 end
186187 lobby :AddListener (" OnUpdateBattleInfo" , self .onUpdateBattleInfo )
@@ -235,6 +236,11 @@ function BattleListWindow:Update()
235236 for _ , battle in pairs (battles ) do
236237 self :AddBattle (battle .battleID , battle )
237238 end
239+
240+ for _ , battle in pairs (battles ) do
241+ self :UpdateButtonColor (battle .battleID )
242+ end
243+
238244 self :UpdateFilters ()
239245 self :UpdateInfoPanel ()
240246end
274280function BattleListWindow :MakeWatchBattle (battleID , battle )
275281 local height = self .itemHeight - 20
276282 local parentButton = Button :New {
277- classname = " button_rounded " ,
283+ classname = " battle_default_button " ,
278284 name = " battleButton" ,
279285 x = 0 ,
280286 right = 0 ,
468474function BattleListWindow :MakeJoinBattle (battleID , battle )
469475 local height = self .itemHeight - 20
470476 local parentButton = Button :New {
471- classname = " button_rounded " ,
477+ classname = " battle_default_button " ,
472478 name = " battleButton" ,
473479 x = 0 ,
474480 right = 0 ,
@@ -633,6 +639,7 @@ function BattleListWindow:AddBattle(battleID, battle)
633639 end
634640
635641 self :AddRow ({button }, battle .battleID )
642+ self :UpdateButtonColor (battleID ) -- necessary for some reason, despite BAR not needing this
636643end
637644
638645function BattleListWindow :ItemInFilter (id )
@@ -689,6 +696,45 @@ function BattleListWindow:CompareItems(id1, id2)
689696 end
690697end
691698
699+ function BattleListWindow :UpdateButtonColor (battleID )
700+
701+ local items = self :GetRowItems (battleID )
702+ if not items then
703+ return
704+ end
705+ local battle = lobby :GetBattle (battleID )
706+ if battle == nil then return end
707+
708+ local oldbuttonstyle = items .battleButton .backgroundColor
709+ local battlebuttonstyle = {0.10 , 0.10 , 0.95 , 0.65 } -- blue
710+ if battle .passworded then
711+ battlebuttonstyle = {0.60 , 0.10 , 0.85 , 0.65 } -- violet
712+ elseif battle .isMatchMaker then
713+ battlebuttonstyle = {0.90 , 0.10 , 0.10 , 0.65 } -- red
714+ elseif lobby :GetBattlePlayerCount (battleID ) < 1 then
715+ battlebuttonstyle = {0.10 , 0.10 , 0.95 , 0.65 } -- blue
716+ elseif battle .isRunning then
717+ battlebuttonstyle = {0.70 , 0.60 , 0.1 , 0.65 } -- yellow
718+ else
719+ battlebuttonstyle = {0.10 , 0.50 , 0.10 , 0.65 } -- green
720+ end
721+ local colorChanged = false
722+ for i , c in ipairs (oldbuttonstyle ) do
723+ if c ~= battlebuttonstyle [i ] then
724+ colorChanged = true
725+ break
726+ end
727+ end
728+ -- Spring.Echo("BattleListWindow:UpdateButtonColor",battleID,battlebuttonstyle, items.battleButton.backgroundColor,battle.isRunning ,battle.passworded, lobby:GetBattlePlayerCount(battleID))
729+
730+ if colorChanged then
731+ -- Spring.Echo("BattleListWindow:UpdateButtonColor",battleID,battlebuttonstyle, items.battleButton.backgroundColor,battle.isRunning ,battle.passworded, lobby:GetBattlePlayerCount(battleID))
732+ items .battleButton .backgroundColor = battlebuttonstyle
733+ items .battleButton .focusColor = battlebuttonstyle
734+ items .battleButton :Invalidate ()
735+ end
736+ end
737+
692738function BattleListWindow :RecalculateOrder (id )
693739 if lobby .commandBuffer then
694740 return
@@ -774,6 +820,7 @@ function BattleListWindow:JoinedBattle(battleID)
774820 local playerCount = lobby :GetBattlePlayerCount (battleID )
775821 playersOnMapCaption :SetCaption (playerCount .. ((playerCount == 1 and " player on " ) or " players on " ) .. battle .mapName :gsub (" _" , " " ))
776822 end
823+ self :UpdateButtonColor (battleID )
777824 self :RecalculateOrder (battleID )
778825end
779826
@@ -797,6 +844,7 @@ function BattleListWindow:LeftBattle(battleID)
797844 local playerCount = lobby :GetBattlePlayerCount (battleID )
798845 playersOnMapCaption :SetCaption (playerCount .. ((playerCount == 1 and " player on " ) or " players on " ) .. battle .mapName :gsub (" _" , " " ))
799846 end
847+ self :UpdateButtonColor (battleID )
800848 self :RecalculateOrder (battleID )
801849end
802850
@@ -875,6 +923,7 @@ function BattleListWindow:OnUpdateBattleInfo(battleID)
875923 local playerCount = lobby :GetBattlePlayerCount (battleID )
876924 playersOnMapCaption :SetCaption (playerCount .. ((playerCount == 1 and " player on " ) or " players on " ) .. battle .mapName :gsub (" _" , " " ))
877925 end
926+ self :UpdateButtonColor (battleID )
878927 self :RecalculateOrder (battleID )
879928end
880929
@@ -897,6 +946,7 @@ function BattleListWindow:OnBattleIngameUpdate(battleID, isRunning)
897946 runningImage .file = BATTLE_NOT_RUNNING
898947 end
899948 runningImage :Invalidate ()
949+ self :UpdateButtonColor (battleID )
900950 self :RecalculateOrder (battleID )
901951end
902952
0 commit comments