微件:ScenarioSimulator:修订间差异

来自PRTS
跳转到导航 跳转到搜索
无编辑摘要
(Update by bot.)
 
第1行: 第1行:
<noinclude>{{#Widget:ScenarioSimulator|data_txt={{用户:Krliov/testpage5}}|data_back={{Widget:Data_Image}}|data_char={{Widget:Data_Char}}|data_audio={{Widget:Data_Audio}}|data_link={{:Data_Link}}|data_name={{DrName}}}}</noinclude>
<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="system_main" style="position:relative;width:800px;height:450px;background-color:#000000;" onclick="txt_system()">
<div class="common_style" id="sys_camera">
<div class="button_style" id="button_auto" style="right:120px;" onclick="txt_auto()">自动▶</div>
<div class="common_style" id="sys_back"></div>
<div class="button_style" id="button_reset" style="right:0px;color:#808080;" onclick="txt_reset()">重置▶</div>
<div class="common_style" id="sys_char"></div>
<div id="system_blocker">
<div class="common_style" id="sys_cutin"></div>
<div class="pic_style" id="pic_back" style="display:none;" onclick="txt_click(1)"></div>
<div class="common_style" id="sys_item"></div>
<div class="pic_style" id="pic_image" style="display:none;" onclick="txt_click(2)"></div>
<div class="common_style" id="sys_image"></div>
<div id="pic_char_1" style="display:none;" onclick="txt_click(11)">
<div class="common_style" id="sys_animation"></div>
<div class="char_style" id="pic_char" style="left:0px;"></div>
</div>
</div>
<div id="pic_char_2" style="display:none;" onclick="txt_click(12)">
<div class="common_style" id="sys_blocker"></div>
<div class="char_style" id="pic_char_left" style="left:0px;"></div>
<div class="common_style" id="sys_masker"></div>
<div class="char_style" id="pic_char_right" style="left:0px;"></div>
<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>&nbsp;&nbsp;&nbsp;:3</span></div>
</div>
</div>
</div>
<div id="system_cutin" style="display:none;" onclick="txt_click(10)">
<div class="common_style" id="sys_clicker"></div>
<div class="cutin_style" id="char_cutin_1" style="left:150px;display:none;"></div>
<div class="common_style hidden" id="sys_decision"></div>
<div class="cutin_style" id="char_cutin_2" style="left:150px;display:none;"></div>
<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 id="system_decision" style="display:none;">
</div></div>
<div class="decision_style" id="decision_1" style="top:120px;display:block;" onclick="txt_decision(0)">...</div>
<div id="sys_audio" style="display:none;"></div>
<div class="decision_style" id="decision_2" style="top:180px;display:block;" onclick="txt_decision(1)">....</div>
<link rel="stylesheet" type="text/css" href="https://static.prts.wiki/assets/scenario/arknights-scenario.css">
<div class="decision_style" id="decision_3" style="top:240px;display:block;" onclick="txt_decision(2)">.....</div>
<script type="csv" id="datas_txt"><!--{$data_txt|regex_replace:"/<?script/":""}--></script>
</div>
<script type="csv" id="datas_back" class="navigation-not-searchable"><!--{$data_back|regex_replace:"/<?script/":""}--></script>
<div id="system_dialog" style="display:block;" onclick="txt_click(0)">
<script type="csv" id="datas_char" class="navigation-not-searchable"><!--{$data_char|regex_replace:"/<?script/":""}--></script>
<div class="dialog_style" style="left:5px;width:150px;text-align:right;color:#929292;font-size:18px;" id="txt_name">剧情模拟器</div>
<script type="json" id="datas_audio" class="navigation-not-searchable"><!--{$data_audio|regex_replace:"/<?script/":""}--></script>
<div class="dialog_style" style="right:5px;width:600px;font-size:15px;" id="txt_output">单击开始剧情回顾</div>
<script type="json" id="datas_link" class="navigation-not-searchable"><!--{$data_link|regex_replace:"/<?script/":""}--></script>
</div>
<script type="csv" id="datas_override" class="navigation-not-searchable"><!--{$data_override|regex_replace:"/<?script/":""}--></script>
</div>
<audio id="system_music" hidden>
</audio>
<audio id="system_sound" hidden>
</audio>
<style>
.char_style{
z-index:1;
position:absolute;
width:800px;
height:440px;
background-repeat:no-repeat;
// background-attachment:fixed;
// background-position:top;
// background-size:600px;
}
.button_style{
z-index:4;
position:absolute;
float:right;
color:white;
width:100px;
height:20px;
font-size:15px;
top:20px;
padding:0px 5px;
text-align:left;
cursor:default;
}
.pic_style{
position:absolute;
width:800px;
height:450px;
background-position:top;
background-size:800px 450px;
}
#pic_image{
z-index:2;
}
.dialog_style{
z-index:3;
position:absolute;
height:80px;
bottom:5px;
padding:5px 10px 0px 10px;
color:white;
background-color:rgba(0,0,0,1);
cursor:default;
}
.decision_style{
z-index:3;
position:absolute;
width:250px;
height:30px;
font-size:15px;
left:290px;
padding:5px 10px 0px 10px;
border:solid 2px white;
text-align:center;
color:white;
background-color:#303030;
cursor:default;
}
.cutin_style{
z-index:2;
position:absolute;
width:125px;
height:420px;
background-repeat:no-repeat;
background-position:top;
// background-size:600px;
}
@keyframes cutin-show{
0%{
left:212.5px;
width:0px;
}
100%{
left:150px;
width:125px;
}
}
@keyframes cutin-hide{
0%{
left:150px;
width:125px;
}
100%{
left:212.5px;
width:0px;
}
}
@keyframes cutin-2-show{
0%{
right:212.5px;
width:0px;
}
100%{
right:150px;
width:125px;
}
}
@keyframes cutin-2-hide{
0%{
right:150px;
width:125px;
}
100%{
right:212.5px;
width:0px;
}
}
</style>
<script type="csv" id="datas_txt"><!--{$data_txt}--></script>
<script type="csv" id="datas_back"><!--{$data_back}--></script>
<script type="csv" id="datas_char"><!--{$data_char}--></script>
<script type="csv" id="datas_audio"><!--{$data_audio}--></script>
<script type="json" id="datas_link"><!--{$data_link}--></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>
var txt_max = 0,txt_num = 0,now_txt = "",now_txt_max = 0,now_txt_num = 0,now_txt_temp = "";
<script class="navigation-not-searchable">
var timer_id = -1,flag_timer = false;
function Timer(){this.list = {};}
var timer_id_auto = -1,flag_auto = false;
/**
var timer_id_wait = -1,timer_id_temp = -1;
* n=name,f=function,t=delay,p=isinterval
var timer_id_blocker = -1,blocker_now = 100,blocker_new = 100;
* @param {string} n 名称,即标识符
var timer_id_music = -1,music_stats = "",music_loop = "",music_volume = 0.8,flag_music = false;
* @param {function} f 需要执行的函数体
var reset_enabled = false,auto_enabled = true,click_enabled = true,system_enabled = true;
* @param {number} t 等待时间/循环时间
var auto_num = 0;
* @param {boolean} p 是否为循环的定时器
var data_temp = "";
* @return {boolean} 创建成功返回true,否则为false
var data_nickname = "<!--{$data_name}-->";
*/
var decision_value = [1,2,3];
Timer.prototype.create = function(n,f,t=1000,p=false)
var decision_mode = false,decision_select = 1,name_checked = false;
var data_txt = new Array();
var data_pic_back = new Array();
var data_pic_char = new Array();
var data_audio = new Array();
var data_link;
//debug setting
var queue = new createjs.LoadQueue(false);
var txt_interval = 50;
try
{
data_temp = document.getElementById("datas_txt").innerHTML;
data_txt = data_temp.split("\n");
}
catch(err)
{
console.error("ERROR:The data_txt loaded failed,please check the input and try again.");
data_txt.push('[name="Krliov"]  There has something wrong when loaded data_txt,please check the input. :3');
auto_enabled = false;
click_enabled = false;
system_enabled = false;
document.getElementById("button_auto").style.color = "#808080";
}
try
{
data_temp = document.getElementById("datas_back").innerHTML;
for (var num of data_temp.split("\n"))
{
var [name,path] = num.split(",");
data_pic_back[name] = path;
queue.loadFile(path);
}
}
catch(err)
{
console.error("ERROR:The data_back loaded failed,please check the input and try again.");
data_txt.push('[name="Krliov"]  There has something wrong when loaded data_back,please check the input. :3');
auto_enabled = false;
click_enabled = false;
system_enabled = false;
document.getElementById("button_auto").style.color = "#808080";
}
try
{
data_temp = document.getElementById("datas_char").innerHTML;
for (var num of data_temp.split("\n"))
{
{
var [name,path] = num.split(",");
var obj = {},self = this;
data_pic_char[name] = path;
        self.clear(n,true);
queue.loadFile(path);
    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;
}
}
}
/**
catch(err)
* @param {string} n 名称,标识符
{
* @param {boolean} s 是否需要在移除时执行未执行的函数
console.error("ERROR:The data_char loaded failed,please check the input and try again.");
* @return {boolean} 移除成功返回true,否则为false
data_txt.push('[name="Krliov"]  There has something wrong when loaded data_char,please check the input. :3');
*/
auto_enabled = false;
Timer.prototype.clear = function(n,s = false)
click_enabled = false;
system_enabled = false;
document.getElementById("button_auto").style.color = "#808080";
}
try
{
data_temp = document.getElementById("datas_audio").innerHTML;
for (var num of data_temp.split("\n"))
{
{
var [name,path] = num.split(",");
var self = this;
data_audio[name] = path;
if(!self.isTimer(n)) return false;
queue.loadFile(path);
    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 () {
catch(err)
var self = this;
{
for(var n in self.list)
console.error("ERROR:The data_audio loaded failed,please check the input and try again.");
{
data_txt.push('[name="Krliov"]  There has something wrong when loaded data_audio,please check the input. :3');
var o = self.list[n];
auto_enabled = false;
if(o.interval) clearInterval(o.id);
click_enabled = false;
else clearTimeout(o.id);
system_enabled = false;
}
document.getElementById("button_auto").style.color = "#808080";
self.list = {};
}
data_temp = document.getElementById("datas_link").innerHTML.toLowerCase();
data_link = JSON.parse(data_temp);
console.log(data_txt);
console.log(data_pic_back);
console.log(data_pic_char);
console.log(data_audio);
console.log(data_link);
function txt_system()
{
if (system_enabled == false || document.getElementById("pic_back").style.display == "block")
{
if(mw.config.values.debug==true){console.log("system didn't passed.");}
return;
}
if(mw.config.values.debug==true){console.log("system passed.");}
txt_click(-1);
}
function txt_click(enter_id)
{
if(timer_id_temp == -1)
{
timer_id_temp = setTimeout("fun_delay('system')",100);
}
}
system_enabled = false;
/**
if(click_enabled == false)
* @param {string} n 名称,标识符
{
* @return {boolean} 存在时返回true,否则为false
if(mw.config.values.debug==true){console.log("click didn't passed.");}
*/
return;
Timer.prototype.hasTimer = function (n) {
var self = this;
return self.list[n];
}
}
if(mw.config.values.debug==true)
/**
{
* @param {string} n 名称,标识符
console.log("click passed.");
* @return {boolean} 为Timer时返回true,否则为false
console.log("enter_id=" + enter_id);
*/
Timer.prototype.isTimer = function (n) {
var self = this;
return self.hasTimer(n) && !self.isFake(n);
}
}
if(txt_num == 0)
/**
{
* @param {string} n 名称,标识符
fun_setting("pre");
* @return {boolean} 设定成功后返回true,否则为false
*/
Timer.prototype.setFake = function (n) {
var self = this;
if(self.isTimer(n)) return false;
self.list[n] = -1;
return true;
}
}
if(reset_enabled == false)
/**
{
* @param {string} n 名称,标识符
reset_enabled = true;
* @return {boolean} 移除成功后返回true,否则为false
document.getElementById("button_reset").style.color = "";
*/
Timer.prototype.removeFake = function (n) {
var self = this;
if(!self.isFake(n)) return false;
delete self.list[n];
return true;
}
}
if(flag_auto == true)
/**
{
* @param {string} n 名称,标识符
auto_stop();
* @return {boolean} 确定为伪造的timer时返回true,否则为false
*/
Timer.prototype.isFake = function (n) {
var self = this;
return self.list[n] === -1;
}
}
if(flag_timer == true)
function DeepCopy(k){
{
function arrCopy(k2){
txt_stop("f");
var arr = [];
document.getElementById("txt_output").innerHTML = now_txt;
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);
}
}
txt_next();
function SetCookie(name,value,options){
return;
var t = new Date();
}
var m = options.expires ? options.expires.match(/^(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/i) : [];
function txt_next()
var res = [];
{
if(m){
var place = -1;
t.setTime(t.getTime()+(((((m[1] || 0)*24+(m[2] || 0)*1)*60+(m[3] || 0)*1)*60+(m[4] || 0)*1)*1000));
//before
res.push("expire="+t.toUTCString());
fun_timer_clear("wait");
fun_msg(3,false,"cool down: "+t.toUTCString());
if (txt_num == txt_max)
{
if(mw.config.values.debug==true){console.log("txt_num=" + txt_num + " ,txt_max=" + txt_max);}
if(flag_auto == true)
{
auto_stop();
}
}
if(flag_music == true)
if(options.path){
{
res.push("path="+options.path);
music_stop();
}
}
document.getElementById("pic_back").style.display = "none";
if(options.domain){
document.getElementById("pic_image").style.display = "none";
res.push("domain="+options.domain);
document.getElementById("pic_char_1").style.display = "none";
document.getElementById("pic_char_2").style.display = "none";
document.getElementById("system_cutin").style.display = "none";
document.getElementById("system_blocker").style.filter = "";
blocker_now = 100;blocker_new = 100;
document.getElementById("txt_name").innerHTML = "剧情模拟器";
document.getElementById("txt_output").innerHTML = "剧情模拟已结束,单击将重新开始剧情回顾";
document.getElementById("system_dialog").style.display = "block";
if(timer_id_temp == -1)
{
timer_id_temp = setTimeout("fun_delay('system')",100);
}
}
reset_enabled = false;
document.cookie = name + "=" + value + ";" + res.join(";");
document.getElementById("button_reset").style.color = "#808080";
txt_num = 0;
now_txt_max = 0;
return;
}
}
//check
function GetCookie(name){
var ret = 0;
var cook = document.cookie;
if (mw.config.values.debug == true)
var arr = cook.split(';');
{
for(var d of arr){
if (data_txt[txt_num] == "")
var str = d.trim();
{
if(str.startsWith(name)){
ret = -2;
return str.substring(name.length+1);
if(decision_mode == true && name_checked == true)
{
decision_mode = false;
}
}
}
}
else
return null;
{
ret = txt_check_test();
}
}
}
else
function RemoveCookie(name,options){
{
var res = ["expires=Thu, 01 Jan 1970 00:00:00 GMT"];
if (data_txt[txt_num] == "")
if(options.path){
{
res.push("path="+options.path);
ret = -2;
if(decision_mode == true && name_checked == true)
{
decision_mode = false;
}
}
}
else
if(options.domain){
{
res.push("domain="+options.domain);
ret = txt_check();
}
}
document.cookie = name + "=" + ";" + res.join(";");
}
}
if(ret == -2)
</script>
{
<script class="navigation-not-searchable">
if(mw.config.values.debug==true){console.log("Has skipped the space part.Data number:" + txt_num);}
var AnaRes = {dynamic:0,skip:-2,error:-1,next:1,wait:2};
txt_num++;
function txt_analyze(txt)
txt_next();
return;
}
else if(ret == -1)
{
if(mw.config.values.debug==true){console.log("Has skipped the unused part.Data number:" + txt_num);}
txt_num++;
txt_next();
return;
}
else if(ret == 1)
{
if(mw.config.values.debug==true){console.log("Data analyze complete.Data number:" + txt_num);}
txt_num++;
txt_next();
return;
}
else if(ret == 2)
{
if(mw.config.values.debug==true){console.log("Break and wait.");}
txt_num++;
return;
}
if(mw.config.values.debug==true){console.log("Data number:" + txt_num);}
if(txt_num < txt_max && txt_num >= 0)
{
txt_dynamic();
}
}
function txt_check()
{
{
if(data_txt[txt_num].match("^\\s+$")) //ONLY SPACE REGEX
let imgs = data.back,chars = data.char,mtpy = pos_multiply;
if(!txt || txt.match("^\\s+$") || txt.match("^\\s*//.*$")) /* ONLY SPACE REGEX|COMMENT REGEX */
{
{
return -1;
return -2;
}
}
else if(data_txt[txt_num].match("^\\s*//.*$")) //COMMENT REGEX
let match = txt.match("^\\[\\s*(?:(.*?)\\((.*)\\)|(?:([\\.|\\w]*)|(.*)))\\s*\\]\\s*(.*)"); /* COMMAND REGEX */
{
let temp = {};
return -1;
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;
}
}
var data_command = data_txt[txt_num].match("^\\[\\s*(?:(.*)\\((.*)\\)|(?:([\\.|\\w]*)|(.*)))\\s*\\]\\s*(.*)"); //COMMAND REGEX
else if(system.decision.mode){
if (data_command == null)
temp.d1 = match == undefined ? "" : match[1] == undefined ? "" : match[1].toLowerCase();
{
temp.d2 = match == undefined ? "" : match[3] == undefined ? "" : match[3].toLowerCase();
document.getElementById("txt_name").innerHTML = "";
if(temp.d1 != 'predicate' && temp.d2 != 'predicate') return -2;
now_txt = data_txt[txt_num];
document.getElementById("system_dialog").style.display = "block";
return 0;
}
}
if (data_command[1] != undefined)
if (match[1]){
{
let m1 = match[1].toLowerCase();
var command_set = {};
let cmd_set = match[2].toObject();
data_command[2] = data_command[2].toLowerCase();
let sets = cmd_set;
data_command[2] = data_command[2].replace(/\s+|["'\$]|(m_dia_)|(m_sys_)|(m_bat_)/g,"");
switch (m1)
for (num of data_command[2].split(","))
{
{
var [type,value] = num.split("=");
case 'background':
command_set[type] = value;
temp.o1 = $("#sys_back");
}
temp.o1.children().stop(true,true);
switch (data_command[1].toLowerCase())
temp.t = cmd_set.fadetime ? +cmd_set.fadetime : 0.15;
{
temp.c1 = temp.o1.children('div').length;
case 'header':
temp.n = cmd_set.image ? "bg_" + cmd_set.image.toLowerCase() : "";
return -1;
if(!temp.n){
case 'playmusic':
if(temp.t > 0){
var obj_music = document.getElementById("system_music");
temp.o1.children('div').fadeToExit(temp.t*1000);
var times=0;
if(cmd_set.block == "true"){
if(command_set.intro == undefined)
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':
{
{
console.error("Command Analyze error:Music intro is not exist.");
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(data_audio[command_set.intro] == undefined)
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)
{
{
console.warn("Audio Data:" + command_set.intro + " is not exist,please check the data list.");
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;
}
}
obj_music.src = data_audio[command_set.intro];
cutin_paras.width = temp.w;
if(command_set.key == undefined)
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':
{
{
console.warn("Music key is no exist,has use the intro to instead.");
if(!cmd_set.options) return -1;
music_loop = data_audio[command_set.intro];
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;
}
}
else
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':
{
{
music_loop = data_audio[command_set.key];
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;
}
}
obj_music.load();
break;
if(command_set.volume != undefined)
case 'showitem':
{
temp.o1 = $("#sys_item");
obj_music.volume = command_set.volume;
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;
}
}
if (command_set.delay != undefined)
temp.i1 = new Image();
{
temp.i1.src = imgs[temp.n];
times = command_set.delay * 1000;
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;
}
}
obj_music.loop = false;
break;
music_stats = "intro";
setTimeout("fun_delay('music')",times);
flag_music = true;
return 1;
case 'playsound':
return -1;
case 'stopmusic':
case 'stopmusic':
music_stop();
case 'stopsound':
return 1;
case 'delay':
if (command_set.time == undefined)
{
{
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(timer_id_wait == -1)
if(temp.cmd == "subtitle"){
{
$("#sys_subtitle").children("span.subtitle").fadeToExit(temp.t);
fun_setting("cmd_close");
timer_id_wait = setTimeout("fun_delay('delay')",command_set.time*1000);
}
}
return 2;
system.txt.delay.set("word",cmd_set.delay*1000);
case 'blocker':
temp.o1 = document.createElement("span");
var temp_d1,temp_d2,temp_c1;
if(cmd_set.id) temp.o1.id = temp.cmd + "_" + cmd_set.id;
temp_d1 = Number(command_set.a);
temp.o1.className = "subtitle_style "+temp.cmd;
temp_d2 = Number(command_set.fadetime);
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;
if(isNaN(temp_d1) == true)
$(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':
{
{
console.warn("a isn't a number,use the default setting to instead.");
let mode = cmd_set.mode || "false";
temp_d1 = 1;
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");
}
}
}
temp_d1 = 100 - temp_d1 * 100;
break;
if(temp_d1 > 100)
case 'timerclear':
{
{
temp_d1 = 100;
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");
}
}
if(isNaN(temp_d2) == true)
break;
case 'timersticker':
{
{
console.warn("fadetime isn't a number,use the default setting to instead.");
let px = cmd_set.x*0.75 || 0,py = cmd_set.y*0.75 || 0,size = cmd_set.size*0.75 || 18;
temp_d2 = 1;
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);
}
}
temp_d2 *= 20;
break;
blocker_new = temp_d1;
case 'video':
temp_c1 = (blocker_new - blocker_now) / temp_d2;
if(cmd_set.res == undefined) return -1;
if(timer_id_blocker == -1)
fun_setting("cmd_suspend");
{
temp.o1 = document.createElement("video");
fun_setting("cmd_close");
temp.o1.width = 960;
timer_id_blocker = setInterval("blocker_dynamic(" + temp_c1 +")",50);
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 'decision':
default:
if(command_set.options == undefined)
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 data_decision = command_set.options.split(";");
temp.sx*=1.2,temp.sy*=1.2;/* temp parameter */
var temp_c1 = command_set.values.split(";");
temp.i1 = new Image();
var obj_1 = document.getElementById("decision_1");
temp.i1.src = imgs[temp.n];
var obj_2 = document.getElementById("decision_2");
cmd_set.screenadapt = "coverall";
var obj_3 = document.getElementById("decision_3");
temp.e1.attr("d-adapt",cmd_set.screenadapt);
obj_1.style.fontSize = "";
temp.i1.onload = function(){
obj_2.style.fontSize = "";
var w = this.width*0.75,h = this.height*0.75;
obj_3.style.fontSize = "";
var obj = temp.e1;
decision_value = [-1,-1,-1];
if(obj.attr("d-adapt") == "coverall"){
switch (data_decision.length)
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':
{
{
case 1:
let n1 = cmd_set.name ? cmd_set.name.toLowerCase() : "",n2 = cmd_set.name2 ? cmd_set.name2.toLowerCase() : "";
decision_value[1] = temp_c1[0];
let f = +cmd_set.focus || 0,dur = +cmd_set.fadetime || 0.15,cnt = n2 ? 2 : 1;
if(data_decision[0].length > 12)
let tarA = "char_left",tarB = "char_right";
{
if(!n1 && !n2){
obj_2.style.fontSize = "10px";
$("#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);
}
}
obj_1.style.display = "none";
else{
obj_2.innerHTML = data_decision[0];
if(tarA != "char_middle") $("#char_middle").fadeToExit(dur*950);
obj_2.style.display = "block";
let [sx,sy,px,py] = fun_char_pos(n,n2 ? -1 : 0);
obj_3.style.display = "none";
let e = $(document.createElement("canvas"));
break;
e.css({"position":"absolute","left":px,"top":py});
case 2:
e.attr({"data-n":n,"data-cnt":cnt,"width":sx,"height":sy});
decision_value[0] = temp_c1[0];
fun_draw_char(e[0],chars[k],sx,sy,cmd_set.blackstart,cmd_set.blackend);
decision_value[2] = temp_c1[1];
char.append(e);
if(data_decision[0].length > 12)
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;
obj_1.style.fontSize = "10px";
e.hide().fadeIn(dur*1000);
if(sf) timer.create("char1_reset",()=>char.attr("style",""),dur*950);
char.children(`:lt(${len})`).fadeToExit(dur*950);
}
}
if(data_decision[1].length > 12)
if(ent){
{
timer.clear("char1_enter");
obj_3.style.fontSize = "10px";
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);
}
}
obj_1.innerHTML = data_decision[0];
}
obj_1.style.display = "block";
if(cmd_set.block == "true"){
obj_2.style.display = "none";
fun_delay("block",dur);
obj_3.innerHTML = data_decision[1];
return 2;
obj_3.style.display = "block";
}
}
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 3:
case 'jump':
decision_value[0] = temp_c1[0];
for(let i=0;i<temp.tm;i++)
decision_value[1] = temp_c1[1];
decision_value[2] = temp_c1[2];
if(data_decision[0].length > 12)
{
{
obj_1.style.fontSize = "10px";
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(data_decision[1].length > 12)
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':
{
{
obj_2.style.fontSize = "10px";
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);
}
}
if(data_decision[2].length > 12)
return 1;
{
case 'zoom':
obj_3.style.fontSize = "10px";
temp.pos[0] = cmd_set.xscale || cmd_set.scale || temp.pos[0];
}
temp.pos[3] = cmd_set.yscale || cmd_set.scale || temp.pos[3];
obj_1.innerHTML = data_decision[0];
temp.o1.css({"transition":"transform "+temp.fd+"s linear"});
obj_1.style.display = "block";
break;
obj_2.innerHTML = data_decision[1];
case 'exit':
obj_2.style.display = "block";
temp.c1 = cmd_set.direction == "left" ? -1920 : 1920;
obj_3.innerHTML = data_decision[2];
temp.c1 = temp.c1 + (temp.n == "left" ? 480 : -480);
obj_3.style.display = "block";
temp.pos[4] = temp.c1;
temp.o1.css("transition","transform "+temp.fd+"s ease-in-out");
break;
break;
default:
default:
console.error("decision data error.");
fun_msg(-1,false,"<CharacterAction>:Unknown type data:"+temp.tp);
return -1;
return -1;
}
}
if(flag_auto == true)
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)
{
{
fun_timer_clear("auto");
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;
}
}
fun_setting("cmd_close");
break;
document.getElementById("system_decision").style.display = "block";
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 'predicate':
case 'decision':
if (command_set.references == undefined)
{
{
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();
}
}
if (command_set.references.includes(decision_select) == true)
return 2;
{
case 'dialog':
decision_mode = false;
temp.t = cmd_set.fadetime == undefined ? 0 : cmd_set.fadetime;
break;
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;
}
}
name_checked = false;
decision_mode = true;
break;
break;
case 'background':
case 'dialogsetting':
var obj_back = document.getElementById("pic_back");
if(command_set.image == undefined)
{
{
obj_back.style.display = "none";
let delay = system.txt.delay;
break;
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(data_pic_back[command_set.image] == undefined)
break;
{
case 'header':
console.warn("Image Data:" + command_set.image + " is not exist,please check the data list.");
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;
}
}
obj_back.style.backgroundImage = "url('" + data_pic_back[command_set.image] + "')";
obj_back.style.display = "block";
break;
break;
case 'image':
case 'image':
var obj_image = document.getElementById("pic_image");
temp.o1 = $('#sys_image');
if(command_set.image == undefined)
temp.o1.children().stop(true,true);
{
temp.t = cmd_set.fadetime ? +cmd_set.fadetime : 0.15;
obj_image.style.display = "none";
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(data_pic_back[command_set.image] == undefined)
temp.e1 = document.createElement('div');
{
temp.e1 = $(temp.e1);
console.warn("Image Data:" + command_set.image + " is not exist,please check the data list.");
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;
}
}
obj_image.style.backgroundImage = "url('" + data_pic_back[command_set.image] + "')";
obj_image.style.display = "block";
break;
break;
case 'imagetween':
case 'imagetween':
return -1;
temp.o1 = $("#sys_image").children("div:last");
case 'camerashake':
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")) || ""; */
case 'character':
temp.t = cmd_set.duration || 0.15;
obj_char_1 = document.getElementById("pic_char_1");
/* if(temp.n == "") return -1; */
obj_char_2 = document.getElementById("pic_char_2");
/* temp.o1.css("backgroundImage","url('"+temp.n+"')"); */
obj_char = document.getElementById("pic_char");
temp.p = temp.o1.css("transform").replace(/\s/g,"").match(/^[a-z]+\((.*)\)/);
var temp_d1,temp_d2,pos_x,pos_y,size_x,size_y;
temp.p = temp.p == null ? [1,0,0,1,0,0] : temp.p[1].split(',');
if (command_set.name == undefined)
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':
{
{
obj_char_1.style.display = "none";
let ch = sets.channel;
obj_char_2.style.display = "none";
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`;
}
}
}
}
else if (command_set.name2 == undefined)
break;
{
case 'gridbg':
[temp_d1,temp_d2] = fun_char_link(command_set.name);
case 'verticalbg':
command_set.name = data_link[temp_d1][temp_d2].default;
case 'largebg':
pos_x = data_link[temp_d1][temp_d2].pos.x / 1.6;
case 'largeimg':
pos_y = data_link[temp_d1][temp_d2].pos.y / 1.6;
temp.mtf = m1.endsWith("bg");
size_x = data_link[temp_d1][temp_d2].scale.x / 1.6;
temp.o1 = temp.mtf ? $("#sys_back") : $("#sys_image");
size_y = data_link[temp_d1][temp_d2].scale.y / 1.6;
temp.ig = cmd_set.imagegroup == undefined ? [] : cmd_set.imagegroup.split('/');
obj_char.style.backgroundPosition = (400-size_x/2+pos_x) + "px " + (450-pos_y-size_y/2) + "px";
temp.sw = cmd_set.solidwidth == undefined ? [] : cmd_set.solidwidth.split('/');
obj_char.style.backgroundSize = size_x + "px " + size_y + "px";
temp.sh = cmd_set.solidheight == undefined ? [] : cmd_set.solidheight.split('/');
if(data_pic_char[command_set.name] == undefined)
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;
console.warn("Char Data:" + command_set.name + " is not exist,please check the data list.");
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;
}
}
}
if (command_set.focus == -1)
}
{
else if(m1.startsWith("vertical")){
obj_char.style.filter = "brightness(50%)"
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
}
{
else if(m1.startsWith("large")){
obj_char.style.filter = "";
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;
}
}
obj_char_1.style.display = "block";
obj_char_2.style.display = "none";
obj_char.style.backgroundImage = "url('" + data_pic_char[command_set.name] + "')";
}
}
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':
{
{
var char_left = document.getElementById("pic_char_left");
if(cmd_set.name == undefined) return -1;
var char_right = document.getElementById("pic_char_right");
system.txt.delay.set("word",cmd_set.delay*1000 || 30);
[temp_d1,temp_d2] = fun_char_link(command_set.name);
system.txt.dynamic = document.getElementById("dialog_output");
command_set.name = data_link[temp_d1][temp_d2].default;
if(!system.multi.mode){
pos_x = data_link[temp_d1][temp_d2].pos.x / 1.6;
system.multi.begin();
pos_y = data_link[temp_d1][temp_d2].pos.y / 1.6;
system.txt.now = "";
size_x = data_link[temp_d1][temp_d2].scale.x / 1.6;
}
size_y = data_link[temp_d1][temp_d2].scale.y / 1.6;
system.txt.name = cmd_set.name;
char_left.style.backgroundPosition = (400-125-size_x/2+pos_x) + "px " + (450-pos_y-size_y/2) + "px";
system.txt.now += fun_txt_format(match[5]);
char_left.style.backgroundSize = size_x + "px " + size_y + "px";
$("#dialog_name").html(cmd_set.name);
[temp_d1,temp_d2] = fun_char_link(command_set.name2);
$("#sys_dialog").show();
command_set.name2 = data_link[temp_d1][temp_d2].default;
if(cmd_set.end == "true"){
pos_x = data_link[temp_d1][temp_d2].pos.x / 1.6;
system.multi.end();
pos_y = data_link[temp_d1][temp_d2].pos.y / 1.6;
}
size_x = data_link[temp_d1][temp_d2].scale.x / 1.6;
}
size_y = data_link[temp_d1][temp_d2].scale.y / 1.6;
return 0;
char_right.style.backgroundPosition = (400+125-size_x/2+pos_x) + "px " + (450-pos_y-size_y/2) + "px";
case 'musicvolume':
char_right.style.backgroundSize =  size_x + "px " + size_y+ "px";
case "soundvolume":
if(data_pic_char[command_set.name] == undefined)
temp.cmd = match[1].toLowerCase();
{
if(cmd_set.volume == undefined){
console.warn("Char Data:" + command_set.name + " is not exist,please check the data list.");
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(data_pic_char[command_set.name2] == undefined)
if (id) {
{
fun_stop_audio(id);
console.warn("Char Data:" + command_set.name2 + " is not exist,please check the data list.");
}
}
if (command_set.focus == 1)
let args = { id: id, volume: vol, delay: ms };
{
if (m1 === "playsound") {
char_left.style.filter = "";
args.loop = sets.loop === "true";
char_right.style.filter = "brightness(50%)";
args.remove = !args.loop;
}
}
else if(command_set.focus ==2)
else if(m1 === "playmusic" && !intro){
{
args.loop = true;
char_left.style.filter = "brightness(50%)";
char_right.style.filter = "";
}
}
else
let aud = fun_audio_create(intro || key, args);
{
aud.classList.add(m1);
char_left.style.filter = "";
if (m1 === "playmusic" && intro) {
char_right.style.filter = "";
aud.setAttribute("data-loop", key);
aud.onended = function () {
this.src = this.getAttribute("data-loop");
this.removeAttribute("data-loop");
this.loop = true;
this.play();
}
}
}
obj_char_1.style.display = "none";
obj_char_2.style.display = "block";
char_left.style.backgroundImage = "url('" + data_pic_char[command_set.name] + "')";
char_right.style.backgroundImage = "url('" + data_pic_char[command_set.name2] + "')";
}
}
break;
break;
case 'charactercutin':
case 'predicate':
if(command_set.widgetid == undefined)
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':
{
{
document.getElementById("system_cutin").style.display = "none";
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;
}
}
var obj_cutin,temp_d1,temp_d2;
if(cmd_set.multi == "true"){
if(command_set.widgetid == 1)
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("system_cutin").style.display = "block";
let mode = cmd_set.mode || "false";
obj_cutin = document.getElementById("char_cutin_1");
let btn1 = document.getElementById("button_playback"),btn2 = document.getElementById("button_auto");
temp_d1 = "cutin_1";
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;
}
}
}
else
break;
case 'timerclear':
{
{
document.getElementById("system_cutin").style.display = "block";
let span = document.getElementById("sticker_timer");
obj_cutin = document.getElementById("char_cutin_2");
if(!span) return -1;
temp_d1 = "cutin_2";
$(span).css("opacity",cmd_set.afrom || 1).fadeTo(cmd_set.duration*1000 || 0,cmd_set.ato || 0);
timer.clear("sticker_timer");
}
}
if(command_set.name == undefined)
break;
case 'timersticker':
{
{
temp_d2 = Number(command_set.fadetime);
let px = cmd_set.x*0.75 || 0,py = cmd_set.y*0.75 || 0,size = cmd_set.size*0.75 || 18;
if(isNaN(temp_d2) == true)
var span = document.getElementById("sticker_timer");
{
if(!span){
temp_d2 = 0;
span = document.createElement("span");
document.getElementById("sys_subtitle").append(span);
}
}
obj_cutin.style.animation = "cutin-hide " + temp_d2 + "s 1"
span.className = "subtitle_style";
fun_setting("cmd_close");
let id = "sticker_timer";
if(timer_id_wait == -1)
span.id = id;
{
span.style.fontSize = `${size}px`;
timer_id_wait = setTimeout("fun_delay('" + temp_d1 + "')",temp_d2 * 1000);
span.style.left = `${px}px`;
}
span.style.top = `${py}px`;
return 2;
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(command_set.fadestyle == "horiz_expand_center")
break;
{
case 'video':
command_set.fadestyle = "cutin-show";
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();
}
}
[temp_d1,temp_d2] = fun_char_link(command_set.name)
$("#sys_animation").append(temp.o1);
command_set.name = data_link[temp_d1][temp_d2].default;
return 2;
size_x = data_link[temp_d1][temp_d2].scale.x / 1.6;
size_y = data_link[temp_d1][temp_d2].scale.y / 1.6;
obj_cutin.style.backgroundSize =  size_x + "px " + size_y+ "px";
obj_cutin.style.display = "block";
obj_cutin.style.backgroundImage = "url('" + data_pic_char[command_set.name] + "')";
obj_cutin.style.animation = command_set.fadestyle + " " + command_set.fadetime + "s 1";
setTimeout("fun_animation_clear('char_cutin_1')",command_set.fadetime*1000);
return 1;
default:
default:
fun_msg(-1,true,"Unknown command:"+match[1]);
return -1;
return -1;
}
}
return 1;
return 1;
}
}
else if(data_command[3] != undefined)
else if(match[3])
{
{
switch(data_command[3].toLowerCase())
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':
document.getElementById("txt_name").innerHTML = "";
$("#dialog_name").empty();
document.getElementById("txt_output").innerHTML = "";
$("#dialog_output").empty();
document.getElementById("system_dialog").style.display = "none";
$("#sys_dialog").hide();
break;
break;
case 'background':
/* @self define command */
document.getElementById("pic_back").style.display = "none";
case 'dialogsetting':
system.txt.delay.reset("all");
$("#dialog_name").removeAttr("style");
break;
break;
case 'image':
case 'image':
document.getElementById("pic_image").style.display = "none";
$("#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 'character':
case 'predicate':
document.getElementById("pic_char_1").style.display = "none";
system.decision.mode = false;
document.getElementById("pic_char_2").style.display = "none";
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(data_command[4] != undefined)
else if(!match[5])
return -1;
else if(match[4])
{
{
if(decision_mode == true)
let p = match[4].toObject();
{
system.txt.dynamic = document.getElementById("dialog_output");
name_checked = true;
if(p.delay){
return -1;
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});
}
}
document.getElementById("txt_name").innerHTML = data_command[4].replace(/(^[^"]+)"([^"]*)"/,"$2");
if(p.name == undefined) return -1;
now_txt = data_command[5].replace("{@nickname}",data_nickname);
system.multi.check();
document.getElementById("system_dialog").style.display = "block";
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 txt_auto()
function txt_click()
{
{
if(timer_id_temp == -1)
if(!system || system.stats.theater || timer.hasTimer("click_block")) return;
if(system.stats.auto) fun_auto_stop();
if(!system.stats.click)
{
{
timer_id_temp = setTimeout("fun_delay('system')",100);
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();
}
}
system_enabled = false;
if(timer.hasTimer("dynamic"))
if(auto_enabled == false)
{
{
if(mw.config.values.debug==true){console.log("auto didn't passed.");}
txt_stop();
system.txt.dynamic.innerHTML = system.txt.now;
return;
return;
}
}
if(mw.config.values.debug==true){console.log("auto passed.");}
txt_next();
if(reset_enabled == false)
}
{
function txt_fullscreen()
reset_enabled = true;
{
document.getElementById("button_reset").style.color = "";
let e1 = document.getElementById("sys_fullscreen"),e2 = document.getElementById("button_fullscreen");
}
if(!e1 || !e2) return 0;
if(flag_auto == false)
let isFull = e2.classList.contains("return");
{
if(isFull){
flag_auto = true;
if(fun_fullscreen_check()){
if(txt_num == 0)
if(document.exitFullscreen) document.exitFullscreen();
{  
else if(document.mozCancelFullScreen) document.mozCancelFullScreen();
fun_setting("pre");
else if(document.webkitExitFullscreen) document.webkitExitFullscreen();/* new webkit */
}
else if(document.webkitCancelFullScreen) document.webkitCancelFullScreen();/* old webkit */
if(timer_id_auto == -1)
else if(document.msExitFullscreen) document.msExitFullscreen();
{
auto_num = 1;
timer_id_auto = setInterval("auto_dynamic()",400);
}
if(timer_id_wait == -1)
{
timer_id_wait = setTimeout("txt_next()",now_txt_max*80+Math.min(txt_num,1)*1000);
}
}
}
}
else if(flag_auto == true)
else{
{
if(e1.requestFullscreen) e1.requestFullscreen();
auto_stop();
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 txt_reset()
function txt_next()
{
{
if(timer_id_temp == -1)
/* before */
{
if (system.txt.index >= system.txt.max){
timer_id_temp = setTimeout("fun_delay('system')",100);
fun_msg(1,true,"<Txt>index="+system.txt.index+",max="+system.txt.max);
}
if(timer.hasTimer("auto")) fun_auto_stop();
system_enabled = false;
fun_setting("reset");
if(reset_enabled == false)
document.getElementById("dialog_output").innerHTML = "剧情模拟已结束,单击将重新开始剧情回顾";
{
if(mw.config.values.debug==true){console.log("reset didn't passed.");}
return;
return;
}
}
if(mw.config.values.debug==true){console.log("reset passed.");}
/* check */
if(flag_auto == true)
let ret = 0,idx = system.txt.index,txt = data.txt[idx];
{
$(".dialog_style.header").attr({"d-now":idx});
auto_stop();
ret = txt === "" ? -2 : system.debug ? txt_analyze_test(txt) : txt_analyze(txt);
}
if(system.debug && system.stats.step && ret == 1) ret = 2;
if(flag_timer == true)
if(ret !== 0) system.txt.index++;
{
switch(ret){
txt_stop();
case -2:
}
fun_msg(0,true,"Has skipped the space or unused part.");
if(flag_music == true)
txt_next();
{
break;
music_stop();
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;
}
}
fun_timer_clear("wait");
fun_timer_clear("blocker");
document.getElementById("pic_back").style.display = "none";
document.getElementById("pic_image").style.display = "none";
document.getElementById("pic_char_1").style.display = "none";
document.getElementById("pic_char_2").style.display = "none";
document.getElementById("system_decision").style.display = "none";
document.getElementById("system_cutin").style.display = "none";
document.getElementById("system_blocker").style.filter = "";
blocker_now = 100;blocker_new = 100;
document.getElementById("txt_name").innerHTML = "剧情模拟器";
document.getElementById("txt_output").innerHTML = "剧情模拟已重置,单击开始剧情回顾";
document.getElementById("system_dialog").style.display = "block";
fun_setting("cmd_open");
reset_enabled = false;
document.getElementById("button_reset").style.color = "#808080"
txt_num = 0;
now_txt_max = 0;
return;
}
}
function txt_decision(choice)
function txt_playback(target,bind,isAll = false)
{
{
if(timer_id_temp == -1)
let obj1 = document.getElementById(target),obj2 = document.getElementById(bind);
{
let isIn = obj2.classList.contains("return");
timer_id_temp = setTimeout("fun_delay('system')",100);
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--;
}
}
system_enabled = false;
else{
decision_select = decision_value[choice];
if(system.stats.auto && system.flag.respond == 0 && !isAll) timer.clear("auto");
fun_setting("cmd_open");
obj1.setShow();
document.getElementById("system_decision").style.display = "none";
if(!isAll) {
if(flag_auto == true && timer_id_auto == -1)
obj1.scrollTop = obj1.scrollHeight-540;
{
}
timer_id_auto = setInterval("auto_dynamic()",400);
obj2.classList.remove("normal");
obj2.classList.add("return");
system.flag.respond++;
}
}
txt_next();
}
}
function auto_stop()
function txt_stop()
{
{
fun_timer_clear("auto");
let txt = system.txt,delay = txt.delay;
fun_timer_clear("wait");
let p = delay.per,c = delay.common;
document.getElementById("button_auto").innerHTML = "自动▶";
if(system.flag.skip >= wait_trigger){
flag_auto = false;
p = 0;
}
c = 0;
function txt_stop(stop_type)
}
{
if(txt.dynamic.parentElement){
if(mw.config.values.debug==true)
/* if is subtitle,reset the interval. */
{
if(txt.dynamic.parentElement.id == "sys_subtitle"){
if(stop_type == "n")
delay.reset("word");
{
console.log("The timer has been stop naturally.");
}
}
else if(stop_type == "f")
{
console.log("The timer has been forced stop.");
}
}
}
if (flag_auto == true && timer_id_wait == -1)
let ms = txt.now.length*p+c;
{
let obj = $("#dialog_audio");
timer_id_wait = setTimeout("txt_next()",now_txt_max*80+Math.min(txt_num,1)*1000);
if(system.stats.theater){
ms = c;
}
}
fun_timer_clear("id");
else if(obj.length > 0){
now_txt_num = 0;
let voice = obj[0];
now_txt_temp = "";
ms = (voice.duration-voice.currentTime)*1000;
txt_num++;
flag_timer = false;
}
function music_stop()
{
var obj_music_1,obj_music_2;
if(mw.config.values.debug == true)
{
obj_music_1 = document.getElementById("system_music");
obj_music_2 = document.getElementById("system_sound");
fun_timer_clear("music");
obj_music_1.pause();
obj_music_1.currentTime = 0;
obj_music_1.src = "";
obj_music_2.pause();
obj_music_2.currentTime = 0;
obj_music_2.src = "";
flag_music = false;
return;
}
}
obj_music_1 = document.getElementById("system_music");
timer.clear("txt");
fun_timer_clear("music");
timer.create("txt",()=>{
obj_music_1.pause();
if(timer.hasTimer("auto")) txt_next();
obj_music_1.currentTime = 0;
}, ms);
obj_music_1.loop = false;
timer.clear("dynamic");
obj_music_1.src = "";
timer.create("click_block",function(){},100);
flag_music = false;
if(system.multi.mode) system.txt.over();
else system.txt.init();
system.txt.index++;
}
}
function auto_dynamic()
function timer_auto()
{
{
var button_auto = document.getElementById("button_auto");
let ele = document.getElementById("button_auto");
switch (auto_num)
switch (system.flag.auto)
{
{
case 1:
case 1:
button_auto.innerHTML = "自动▶";
ele.innerHTML = "自动▶";
break;
break;
case 2:
case 2:
button_auto.innerHTML = "自动▶▶";
ele.innerHTML = "自动▶▶";
break;
break;
case 3:
case 3:
button_auto.innerHTML = "自动▶▶▶";
ele.innerHTML = "自动▶▶▶";
auto_num=0;
system.flag.auto=0;
break;
break;
}
}
auto_num++;
system.flag.auto++;
}
}
function txt_dynamic()
function timer_dialog()
{
{
var interval = 50;
let txt = system.txt;
if(mw.config.values.debug == true)
let tag = "",str = txt.now,str_tmp = txt.now_temp,len = str.length,idx = txt.now_index;
{
if (idx < len){
interval = txt_interval;
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;
}
}
now_txt_max = now_txt.length;
let rx = parseInt(Math.random()*99) + 1,ry = parseInt(Math.random()*99) + 1;
if(timer_id == -1)
fun_msg(1,true,"<ShakeCommon>rnd_x:"+rx+",rnd_y:"+ry);
{
let d = [-1,-0.707,0,1,0.707];
flag_timer = true;
rx = rx < ustb_p ? parseInt(Math.random()*5) : 0;
timer_id = setInterval("timer1()",interval);
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 blocker_dynamic(temp_c)
function fun_auto_stop()
{
{
blocker_now = blocker_now + temp_c;
timer.clear("auto");
document.getElementById("system_blocker").style.filter = "brightness(" + blocker_now + "%)";
document.getElementById("button_auto").innerHTML = "自动▶";
if(blocker_now < blocker_new && temp_c > 0)
system.stats.auto = false;
{
}
return;
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;
}
}
else if(blocker_now > blocker_new && temp_c < 0)
return sound;
{
}
return;
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;
}
}
blocker_now = blocker_new;
return len;
fun_timer_clear("blocker");
fun_setting("cmd_open");
document.getElementById("system_blocker").style.filter = "brightness(" + blocker_now + "%)";
txt_next();
}
}
function timer1()
function fun_cal_rgba(c_r,c_g,c_b,c_a)
{
{
if (now_txt_num < now_txt_max)
let d = [c_r,c_g,c_b,c_a];
for (let i = 0;i < d.length;i++)
{
{
now_txt_temp = now_txt_temp + now_txt.substr(now_txt_num,1);
d[i] = Math.max(0,d[i]);
document.getElementById("txt_output").innerHTML = now_txt_temp;
if(d[i] <= 1) d[i] = parseInt(d[i]*255);
now_txt_num++;
d[i] = d[i].toString(16);
return;
if(d[i] < 0x10) d[i] = "0" + d[i];
}
}
txt_stop("n");
return "#" + d[0] + d[1] + d[2] + d[3];
}
}
function timer2()
function fun_char_link(key_data)
{
{
var obj_music = document.getElementById("system_music");
let n,i,links = data.link;
if(obj_music.ended == false)
let key = key_data.trim();
if(!key)
{
{
return;
fun_msg(-2,false,"The input parameter is empty,has skipped the data.");
return [-1,-1];
}
}
flag_music = false;
let m = key.match(/^([^@#$]+)(?:([@#$])([a-z\d]+)|#(\d+)\$(\d+))?$/);
if(music_stats == "intro")
if(m == null)
{
{
music_stats = "loop";
fun_msg(-2,false,"Can't get key from the input parameter,has skipped the data.");
obj_music.currentTime = 0;
return [-1,-1];
obj_music.loop = true;
obj_music.src = music_loop;
obj_music.play();
fun_timer_clear("music");
flag_music = true;
}
}
}
n = m[1],i = m[3];
function fun_setting(mode)
if(links[n] == undefined)
{
if(mode == "pre")
{
{
if (mw.config.values.debug == true)
fun_msg(-2,false,"The appointed key ["+n+"] not exist,has skipped the data.");
{
return [-1,-1];
txt_max = data_txt.length;
}
console.log("txt_max=" + txt_max);
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;
}
}
else if(txt_max == 0)
if(i >= links[n].array.length)
{
{
txt_max = data_txt.length;
fun_msg(-1,false,"The analyze key ["+n+":"+i+"] is out of range,use the default char to instead.");
i = 0;
}
}
reset_enabled = true;
return [n,i];
document.getElementById("txt_name").innerHTML = "";
}
document.getElementById("txt_output").innerHTML = "";
else if(m[2] == '@'){
document.getElementById("system_dialog").style.display = "none";
for(let idx = 0;idx<links[n].array.length;idx++) if(links[n].array[idx].alias == i) return [n,idx];
document.getElementById("button_reset").style.color = "";
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;
}
}
else if(mode == "cmd_close")
return data.link[key].array[idx].name;
{
}
click_enabled = false;
function fun_char_pos(key,pos = 0){
auto_enabled = false;
let links = data.link,mtpy = pos_multiply;
document.getElementById("button_auto").style.color = "#808080";
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.");
}
}
else if(mode == "cmd_open")
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")
{
{
click_enabled = true;
fun_setting("cmd_close");
auto_enabled = true;
if(system.flag.skip == wait_trigger) t = 0;
document.getElementById("button_auto").style.color = "";
setTimeout(function(){
fun_setting("cmd_open");
if(system.stats.reset) txt_next();
},t);
}
}
}
}
function fun_delay(key_cmd)
/**
* @param {HTMLCanvasElement} can
* @param {String} url
* @param {Number} w
* @param {Number} h
* @param {Number[]} black
*/
function fun_draw_char(can,url,w,h,...black)
{
{
if(key_cmd == "system")
var img = new Image();
{
img.src = url;
fun_timer_clear("temp");
img.onload = function(){
if(mw.config.values.debug==true)
if(can.width != w || can.height != h)
{
{
console.log("system_enabeld has been set to true.");
can.width = w;
can.height = h;
}
}
system_enabled = true;
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);
}
}
else if(key_cmd == "music")
var ang= Number.isNaN(+dire) ? dire : dire_map[dire],fr_p = fr*100,to_p = to*100;
{
var tick = dur*100;
document.getElementById("system_music").play();
if(tick <= 0){
if(timer_id_music == -1)
ele.style.backgroundImage = "linear-gradient("+ang+",black "+to_p+"%,transparent "+to_p+"%)";
{
ele.style.opacity = parseFloat(alpha);
timer_id_music = setInterval("timer2()",100);
return;
}
}
}
else if(key_cmd == "sound")
var now = fr_p,sep = (to_p-fr_p)/tick,sep_a = (1-alpha)/tick;
{
ele.setAttribute("d-end",to_p);
document.getElementById("system_sound").play();
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);
}
}
else if(key_cmd == "delay")
timer.create("dyn_curtain_"+dire,function(){
{
var o = document.getElementById(dire_name);
fun_timer_clear("wait");
if(!o){
fun_setting("cmd_open");
timer.clear("dyn_curtain_"+dire);
txt_next();
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);
}
}
else if(key_cmd == "cutin_1")
}
{
function fun_fullscreen(){
document.getElementById("char_cutin_1").style.display = "none";
let sx = screen.width,sy = screen.height;
fun_animation_clear("char_cutin_1");
let s = Math.min(sx/base_width,sy/base_height);
fun_setting("cmd_open");
let px=(sx-base_width*s)/2,py=(sy-base_height*s)/2;
txt_next();
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 if(key_cmd == "cutin_2")
else{
{
ele1.style.transform = "";
document.getElementById("char_cutin_2").style.display = "none";
ele2.classList.add("normal");
fun_animation_clear("char_cutin_2");
ele2.classList.remove("return");
fun_setting("cmd_open");
ele3.style.left = "";
txt_next();
ele3.style.top = "";
}
}
}
}
function fun_timer_clear(key_id)
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(key_id == "id" && timer_id != -1)
if(!key) return "";
{
let p = key.toLowerCase();
clearInterval(timer_id);
return key.startsWith("$") ? data.audio[p.substr(1)] : key.startsWith("@") ? assets_url + p.substr(1) : assets_url + p.replace("sound_beta_2", "audio") + ".mp3";
timer_id = -1;
}
/**
* 向控制台输出一条带有时间信息的数据
* @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;
}
}
else if(key_id == "temp" && timer_id_temp != -1)
}
{
function fun_playback(tar,para,txt = system.txt.now){
clearTimeout(timer_id_temp);
let o = document.createElement("li");
timer_id_temp = -1;
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;
}
}
else if(key_id == "auto" && timer_id_auto != -1)
if(n.trim()){
{
let e1 = document.createElement("em");
clearInterval(timer_id_auto);
e1.innerHTML = n;
timer_id_auto = -1;
o.append(e1);
}
}
else if(key_id == "wait" && timer_id_wait != -1)
let e2 = document.createElement("span");
{
e2.innerHTML = txt.replace(/\<(?!br).*?\>/g,"");
clearTimeout(timer_id_wait);
o.append(e2);
timer_id_wait = -1;
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;
}
}
else if(key_id == "music" && timer_id_music != -1)
}
{
function fun_stop_audio(key,args)
clearTimeout(timer_id_music);
{
timer_id_music = -1;
let pas = args || { time: 0.5 };
if (!key.startsWith("@")) {
let tar = document.getElementById(key);
if (tar) tar.fade(pas.time, 0, true);
return;
}
}
else if(key_id == "blocker" && timer_id_blocker != -1)
switch(key){
{
case "@all":
clearInterval(timer_id_blocker);
{
timer_id_blocker = -1;
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 fun_animation_clear(obj_id)
function fun_skip_start()
{
{
document.getElementById(obj_id).style.animation = "";
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 fun_char_link(temp_data)
function fun_skip_stop()
{
{
var place,temp_d1,temp_d2;
if(!system) return;
place = temp_data.lastIndexOf("#");
if(system.flag.skip == wait_trigger){
if(place > 0)
timer.removeFake("auto");
{
timer.create("click_block",function(){},100);
temp_d1 = temp_data.substr(0,place);
}
temp_d2 = temp_data.substr(place + 1);
else timer.clear("skip");
if(mw.config.values.debug == true){console.log("temp_d1=" + temp_d1 + ",temp_d2=" + temp_d2);}
system.flag.skip = 0;
try{
}
temp_d2--;
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;
}
}
catch(err){
var dat = `*Time: ${new Date().toLocaleString()}\n*Note: ${note}`;
if(mw.config.values.debug == true){console.error("Data analyze error,use the default char to instead");}
if(system.error.stat) dat = `${dat}\n*error: ${system.error.info}\n**client: ${system.user.client} | screen: ${system.user.display}`;
temp_d2 = 0;
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 [temp_d1,temp_d2];
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}"`);
}
}
place = temp_data.lastIndexOf("@");
return `[${header}(${res.join(', ')})]`;
if(place > 0)
}
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++)
{
{
temp_d1 = temp_data.substr(0,place);
if(sets.check('override',page,i)) txts[i] = sets.override[page][i+1];
temp_d2 = temp_data.substr(place1 + 1);
let txt = txts[i];
if(mw.config.values.debug == true){console.log("temp_d1=" + temp_d1 + ",temp_d2=" + temp_d2);}
if(!txt || txt.match("^\\s+$") || txt.match("^\\s*//.*$")) continue;
for(place = 0;place<data_link[temp_d1].length;place++)
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)
{
{
if(data_link[temp_d1][place].name == temp_d2)
let m1 = match[1].toLowerCase(),cmd_set = match[2].toObject();
switch (m1)
{
{
return [temp_d1,place];
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(place == data_link[temp_d1].length)
else if(match[4] && match[5])
{
{
if(mw.config.values.debug == true){console.error("Data analyze error,use the default char to instead");}
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]));
}
}
}
}
return [temp_data,0];
for (let asset of assets){
queue.loadFile(asset,false);
}
system.multi.reset();/* 临时使用完毕 */
if(str) document.getElementById('playback_all_result').append(str);
}
}
function txt_check_test()
function fun_format_time(t){
{
let arr = [Math.floor(t/3600),Math.floor((t%3600)/60),Math.floor(t%60)];
if(data_txt[txt_num].match("^\\s+$")) //ONLY SPACE REGEX
for(let i = 0;i<arr.length;i++){
{
arr[i] = arr[i] < 10 ? "0"+arr[i].toString() : arr[i].toString();
return -1;
}
}
else if(data_txt[txt_num].match("^\\s*//.*$")) //COMMENT REGEX
return `${arr[0]}:${arr[1]}:${arr[2]}`;
{
}
return -1;
</script>
}
<script class="navigation-not-searchable">
var data_command = data_txt[txt_num].match("^\\[\\s*(?:(.*)\\((.*)\\)|(?:([\\.|\\w]*)|(.*)))\\s*\\]\\s*(.*)"); //COMMAND REGEX
(window.RLQ = window.RLQ || []).push(["jquery", function () {
console.log(data_command);
$(document).ready(()=>{
if (data_command == null)
$(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange', function() {
{
fun_fullscreen();
document.getElementById("txt_name").innerHTML = "";
});
now_txt = data_txt[txt_num];
$("#button_fullscreen").click(function() {
document.getElementById("system_dialog").style.display = "block";
txt_fullscreen();
return 0;
});
}
let name = mw.config.get("wgUserName");
if (data_command[1] != undefined)
system.user.name = name ? name.replace(/[Dd][Rr]\./,"") : "博士";
{
try{
var command_set = {};
fun_sys_preload();
data_command[2] = data_command[2].toLowerCase();
}
data_command[2] = data_command[2].replace(/\s+|["'\$]|(m_dia_)|(m_sys_)|(m_bat_)/g,"");
catch(err){
console.log(data_command[2]);
document.getElementById("dialog_output").innerHTML = "数据载入异常。请尝试刷新页面或是将提交异常反馈。"
for (num of data_command[2].split(","))
system.error.type = "preload_error";
{
system.error.info = err.toString();
var [type,value] = num.split("=");
system.error.stat = true;
command_set[type] = value;
}
});
$.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;
}
}
console.log(command_set);
if(system.user.client == "desktop") document.getElementById("button_report").setShow();
switch (data_command[1].toLowerCase())
var txt = document.getElementById("dialog_output");
{
txt.innerHTML = "页面已加载完毕。为避免意外的数据消耗,剧情资源仅在长按1s后开始预载。如果您仅需浏览纯文本内容,请直接单击LOG ALL";
case 'header':
system.preload.init();
return -1;
};
case 'playmusic':
fun_sys_init();
var obj_music = document.getElementById("system_music");
</script>
var times=0;
<script class="navigation-not-searchable">
if(command_set.intro == undefined)
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);
console.error("Command Analyze error:Music intro is not exist.");
queue.installPlugin(createjs.Sound);
return -1;
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(data_audio[command_set.intro] == undefined)
else if(tar === "word"){
{
self.word = 30;
console.warn("Audio Data:" + command_set.intro + " is not exist,please check the data list.");
}
}
obj_music.src = data_audio[command_set.intro];
else if(tar === "per"){
if(command_set.key == undefined)
self.per = 50;
{
console.warn("Music key is no exist,has use the intro to instead.");
music_loop = data_audio[command_set.intro];
}
}
else
else if(tar === "common"){
{
self.common = 1500;
music_loop = data_audio[command_set.key];
}
}
obj_music.load();
}
if(command_set.volume != undefined)
}
{
},
obj_music.volume = command_set.volume;
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 (command_set.delay != undefined)
if(timer.hasTimer("auto")) fun_auto_stop();
{
if(timer.hasTimer("dynamic")) txt_stop();
times = command_set.delay * 1000;
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");
}
}
}
obj_music.loop = false;
});
music_stats = "intro";
auto.addEventListener("click",function(ev){
setTimeout("fun_delay('music')",times);
var stats = system.stats;
flag_music = true;
if((!stats.click && system.txt.max == 0) || stats.theater || stats.report){
return 1;
fun_msg(0,true,"auto didn't pass.");
case 'playsound':
return 0;
return -1;
case 'stopmusic':
music_stop();
return 1;
case 'delay':
if (command_set.time == undefined)
{
return -1;
}
}
if(timer_id_wait == -1)
if(!stats.auto){
{
stats.auto = true;
fun_setting("cmd_close");
if(system.txt.index == 0) fun_setting("pre");
timer_id_wait = setTimeout("fun_delay('delay')",command_set.time*1000);
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();
}
}
return 2;
else{
case 'blocker':
fun_auto_stop();
var temp_d1,temp_d2,temp_c1;
temp_d1 = Number(command_set.a);
temp_d2 = Number(command_set.fadetime);
if(isNaN(temp_d1) == true)
{
console.warn("a isn't a number,use the default setting to instead.");
temp_d1 = 1;
}
}
temp_d1 = 100 - temp_d1 * 100;
ev.preventDefault();
if(temp_d1 > 100)
});
{
/* property */
temp_d1 = 100;
var sets = system.stats;
}
auto.classList.remove("forbid");
if(isNaN(temp_d2) == true)
sets.click = true;
{
if(system.error.stat){
console.warn("fadetime isn't a number,use the default setting to instead.");
document.getElementById("dialog_output").innerHTML = "部分数据预载入异常,本次剧情回顾可能存在图片/音频消失的情况。LOG ALL已禁用<br/>单击开始剧情回顾";
temp_d2 = 1;
sets.log_all = false;
}
}
temp_d2 *= 20;
else{
blocker_new = temp_d1;
document.getElementById("dialog_output").innerHTML = "资源加载完毕。单击开始剧情回顾";
temp_c1 = (blocker_new - blocker_now) / temp_d2;
}
if(timer_id_blocker == -1)
if(sets.log_all) document.getElementById("button_playback_all").setShow();
{
if(fun_fullscreen_support()) document.getElementById("button_fullscreen").setShow();
fun_setting("cmd_close");
if(system.user.client == "desktop") document.getElementById("button_report").setShow();
timer_id_blocker = setInterval("blocker_dynamic(" + temp_c1 +")",50);
},
}
handler:{
return 2;
begin: function(e){
case 'decision':
if(timer.hasTimer("preload_wait")) return;
if(command_set.options == undefined)
timer.create("preload_wait",function(){
{
system.preload.start();
return -1;
}, 1000);
}
},
var data_decision = command_set.options.split(";");
end: function(e){
var temp_c1 = command_set.values.split(";");
timer.clear("preload_wait");
console.log(data_decision);
},
var obj_1 = document.getElementById("decision_1");
}
var obj_2 = document.getElementById("decision_2");
}
var obj_3 = document.getElementById("decision_3");
};
obj_1.style.fontSize = "";
var scenario = {
obj_2.style.fontSize = "";
cutin:{
obj_3.style.fontSize = "";
decision_value = [-1,-1,-1];
}
switch (data_decision.length)
}
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 1:
case 'title':
decision_value[1] = temp_c1[0];
if(data_decision[0].length > 12)
{
{
obj_2.style.fontSize = "10px";
let [p,n] = m2.split('=');
if(!n) continue;
ride[m1][p] = n;
}
}
obj_1.style.display = "none";
obj_2.innerHTML = data_decision[0];
obj_2.style.display = "block";
obj_3.style.display = "none";
break;
break;
case 2:
case 'char':
decision_value[0] = temp_c1[0];
case 'image':
decision_value[2] = temp_c1[1];
case 'tween':
if(data_decision[0].length > 12)
{
{
obj_1.style.fontSize = "10px";
/* 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;
}
}
if(data_decision[1].length > 12)
break;
case 'override':
{
{
obj_3.style.fontSize = "10px";
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;
}
}
obj_1.innerHTML = data_decision[0];
obj_1.style.display = "block";
obj_2.style.display = "none";
obj_3.innerHTML = data_decision[1];
obj_3.style.display = "block";
break;
break;
case 3:
case 'disable':
decision_value[0] = temp_c1[0];
decision_value[1] = temp_c1[1];
decision_value[2] = temp_c1[2];
if(data_decision[0].length > 12)
{
obj_1.style.fontSize = "10px";
}
if(data_decision[1].length > 12)
{
obj_2.style.fontSize = "10px";
}
if(data_decision[2].length > 12)
{
{
obj_3.style.fontSize = "10px";
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;
}
}
}
}
obj_1.innerHTML = data_decision[0];
obj_1.style.display = "block";
obj_2.innerHTML = data_decision[1];
obj_2.style.display = "block";
obj_3.innerHTML = data_decision[2];
obj_3.style.display = "block";
break;
break;
default:
console.error("decision data error.");
return -1;
}
}
if(flag_auto == true)
}
{
console.log(ride);
fun_timer_clear("auto");
}
}
obj = document.getElementById("datas_txt");
fun_setting("cmd_close");
if(obj){
document.getElementById("system_decision").style.display = "block";
this.txt = obj.innerHTML.split('\n');
return 2;
let m = this.txt[0].match(/\[header\((.*)\)/i);
case 'predicate':
if(m){
if (command_set.references == undefined)
let set = m[1].toObject();
{
if(set.is_prtswiki_only == "true") system.stats.log_all = false;
return -1;
}
}
}
if (command_set.references.includes(decision_select) == true)
obj = document.getElementById("datas_back");
{
if(obj){
decision_mode = false;
for(let d of obj.innerHTML.split('\n')){
break;
let [k,v] = d.split(',');
}
this.back[k] = v;
name_checked = false;
}
decision_mode = true;
}
break;
obj = document.getElementById("datas_char");
case 'background':
if(obj){
var obj_back = document.getElementById("pic_back");
for(let d of obj.innerHTML.split('\n')){
if(command_set.image == undefined)
let [k,v] = d.split(',');
{
this.char[k] = v;
obj_back.style.display = "none";
}
break;
}
if(data_pic_back[command_set.image] == undefined)
{
console.warn("Image Data:" + command_set.image + " is not exist,please check the data list.");
}
obj_back.style.backgroundImage = "url('" + data_pic_back[command_set.image] + "')";
obj_back.style.display = "block";
break;
case 'image':
var obj_image = document.getElementById("pic_image");
if(command_set.image == undefined)
{
obj_image.style.display = "none";
break;
}
if(data_pic_back[command_set.image] == undefined)
{
console.warn("Image Data:" + command_set.image + " is not exist,please check the data list.");
}
obj_image.style.backgroundImage = "url('" + data_pic_back[command_set.image] + "')";
obj_image.style.display = "block";
break;
case 'imagetween':
return -1;
case 'camerashake':
return -1;
case 'character':
obj_char_1 = document.getElementById("pic_char_1");
obj_char_2 = document.getElementById("pic_char_2");
obj_char = document.getElementById("pic_char");
var temp_d1,temp_d2,pos_x,pos_y,size_x,size_y;
if (command_set.name == undefined)
{
obj_char_1.style.display = "none";
obj_char_2.style.display = "none";
}
else if (command_set.name2 == undefined)
{
[temp_d1,temp_d2] = fun_char_link(command_set.name);
console.log("temp_d1=" + temp_d1 + ",temp_d2=" + temp_d2);
command_set.name = data_link[temp_d1][temp_d2].default;
pos_x = data_link[temp_d1][temp_d2].pos.x / 1.6;
pos_y = data_link[temp_d1][temp_d2].pos.y / 1.6;
size_x = data_link[temp_d1][temp_d2].scale.x / 1.6;
size_y = data_link[temp_d1][temp_d2].scale.y / 1.6;
obj_char.style.backgroundPosition = (400-size_x/2+pos_x) + "px " + (450-pos_y-size_y/2) + "px";
obj_char.style.backgroundSize = size_x + "px " + size_y + "px";
if(data_pic_char[command_set.name] == undefined)
{
console.warn("Char Data:" + command_set.name + " is not exist,please check the data list.");
}
if (command_set.focus == -1)
{
obj_char.style.filter = "brightness(50%)"
}
else
{
obj_char.style.filter = "";
}
obj_char_1.style.display = "block";
obj_char_2.style.display = "none";
obj_char.style.backgroundImage = "url('" + data_pic_char[command_set.name] + "')";
}
else
{
var char_left = document.getElementById("pic_char_left");
var char_right = document.getElementById("pic_char_right");
[temp_d1,temp_d2] = fun_char_link(command_set.name);
command_set.name = data_link[temp_d1][temp_d2].default;
pos_x = data_link[temp_d1][temp_d2].pos.x / 1.6;
pos_y = data_link[temp_d1][temp_d2].pos.y / 1.6;
size_x = data_link[temp_d1][temp_d2].scale.x / 1.6;
size_y = data_link[temp_d1][temp_d2].scale.y / 1.6;
char_left.style.backgroundPosition = (400-125-size_x/2+pos_x) + "px " + (450-pos_y-size_y/2) + "px";
char_left.style.backgroundSize = size_x + "px " + size_y + "px";
[temp_d1,temp_d2] = fun_char_link(command_set.name2);
command_set.name2 = data_link[temp_d1][temp_d2].default;
pos_x = data_link[temp_d1][temp_d2].pos.x / 1.6;
pos_y = data_link[temp_d1][temp_d2].pos.y / 1.6;
size_x = data_link[temp_d1][temp_d2].scale.x / 1.6;
size_y = data_link[temp_d1][temp_d2].scale.y / 1.6;
char_right.style.backgroundPosition = (400+125-size_x/2+pos_x) + "px " + (450-pos_y-size_y/2) + "px";
char_right.style.backgroundSize =  size_x + "px " + size_y+ "px";
if(data_pic_char[command_set.name] == undefined)
{
console.warn("Char Data:" + command_set.name + " is not exist,please check the data list.");
}
if(data_pic_char[command_set.name2] == undefined)
{
console.warn("Char Data:" + command_set.name2 + " is not exist,please check the data list.");
}
if (command_set.focus == 1)
{
char_left.style.filter = "";
char_right.style.filter = "brightness(50%)";
}
else if(command_set.focus ==2)
{
char_left.style.filter = "brightness(50%)";
char_right.style.filter = "";
}
else
{
char_left.style.filter = "";
char_right.style.filter = "";
}
obj_char_1.style.display = "none";
obj_char_2.style.display = "block";
char_left.style.backgroundImage = "url('" + data_pic_char[command_set.name] + "')";
char_right.style.backgroundImage = "url('" + data_pic_char[command_set.name2] + "')";
}
break;
case 'charactercutin':
if(command_set.widgetid == undefined)
{
document.getElementById("system_cutin").style.display = "none";
return 1;
}
var obj_cutin,temp_d1,temp_d2,size_x,size_y;
if(command_set.widgetid == 1)
{
document.getElementById("system_cutin").style.display = "block";
obj_cutin = document.getElementById("char_cutin_1");
temp_d1 = "cutin_1";
}
else
{
document.getElementById("system_cutin").style.display = "block";
obj_cutin = document.getElementById("char_cutin_2");
temp_d1 = "cutin_2";
}
if(command_set.name == undefined)
{
temp_d2 = Number(command_set.fadetime);
if(isNaN(temp_d2) == true)
{
temp_d2 = 0;
}
obj_cutin.style.animation = "cutin-hide " + temp_d2 + "s 1"
fun_setting("cmd_close");
if(timer_id_wait == -1)
{
timer_id_wait = setTimeout("fun_delay('" + temp_d1 + "')",temp_d2 * 1000);
}
return 2;
}
if(command_set.fadestyle == "horiz_expand_center")
{
command_set.fadestyle = "cutin-show";
}
[temp_d1,temp_d2] = fun_char_link(command_set.name)
command_set.name = data_link[temp_d1][temp_d2].default;
size_x = data_link[temp_d1][temp_d2].scale.x / 1.6;
size_y = data_link[temp_d1][temp_d2].scale.y / 1.6;
obj_cutin.style.backgroundSize =  size_x + "px " + size_y+ "px";
obj_cutin.style.display = "block";
obj_cutin.style.backgroundImage = "url('" + data_pic_char[command_set.name] + "')";
obj_cutin.style.animation = command_set.fadestyle + " " + command_set.fadetime + "s 1";
setTimeout("fun_animation_clear('char_cutin_1')",command_set.fadetime*1000);
return 1;
default:
return -1;
}
}
return 1;
obj = document.getElementById("datas_audio");
}
if(obj){
else if(data_command[3] != undefined)
let str = obj.innerHTML.toLocaleLowerCase(),pos = str.search(/,\s+\}$/);
{
if(pos != -1) {
switch(data_command[3].toLowerCase())
fun_msg(0,false,"The inner code has been executed.");
{
str = str.substr(0,pos) + "}";/* 防止背刺 */
case 'dialog':
}
document.getElementById("txt_name").innerHTML = "";
let dics = JSON.parse(str);
document.getElementById("txt_output").innerHTML = "";
for(let k in dics){
document.getElementById("system_dialog").style.display = "none";
if(dics[k].toString().indexOf("sound_beta_2") == -1) continue;
break;
this.audio[k] = dics[k].replace("sound_beta_2",assets_url + "audio") + ".mp3";
case 'background':
}
document.getElementById("pic_back").style.display = "none";
this.audio["btn_click"] = source_url + "music/general/g_ui/g_ui_btn_n.mp3";
break;
case 'image':
document.getElementById("pic_image").style.display = "none";
break;
case 'character':
document.getElementById("pic_char_1").style.display = "none";
document.getElementById("pic_char_2").style.display = "none";
break;
}
}
return 1;
obj = document.getElementById("datas_link");
}
if(obj){
else if(data_command[4] != undefined)
this.link = JSON.parse(obj.innerHTML.toLowerCase());
{
if(decision_mode == true)
{
name_checked = true;
return -1;
}
}
document.getElementById("txt_name").innerHTML = data_command[4].replace(/(^[^"]+)"([^"]*)"/,"$2");
let user = system.user;
now_txt = data_command[5].replace("{@nickname}",data_nickname);
user.client = document.URL.includes("m.prts.wiki") ? "mobile" : "desktop";
document.getElementById("system_dialog").style.display = "block";
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);
}
}
return 0;
}
}
data.init();
system.disabled.init();
</script>
</script>
</includeonly>
</includeonly>

2024年4月25日 (四) 22:08的最新版本

提示
如果您需要了解这个小部件的更新日志,请查看剧情模拟器更新日志
提示
如果您需要了解这个小部件的更新日志,请查看剧情模拟器更新日志

自动▶
重置▶