• 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
m
no edit summary
Line 12: Line 12:  
     !AS]],
 
     !AS]],
 
     _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}; background-color: ${bg_color};" |${values.node}<br /><span style="color: ${time_color};">${values.time}</span>]],
         formation = [[| ${values.formation}]],
+
         formation = [[| style="background-color: ${bg_color};" |${values.formation}]],
         fleet = [[| ${values.fleet}]],
+
         fleet = [[| style="background-color: ${bg_color};" |${values.fleet}]],
         as = [[| style="text-align: center;" |${values.as}]],
+
         as = [[| style="text-align: center; background-color: ${bg_color};" |${values.as}]],
 
     },
 
     },
 
     _empty_node_template = [[| style="text-align: center;" |${values.node}
 
     _empty_node_template = [[| style="text-align: center;" |${values.node}
 
     | colspan="3" style="text-align: center;" |Must be my imagination (battle avoided)]],
 
     | colspan="3" style="text-align: center;" |Must be my imagination (battle avoided)]],
     _resource_node_template = [[| style="text-align: center;" |${values.node}
+
     _resource_node_template = [[| style="text-align: center; background-color: ${values.bg_color};" |${values.node}
     | colspan="3" style="text-align: center;" |${values.resource}${values.amount}]],
+
    | style="text-align: center; background-color: ${values.bg_color};" |${values.node_type}
 +
     | colspan="2" style="text-align: center; background-color: ${values.bg_color};" |${values.text}]],
 
     _columns = {
 
     _columns = {
 
         "node",
 
         "node",
Line 29: Line 30:  
     _day_battle_color = "gold",
 
     _day_battle_color = "gold",
 
     _night_battle_color = "blue",
 
     _night_battle_color = "blue",
 +
    _night_battle_bg_color = "lightblue",
 
     _boss_battle_color = "red",
 
     _boss_battle_color = "red",
 +
    _resource_node_bg_color = "lightgreen",
 +
    _maelstrom_node_bg_color = "pink",
 
})
 
})
    
function NodeInfo:node(row)
 
function NodeInfo:node(row)
     local color, time_color = "initial", self._day_battle_color
+
     local color, time_color, bg_color = "initial", self._day_battle_color, "initial"
 
     if row.boss then
 
     if row.boss then
 
         color = self._boss_battle_color
 
         color = self._boss_battle_color
Line 39: Line 43:  
     if row.time == "(Night Battle)" then
 
     if row.time == "(Night Battle)" then
 
         time_color = self._night_battle_color
 
         time_color = self._night_battle_color
 +
        bg_color = self._night_battle_bg_color
 
     end
 
     end
     return { values = { node = row.node, time = row.time }, color = color, time_color = time_color }
+
     return { values = { node = row.node, time = row.time }, color = color, time_color = time_color, bg_color = bg_color }
 
end
 
end
   Line 187: Line 192:  
table.insert(self._data_rows, row_values)
 
table.insert(self._data_rows, row_values)
 
end
 
end
 +
end
 +
 +
function NodeInfo:process_resource_node(resource, amount)
 +
    --Amount may or may not be just numbers
 +
    local action, units, node_type, bg_color = "Gained", "", "Resource", self._resource_node_bg_color
 +
   
 +
    if mw.ustring.sub(amount, 1, 1) == "-" then
 +
        action = "Lost"
 +
        amount = mw.ustring.sub(amount, 2)
 +
        node_type = "Maelstrom"
 +
        bg_color = self._maelstrom_node_bg_color
 +
    end
 +
   
 +
    if mw.ustring.find(amount, " ") then
 +
        local split = mw.ustring.find(amount, " ")
 +
        units = mw.ustring.sub(amount, split + 1)
 +
        amount = mw.ustring.sub(amount, 1, split - 1)
 +
    end
 +
   
 +
    local text = action .. " " .. amount .. " " .. resource .. " " .. units
 +
    return text, node_type, bg_color
 
end
 
end
   Line 196: Line 222:  
table.insert(self._rows, self._header)
 
table.insert(self._rows, self._header)
 
elseif type(row_values) == "table" then
 
elseif type(row_values) == "table" then
 +
    local bg_color = "initial"
 
for _, column in ipairs(self._columns) do
 
for _, column in ipairs(self._columns) do
 +
    if column == "node" and row_values[column].bg_color ~= "initial" then
 +
        bg_color = row_values[column].bg_color
 +
    end
 +
    row_values[column].bg_color = bg_color
 
if row_values[column] then
 
if row_values[column] then
 
table.insert(self._rows, format(self._column_cell_templates[column] or self._cell, row_values[column]))
 
table.insert(self._rows, format(self._column_cell_templates[column] or self._cell, row_values[column]))
Line 211: Line 242:  
                local amount = mw.ustring.sub(resource, split + 1)
 
                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), size = "22x22px"}
 
                resource = Formatting:format_image{mw.ustring.sub(resource, 1, split - 1) .. ".png", caption = mw.ustring.sub(resource, 1, split - 1), size = "22x22px"}
                 table.insert(self._rows, format{self._resource_node_template, values = { node = node, amount = amount, resource = resource } })
+
                local text, node_type, bg_color = self:process_resource_node(resource, amount)
 +
                 table.insert(self._rows, format{self._resource_node_template, values = {
 +
                    node = node,
 +
                    text = text,
 +
                    node_type = node_type,
 +
                    bg_color = bg_color,
 +
                }})
 
            end
 
            end
 
    end
 
    end
48

edits

Navigation menu