• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Changes

Jump to navigation Jump to search
no edit summary
Line 7: Line 7:  
_header_template = nil,
 
_header_template = nil,
 
_cell = [[${values.value}]],
 
_cell = [[${values.value}]],
_columns = {
  −
"one",
  −
"two",
  −
"three",
  −
"four",
  −
"five",
  −
},
   
}
 
}
    
function CardList:create_table_prep()
 
function CardList:create_table_prep()
 
self._size = self._args.image_size or self._default_size
 
self._size = self._args.image_size or self._default_size
end
+
self._columns = {}
 
+
if self._args.column_count then
function CardList:one(row)
+
    if self._args.column_count == "false" then
return self:card(row[1])
+
        self._column_count = false
end
+
    else
 
+
        self._column_count = tonumber(self._args.column_count)
function CardList:two(row)
+
    end
return self:card(row[2])
+
    end
end
+
    if self._column_count then
 
+
    for i=1, self._column_count do
function CardList:three(row)
+
        table.insert(self._columns, i)
return self:card(row[3])
+
    end
end
+
    end
 
  −
function CardList:four(row)
  −
return self:card(row[4])
  −
end
  −
 
  −
function CardList:five(row)
  −
return self:card(row[5])
   
end
 
end
   Line 65: Line 51:  
for index, item_key in ipairs(self._args) do
 
for index, item_key in ipairs(self._args) do
 
if mw.ustring.sub(item_key, 1, 1) == "!" then
 
if mw.ustring.sub(item_key, 1, 1) == "!" then
local filled = #row
+
    if self._column_count then
if filled ~= 0 then
+
    local filled = #row
for i=1, 5 - filled do
+
    if filled ~= 0 then
table.insert(row, false)
+
    for i=1, self._column_count - filled do
end
+
    table.insert(row, false)
table.insert(self._items, row)
+
    end
row = {}
+
    table.insert(self._items, row)
for i=1, filled do
+
    row = {}
table.insert(row, false)
+
    for i=1, filled do
end
+
    table.insert(row, false)
end
+
    end
 +
    end
 +
    end
 
table.insert(self._items, mw.ustring.sub(item_key, 2))
 
table.insert(self._items, mw.ustring.sub(item_key, 2))
 +
    elseif not self._column_count and item_key == "~" then
 +
        table.insert(self._items, row)
 +
        row = {}
 +
        count = 0
 
else
 
else
 
count = count + 1
 
count = count + 1
Line 86: Line 78:  
end
 
end
 
table.insert(row, item)
 
table.insert(row, item)
if count % 5 == 0 then
+
if self._column_count and (count % self._column_count == 0) then
 
table.insert(self._items, row)
 
table.insert(self._items, row)
 
row = {}
 
row = {}
 +
elseif not self._column_count then
 +
    self._max_columns = math.max(self._max_columns or 0, count)
 
end
 
end
 
end
 
end
 
end
 
end
 
if #row > 0 then
 
if #row > 0 then
for i=1, 5 - #row do
+
if self._column_count then
table.insert(row, false)
+
    for i=1, self._column_count - #row do
 +
    table.insert(row, false)
 +
    end
 
end
 
end
 
table.insert(self._items, row)
 
table.insert(self._items, row)
 
end
 
end
 +
    if not self._column_count then
 +
    for i=1, self._max_columns do
 +
        table.insert(self._columns, i)
 +
    end
 +
    end
 
end
 
end
   Line 108: Line 109:  
row_values = {}
 
row_values = {}
 
for _, column in ipairs(self._columns) do
 
for _, column in ipairs(self._columns) do
row_values[column] = self[column](self, item)
+
    if self._column_count or item[column] then
row_values[column].rowspan = 1
+
    row_values[column] = self:card(item[column])
row_values[column].colspan = 1
+
    row_values[column].rowspan = 1
 +
    row_values[column].colspan = 1
 +
    end
 
end
 
end
 
end
 
end
Anonymous user

Navigation menu