@@ -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
@@ -771,6 +817,7 @@ function BattleListWindow:JoinedBattle(battleID)
771817 local playerCount = lobby :GetBattlePlayerCount (battleID )
772818 playersOnMapCaption :SetCaption (playerCount .. ((playerCount == 1 and " player on " ) or " players on " ) .. battle .mapName :gsub (" _" , " " ))
773819 end
820+ self :UpdateButtonColor (battleID )
774821 self :RecalculateOrder (battleID )
775822end
776823
@@ -794,6 +841,7 @@ function BattleListWindow:LeftBattle(battleID)
794841 local playerCount = lobby :GetBattlePlayerCount (battleID )
795842 playersOnMapCaption :SetCaption (playerCount .. ((playerCount == 1 and " player on " ) or " players on " ) .. battle .mapName :gsub (" _" , " " ))
796843 end
844+ self :UpdateButtonColor (battleID )
797845 self :RecalculateOrder (battleID )
798846end
799847
@@ -870,6 +918,7 @@ function BattleListWindow:OnUpdateBattleInfo(battleID)
870918 local playerCount = lobby :GetBattlePlayerCount (battleID )
871919 playersOnMapCaption :SetCaption (playerCount .. ((playerCount == 1 and " player on " ) or " players on " ) .. battle .mapName :gsub (" _" , " " ))
872920 end
921+ self :UpdateButtonColor (battleID )
873922 self :RecalculateOrder (battleID )
874923end
875924
@@ -892,6 +941,7 @@ function BattleListWindow:OnBattleIngameUpdate(battleID, isRunning)
892941 runningImage .file = BATTLE_NOT_RUNNING
893942 end
894943 runningImage :Invalidate ()
944+ self :UpdateButtonColor (battleID )
895945 self :RecalculateOrder (battleID )
896946end
897947
0 commit comments