◆少前百科是非盈利性、非官方的少女前线维基百科。 ◆如果您发现某些内容错误/空缺,请勇于修正/添加!参与进来其实很容易!点这里 加入少前百科。 ◆有任何意见、建议、纠错,欢迎在 GFwiki:反馈与建议 提出和讨论。编辑事务讨论QQ群:597764980,微博@GFwiki少前百科 ◆To foreigners,You can use twitter to contact us. |
“Widget:Costume/js”的版本间的差异
(测试) |
|||
(未显示3个用户的39个中间版本) | |||
第2行: | 第2行: | ||
var picarr = []; | var picarr = []; | ||
− | <!--{if ($num1)}-->picarr.push({num:<!--{$num1}-->, doll:"<!--{$doll1}-->", name:"<!--{$name1}-->", line:"<!--{$line1}-->", pic0:"<!--{$ | + | <!--{if ($num1)}-->picarr.push({num:<!--{$num1}-->, doll:"<!--{$doll1}-->", code:"<!--{$code1}-->", name:"<!--{$name1}-->", line:"<!--{$line1}-->", pic0:"<!--{$pica1}-->", pic1:"<!--{$picb1}-->"});<!--{else}--><!--{/if}--> |
− | <!--{if ($num2)}-->picarr.push({num:<!--{$num2}-->, doll:"<!--{$doll2}-->", | + | <!--{if ($num2)}-->picarr.push({num:<!--{$num2}-->, doll:"<!--{$doll2}-->", code:"<!--{$code2}-->", name:"<!--{$name2}-->", line:"<!--{$line2}-->", pic0:"<!--{$pica2}-->", pic1:"<!--{$picb2}-->"});<!--{else}--><!--{/if}--> |
− | <!--{if ($num3)}-->picarr.push({num:<!--{$num3}-->, doll:"<!--{$doll3}-->", | + | <!--{if ($num3)}-->picarr.push({num:<!--{$num3}-->, doll:"<!--{$doll3}-->", code:"<!--{$code3}-->", name:"<!--{$name3}-->", line:"<!--{$line3}-->", pic0:"<!--{$pica3}-->", pic1:"<!--{$picb3}-->"});<!--{else}--><!--{/if}--> |
− | <!--{if ($num4)}-->picarr.push({num:<!--{$num4}-->, doll:"<!--{$doll4}-->", | + | <!--{if ($num4)}-->picarr.push({num:<!--{$num4}-->, doll:"<!--{$doll4}-->", code:"<!--{$code4}-->", name:"<!--{$name4}-->", line:"<!--{$line4}-->", pic0:"<!--{$pica4}-->", pic1:"<!--{$picb4}-->"});<!--{else}--><!--{/if}--> |
− | <!--{if ($num5)}-->picarr.push({num:<!--{$num5}-->, doll:"<!--{$doll5}-->", | + | <!--{if ($num5)}-->picarr.push({num:<!--{$num5}-->, doll:"<!--{$doll5}-->", code:"<!--{$code5}-->", name:"<!--{$name5}-->", line:"<!--{$line5}-->", pic0:"<!--{$pica5}-->", pic1:"<!--{$picb5}-->"});<!--{else}--><!--{/if}--> |
− | <!--{if ($num6)}-->picarr.push({num:<!--{$num6}-->, doll:"<!--{$doll6}-->", | + | <!--{if ($num6)}-->picarr.push({num:<!--{$num6}-->, doll:"<!--{$doll6}-->", code:"<!--{$code6}-->", name:"<!--{$name6}-->", line:"<!--{$line6}-->", pic0:"<!--{$pica6}-->", pic1:"<!--{$picb6}-->"});<!--{else}--><!--{/if}--> |
− | <!--{if ($num7)}-->picarr.push({num:<!--{$num7}-->, doll:"<!--{$doll7}-->", | + | <!--{if ($num7)}-->picarr.push({num:<!--{$num7}-->, doll:"<!--{$doll7}-->", code:"<!--{$code7}-->", name:"<!--{$name7}-->", line:"<!--{$line7}-->", pic0:"<!--{$pica7}-->", pic1:"<!--{$picb7}-->"});<!--{else}--><!--{/if}--> |
− | <!--{if ($num8)}-->picarr.push({num:<!--{$num8}-->, doll:"<!--{$doll8}-->", | + | <!--{if ($num8)}-->picarr.push({num:<!--{$num8}-->, doll:"<!--{$doll8}-->", code:"<!--{$code8}-->", name:"<!--{$name8}-->", line:"<!--{$line8}-->", pic0:"<!--{$pica8}-->", pic1:"<!--{$picb8}-->"});<!--{else}--><!--{/if}--> |
− | <!--{if ($num9)}-->picarr.push({num:<!--{$num9}-->, doll:"<!--{$doll9}-->", | + | <!--{if ($num9)}-->picarr.push({num:<!--{$num9}-->, doll:"<!--{$doll9}-->", code:"<!--{$code9}-->", name:"<!--{$name9}-->", line:"<!--{$line9}-->", pic0:"<!--{$pica9}-->", pic1:"<!--{$picb9}-->"});<!--{else}--><!--{/if}--> |
− | <!--{if ($num10)}-->picarr.push({num:<!--{$num10}-->, doll:"<!--{$doll10}-->", | + | <!--{if ($num10)}-->picarr.push({num:<!--{$num10}-->, doll:"<!--{$doll10}-->", code:"<!--{$code10}-->", name:"<!--{$name10}-->", line:"<!--{$line10}-->", pic0:"<!--{$pica10}-->", pic1:"<!--{$picb10}-->"});<!--{else}--><!--{/if}--> |
− | <!--{if ($num11)}-->picarr.push({num:<!--{$num11}-->, doll:"<!--{$doll11}-->", name:"<!--{$name11}-->", line:"<!--{$line11}-->", pic0:"<!--{$pica11}-->", pic1:"<!--{$picb11}-->"});<!--{else}--><!--{/if}--> | + | <!--{if ($num11)}-->picarr.push({num:<!--{$num11}-->, doll:"<!--{$doll11}-->", code:"<!--{$code11}-->", name:"<!--{$name11}-->", line:"<!--{$line11}-->", pic0:"<!--{$pica11}-->", pic1:"<!--{$picb11}-->"});<!--{else}--><!--{/if}--> |
− | <!--{if ($num12)}-->picarr.push({num:<!--{$num12}-->, doll:"<!--{$doll12}-->", name:"<!--{$name12}-->", line:"<!--{$line12}-->", pic0:"<!--{$pica12}-->", pic1:"<!--{$picb12}-->"});<!--{else}--><!--{/if}--> | + | <!--{if ($num12)}-->picarr.push({num:<!--{$num12}-->, doll:"<!--{$doll12}-->", code:"<!--{$code12}-->", name:"<!--{$name12}-->", line:"<!--{$line12}-->", pic0:"<!--{$pica12}-->", pic1:"<!--{$picb12}-->"});<!--{else}--><!--{/if}--> |
− | + | let height = window.innerHeight; | |
− | + | let width = window.innerWidth; | |
+ | if(width > height) $("#suitdiv").height(height - 40); | ||
+ | if(width > height) $("#skinImgDiv").width(height - 40); | ||
+ | else{ $("#skinImgDiv").width(width - 40); $("#skinImgDiv").height(width - 40);} | ||
− | + | var picState = 0; // 0:正常 1:重创 | |
− | loadcreat( | + | var picIndex = 0; // 当前选择的立绘Index |
− | function loadcreat( | + | |
+ | loadcreat(); | ||
+ | function loadcreat(){ | ||
for(let i = 0; i < picarr.length; i++){ | for(let i = 0; i < picarr.length; i++){ | ||
− | var img = new Image(); | + | for(j in ["pic0", "pic1"]){ |
− | + | var img = new Image(); | |
− | + | $(img).load(function(){$(this).remove();}); | |
− | + | $(img).attr({"src":picarr[i][["pic0", "pic1"][j]]}); | |
− | + | } | |
− | |||
− | |||
− | |||
− | |||
} | } | ||
} | } | ||
− | + | // 人形装扮选择序列的DOM创建 | |
− | + | var skinNameDiv = document.querySelectorAll(".skinname"); | |
− | + | for(let i = 0; i < skinNameDiv.length; i++){ | |
− | + | let text = `<div class="skinnamedoll">` + picarr[i].doll + `<\/div><div class="skinnameskin">` + picarr[i].name + `<\/div>`; | |
− | + | $(skinNameDiv[i]).html(text); | |
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | + | var picnDiv = document.querySelectorAll(".picndiv"); | |
− | + | for(let i = 0; i < picnDiv.length; i++) $(picnDiv[i]).attr("index", i); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | $(" | + | $(".picndiv").click(function(){ |
− | + | $("img.picn").css("border-top", "4px solid #eaeaea"); | |
− | + | $(this).children("img.picn").css("border-top", "4px solid #f4c430"); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | $(" | + | $(".picndiv").children(".skinname").css({"background-color":"#1a1a1a"}); |
− | + | $(".picndiv").children(".skinname").children("div").css({"color":"#eaeaea"}); | |
− | + | $(this).children(".skinname").css({"background-color":"#f4c430"}); | |
− | + | $(this).children(".skinname").children("div").css({"color":"#000000"}); | |
− | $( | + | picIndex = $(this).attr("index"); |
− | $( | + | skinChange(Number($(this).attr("index"))); |
}); | }); | ||
− | $( | + | $(picnDiv[0]).click(); |
− | + | ||
− | let | + | $("#thepic").click(function(event){ |
− | + | let relative_x = event.offsetX; | |
+ | let pic_width = $(this).width(); | ||
− | + | if(relative_x < pic_width / 4) skinPrev(); | |
− | + | else if(relative_x > pic_width / 4 * 3) skinNext(); | |
− | + | else skinStateSwitch(); | |
− | |||
− | |||
− | else | ||
}); | }); | ||
− | // | + | // 装扮切换的函数 分别处理立绘、spine、人形、装扮名称、台词 |
− | + | function skinNext(){ | |
− | + | let nextNum = Number(picIndex) + 1; | |
− | $( | + | if(picIndex >= picarr.length - 1) nextNum = 0; |
+ | $(picnDiv[nextNum]).click(); | ||
} | } | ||
− | + | function skinPrev(){ | |
− | + | let prevNum = picIndex - 1; | |
− | + | if(picIndex <= 0) prevNum = picarr.length - 1; | |
− | $( | + | $(picnDiv[prevNum]).click(); |
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | function skinStateSwitch(){ | |
− | + | picState = (picState) ? 0 : 1; | |
+ | skinChange("skinStateSwitch"); | ||
+ | } | ||
− | + | function skinChange(mode){ | |
− | + | picChange(); | |
− | + | if(mode != "skinStateSwitch")spineChange(); | |
− | + | if(mode != "skinStateSwitch")$("#skininfodoll").html(picarr[picIndex].doll); | |
− | + | if(mode != "skinStateSwitch")$("#skininfoname").html(picarr[picIndex].name); | |
− | + | if(mode != "skinStateSwitch")$("#skindollline").html(picarr[picIndex].line); | |
− | + | } | |
− | |||
− | |||
− | + | function picChange(){ | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | function | ||
$("#thepic").fadeOut(60); | $("#thepic").fadeOut(60); | ||
setTimeout(function(){ | setTimeout(function(){ | ||
− | if( | + | if(picState == 0) $("#thepic").attr("src", picarr[picIndex].pic0); |
− | else $("#thepic").attr("src", picarr[ | + | else $("#thepic").attr("src", picarr[picIndex].pic1); |
setTimeout(function(){ | setTimeout(function(){ | ||
$("#thepic").fadeIn(60); | $("#thepic").fadeIn(60); | ||
第160行: | 第104行: | ||
}, 60); | }, 60); | ||
} | } | ||
− | function | + | |
+ | function spineChange(){ | ||
$("#spineSkinBox").children("canvas").fadeOut(100); | $("#spineSkinBox").children("canvas").fadeOut(100); | ||
setTimeout(function(){ | setTimeout(function(){ | ||
− | ($(".chibi-costume-switcher").children("option"))[ | + | ($(".chibi-costume-switcher").children("option"))[picIndex].selected = true; |
swap_costume($(".chibi-costume-switcher"), 'spineSkinBox'); | swap_costume($(".chibi-costume-switcher"), 'spineSkinBox'); | ||
$("#spineSkinBox").children("canvas").fadeIn(100); | $("#spineSkinBox").children("canvas").fadeIn(100); | ||
第169行: | 第114行: | ||
} | } | ||
− | // | + | // spine的DOM创建 黑盒 |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
let html_str = `<select class="chibi-costume-switcher" autocomplete="off" onchange="swap_costume(this)" style="display:none;">`; | let html_str = `<select class="chibi-costume-switcher" autocomplete="off" onchange="swap_costume(this)" style="display:none;">`; | ||
− | html_str += `<option selected="selected" value="` + picarr[0].num + `" data-tdoll="` + picarr[0]. | + | html_str += `<option selected="selected" value="` + picarr[0].num + `" data-tdoll="` + picarr[0].code + `"></option>`; |
− | for(let i = 1; i < picarr.length; i ++) | + | for(let i = 1; i < picarr.length; i ++) html_str += `<option value="` + picarr[i].num + `" data-tdoll="` + picarr[i].code + `"></option>`; |
− | |||
− | |||
html_str += `</select>`; | html_str += `</select>`; | ||
第237行: | 第159行: | ||
$(".chibiAnimationContainer").attr('data-tdoll-id', tdollId); | $(".chibiAnimationContainer").attr('data-tdoll-id', tdollId); | ||
$(".chibiAnimationContainer").attr('data-tdoll-costume', chibiCostumeName); | $(".chibiAnimationContainer").attr('data-tdoll-costume', chibiCostumeName); | ||
− | $(".chibiAnimationContainer").find('.chibiAnimation').trigger("costume_changed", [chibiCostumeName | + | $(".chibiAnimationContainer").find('.chibiAnimation').trigger("costume_changed", [chibiCostumeName , tdollId]); |
+ | if($(".chibiAnimationContainer").children('.chibiDormButton').hasClass('stateon')) { | ||
+ | var currentDormButton = $(".chibiAnimationContainer").children('.chibiDormButton'); | ||
+ | var futureEnabledState = currentDormButton.hasClass('stateoff'); | ||
+ | if(futureEnabledState) { | ||
+ | currentDormButton.addClass('stateon'); | ||
+ | currentDormButton.removeClass('stateoff'); | ||
+ | } else { | ||
+ | currentDormButton.removeClass('stateon'); | ||
+ | currentDormButton.addClass('stateoff'); | ||
+ | } | ||
+ | } | ||
var costumeId = tdollId + chibiCostumeName; | var costumeId = tdollId + chibiCostumeName; | ||
var cpp = window.gfUtils.createWikiPathPart; | var cpp = window.gfUtils.createWikiPathPart; | ||
第245行: | 第178行: | ||
$(".tdoll_chibi>img,.chibiAnimationContainer>img").attr("src", chibiPath); | $(".tdoll_chibi>img,.chibiAnimationContainer>img").attr("src", chibiPath); | ||
} | } | ||
− | |||
}) | }) | ||
</script></includeonly> | </script></includeonly> |