Skip to content

Commit

Permalink
Allow teamStyle option for default MS headers (#3423)
Browse files Browse the repository at this point in the history
* allow teamStyle option input for header

* fix anno

* actually pass it along & better anno

* customs
  • Loading branch information
hjpalpha authored Oct 24, 2023
1 parent 44f8021 commit 0ac0d09
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 23 deletions.
23 changes: 12 additions & 11 deletions components/match2/commons/match_summary_base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -532,24 +532,24 @@ end

---Default header function
---@param match table
---@param options {noScore: boolean?}?
---@param options {teamStyle: teamStyle?, width: string?, noScore:boolean?}?
---@return MatchSummaryHeader
function MatchSummary.createDefaultHeader(match, options)
options = options or {}

local teamStyle = options.teamStyle
local header = MatchSummary.Header()

if options.noScore then
return header
:leftOpponent(header:createOpponent(match.opponents[1], 'left'))
:rightOpponent(header:createOpponent(match.opponents[2], 'right'))
:leftOpponent(header:createOpponent(match.opponents[1], 'left', teamStyle))
:rightOpponent(header:createOpponent(match.opponents[2], 'right', teamStyle))
end

return header
:leftOpponent(header:createOpponent(match.opponents[1], 'left'))
:leftOpponent(header:createOpponent(match.opponents[1], 'left', teamStyle))
:leftScore(header:createScore(match.opponents[1]))
:rightScore(header:createScore(match.opponents[2]))
:rightOpponent(header:createOpponent(match.opponents[2], 'right'))
:rightOpponent(header:createOpponent(match.opponents[2], 'right', teamStyle))
end

---Creates a match footer with vods if vods are set
Expand Down Expand Up @@ -578,16 +578,17 @@ end
---Default createMatch function for usage in Custom MatchSummary
---@param matchData table?
---@param CustomMatchSummary table
---@param options {teamStyle: teamStyle?, width: string?, noScore: boolean?}?
---@return MatchSummaryMatch?
function MatchSummary.createMatch(matchData, CustomMatchSummary)
function MatchSummary.createMatch(matchData, CustomMatchSummary, options)
if not matchData then
return
end

local match = Match()

local createHeader = CustomMatchSummary.createHeader or MatchSummary.createDefaultHeader
match:header(createHeader(matchData))
match:header(createHeader(matchData, options))

match:body(CustomMatchSummary.createBody(matchData))

Expand All @@ -604,7 +605,7 @@ end
---Default getByMatchId function for usage in Custom MatchSummary
---@param CustomMatchSummary table
---@param args table
---@param options table?
---@param options {teamStyle: teamStyle?, width: string?, noScore:boolean?}?
---@return Html
function MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, options)
assert(type(CustomMatchSummary.createBody) == 'function', 'Function "createBody" missing in "Module:MatchSummary"')
Expand All @@ -619,12 +620,12 @@ function MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, options)
--additional header for when martin adds the the css and buttons for switching between match and reset match
--if bracketResetMatch then
--local createHeader = CustomMatchSummary.createHeader or MatchSummary.createDefaultHeader
--matchSummary:header(createHeader(match, {noScore = true}))
--matchSummary:header(createHeader(match, {noScore = true, teamStyle = options.teamStyle}))
--here martin can add the buttons for switching between match and reset match
--end

local createMatch = CustomMatchSummary.createMatch or function(matchData)
return MatchSummary.createMatch(matchData, CustomMatchSummary)
return MatchSummary.createMatch(matchData, CustomMatchSummary, options)
end
matchSummary:addMatch(createMatch(match))
matchSummary:addMatch(createMatch(bracketResetMatch))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function StarcraftMatchSummary.MatchSummaryContainer(args)
--additional header for when martin adds the the css and buttons for switching between match and reset match
--if bracketResetMatch then
--local createHeader = CustomMatchSummary.createHeader or MatchSummary.createDefaultHeader
--matchSummary:header(createHeader(match, {noScore = true}))
--matchSummary:header(createHeader(match, {noScore = true, teamStyle = options.teamStyle}))
--here martin can add the buttons for switching between match and reset match
--end

