|
|
Line 3: |
Line 3: |
| local p = {} | | local p = {} |
|
| |
|
| -- Main process
| |
| function p.main(frame) | | function p.main(frame) |
| local args = getArgs(frame); | | local args = getArgs(frame); |
|
| |
|
| -- Making life easier. | | local CHARACTER_ID = { |
| function inArgs(name)
| | Elsword = 1, |
| if (inArray(name, args)) then | | Aisha = 2, |
| return true
| | Rena = 3, |
| end | | Raven = 4, |
| end | | Eve = 5, |
| | Chung = 6, |
| | Ara = 7, |
| | Elesis = 8, |
| | Add = 9, |
| | LuCiel = 10, |
| | Rose = 11, |
| | Ain = 12, |
| | Laby = 13, |
| | Noah = 14, |
| | Lithia = 15 |
| | } |
|
| |
|
| local isForceNav = args.forcenav ~= nil; | | local character = args[1] |
| | local data = args[2] |
| | local isBase = not data or data == base; |
| | local pathIndex = "" |
| | local jobIndex = "" |
| | local transString = "" |
| | local link = args.link and (isBase and character or args.link) or "" |
| | local lang = args.link and args.lang and ("/" .. args.lang) or "" |
| | local scale = args.scale or 1 |
| | local id = CHARACTER_ID[character] |
| | local charId = string.len(id) == 1 and ("0" .. id) or id |
|
| |
|
| -- Prepare a table of skill types to display in the navigation.
| | if isBase then |
| local skill_types;
| | jobIndex = "NO_OCCUPATION" |
| if (not isForceNav) then | | elseif data ~= "base" then |
| skill_types = {{ | | local arr = split(data, "x"); |
| ['name'] = args.l_hyper, -- 'Hyper Active',
| | if not #arr then |
| ['abbr'] = 'HA'
| | arr[1] = data |
| }, {
| | end |
| ['name'] = args.l_secret, -- 'Secret Art',
| | pathIndex = arr[1] .. "LINE_" |
| ['abbr'] = 'SeA'
| | if string.find(pathIndex, "t") then |
| }, {
| | transString = "_T" |
| ['name'] = args.l_special, -- 'Special Active',
| | pathIndex = pathIndex:gsub("t", "") |
| ['abbr'] = 'SA'
| | arr[2] = "2" |
| }, {
| |
| ['name'] = args.l_active, -- 'Active',
| |
| ['abbr'] = 'A'
| |
| }, {
| |
| ['name'] = args.l_mod, -- 'Force Mod',
| |
| ['abbr'] = 'FC'
| |
| }, {
| |
| ['name'] = args.l_buff, -- 'Buff',
| |
| ['abbr'] = 'B'
| |
| }, {
| |
| ['name'] = args.l_passive, -- 'Passive',
| |
| ['abbr'] = 'P'
| |
| }, {
| |
| ['name'] = args.l_demon, -- 'Manic Demon',
| |
| ['abbr'] = 'MD'
| |
| }, {
| |
| ['name'] = '[[File:ForceIcon.png|16px]] ' .. args.l_demon, -- 'Manic Demon',
| |
| ['abbr'] = 'MDF'
| |
| }, {
| |
| ['name'] = args.l_master, -- 'Master Skill',
| |
| ['abbr'] = 'MS'
| |
| }, {
| |
| ['name'] = args.l_couple, -- 'Couple Skill',
| |
| ['abbr'] = 'Wed'
| |
| }, {
| |
| ['name'] = args.l_row1, -- 'Row 1',
| |
| ['abbr'] = 'row1'
| |
| }, {
| |
| ['name'] = args.l_row2, -- 'Row 2',
| |
| ['abbr'] = 'row2'
| |
| }, {
| |
| ['name'] = args.l_row3, -- 'Row 3',
| |
| ['abbr'] = 'row3'
| |
| }, {
| |
| ['name'] = args.l_row4, -- 'Row 4',
| |
| ['abbr'] = 'row4'
| |
| }}
| |
| else | |
| -- Force Nav called, change skill types
| |
| skill_types = {{
| |
| ['name'] = args.l_force_active, -- 'Force Active',
| |
| ['abbr'] = 'FA3',
| |
| ['type'] = 'third'
| |
| }, {
| |
| ['name'] = args.l_force_passive, -- 'Force Passive',
| |
| ['abbr'] = 'FP3',
| |
| ['type'] = 'third'
| |
| }, {
| |
| ['name'] = args.l_force_active, -- 'Force Active',
| |
| ['abbr'] = 'FAM',
| |
| ['type'] = 'master'
| |
| }, {
| |
| ['name'] = args.l_force_passive, -- 'Force Passive',
| |
| ['abbr'] = 'FPM',
| |
| ['type'] = 'master'
| |
| }}
| |
| end
| |
| | |
| -- For backward compatibility. Do not remove until all pages are changed.
| |
| if (args.name == nil) then
| |
| args.name = args.Name;
| |
| end
| |
| | |
| -- Needed this to make a custom toggle.
| |
| local char_name_sanitized = '';
| |
| local char_name = args.name;
| |
| if (isForceNav and args.parent_name ~= nil) then
| |
| char_name = args.parent_name;
| |
| end
| |
| for w in char_name:gmatch("%w+") do
| |
| char_name_sanitized = char_name_sanitized .. w;
| |
| end
| |
| if (isForceNav and args.parent_name ~= nil) then
| |
| char_name_sanitized = 'ForceSkills-' .. char_name_sanitized; | |
| end
| |
| | |
| -- Main block
| |
| local skill_nav = mw.html.create('div'):addClass('skill-nav');
| |
| if (isForceNav) then
| |
| skill_nav:addClass('force-nav');
| |
| end
| |
| | |
| -- Header
| |
| local header = skill_nav:tag('div'):addClass('skill-nav-header');
| |
| local colors;
| |
| if (args.color ~= nil) then
| |
| colors = args.color; | |
| else
| |
| colors = frame:expandTemplate{
| |
| title = 'ColorSel',
| |
| args = {'Character', args.char}
| |
| };
| |
| end
| |
| | |
| -- Redirect to language subpages if provided.
| |
| local is_localized = args.lang ~= nil;
| |
| local lang_suffix = '';
| |
| if (is_localized) then
| |
| lang_suffix = '/' .. args.lang;
| |
| end
| |
| | |
| colors = colors:gsub('#', '#')
| |
|
| |
| header:css('background-color', colors);
| |
| | |
| if (args.is_guild ~= nil) then
| |
| header:css({
| |
| ['justify-content'] = 'center', | |
| ['background-color'] = colors
| |
| }); | |
| end
| |
|
| |
| if (not isForceNav and not args.is_guild) then
| |
| header:wikitext(frame:expandTemplate{
| |
| title = 'Face',
| |
| args = {
| |
| args.char,
| |
| args.pic,
| |
| link = args.name,
| |
| lang = lang_suffix,
| |
| scale = '0.85'
| |
| }
| |
| })
| |
| end
| |
| -- Header text with a link
| |
| if (args.l_name == nil) then
| |
| args.l_name = args.name; | |
| end
| |
| local headerText = header:tag('span'):addClass('skill-nav-title');
| |
| if (not isForceNav) then
| |
| headerText:wikitext('[[' .. args.name .. lang_suffix .. '|' .. args.l_name .. ']] - ' .. args.l_skills);
| |
| else
| |
| headerText:wikitext(args.name); | |
| end
| |
| | |
| -- Generate the navigation's body
| |
| local skill_nav_wrap = skill_nav:tag('div'):addClass('skill-nav-inner-wrap border-color')
| |
| if (args.type ~= nil) then
| |
| skill_nav_wrap:addClass(args.type);
| |
| end
| |
| -- Make it collapsible if needed.
| |
| if ((args.type ~= nil and string.find(args.type, 'mw%-collapsible') ~= nil) or args.collapsible ~= nil) then
| |
| skill_nav_wrap:attr('id', 'mw-customcollapsible-' .. char_name_sanitized);
| |
| header:tag('div'):addClass('mw-customtoggle-' .. char_name_sanitized);
| |
| end
| |
| if (args.collapsible ~= nil) then
| |
| skill_nav_wrap:addClass('mw-collapsible');
| |
| end
| |
| if (args.collapsed ~= nil) then
| |
| skill_nav_wrap:addClass('mw-collapsed');
| |
| end
| |
| | |
| -- Generate the navigation's body content.
| |
| for k2, v2 in spairs(skill_types) do
| |
| local name = v2['name'];
| |
| local abbr = v2['abbr'];
| |
| local type = v2['type'];
| |
| if (inArgs(abbr)) then
| |
| -- Syntax: [image.extension]; [name]; [image.extension]; [name]; (...) | |
| local skills = split(args[abbr], ';');
| |
| if (abbr == 'Wed') then
| |
| skills = {
| |
| 'RelationSkill1.png', 'Extreme Heavenly Love' .. lang_suffix .. '|' .. args.l_couple_skill_name,
| |
| 'RelationSkill2.png', 'Extreme Heavenly Bond' .. lang_suffix .. '|' .. args.l_soulmate_skill_name
| |
| }
| |
| end
| |
| -- Separate syntax for Master Skills: [Stage 1 image]; [Stage 2 image]; [Stage 3 image]; [Stage 4 image]; [skill name];
| |
| local mc_skill_name = '' | |
| local mc_skill_name_head = ''
| |
| if (abbr == 'MS') then
| |
| mc_skill_name = skills[5];
| |
| mc_skill_name = mc_skill_name:gsub('ä', 'a');
| |
| local l_mc_skill_name = skills[5];
| |
| if (args.l_mc_skill_name ~= nil and is_localized) then
| |
| l_mc_skill_name = args.l_mc_skill_name;
| |
| end
| |
| mc_skill_name_head = '<br/>- ' .. l_mc_skill_name;
| |
| skills[7] = skills[4];
| |
| skills[5] = skills[3];
| |
| skills[3] = skills[2];
| |
| skills[8] = mc_skill_name .. '/Stage 4' .. lang_suffix .. '|' .. args.l_stage .. ' 4';
| |
| skills[6] = mc_skill_name .. '/Stage 3' .. lang_suffix .. '|' .. args.l_stage .. ' 3';
| |
| skills[4] = mc_skill_name .. '/Stage 2' .. lang_suffix .. '|' .. args.l_stage .. ' 2';
| |
| skills[2] = mc_skill_name .. '/Stage 1' .. lang_suffix .. '|' .. args.l_stage .. ' 1';
| |
| end
| |
| local i = 1;
| |
| | |
| -- If Force Nav, append an extra header before "Force Active" if needed.
| |
| if (abbr == 'FA3' or abbr == 'FAM') then
| |
| local extra_head = skill_nav_wrap:tag('div'):addClass(
| |
| 'skill-nav-sub-head skill-nav-extra-head border-color tone-7 color-normal-force-link');
| |
| if (type == 'third') then
| |
| extra_head:wikitext('[[3rd Jobs' .. lang_suffix .. '|' .. args.l_third_job .. ']]');
| |
| elseif (type == 'master') then
| |
| extra_head:wikitext('[[Master Class' .. lang_suffix .. '|' .. args.l_master_class .. ']]');
| |
| end
| |
| end
| |
| | |
| -- Append header fields on the left.
| |
| skill_nav_wrap:tag('div'):addClass('skill-nav-sub-head border-color tone-4'):wikitext(name ..
| |
| mc_skill_name_head);
| |
| | |
| -- Get localized names
| |
| local l_display_names = nil;
| |
| if (abbr ~= 'MS' and args['l_' .. abbr] ~= nil) then
| |
| l_display_names = split(args['l_' .. abbr], ";");
| |
| end
| |
| | |
| -- Append skill fields on the right.
| |
| local content = skill_nav_wrap:tag('div'):addClass('skill-nav-skill-content border-color tone-6'); | |
| for k, v in pairs(skills) do
| |
| if v == nil then
| |
| return
| |
| end
| |
| -- Fetch skills every 2 table elements, since we don't want doubles.
| |
| if (i % 2 == 0) then
| |
| -- The display name of skills
| |
| local v_display_name = v;
| |
| if (is_localized and abbr ~= 'MS' and l_display_names ~= nil) then
| |
| v_display_name = l_display_names[i / 2];
| |
| end
| |
| -- Remove stuff like (Elesis) or (Elsword) in skill display name
| |
| v_display_name = v_display_name:gsub("%s%([%w%s%/]+%)", "");
| |
| | |
| -- Append the actual skills.
| |
| local skill_entry = content:tag('div'):addClass(
| |
| 'skill-nav-skill tone-7-hover color-normal-force-link tone-8-active');
| |
| local skill_icon = skill_entry:tag('div'):addClass('skill-nav-image')
| |
| if (abbr == 'FC' or abbr == 'MDF') then
| |
| -- [Mod] case
| |
| skill_entry:wikitext('[[' .. v .. '/ModA' .. lang_suffix .. '|' .. v_display_name .. ']]');
| |
| skill_icon:wikitext(frame:expandTemplate{
| |
| title = 'Force',
| |
| args = {
| |
| trim(skills[i - 1]), -- closest smaller odd element will be the icon
| |
| link = v,
| |
| language = args.lang,
| |
| size = '3'
| |
| }
| |
| });
| |
| else
| |
| -- Normal skill case
| |
| if (abbr == 'MS' or abbr == 'Wed') then
| |
| -- Master Skill/Wedding Skill case
| |
| skill_entry:wikitext('[[' .. v_display_name .. ']]');
| |
| else
| |
| skill_entry:wikitext('[[' .. v .. lang_suffix .. '|' .. v_display_name .. ']]');
| |
| end
| |
| | |
| skill_icon:wikitext('[[File:' .. trim(skills[i - 1]) .. '|30px|link= ' .. v .. lang_suffix ..
| |
| ']]');
| |
| end
| |
| end
| |
| i = i + 1;
| |
| end
| |
| end | | end |
| | jobIndex = arr[2] and ("0" .. arr[2]) or "" |
| end | | end |
|
| |
|
| -- Append the Force Skill Navigation if needed.
| | local image = mw.html.create('div'):addClass('image-cropped') |
| local force_nav = '' | | image:tag('div'):addClass('image-wrap image-face') |
| if (args.FS == 'true') then
| | :attr("style", "width: " .. 116 * scale .. "px; height: " .. 60 * scale .. "px;") |
| force_nav = frame:expandTemplate{
| | :wikitext("[[File:Character Face " .. charId .. "-FACE " .. pathIndex .. jobIndex .. transString .. ".png|link=" .. link .. lang .. "]]") |
| title = 'ForceSkillNav' .. lang_suffix,
| |
| args = {
| |
| type = 'mw-collapsible mw-collapsed',
| |
| char = colors,
| |
| Color = args.color,
| |
| parent_name = args.name
| |
| }
| |
| } | |
| end
| |
| | |
| -- Output point
| |
| return tostring(skill_nav) .. force_nav;
| |
|
| |
|
| | return tostring(image) |
| end | | end |
|
| |
|
| return p | | return p |