微件:ScenarioSimulator:修订间差异
跳转到导航
跳转到搜索
小无编辑摘要 |
(Update by bot.) |
||
第1行: | 第1行: | ||
<noinclude>{{#Widget:ScenarioSimulator|data_txt={{用户:Krliov/ | <noinclude>{{Cbox2|title=提示|lv=0|icon=edit|text=如果您需要了解这个小部件的更新日志,请查看[[User:Krliov/ScenarioSimulator_Update_Log|剧情模拟器更新日志]]}}{{#Widget:ScenarioSimulator|data_txt={{用户:Krliov/datapage1}}|data_back={{Widget:Data_Image}}|data_char={{Widget:Data_Char}}|data_audio={{Widget:Data_Audio}}|data_override={{Widget:Data_Override}}|data_link={{Widget:Data_Link}}|data_name={{DrName}}}}</noinclude><includeonly><div class="common_style" id="sys_fullscreen"><div id="sys_offset"> | ||
<includeonly> | <div id="sys_main"> | ||
<div id=" | <div class="common_style" id="sys_camera"> | ||
<div class="common_style" id="sys_back"></div> | |||
<div class="common_style" id="sys_char"></div> | |||
<div class="common_style" id="sys_cutin"></div> | |||
<div class="common_style" id="sys_item"></div> | |||
<div class="common_style" id="sys_image"></div> | |||
<div class="common_style" id="sys_animation"></div> | |||
<div class=" | |||
</div> | </div> | ||
<div id=" | <div class="common_style" id="sys_blocker"></div> | ||
<div class="common_style" id="sys_masker"></div> | |||
<div class=" | <div class="common_style" id="sys_subtitle"></div> | ||
<div id="sys_dialog"> | |||
<div class="dialog_style header"></div> | |||
<div class="dialog_style footer"> | |||
<div class="name"><span id="dialog_name">剧情模拟器</span></div> | |||
<div class="content"><span id="dialog_output">页面载入中...<br/><s>少女折寿中...</s> :3</span></div> | |||
</div> | |||
</div> | </div> | ||
<div id=" | <div class="common_style" id="sys_clicker"></div> | ||
<div class="common_style hidden" id="sys_decision"></div> | |||
<div class=" | <div class="button_style right forbid" id="button_auto">自动▶</div> | ||
<div class="button_style right forbid" id="button_reset">重置▶</div> | |||
<div class="button_style left normal" id="button_playback"></div> | |||
<div class="button_style left normal hidden" id="button_fullscreen"></div> | |||
<div class="button_style left normal hidden" id="button_playback_all"></div> | |||
<div class="button_style left normal hidden nomobile" id="button_report"> | |||
<div class="report common hidden"> | |||
<h4>报告错误</h4> | |||
<label>已自动收集的信息:</label> | |||
<textarea class="playback_common" id="report_collected" disabled placeholder="display collected data."></textarea> | |||
<label>留言备注:</label> | |||
<textarea class="playback_common" id="report_note" placeholder="必填。请在此附上您需要补充的信息"></textarea> | |||
<button type="submit" id="report_submit">提交</button> | |||
<svg viewBox="0 0 1024 1024" width="15" height="15"> | |||
<path d="M523.085935 101.849403m-101.850403 0a101.850403 101.850403 0 1 0 203.700806 0 101.850403 101.850403 0 1 0-203.700806 0Z"></path> | |||
<path d="M769.836489 187.508901m-96.031437 0a96.031437 96.031437 0 1 0 192.062875 0 96.031437 96.031437 0 1 0-192.062875 0Z"></path> | |||
<path d="M903.286707 381.395765m-90.210471 0a90.210471 90.210471 0 1 0 180.420943 0 90.210471 90.210471 0 1 0-180.420943 0Z"></path> | |||
<path d="M905.950692 609.722427m-84.390506 0a84.390506 84.390506 0 1 0 168.781011 0 84.390506 84.390506 0 1 0-168.781011 0Z"></path> | |||
<path d="M799.997313 786.127394m-78.57054 0a78.57054 78.57054 0 1 0 157.141079 0 78.57054 78.57054 0 1 0-157.141079 0Z"></path> | |||
<path d="M605.196454 889.708787m-72.750574 0a72.750574 72.750574 0 1 0 145.501148 0 72.750574 72.750574 0 1 0-145.501148 0Z"></path> | |||
<path d="M397.148673 877.857856m-66.931608 0a66.931608 66.931608 0 1 0 133.863216 0 66.931608 66.931608 0 1 0-133.863216 0Z"></path> | |||
<path d="M223.665689 762.483532m-61.110641 0a61.110642 61.110642 0 1 0 122.221283 0 61.110642 61.110642 0 1 0-122.221283 0Z"></path> | |||
<path d="M134.483212 587.14856m-55.290676 0a55.290676 55.290676 0 1 0 110.581352 0 55.290676 55.290676 0 1 0-110.581352 0Z"></path> | |||
<path d="M135.396207 408.896604m-49.47071 0a49.47071 49.47071 0 1 0 98.94142 0 49.47071 49.47071 0 1 0-98.94142 0Z"></path> | |||
<path d="M205.336797 260.047476m-43.650744 0a43.650744 43.650744 0 1 0 87.301488 0 43.650744 43.650744 0 1 0-87.301488 0Z"></path> | |||
<path d="M315.81515 159.990063m-37.829779 0a37.829778 37.829778 0 1 0 75.659557 0 37.829778 37.829778 0 1 0-75.659557 0Z"></path> | |||
</svg> | |||
<button type="button" id="report_cancel">取消</button> | |||
</div> | |||
</div> | |||
<div class="common_style playback_common hidden" id="sys_playback"> | |||
<ul class="log_style" id="playback_result"></ul> | |||
</div> | |||
<div class="common_style playback_common hidden" id="sys_playback_all"> | |||
<ul class="log_style" id="playback_all_result"></ul> | |||
</div> | </div> | ||
</div> | </div> | ||
</div></div> | |||
<div id="sys_audio" style="display:none;"></div> | |||
<link rel="stylesheet" type="text/css" href="https://static.prts.wiki/assets/scenario/arknights-scenario.css"> | |||
<script type="csv" id="datas_txt"><!--{$data_txt|regex_replace:"/<?script/":""}--></script> | |||
<script type="csv" id="datas_back" class="navigation-not-searchable"><!--{$data_back|regex_replace:"/<?script/":""}--></script> | |||
<script type="csv" id="datas_char" class="navigation-not-searchable"><!--{$data_char|regex_replace:"/<?script/":""}--></script> | |||
<script type="json" id="datas_audio" class="navigation-not-searchable"><!--{$data_audio|regex_replace:"/<?script/":""}--></script> | |||
<script type="json" id="datas_link" class="navigation-not-searchable"><!--{$data_link|regex_replace:"/<?script/":""}--></script> | |||
<script type="csv" id="datas_override" class="navigation-not-searchable"><!--{$data_override|regex_replace:"/<?script/":""}--></script> | |||
< | |||
// | |||
} | |||
</ | |||
<script type="csv" id=" | |||
<script type=" | |||
<script type=" | |||
<script type="csv" id=" | |||
<script | |||
<script src="https://s3.pstatp.com/cdn/expire-1-M/PreloadJS/1.0.1/preloadjs.min.js" type="application/javascript"></script> | <script src="https://s3.pstatp.com/cdn/expire-1-M/PreloadJS/1.0.1/preloadjs.min.js" type="application/javascript"></script> | ||
<script | <script src="https://static.prts.wiki/assets/scenario/krliov.toolbox.js" type="application/javascript"></script> | ||
<script class="navigation-not-searchable"> | |||
function Timer(){this.list = {};} | |||
/** | |||
* n=name,f=function,t=delay,p=isinterval | |||
* @param {string} n 名称,即标识符 | |||
* @param {function} f 需要执行的函数体 | |||
* @param {number} t 等待时间/循环时间 | |||
* @param {boolean} p 是否为循环的定时器 | |||
* @return {boolean} 创建成功返回true,否则为false | |||
*/ | |||
Timer.prototype.create = function(n,f,t=1000,p=false) | |||
// | |||
} | |||
} | |||
{ | |||
{ | { | ||
var | var obj = {},self = this; | ||
self.clear(n,true); | |||
if(typeof(n) !== "string" || typeof(f) !== 'function' || Number.isNaN(+t)) return false; | |||
obj.delegate = f; | |||
obj.interval = p; | |||
if(p){ | |||
obj.id = setInterval(function(){ | |||
obj.delegate(); | |||
},+t); | |||
} | |||
else{ | |||
obj.trigger = false; | |||
obj.id = setTimeout(function(){ | |||
obj.delegate(); | |||
obj.trigger = true; | |||
self.clear(n); | |||
},+t); | |||
} | |||
self.list[n] = obj; | |||
return true; | |||
} | } | ||
} | /** | ||
* @param {string} n 名称,标识符 | |||
{ | * @param {boolean} s 是否需要在移除时执行未执行的函数 | ||
* @return {boolean} 移除成功返回true,否则为false | |||
*/ | |||
Timer.prototype.clear = function(n,s = false) | |||
{ | { | ||
var | var self = this; | ||
if(!self.isTimer(n)) return false; | |||
let o = self.list[n]; | |||
if(s && !o.trigger && typeof(o.delegate) === "function"){ | |||
o.delegate(); | |||
} | |||
if(o.id){ | |||
if(o.interval) clearInterval(o.id); | |||
else clearTimeout(o.id); | |||
} | |||
delete self.list[n]; | |||
return true; | |||
} | } | ||
Timer.prototype.clearAll = function () { | |||
var self = this; | |||
for(var n in self.list) | |||
{ | |||
var o = self.list[n]; | |||
if(o.interval) clearInterval(o.id); | |||
else clearTimeout(o.id); | |||
} | |||
self.list = {}; | |||
} | } | ||
/** | |||
* @param {string} n 名称,标识符 | |||
* @return {boolean} 存在时返回true,否则为false | |||
*/ | |||
return; | Timer.prototype.hasTimer = function (n) { | ||
var self = this; | |||
return self.list[n]; | |||
} | } | ||
/** | |||
* @param {string} n 名称,标识符 | |||
* @return {boolean} 为Timer时返回true,否则为false | |||
*/ | |||
Timer.prototype.isTimer = function (n) { | |||
var self = this; | |||
return self.hasTimer(n) && !self.isFake(n); | |||
} | } | ||
/** | |||
* @param {string} n 名称,标识符 | |||
* @return {boolean} 设定成功后返回true,否则为false | |||
*/ | |||
Timer.prototype.setFake = function (n) { | |||
var self = this; | |||
if(self.isTimer(n)) return false; | |||
self.list[n] = -1; | |||
return true; | |||
} | } | ||
/** | |||
* @param {string} n 名称,标识符 | |||
* @return {boolean} 移除成功后返回true,否则为false | |||
*/ | |||
Timer.prototype.removeFake = function (n) { | |||
var self = this; | |||
if(!self.isFake(n)) return false; | |||
delete self.list[n]; | |||
return true; | |||
} | } | ||
/** | |||
* @param {string} n 名称,标识符 | |||
* @return {boolean} 确定为伪造的timer时返回true,否则为false | |||
*/ | |||
Timer.prototype.isFake = function (n) { | |||
var self = this; | |||
return self.list[n] === -1; | |||
} | } | ||
function DeepCopy(k){ | |||
function arrCopy(k2){ | |||
var arr = []; | |||
for(var e of k2) arr.push(typeof e === "object" ? DeepCopy(e) : e); | |||
return; | return arr; | ||
} | |||
function objCopy(k2){ | |||
var obj = {}; | |||
for(var d of Object.entries(k2)) obj[d[0]] = typeof d[1] === "object" ? DeepCopy(d) : d[1]; | |||
return obj; | |||
} | |||
return Array.isArray(k) ? arrCopy(k) : objCopy(k); | |||
} | } | ||
function SetCookie(name,value,options){ | |||
var t = new Date(); | |||
var m = options.expires ? options.expires.match(/^(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/i) : []; | |||
function | var res = []; | ||
{ | if(m){ | ||
t.setTime(t.getTime()+(((((m[1] || 0)*24+(m[2] || 0)*1)*60+(m[3] || 0)*1)*60+(m[4] || 0)*1)*1000)); | |||
// | res.push("expire="+t.toUTCString()); | ||
fun_msg(3,false,"cool down: "+t.toUTCString()); | |||
} | } | ||
if( | if(options.path){ | ||
res.push("path="+options.path); | |||
} | } | ||
if(options.domain){ | |||
res.push("domain="+options.domain); | |||
} | } | ||
document.cookie = name + "=" + value + ";" + res.join(";"); | |||
document. | |||
} | } | ||
function GetCookie(name){ | |||
var cook = document.cookie; | |||
var arr = cook.split(';'); | |||
for(var d of arr){ | |||
var str = d.trim(); | |||
if(str.startsWith(name)){ | |||
return str.substring(name.length+1); | |||
if( | |||
} | } | ||
} | } | ||
return null; | |||
} | } | ||
function RemoveCookie(name,options){ | |||
var res = ["expires=Thu, 01 Jan 1970 00:00:00 GMT"]; | |||
if(options.path){ | |||
{ | res.push("path="+options.path); | ||
} | } | ||
if(options.domain){ | |||
res.push("domain="+options.domain); | |||
} | } | ||
document.cookie = name + "=" + ";" + res.join(";"); | |||
} | } | ||
</script> | |||
<script class="navigation-not-searchable"> | |||
var AnaRes = {dynamic:0,skip:-2,error:-1,next:1,wait:2}; | |||
function txt_analyze(txt) | |||
function | |||
{ | { | ||
if( | let imgs = data.back,chars = data.char,mtpy = pos_multiply; | ||
if(!txt || txt.match("^\\s+$") || txt.match("^\\s*//.*$")) /* ONLY SPACE REGEX|COMMENT REGEX */ | |||
{ | { | ||
return - | return -2; | ||
} | } | ||
let match = txt.match("^\\[\\s*(?:(.*?)\\((.*)\\)|(?:([\\.|\\w]*)|(.*)))\\s*\\]\\s*(.*)"); /* COMMAND REGEX */ | |||
{ | let temp = {}; | ||
return | if (match == null && !system.decision.mode){ | ||
system.multi.check(); | |||
system.txt.dynamic = document.getElementById("dialog_output"); | |||
system.txt.name = ""; | |||
system.txt.now = fun_txt_format(txt); | |||
fun_playback("@p",""); | |||
document.getElementById("dialog_name").setClear(); | |||
document.getElementById("sys_dialog").show(); | |||
return 0; | |||
} | } | ||
else if(system.decision.mode){ | |||
temp.d1 = match == undefined ? "" : match[1] == undefined ? "" : match[1].toLowerCase(); | |||
temp.d2 = match == undefined ? "" : match[3] == undefined ? "" : match[3].toLowerCase(); | |||
if(temp.d1 != 'predicate' && temp.d2 != 'predicate') return -2; | |||
} | } | ||
if ( | if (match[1]){ | ||
let m1 = match[1].toLowerCase(); | |||
let cmd_set = match[2].toObject(); | |||
let sets = cmd_set; | |||
switch (m1) | |||
{ | { | ||
case 'background': | |||
temp.o1 = $("#sys_back"); | |||
temp.o1.children().stop(true,true); | |||
temp.t = cmd_set.fadetime ? +cmd_set.fadetime : 0.15; | |||
temp.c1 = temp.o1.children('div').length; | |||
case ' | temp.n = cmd_set.image ? "bg_" + cmd_set.image.toLowerCase() : ""; | ||
return -1; | if(!temp.n){ | ||
case ' | if(temp.t > 0){ | ||
temp.o1.children('div').fadeToExit(temp.t*1000); | |||
if(cmd_set.block == "true"){ | |||
if( | fun_delay("block",temp.t); | ||
return 2; | |||
} | |||
} | |||
else temp.o1.empty(); | |||
break; | |||
} | |||
temp.e1 = document.createElement('div'); | |||
temp.o1.append(temp.e1); | |||
temp.e1 = $(temp.e1); | |||
temp.sx = cmd_set.xscale || cmd_set.width || 1; | |||
temp.sy = cmd_set.yscale || cmd_set.height || 1; | |||
temp.px = (cmd_set.x && cmd_set.x*mtpy) || 0; | |||
temp.py = (cmd_set.y && cmd_set.y*mtpy) || 0; | |||
if(!imgs[temp.n]){ | |||
fun_msg(-2,false,"<Background>Data ["+temp.n+"] not exist,please check the data list."); | |||
return -1; | |||
} | |||
temp.sx*=1.2,temp.sy*=1.2;/* temp parameter */ | |||
temp.i1 = new Image(); | |||
temp.i1.src = imgs[temp.n]; | |||
temp.tsx = temp.i1.width*0.75;temp.tsy = temp.i1.height*0.75; | |||
cmd_set.screenadapt = "coverall"; | |||
temp.e1.attr("d-adapt",cmd_set.screenadapt); | |||
temp.i1.onload = function(){ | |||
var w = this.width*0.75,h = this.height*0.75; | |||
var obj = $("#sys_back").children(':last'); | |||
if(obj.attr("d-adapt") == "coverall"){ | |||
var sx = w / 960,sy = h / 540; | |||
var s = Math.min(sx,sy); | |||
w /= s;h /= s; | |||
} | |||
var x = 480 - w/2,y = 270 - h/2; | |||
obj.css({"width":w,"height":h,"left":x,"top":y,"background-size":w+"px "+h+"px","background-image":"url("+this.src+")"}); | |||
} | |||
temp.e1.css({"position":"absolute","transform":`matrix(${temp.sx},0,0,${temp.sy},${temp.px},${-temp.py})`}); | |||
temp.e1.hide().fadeIn(temp.t*1000,()=>{ | |||
temp.o1.children('div:lt('+temp.c1+')').remove(); | |||
}); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'backgroundtween': | |||
temp.o1 = $("#sys_back").children("div:last"); | |||
if(temp.o1.length == 0) return -1; | |||
/* temp.n = (cmd_set.image && imgs["bg_" + cmd_set.image.toLowerCase()]) || fun_get_url(temp.o1.css("backgroundImage")) || ""; */ | |||
temp.t = cmd_set.duration || 0.15; | |||
/* if(temp.n == "") return -1; */ | |||
/* temp.o1.css("backgroundImage","url('"+temp.n+"')"); */ | |||
temp.p = temp.o1.css("transform").replace(/\s/g,"").match(/^[a-z]+\((.*)\)/); | |||
temp.p = temp.p == null ? [1,0,0,1,0,0] : temp.p[1].split(','); | |||
temp.sxf = cmd_set.xscalefrom || cmd_set.xscale || temp.p[0]; | |||
temp.sxt = cmd_set.xscaleto || cmd_set.xscale || temp.p[0]; | |||
temp.syf = cmd_set.yscalefrom || cmd_set.yscale || temp.p[3]; | |||
temp.syt = cmd_set.yscaleto || cmd_set.yscale || temp.p[3]; | |||
temp.pxf = cmd_set.xfrom ? cmd_set.xfrom*0.75 : cmd_set.x ? cmd_set.x*0.75 : temp.p[4]; | |||
temp.pxt = cmd_set.xto ? cmd_set.xto*0.75 : cmd_set.x ? cmd_set.x*0.75 : temp.p[4]; | |||
temp.pyf = cmd_set.yfrom ? cmd_set.yfrom*0.75 : cmd_set.y ? cmd_set.y*0.75 : -temp.p[5]; | |||
temp.pyt = cmd_set.yto ? cmd_set.yto*0.75 : cmd_set.y ? cmd_set.y*0.75 : -temp.p[5]; | |||
temp.pyf = -temp.pyf;temp.pyt = -temp.pyt; | |||
temp.o1.css("transition","").css("transform","matrix("+temp.sxf+",0,0,"+temp.syf+","+temp.pxf+","+temp.pyf+")"); | |||
timer.create("back_tween",()=>{temp.o1.css("transition","transform "+temp.t + "s linear").css("transform","matrix("+temp.sxt+",0,0,"+temp.syt+","+temp.pxt+","+temp.pyt+")");},20); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'blocker': | |||
temp.t = cmd_set.fadetime == undefined ? 0.2 : cmd_set.fadetime;/* 默认12帧过渡时间 */ | |||
temp.d1 = cmd_set.a == undefined ? 1 : +cmd_set.a; | |||
temp.d2 = cmd_set.r == undefined ? 0 : +cmd_set.r; | |||
temp.d3 = cmd_set.g == undefined ? 0 : +cmd_set.g; | |||
temp.d4 = cmd_set.b == undefined ? 0 : +cmd_set.b; | |||
if(temp.d1 > 1) temp.d1 = 1;/* 闲着没事的以防万一 */ | |||
temp.o1 = $("#sys_blocker"); | |||
if(cmd_set.image){ | |||
temp.d1 = Math.max(0,1-temp.d1); | |||
} | |||
temp.o1.stop(true).css("transition","background-color "+temp.t+"s linear").css("background-color",fun_cal_rgba(temp.d2,temp.d3,temp.d4,temp.d1)); | |||
temp.o1.css("background-image",cmd_set.image ? "url('"+imgs[cmd_set.image]+"')" : ""); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'cameraeffect': | |||
temp.d1 = cmd_set.effect == undefined ? "" : cmd_set.effect.toLowerCase(); | |||
temp.d2 = cmd_set.amount == undefined ? 0 : cmd_set.amount; | |||
temp.t = cmd_set.fadetime == undefined ? -1 : +cmd_set.fadetime; | |||
temp.o1 = $("#sys_camera"); | |||
if(temp.t > 0){ | |||
temp.o1.css("transition","filter "+temp.t+"s linear"); | |||
timer.create("cmreff_w",()=>{ | |||
temp.o1.css("transition",""); | |||
},temp.t*1000); | |||
} | |||
if(temp.d2 == 0){ | |||
temp.o1.css("filter",""); | |||
return 1; | |||
} | |||
switch(temp.d1){ | |||
case 'grayscale': | |||
temp.o1.css("filter","grayscale("+temp.d2+")"); | |||
break; | |||
default: | |||
temp.o1.css("filter",""); | |||
break; | |||
} | |||
break; | |||
case 'camerashake': | |||
temp.t = cmd_set.duration == undefined ? -1 : +cmd_set.duration; | |||
temp.strx = cmd_set.xstrength == undefined ? 0 : cmd_set.xstrength * 0.75; | |||
temp.stry = cmd_set.ystrength == undefined ? 0 : cmd_set.ystrength * 0.75; | |||
temp.rnd = cmd_set.randomness == undefined ? 90 : +cmd_set.randomness; | |||
temp.v = cmd_set.vibrato == undefined ? 30 : +cmd_set.vibrato; | |||
timer.clear("shake"); | |||
temp.o1 = $("#sys_camera"); | |||
temp.o1.css({left:0,top:0}); | |||
if(cmd_set.stop == "true"){ | |||
temp.o1.removeAttr("d-sh-n"); | |||
temp.o1.removeAttr("d-sh-t"); | |||
return 1; | |||
} | |||
temp.c1 = Math.floor(1000/temp.v); | |||
temp.c2 = temp.t * temp.v; | |||
if(temp.c2 >= 0 && temp.c2 < 1){ | |||
fun_msg(-1,false,"<CameraShake>The duration is too short,use the minimum value to instead."); | |||
temp.c2 = 1; | |||
} | |||
temp.o1.css("transition-duration",(1/temp.v).toFixed(4) + "s"); | |||
temp.o1.attr({"d-sh-n":"shake","d-sh-t":0}); | |||
timer.create("shake",()=>timer_shake_common("sys_camera",temp.strx,temp.stry,temp.rnd,temp.c2),temp.c1,true); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'character': | |||
{ | { | ||
let n1 = cmd_set.name ? cmd_set.name.toLowerCase() : "",n2 = cmd_set.name2 ? cmd_set.name2.toLowerCase() : ""; | |||
let f = +cmd_set.focus || 0,dur = +cmd_set.fadetime || 0.15,cnt = n2 ? 2 : 1; | |||
let tarA = "char_left",tarB = "char_right"; | |||
if(!n1 && !n2){ | |||
$("#sys_char").children().fadeToExit(dur*950); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",dur); | |||
return 2; | |||
} | |||
return -2; | |||
} | |||
let char = $(`#${tarB}`); | |||
if(n2){ | |||
timer.clear("char2_reset",true); | |||
let ent = cmd_set.enter2 || "",len = char.children().length; | |||
if(char.length === 0){ | |||
let e = document.createElement("div"); | |||
e.id = tarB; | |||
e.className = "char_style char"; | |||
$("#sys_char").append(e); | |||
char = $(e); | |||
} | |||
else char.stop(true); | |||
let [n,i] = fun_char_link(n2); | |||
if(n == -1) | |||
return -1; | |||
let k = fun_char_format(n,i); | |||
if(!chars[k]) | |||
fun_msg(-1,false,`<${m1}>Linked key [${k}] not exist.`); | |||
let can = char.children(":last"); | |||
if (f == -1 || f == 1) | |||
char.addClass("unfocus"); | |||
else | |||
char.removeClass("unfocus"); | |||
if(can.attr("data-n") == n && can.attr("data-cnt") == cnt){ | |||
fun_draw_char(can[0],chars[k],can[0].width,can[0].height,cmd_set.blackstart2,cmd_set.blackend2); | |||
if(cmd_set.fadetime || cmd_set.duration) | |||
can.hide().fadeIn(dur*950 || 0); | |||
} | |||
else{ | |||
let [sx,sy,px,py] = fun_char_pos(n,1); | |||
let e = $(document.createElement("canvas")); | |||
e.css({"position":"absolute","left":px,"top":py}); | |||
e.attr({"data-n":n,"data-cnt":cnt,"width":sx,"height":sy}); | |||
fun_draw_char(e[0],chars[k],sx,sy,cmd_set.blackstart2,cmd_set.blackend2); | |||
char.append(e); | |||
if(k == "char_empty") char.attr("style",""); | |||
let sf = char.attr("style") == "" ? false : can.attr("data-n") == "char_empty" && can.attr("data-cnt") == cnt ? false : true; | |||
e.hide().fadeIn(dur*1000); | |||
if(sf) timer.create("char2_reset",()=>char.attr("style",""),dur*950); | |||
char.children(`:lt(${len})`).fadeToExit(dur*950); | |||
} | |||
if(ent){ | |||
timer.clear("char2_enter"); | |||
char.attr("style",""); | |||
let tx = ent == "left" ? -base_width : ent == "right" ? base_width : 0,ty = ent == "up" ? -base_height : ent == "down" ? base_height : 0; | |||
char.css("transform",`"matrix(1,0,0,1,${tx},${ty})"`); | |||
timer.create("char2_enter",()=>{char.css({"transition":`transform ${dur}s`,"transform":"matrix(1,0,0,1,0,0)"})},20); | |||
} | |||
} | |||
else{ | |||
char.fadeToExit(dur*950); | |||
$(`#${tarA}`).fadeToExit(dur*950); | |||
tarA = "char_middle"; | |||
} | |||
char = $(`#${tarA}`); | |||
if(n1){ | |||
let ent = cmd_set.enter || "",len = char.children().length; | |||
timer.clear("char1_reset",true); | |||
if(char.length === 0){ | |||
let e = document.createElement("div"); | |||
e.id = tarA; | |||
e.className = "char_style char"; | |||
$("#sys_char").append(e); | |||
char = $(e); | |||
} | |||
else char.stop(true); | |||
let [n,i] = fun_char_link(n1); | |||
if(n == -1) | |||
return -1; | |||
let k = fun_char_format(n,i); | |||
if(!chars[k]) | |||
fun_msg(-1,false,`<${m1}>Linked key [${k}] not exist.`); | |||
let can = char.children(":last"); | |||
if (f == -1 || f == 2) | |||
char.addClass("unfocus"); | |||
else | |||
char.removeClass("unfocus"); | |||
if(can.attr("data-n") == n && can.attr("data-cnt") == cnt){ | |||
fun_draw_char(can[0],chars[k],can[0].width,can[0].height,cmd_set.blackstart,cmd_set.blackend); | |||
if(cmd_set.fadetime || cmd_set.duration) | |||
can.hide().fadeIn(dur*950 || 0); | |||
} | |||
else{ | |||
if(tarA != "char_middle") $("#char_middle").fadeToExit(dur*950); | |||
let [sx,sy,px,py] = fun_char_pos(n,n2 ? -1 : 0); | |||
let e = $(document.createElement("canvas")); | |||
e.css({"position":"absolute","left":px,"top":py}); | |||
e.attr({"data-n":n,"data-cnt":cnt,"width":sx,"height":sy}); | |||
fun_draw_char(e[0],chars[k],sx,sy,cmd_set.blackstart,cmd_set.blackend); | |||
char.append(e); | |||
if(k == "char_empty") char.attr("style",""); | |||
let sf = char.attr("style") == "" ? false : can.attr("data-n") == "char_empty" && can.attr("data-cnt") == cnt ? false : true; | |||
e.hide().fadeIn(dur*1000); | |||
if(sf) timer.create("char1_reset",()=>char.attr("style",""),dur*950); | |||
char.children(`:lt(${len})`).fadeToExit(dur*950); | |||
} | |||
if(ent){ | |||
timer.clear("char1_enter"); | |||
char.attr("style",""); | |||
let tx = ent == "left" ? -base_width : ent == "right" ? base_width : 0,ty = ent == "up" ? -base_height : ent == "down" ? base_height : 0; | |||
char.css("transform",`"matrix(1,0,0,1,${tx},${ty})"`); | |||
timer.create("char1_enter",()=>{char.css({"transition":`transform ${dur}s`,"transform":"matrix(1,0,0,1,0,0)"})},20); | |||
} | |||
} | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",dur); | |||
return 2; | |||
} | |||
} | |||
break; | |||
case 'characteraction': | |||
temp.n = cmd_set.name == undefined ? "" : cmd_set.name; | |||
if(temp.n == "") return -1; | |||
temp.tp = cmd_set.type; | |||
temp.px = cmd_set.xpos == undefined ? 0 : cmd_set.xpos*0.75; | |||
temp.py = cmd_set.ypos == undefined ? 0 : cmd_set.ypos*0.75; | |||
temp.fd = cmd_set.duration == undefined ? cmd_set.fadetime == undefined ? 0.25 : +cmd_set.fadetime : +cmd_set.duration; | |||
temp.pw = cmd_set.power == undefined ? 0 : cmd_set.power*0.75; | |||
temp.tm = cmd_set.times == undefined ? 1 : +cmd_set.times; | |||
temp.o1 = $(`#char_${temp.n}`); | |||
if(temp.o1.length == 0){ | |||
fun_msg(-2,false,"<CharacterAction>Unexcepted character length."); | |||
return -1; | |||
} | |||
timer.clear("trans_action",true); | |||
temp.d1 = temp.o1[0].style.transform.replace(/\s/g,"").match(/^matrix\((.*)\).*$/i); | |||
temp.pos = temp.d1 == null ? [1,0,0,1,0,0] : temp.d1[1].split(","); | |||
temp.pos[4] = +temp.pos[4] + temp.px;temp.pos[5] = +temp.pos[5] - temp.py; | |||
switch(temp.tp){ | |||
case 'move': | |||
temp.o1.css("transition","transform "+temp.fd+"s linear"); | |||
break; | |||
case 'jump': | |||
for(let i=0;i<temp.tm;i++) | |||
{ | |||
setTimeout(() => { | |||
temp.o1.animate({"top":"-="+temp.pw},temp.fd*500,(o = temp.o1)=>{ | |||
o.animate({"top":0},temp.fd*500); | |||
}); | |||
}, temp.fd*i*950); | |||
} | |||
temp.o1.css("transition","transform "+temp.fd+"s"); | |||
break; | |||
case 'shake': | |||
{ | |||
let n = "action_" + temp.n,tm = temp.tm,fd = temp.fd,pw = temp.pw; | |||
timer.clear(n); | |||
temp.o1.css({left:0,top:0}); | |||
if(cmd_set.stop == "true"){ | |||
temp.o1.removeAttr("d-sh-n"); | |||
temp.o1.removeAttr("d-sh-t"); | |||
return 1; | |||
} | |||
temp.o1.attr({"d-sh-n":n,"d-sh-t":0}); | |||
let c = tm > 0 ? Math.max(Math.round(fd*1000/tm),1) : fd; | |||
timer.create(n,()=>timer_shake_common(temp.o1,pw,pw,cmd_set.randomness || 90,tm),c,true); | |||
} | |||
return 1; | |||
case 'zoom': | |||
temp.pos[0] = cmd_set.xscale || cmd_set.scale || temp.pos[0]; | |||
temp.pos[3] = cmd_set.yscale || cmd_set.scale || temp.pos[3]; | |||
temp.o1.css({"transition":"transform "+temp.fd+"s linear"}); | |||
break; | |||
case 'exit': | |||
temp.c1 = cmd_set.direction == "left" ? -1920 : 1920; | |||
temp.c1 = temp.c1 + (temp.n == "left" ? 480 : -480); | |||
temp.pos[4] = temp.c1; | |||
temp.o1.css("transition","transform "+temp.fd+"s ease-in-out"); | |||
break; | |||
default: | |||
fun_msg(-1,false,"<CharacterAction>:Unknown type data:"+temp.tp); | |||
return -1; | |||
} | |||
timer.create("trans_action",function(){temp.o1.css("transform","matrix("+temp.pos.toString()+")")},20); | |||
if(cmd_set.isblock == "true"){ | |||
fun_delay("block",temp.fd); | |||
return 2; | |||
} | |||
break; | |||
case 'charactercutin': | |||
temp.o1 = $("#sys_cutin"); | |||
if(cmd_set.widgetid == undefined){ | |||
temp.o1.empty(); | |||
return -1; | return -1; | ||
} | } | ||
if( | temp.t = cmd_set.fadetime == undefined ? 140 : cmd_set.fadetime*1000; | ||
temp.n = cmd_set.name == undefined ? "" : cmd_set.name.toLowerCase(); | |||
temp.id = "cutin_" + cmd_set.widgetid.replace(/ /g,"_"); | |||
temp.px = cmd_set.offsetx == undefined ? 480 : 480+cmd_set.offsetx*0.75; | |||
temp.py = cmd_set.offsety == undefined ? 0 : -cmd_set.offsety*0.75; | |||
temp.w = cmd_set.width == undefined ? 150 : cmd_set.width*0.75; | |||
temp.h = cmd_set.height == undefined ? 540 : cmd_set.height*0.75; | |||
temp.o2 = $("#"+temp.id); | |||
if(!temp.n && temp.o2.length > 0){ | |||
let pas = data_cutin[temp.id]; | |||
if(pas.style == 0){ | |||
temp.o2.fadeToExit(temp.t); | |||
} | |||
else{ | |||
if(pas.style > 0 && pas.style <= 3) temp.o2.animate({"width":0,"left":pas.left,"backgroundPositionX":pas.imgX},temp.t,"linear"); | |||
else if(pas.style > 3 && pas.style <= 6) temp.o2.animate({"height":0,"top":pas.top,"backgroundPositionY":pas.imgY},temp.t,"linear"); | |||
} | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t,"ms"); | |||
return 2; | |||
} | |||
break; | |||
} | |||
if(temp.o2.length == 0){ | |||
temp.o2 = document.createElement('div'); | |||
temp.o1.append(temp.o2); | |||
temp.o2 = $(temp.o2); | |||
temp.o2.attr({"id":temp.id,"class":"cutin_style"}); | |||
} | |||
[temp.d1,temp.c1] = fun_char_link(temp.n); | |||
if(temp.d1 == -1) return -1; | |||
temp.n = fun_char_format(temp.d1,temp.c1); | |||
let infos = fun_char_pos(temp.d1); | |||
let fx = temp.w/2,fy = temp.h/2; | |||
/* backgroundPosition */ | |||
temp.ixe = temp.ixs = -infos[0]/2+fx; | |||
temp.iye = temp.iys = infos[3]; | |||
/* ls=left start,le=left end,ts=top start,te=top end */ | |||
temp.le = temp.ls = temp.px-fx; | |||
temp.te = temp.ts = temp.py; | |||
let cutin_paras = {}; | |||
switch(cmd_set.fadestyle) | |||
{ | { | ||
case 'horiz_expand_center': | |||
cutin_paras.style = 1; | |||
temp.ls += fx; | |||
temp.ixs -= fx; | |||
break; | |||
case 'horiz_expand_left2right': | |||
cutin_paras.style = 2; | |||
break; | |||
case 'horiz_expand_right2left': | |||
cutin_paras.style = 3; | |||
temp.ls += temp.w; | |||
temp.ixs -= temp.w; | |||
break; | |||
case 'vert_expand_center': | |||
cutin_paras.style = 4; | |||
temp.ts += fy; | |||
temp.iys -= fy; | |||
break; | |||
case 'vert_expand_top2buttom': | |||
cutin_paras.style = 5; | |||
break; | |||
case 'vert_expand_buttom2top': | |||
cutin_paras.style = 6; | |||
temp.ts += temp.h; | |||
temp.iys -= temp.h; | |||
break; | |||
default: | |||
cutin_paras.style = 0; | |||
break; | |||
} | } | ||
cutin_paras.width = temp.w; | |||
if( | cutin_paras.height = temp.h; | ||
cutin_paras.offsetx = temp.px; | |||
cutin_paras.left = temp.ls; | |||
cutin_paras.top = temp.ts; | |||
cutin_paras.imgX = temp.ixs; | |||
cutin_paras.imgY = temp.iys; | |||
data_cutin[temp.id] = cutin_paras; | |||
if(!chars[temp.n]) fun_msg(-1,false,"<CharacterCutin>Data ["+temp.n+"] not exist,please check the data list."); | |||
temp.o2.css({"backgroundSize":infos[0]+"px "+infos[1]+"px","backgroundImage":"url('"+chars[temp.n]+"')","backgroundPosition":temp.ixs+"px "+temp.iys+"px"}); | |||
temp.o2.css({"left":temp.ls,"top":temp.ts}); | |||
if(cutin_paras.style == 0) temp.o2.hide().css({"width":temp.w,"height":temp.h}).fadeIn(temp.t); | |||
else if(cutin_paras.style > 0 && cutin_paras.style <= 3) temp.o2.css({"width":0,"height":temp.h}).animate({"width":temp.w,"left":temp.le,"backgroundPositionX":temp.ixe},temp.t,"linear"); | |||
else if(cutin_paras.style > 3 && cutin_paras.style <= 6) temp.o2.css({"width":temp.w,"height":0}).animate({"height":temp.h,"top":temp.te,"backgroundPositionY":temp.iye},temp.t,"linear"); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t,"ms"); | |||
return 2; | |||
} | |||
break; | |||
case 'charslot': | |||
temp.p = cmd_set.slot; | |||
temp.t = +cmd_set.duration || 0.15; | |||
temp.o = $("#sys_char"); | |||
if(!temp.p){ | |||
temp.o.children().fadeToExit(temp.t*950); | |||
if(cmd_set.isblock){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
return 1; | |||
} | |||
temp.n = cmd_set.name ? cmd_set.name.toLowerCase() : ""; | |||
temp.f = cmd_set.focus || "unset"; | |||
temp.ac = cmd_set.action || ""; | |||
temp.a = cmd_set.afrom && cmd_set.ato ? [cmd_set.afrom,cmd_set.ato] : "unset"; | |||
switch(temp.p.toLowerCase()){ | |||
case "left": | |||
case "l": | |||
temp.p = "char_left"; | |||
temp.ps = -1; | |||
break; | |||
case "middle": | |||
case "m": | |||
temp.p = "char_middle"; | |||
temp.ps = 0; | |||
break; | |||
case "right": | |||
case "r": | |||
temp.p = "char_right"; | |||
temp.ps = 1; | |||
break; | |||
} | |||
temp.o1 = $("#"+temp.p); | |||
if(temp.o1.length == 0){ | |||
temp.o1 = $(document.createElement("div")); | |||
temp.o1[0].id = temp.p; | |||
temp.o1.addClass("char_style slot"); | |||
temp.o.append(temp.o1); | |||
} | |||
temp.o3 = temp.o1.children(":last"); | |||
if(temp.n){ | |||
if(!temp.o3.attr("data-n")) cmd_set.end = "false"; | |||
if(!cmd_set.focus) temp.f = cmd_set.slot; | |||
let c11 = temp.o1.children().length; | |||
/* timer.clear("char2_reset",true); */ | |||
let [n,i] = fun_char_link(temp.n); | |||
if(n == -1) return -1; | |||
let n1 = fun_char_format(n,i); | |||
if(!chars[n1]) fun_msg(-1,false,"<CharSlot>Data ["+n1+"] not exist,please check the data list."); | |||
let [sx,sy,px,py] = fun_char_pos(n,temp.ps); | |||
if(temp.o3.attr("data-n") == n){ | |||
fun_draw_char(temp.o3[0],chars[n1],sx,sy,cmd_set.bstart,cmd_set.bend); | |||
temp.o3.fadeTo(temp.t*950,1); | |||
if(cmd_set.fadetime) temp.o3.hide().fadeIn(cmd_set.fadetime*950);/* 这里就是需要判定fadetime */ | |||
} | |||
else{ | |||
let e = $(document.createElement("canvas")); | |||
e.css({"position":"absolute","left":px,"top":py}); | |||
e.attr({"data-n":n,"width":sx,"height":sy}); | |||
fun_draw_char(e[0],chars[n1],sx,sy,cmd_set.bstart,cmd_set.bend); | |||
temp.o1.append(e); | |||
e.hide().fadeIn(temp.t*1000); | |||
temp.o1.children(":lt("+c11+")").fadeToExit(temp.t*950); | |||
temp.o3 = e; | |||
} | |||
} | |||
let pas = cmd_set.end == "false" ? temp.o1[0].props || {px:0,py:0,sx:1,sy:1} : {px:0,py:0,sx:1,sy:1}; | |||
/* preload */ | |||
temp.tsf = [pas.sx,0,0,pas.sy,pas.px,pas.py]; | |||
if(cmd_set.posfrom && cmd_set.posto){ | |||
let pf = cmd_set.posfrom.split(','),pt = cmd_set.posto.split(','); | |||
if(pf.length == 2 && pt.length == 2){ | |||
temp.tsf[4] = pf[0] * mtpy; | |||
temp.tsf[5] = -pf[1] * mtpy; | |||
pas.px = pt[0] * mtpy; | |||
pas.py = -pt[1] * mtpy; | |||
} | |||
} | |||
else if(cmd_set.posto){ | |||
let pt = cmd_set.posto.split(','); | |||
if(pt.length == 2){ | |||
pas.px += pt[0] * mtpy; | |||
pas.py -= pt[1] * mtpy; | |||
} | |||
} | |||
/* focus */ | |||
if(temp.f === "none"){ | |||
temp.o1.addClass("unfocus"); | |||
} | |||
else if(temp.f !== "unset"){ | |||
if(cmd_set.focus == "all") temp.f = "l,m,r"; | |||
let fs = temp.f.toLowerCase().split(','); | |||
/* fix focus array */ | |||
for(var i = 0;i < fs.length;i++){ | |||
switch(fs[i]){ | |||
case 'l': | |||
case 'left': | |||
fs[i] = "left"; | |||
break; | |||
case 'm': | |||
case 'middle': | |||
fs[i] = "middle"; | |||
break; | |||
case 'r': | |||
case 'right': | |||
fs[i] = "right"; | |||
break; | |||
} | |||
} | |||
temp.o.children().each((i,e)=>{ | |||
var s = e.id; | |||
for(var f of fs){ | |||
if(s.includes(f)){ | |||
e.classList.remove("unfocus"); | |||
return; | |||
} | |||
} | |||
e.classList.add("unfocus"); | |||
}); | |||
} | |||
/* action */ | |||
let trans_str = "transform "+temp.t+"s linear"; | |||
if(temp.ac){ | |||
let pw = cmd_set.power ? 0 : cmd_set.power * mtpy; | |||
let tm = cmd_set.times ? 0 : +cmd_set.times; | |||
let rand = Number.isNaN(parseInt(cmd_set.random)) ? 90 : +cmd_set.random; | |||
temp.o1.css("transform-origin",""); | |||
switch(temp.ac){ | |||
case "zoom": | |||
pas.sx = cmd_set.xscale || cmd_set.scale || pas.sx; | |||
pas.sy = cmd_set.yscale || cmd_set.scale || pas.sy; | |||
if(cmd_set.poszoom && temp.o3[0]){ | |||
let [oriX,oriY] = cmd_set.poszoom.split(','); | |||
pas.px += (0.5-oriX)*pas.sx*temp.o3[0].width; | |||
pas.py += (oriY-0.5)*pas.sy*temp.o3[0].height; | |||
temp.o1.css("transform-origin","center"); | |||
} | |||
break; | |||
case "jump": | |||
let et = tm <= 0 ? 0 : temp.t*1000/tm; | |||
for(let i=0;i<temp.tm;i++) | |||
{ | |||
setTimeout(() => { | |||
temp.o1.animate({"top":"-="+pw},et/2,(o = temp.o1)=>{ | |||
o.animate({"top":0},et/2); | |||
}); | |||
}, et*i*1000); | |||
} | |||
trans_str = "transform "+temp.t+"s ease-out"; | |||
break; | |||
case "shake": | |||
let n = "shake_" + temp.p; | |||
timer.clear(n); | |||
temp.o1.css({left:0,top:0}); | |||
if(cmd_set.stop == "true"){ | |||
temp.o1.removeAttr("d-sh-n"); | |||
temp.o1.removeAttr("d-sh-t"); | |||
return 1; | |||
} | |||
temp.o1.attr({"d-sh-n":n,"d-sh-t":0}); | |||
let c = tm > 0 ? Math.max(Math.round(temp.t*1000/tm),1) : temp.t; | |||
timer.create(temp.n2,()=>timer_shake_common(temp.o1,pw,pw,rand,tm),c,true); | |||
return 1; | |||
default: | |||
break; | |||
} | |||
} | |||
/* transform */ | |||
temp.tst = [pas.sx,0,0,pas.sy,pas.px,pas.py]; | |||
temp.o1[0].props = pas; | |||
temp.o1.css({transform:"matrix("+temp.tsf.toString()+")"}); | |||
/* opacity */ | |||
if(Array.isArray(temp.a)){ | |||
temp.o3.fadeTo(0,temp.a[0]); | |||
temp.o3.fadeTo(temp.t*1000,temp.a[1]); | |||
} | |||
else if(temp.a != "unset" && cmd_set.afrom === cmd_set.ato){ | |||
temp.a = cmd_set.afrom; | |||
temp.o3.fadeTo(0,temp.a); | |||
} | |||
if(cmd_set.duration){ | |||
timer.create("slot_si",function(){temp.o1.css({transition:trans_str})},15); | |||
} | |||
timer.create("trans_slot",function(){temp.o1.css({transform:"matrix("+temp.tst.toString()+")"})},20); | |||
if(cmd_set.isblock == "true"){ | |||
fun_delay("block",temp.t,"s"); | |||
return 2; | |||
} | |||
break; | |||
case 'curtain': | |||
temp.dr = cmd_set.direction || ""; | |||
if(!temp.dr){ | |||
$("#sys_masker").children(".curtain").fadeToExit(cmd_set.fadetime*1000 || 0); | |||
return -1; | |||
} | |||
temp.o1 = document.getElementById("curtain_"+temp.dr); | |||
temp.fr = cmd_set.fillfrom || (temp.o1 ? temp.o1.getAttribute("d-end") : 0); | |||
temp.ft = cmd_set.fillto; | |||
temp.t = cmd_set.fadetime || 0; | |||
if(!temp.fr || !temp.ft){ | |||
return; | |||
} | |||
fun_curtain_create(temp.dr,temp.fr,temp.ft,temp.t,cmd_set.a || 1); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'delay': | |||
if (!cmd_set.time) return -1; | |||
fun_delay("block",cmd_set.time); | |||
return 2; | |||
case 'decision': | |||
{ | { | ||
if(!cmd_set.options) return -1; | |||
let ops = fun_txt_format(cmd_set.options).split(";"),op_len = ops.length,vas = cmd_set.values.split(";"); | |||
let py = Math.max((556 - op_len * 80) / 2,72);/* 556=588-32@向上偏移32px */ | |||
let dec = document.getElementById("sys_decision"); | |||
dec.setClear(); | |||
for(let i = 0;i < op_len;i++){ | |||
let op = document.createElement("div"); | |||
dec.append(op); | |||
op.className = "decision_style"; | |||
op.innerHTML = ops[i]; | |||
op.setAttribute("d-value",vas[i]); | |||
op.addEventListener("click",function(){ | |||
var self = this; | |||
let sys_dec = document.getElementById("sys_decision"); | |||
sys_dec.setHide(); | |||
let pb = document.createElement('li'); | |||
document.getElementById("playback_result").append(pb); | |||
let arr = [...sys_dec.children]; | |||
system.decision.select = +self.getAttribute("d-value"); | |||
for (let ele of arr){ | |||
let p = document.createElement("span"); | |||
pb.append(p); | |||
p.innerHTML = "【" + ele.innerHTML + "】"; | |||
p.classList.add("decision"); | |||
if(ele == self){ | |||
p.classList.add("selected"); | |||
} | |||
} | |||
pb.style = "height: " + (arr.length * 22) + "px"; | |||
fun_audio_create(data.audio["btn_click"],{remove:true}); | |||
fun_setting("cmd_resume"); | |||
if(system.stats.auto && !timer.isTimer("auto")) timer.create("auto",()=>timer_auto(),400,true); | |||
txt_next(); | |||
}); | |||
op.style.top = py + "px"; | |||
py += 72; | |||
} | |||
if(system.stats.auto) timer.clear("auto"); | |||
fun_setting("cmd_suspend"); | |||
dec.setShow(); | |||
} | |||
return 2; | |||
case 'dialog': | |||
temp.t = cmd_set.fadetime == undefined ? 0 : cmd_set.fadetime; | |||
temp.b = cmd_set.block == undefined ? "false" : cmd_set.block; | |||
$("#sys_dialog").fadeOut(temp.t*950,'linear'); | |||
if(temp.b == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'header': | |||
return -1; | |||
case 'hideitem': | |||
temp.o1 = $("#sys_item").children(); | |||
temp.t = cmd_set.fadetime == undefined ? 0.16 : cmd_set.fadetime; | |||
if(temp.o1.length == 0) return -1; | |||
temp.o1.fadeToExit(temp.t*950,'linear'); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'image': | |||
temp.o1 = $('#sys_image'); | |||
temp.o1.children().stop(true,true); | |||
temp.t = cmd_set.fadetime ? +cmd_set.fadetime : 0.15; | |||
temp.c1 = temp.o1.children('div').length; | |||
temp.n = (cmd_set.image && cmd_set.image.toLowerCase()) || ""; | |||
if(temp.n == ""){ | |||
if(temp.t > 0){ | |||
temp.o1.children('div').fadeToExit(temp.t*950,'linear'); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
} | |||
else temp.o1.empty(); | |||
break; | |||
} | |||
temp.e1 = document.createElement('div'); | |||
temp.e1 = $(temp.e1); | |||
temp.sx = cmd_set.xscale || cmd_set.width || 1; | |||
temp.sy = cmd_set.yscale || cmd_set.height || 1; | |||
temp.px = (cmd_set.x && cmd_set.x*0.75) || 0; | |||
temp.py = (cmd_set.y && cmd_set.y*0.75) || 0; | |||
if(imgs[temp.n] == undefined || imgs[temp.n] == ""){ | |||
fun_msg(-2,false,"<Image>Data ["+temp.n+"] not exist,please check the data list."); | |||
return -1; | |||
} | |||
temp.i1 = new Image(); | |||
temp.i1.src = imgs[temp.n]; | |||
temp.tsx = temp.i1.width*0.75;temp.tsy = temp.i1.height*0.75; | |||
if(cmd_set.screenadapt == "coverall"){ | |||
let w = temp.tsx / 960,h = temp.tsy / 540; | |||
w = Math.min(w,h); | |||
temp.tsx /= w,temp.tsy /= w; | |||
} | |||
temp.tpx = 480-temp.tsx/2,temp.tpy = 270-temp.tsy/2; | |||
temp.py = -temp.py; | |||
temp.e1.css({"position":"absolute","width":temp.tsx,"height":temp.tsy,"left":temp.tpx,"top":temp.tpy,"background-image":"url("+imgs[temp.n]+")","background-size":temp.tsx+"px "+temp.tsy+"px","transform":"matrix("+temp.sx+",0,0,"+temp.sy+","+temp.px+","+temp.py+")"}); | |||
temp.o1.append(temp.e1); | |||
temp.e1.hide().fadeIn(temp.t*1000,()=>{ | |||
temp.o1.children('div:lt('+temp.c1+')').remove(); | |||
}); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'imagerotate': | |||
temp.o1 = $("#sys_image").children("div:last"); | |||
if(temp.o1.length == 0) return -1; | |||
temp.ang = cmd_set.angle || 0; | |||
temp.fd = cmd_set.fadetime || 0; | |||
temp.d1 = temp.o1.css("transform").replace(/rotate\(.*?\)/g,""); | |||
temp.o1.css("transition","transform "+temp.fd+"s"); | |||
timer.create("img_rot_w",()=>{temp.o1.css("transform",temp.d1 + " rotate("+temp.ang+"deg)")},20); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.fd); | |||
return 2; | |||
} | |||
break; | |||
case 'imagetween': | |||
temp.o1 = $("#sys_image").children("div:last"); | |||
if(temp.o1.length == 0) return -1; | |||
temp.t = cmd_set.duration || 0.15; | |||
temp.p = temp.o1.css("transform").replace(/\s/g,"").match(/^[a-z]+\((.*)\)/); | |||
temp.p = temp.p == null ? [1,0,0,1,0,0] : temp.p[1].split(','); | |||
temp.sxf = cmd_set.xscalefrom || cmd_set.xscale || temp.p[0]; | |||
temp.sxt = cmd_set.xscaleto || cmd_set.xscale || temp.p[0]; | |||
temp.syf = cmd_set.yscalefrom || cmd_set.yscale || temp.p[3]; | |||
temp.syt = cmd_set.yscaleto || cmd_set.yscale || temp.p[3]; | |||
temp.pxf = cmd_set.xfrom ? cmd_set.xfrom*0.75 : cmd_set.x ? cmd_set.x*0.75 : temp.p[4]; | |||
temp.pxt = cmd_set.xto ? cmd_set.xto*0.75 : cmd_set.x ? cmd_set.x*0.75 : temp.p[4]; | |||
temp.pyf = cmd_set.yfrom ? cmd_set.yfrom*0.75 : cmd_set.y ? cmd_set.y*0.75 : -temp.p[5]; | |||
temp.pyt = cmd_set.yto ? cmd_set.yto*0.75 : cmd_set.y ? cmd_set.y*0.75 : -temp.p[5]; | |||
temp.pyf = -temp.pyf;temp.pyt = -temp.pyt; | |||
temp.o1.css("transform","matrix("+temp.sxf+",0,0,"+temp.syf+","+temp.pxf+","+temp.pyf+")"); | |||
timer.create("imaget_w",function(){temp.o1.css("transition","transform "+temp.t + "s linear").css("transform","matrix("+temp.sxt+",0,0,"+temp.syt+","+temp.pxt+","+temp.pyt+")")},20); | |||
if(cmd_set.duration == undefined || cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'gridbg': | |||
case 'verticalbg': | |||
case 'largebg': | |||
case 'largeimg': | |||
temp.mtf = m1.endsWith("bg"); | |||
temp.o1 = temp.mtf ? $("#sys_back") : $("#sys_image"); | |||
temp.ig = cmd_set.imagegroup == undefined ? [] : cmd_set.imagegroup.split('/'); | |||
temp.sw = cmd_set.solidwidth == undefined ? [] : cmd_set.solidwidth.split('/'); | |||
temp.sh = cmd_set.solidheight == undefined ? [] : cmd_set.solidheight.split('/'); | |||
if(temp.ig.length == 0 || temp.sw.length == 0 || temp.sh.length == 0) return -1; | |||
temp.px = cmd_set.x == undefined ? 0 : cmd_set.x*0.75; | |||
temp.py = cmd_set.y == undefined ? 0 : cmd_set.y*0.75; | |||
temp.sx = temp.sw.getSum()*0.9;temp.sy = temp.sh.getSum()*0.9; | |||
temp.t = cmd_set.fadetime || 0.15; | |||
temp.c1 = temp.o1.children('canvas').length; | |||
temp.o2 = document.createElement("canvas"); | |||
temp.o2 = $(temp.o2); | |||
if(m1.startsWith("grid")){ | |||
let leng = temp.ig.length,r = Math.ceil(Math.sqrt(leng)); | |||
let sx = Math.floor(temp.sx/r),sy = Math.floor(temp.sy/r); | |||
let px = (base_width-sx)/2,py = (base_height-sy)/2; | |||
temp.o2.attr({width:sx,height:sy,left:px,top:py}); | |||
for(let i = 0,offx = 0,offy = 0;i<leng;i++){ | |||
fun_draw_image(temp.o2[0],imgs[(temp.mtf ? "bg_" : "")+temp.ig[i].toLowerCase()],temp.sw[i]*0.9,temp.sh[i]*0.9,offx,offy); | |||
offx += temp.sw[i]*0.9; | |||
if(i > 0 && (i+1) % 2 == 0){ | |||
offx = 0; | |||
offy += temp.sh[i]*0.9; | |||
} | |||
} | |||
} | |||
else if(m1.startsWith("vertical")){ | |||
let sx = temp.sx,sy = temp.sy; | |||
let px = (base_width-sx)/2,py = (base_height-sy)/2; | |||
temp.o2.attr({width:sx,height:sy,left:px,top:py}); | |||
for(let i = 0,leni = temp.sw.length,offx = 0;i<leni;i++){ | |||
for(let j = 0,lenj = temp.sh.length,offy = 0;j<lenj;j++){ | |||
fun_draw_image(temp.o2[0],imgs[(temp.mtf ? "bg_" : "")+temp.ig[i+j*leni].toLowerCase()],temp.sw[i]*0.9,temp.sh[j]*0.9,offx,offy); | |||
offy += temp.sh[j]*0.9; | |||
} | |||
offx += temp.sw[i]*0.9; | |||
} | |||
} | |||
else if(m1.startsWith("large")){ | |||
let sx = temp.sx,sy = temp.sy; | |||
let px = (base_width-sx)/2,py = (base_height-sy)/2; | |||
temp.o2.attr({width:sx,height:sy,left:px,top:py}); | |||
for(let i = 0,offx = 0;i<temp.sw.length;i++){ | |||
for(let j=0,lenj = temp.sh.length,offy = 0;j<lenj;j++){ | |||
fun_draw_image(temp.o2[0],imgs[(temp.mtf ? "bg_" : "")+temp.ig[i*lenj+j].toLowerCase()],temp.sw[i]*0.9,temp.sh[j]*0.9,offx,offy); | |||
offy += temp.sh[j]*0.9; | |||
} | |||
offx += temp.sw[i]*0.9; | |||
} | |||
} | |||
else return -1; | |||
temp.o2.css({"position":"absolute","transform":`matrix(1.2,0,0,1.2,${temp.px},${-temp.py})`}); | |||
temp.o1.append(temp.o2); | |||
temp.o2.hide().fadeIn(temp.t*1000,()=>{ | |||
temp.o1.children("canvas:lt("+temp.c1+")").remove(); | |||
}); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'largebgtween': | |||
case 'largeimgtween': | |||
temp.mtf = match[1].toLowerCase() == "largebgtween"; | |||
temp.o1 = temp.mtf ? $("#sys_back") : $("#sys_image"); | |||
temp.o1 = temp.o1.children("canvas:last"); | |||
temp.o1 = $("#sys_back").children("canvas:last"); | |||
if(temp.o1.length == 0) return -1; | |||
temp.t = cmd_set.duration || 0.15; | |||
temp.p = temp.o1.css("transform").replace(/\s/g,"").match(/^[a-z]+\((.*)\)/); | |||
temp.p = temp.p == null ? [1,0,0,1,0,0] : temp.p[1].split(','); | |||
temp.sxf = cmd_set.xscalefrom || cmd_set.xscale || temp.p[0]; | |||
temp.sxt = cmd_set.xscaleto || cmd_set.xscale || temp.p[0]; | |||
temp.syf = cmd_set.yscalefrom || cmd_set.yscale || temp.p[3]; | |||
temp.syt = cmd_set.yscaleto || cmd_set.yscale || temp.p[3]; | |||
temp.pxf = cmd_set.xfrom ? cmd_set.xfrom*0.75 : cmd_set.x ? cmd_set.x*0.75 : temp.p[4]; | |||
temp.pxt = cmd_set.xto ? cmd_set.xto*0.75 : cmd_set.x ? cmd_set.x*0.75 : temp.p[4]; | |||
temp.pyf = cmd_set.yfrom ? cmd_set.yfrom*0.75 : cmd_set.y ? cmd_set.y*0.75 : -temp.p[5]; | |||
temp.pyt = cmd_set.yto ? cmd_set.yto*0.75 : cmd_set.y ? cmd_set.y*0.75 : -temp.p[5]; | |||
temp.pyf = -temp.pyf;temp.pyt = -temp.pyt; | |||
fun_msg(1,true,"<LargeBgTween>From:xscale="+temp.sxf+",yscale="+temp.syf+",x="+temp.pxf+"y="+temp.pyf); | |||
fun_msg(1,true,"<LargeBgTween>To:xscale="+temp.sxt+",yscale="+temp.syt+",x="+temp.pxt+"y="+temp.pyt); | |||
temp.o1.css("transform","matrix("+temp.sxf+",0,0,"+temp.syf+","+temp.pxf+","+temp.pyf+")"); | |||
timer.create("largebgt_w",function(){temp.o1.css("transition","transform "+temp.t + "s linear").css("transform","matrix("+temp.sxt+",0,0,"+temp.syt+","+temp.pxt+","+temp.pyt+")")},20); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'multiline': | |||
if(cmd_set.name == undefined) return -1; | |||
system.txt.delay.set("word",cmd_set.delay*1000 || 30); | |||
system.txt.dynamic = document.getElementById("dialog_output"); | |||
if(!system.multi.mode){ | |||
system.multi.begin(); | |||
system.txt.now = ""; | |||
} | |||
system.txt.name = cmd_set.name; | |||
system.txt.now += fun_txt_format(match[5]); | |||
$("#dialog_name").html(cmd_set.name); | |||
$("#sys_dialog").show(); | |||
if(cmd_set.end == "true"){ | |||
system.multi.end(); | |||
} | |||
return 0; | |||
case 'musicvolume': | |||
case "soundvolume": | |||
temp.cmd = match[1].toLowerCase(); | |||
if(cmd_set.volume == undefined){ | |||
fun_msg(-2,false,"<"+match[1]+">Can't find the volume parameter."); | |||
return -1; | |||
} | } | ||
temp.ch = temp.cmd == "musicvolume" ? "sys_music" : (cmd_set.channel && "audio_" + cmd_set.channel) || ""; | |||
if(temp.ch == "") return -1; | |||
temp.o1 = document.getElementById(temp.ch); | |||
if(temp.o1 == null) return -1; | |||
temp.o1.fade(cmd_set.fadetime,cmd_set.volume*0.5); | |||
break; | |||
case 'playmusic': | |||
case 'playsound': | |||
{ | { | ||
let log = fun_msg; | |||
let ms = sets.delay * 1000 || 0; | |||
let intro = fun_get_audio_url(sets.intro), key = fun_get_audio_url(sets.key); | |||
let id = m1 === "playmusic" ? "sys_music" : (sets.channel && "audio_" + sets.channel) || ""; | |||
let vol = sets.volume ? Math.min(sets.volume * 0.5, 1) : 0.4; | |||
if (!key) { | |||
log(-2, false, `<${m1}>The key is not specific.`); | |||
return -1; | |||
} | |||
if (id) { | |||
fun_stop_audio(id); | |||
} | |||
let args = { id: id, volume: vol, delay: ms }; | |||
if (m1 === "playsound") { | |||
args.loop = sets.loop === "true"; | |||
args.remove = !args.loop; | |||
} | |||
else if(m1 === "playmusic" && !intro){ | |||
args.loop = true; | |||
} | |||
let aud = fun_audio_create(intro || key, args); | |||
aud.classList.add(m1); | |||
if (m1 === "playmusic" && intro) { | |||
aud.setAttribute("data-loop", key); | |||
aud.onended = function () { | |||
this.src = this.getAttribute("data-loop"); | |||
this.removeAttribute("data-loop"); | |||
this.loop = true; | |||
this.play(); | |||
} | |||
} | |||
} | |||
break; | |||
case 'predicate': | |||
if (!cmd_set.references || cmd_set.references.includes(system.decision.select)){ | |||
system.decision.mode = false; | |||
} | |||
else{ | |||
system.decision.mode = true; | |||
} | } | ||
break; | |||
if( | case 'showitem': | ||
{ | temp.o1 = $("#sys_item"); | ||
temp.n = (cmd_set.image && cmd_set.image.toLowerCase()) || ""; | |||
temp.b = cmd_set.block || "true"; | |||
temp.t = cmd_set.fadetime || 0.16; | |||
if(temp.n == "") return -1; | |||
if(imgs[temp.n] == undefined || imgs[temp.n] == ""){ | |||
fun_msg(-2,false,"<ShowItem>Data ["+temp.n+"] not exist,please check the data list."); | |||
return -1; | |||
} | } | ||
temp.i1 = new Image(); | |||
{ | temp.i1.src = imgs[temp.n]; | ||
temp.sx = temp.i1.width*0.6;temp.sy = temp.i1.height*0.6; | |||
temp.px = (960-temp.sx)/2-7.5;temp.py = (540-temp.sy)/2-7.5; | |||
temp.e1 = document.createElement('div'); | |||
temp.e1 = $(temp.e1); | |||
temp.e1.addClass("item_style"); | |||
temp.e1.css({"background-image":"url("+imgs[temp.n]+")","background-size":"100%","width":temp.sx+"px","height":temp.sy+"px","left":temp.px+"px","top":temp.py+"px"}); | |||
temp.e1.hide().fadeIn(temp.t*1000); | |||
temp.o1.append(temp.e1); | |||
if(temp.b == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | } | ||
break; | |||
case 'stopmusic': | case 'stopmusic': | ||
case 'stopsound': | |||
case ' | |||
{ | { | ||
let id = m1 === "stopmusic" ? "@music" : (sets.channel && "audio_" + sets.channel) || "@sound"; | |||
fun_stop_audio(id, { time: sets.fadetime || 1 }); | |||
} | |||
break; | |||
case 'sticker': | |||
case 'subtitle': | |||
temp.cmd = match[1].toLowerCase(); | |||
temp.d1 = cmd_set.text == undefined ? "" : fun_txt_format(cmd_set.text); | |||
temp.d2 = cmd_set.alignment == undefined ? "" : cmd_set.alignment; | |||
temp.d3 = cmd_set.size == undefined ? 18 : cmd_set.size*0.75; | |||
temp.d5 = cmd_set.width == undefined ? 675 : cmd_set.width*0.75; | |||
temp.c1 = cmd_set.x == undefined ? 0 : cmd_set.x*0.75; | |||
temp.c2 = cmd_set.y == undefined ? 0 : cmd_set.y*0.75; | |||
temp.t = cmd_set.fadetime || 0; | |||
if(temp.cmd == "sticker" && !cmd_set.id){ | |||
fun_msg(-2,false,"<Sticker>Parameter id not applied."); | |||
return -1 | |||
} | |||
if(!temp.d1){ | |||
if(cmd_set.id){ | |||
system.multi.check(); | |||
$("#"+temp.cmd+"_"+cmd_set.id).fadeToExit(temp.t); | |||
} | |||
else if(temp.cmd == "subtitle"){ | |||
$("#sys_subtitle").children("span.subtitle").fadeToExit(temp.t); | |||
} | |||
return 1; | |||
} | |||
if(cmd_set.multi == "true"){ | |||
if(system.multi.mode){ | |||
system.txt.now += temp.d1; | |||
return 0; | |||
} | |||
system.multi.begin(); | |||
} | |||
if(!temp.d2){ | |||
fun_msg(-2,false,"<"+match[1]+">Parameter alignment not applied."); | |||
return -1; | return -1; | ||
} | } | ||
if( | if(temp.cmd == "subtitle"){ | ||
$("#sys_subtitle").children("span.subtitle").fadeToExit(temp.t); | |||
} | } | ||
system.txt.delay.set("word",cmd_set.delay*1000); | |||
temp.o1 = document.createElement("span"); | |||
if(cmd_set.id) temp.o1.id = temp.cmd + "_" + cmd_set.id; | |||
temp.o1.className = "subtitle_style "+temp.cmd; | |||
temp.pl = temp.d2 == "center" ? Math.max(temp.d5-fun_cal_len(temp.d1,fun_get_font(temp.d3)),0)/2 : temp.d2 == "right" ? Math.max(temp.d5-fun_cal_len(temp.d1,fun_get_font(temp.d3)),0) : 0; | |||
$(temp.o1).css({"left" : temp.c1 ,"top" : temp.c2 ,"font-size" : temp.d3 + "px","padding-left" : temp.pl,"width" : temp.d5}); | |||
$("#sys_subtitle").append(temp.o1); | |||
system.txt.name = ""; | |||
system.txt.now = temp.d1; | |||
system.txt.dynamic = temp.o1; | |||
if(!system.multi.mode) fun_playback("@p",system.txt.name,system.txt.now); | |||
return 0; | |||
case 'theater': | |||
{ | { | ||
let mode = cmd_set.mode || "false"; | |||
let btn1 = document.getElementById("button_playback"),btn2 = document.getElementById("button_auto"); | |||
if(mode == "true"){ | |||
if(btn1.classList.contains("return")) txt_playback("sys_playback","button_playback");/* 防止极限情况下导致的bug */ | |||
system.flag.skip = 0;/* 强制停止skip模式 */ | |||
system.stats.theater = true; | |||
btn1.setHide(); | |||
btn2.setHide(); | |||
timer.setFake("auto"); | |||
} | |||
else{ | |||
system.stats.theater = false; | |||
btn1.setShow(); | |||
btn2.setShow(); | |||
timer.removeFake("auto"); | |||
} | |||
} | } | ||
break; | |||
case 'timerclear': | |||
{ | { | ||
let span = document.getElementById("sticker_timer"); | |||
if(!span) return -1; | |||
$(span).css("opacity",cmd_set.afrom || 1).fadeTo(cmd_set.duration*1000 || 0,cmd_set.ato || 0); | |||
timer.clear("sticker_timer"); | |||
} | } | ||
break; | |||
case 'timersticker': | |||
{ | { | ||
let px = cmd_set.x*0.75 || 0,py = cmd_set.y*0.75 || 0,size = cmd_set.size*0.75 || 18; | |||
var span = document.getElementById("sticker_timer"); | |||
if(!span){ | |||
span = document.createElement("span"); | |||
document.getElementById("sys_subtitle").append(span); | |||
} | |||
span.className = "subtitle_style"; | |||
let id = "sticker_timer"; | |||
span.id = id; | |||
span.style.fontSize = `${size}px`; | |||
span.style.left = `${px}px`; | |||
span.style.top = `${py}px`; | |||
span.setAttribute("max-t",cmd_set.time || -1); | |||
span.setAttribute("now-t",0); | |||
span.innerHTML = fun_format_time(0); | |||
timer.create(id,(n = id)=>{ | |||
var e = document.getElementById(n); | |||
if(!e){ | |||
timer.clear(n,false); | |||
return; | |||
} | |||
var t = parseInt(e.getAttribute("now-t")) || 0,tm = parseInt(e.getAttribute("max-t")); | |||
e.setAttribute("now-t",++t); | |||
e.innerHTML = fun_format_time(t); | |||
if(tm < 0 || t < tm) return; | |||
timer.clear(n,false); | |||
},1000,true); | |||
} | } | ||
break; | |||
case 'video': | |||
if(cmd_set.res == undefined) return -1; | |||
fun_setting("cmd_suspend"); | |||
{ | temp.o1 = document.createElement("video"); | ||
fun_setting(" | temp.o1.width = 960; | ||
temp.o1.height = 540; | |||
temp.o1.autoplay = "autoplay"; | |||
temp.o1.src = source_url + cmd_set.res; | |||
temp.o1.onended = function(){ | |||
this.remove(); | |||
fun_setting("cmd_resume"); | |||
txt_next(); | |||
} | } | ||
document.getElementById("sys_animation").append(temp.o1); | |||
return 2; | |||
default: | |||
return -1; | |||
} | |||
return 1; | |||
} | |||
else if(match[3]) | |||
{ | |||
switch(match[3].toLowerCase()) | |||
{ | |||
case 'background': | |||
$("#sys_back").children('div').remove(); | |||
break; | |||
case 'character': | |||
case 'charslot': | |||
$("#sys_char").children().fadeToExit(150); | |||
fun_delay("block",0.2); | |||
return 2; | |||
case 'curtain': | |||
$("#sys_masker").children(".curtain").remove(); | |||
break; | |||
case 'dialog': | |||
$("#dialog_name").empty(); | |||
$("#dialog_output").empty(); | |||
$("#sys_dialog").hide(); | |||
break; | |||
case 'image': | |||
$("#sys_image").children('div').remove(); | |||
break; | |||
case 'gridbg': | |||
case 'verticalbg': | |||
case 'largebg': | |||
$("#sys_back").children('canvas').remove(); | |||
break; | |||
case 'largeimg': | |||
$("#sys_image").children('canvas').remove(); | |||
break; | |||
case 'predicate': | |||
system.decision.mode = false; | |||
break; | |||
case 'hideitem': | |||
$("#sys_item").children("div").fadeToExit(320); | |||
fun_delay("block",0.32); | |||
return 2; | |||
case 'stickerclear': | |||
$("#sys_subtitle").children("span.sticker").fadeToExit(200); | |||
fun_delay("block",0.2); | |||
return 2; | |||
case 'subtitle': | |||
$("#sys_subtitle").children("span.subtitle").fadeToExit(200); | |||
fun_delay("block",0.2); | |||
return 2; | return 2; | ||
case ' | default: | ||
if( | return -1; | ||
{ | } | ||
return 1; | |||
} | |||
else if(!match[5]) | |||
return -1; | |||
else if(match[4]) | |||
{ | |||
system.txt.dynamic = document.getElementById("dialog_output"); | |||
let p = match[4].toObject(); | |||
if(p.delay){ | |||
fun_delay("block",p.delay); | |||
return 2; | |||
} | |||
if(p.bind){ | |||
fun_audio_create(fun_get_audio_url(p.bind),{vol:0.5,id:"dialog_audio",remove:true}); | |||
} | |||
if(p.name == undefined) return -1; | |||
system.multi.check(); | |||
system.txt.name = p.name; | |||
system.txt.now = fun_txt_format(match[5]); | |||
fun_playback("@p",p); | |||
let name = document.getElementById("dialog_name"); | |||
name.innerHTML = p.name; | |||
if(p.color){ | |||
name.style.color = p.color; | |||
} | |||
document.getElementById("sys_dialog").show(); | |||
} | |||
return 0; | |||
} | |||
function txt_analyze_test(txt) | |||
{ | |||
let imgs = data.back,chars = data.char,mtpy = pos_multiply; | |||
fun_msg(1,true,"<Line "+system.txt.index+">"+txt); | |||
if(!txt || txt.match("^\\s+$") || txt.match("^\\s*//.*$")) /* ONLY SPACE REGEX|COMMENT REGEX */ | |||
{ | |||
return -2; | |||
} | |||
let match = txt.match("^\\[\\s*(?:(.*?)\\((.*)\\)|(?:([\\.|\\w]*)|(.*)))\\s*\\]\\s*(.*)"); /* COMMAND REGEX */ | |||
let temp = {}; | |||
if (match == null && !system.decision.mode){ | |||
system.multi.check(); | |||
system.txt.dynamic = document.getElementById("dialog_output"); | |||
system.txt.name = ""; | |||
system.txt.now = fun_txt_format(txt); | |||
fun_playback("@p",""); | |||
$("#dialog_name").empty(); | |||
$("#sys_dialog").show(); | |||
return 0; | |||
} | |||
else if(system.decision.mode){ | |||
temp.d1 = match == undefined ? "" : match[1] == undefined ? "" : match[1].toLowerCase(); | |||
temp.d2 = match == undefined ? "" : match[3] == undefined ? "" : match[3].toLowerCase(); | |||
if(temp.d1 != 'predicate' && temp.d2 != 'predicate') return -2; | |||
} | |||
if (match[1] != undefined){ | |||
let m1 = match[1].toLowerCase(); | |||
let cmd_set = match[2].toObject(); | |||
let sets = cmd_set; | |||
switch (m1){ | |||
case 'background': | |||
temp.o1 = $('#sys_back'); | |||
temp.o1.children().stop(true,true); | |||
temp.t = cmd_set.fadetime ? +cmd_set.fadetime : 0.15; | |||
temp.c1 = temp.o1.children('div').length; | |||
temp.n = (cmd_set.image && "bg_" + cmd_set.image.toLowerCase()) || ""; | |||
if(temp.n == ""){ | |||
if(temp.t > 0){ | |||
temp.o1.children('div').fadeToExit(temp.t*1000,'linear'); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
} | |||
else temp.o1.empty(); | |||
return 1; | |||
} | |||
temp.e1 = document.createElement('div'); | |||
temp.e1 = $(temp.e1); | |||
temp.sx = cmd_set.xscale || cmd_set.width || 1; | |||
temp.sy = cmd_set.yscale || cmd_set.height || 1; | |||
temp.px = (cmd_set.x && cmd_set.x*0.75) || 0; | |||
temp.py = (cmd_set.y && cmd_set.y*0.75) || 0; | |||
if(imgs[temp.n] == undefined || imgs[temp.n] == ""){ | |||
fun_msg(-2,false,"<Background>Data ["+temp.n+"] not exist,please check the data list."); | |||
return -1; | return -1; | ||
} | } | ||
var | temp.sx*=1.2,temp.sy*=1.2;/* temp parameter */ | ||
temp.i1 = new Image(); | |||
temp.i1.src = imgs[temp.n]; | |||
cmd_set.screenadapt = "coverall"; | |||
temp.e1.attr("d-adapt",cmd_set.screenadapt); | |||
temp.i1.onload = function(){ | |||
var w = this.width*0.75,h = this.height*0.75; | |||
var obj = temp.e1; | |||
if(obj.attr("d-adapt") == "coverall"){ | |||
var sx = w / 960,sy = h / 540; | |||
var s = Math.min(sx,sy); | |||
w /= s;h /= s; | |||
} | |||
var x = 480 - w/2,y = 270 - h/2; | |||
obj.css({"width":w,"height":h,"left":x,"top":y,"background-size":w+"px "+h+"px","background-image":"url("+this.src+")"}); | |||
} | |||
temp.e1.css({"position":"absolute","transform":`matrix(${temp.sx},0,0,${temp.sy},${temp.px},${-temp.py})`}); | |||
temp.o1.append(temp.e1); | |||
temp.e1.hide().fadeIn(temp.t*1000,()=>{ | |||
temp.o1.children('div:lt('+temp.c1+')').remove(); | |||
}); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'backgroundtween': | |||
temp.o1 = $("#sys_back").children("div:last"); | |||
if(temp.o1.length == 0) return -1; | |||
/* temp.n = (cmd_set.image && imgs["bg_" + cmd_set.image.toLowerCase()]) || fun_get_url(temp.o1.css("backgroundImage")) || ""; */ | |||
temp.t = cmd_set.duration || 0.15; | |||
/* if(temp.n == "") return -1; */ | |||
/* temp.o1.css("backgroundImage","url('"+temp.n+"')"); */ | |||
temp.p = temp.o1.css("transform").replace(/\s/g,"").match(/^[a-z]+\((.*)\)/); | |||
temp.p = temp.p == null ? [1,0,0,1,0,0] : temp.p[1].split(','); | |||
temp.sxf = cmd_set.xscalefrom || cmd_set.xscale || temp.p[0]; | |||
temp.sxt = cmd_set.xscaleto || cmd_set.xscale || temp.p[0]; | |||
temp.syf = cmd_set.yscalefrom || cmd_set.yscale || temp.p[3]; | |||
temp.syt = cmd_set.yscaleto || cmd_set.yscale || temp.p[3]; | |||
temp.pxf = cmd_set.xfrom ? cmd_set.xfrom*0.75 : cmd_set.x ? cmd_set.x*0.75 : temp.p[4]; | |||
temp.pxt = cmd_set.xto ? cmd_set.xto*0.75 : cmd_set.x ? cmd_set.x*0.75 : temp.p[4]; | |||
temp.pyf = cmd_set.yfrom ? cmd_set.yfrom*0.75 : cmd_set.y ? cmd_set.y*0.75 : -temp.p[5]; | |||
temp.pyt = cmd_set.yto ? cmd_set.yto*0.75 : cmd_set.y ? cmd_set.y*0.75 : -temp.p[5]; | |||
temp.pyf = -temp.pyf;temp.pyt = -temp.pyt; | |||
fun_msg(1,true,"<BackgroundTween>From:xscale="+temp.sxf+",yscale="+temp.syf+",x="+temp.pxf+",y="+temp.pyf); | |||
fun_msg(1,true,"<BackgroundTween>To:xscale="+temp.sxt+",yscale="+temp.syt+",x="+temp.pxt+",y="+temp.pyt); | |||
temp.o1.css("transition","").css("transform","matrix("+temp.sxf+",0,0,"+temp.syf+","+temp.pxf+","+temp.pyf+")"); | |||
timer.create("backt_w",()=>temp.o1.css("transition","transform "+temp.t + "s linear").css("transform","matrix("+temp.sxt+",0,0,"+temp.syt+","+temp.pxt+","+temp.pyt+")"),20); | |||
if(cmd_set.duration == undefined || cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'blocker': | |||
temp.t = cmd_set.fadetime == undefined ? 0.2 : cmd_set.fadetime;/* 默认12帧过渡时间 */ | |||
temp.d1 = cmd_set.a == undefined ? 1 : +cmd_set.a; | |||
temp.d2 = cmd_set.r == undefined ? 0 : +cmd_set.r; | |||
temp.d3 = cmd_set.g == undefined ? 0 : +cmd_set.g; | |||
temp.d4 = cmd_set.b == undefined ? 0 : +cmd_set.b; | |||
if(temp.d1 > 1) temp.d1 = 1;/* 闲着没事的以防万一 */ | |||
temp.o1 = $("#sys_blocker"); | |||
if(cmd_set.image){ | |||
temp.d1 = Math.max(0,1-temp.d1); | |||
} | |||
temp.o1.stop(true).css("transition","background-color "+temp.t+"s linear").css("background-color",fun_cal_rgba(temp.d2,temp.d3,temp.d4,temp.d1)); | |||
temp.o1.css("background-image",cmd_set.image ? "url('"+imgs[cmd_set.image]+"')" : ""); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'cameraeffect': | |||
temp.d1 = cmd_set.effect == undefined ? "" : cmd_set.effect.toLowerCase(); | |||
temp.d2 = cmd_set.amount == undefined ? 0 : cmd_set.amount; | |||
temp.t = cmd_set.fadetime == undefined ? -1 : +cmd_set.fadetime; | |||
temp.o1 = $("#sys_camera"); | |||
if(temp.t > 0){ | |||
temp.o1.css("transition","filter "+temp.t+"s linear"); | |||
timer.create("cmreff_w",()=>{ | |||
temp.o1.css("transition",""); | |||
},temp.t*1000); | |||
} | |||
if(temp.d2 == 0){ | |||
temp.o1.css("filter",""); | |||
break; | |||
} | |||
switch(temp.d1){ | |||
case 'grayscale': | |||
temp.o1.css("filter","grayscale("+temp.d2+")"); | |||
break; | |||
default: | |||
temp.o1.css("filter",""); | |||
break; | |||
} | |||
break; | |||
case 'camerashake': | |||
temp.t = cmd_set.duration == undefined ? -1 : +cmd_set.duration; | |||
temp.strx = cmd_set.xstrength == undefined ? 0 : cmd_set.xstrength * 0.75; | |||
temp.stry = cmd_set.ystrength == undefined ? 0 : cmd_set.ystrength * 0.75; | |||
temp.rnd = cmd_set.randomness == undefined ? 90 : +cmd_set.randomness; | |||
temp.v = cmd_set.vibrato == undefined ? 30 : +cmd_set.vibrato; | |||
timer.clear("shake"); | |||
temp.o1 = $("#sys_camera"); | |||
temp.o1.css({left:0,top:0}); | |||
if(cmd_set.stop == "true"){ | |||
temp.o1.removeAttr("d-sh-n"); | |||
temp.o1.removeAttr("d-sh-t"); | |||
return 1; | |||
} | |||
temp.c1 = Math.floor(1000/temp.v); | |||
temp.c2 = temp.t * temp.v; | |||
if(temp.c2 >= 0 && temp.c2 < 1){ | |||
fun_msg(-1,false,"<CameraShake>The duration is too short,use the minimum value to instead."); | |||
temp.c2 = 1; | |||
} | |||
fun_msg(1,true,"<CameraShake>duration="+temp.t+",xstrength="+temp.strx+",ystrength="+temp.stry+",randomness="+temp.rnd+",vibrato="+temp.v); | |||
temp.o1.css("transition-duration",(1/temp.v).toFixed(4) + "s"); | |||
temp.o1.attr({"d-sh-n":"shake","d-sh-t":0}); | |||
timer.create("shake",()=>timer_shake_common("sys_camera",temp.strx,temp.stry,temp.rnd,temp.c2),temp.c1,true); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'character': | |||
{ | { | ||
let n1 = cmd_set.name ? cmd_set.name.toLowerCase() : "",n2 = cmd_set.name2 ? cmd_set.name2.toLowerCase() : ""; | |||
let f = +cmd_set.focus || 0,dur = +cmd_set.fadetime || 0.15,cnt = n2 ? 2 : 1; | |||
let tarA = "char_left",tarB = "char_right"; | |||
{ | if(!n1 && !n2){ | ||
$("#sys_char").children().fadeToExit(dur*950); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",dur); | |||
return 2; | |||
} | |||
return -2; | |||
} | |||
let char = $(`#${tarB}`); | |||
if(n2){ | |||
timer.clear("char2_reset",true); | |||
let ent = cmd_set.enter2 || "",len = char.children().length; | |||
if(char.length === 0){ | |||
let e = document.createElement("div"); | |||
e.id = tarB; | |||
e.className = "char_style char"; | |||
$("#sys_char").append(e); | |||
char = $(e); | |||
} | |||
else | |||
char.stop(true); | |||
let [n,i] = fun_char_link(n2); | |||
fun_msg(1,true,`<${m1}>[2]name: ${n},index: ${i}`); | |||
if(n == -1) | |||
return -1; | |||
let k = fun_char_format(n,i); | |||
if(!chars[k]) | |||
fun_msg(-1,false,`<${m1}>Linked key [${k}] not exist.`); | |||
let can = char.children(":last"); | |||
if (f == -1 || f == 1) | |||
char.addClass("unfocus"); | |||
else | |||
char.removeClass("unfocus"); | |||
if(can.attr("data-n") == n && can.attr("data-cnt") == cnt){ | |||
fun_draw_char(can[0],chars[k],can[0].width,can[0].height,cmd_set.blackstart2,cmd_set.blackend2); | |||
if(cmd_set.fadetime || cmd_set.duration) | |||
can.hide().fadeIn(dur*950 || 0); | |||
} | |||
else{ | |||
let [sx,sy,px,py] = fun_char_pos(n,1); | |||
let e = $(document.createElement("canvas")); | |||
e.css({"position":"absolute","left":px,"top":py}); | |||
e.attr({"data-n":n,"data-cnt":cnt,"width":sx,"height":sy}); | |||
fun_draw_char(e[0],chars[k],sx,sy,cmd_set.blackstart2,cmd_set.blackend2); | |||
char.append(e); | |||
if(k == "char_empty") char.attr("style",""); | |||
let sf = char.attr("style") == "" ? false : can.attr("data-n") == "char_empty" && can.attr("data-cnt") == cnt ? false : true; | |||
e.hide().fadeIn(dur*1000); | |||
if(sf) timer.create("char2_reset",()=>char.attr("style",""),dur*950); | |||
char.children(`:lt(${len})`).fadeToExit(dur*950); | |||
} | |||
if(ent){ | |||
timer.clear("char2_enter"); | |||
char.attr("style",""); | |||
let tx = ent == "left" ? -base_width : ent == "right" ? base_width : 0,ty = ent == "up" ? -base_height : ent == "down" ? base_height : 0; | |||
char.css("transform",`"matrix(1,0,0,1,${tx},${ty})"`); | |||
timer.create("char2_enter",()=>{char.css({"transition":`transform ${dur}s`,"transform":"matrix(1,0,0,1,0,0)"})},20); | |||
} | |||
} | |||
else{ | |||
char.fadeToExit(dur*950); | |||
$(`#${tarA}`).fadeToExit(dur*950); | |||
tarA = "char_middle"; | |||
} | |||
char = $(`#${tarA}`); | |||
if(n1){ | |||
let ent = cmd_set.enter || "",len = char.children().length; | |||
timer.clear("char1_reset",true); | |||
if(char.length === 0){ | |||
let e = document.createElement("div"); | |||
e.id = tarA; | |||
e.className = "char_style char"; | |||
$("#sys_char").append(e); | |||
char = $(e); | |||
} | |||
else | |||
char.stop(true); | |||
let [n,i] = fun_char_link(n1); | |||
fun_msg(1,true,`<${m1}>[1]name: ${n},index: ${i}`); | |||
if(n == -1) | |||
return -1; | |||
let k = fun_char_format(n,i); | |||
if(!chars[k]) | |||
fun_msg(-1,false,`<${m1}>Linked key [${k}] not exist.`); | |||
let can = char.children(":last"); | |||
if (f == -1 || f == 2) | |||
char.addClass("unfocus"); | |||
else | |||
char.removeClass("unfocus"); | |||
if(can.attr("data-n") == n && can.attr("data-cnt") == cnt){ | |||
fun_draw_char(can[0],chars[k],can[0].width,can[0].height,cmd_set.blackstart,cmd_set.blackend); | |||
if(cmd_set.fadetime || cmd_set.duration) | |||
can.hide().fadeIn(dur*950 || 0); | |||
} | } | ||
else{ | |||
if(tarA != "char_middle") $("#char_middle").fadeToExit(dur*950); | |||
let [sx,sy,px,py] = fun_char_pos(n,n2 ? -1 : 0); | |||
let e = $(document.createElement("canvas")); | |||
e.css({"position":"absolute","left":px,"top":py}); | |||
e.attr({"data-n":n,"data-cnt":cnt,"width":sx,"height":sy}); | |||
fun_draw_char(e[0],chars[k],sx,sy,cmd_set.blackstart,cmd_set.blackend); | |||
char.append(e); | |||
if(k == "char_empty") char.attr("style",""); | |||
let sf = char.attr("style") == "" ? false : can.attr("data-n") == "char_empty" && can.attr("data-cnt") == cnt ? false : true; | |||
e.hide().fadeIn(dur*1000); | |||
if(sf) timer.create("char1_reset",()=>char.attr("style",""),dur*950); | |||
char.children(`:lt(${len})`).fadeToExit(dur*950); | |||
} | } | ||
if( | if(ent){ | ||
timer.clear("char1_enter"); | |||
char.attr("style",""); | |||
let tx = ent == "left" ? -base_width : ent == "right" ? base_width : 0,ty = ent == "up" ? -base_height : ent == "down" ? base_height : 0; | |||
char.css("transform",`"matrix(1,0,0,1,${tx},${ty})"`); | |||
timer.create("char1_enter",()=>{char.css({"transition":`transform ${dur}s`,"transform":"matrix(1,0,0,1,0,0)"})},20); | |||
} | } | ||
} | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",dur); | |||
return 2; | |||
} | |||
} | |||
break; | |||
case 'characteraction': | |||
temp.n = cmd_set.name == undefined ? "" : cmd_set.name; | |||
if(temp.n == "") return -1; | |||
temp.tp = cmd_set.type; | |||
temp.px = cmd_set.xpos == undefined ? 0 : cmd_set.xpos*0.75; | |||
temp.py = cmd_set.ypos == undefined ? 0 : cmd_set.ypos*0.75; | |||
temp.fd = cmd_set.duration == undefined ? cmd_set.fadetime == undefined ? 0.25 : +cmd_set.fadetime : +cmd_set.duration; | |||
temp.pw = cmd_set.power == undefined ? 0 : cmd_set.power*0.75; | |||
temp.tm = cmd_set.times == undefined ? 1 : +cmd_set.times; | |||
temp.o1 = $(`#char_${temp.n}`); | |||
if(temp.o1.length == 0){ | |||
fun_msg(-2,false,"<CharacterAction>Unexcepted character length."); | |||
return -1; | |||
} | |||
timer.clear("trans_action",true); | |||
temp.d1 = temp.o1[0].style.transform.replace(/\s/g,"").match(/^matrix\((.*)\).*$/i); | |||
temp.pos = temp.d1 == null ? [1,0,0,1,0,0] : temp.d1[1].split(","); | |||
temp.pos[4] = +temp.pos[4] + temp.px;temp.pos[5] = +temp.pos[5] - temp.py; | |||
switch(temp.tp){ | |||
case 'move': | |||
temp.o1.css("transition","transform "+temp.fd+"s linear"); | |||
break; | break; | ||
case | case 'jump': | ||
for(let i=0;i<temp.tm;i++) | |||
{ | { | ||
setTimeout(() => { | |||
temp.o1.animate({"top":"-="+temp.pw},temp.fd*500,(o = temp.o1)=>{ | |||
o.animate({"top":0},temp.fd*500); | |||
}); | |||
}, temp.fd*i*950); | |||
} | } | ||
if( | temp.o1.css("transition","transform "+temp.fd+"s"); | ||
break; | |||
case 'rotate': | |||
temp.o2 = temp.o1.children(); | |||
temp.o2.css("transform",""); | |||
timer.clear(temp.n+"_rotate"); | |||
if(cmd_set.stop == "true") return 1; | |||
temp.st = cmd_set.start == undefined ? 0 : cmd_set.start; | |||
temp.le = cmd_set.leftend == undefined ? -15 : -cmd_set.leftend; | |||
temp.re = cmd_set.rightend == undefined ? 15 : cmd_set.rightend; | |||
temp.o2.css({"transform-origin":"center","transition":"transform "+temp.fd+"s ease-in-out","transform":"rotate("+temp.st+"deg)"}); | |||
temp.o2.attr({"data-r":0,"data-c":0,"data-cm":temp.tm}); | |||
timer.create(temp.n+"_rotate",()=>{ | |||
let d = temp.o2.attr("data-r"),c = temp.o2.attr("data-c"),t = temp.o2.attr("data-cm"); | |||
if(d == "0") temp.o2.css("transform","rotate(" + temp.le + "deg)"); | |||
else temp.o2.css("transform","rotate(" + temp.re + "deg)"); | |||
temp.o2.attr("data-r",d == "1" ? "0" : "1"); | |||
if(t == "-1") return; | |||
if(++c > t){ | |||
temp.o2.css("transform",""); | |||
timer.clear(temp.n+"_rotate"); | |||
} | |||
temp.o2.attr("data-c",c); | |||
},temp.fd*1000,true); | |||
return 1; | |||
case 'shake': | |||
{ | { | ||
let n = "action_" + temp.n,tm = temp.tm,fd = temp.fd,pw = temp.pw; | |||
timer.clear(n); | |||
temp.o1.css({left:0,top:0}); | |||
if(cmd_set.stop == "true"){ | |||
temp.o1.removeAttr("d-sh-n"); | |||
temp.o1.removeAttr("d-sh-t"); | |||
return 1; | |||
} | |||
temp.o1.attr({"d-sh-n":n,"d-sh-t":0}); | |||
let c = tm > 0 ? Math.max(Math.round(fd*1000/tm),1) : fd; | |||
timer.create(n,()=>timer_shake_common(temp.o1,pw,pw,cmd_set.randomness || 90,tm),c,true); | |||
} | } | ||
return 1; | |||
case 'zoom': | |||
temp.pos[0] = cmd_set.xscale || cmd_set.scale || temp.pos[0]; | |||
temp.pos[3] = cmd_set.yscale || cmd_set.scale || temp.pos[3]; | |||
temp.o1.css({"transition":"transform "+temp.fd+"s linear"}); | |||
break; | |||
case 'exit': | |||
temp.c1 = cmd_set.direction == "left" ? -1920 : 1920; | |||
temp.c1 = temp.c1 + (temp.n == "left" ? 480 : -480); | |||
temp.pos[4] = temp.c1; | |||
temp.o1.css("transition","transform "+temp.fd+"s ease-in-out"); | |||
break; | break; | ||
default: | default: | ||
fun_msg(-1,false,"<CharacterAction>:Unknown type data:"+temp.tp); | |||
return -1; | return -1; | ||
} | } | ||
if( | timer.create("trans_action",function(){temp.o1.css("transform","matrix("+temp.pos.toString()+")");},20); | ||
if(cmd_set.isblock == "true"){ | |||
fun_delay("block",temp.fd); | |||
return 2; | |||
} | |||
break; | |||
case 'charactercutin': | |||
temp.o1 = $("#sys_cutin"); | |||
if(cmd_set.widgetid == undefined){ | |||
temp.o1.empty(); | |||
return -1; | |||
} | |||
temp.t = cmd_set.fadetime == undefined ? 140 : cmd_set.fadetime*1000; | |||
temp.n = cmd_set.name == undefined ? "" : cmd_set.name.toLowerCase(); | |||
temp.id = "cutin_" + cmd_set.widgetid.replace(/ /g,"_"); | |||
temp.px = cmd_set.offsetx == undefined ? 480 : 480+cmd_set.offsetx*0.75; | |||
temp.py = cmd_set.offsety == undefined ? 0 : -cmd_set.offsety*0.75; | |||
temp.w = cmd_set.width == undefined ? 150 : cmd_set.width*0.75; | |||
temp.h = cmd_set.height == undefined ? 540 : cmd_set.height*0.75; | |||
temp.o2 = $("#"+temp.id); | |||
if(temp.n == "" && temp.o2.length > 0){ | |||
let pas = data_cutin[temp.id]; | |||
if(pas.style == 0){ | |||
temp.o2.fadeToExit(temp.t); | |||
} | |||
else{ | |||
if(pas.style > 0 && pas.style <= 3) temp.o2.animate({"width":0,"left":pas.left,"backgroundPositionX":pas.imgX},temp.t,"linear"); | |||
else if(pas.style > 3 && pas.style <= 6) temp.o2.animate({"height":0,"top":pas.top,"backgroundPositionY":pas.imgY},temp.t,"linear"); | |||
} | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t,"ms"); | |||
return 2; | |||
} | |||
break; | |||
} | |||
if(temp.o2.length == 0){ | |||
temp.o2 = document.createElement('div'); | |||
temp.o1.append(temp.o2); | |||
temp.o2 = $(temp.o2); | |||
temp.o2.attr({"id":temp.id,"class":"cutin_style"}); | |||
} | |||
[temp.d1,temp.c1] = fun_char_link(temp.n); | |||
if(temp.d1 == -1) return -1; | |||
temp.n = fun_char_format(temp.d1,temp.c1); | |||
let infos = fun_char_pos(temp.d1); | |||
let fx = temp.w/2,fy = temp.h/2; | |||
/* backgroundPosition */ | |||
temp.ixe = temp.ixs = -infos[0]/2+fx; | |||
temp.iye = temp.iys = infos[3]; | |||
/* ls=left start,le=left end,ts=top start,te=top end */ | |||
temp.le = temp.ls = temp.px-fx; | |||
temp.te = temp.ts = temp.py; | |||
let cutin_paras = {}; | |||
switch(cmd_set.fadestyle) | |||
{ | { | ||
case 'horiz_expand_center': | |||
cutin_paras.style = 1; | |||
temp.ls += fx; | |||
temp.ixs -= fx; | |||
break; | |||
case 'horiz_expand_left2right': | |||
cutin_paras.style = 2; | |||
break; | |||
case 'horiz_expand_right2left': | |||
cutin_paras.style = 3; | |||
temp.ls += temp.w; | |||
temp.ixs -= temp.w; | |||
break; | |||
case 'vert_expand_center': | |||
cutin_paras.style = 4; | |||
temp.ts += fy; | |||
temp.iys -= fy; | |||
break; | |||
case 'vert_expand_top2buttom': | |||
cutin_paras.style = 5; | |||
break; | |||
case 'vert_expand_buttom2top': | |||
cutin_paras.style = 6; | |||
temp.ts += temp.h; | |||
temp.iys -= temp.h; | |||
break; | |||
default: | |||
cutin_paras.style = 0; | |||
break; | |||
} | |||
cutin_paras.width = temp.w; | |||
cutin_paras.height = temp.h; | |||
cutin_paras.offsetx = temp.px; | |||
cutin_paras.left = temp.ls; | |||
cutin_paras.top = temp.ts; | |||
cutin_paras.imgX = temp.ixs; | |||
cutin_paras.imgY = temp.iys; | |||
data_cutin[temp.id] = cutin_paras; | |||
if(!chars[temp.n]) fun_msg(-1,false,"<CharacterCutin>Data ["+temp.n+"] not exist,please check the data list."); | |||
temp.o2.css({"backgroundSize":infos[0]+"px "+infos[1]+"px","backgroundImage":"url('"+chars[temp.n]+"')","backgroundPosition":temp.ixs+"px "+temp.iys+"px"}); | |||
temp.o2.css({"left":temp.ls,"top":temp.ts}); | |||
if(cutin_paras.style == 0) temp.o2.hide().css({"width":temp.w,"height":temp.h}).fadeIn(temp.t); | |||
else if(cutin_paras.style > 0 && cutin_paras.style <= 3) temp.o2.css({"width":0,"height":temp.h}).animate({"width":temp.w,"left":temp.le,"backgroundPositionX":temp.ixe},temp.t,"linear"); | |||
else if(cutin_paras.style > 3 && cutin_paras.style <= 6) temp.o2.css({"width":temp.w,"height":0}).animate({"height":temp.h,"top":temp.te,"backgroundPositionY":temp.iye},temp.t,"linear"); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t,"ms"); | |||
return 2; | |||
} | } | ||
break; | |||
document.getElementById(" | case 'charslot': | ||
temp.p = cmd_set.slot; | |||
temp.t = +cmd_set.duration || 0.15; | |||
temp.o = $("#sys_char"); | |||
if(!temp.p){ | |||
temp.o.children().fadeToExit(temp.t*950); | |||
if(cmd_set.isblock){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
return 1; | |||
} | |||
temp.n = cmd_set.name ? cmd_set.name.toLowerCase() : ""; | |||
temp.f = cmd_set.focus || "unset"; | |||
temp.ac = cmd_set.action || ""; | |||
temp.a = cmd_set.afrom && cmd_set.ato ? [cmd_set.afrom,cmd_set.ato] : "unset"; | |||
switch(temp.p.toLowerCase()){ | |||
case "left": | |||
case "l": | |||
temp.p = "char_left"; | |||
temp.ps = -1; | |||
break; | |||
case "middle": | |||
case "m": | |||
temp.p = "char_middle"; | |||
temp.ps = 0; | |||
break; | |||
case "right": | |||
case "r": | |||
temp.p = "char_right"; | |||
temp.ps = 1; | |||
break; | |||
} | |||
temp.o1 = $("#"+temp.p); | |||
if(temp.o1.length == 0){ | |||
temp.o1 = $(document.createElement("div")); | |||
temp.o1[0].id = temp.p; | |||
temp.o1.addClass("char_style slot"); | |||
temp.o.append(temp.o1); | |||
} | |||
temp.o3 = temp.o1.children(":last"); | |||
if(temp.n){ | |||
if(!temp.o3.attr("data-n")) cmd_set.end = "false"; | |||
if(!cmd_set.focus) temp.f = cmd_set.slot; | |||
let c11 = temp.o1.children().length; | |||
/* timer.clear("char2_reset",true); */ | |||
let [n,i] = fun_char_link(temp.n); | |||
fun_msg(1,false,"<CharSlot>name="+n+",index="+i); | |||
if(n == -1) return -1; | |||
let n1 = fun_char_format(n,i); | |||
if(!chars[n1]) fun_msg(-1,false,"<CharSlot>Data ["+n1+"] not exist,please check the data list."); | |||
let [sx,sy,px,py] = fun_char_pos(n,temp.ps); | |||
if(temp.o3.attr("data-n") == n){ | |||
fun_draw_char(temp.o3[0],chars[n1],sx,sy,cmd_set.bstart,cmd_set.bend); | |||
temp.o3.fadeTo(temp.t*950,1); | |||
if(cmd_set.fadetime) temp.o3.hide().fadeIn(cmd_set.fadetime*950);/* 这里就是需要判定fadetime */ | |||
} | |||
else{ | |||
let e = $(document.createElement("canvas")); | |||
e.css({"position":"absolute","left":px,"top":py}); | |||
e.attr({"data-n":n,"width":sx,"height":sy}); | |||
fun_draw_char(e[0],chars[n1],sx,sy,cmd_set.bstart,cmd_set.bend); | |||
temp.o1.append(e); | |||
e.hide().fadeIn(temp.t*1000); | |||
temp.o1.children(":lt("+c11+")").fadeToExit(temp.t*950); | |||
temp.o3 = e; | |||
} | |||
} | |||
let pas = cmd_set.end == "true" ? {px:0,py:0,sx:1,sy:1} : temp.o1[0].props || {px:0,py:0,sx:1,sy:1}; | |||
/* preload */ | |||
temp.tsf = [pas.sx,0,0,pas.sy,pas.px,pas.py]; | |||
if(cmd_set.posfrom && cmd_set.posto){ | |||
let pf = cmd_set.posfrom.split(','),pt = cmd_set.posto.split(','); | |||
if(pf.length == 2 && pt.length == 2){ | |||
temp.tsf[4] = pf[0] * mtpy; | |||
temp.tsf[5] = -pf[1] * mtpy; | |||
pas.px = pt[0] * mtpy; | |||
pas.py = -pt[1] * mtpy; | |||
} | |||
} | |||
else if(cmd_set.posto){ | |||
let pt = cmd_set.posto.split(','); | |||
if(pt.length == 2){ | |||
pas.px += pt[0] * mtpy; | |||
pas.py -= pt[1] * mtpy; | |||
} | |||
} | |||
/* focus */ | |||
if(temp.f === "none"){ | |||
temp.o1.addClass("unfocus"); | |||
} | |||
else if(temp.f !== "unset"){ | |||
if(cmd_set.focus == "all") temp.f = "l,m,r"; | |||
let fs = temp.f.toLowerCase().split(','); | |||
/* fix focus array */ | |||
for(var i = 0;i < fs.length;i++){ | |||
switch(fs[i]){ | |||
case 'l': | |||
case 'left': | |||
fs[i] = "left"; | |||
break; | |||
case 'm': | |||
case 'middle': | |||
fs[i] = "middle"; | |||
break; | |||
case 'r': | |||
case 'right': | |||
fs[i] = "right"; | |||
break; | |||
} | |||
} | |||
temp.o.children().each((i,e)=>{ | |||
var s = e.id; | |||
for(var f of fs){ | |||
if(s.includes(f)){ | |||
e.classList.remove("unfocus"); | |||
return; | |||
} | |||
} | |||
e.classList.add("unfocus"); | |||
}); | |||
} | |||
/* action */ | |||
let trans_str = "transform "+temp.t+"s linear"; | |||
if(temp.ac){ | |||
let pw = cmd_set.power ? 0 : cmd_set.power * mtpy; | |||
let tm = cmd_set.times ? 0 : +cmd_set.times; | |||
let rand = Number.isNaN(parseInt(cmd_set.random)) ? 90 : +cmd_set.random; | |||
temp.o1.css("transform-origin",""); | |||
switch(temp.ac){ | |||
case "zoom": | |||
pas.sx = cmd_set.xscale || cmd_set.scale || pas.sx; | |||
pas.sy = cmd_set.yscale || cmd_set.scale || pas.sy; | |||
if(cmd_set.poszoom && temp.o3[0]){ | |||
let [oriX,oriY] = cmd_set.poszoom.split(','); | |||
fun_msg(1,true,`[ZoomBefore]px: ${pas.px},py: ${pas.py}`); | |||
pas.px += (0.5-oriX)*pas.sx*temp.o3[0].width; | |||
pas.py += (oriY-0.5)*pas.sy*temp.o3[0].height; | |||
temp.o1.css("transform-origin","center"); | |||
fun_msg(1,true,`[ZoomAfter]px: ${pas.px},py: ${pas.py}`); | |||
} | |||
break; | |||
case "jump": | |||
let et = tm <= 0 ? 0 : temp.t*1000/tm; | |||
for(let i=0;i<temp.tm;i++) | |||
{ | |||
setTimeout(() => { | |||
temp.o1.animate({"top":"-="+pw},et/2,(o = temp.o1)=>{ | |||
o.animate({"top":0},et/2); | |||
}); | |||
}, et*i*1000); | |||
} | |||
trans_str = "transform "+temp.t+"s ease-out"; | |||
break; | |||
case "shake": | |||
let n = "shake_" + temp.p; | |||
timer.clear(n); | |||
temp.o1.css({left:0,top:0}); | |||
if(cmd_set.stop == "true"){ | |||
temp.o1.removeAttr("d-sh-n"); | |||
temp.o1.removeAttr("d-sh-t"); | |||
return 1; | |||
} | |||
temp.o1.attr({"d-sh-n":n,"d-sh-t":0}); | |||
let c = tm > 0 ? Math.max(Math.round(temp.t*1000/tm),1) : temp.t; | |||
timer.create(temp.n2,()=>timer_shake_common(temp.o1,pw,pw,rand,tm),c,true); | |||
return 1; | |||
default: | |||
fun_msg(-1,true,"< %s >Unexcepted type of %s",match[1],temp.ac); | |||
break; | |||
} | |||
} | |||
/* transform */ | |||
temp.tst = [pas.sx,0,0,pas.sy,pas.px,pas.py]; | |||
temp.o1[0].props = pas; | |||
fun_msg(1,true,"<CharSlot>trans_from:",temp.tsf,"trans_to:",temp.tst); | |||
temp.o1.css({transform:"matrix("+temp.tsf.toString()+")"}); | |||
/* opacity */ | |||
if(Array.isArray(temp.a)){ | |||
temp.o3.fadeTo(0,temp.a[0]); | |||
temp.o3.fadeTo(temp.t*1000,temp.a[1]); | |||
} | |||
else if(temp.a != "unset" && cmd_set.afrom === cmd_set.ato){ | |||
temp.a = cmd_set.afrom; | |||
temp.o3.fadeTo(0,temp.a); | |||
} | |||
if(cmd_set.duration){ | |||
timer.create("slot_si",function(){temp.o1.css({transition:trans_str})},15); | |||
} | |||
timer.create("trans_slot",function(){temp.o1.css({transform:"matrix("+temp.tst.toString()+")"})},20); | |||
if(cmd_set.isblock == "true"){ | |||
fun_delay("block",temp.t,"s"); | |||
return 2; | |||
} | |||
break; | |||
case 'curtain': | |||
{ | |||
let dr = cmd_set.direction || "",dur = cmd_set.fadetime || 0; | |||
if(!dr){ | |||
$("#sys_masker").children(".curtain").each((idx,ele)=>{ | |||
var fr = ele.getAttribute("d-end") * 0.01; | |||
fun_curtain_create(ele.id.getValue("_"),fr,0,cmd_set.fadetime || 0); | |||
}); | |||
return 1; | |||
} | |||
let obj = document.getElementById(`curtain_${dr}`); | |||
let fr = cmd_set.fillfrom || (obj ? obj.getAttribute("d-end") : 0),ft = cmd_set.fillto; | |||
if(!fr || !ft) return -1; | |||
fun_curtain_create(dr,fr,ft,dur,cmd_set.a || 1); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",dur); | |||
return 2; | |||
} | |||
} | |||
break; | |||
case 'delay': | |||
if (!cmd_set.time) return -1; | |||
fun_delay("block",cmd_set.time); | |||
return 2; | return 2; | ||
case ' | case 'decision': | ||
{ | { | ||
return -1; | if(!cmd_set.options) return -1; | ||
let ops = fun_txt_format(cmd_set.options).split(";"),op_len = ops.length,vas = cmd_set.values.split(";"); | |||
let py = Math.max((556 - op_len * 80) / 2,72);/* 556=588-32@向上偏移32px */ | |||
let dec = document.getElementById("sys_decision"); | |||
dec.setClear(); | |||
for(let i = 0;i < op_len;i++){ | |||
let op = document.createElement("div"); | |||
dec.append(op); | |||
op.className = "decision_style"; | |||
op.innerHTML = ops[i]; | |||
op.setAttribute("d-value",vas[i]); | |||
op.addEventListener("click",function(){ | |||
var self = this; | |||
let sys_dec = document.getElementById("sys_decision"); | |||
sys_dec.setHide(); | |||
let pb = document.createElement('li'); | |||
document.getElementById("playback_result").append(pb); | |||
let arr = [...sys_dec.children]; | |||
system.decision.select = +self.getAttribute("d-value"); | |||
for (let ele of arr){ | |||
let p = document.createElement("span"); | |||
pb.append(p); | |||
p.innerHTML = "【" + ele.innerHTML + "】"; | |||
p.classList.add("decision"); | |||
if(ele == self){ | |||
p.classList.add("selected"); | |||
} | |||
} | |||
pb.style = "height: " + (arr.length * 22) + "px"; | |||
fun_audio_create(data.audio["btn_click"],{remove:true}); | |||
fun_setting("cmd_resume"); | |||
if(system.stats.auto && !timer.isTimer("auto")) timer.create("auto",()=>timer_auto(),400,true); | |||
txt_next(); | |||
}); | |||
op.style.top = py + "px"; | |||
py += 72; | |||
} | |||
if(system.stats.auto) timer.clear("auto"); | |||
fun_setting("cmd_suspend"); | |||
dec.setShow(); | |||
} | } | ||
return 2; | |||
case 'dialog': | |||
temp.t = cmd_set.fadetime == undefined ? 0 : cmd_set.fadetime; | |||
temp.b = cmd_set.block == undefined ? "false" : cmd_set.block; | |||
$("#sys_dialog").fadeOut(temp.t*950,'linear'); | |||
if(temp.b == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | } | ||
break; | break; | ||
case ' | case 'dialogsetting': | ||
{ | { | ||
let delay = system.txt.delay; | |||
if(cmd_set.reset == "true"){ | |||
delay.reset("all"); | |||
$("#dialog_name").css("color",""); | |||
return 1; | |||
} | |||
delay.set("word",cmd_set.interval); | |||
delay.set("per",cmd_set.delay); | |||
delay.set("common",cmd_set.delayall); | |||
if(cmd_set.namecolor){ | |||
$("#dialog_name").css("color",cmd_set.namecolor); | |||
} | |||
} | } | ||
if( | break; | ||
{ | case 'header': | ||
return -1; | |||
case 'hideitem': | |||
temp.o1 = $("#sys_item").children(); | |||
temp.t = cmd_set.fadetime == undefined ? 0.16 : cmd_set.fadetime; | |||
if(temp.o1.length == 0) return -1; | |||
temp.o1.fadeToExit(temp.t*1000,'linear'); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | } | ||
break; | break; | ||
case 'image': | case 'image': | ||
temp.o1 = $('#sys_image'); | |||
if( | temp.o1.children().stop(true,true); | ||
temp.t = cmd_set.fadetime ? +cmd_set.fadetime : 0.15; | |||
temp.c1 = temp.o1.children('div').length; | |||
temp.n = (cmd_set.image && cmd_set.image.toLowerCase()) || ""; | |||
if(temp.n == ""){ | |||
if(temp.t > 0){ | |||
temp.o1.children('div').fadeToExit(temp.t*1000,'linear'); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
} | |||
else temp.o1.empty(); | |||
break; | break; | ||
} | } | ||
if( | temp.e1 = document.createElement('div'); | ||
temp.e1 = $(temp.e1); | |||
temp.sx = cmd_set.xscale || cmd_set.width || 1; | |||
temp.sy = cmd_set.yscale || cmd_set.height || 1; | |||
temp.px = (cmd_set.x && cmd_set.x*0.75) || 0; | |||
temp.py = (cmd_set.y && cmd_set.y*0.75) || 0; | |||
if(imgs[temp.n] == undefined || imgs[temp.n] == ""){ | |||
fun_msg(-2,false,"<Image>Data ["+temp.n+"] not exist,please check the data list."); | |||
return -1; | |||
} | |||
temp.i1 = new Image(); | |||
temp.i1.src = imgs[temp.n]; | |||
temp.tsx = temp.i1.width*0.75;temp.tsy = temp.i1.height*0.75; | |||
if(cmd_set.screenadapt == "coverall"){ | |||
let w = temp.tsx / 960,h = temp.tsy / 540; | |||
w = Math.min(w,h); | |||
temp.tsx /= w,temp.tsy /= w; | |||
} | |||
temp.tpx = 480-temp.tsx/2,temp.tpy = 270-temp.tsy/2; | |||
temp.py = -temp.py; | |||
fun_msg(1,true,"<Image>size_x="+temp.sx+",size_y="+temp.sy+",pos_x="+temp.px+",pos_y="+temp.py); | |||
temp.e1.css({"position":"absolute","width":temp.tsx,"height":temp.tsy,"left":temp.tpx,"top":temp.tpy,"background-image":"url("+imgs[temp.n]+")","background-size":temp.tsx+"px "+temp.tsy+"px","transform":"matrix("+temp.sx+",0,0,"+temp.sy+","+temp.px+","+temp.py+")"}); | |||
temp.o1.append(temp.e1); | |||
temp.e1.hide().fadeIn(temp.t*1000,()=>{ | |||
temp.o1.children('div:lt('+temp.c1+')').remove(); | |||
}); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'imagerotate': | |||
temp.o1 = $("#sys_image").children("div:last"); | |||
if(temp.o1.length == 0) return -1; | |||
temp.ang = cmd_set.angle || 0; | |||
temp.fd = cmd_set.fadetime || 0; | |||
temp.d1 = temp.o1.css("transform").replace(/rotate\(.*?\)/g,""); | |||
temp.o1.css("transition","transform "+temp.fd+"s"); | |||
timer.create("img_rot_w",(d = temp.d1,r = temp.ang)=>{temp.o1.css("transform",d + " rotate("+r+"deg)")},20); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.fd); | |||
return 2; | |||
} | } | ||
break; | break; | ||
case 'imagetween': | case 'imagetween': | ||
return -1; | temp.o1 = $("#sys_image").children("div:last"); | ||
if(temp.o1.length == 0) return -1; | |||
return -1; | /* temp.n = (cmd_set.image && imgs[cmd_set.image.toLowerCase()]) || fun_get_url(temp.o1.css("backgroundImage")) || ""; */ | ||
temp.t = cmd_set.duration || 0.15; | |||
/* if(temp.n == "") return -1; */ | |||
/* temp.o1.css("backgroundImage","url('"+temp.n+"')"); */ | |||
temp.p = temp.o1.css("transform").replace(/\s/g,"").match(/^[a-z]+\((.*)\)/); | |||
temp.p = temp.p == null ? [1,0,0,1,0,0] : temp.p[1].split(','); | |||
if ( | temp.sxf = cmd_set.xscalefrom || cmd_set.xscale || temp.p[0]; | ||
temp.sxt = cmd_set.xscaleto || cmd_set.xscale || temp.p[0]; | |||
temp.syf = cmd_set.yscalefrom || cmd_set.yscale || temp.p[3]; | |||
temp.syt = cmd_set.yscaleto || cmd_set.yscale || temp.p[3]; | |||
temp.pxf = cmd_set.xfrom ? cmd_set.xfrom*0.75 : cmd_set.x ? cmd_set.x*0.75 : temp.p[4]; | |||
temp.pxt = cmd_set.xto ? cmd_set.xto*0.75 : cmd_set.x ? cmd_set.x*0.75 : temp.p[4]; | |||
temp.pyf = cmd_set.yfrom ? cmd_set.yfrom*0.75 : cmd_set.y ? cmd_set.y*0.75 : -temp.p[5]; | |||
temp.pyt = cmd_set.yto ? cmd_set.yto*0.75 : cmd_set.y ? cmd_set.y*0.75 : -temp.p[5]; | |||
temp.pyf = -temp.pyf;temp.pyt = -temp.pyt; | |||
fun_msg(1,true,"<ImageTween>From:xscale="+temp.sxf+",yscale="+temp.syf+",x="+temp.pxf+",y="+temp.pyf); | |||
fun_msg(1,true,"<ImageTween>To:xscale="+temp.sxt+",yscale="+temp.syt+",x="+temp.pxt+",y="+temp.pyt); | |||
temp.o1.css("transform","matrix("+temp.sxf+",0,0,"+temp.syf+","+temp.pxf+","+temp.pyf+")"); | |||
timer.create("imaget_w",()=>temp.o1.css("transition","transform "+temp.t + "s linear").css("transform","matrix("+temp.sxt+",0,0,"+temp.syt+","+temp.pxt+","+temp.pyt+")"),20); | |||
if(cmd_set.duration == undefined || cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'interlude': | |||
{ | { | ||
let ch = sets.channel; | |||
if(!ch) return -1; | |||
let obj = document.querySelector("#inter_"+ch); | |||
if(!obj){ | |||
obj = document.createElement("span"); | |||
obj.className = "interlude"; | |||
obj.id = "inter_" + ch; | |||
obj.style.position = "absolute"; | |||
} | |||
let mask = sets.maskid || ""; | |||
let [sx,sy] = sets.size ? sets.size.split(',') : [0,0]; | |||
let [px,py] = sets.offset ? sets.offset.split(',') : [0,0]; | |||
sx *= mtpy;sy *= mtpy; px *= mtpy; py *= mtpy; | |||
if(sx > 0 && sy > 0){ | |||
obj.style.width = `${sx}px`; | |||
obj.style.height = `${sy}px`; | |||
if(mask){ | |||
obj.classList.add(mask); | |||
if(mask === "ui_cutin_mask_horizon") obj.style.marginTop = `${-sy/2}px`; | |||
else if(mask === "ui_cutin_mask_vertical") obj.style.marginLeft = `${-sx/2}px`; | |||
} | |||
} | |||
} | } | ||
break; | |||
case 'gridbg': | |||
case 'verticalbg': | |||
case 'largebg': | |||
case 'largeimg': | |||
temp.mtf = m1.endsWith("bg"); | |||
temp.o1 = temp.mtf ? $("#sys_back") : $("#sys_image"); | |||
temp.ig = cmd_set.imagegroup == undefined ? [] : cmd_set.imagegroup.split('/'); | |||
temp.sw = cmd_set.solidwidth == undefined ? [] : cmd_set.solidwidth.split('/'); | |||
temp.sh = cmd_set.solidheight == undefined ? [] : cmd_set.solidheight.split('/'); | |||
if(temp.ig.length == 0 || temp.sw.length == 0 || temp.sh.length == 0) return -1; | |||
temp.px = cmd_set.x == undefined ? 0 : cmd_set.x*0.75; | |||
temp.py = cmd_set.y == undefined ? 0 : cmd_set.y*0.75; | |||
temp.sx = temp.sw.getSum()*0.9;temp.sy = temp.sh.getSum()*0.9; | |||
temp.t = cmd_set.fadetime || 0.15; | |||
temp.c1 = temp.o1.children('canvas').length; | |||
temp.o2 = document.createElement("canvas"); | |||
temp.o2 = $(temp.o2); | |||
if(m1.startsWith("grid")){ | |||
let leng = temp.ig.length,r = Math.ceil(Math.sqrt(leng)); | |||
let sx = Math.floor(temp.sx/r),sy = Math.floor(temp.sy/r); | |||
let px = (base_width-sx)/2,py = (base_height-sy)/2; | |||
temp.o2.attr({width:sx,height:sy,left:px,top:py}); | |||
for(let i = 0,offx = 0,offy = 0;i<leng;i++){ | |||
fun_draw_image(temp.o2[0],imgs[(temp.mtf ? "bg_" : "")+temp.ig[i].toLowerCase()],temp.sw[i]*0.9,temp.sh[i]*0.9,offx,offy); | |||
offx += temp.sw[i]*0.9; | |||
if(i > 0 && (i+1) % 2 == 0){ | |||
offx = 0; | |||
offy += temp.sh[i]*0.9; | |||
} | |||
} | } | ||
} | |||
{ | else if(m1.startsWith("vertical")){ | ||
let sx = temp.sx,sy = temp.sy; | |||
let px = (base_width-sx)/2,py = (base_height-sy)/2; | |||
temp.o2.attr({width:sx,height:sy,left:px,top:py}); | |||
for(let i = 0,leni = temp.sw.length,offx = 0;i<leni;i++){ | |||
for(let j = 0,lenj = temp.sh.length,offy = 0;j<lenj;j++){ | |||
fun_draw_image(temp.o2[0],imgs[(temp.mtf ? "bg_" : "")+temp.ig[i+j*leni].toLowerCase()],temp.sw[i]*0.9,temp.sh[j]*0.9,offx,offy); | |||
offy += temp.sh[j]*0.9; | |||
} | |||
offx += temp.sw[i]*0.9; | |||
} | } | ||
} | |||
{ | else if(m1.startsWith("large")){ | ||
let sx = temp.sx,sy = temp.sy; | |||
let px = (base_width-sx)/2,py = (base_height-sy)/2; | |||
temp.o2.attr({width:sx,height:sy,left:px,top:py}); | |||
for(let i = 0,offx = 0;i<temp.sw.length;i++){ | |||
for(let j=0,lenj = temp.sh.length,offy = 0;j<lenj;j++){ | |||
fun_draw_image(temp.o2[0],imgs[(temp.mtf ? "bg_" : "")+temp.ig[i*lenj+j].toLowerCase()],temp.sw[i]*0.9,temp.sh[j]*0.9,offx,offy); | |||
offy += temp.sh[j]*0.9; | |||
} | |||
offx += temp.sw[i]*0.9; | |||
} | } | ||
} | } | ||
else | else return -1; | ||
temp.o2.css({"position":"absolute","transform":`matrix(1.2,0,0,1.2,${temp.px},${-temp.py})`}); | |||
temp.o1.append(temp.o2); | |||
temp.o2.hide().fadeIn(temp.t*1000,()=>{ | |||
temp.o1.children("canvas:lt("+temp.c1+")").remove(); | |||
}); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'largebgtween': | |||
case 'largeimgtween': | |||
temp.mtf = match[1].toLowerCase() == "largebgtween"; | |||
temp.o1 = temp.mtf ? $("#sys_back") : $("#sys_image"); | |||
temp.o1 = temp.o1.children("canvas:last"); | |||
if(temp.o1.length == 0) return -1; | |||
temp.t = cmd_set.duration || 0.15; | |||
temp.p = temp.o1.css("transform").replace(/\s/g,"").match(/^[a-z]+\((.*)\)/); | |||
temp.p = temp.p == null ? [1,0,0,1,0,0] : temp.p[1].split(','); | |||
temp.sxf = cmd_set.xscalefrom || cmd_set.xscale || temp.p[0]; | |||
temp.sxt = cmd_set.xscaleto || cmd_set.xscale || temp.p[0]; | |||
temp.syf = cmd_set.yscalefrom || cmd_set.yscale || temp.p[3]; | |||
temp.syt = cmd_set.yscaleto || cmd_set.yscale || temp.p[3]; | |||
temp.pxf = cmd_set.xfrom ? cmd_set.xfrom*0.75 : cmd_set.x ? cmd_set.x*0.75 : temp.p[4]; | |||
temp.pxt = cmd_set.xto ? cmd_set.xto*0.75 : cmd_set.x ? cmd_set.x*0.75 : temp.p[4]; | |||
temp.pyf = cmd_set.yfrom ? cmd_set.yfrom*0.75 : cmd_set.y ? cmd_set.y*0.75 : -temp.p[5]; | |||
temp.pyt = cmd_set.yto ? cmd_set.yto*0.75 : cmd_set.y ? cmd_set.y*0.75 : -temp.p[5]; | |||
temp.pyf = -temp.pyf;temp.pyt = -temp.pyt; | |||
fun_msg(1,true,"<LargeBgTween>From:xscale="+temp.sxf+",yscale="+temp.syf+",x="+temp.pxf+",y="+temp.pyf); | |||
fun_msg(1,true,"<LargeBgTween>To:xscale="+temp.sxt+",yscale="+temp.syt+",x="+temp.pxt+",y="+temp.pyt); | |||
temp.o1.css("transform","matrix("+temp.sxf+",0,0,"+temp.syf+","+temp.pxf+","+temp.pyf+")"); | |||
timer.create("large_t_w",()=>temp.o1.css("transition","transform "+temp.t + "s linear").css("transform","matrix("+temp.sxt+",0,0,"+temp.syt+","+temp.pxt+","+temp.pyt+")"),20); | |||
if(cmd_set.block == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'multiline': | |||
{ | { | ||
if(cmd_set.name == undefined) return -1; | |||
system.txt.delay.set("word",cmd_set.delay*1000 || 30); | |||
system.txt.dynamic = document.getElementById("dialog_output"); | |||
if(!system.multi.mode){ | |||
system.multi.begin(); | |||
system.txt.now = ""; | |||
} | |||
system.txt.name = cmd_set.name; | |||
system.txt.now += fun_txt_format(match[5]); | |||
$("#dialog_name").html(cmd_set.name); | |||
$("#sys_dialog").show(); | |||
if(cmd_set.end == "true"){ | |||
system.multi.end(); | |||
} | |||
} | |||
return 0; | |||
case 'musicvolume': | |||
case "soundvolume": | |||
if( | temp.cmd = match[1].toLowerCase(); | ||
if(cmd_set.volume == undefined){ | |||
fun_msg(-2,false,"<"+match[1]+">Can't find the volume parameter."); | |||
return -1; | |||
} | |||
temp.ch = temp.cmd == "musicvolume" ? "sys_music" : (cmd_set.channel && "audio_" + cmd_set.channel) || ""; | |||
if(temp.ch == "") return -1; | |||
temp.o1 = document.getElementById(temp.ch); | |||
if(temp.o1 == null) return -1; | |||
temp.o1.fade(cmd_set.fadetime,cmd_set.volume*0.5); | |||
break; | |||
case 'playmusic': | |||
case 'playsound': | |||
{ | |||
let log = fun_msg; | |||
let ms = sets.delay * 1000 || 0; | |||
let intro = fun_get_audio_url(sets.intro), key = fun_get_audio_url(sets.key); | |||
let id = m1 === "playmusic" ? "sys_music" : (sets.channel && "audio_" + sets.channel) || ""; | |||
let vol = sets.volume ? Math.min(sets.volume * 0.5, 1) : 0.4; | |||
if (!key) { | |||
log(-2, false, `<${m1}>The key is not specific.`); | |||
return -1; | |||
} | } | ||
if( | if (id) { | ||
fun_stop_audio(id); | |||
} | } | ||
if ( | let args = { id: id, volume: vol, delay: ms }; | ||
if (m1 === "playsound") { | |||
args.loop = sets.loop === "true"; | |||
args.remove = !args.loop; | |||
} | } | ||
else if( | else if(m1 === "playmusic" && !intro){ | ||
args.loop = true; | |||
} | } | ||
let aud = fun_audio_create(intro || key, args); | |||
{ | aud.classList.add(m1); | ||
if (m1 === "playmusic" && intro) { | |||
aud.setAttribute("data-loop", key); | |||
aud.onended = function () { | |||
this.src = this.getAttribute("data-loop"); | |||
this.removeAttribute("data-loop"); | |||
this.loop = true; | |||
this.play(); | |||
} | |||
} | } | ||
} | } | ||
break; | break; | ||
case ' | case 'predicate': | ||
if( | if (cmd_set.references == undefined){ | ||
system.decision.mode = false; | |||
break; | |||
} | |||
if (cmd_set.references.includes(system.decision.select)){ | |||
system.decision.mode = false; | |||
break; | |||
} | |||
system.decision.mode = true; | |||
break; | |||
case 'showitem': | |||
temp.o1 = $("#sys_item"); | |||
temp.n = (cmd_set.image && cmd_set.image.toLowerCase()) || ""; | |||
temp.b = cmd_set.block || "true"; | |||
temp.t = cmd_set.fadetime || 0.16; | |||
if(temp.n == "") return -1; | |||
if(imgs[temp.n] == undefined || imgs[temp.n] == ""){ | |||
fun_msg(-2,false,"<ShowItem>Data ["+temp.n+"] not exist,please check the data list."); | |||
return -1; | |||
} | |||
temp.i1 = new Image(); | |||
temp.i1.src = imgs[temp.n]; | |||
temp.sx = temp.i1.width*0.6;temp.sy = temp.i1.height*0.6; | |||
temp.px = (960-temp.sx)/2-7.5;temp.py = (540-temp.sy)/2-7.5; | |||
temp.e1 = document.createElement('div'); | |||
temp.e1 = $(temp.e1); | |||
temp.e1.addClass("item_style"); | |||
temp.e1.css({"background-image":"url("+imgs[temp.n]+")","background-size":"100%","width":temp.sx+"px","height":temp.sy+"px","left":temp.px+"px","top":temp.py+"px"}); | |||
fun_msg(1,true,"<ShowItem>fadetime="+temp.t+",width="+temp.sx+",height="+temp.sy+",left="+temp.px+",top="+temp.py); | |||
temp.e1.hide().fadeIn(temp.t*1000); | |||
temp.o1.append(temp.e1); | |||
if(temp.b == "true"){ | |||
fun_delay("block",temp.t); | |||
return 2; | |||
} | |||
break; | |||
case 'stopmusic': | |||
case 'stopsound': | |||
{ | { | ||
let id = m1 === "stopmusic" ? "@music" : (sets.channel && "audio_" + sets.channel) || "@sound"; | |||
fun_stop_audio(id, { time: sets.fadetime || 1 }); | |||
} | |||
break; | |||
case 'sticker': | |||
case 'subtitle': | |||
temp.cmd = match[1].toLowerCase(); | |||
temp.d1 = cmd_set.text == undefined ? "" : fun_txt_format(cmd_set.text); | |||
temp.d2 = cmd_set.alignment == undefined ? "" : cmd_set.alignment; | |||
temp.d3 = cmd_set.size == undefined ? 18 : cmd_set.size*0.75; | |||
temp.d4 = cmd_set.delay == undefined ? 0 : +cmd_set.delay; | |||
temp.d5 = cmd_set.width == undefined ? 675 : cmd_set.width*0.75; | |||
temp.c1 = cmd_set.x == undefined ? 0 : cmd_set.x*0.75; | |||
temp.c2 = cmd_set.y == undefined ? 0 : cmd_set.y*0.75; | |||
temp.t = cmd_set.fadetime || 0; | |||
if(temp.cmd == "sticker" && !cmd_set.id){ | |||
fun_msg(-2,false,"<Sticker>Parameter id not applied"); | |||
return -1 | |||
} | |||
if(!temp.d1){ | |||
if(cmd_set.id){ | |||
system.multi.check(); | |||
$("#"+temp.cmd+"_"+cmd_set.id).fadeToExit(temp.t); | |||
} | |||
else if(temp.cmd == "subtitle"){ | |||
$("#sys_subtitle").children("span.subtitle").fadeToExit(temp.t); | |||
} | |||
return 1; | return 1; | ||
} | } | ||
if(cmd_set.multi == "true"){ | |||
if( | if(system.multi.mode){ | ||
system.txt.now += temp.d1; | |||
return 0; | |||
} | |||
system.multi.begin(); | |||
} | |||
if(!temp.d2){ | |||
fun_msg(-2,false,"<"+match[1]+">Parameter alignment not applied."); | |||
return -1; | |||
} | |||
if(temp.cmd == "subtitle"){ | |||
$("#sys_subtitle").children("span.subtitle").fadeToExit(temp.t); | |||
} | |||
system.txt.delay.set("word",cmd_set.delay*1000); | |||
temp.o1 = document.createElement("span"); | |||
if(cmd_set.id) temp.o1.id = temp.cmd + "_" + cmd_set.id; | |||
temp.o1.className = "subtitle_style "+temp.cmd; | |||
temp.pl = temp.d2 == "center" ? Math.max(temp.d5-fun_cal_len(temp.d1,fun_get_font(temp.d3)),0)/2 : temp.d2 == "right" ? Math.max(temp.d5-fun_cal_len(temp.d1,fun_get_font(temp.d3)),0) : 0; | |||
$(temp.o1).css({"left" : temp.c1 ,"top" : temp.c2 ,"font-size" : temp.d3 + "px","padding-left" : temp.pl,"width" : temp.d5}); | |||
$("#sys_subtitle").append(temp.o1); | |||
system.txt.name = ""; | |||
system.txt.now = temp.d1; | |||
system.txt.dynamic = temp.o1; | |||
if(!system.multi.mode) fun_playback("@p",""); | |||
return 0; | |||
case 'theater': | |||
{ | { | ||
document.getElementById(" | let mode = cmd_set.mode || "false"; | ||
let btn1 = document.getElementById("button_playback"),btn2 = document.getElementById("button_auto"); | |||
if(mode == "true"){ | |||
if(btn1.classList.contains("return")) txt_playback("sys_playback","button_playback");/* 防止极限情况下导致的bug */ | |||
system.flag.skip = 0;/* 强制停止skip模式 */ | |||
btn1.setHide(); | |||
btn2.setHide(); | |||
timer.setFake("auto"); | |||
system.stats.theater = true; | |||
} | |||
else{ | |||
btn1.setShow(); | |||
btn2.setShow(); | |||
timer.removeFake("auto"); | |||
system.stats.theater = false; | |||
} | |||
} | } | ||
break; | |||
case 'timerclear': | |||
{ | { | ||
document.getElementById(" | let span = document.getElementById("sticker_timer"); | ||
if(!span) return -1; | |||
$(span).css("opacity",cmd_set.afrom || 1).fadeTo(cmd_set.duration*1000 || 0,cmd_set.ato || 0); | |||
timer.clear("sticker_timer"); | |||
} | } | ||
break; | |||
case 'timersticker': | |||
{ | { | ||
let px = cmd_set.x*0.75 || 0,py = cmd_set.y*0.75 || 0,size = cmd_set.size*0.75 || 18; | |||
if( | var span = document.getElementById("sticker_timer"); | ||
if(!span){ | |||
span = document.createElement("span"); | |||
document.getElementById("sys_subtitle").append(span); | |||
} | } | ||
span.className = "subtitle_style"; | |||
let id = "sticker_timer"; | |||
span.id = id; | |||
span.style.fontSize = `${size}px`; | |||
span.style.left = `${px}px`; | |||
} | span.style.top = `${py}px`; | ||
span.setAttribute("max-t",cmd_set.time || -1); | |||
span.setAttribute("now-t",0); | |||
span.innerHTML = fun_format_time(0); | |||
timer.create(id,(n = id)=>{ | |||
var e = document.getElementById(n); | |||
if(!e){ | |||
timer.clear(n,false); | |||
return; | |||
} | |||
var t = parseInt(e.getAttribute("now-t")) || 0,tm = parseInt(e.getAttribute("max-t")); | |||
e.setAttribute("now-t",++t); | |||
e.innerHTML = fun_format_time(t); | |||
if(tm < 0 || t < tm) return; | |||
timer.clear(n,false); | |||
},1000,true); | |||
} | } | ||
if( | break; | ||
{ | case 'video': | ||
if(cmd_set.res == undefined) return -1; | |||
fun_setting("cmd_suspend"); | |||
temp.o1 = document.createElement("video"); | |||
$(temp.o1).attr({"width":960,"heigth":540,"autoplay":"autoplay","src":source_url + cmd_set.res}); | |||
temp.o1.onended = function(){ | |||
this.remove(); | |||
fun_setting("cmd_resume"); | |||
txt_next(); | |||
} | } | ||
$("#sys_animation").append(temp.o1); | |||
return 2; | |||
return | |||
default: | default: | ||
fun_msg(-1,true,"Unknown command:"+match[1]); | |||
return -1; | return -1; | ||
} | } | ||
return 1; | return 1; | ||
} | } | ||
else if( | else if(match[3]) | ||
{ | { | ||
switch( | switch(match[3].toLowerCase()) | ||
{ | { | ||
case 'background': | |||
$("#sys_back").children('div').remove(); | |||
break; | |||
case 'character': | |||
case 'charslot': | |||
$("#sys_char").children().fadeToExit(150); | |||
fun_delay("block",0.2); | |||
return 2; | |||
case 'curtain': | |||
$("#sys_masker").children(".curtain").remove(); | |||
break; | |||
case 'dialog': | case 'dialog': | ||
$("#dialog_name").empty(); | |||
$("#dialog_output").empty(); | |||
$("#sys_dialog").hide(); | |||
break; | break; | ||
case ' | /* @self define command */ | ||
case 'dialogsetting': | |||
system.txt.delay.reset("all"); | |||
$("#dialog_name").removeAttr("style"); | |||
break; | break; | ||
case 'image': | case 'image': | ||
$("#sys_image").children('div').remove(); | |||
break; | |||
case 'gridbg': | |||
case 'verticalbg': | |||
case 'largebg': | |||
$("#sys_back").children('canvas').remove(); | |||
break; | |||
case 'largeimg': | |||
$("#sys_image").children('canvas').remove(); | |||
break; | break; | ||
case ' | case 'predicate': | ||
system.decision.mode = false; | |||
break; | break; | ||
case 'hideitem': | |||
$("#sys_item").children("div").fadeToExit(320); | |||
fun_delay("block",0.32); | |||
return 2; | |||
/* @self define command */ | |||
case 'skiptoend': | |||
system.txt.index = system.txt.max; | |||
return 2; | |||
case 'stickerclear': | |||
$("#sys_subtitle").children("span.sticker").fadeToExit(200); | |||
fun_delay("block",0.2); | |||
return 2; | |||
case 'subtitle': | |||
$("#sys_subtitle").children("span.subtitle").fadeToExit(200); | |||
fun_delay("block",0.2); | |||
return 2; | |||
default: | |||
return -1; | |||
} | } | ||
return 1; | return 1; | ||
} | } | ||
else if( | else if(!match[5]) | ||
return -1; | |||
else if(match[4]) | |||
{ | { | ||
let p = match[4].toObject(); | |||
{ | system.txt.dynamic = document.getElementById("dialog_output"); | ||
if(p.delay){ | |||
return | fun_delay("block",p.delay); | ||
return 2; | |||
} | |||
if(p.bind){ | |||
fun_audio_create(fun_get_audio_url(p.bind),{vol:0.5,id:"dialog_audio",remove:true}); | |||
} | } | ||
if(p.name == undefined) return -1; | |||
system.multi.check(); | |||
system.txt.name = p.name; | |||
system.txt.now = fun_txt_format(match[5]); | |||
fun_playback("@p",p); | |||
$("#dialog_name").html(p.name); | |||
$("#dialog_name").css("color",p.color == undefined ? "" : p.color); | |||
$("#sys_dialog").show(); | |||
} | } | ||
return 0; | return 0; | ||
} | } | ||
function | function txt_click() | ||
{ | { | ||
if( | if(!system || system.stats.theater || timer.hasTimer("click_block")) return; | ||
if(system.stats.auto) fun_auto_stop(); | |||
if(!system.stats.click) | |||
{ | { | ||
fun_msg(0,true,"Click didn't passed."); | |||
return; | |||
} | |||
fun_msg(0,true,"Click passed."); | |||
if(system.txt.index == 0) fun_setting("pre"); | |||
let audio = document.getElementById("dialog_audio"); | |||
if(audio){ | |||
audio.dispose(); | |||
} | } | ||
if(timer.hasTimer("dynamic")) | |||
if( | |||
{ | { | ||
txt_stop(); | |||
system.txt.dynamic.innerHTML = system.txt.now; | |||
return; | return; | ||
} | } | ||
txt_next(); | |||
} | |||
function txt_fullscreen() | |||
{ | |||
let e1 = document.getElementById("sys_fullscreen"),e2 = document.getElementById("button_fullscreen"); | |||
if(!e1 || !e2) return 0; | |||
if( | let isFull = e2.classList.contains("return"); | ||
if(isFull){ | |||
if(fun_fullscreen_check()){ | |||
if(document.exitFullscreen) document.exitFullscreen(); | |||
{ | else if(document.mozCancelFullScreen) document.mozCancelFullScreen(); | ||
else if(document.webkitExitFullscreen) document.webkitExitFullscreen();/* new webkit */ | |||
else if(document.webkitCancelFullScreen) document.webkitCancelFullScreen();/* old webkit */ | |||
else if(document.msExitFullscreen) document.msExitFullscreen(); | |||
} | } | ||
} | } | ||
else if( | else{ | ||
if(e1.requestFullscreen) e1.requestFullscreen(); | |||
else if(e1.mozRequestFullScreen) e1.mozRequestFullScreen(); | |||
else if(e1.webkitRequestFullscreen) e1.webkitRequestFullscreen();/* new webkit */ | |||
else if(e1.webkitRequestFullScreen) e1.webkitRequestFullScreen();/* old webkit */ | |||
else if(e1.msRequestFullscreen) e1.msRequestFullscreen(); | |||
} | } | ||
} | } | ||
function | function txt_next() | ||
{ | { | ||
if( | /* before */ | ||
if (system.txt.index >= system.txt.max){ | |||
fun_msg(1,true,"<Txt>index="+system.txt.index+",max="+system.txt.max); | |||
if(timer.hasTimer("auto")) fun_auto_stop(); | |||
fun_setting("reset"); | |||
document.getElementById("dialog_output").innerHTML = "剧情模拟已结束,单击将重新开始剧情回顾"; | |||
return; | return; | ||
} | } | ||
/* check */ | |||
if( | let ret = 0,idx = system.txt.index,txt = data.txt[idx]; | ||
{ | $(".dialog_style.header").attr({"d-now":idx}); | ||
ret = txt === "" ? -2 : system.debug ? txt_analyze_test(txt) : txt_analyze(txt); | |||
if(system.debug && system.stats.step && ret == 1) ret = 2; | |||
if(ret !== 0) system.txt.index++; | |||
switch(ret){ | |||
case -2: | |||
fun_msg(0,true,"Has skipped the space or unused part."); | |||
txt_next(); | |||
break; | |||
case -1: | |||
fun_msg(0,true,"Has skipped the error part."); | |||
txt_next(); | |||
break; | |||
case 1: | |||
fun_msg(0,true,"Data analyze complete."); | |||
txt_next(); | |||
break; | |||
case 2: | |||
fun_msg(0,true,"Break and wait."); | |||
break; | |||
default: | |||
if(system.txt.index < system.txt.max && system.txt.index >= 0){ | |||
let i = system.flag.skip >= wait_trigger ? 1 : system.txt.delay.word; | |||
timer.create("dynamic",()=>timer_dialog(),i,true); | |||
} | |||
break; | |||
} | } | ||
} | } | ||
function | function txt_playback(target,bind,isAll = false) | ||
{ | { | ||
let obj1 = document.getElementById(target),obj2 = document.getElementById(bind); | |||
{ | let isIn = obj2.classList.contains("return"); | ||
if(isIn){ | |||
if (system.stats.auto && system.flag.respond == 1 && !isAll){ | |||
timer.create("auto",()=>timer_auto(),400,true); | |||
if(!timer.hasTimer("txt") && !timer.hasTimer("dynamic")) txt_next(); | |||
} | |||
obj1.setHide(); | |||
obj2.classList.add("normal"); | |||
obj2.classList.remove("return"); | |||
system.flag.respond--; | |||
} | } | ||
else{ | |||
if(system.stats.auto && system.flag.respond == 0 && !isAll) timer.clear("auto"); | |||
obj1.setShow(); | |||
if(!isAll) { | |||
obj1.scrollTop = obj1.scrollHeight-540; | |||
} | |||
obj2.classList.remove("normal"); | |||
obj2.classList.add("return"); | |||
system.flag.respond++; | |||
} | } | ||
} | } | ||
function | function txt_stop() | ||
{ | { | ||
let txt = system.txt,delay = txt.delay; | |||
let p = delay.per,c = delay.common; | |||
if(system.flag.skip >= wait_trigger){ | |||
p = 0; | |||
} | c = 0; | ||
} | |||
if(txt.dynamic.parentElement){ | |||
if( | /* if is subtitle,reset the interval. */ | ||
if(txt.dynamic.parentElement.id == "sys_subtitle"){ | |||
if( | delay.reset("word"); | ||
} | } | ||
} | } | ||
let ms = txt.now.length*p+c; | |||
{ | let obj = $("#dialog_audio"); | ||
if(system.stats.theater){ | |||
ms = c; | |||
} | } | ||
else if(obj.length > 0){ | |||
let voice = obj[0]; | |||
ms = (voice.duration-voice.currentTime)*1000; | |||
} | } | ||
timer.clear("txt"); | |||
timer.create("txt",()=>{ | |||
if(timer.hasTimer("auto")) txt_next(); | |||
}, ms); | |||
timer.clear("dynamic"); | |||
timer.create("click_block",function(){},100); | |||
if(system.multi.mode) system.txt.over(); | |||
else system.txt.init(); | |||
system.txt.index++; | |||
} | } | ||
function | function timer_auto() | ||
{ | { | ||
let ele = document.getElementById("button_auto"); | |||
switch ( | switch (system.flag.auto) | ||
{ | { | ||
case 1: | case 1: | ||
ele.innerHTML = "自动▶"; | |||
break; | break; | ||
case 2: | case 2: | ||
ele.innerHTML = "自动▶▶"; | |||
break; | break; | ||
case 3: | case 3: | ||
ele.innerHTML = "自动▶▶▶"; | |||
system.flag.auto=0; | |||
break; | break; | ||
} | } | ||
system.flag.auto++; | |||
} | } | ||
function | function timer_dialog() | ||
{ | { | ||
let txt = system.txt; | |||
if( | let tag = "",str = txt.now,str_tmp = txt.now_temp,len = str.length,idx = txt.now_index; | ||
{ | if (idx < len){ | ||
if(str[idx] == "<"){ | |||
let i = idx; | |||
while(++i < len && str[i] != ">"); | |||
if(i < len){ | |||
if(str[idx + 1] != "/"){ | |||
tag = "</" + str.substring(idx + 1, i) + ">"; | |||
fun_msg(1, true, "<TimerDialog>tag=" + tag); | |||
} | |||
if(str[i + 1] == "<"){/* prevent the belong mark. */ | |||
let i2 = i + 1; | |||
while(++i2 < len && (str[i2] != ">" || str[i2 + 1] == "<")); | |||
if(i2 < len) i = i2; | |||
} | |||
str_tmp += str.substring(idx,i + 1); | |||
idx = i + 1; | |||
} | |||
} | |||
else if(str.substring(idx,idx + 2) == "&#" && str.match(/&#\d{4};/)){ | |||
str_tmp += str.substring(idx,idx+7); | |||
idx += 7; | |||
} | |||
txt.now_temp = str_tmp + (txt.now[idx] || ""); | |||
txt.dynamic.innerHTML = txt.now_temp + tag; | |||
txt.now_index = Math.min(++idx,len); | |||
return; | |||
} | |||
txt_stop(); | |||
} | |||
function timer_shake_common(tar,str_x,str_y,ustb_p,max_t){ | |||
let o = tar; | |||
if(typeof tar === "string"){ | |||
o = $("#"+tar); | |||
} | |||
if(!o.length){ | |||
timer.clearAll(); | |||
fun_msg(-2,false,"<ShakeCommon>Err tar of [%s]",tar); | |||
return; | |||
} | } | ||
let rx = parseInt(Math.random()*99) + 1,ry = parseInt(Math.random()*99) + 1; | |||
fun_msg(1,true,"<ShakeCommon>rnd_x:"+rx+",rnd_y:"+ry); | |||
{ | let d = [-1,-0.707,0,1,0.707]; | ||
rx = rx < ustb_p ? parseInt(Math.random()*5) : 0; | |||
ry = ry < ustb_p ? parseInt(Math.random()*5) : 0; | |||
o.css({left:d[rx]*str_x,top:d[ry]*str_y}); | |||
let t = parseInt(o.attr("d-sh-t")); | |||
if(max_t < 0) return; | |||
else if(++t < max_t){ | |||
o.attr("d-sh-t",t); | |||
return; | |||
} | } | ||
let n = o.attr("d-sh-n"); | |||
timer.clear(n); | |||
o.css({left:0,top:0,"transform-duration":""}); | |||
o.removeAttr("d-sh-t"); | |||
o.removeAttr("d-sh-n"); | |||
} | } | ||
function | function fun_auto_stop() | ||
{ | { | ||
timer.clear("auto"); | |||
document.getElementById(" | document.getElementById("button_auto").innerHTML = "自动▶"; | ||
if( | system.stats.auto = false; | ||
{ | } | ||
function fun_audio_create(url,args){ | |||
if(!url) return; | |||
if(!args) args = {}; | |||
var sound = new Audio(url); | |||
document.getElementById("sys_audio").append(sound); | |||
sound.id = args.id || ""; | |||
sound.volume = args.vol*0.5 || 0.5; | |||
if(args.loop){ | |||
sound.loop = true; | |||
} | |||
else if(args.remove){ | |||
sound.onended = function(){this.remove();} | |||
} | |||
if (args.delay) { | |||
setTimeout(() => { | |||
sound.play(); | |||
}, args.delay); | |||
} | |||
else { | |||
sound.autoplay = true; | |||
} | } | ||
return sound; | |||
{ | } | ||
function fun_cal_len(str,font,base = 0) | |||
{ | |||
let arr = str.split('<br/>'), len = 0; | |||
for (let d of arr) { | |||
let s = d.replace(/\<.*?\>/g, ""); | |||
let px = s.getPx(font); | |||
len += base ? Math.ceil(px / base) : px; | |||
} | } | ||
return len; | |||
} | } | ||
function | function fun_cal_rgba(c_r,c_g,c_b,c_a) | ||
{ | { | ||
let d = [c_r,c_g,c_b,c_a]; | |||
for (let i = 0;i < d.length;i++) | |||
{ | { | ||
d[i] = Math.max(0,d[i]); | |||
if(d[i] <= 1) d[i] = parseInt(d[i]*255); | |||
d[i] = d[i].toString(16); | |||
if(d[i] < 0x10) d[i] = "0" + d[i]; | |||
} | } | ||
return "#" + d[0] + d[1] + d[2] + d[3]; | |||
} | } | ||
function | function fun_char_link(key_data) | ||
{ | { | ||
let n,i,links = data.link; | |||
if( | let key = key_data.trim(); | ||
if(!key) | |||
{ | { | ||
return; | fun_msg(-2,false,"The input parameter is empty,has skipped the data."); | ||
return [-1,-1]; | |||
} | } | ||
let m = key.match(/^([^@#$]+)(?:([@#$])([a-z\d]+)|#(\d+)\$(\d+))?$/); | |||
if( | if(m == null) | ||
{ | { | ||
fun_msg(-2,false,"Can't get key from the input parameter,has skipped the data."); | |||
return [-1,-1]; | |||
} | } | ||
n = m[1],i = m[3]; | |||
if(links[n] == undefined) | |||
if( | |||
{ | { | ||
if ( | fun_msg(-2,false,"The appointed key ["+n+"] not exist,has skipped the data."); | ||
{ | return [-1,-1]; | ||
} | |||
if(m[2] == '$' || (m[4] && m[5])){ | |||
let g = '$' + (m[5] || i);/* group */ | |||
i = m[4] || i; | |||
let ps = links[n].array.findIndex((v)=>v.name.endsWith(g)),pe = links[n].array.findIndex((v,vi)=>!v.name.endsWith(g) && vi>ps); | |||
if(ps == -1){ | |||
fun_msg(-1,false,"The analyze key ["+n+":"+i+"] not exist,use the default char to instead."); | |||
return [n,0]; | |||
} | |||
pe = pe == -1 ? links[n].array.length - 1 : pe - 1; | |||
if(m[2]) return [n,ps]; | |||
try{ | |||
i--; | |||
} | |||
catch(err){ | |||
fun_msg(-1,false,"Data analyze error,use the default char to instead."); | |||
i = ps; | |||
} | |||
if(i > pe-ps){ | |||
fun_msg(-1,false,"The analyze key ["+n+":"+i+"] is out of range,use the default char to instead."); | |||
i = ps; | |||
} | |||
return[n,i+ps]; | |||
} | |||
else if(m[2] == "#"){ | |||
try{ | |||
i--; | |||
} | |||
catch(err){ | |||
fun_msg(-1,false,"Data analyze error,use the default char to instead."); | |||
i = 0; | |||
} | } | ||
if(i >= links[n].array.length) | |||
{ | { | ||
fun_msg(-1,false,"The analyze key ["+n+":"+i+"] is out of range,use the default char to instead."); | |||
i = 0; | |||
} | } | ||
return [n,i]; | |||
} | |||
else if(m[2] == '@'){ | |||
for(let idx = 0;idx<links[n].array.length;idx++) if(links[n].array[idx].alias == i) return [n,idx]; | |||
fun_msg(-1,false,"Data analyze error,use the default char to instead."); | |||
return [n,0]; | |||
} | |||
return [n,0]; | |||
} | |||
function fun_char_format(key,idx){ | |||
if(!data.link[key]){ | |||
fun_msg(-2,false,"Character key ["+key+"] not exist,please check the link list."); | |||
return key; | |||
} | } | ||
return data.link[key].array[idx].name; | |||
{ | } | ||
function fun_char_pos(key,pos = 0){ | |||
let links = data.link,mtpy = pos_multiply; | |||
let px,py,sx,sy; | |||
px=links[key].pos.x * mtpy; | |||
py=links[key].pos.y * mtpy; | |||
sx=links[key].size.x * mtpy; | |||
sy=links[key].size.y * mtpy; | |||
switch(pos){ | |||
case -1: | |||
px = 330-sx/2+px; | |||
break; | |||
case 0: | |||
px = 480-sx/2+px; | |||
break; | |||
case 1: | |||
px = 630-sx/2+px; | |||
break; | |||
} | |||
py = 540-sy/2-py; | |||
return [sx,sy,px,py]; | |||
} | |||
function fun_get_font(size) | |||
{ | |||
return size + "px Noto Sans S Chinese"; | |||
} | |||
function fun_debug_analyze(txt,forcefun = 0){ | |||
let r,fun = ""; | |||
if((system.debug && !forcefun) || forcefun == -1){ | |||
r = txt_analyze_test(txt); | |||
fun = "txt_analyze_test"; | |||
} | |||
else if((!system.debug && !forcefun) || forcefun == 1){ | |||
r = txt_analyze(txt); | |||
fun = "txt_analyze"; | |||
} | |||
else{ | |||
fun_msg(-2,false,"Error parameter value."); | |||
} | } | ||
fun_msg(1,false,"text data use ["+ fun +"] analyze complete.return code:["+ r +"]"); | |||
} | |||
function fun_delay(key_cmd,key_time,key_type = "s") | |||
{ | |||
if(system.stats.step) return; | |||
var t = Number.isNaN(+key_time) ? 1 : +key_time; | |||
if(key_type == "s") t *= 1000; | |||
if(key_cmd == "block") | |||
{ | { | ||
fun_setting("cmd_close"); | |||
if(system.flag.skip == wait_trigger) t = 0; | |||
setTimeout(function(){ | |||
fun_setting("cmd_open"); | |||
if(system.stats.reset) txt_next(); | |||
},t); | |||
} | } | ||
} | } | ||
function | /** | ||
* @param {HTMLCanvasElement} can | |||
* @param {String} url | |||
* @param {Number} w | |||
* @param {Number} h | |||
* @param {Number[]} black | |||
*/ | |||
function fun_draw_char(can,url,w,h,...black) | |||
{ | { | ||
var img = new Image(); | |||
img.src = url; | |||
img.onload = function(){ | |||
if( | if(can.width != w || can.height != h) | ||
{ | { | ||
can.width = w; | |||
can.height = h; | |||
} | } | ||
fun_msg(1,true,"<DrawChar>img_w="+img.width+",img_h="+img.height); | |||
var ctx = can.getContext("2d"); | |||
ctx.clearRect(0,0,w,h); | |||
if(ctx.globalCompositeOperation == "source-atop") ctx.globalCompositeOperation = "source-over"; | |||
ctx.drawImage(img,0,0,w,h); | |||
if(black.length == 0 || black[0] == undefined || black[1] == undefined) return; | |||
/*draw black cover*/ | |||
var gri = ctx.createLinearGradient(0,h*black[0],0,h*black[1]); | |||
gri.addColorStop(0,"black");gri.addColorStop(1,"rgba(0,0,0,0)"); | |||
ctx.fillStyle = gri; | |||
ctx.globalCompositeOperation = "source-atop"; | |||
ctx.fillRect(0,0,w,h*black[1]); | |||
} | |||
} | |||
function fun_curtain_create(dire,fr,to,dur,alpha){ | |||
const dire_map = {"0":"180deg","1":"225deg","2":"270deg","4":"0deg","5":"45deg","6":"90deg"}; | |||
var dire_name = `curtain_${dire}`,ele = document.getElementById(dire_name); | |||
if(!ele){ | |||
ele = document.createElement("div"); | |||
ele.id = dire_name; | |||
ele.className = "common_style curtain"; | |||
document.getElementById("sys_masker").append(ele); | |||
} | } | ||
var ang= Number.isNaN(+dire) ? dire : dire_map[dire],fr_p = fr*100,to_p = to*100; | |||
{ | var tick = dur*100; | ||
if(tick <= 0){ | |||
ele.style.backgroundImage = "linear-gradient("+ang+",black "+to_p+"%,transparent "+to_p+"%)"; | |||
ele.style.opacity = parseFloat(alpha); | |||
return; | |||
} | } | ||
var now = fr_p,sep = (to_p-fr_p)/tick,sep_a = (1-alpha)/tick; | |||
{ | ele.setAttribute("d-end",to_p); | ||
ele.setAttribute("d-now",now); | |||
ele.setAttribute("d-sep",sep); | |||
if(sep_a){ | |||
ele.style.opacity = 1; | |||
ele.setAttribute("d-alpha",alpha); | |||
ele.setAttribute("d-sep-a",sep_a); | |||
} | } | ||
timer.create("dyn_curtain_"+dire,function(){ | |||
{ | var o = document.getElementById(dire_name); | ||
if(!o){ | |||
timer.clear("dyn_curtain_"+dire); | |||
return; | |||
} | |||
var n = o.getAttribute("d-now"),s = o.getAttribute("d-sep"),e = o.getAttribute("d-end"),s_a = o.getAttribute("d-sep-a"); | |||
n = +n + +s; | |||
o.style.backgroundImage = "linear-gradient("+ang+",black "+n+"%,transparent "+n+"%)"; | |||
if(s_a){ | |||
var n_a = o.style.opacity; | |||
n_a -= parseFloat(s_a); | |||
o.style.opacity = n_a; | |||
} | |||
if((s > 0 && n < e) || (s < 0 && n > e)){ | |||
o.setAttribute("d-now",n); | |||
return; | |||
} | |||
timer.clear("dyn_curtain_"+dire); | |||
o.style.backgroundImage = "linear-gradient("+ang+",black "+e+"%,transparent "+e+"%)"; | |||
if(s_a){ | |||
o.style.opacity = parseFloat(o.getAttribute("d-alpha")); | |||
} | |||
},10,true); | |||
} | |||
function fun_draw_image(can,url,w,h,x,y){ | |||
var img = new Image(); | |||
img.src = url; | |||
img.onload = function(){ | |||
fun_msg(1,true,"<DrawImage>url: "+ url +"img_w: "+this.width+",img_h: "+this.height); | |||
var ctx = can.getContext("2d"); | |||
ctx.clearRect(x,y,w,h); | |||
ctx.drawImage(img,x,y,w,h); | |||
} | } | ||
} | |||
function fun_fullscreen(){ | |||
let sx = screen.width,sy = screen.height; | |||
let s = Math.min(sx/base_width,sy/base_height); | |||
let px=(sx-base_width*s)/2,py=(sy-base_height*s)/2; | |||
fun_msg(1,true,"screen.width: "+sx+",screen.height: "+sy+",scale: "+s); | |||
fun_msg(1,true,"screen.availWidth: "+screen.availWidth+",screen.availHeight: "+screen.availHeight+",width_offset: "+px+",height_offset: "+py); | |||
let ele1 = document.getElementById("sys_main"),ele2=document.getElementById("button_fullscreen"),ele3=document.getElementById("sys_offset"); | |||
if(fun_fullscreen_check()){ | |||
ele1.style.transform = "scale(" + s + ")"; | |||
ele2.classList.remove("normal"); | |||
ele2.classList.add("return"); | |||
ele3.style.left = px + "px"; | |||
ele3.style.top = py + "px"; | |||
} | } | ||
else | else{ | ||
ele1.style.transform = ""; | |||
ele2.classList.add("normal"); | |||
ele2.classList.remove("return"); | |||
ele3.style.left = ""; | |||
ele3.style.top = ""; | |||
} | } | ||
} | } | ||
function | function fun_fullscreen_check(){ | ||
return !!(document.fullscreen || document.mozFullScreen || document.webkitIsFullScreen || document.webkitFullScreen || document.msFullScreen); | |||
} | |||
function fun_fullscreen_support(){ | |||
/* if(!system.debug && (system.user.client == "mobile" || system.user.display == "vert")) return false; */ | |||
let temp = document.documentElement; | |||
return document.fullscreenEnabled && ('requestFullscreen' in temp || 'webkitRequestFullScreen' in temp || ('mozRequestFullScreen' in temp && document.mozFullScreenEnabled) || false) | |||
} | |||
function fun_get_url(n) | |||
{ | |||
return n.replace(/^url\(["']|["']\)$/g,""); | |||
} | |||
function fun_get_audio_url(key) | |||
{ | { | ||
if( | if(!key) return ""; | ||
{ | let p = key.toLowerCase(); | ||
return key.startsWith("$") ? data.audio[p.substr(1)] : key.startsWith("@") ? assets_url + p.substr(1) : assets_url + p.replace("sound_beta_2", "audio") + ".mp3"; | |||
} | |||
/** | |||
* 向控制台输出一条带有时间信息的数据 | |||
* @function 向控制台输出信息 | |||
* @description 向控制台输出一条带有时间信息的数据 | |||
* @param msgs {String[]} 需要输出的消息 | |||
* @param msg_type {Number} 消息类型:Info=0,Debug=1,Warn=-1,Error=-2;Special color Info=2+ | |||
* @param msg_debug {Boolean} 是否只在debug状态下输出消息:true(默认)=仅在debug状态下输出消息,false=无论何时都会输出消息 | |||
* @return void | |||
* @author Krliov | |||
*/ | |||
function fun_msg(msg_type,msg_debug,...msgs) | |||
{ | |||
if(msg_debug && !system.debug) return; | |||
let t = new Date(); | |||
let t_txt = t.getFullYear() + "-" + (t.getMonth()+1) + "-" + t.getDate() + " " + t.getHours() + ":" + t.getMinutes() + ":" + t.getSeconds(); | |||
let data = msgs.slice(1); | |||
data.unshift(t_txt); | |||
switch(msg_type){ | |||
case -2: | |||
data.unshift("[%s][Error]:" + msgs[0]); | |||
console.error(...data); | |||
break; | |||
case -1: | |||
data.unshift("[%s][Warn]:" + msgs[0]); | |||
console.warn(...data); | |||
break; | |||
case 0: | |||
data.unshift("[%s][Info]:" + msgs[0]); | |||
console.log(...data); | |||
break; | |||
case 1: | |||
data.unshift("%c[%s][Debug]:" + msgs[0],"background-color:orange;"); | |||
console.log(...data); | |||
break; | |||
case 2: | |||
data.unshift("%c[%s][Info]:" + msgs[0],"color:#0080ff"); | |||
console.log(...data); | |||
break; | |||
case 3: | |||
data.unshift("%c[%s][Info]:" + msgs[0],"color:#0080ff"); | |||
console.log(...data); | |||
break; | |||
} | } | ||
} | |||
{ | function fun_playback(tar,para,txt = system.txt.now){ | ||
let o = document.createElement("li"); | |||
let n = typeof para === "object" ? para.name : para; | |||
if(n == undefined || !txt) return; | |||
switch(tar){ | |||
case 'playback': | |||
case '@p': | |||
tar = "playback_result"; | |||
break; | |||
case 'playback_all': | |||
case '@pa': | |||
tar = para.mode ? para.target : "playback_all_result"; | |||
break; | |||
} | } | ||
if(n.trim()){ | |||
let e1 = document.createElement("em"); | |||
e1.innerHTML = n; | |||
o.append(e1); | |||
} | } | ||
let e2 = document.createElement("span"); | |||
{ | e2.innerHTML = txt.replace(/\<(?!br).*?\>/g,""); | ||
o.append(e2); | |||
if(fun_cal_len(n,fun_get_font(16)) > log_em_limit_px) o.childNodes[0].style.fontSize = "12px"; | |||
if(typeof para === "object" && para.color != undefined) o.childNodes[0].style.color = para.color; | |||
if(typeof tar === "string") tar = document.getElementById(tar); | |||
if(tar) tar.append(o); | |||
} | |||
function fun_setting(key) | |||
{ | |||
switch(key){ | |||
case "pre": | |||
{ | |||
if (system.debug) system.txt.max = data.txt.length; | |||
else if(system.txt.max == 0) system.txt.max = data.txt.length; | |||
fun_msg(1,true,"<Txt>max: "+system.txt.max); | |||
system.stats.reset = true; | |||
var eles = document.getElementsByClassName("dialog_style header"); | |||
if(eles){ | |||
eles[0].setAttribute("d-max",system.txt.max); | |||
} | |||
document.getElementById("dialog_name").setClear(); | |||
document.getElementById("dialog_output").setClear(); | |||
document.getElementById("playback_result").setClear(); | |||
document.getElementById("sys_dialog").hide(); | |||
document.getElementById("button_reset").classList.remove("forbid"); | |||
document.getElementById("sys_blocker").style.backgroundColor = "rgba(0,0,0,0)"; | |||
} | |||
break; | |||
case "reset": | |||
{ | |||
fun_stop_audio("@all"); | |||
timer.clearAll(); | |||
document.getElementById("sys_animation").setClear(); | |||
document.getElementById("sys_subtitle").setClear(); | |||
document.getElementById("sys_back").setClear(); | |||
document.getElementById("sys_image").setClear(); | |||
document.getElementById("sys_char").setClear(); | |||
document.getElementById("sys_item").setClear(); | |||
document.getElementById("sys_cutin").setClear(); | |||
document.getElementById("sys_decision").setHide(); | |||
document.getElementById("sys_camera").style = ""; | |||
document.getElementById("sys_blocker").style = ""; | |||
document.getElementById("dialog_name").style = ""; | |||
document.getElementById("dialog_name").innerHTML = "剧情模拟器"; | |||
document.getElementById("sys_dialog").show(); | |||
system.stats.reset = false; | |||
system.multi.reset(); | |||
if(system.stats.theater){ | |||
system.stats.theater = false; | |||
document.getElementById("button_playback").setShow(); | |||
document.getElementById("button_auto").setShow(); | |||
} | |||
fun_setting("cmd_open"); | |||
document.getElementById("button_reset").classList.add("forbid"); | |||
system.txt.index = 0;system.txt.dynamic = null;system.flag.respond = 0; | |||
} | |||
break; | |||
case "cmd_suspend": | |||
system.flag.respond++; | |||
case "cmd_close": | |||
system.stats.click = false; | |||
break; | |||
case "cmd_resume": | |||
system.flag.respond--; | |||
case "cmd_open": | |||
system.stats.click = true; | |||
break; | |||
} | } | ||
} | |||
function fun_stop_audio(key,args) | |||
{ | |||
let pas = args || { time: 0.5 }; | |||
if (!key.startsWith("@")) { | |||
let tar = document.getElementById(key); | |||
if (tar) tar.fade(pas.time, 0, true); | |||
return; | |||
} | } | ||
switch(key){ | |||
case "@all": | |||
{ | |||
let tars = document.getElementById("sys_audio").children; | |||
for (let tar of tars) { | |||
tar.fade(1, 0, true); | |||
} | |||
} | |||
break; | |||
case "@music": | |||
{ | |||
let tar = document.getElementById("sys_music"); | |||
if (tar) tar.fade(pas.time, 0, true); | |||
} | |||
break; | |||
case "@sound": | |||
{ | |||
let tars = document.getElementById("sys_audio").querySelectorAll(".playsound"); | |||
for (let tar of tars) { | |||
tar.fade(pas.time, 0, true); | |||
} | |||
} | |||
break; | |||
} | } | ||
} | } | ||
function | function fun_skip_start() | ||
{ | { | ||
if(!system || system.stats.theater || system.txt.max == 0 || system.flag.respond > 0) return 0; | |||
if(timer.hasTimer("skip")) fun_skip_stop();/* 防止意外导致的加速无法停止 */ | |||
timer.create("skip",()=>{ | |||
if(++system.flag.skip >= wait_trigger){ | |||
if(system.stats.auto) fun_auto_stop(); | |||
timer.clear("skip"); | |||
timer.setFake("auto"); | |||
txt_next(); | |||
} | |||
},10,true); | |||
} | } | ||
function | function fun_skip_stop() | ||
{ | { | ||
if(!system) return; | |||
if(system.flag.skip == wait_trigger){ | |||
timer.removeFake("auto"); | |||
{ | timer.create("click_block",function(){},100); | ||
} | |||
else timer.clear("skip"); | |||
if(mw.config.values. | system.flag.skip = 0; | ||
} | |||
function fun_txt_format(key_txt){ | |||
let t = key_txt.trim().replace(/{@nickname}/ig,system.user.name); | |||
try{ | |||
t = t.replaceAll("<color=","<font color=").replaceAll("</color>","</font>"); | |||
t = t.replaceAll("{@s}","").replaceAll("\\n","<br/>"); | |||
} | |||
catch(err){ | |||
fun_msg(-1,false,"This browser not support replaceAll function."); | |||
t = t.replace(/<color=/ig,"<font color=").replace(/<\/color>/ig,"</font>"); | |||
t = t.replace(/{@s}/ig,""); | |||
t = t.replace(/\\n/g,"<br/>"); | |||
} | |||
return t; | |||
} | |||
function fun_report_to_developer(note){ | |||
if(!mw.config.values.wgUserGroups.includes("user") || GetCookie("ak_scerp_cd")) return; | |||
var api = new mw.Api(); | |||
var btn_sub = document.getElementById("report_submit"); | |||
api.get({action:'query',meta:'tokens',type:'csrf'}).done((ret)=>{ | |||
if(ret.error || ret.warning){ | |||
fun_msg(-2,false,"get token failed."); | |||
btn_sub.disabled = false; | |||
btn_sub.classList.remove("waiting"); | |||
return; | |||
} | } | ||
var dat = `*Time: ${new Date().toLocaleString()}\n*Note: ${note}`; | |||
if(system.error.stat) dat = `${dat}\n*error: ${system.error.info}\n**client: ${system.user.client} | screen: ${system.user.display}`; | |||
dat = `${dat}\n*index: ${system.txt.index} | debug: ${system.debug}\n*UserAgent: ${navigator.userAgent}\n*Reporter: ${system.user.name}`; | |||
var token = ret.query.tokens.csrftoken.toString(); | |||
var param = { | |||
action: "edit", | |||
title: "剧情一览/Auto_Report_List", | |||
section: "new", | |||
sectiontitle: "[["+system.page+"]]", | |||
bot: true, | |||
watchlist: 'nochange', | |||
text: dat, | |||
summary: "Append by ScenarioSimulator Auto Report Script.", | |||
token: token, | |||
}; | |||
api.post(param).done((ret)=>{ | |||
console.log(ret); | |||
btn_sub.disabled = false; | |||
btn_sub.classList.remove("waiting"); | |||
if(ret.error){ | |||
fun_msg(-2,false,"Report Error.",ret); | |||
return; | |||
} | |||
fun_msg(3,false,"Report Success!"); | |||
if(!mw.config.values.wgUserGroups.includes("sysop")) SetCookie("ak_scerp_cd","yes",{path:'/',domain:'.prts.wiki',expires:'5m'}); | |||
mw.notify("提交完成!"); | |||
btn_sub.parentElement.classList.add("hidden"); | |||
}); | |||
}); | |||
} | |||
function fun_report_toggle(){ | |||
let report = document.getElementById("button_report"); | |||
if(!report || !report.childElementCount) return; | |||
let ui = report.children[0]; | |||
if(ui.classList.contains("hidden")){ | |||
system.stats.report = true; | |||
fun_setting("cmd_suspend"); | |||
var dat = "*index: "+system.txt.index+"\n*UserAgent: "+navigator.userAgent+"\n*ID: "+system.user.name; | |||
if(system.error.stat) dat = "*error: "+system.error.info + "\n" + dat; | |||
document.getElementById("report_collected").value = dat; | |||
document.getElementById("report_note").value = ""; | |||
ui.classList.remove("hidden"); | |||
} | |||
else{ | |||
ui.classList.add("hidden"); | |||
fun_setting("cmd_resume"); | |||
system.stats.report = false; | |||
} | |||
} | |||
function fun_sys_init(){ | |||
let report = document.getElementById("button_report"); | |||
document.getElementById("button_playback").addEventListener("click",()=>{ | |||
txt_playback("sys_playback","button_playback"); | |||
}); | |||
document.getElementById("button_playback_all").addEventListener("click",()=>{ | |||
txt_playback("sys_playback_all","button_playback_all",true); | |||
}); | |||
if(report){ | |||
report.addEventListener("click", function(event){ | |||
if(event.defaultPrevented) return; | |||
fun_report_toggle(); | |||
}); | |||
for(var ele of report.children){ | |||
ele.addEventListener("click",function(e){ | |||
e.preventDefault(); | |||
}); | |||
} | } | ||
return [ | document.getElementById("report_submit").addEventListener("click",function(e){ | ||
if(!mw.config.values.wgUserGroups.includes("user")){ | |||
mw.notify("您需要登录后才能使用此功能~"); | |||
return; | |||
} | |||
if(GetCookie("ak_scerp_cd")){ | |||
mw.notify("您在短时间内已经报告过了,请5分钟后再试吧~"); | |||
return; | |||
} | |||
var note = document.getElementById("report_note"); | |||
if(!note.value.trim()){ | |||
mw.notify("请填写上相关备注信息~"); | |||
return; | |||
} | |||
this.disabled = true; | |||
this.classList.add("waiting"); | |||
fun_report_to_developer(note.value); | |||
e.preventDefault(); | |||
}); | |||
document.getElementById("report_cancel").addEventListener("click",function(e){ | |||
fun_report_toggle(); | |||
e.preventDefault(); | |||
}); | |||
} | |||
} | |||
function fun_serialize_object(header,obj){ | |||
var res = []; | |||
for(var [k,v] of Object.entries(obj)){ | |||
if(v == undefined) continue; | |||
res.push(`${k}="${v}"`); | |||
} | } | ||
return `[${header}(${res.join(', ')})]`; | |||
} | |||
function fun_sys_preload(){ | |||
let page = system.page; | |||
let assets = new Set(); | |||
let decs = {mode:false,element:undefined,options:[],stacks:[]}; | |||
let txts = data.txt,imgs = data.back,chars = data.char,sets = data.setting,str = ""; | |||
for (let i = 0;i < txts.length;i++) | |||
{ | { | ||
if(sets.check('override',page,i)) txts[i] = sets.override[page][i+1]; | |||
let txt = txts[i]; | |||
if(!txt || txt.match("^\\s+$") || txt.match("^\\s*//.*$")) continue; | |||
let match = txt.match("^\\[\\s*(?:(.*?)\\((.*)\\)|(?:([\\.|\\w]*)|(.*)))\\s*\\]\\s*(.*)"); | |||
let temp = {}; | |||
if (match == null) { | |||
if(system.multi.mode){ | |||
fun_playback("@pa",{name:system.txt.name,mode:decs.mode,target:decs.element}); | |||
system.txt.name = ""; | |||
system.txt.now = ""; | |||
} | |||
fun_playback("@pa",{name:"",mode:decs.mode,target:decs.element},fun_txt_format(txt)); | |||
continue; | |||
}; | |||
fun_msg(1,true,`<Debug>Ready to analyze Line [${i}]`); | |||
if (match[1] != undefined) | |||
{ | { | ||
let m1 = match[1].toLowerCase(),cmd_set = match[2].toObject(); | |||
switch (m1) | |||
{ | { | ||
case 'background': | |||
case 'image': | |||
case 'showitem': | |||
{ | |||
if(sets.check('image',page,i)){ | |||
let pas = sets['image'][page][i+1]; | |||
for(let [k,v] of Object.entries(pas)){ | |||
cmd_set[k] = pas[k]; | |||
} | |||
txts[i] = fun_serialize_object(match[1],cmd_set); | |||
} | |||
let key = cmd_set.image ? (m1 == "background" ? "bg_" : "") + cmd_set.image.toLowerCase() : ""; | |||
if(!key) continue; | |||
if(!imgs[key]){ | |||
fun_msg(-2,false,`<${m1}>Linked key [${key}] not exist.`); | |||
continue; | |||
} | |||
assets.add(imgs[key]); | |||
} | |||
break; | |||
case 'backgroundtween': | |||
case 'imagetween': | |||
case 'largebgtween': | |||
case 'largeimgtween': | |||
{ | |||
if(sets.check('tween',page,i)){ | |||
let pas = sets.tween[page][i+1]; | |||
for(let [k,v] of Object.entries(pas)){ | |||
cmd_set[k] = pas[k]; | |||
} | |||
txts[i] = fun_serialize_object(match[1],cmd_set); | |||
} | |||
} | |||
case 'character': | |||
case 'charactercutin': | |||
case 'charslot': | |||
{ | |||
if(sets.check('char',page,i)){ | |||
let pas = sets['char'][page][i+1]; | |||
cmd_set.name = pas.name || cmd_set.name; | |||
if(m1 === "character") cmd_set.name2 = pas.name2 || cmd_set.name2; | |||
txts[i] = fun_serialize_object(match[1],cmd_set); | |||
} | |||
let names = []; | |||
if(cmd_set.name) names.push(cmd_set.name.toLowerCase()); | |||
if(m1 === "character" && cmd_set.name2) names.push(cmd_set.name2.toLowerCase()); | |||
for(let name of names){ | |||
let [k,i] = fun_char_link(name); | |||
if(k == -1) continue; | |||
let key = fun_char_format(k,i); | |||
if(!chars[key]){ | |||
fun_msg(-2,false,`<${m1}>Linked key [${key}] not exist.`); | |||
continue; | |||
} | |||
assets.add(chars[key]); | |||
} | |||
} | |||
break; | |||
case 'decision': | |||
{ | |||
let ops = cmd_set.options ? fun_txt_format(cmd_set.options).split(';') : []; | |||
let vas = cmd_set.values ? cmd_set.values.split(';') : []; | |||
if(!ops || !vas) continue; | |||
let panel = document.createElement('div'); | |||
panel.classList.add("decision"); | |||
let group = document.createElement("li"); | |||
group.classList.add("decision"); | |||
for(let i = 0;i < ops.length;i++){ | |||
decs.options[vas[i]] = ops[i]; | |||
let span = document.createElement("span"); | |||
span.classList.add("decision"); | |||
span.innerHTML = `【${ops[i]}】`; | |||
group.append(span); | |||
} | |||
group.style.height = `${ops.length*22}px`; | |||
panel.append(group); | |||
if(decs.mode){ | |||
decs.element.append(panel); | |||
decs.element = group; | |||
} | |||
else{ | |||
str = panel; | |||
decs.element = panel; | |||
decs.mode = true; | |||
} | |||
decs.stacks.push({self:panel,values:vas,selected:new Set()}); | |||
} | |||
break; | |||
case 'gridbg': | |||
case 'verticalbg': | |||
case 'largebg': | |||
case 'largeimg': | |||
{ | |||
let imgs = cmd_set.imagegroup ? cmd_set.imagegroup.split('/') : []; | |||
for(let img of imgs){ | |||
let key = (m1.endsWith('bg') ? "bg_" : "") + img.toLowerCase(); | |||
if(!key) continue; | |||
if(!imgs[key]){ | |||
fun_msg(-2,false,`<${m1}>Linked key [${key}] not exist.`); | |||
continue; | |||
} | |||
assets.add(imgs[key]); | |||
} | |||
} | |||
break; | |||
case 'multiline': | |||
if(cmd_set.name == undefined) continue; | |||
system.txt.name = cmd_set.name; | |||
system.txt.now += fun_txt_format(match[5]); | |||
if(cmd_set.end == "true"){ | |||
fun_playback("@pa",{name:system.txt.name,mode:decs.mode,target:decs.element}); | |||
system.multi.reset(); | |||
system.txt.now = ""; | |||
} | |||
else{ | |||
system.multi.mode = true; | |||
} | |||
break; | |||
case 'playmusic': | |||
case 'playsound': | |||
{ | |||
let auds = []; | |||
if(m1 === "playmusic" && cmd_set.intro) auds.push(cmd_set.intro); | |||
if(cmd_set.key) auds.push(cmd_set.key); | |||
for(let aud of auds){ | |||
let key = fun_get_audio_url(aud); | |||
if(!key) continue; | |||
assets.add(key); | |||
} | |||
} | |||
break; | |||
case 'predicate': | |||
temp.refs = cmd_set.references == undefined ? [] : cmd_set.references.split(';'); | |||
if(decs.stacks.empty()) { | |||
fun_msg(-1,false,"<Predicate>The stacks is empty.Has skipped the command."); | |||
continue; | |||
} | |||
let ptr = decs.stacks.last(); | |||
do{ | |||
let refv = temp.refs.filter((x)=>ptr.values.includes(x)); | |||
let remv = ptr.values.filter((x)=>!ptr.selected.has(x)); | |||
if(refv.length == ptr.values.length || remv.empty()){ | |||
decs.stacks.pop(); | |||
ptr = decs.stacks.last(); | |||
if(ptr) decs.element = ptr.self; | |||
continue; | |||
} | |||
temp.selv = refv.filter((x)=>!ptr.selected.has(x)); | |||
break; | |||
}while(!decs.stacks.empty()); | |||
if(decs.stacks.empty()){ | |||
decs.mode = false; | |||
decs.options = []; | |||
document.getElementById('playback_all_result').append(str); | |||
str = null; | |||
continue; | |||
} | |||
temp.o1 = document.createElement('div'); | |||
temp.o1.className = 'predicate'; | |||
ptr.self.append(temp.o1); | |||
decs.element = temp.o1; | |||
for(let i of temp.selv){ | |||
let d = decs.options[i]; | |||
if(!d){ | |||
fun_msg(-1,false,"<Predicate>Can't find the options data of the value ["+i+"]."); | |||
continue; | |||
} | |||
let e = document.createElement('span'); | |||
e.innerHTML = "【"+d+"】"; | |||
ptr.selected.add(i); | |||
temp.o1.append(e); | |||
} | |||
break; | |||
case 'sticker': | |||
case 'subtitle': | |||
temp.d1 = cmd_set.text == undefined ? "" : fun_txt_format(cmd_set.text); | |||
if(temp.d1 == ""){ | |||
if(system.multi.mode){ | |||
fun_playback("@pa",{name:"",mode:decs.mode,target:decs.element}); | |||
system.txt.now = ""; | |||
} | |||
continue; | |||
} | |||
else if(cmd_set.multi == "true"){ | |||
system.txt.now += temp.d1; | |||
system.multi.mode = true; | |||
continue; | |||
} | |||
fun_playback("@pa",{name:"",mode:decs.mode,target:decs.element},temp.d1); | |||
break; | |||
case 'video': | |||
{ | |||
let res = cmd_set.res ? cmd_set.res.toLowerCase() : ""; | |||
if(!res) continue; | |||
assets.add(source_url + res); | |||
} | |||
break; | |||
default: | |||
break; | |||
} | |||
continue; | |||
} | |||
else if(match[3]){ | |||
switch(match[3].toLowerCase()){ | |||
case 'predicate': | |||
decs = {mode:false,options:[],stacks:[]}; | |||
document.getElementById('playback_all_result').append(str); | |||
str = ""; | |||
break; | |||
} | } | ||
continue; | |||
} | } | ||
if( | else if(match[4] && match[5]) | ||
{ | { | ||
if( | temp.p = match[4].toObject(); | ||
if(temp.p == null || temp.p.name == undefined) continue; | |||
if(system.multi.mode){ | |||
fun_playback("@pa",{name:system.txt.name,mode:decs.mode,target:decs.element}); | |||
system.multi.reset(); | |||
system.txt.name = ""; | |||
system.txt.now = ""; | |||
} | |||
fun_playback("@pa",{name:temp.p.name,mode:decs.mode,target:decs.element},fun_txt_format(match[5])); | |||
} | } | ||
} | } | ||
for (let asset of assets){ | |||
queue.loadFile(asset,false); | |||
} | |||
system.multi.reset();/* 临时使用完毕 */ | |||
if(str) document.getElementById('playback_all_result').append(str); | |||
} | } | ||
function | function fun_format_time(t){ | ||
{ | let arr = [Math.floor(t/3600),Math.floor((t%3600)/60),Math.floor(t%60)]; | ||
for(let i = 0;i<arr.length;i++){ | |||
{ | arr[i] = arr[i] < 10 ? "0"+arr[i].toString() : arr[i].toString(); | ||
} | } | ||
return `${arr[0]}:${arr[1]}:${arr[2]}`; | |||
} | |||
</script> | |||
<script class="navigation-not-searchable"> | |||
(window.RLQ = window.RLQ || []).push(["jquery", function () { | |||
$(document).ready(()=>{ | |||
$(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange', function() { | |||
fun_fullscreen(); | |||
}); | |||
$("#button_fullscreen").click(function() { | |||
txt_fullscreen(); | |||
return | }); | ||
let name = mw.config.get("wgUserName"); | |||
system.user.name = name ? name.replace(/[Dd][Rr]\./,"") : "博士"; | |||
{ | try{ | ||
var | fun_sys_preload(); | ||
} | |||
catch(err){ | |||
document.getElementById("dialog_output").innerHTML = "数据载入异常。请尝试刷新页面或是将提交异常反馈。" | |||
system.error.type = "preload_error"; | |||
system.error.info = err.toString(); | |||
system.error.stat = true; | |||
} | |||
}); | |||
$.prototype.fadeToExit = function(duration, easing){ | |||
if(!duration){ | |||
return this.remove(); | |||
} | |||
return this.fadeOut(duration,easing,function(){this.remove()}); | |||
} | |||
}]); | |||
window.onload = function(ev){ | |||
var logAll = document.getElementById("button_playback_all"),txt = document.getElementById("dialog_output"); | |||
if(!system.error.stat && system.stats.log_all) logAll.setShow(); | |||
if(fun_fullscreen_support()) document.getElementById("button_fullscreen").setShow(); | |||
if(public_disabled || system.disabled.flag){ | |||
let r = system.disabled.note; | |||
txt.innerHTML = (public_disabled ? "剧情模拟器已被全局停用" : "该页面的剧情模拟器已被停用") + ",查看剧情所有文本请单击LOG ALL" + (r ? "<br/>附言: " + r : ""); | |||
document.getElementById("button_auto").setHide(); | |||
document.getElementById("button_reset").setHide(); | |||
document.getElementById("button_playback").setHide(); | |||
logAll.setShow(); | |||
logAll.style.left = "24px"; | |||
return; | |||
} | } | ||
if(system.user.client == "desktop") document.getElementById("button_report").setShow(); | |||
var txt = document.getElementById("dialog_output"); | |||
{ | txt.innerHTML = "页面已加载完毕。为避免意外的数据消耗,剧情资源仅在长按1s后开始预载。如果您仅需浏览纯文本内容,请直接单击LOG ALL"; | ||
system.preload.init(); | |||
}; | |||
fun_sys_init(); | |||
var | </script> | ||
var | <script class="navigation-not-searchable"> | ||
if( | const dec_limit_px = 450,log_limit_px = 582,log_em_limit_px = 200,wait_trigger = 150,base_width = 960,base_height = 540,pos_multiply = 0.75; | ||
const queue = new createjs.LoadQueue(false); | |||
queue.installPlugin(createjs.Sound); | |||
const source_url = "https://static.prts.wiki/",assets_url = "https://torappu.prts.wiki/assets/"; | |||
var public_disabled = false; | |||
var timer = new Timer(); | |||
var system = { | |||
page: "", | |||
debug: document.URL.includes("&debug=true"), | |||
/* debug: true, */ | |||
error:{type:"",info:undefined,stat:false}, | |||
txt:{max:0,index:0,name:"",now:"",now_temp:"",now_index:0,dynamic:undefined, | |||
init(){ | |||
this.now_index = 0; | |||
this.now_temp = ""; | |||
}, | |||
over(){ | |||
this.now_index = this.now.length; | |||
this.now_temp = this.now; | |||
}, | |||
delay:{ | |||
word: 30,per: 50,common: 1500, | |||
set(tar, value){ | |||
var self = this; | |||
if(self[tar] && value) self[tar] = value; | |||
}, | |||
reset(tar){ | |||
var self = this; | |||
if(tar === "all"){ | |||
self.word = 30; | |||
self.per = 50; | |||
self.common = 1500; | |||
} | } | ||
if( | else if(tar === "word"){ | ||
self.word = 30; | |||
} | } | ||
else if(tar === "per"){ | |||
self.per = 50; | |||
} | } | ||
else | else if(tar === "common"){ | ||
self.common = 1500; | |||
} | } | ||
} | |||
if( | } | ||
{ | }, | ||
flag:{auto:0,respond:0,skip:0,load:0}, | |||
stats:{reset:false,click:false,theater:false,auto:false,log_all:true,step:false,report:false}, | |||
decision:{mode:false,select:1,values:[-1,-1,-1]}, | |||
disabled:{ | |||
flag:false, | |||
note:"", | |||
init(){ | |||
let sets = data.setting.disable; | |||
for(let p in sets.prefix){ | |||
if(!system.page.startsWith(p)) continue; | |||
this.flag = true; | |||
this.note = sets.prefix[p]; | |||
return; | |||
} | |||
for(let t in sets.title){ | |||
if(system.page !== t) continue; | |||
this.flag = true; | |||
this.note = sets.title[p]; | |||
return; | |||
} | |||
} | |||
}, | |||
source:{}, | |||
multi:{ | |||
mode:false, | |||
check(){ | |||
if(!this.mode) return false; | |||
this.end(); | |||
this.init(); | |||
return true; | |||
}, | |||
init(){ | |||
system.txt.init(); | |||
}, | |||
begin(){ | |||
this.init(); | |||
this.mode = true; | |||
}, | |||
end(tar = "@p"){ | |||
fun_playback(tar,system.txt.name,system.txt.now); | |||
this.reset(); | |||
}, | |||
reset(){ | |||
system.txt.delay.reset("word"); | |||
/* this.init(); */ | |||
this.mode = false; | |||
} | |||
}, | |||
auto:{ | |||
mode: false, | |||
flag: 0, | |||
toggle(){ | |||
var self = this; | |||
if(self.mode) self.stop(); | |||
else self.start(); | |||
}, | |||
start(){ | |||
var self = this; | |||
self.mode = true; | |||
if(system.txt.index == 0) fun_setting("pre"); | |||
timer.clear("auto"); | |||
self.flag = 1; | |||
self.resume(); | |||
}, | |||
stop(){ | |||
var self = this; | |||
timer.clear("auto"); | |||
document.getElementById("button_auto").innerHTML = "自动▶"; | |||
self.mode = false; | |||
}, | |||
suspend(){ | |||
var self = this; | |||
if(!self.mode) return; | |||
timer.clear("auto"); | |||
}, | |||
resume(){ | |||
var self = this; | |||
if(!self.mode) return; | |||
timer.create("auto",timer_auto, 400, true); | |||
self.checkNext(); | |||
}, | |||
checkNext(){ | |||
if(!system.stats.click || timer.hasTimer("dynamic") || timer.hasTimer("txt")) return; | |||
txt_next(); | |||
} | |||
}, | |||
user:{name:"",client:"",display:""}, | |||
preload:{ | |||
start(){ | |||
var self = this.handler; | |||
fun_msg(2,false,"Source start loading..."); | |||
queue.load(); | |||
var c = document.getElementById("sys_clicker"); | |||
c.removeEventListener("mousedown", self.begin); | |||
c.removeEventListener("mouseup", self.end); | |||
c.removeEventListener("mouseleave", self.end); | |||
c.removeEventListener("touchstart", self.begin); | |||
c.removeEventListener("touchend", self.end); | |||
c.removeEventListener("touchcancel", self.end); | |||
}, | |||
init(){ | |||
queue.on("fileload",(e)=>{ | |||
fun_msg(0,true,"Source Loaded:",e.item.src); | |||
document.getElementById("dialog_output").innerHTML = "正在载入资源:"+e.item.src.getValue("/"); | |||
}); | |||
queue.on("complete", function(){ | |||
fun_msg(2,false,"All source loaded complete."); | |||
system.preload.complete(); | |||
},this, true); | |||
var self = this.handler,clicker = document.getElementById("sys_clicker"); | |||
clicker.addEventListener("mousedown",self.begin); | |||
clicker.addEventListener("mouseup",self.end); | |||
clicker.addEventListener("mouseleave",self.end); | |||
clicker.addEventListener("touchstart",self.begin); | |||
clicker.addEventListener("touchend",self.end); | |||
clicker.addEventListener("touchcancel",self.end); | |||
}, | |||
complete(){ | |||
var auto = document.getElementById("button_auto"),main = document.getElementById("sys_main"),clicker = document.getElementById("sys_clicker"); | |||
clicker.addEventListener("click", function(ev){txt_click();ev.preventDefault();}); | |||
clicker.addEventListener("mousedown", fun_skip_start); | |||
clicker.addEventListener("mouseup", fun_skip_stop); | |||
clicker.addEventListener("mouseleave", fun_skip_stop); | |||
clicker.addEventListener("touchstart", fun_skip_start); | |||
clicker.addEventListener("touchend", fun_skip_stop); | |||
clicker.addEventListener("touchleave", fun_skip_stop); | |||
document.getElementById("button_reset").addEventListener("click",(ev)=>{ | |||
var stats = system.stats; | |||
if(!stats.reset || stats.report){ | |||
fun_msg(0,true,"reset didn't pass."); | |||
return; | |||
} | } | ||
if ( | if(timer.hasTimer("auto")) fun_auto_stop(); | ||
{ | if(timer.hasTimer("dynamic")) txt_stop(); | ||
fun_setting("reset"); | |||
document.getElementById("dialog_output").innerHTML = "剧情模拟已重置,单击开始剧情回顾"; | |||
ev.preventDefault(); | |||
}); | |||
main.addEventListener("mousemove",function(e){ | |||
var self = this; | |||
self.style.cursor = "default"; | |||
if(!fun_fullscreen_check()) return; | |||
timer.clear("mousehide"); | |||
timer.create("mousehide",function(){ | |||
self.style.cursor = "none"; | |||
},1500); | |||
e.preventDefault(); | |||
}); | |||
document.addEventListener("keydown",function(ev){ | |||
if(system.debug && ev.ctrlKey){ | |||
var eles = document.getElementsByClassName("dialog_style header"); | |||
if(eles){ | |||
eles[0].classList.toggle("debug"); | |||
} | |||
} | } | ||
}); | |||
auto.addEventListener("click",function(ev){ | |||
var stats = system.stats; | |||
if((!stats.click && system.txt.max == 0) || stats.theater || stats.report){ | |||
fun_msg(0,true,"auto didn't pass."); | |||
return 0; | |||
return | |||
} | } | ||
if( | if(!stats.auto){ | ||
stats.auto = true; | |||
if(system.txt.index == 0) fun_setting("pre"); | |||
timer.clear("auto"); | |||
system.flag.auto = 1; | |||
timer.create("auto", timer_auto, 400, true); | |||
if(stats.click && !timer.hasTimer("dynamic") && !timer.hasTimer("txt")) txt_next(); | |||
} | } | ||
else{ | |||
fun_auto_stop(); | |||
} | } | ||
ev.preventDefault(); | |||
}); | |||
/* property */ | |||
var sets = system.stats; | |||
auto.classList.remove("forbid"); | |||
sets.click = true; | |||
if(system.error.stat){ | |||
document.getElementById("dialog_output").innerHTML = "部分数据预载入异常,本次剧情回顾可能存在图片/音频消失的情况。LOG ALL已禁用<br/>单击开始剧情回顾"; | |||
sets.log_all = false; | |||
} | |||
else{ | |||
document.getElementById("dialog_output").innerHTML = "资源加载完毕。单击开始剧情回顾"; | |||
} | |||
if(sets.log_all) document.getElementById("button_playback_all").setShow(); | |||
if(fun_fullscreen_support()) document.getElementById("button_fullscreen").setShow(); | |||
if(system.user.client == "desktop") document.getElementById("button_report").setShow(); | |||
}, | |||
handler:{ | |||
begin: function(e){ | |||
if(timer.hasTimer("preload_wait")) return; | |||
if( | timer.create("preload_wait",function(){ | ||
{ | system.preload.start(); | ||
}, 1000); | |||
} | }, | ||
end: function(e){ | |||
timer.clear("preload_wait"); | |||
}, | |||
} | |||
} | |||
}; | |||
var scenario = { | |||
cutin:{ | |||
} | |||
switch ( | } | ||
var data_cutin = {}; | |||
var data = { | |||
txt:[], | |||
audio:{}, | |||
back:{}, | |||
char:{}, | |||
link:{}, | |||
setting:{ | |||
title:{}, | |||
char:{}, | |||
image:{}, | |||
tween:{}, | |||
override:{}, | |||
disable:{prefix:{},title:{}}, | |||
set(page,str){ | |||
var self = this; | |||
return self.title[page] ? str.replace(page,self.title[page]) : str.replace('/BEG',' 行动前').replace('/END',' 行动后').replace('/NBT',''); | |||
}, | |||
check(sub,key,line){ | |||
let ret = false; | |||
let self = this; | |||
line++; | |||
ret = self[sub] && self[sub][key] && self[sub][key][line] != undefined; | |||
if(ret) fun_msg(-1,false,`Line [${line}] data has been overrided.`); | |||
return ret; | |||
}, | |||
}, | |||
init(){ | |||
let obj = document.getElementById("datas_override"),ride = this.setting; | |||
if(obj){ | |||
let arr = obj.innerHTML.split('\n'); | |||
for(let str of arr){ | |||
if(str == "" || str.match("^\\s+$") || str.match("^\\s*//.*$")) continue; | |||
let match = str.match("^\\s*(.*?)\\:(.*)$"); | |||
if(!match || !match[2]) continue; | |||
let m1 = match[1].toLowerCase(),m2 = match[2]; | |||
switch(m1) | |||
{ | { | ||
case | case 'title': | ||
{ | { | ||
let [p,n] = m2.split('='); | |||
if(!n) continue; | |||
ride[m1][p] = n; | |||
} | } | ||
break; | break; | ||
case | case 'char': | ||
case 'image': | |||
case 'tween': | |||
{ | { | ||
/* d = data,v = value,p = page,l = line */ | |||
let [d,v] = m2.split(';'),[p,l] = d.split(','); | |||
if(!v || !l) continue; | |||
let ls = l.split('.'),vs = v.split(','); | |||
let obj = {}; | |||
if(!ride[m1][p]) ride[m1][p] = {}; | |||
for(let vc of vs){ | |||
let [k2,v2] = vc.split('='); | |||
obj[k2] = v2; | |||
} | |||
for(let lc of ls) ride[m1][p][lc] = obj; | |||
} | } | ||
break; | |||
case 'override': | |||
{ | { | ||
let [d,v] = m2.split(';'),[p,l] = d.split(','); | |||
if(!l) continue; | |||
if(v == undefined) v = ""; | |||
if(!ride[m1][p]) ride[m1][p] = {}; | |||
ride[m1][p][l] = v; | |||
} | } | ||
break; | break; | ||
case | case 'disable': | ||
{ | { | ||
if(public_disabled) continue; | |||
let vs = m2.split(';'); | |||
if(vs.length == 2 && vs[0] === "public"){ | |||
system.disabled.note = arr[1]; | |||
public_disabled = true; | |||
} | |||
/* t = type,p = target */ | |||
let t = "",p = ""; | |||
for(let vc of vs){ | |||
let [k,v] = vc.split(':'); | |||
if(!v) continue; | |||
switch(k){ | |||
case "prefix": | |||
case "title": | |||
t = t || k; | |||
p = p || v; | |||
ride.disable[k][v] = ""; | |||
break; | |||
case "note": | |||
if(t && p){ | |||
ride.disable[t][p] = v; | |||
} | |||
break; | |||
} | |||
} | |||
} | } | ||
break; | break; | ||
} | } | ||
} | |||
console.log(ride); | |||
} | |||
obj = document.getElementById("datas_txt"); | |||
if(obj){ | |||
this.txt = obj.innerHTML.split('\n'); | |||
let m = this.txt[0].match(/\[header\((.*)\)/i); | |||
if(m){ | |||
let set = m[1].toObject(); | |||
if(set.is_prtswiki_only == "true") system.stats.log_all = false; | |||
} | |||
} | |||
obj = document.getElementById("datas_back"); | |||
if(obj){ | |||
for(let d of obj.innerHTML.split('\n')){ | |||
let [k,v] = d.split(','); | |||
this.back[k] = v; | |||
} | |||
} | |||
obj = document.getElementById("datas_char"); | |||
if(obj){ | |||
for(let d of obj.innerHTML.split('\n')){ | |||
let [k,v] = d.split(','); | |||
this.char[k] = v; | |||
} | |||
[ | |||
} | } | ||
obj = document.getElementById("datas_audio"); | |||
if(obj){ | |||
let str = obj.innerHTML.toLocaleLowerCase(),pos = str.search(/,\s+\}$/); | |||
if(pos != -1) { | |||
fun_msg(0,false,"The inner code has been executed."); | |||
str = str.substr(0,pos) + "}";/* 防止背刺 */ | |||
} | |||
let dics = JSON.parse(str); | |||
for(let k in dics){ | |||
if(dics[k].toString().indexOf("sound_beta_2") == -1) continue; | |||
this.audio[k] = dics[k].replace("sound_beta_2",assets_url + "audio") + ".mp3"; | |||
} | |||
this.audio["btn_click"] = source_url + "music/general/g_ui/g_ui_btn_n.mp3"; | |||
} | } | ||
obj = document.getElementById("datas_link"); | |||
if(obj){ | |||
this.link = JSON.parse(obj.innerHTML.toLowerCase()); | |||
if( | |||
} | } | ||
document. | let user = system.user; | ||
user.client = document.URL.includes("m.prts.wiki") ? "mobile" : "desktop"; | |||
user.display = screen.availWidth * 0.7 < screen.availHeight ? "vert" : "horiz"; | |||
let tarStr = "firstHeading"; | |||
let tarObj = document.getElementById(tarStr); | |||
system.page = tarObj.innerText; | |||
document.title = ride.set(system.page,document.title); | |||
tarObj.innerHTML = ride.set(system.page,system.page); | |||
} | } | ||
} | } | ||
data.init(); | |||
system.disabled.init(); | |||
</script> | </script> | ||
</includeonly> | </includeonly> |