Module:RoundN: Difference between revisions

Content deleted Content added
m slightly less shrink if not widescore = yes
new feature: p.branch_upwards; also 3rdplace revamped to support multi-scores; various bug fixes
Line 65:
notTop = {[isTop and 1 or 0] = p.reuseStr.solid}
for k = 0, 1 do
tab.r = rowNum[colm.r + k * 4]:tag'td'
:css(notTop[k] and
{[isTop and 'border-top' or 'border-bottom'] = notTop[k]}
Line 77:
text = nil
end
m.available = nilfalse
else
return nil
Line 97:
local h = p.getNodeFunc()
if m.available then
tab.r = rowNum[colm.r]:tag'td'
:attr{
rowspan = 6,
Line 103:
}
h.addText(h.nonFunc)
m.available = nilfalse
return x
else
Line 317:
'flex_tree',
'no_column_head',
'short_brackets',
'branch_upwards'
}) do
if args[v] and (p[v] == nil or type(p[v]) == 'boolean') then
Line 333 ⟶ 334:
local nodeArgs = {
score = p.scoreBoxes - sumBox,
team = {offset = 1 + p.scoreBoxes - sumBox},
}
all = 1 + (1 + p.scoreBoxes - sumBox),
nodeArgs.all = 1 + nodeArgs.team.offset * 2
nodeArgs.tableSum = {
__add = function(v, t)
local s__add = function(v, t)
forif i,#t n== in ipairs(t)3 dothen
sreturn = sv + nnodeArgs.all
end
return s - (p.scoreSumBox and #t == 3 and 2 or 0)
end
local bumpss = bumpv
}
for ki, vn in ipairs({t) do
col.r s = rs + bumpsn
end
return s --[[ + (p.scoreSumBox and #t == 3 and -2 or 0) --merging disabled with score boxes, uncomment if enable]]
end
}
nodeArgs.team[1] = 1--constant to be replaced later by new param
Line 366 ⟶ 370:
}
fontSize, fontUnit = {fontSize * fontUnit}
local fontSize1dec = math.ceil(fontSize * 10) / 10
end
end
tab
:cssText(table.concat{args.scroll_height and 'padding' or 'margin', ':', fontSize1decfontSize and (math.ceil(fontSize * 10) / 10) or '.9', 'em 2em 1em 1em;border:0;', fontSize and '' or 'font-size:90%;', args.style})
:attr{cellpadding = 0, cellspacing = 0}
if not p.no_column_head then--headings row
Line 407 ⟶ 410:
end
}
p.branch_upwards = p.branch_upwards and 0
for k = 1, p.cols do
if k > 1 then
Line 442 ⟶ 446:
args.line_px:rep(2):gsub('(%a)(%d)', '%1 %2', 1)
}
ifp['3rdplace'] = p.tCols == p.cols and (p['3rdplace'] or p.cols > 3 and p['3rdplace'] == nil and not p.no_column_head) then--begin 3rd place
for r = 1, rows do
rowNum.third = p['3rdplace'] and
(math.max(rows + (rows - 18) / 2, 7) + (p.no_column_head and 8 or 10))
or rows
for r = 1, rowsrowNum.third do
newRow(r)
end
Line 449 ⟶ 457:
for c = 1, p.cols do
col.c = c
local bumps = bump
if c > 1 then
col.tot = col.tot + math.pow(2, p.tCols - c)
if p.branch_upwards then
bumps = 0
rowNum[rows + 1]:tag'td':attr{rowspan = 4}
else
rowNum[1]:node(c < p.cols and
mw.clone(bumpBase):attr{rowspan = bump}
Line 459 ⟶ 472:
})
)
end
end
local bumps = bump
col.top = m.num
nodeFunc.bridge.lay[c] = {}
p.span = p.tCols > c and bump * 2 or c == p.tCols and p.branch_upwards or math.max((bump - 1) / 2, 2)
local colorFinal, bumpMidcol.show3rd = p.color['3rdplace'] and p.colsc == p.tCols and c == p.cols, mw.clone(bumpBase):attr{rowspan = prowNum.span}third
local colorFinal, bumpMid = p.color and p.cols == p.tCols and c == p.cols, p.span > 0 and mw.clone(bumpBase):attr{rowspan = p.span} or nil
for r = 1, col.show3rd or rows, 2 do
col.r = r + bumps
m.r = r + bumps
if col.show3rd or rowNum[colm.r] and m.num <= col.tot then
if m.phase == 0 then
m.showBox = setmetatable({1, pnodeArgs.colspan or 1team.offset, pnodeArgs.colspan or 1team.offset}, nodeArgs.tableSum)
if nodeFunc:scanPattern(args, step) then
nodeFunc.called = {}
m.available = true
else
m.available = nil
end
end
Line 484 ⟶ 500:
end
end
local startcanvas = col.r + (nodeFunc.pattern and nodeFunc.called.canvas and 6 or 0)
rowNum[startm.r + (canvas or 0)]:tag'td':attr{rowspan = maxSpan((start > col.rcanvas and 0 or 6) + bump * 2, startm.r + (canvas or 0), rows), colspan = p.colspan}
elseif m.phase == 2 then
if nodeFunc.pattern and (nodeFunc.called.bridge or nodeFunc.called.canvas) then
Line 491 ⟶ 507:
end
m.num = m.num + 1
step = step + (p.omit_blanks and 0 or nodeArgsm.allshowBox)
bumps = bumps + (col.show3rd and 0 or maxSpan(p.span, colm.r, rows))
end
elseif m.phase == 0 then
Line 501 ⟶ 517:
end
end
if not m.available == false then
m.showBox = nodeArgs.blank
step = step + 1
Line 507 ⟶ 523:
end
if m.showBox[1] then
if col.show3rd then
dpBox(nodeFunc.pattern and nodeFunc.nonFunc or args[step], col.r, skipMatch[m.num])
col.show3rd = (m.num - col.top) * 2
if col.show3rd == 2 then
if rowNum[rows + 1] and p.cols > 1 then --if 3rd place extends below bottom cell
rowNum[rows + 1]:tag'td':attr{
rowspan = colm.r + 7 - rows,
colspan = (p.cols - 1) * 4
}
end
if p.tCols == 1 then
bumps = bumps + 3
elseif p.branch_upwards then
r = 7
bumps = 2
end
m.r = r + bumps
drawHead(args.Consol or args['RD' .. (p.cols + 1)] or p.RD[4], colm.r)
bumps = bumps + 2
m.r = r + bumps
end
end
dpBox(nodeFunc.pattern and nodeFunc.nonFunc or args[step], colm.r, skipMatch[m.num])
if p.previewnumbers then
p.namespace = p.namespace or mw.title.getCurrentTitle().namespace
Line 555 ⟶ 592:
else
if m.showBox[m.phase] then
local base = {color = colorFinal, phase = m.phase + (col.show3rd or 0)}
teamBox(args[step + nodeArgs.team[m.phase]], colm.r, setmetatable(base, {__index = {bold = m.bold and m.bold.win[m.phase]}}))
if p.colspan then
if #m.nonEmpty == 0 then
for s = 1, p.scoreBoxes do
teamBox('', colm.r, base)
end
else
Line 568 ⟶ 605:
local thinLeft = p.scoreSumBox and {[1] = {}, [#m.nonEmpty] = {'0 1ex'}} or {}
for s, i in ipairs(m.nonEmpty) do
teamBox(args[i[m.phase]], colm.r, setmetatable(base, {__index = {'center', borderLeft = not thinLeft[s] and 0 or nil, sumBox = thinLeft[s], bold = m.bold and m.bold.box[s][m.phase]}}))
end
end
Line 581 ⟶ 618:
'<table>',
tostring(sp.row), '<tr>',
tostring(rowNum[colm.r - 4]), '<tr>',
tostring(rowNum[colm.r - 2]), '<tr>',
tostring(rowNum[colm.r]), '</table>',
}
end
Line 589 ⟶ 626:
skipMatch[m.num] = 'orphan'
end
step = step + (m.showBox.unchanged and nodeArgs.full or m.showBox)
m.num = m.num + 1
if bump > 0 and rowNum[colm.r + 2] and not (nodeFunc.pattern and nodeFunc.called.canvas) then
bumps = bumps + p.span
rowNum[colm.r + 2]:node(bumpMid)
end
r = r + (col.show3rd or bump)
end
end
mif col.phaseshow3rd == (2 and m.phase + 1)== %2 3then
col.show3rd = nil
else
m.phase = (m.phase + 1) % 3
end
end
end
Line 604 ⟶ 645:
p.unit = bump + 3
bump = (rows - rows / math.pow(2, c)) / math.pow(2, p.tCols - c)
bumps = p.branch_upwards and 4 or (p.unit + 1)
rowNum[1]
:tag'td':attr{rowspan = bumps}
if not p.branch_upwards then
rowNum[1]:tag'td'
:attr{rowspan = (p.branch_upwards or bump) + 4}
:css(nodeFunc.bridge.lay[c][0] and
{['border-right'] = p.reuseStr.solid}
or {}
)
end
col.n = 0
for r = bumps + 1, rows, p.unit * 2 do
Line 641 ⟶ 684:
)
:node(col.t == 1 and interval > 0 and not nodeFunc.bridge.lay[c][col.n - 2] and p.cornerDiv)
rowNum[r + (p.branch_upwards and (4 - bump) or p.unit)]:tag'td'
:attr{rowspan = maxSpan(p.unit, r + p.unit, rows)}
:cssText(col.t == 1 and
Line 657 ⟶ 700:
rowNum[r + p.unit * 5] and col.t2 < 3 or false
}
rowNum[r + (p.branch_upwards or p.unit)]:tag'td'
:attr{rowspan = maxSpan(p.unit * 4, r + (p.branch_upwards and (4 - bump) or p.unit), rows)}
:css(interval == 0 and (col.t[1] or col.t[2]) and {
['border-width'] = table.concat{tab.line[1][col.t[1]], ' 0 ', tab.line[1][col.t[2]]},
Line 672 ⟶ 715:
end
end
end
end
if p.tCols == p.cols and (p['3rdplace'] or p.cols > 3 and p['3rdplace'] == nil and not p.no_column_head) then--begin 3rd place
col.r = rows / 2 + 4 + math.max(p.span, 3)
for r = rows + 1, col.r + 7 do
newRow(r)
end
if rowNum[rows + 1] and p.cols > 1 then --if 3rd place extends below bottom cell
rowNum[rows + 1]:tag'td':attr{
rowspan = col.r + 7 - rows,
colspan = (p.cols - 1) * 4
}
end
drawHead(args.Consol or args['RD' .. (p.cols + 1)] or p.RD[4], col.r)
dpBox(args[step], col.r + 2)
m.bold = boldWin(p.scoreWasher:main(args[step + 2]), p.scoreWasher:main(args[step + 4]), unBold[m.num])
for k, v in ipairs({
{4, {color = p.color and 3, bold = m.bold[1]}},
{4, {'center', color = p.color and 3, bold = m.bold[1]}},
{6, {bold = m.bold[2]}},
{6, {'center', bold = m.bold[2]}}
}) do
teamBox(args[step + k], col.r + v[1], v[2])
end
end