Changes

m
no edit summary
Line 13: Line 13:  
     _column_cell_templates = {
 
     _column_cell_templates = {
 
         node = [[| colspan="${colspan}" rowspan="${rowspan}" style="text-align: center; color: ${color};" |${values.node}<br /><span style="color: ${time_color};">${values.time}</span>]],
 
         node = [[| colspan="${colspan}" rowspan="${rowspan}" style="text-align: center; color: ${color};" |${values.node}<br /><span style="color: ${time_color};">${values.time}</span>]],
         formation = [[| style="background-color: ${bg_color}" |${values.formation}]],
+
         formation = [[| ${values.formation}]],
         fleet = [[| style="background-color: ${bg_color}" |${values.fleet}]],
+
         fleet = [[| ${values.fleet}]],
         as = [[| style="text-align: center; background-color: ${bg_color}" |${values.as}]],
+
         as = [[| style="text-align: center;" |${values.as}]],
    },
  −
    _column_bg_colors = {
  −
        node = "transparent",
  −
        formation = "transparent",
  −
        fleet = "transparent",
  −
        as = "transparent",
   
     },
 
     },
 +
    _empty_node_template = [[| style="text-align: center;" |${values.node}
 +
    | colspan="3" |Must be my imagination (battle avoided)]],
 +
    _resource_node_template = [[| style="text-align: center;" |${values.node}
 +
    | colspan="3" |${values.resource}${values.amount}]],
 
     _columns = {
 
     _columns = {
 
         "node",
 
         "node",
Line 46: Line 44:     
function NodeInfo:formation(row)
 
function NodeInfo:formation(row)
     return { values = { formation = row.formation }, bg_color = self._column_bg_colors.formation }
+
     return { values = { formation = row.formation } }
 
end
 
end
    
function NodeInfo:fleet(row)
 
function NodeInfo:fleet(row)
     return { values = { fleet = row.fleet }, bg_color = self._column_bg_colors.fleet }
+
     return { values = { fleet = row.fleet } }
 
end
 
end
    
function NodeInfo:as(row)
 
function NodeInfo:as(row)
     return { values = { as = row.as }, bg_color = self._column_bg_colors.as }
+
     return { values = { as = row.as } }
 
end
 
end
   Line 85: Line 83:  
     local node, time, boss, formation_image, fleet, as_rating = nil, nil, false, nil, "", 0
 
     local node, time, boss, formation_image, fleet, as_rating = nil, nil, false, nil, "", 0
 
for index, item_key in ipairs(self._args) do
 
for index, item_key in ipairs(self._args) do
if item_key == "-" then
+
if item_key == "-" or mw.ustring.find(item_key, "#") then
 
    self:insert_item(node, time, boss, formation_image, fleet, as_rating, item_key)
 
    self:insert_item(node, time, boss, formation_image, fleet, as_rating, item_key)
 
table.insert(self._items, "break")
 
table.insert(self._items, "break")
Line 91: Line 89:  
node, time, boss, formation_image, fleet, as_rating = nil, nil, false, nil, "", 0
 
node, time, boss, formation_image, fleet, as_rating = nil, nil, false, nil, "", 0
 
mode = 1
 
mode = 1
 +
 +
if mw.ustring.find(item_key, "#") then
 +
    item_key = mw.ustring.sub(item_key, 2)
 +
   
 +
    --If it has no /, then it's an empty node; otherwise, it has a resource and number
 +
    if not mw.ustring.find(item_key, '/') then
 +
        table.insert(self._items, item_key .. "/empty")
 +
    else
 +
        table.insert(self._items, item_key)
 +
    end
 +
    table.insert(self._items, "break")
 +
end
 
else
 
else
 
--Each item will be just a string, so we need to check for one of the _columns, which will be done by mode
 
--Each item will be just a string, so we need to check for one of the _columns, which will be done by mode
Line 166: Line 176:  
end
 
end
 
table.insert(self._data_rows, row_values)
 
table.insert(self._data_rows, row_values)
 +
end
 +
end
 +
 +
function NodeInfo:build_rows()
 +
for index, row_values in ipairs(self._data_rows) do
 +
if row_values ~= "break" and not mw.ustring.find(row_values, '/') then
 +
table.insert(self._rows, self._row_starter)
 +
if row_values == "header" then
 +
table.insert(self._rows, self._header)
 +
elseif type(row_values) == "table" then
 +
for _, column in ipairs(self._columns) do
 +
if row_values[column] then
 +
table.insert(self._rows, format(self._column_cell_templates[column] or self._cell, row_values[column]))
 +
end
 +
end
 +
else
 +
table.insert(self._rows,
 +
format{self._cell,
 +
colspan = #self._columns, rowspan = 1,
 +
text_align = self._args[self._custom_row_prefix .. row_values .. self._text_align_suffix] or self._start_align,
 +
bg_color = self._args[self._custom_row_prefix .. row_values .. self._bg_color_suffix] or self._transparent,
 +
values = {
 +
value = self._args[self._custom_row_prefix .. row_values .. self._content_suffix] or "",
 +
},
 +
}
 +
)
 +
    end
 +
    else
 +
        table.insert(self._rows, self._row_starter)
 +
       
 +
        local split = mw.ustring.find(row_values, '/')
 +
        local node = mw.ustring.sub(row_values, 1, split - 1)
 +
        local resource = mw.ustring.sub(row_values, split + 1)
 +
        if resource == "empty" then
 +
            table.insert(self._rows, format{self._empty_node_template, { values = { node = amount } } })
 +
        else
 +
            split = mw.ustring.find(resource, '/')
 +
            local amount = mw.ustring.sub(resource, split + 1)
 +
            resource = Formatting:format_image{mw.ustring.sub(resource, 1, split - 1) .. ".png", caption = mw.ustring.sub(resource, 1, split - 1)}
 +
            table.insert(self._rows, format{self._resource_node_template, { values = { node = node, amount = amount, resource = resource } } })
 +
        end
 +
end
 
end
 
end
 
end
 
end
    
return NodeInfo
 
return NodeInfo
48

edits