• 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
Add seasonal forms for gallery
Line 4: Line 4:  
local BaseData = require("Module:BaseData")
 
local BaseData = require("Module:BaseData")
 
local Ship = require("Module:Ship")
 
local Ship = require("Module:Ship")
 +
local ShipGraphicKai = require('Module:ShipGraphicKai')
    
-- [[Category:Todo]]: support passing Ship object in those modules, use Ship object, redo and move ship_remodel_forms function
 
-- [[Category:Todo]]: support passing Ship object in those modules, use Ship object, redo and move ship_remodel_forms function
Line 13: Line 14:  
local reversible_forms = {}
 
local reversible_forms = {}
   −
function ship_remodel_forms(ship_name, ship_suffix, j)
+
function ship_remodel_forms(ship_name, seasonal_forms, ship_suffix, j)
 
     j = j or 1
 
     j = j or 1
 
     ship_suffix = ship_suffix or ""
 
     ship_suffix = ship_suffix or ""
Line 22: Line 23:  
     end
 
     end
 
     local form_data = ship_data[ship_suffix]
 
     local form_data = ship_data[ship_suffix]
 +
    if seasonal_forms then
 +
        for suffix, data in pairs(ship_data) do
 +
            if data._seasonal == true and data._name and data._suffix then
 +
                table.insert(seasonal_forms, data._name .. "/" .. data._suffix)
 +
            end
 +
        end
 +
    end
 
     local i = 0
 
     local i = 0
 
     while form_data and form_data._remodel_to and not Utils.find(forms, form_data._remodel_to) and i < 10 and j <= 3 do
 
     while form_data and form_data._remodel_to and not Utils.find(forms, form_data._remodel_to) and i < 10 and j <= 3 do
 
         local ship_name_next, ship_suffix_next = Ship:process_ship_key(form_data._remodel_to)
 
         local ship_name_next, ship_suffix_next = Ship:process_ship_key(form_data._remodel_to)
 
         if ship_name_next ~= ship_name then
 
         if ship_name_next ~= ship_name then
             return Utils.concat(forms, ship_remodel_forms(ship_name_next, ship_suffix_next, j + 1))
+
             return Utils.concat(forms, ship_remodel_forms(ship_name_next, seasonal_forms, ship_suffix_next, j + 1))
 
         else
 
         else
 
             table.insert(forms, form_data._remodel_to)
 
             table.insert(forms, form_data._remodel_to)
Line 66: Line 74:     
     _gallery_tabber = [[{{#tag:tabber|
 
     _gallery_tabber = [[{{#tag:tabber|
{{!}}-{{!}}Normal={{ShipGraphicKai|${name}/${suffix}|link=nil|size=300px}}
+
{{!}}-{{!}}Normal=${image}
{{!}}-{{!}}Damaged={{ShipGraphicKai|${name}/${suffix}|link=nil|damaged=true|size=300px}}
+
{{!}}-{{!}}Damaged=${image_damaged}
 
}}]],
 
}}]],
   Line 167: Line 175:  
-- [[Category:Todo]]:
 
-- [[Category:Todo]]:
 
-- Ignore forms with same base and/or damaged CG (requires updating for data modules)
 
-- Ignore forms with same base and/or damaged CG (requires updating for data modules)
-- Seasonal forms
+
-- Improve performance by not using frame:preprocess?
-- Improve performance by not using preprocess, ShipGraphicKai, etc.
   
function ShipPage.GalleryTabber(frame, args)
 
function ShipPage.GalleryTabber(frame, args)
 
     args = args or Utils.getTemplateArgs(frame)
 
     args = args or Utils.getTemplateArgs(frame)
 
     local ship_name = args.explicit.ship or args.implicit.pagename or ""
 
     local ship_name = args.explicit.ship or args.implicit.pagename or ""
     local forms = ship_remodel_forms(ship_name)
+
    local seasonal_forms = {}
 +
     local forms = ship_remodel_forms(ship_name, seasonal_forms)
 
     local result = { "{{#tag:tabber|" }
 
     local result = { "{{#tag:tabber|" }
 
     for _, form in ipairs(forms) do
 
     for _, form in ipairs(forms) do
         local name, suffix = Ship:process_ship_key(form)
+
         local image = ShipGraphicKai:Asset({ form, link = "nil", size = "300px" })
 +
        local image_damaged = ShipGraphicKai:Asset({ form, link = "nil", damaged = true, size = "300px" })
 
         table.insert(result, suffix == "" and "{{!}}-{{!}}Base=" or ("{{!}}-{{!}}" .. suffix .. "="))
 
         table.insert(result, suffix == "" and "{{!}}-{{!}}Base=" or ("{{!}}-{{!}}" .. suffix .. "="))
         table.insert(result, format{ ShipPage._gallery_tabber, name = name, suffix = suffix })
+
         table.insert(result, format{
 +
            ShipPage._gallery_tabber,
 +
            image = image,
 +
            image_damaged = image_damaged
 +
        })
 +
    end
 +
    for _, form in ipairs(seasonal_forms) do
 +
        local image = ShipGraphicKai:Asset({ form, link = "nil", size = "300px" })
 +
        local image_damaged = ShipGraphicKai:Asset({ form, link = "nil", damaged = true, size = "300px" })
 +
        table.insert(result, "{{!}}-{{!}}" .. suffix .. "=")
 +
        table.insert(result, format{
 +
            ShipPage._gallery_tabber,
 +
            image = image,
 +
            image_damaged = image_damaged
 +
        })
 
     end
 
     end
 
     table.insert(result, "}}")
 
     table.insert(result, "}}")
cssedit, gkautomate
7,064

edits

Navigation menu