Expand Down
2 changes: 1 addition & 1 deletion components/match2/wikis/arenaofvalor/match_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ end
---@param args table
---@return Html
function CustomMatchSummary.getByMatchId(args)
return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '420px'})
return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '420px', teamStyle = 'bracket'})
end

---@param match MatchGroupUtilMatch
Expand Down
2 changes: 1 addition & 1 deletion components/match2/wikis/dota2/match_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ end
---@param args table
---@return Html
function CustomMatchSummary.getByMatchId(args)
return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '400px'})
return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '400px', teamStyle = 'bracket'})
end

---@param match MatchGroupUtilMatch
Expand Down
2 changes: 1 addition & 1 deletion components/match2/wikis/leagueoflegends/match_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ end
---@param args table
---@return Html
function CustomMatchSummary.getByMatchId(args)
return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '400px'})
return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '400px', teamStyle = 'bracket'})
end

---@param match MatchGroupUtilMatch
Expand Down
2 changes: 1 addition & 1 deletion components/match2/wikis/mobilelegends/match_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ end
---@param args table
---@return Html
function CustomMatchSummary.getByMatchId(args)
return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '420px'})
return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '420px', teamStyle = 'bracket'})
end

---@param match MatchGroupUtilMatch
Expand Down
2 changes: 1 addition & 1 deletion components/match2/wikis/pokemon/match_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ end
---@param args table
---@return Html
function CustomMatchSummary.getByMatchId(args)
return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '420px'})
return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '420px', teamStyle = 'bracket'})
end

---@param match MatchGroupUtilMatch
Expand Down
3 changes: 2 additions & 1 deletion components/match2/wikis/rocketleague/match_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,9 @@ function CustomMatchSummary.getByMatchId(args)
end

---@param match MatchGroupUtilMatch
---@param options {teamStyle: boolean?, width: string?}?
---@return RocketleagueMatchSummaryHeader
function CustomMatchSummary.createHeader(match)
function CustomMatchSummary.createHeader(match, options)
local header = Header()

return header
Expand Down
3 changes: 2 additions & 1 deletion components/match2/wikis/sideswipe/match_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ function CustomMatchSummary.getByMatchId(args)
end

---@param match MatchGroupUtilMatch
---@param options {teamStyle: boolean?, width: string?}?
---@return SideswipeMatchSummaryHeader
function CustomMatchSummary.createHeader(match)
function CustomMatchSummary.createHeader(match, options)
local header = Header()

return header
Expand Down
2 changes: 1 addition & 1 deletion components/match2/wikis/splatoon/match_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ end
---@param args table
---@return Html
function CustomMatchSummary.getByMatchId(args)
return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '490px'})
return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '490px', teamStyle = 'bracket'})
end

---@param match MatchGroupUtilMatch
Expand Down
3 changes: 2 additions & 1 deletion components/match2/wikis/trackmania/match_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ function CustomMatchSummary.getByMatchId(args)
end

---@param match MatchGroupUtilMatch
---@param options {teamStyle: boolean?, width: string?}?
---@return TrackmaniaMatchSummaryHeader
function CustomMatchSummary.createHeader(match)
function CustomMatchSummary.createHeader(match, options)
local header = Header()

return header
Expand Down
2 changes: 1 addition & 1 deletion components/match2/wikis/valorant/match_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ local CustomMatchSummary = {}
---@param args table
---@return Html
function CustomMatchSummary.getByMatchId(args)
return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '480px'})
return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '480px', teamStyle = 'bracket'})
end

---@param match MatchGroupUtilMatch
Expand Down
2 changes: 1 addition & 1 deletion components/match2/wikis/warcraft/match_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function CustomMatchSummary.getByMatchId(args)
--additional header for when martin adds the the css and buttons for switching between match and reset match
--if bracketResetMatch then
--local createHeader = CustomMatchSummary.createHeader or MatchSummary.createDefaultHeader
--matchSummary:header(createHeader(match, {noScore = true}))
--matchSummary:header(createHeader(match, {noScore = true, teamStyle = options.teamStyle}))
--here martin can add the buttons for switching between match and reset match
--end

Expand Down

0 comments on commit 0ac0d09

Please sign in to comment.