“Widget:ScenarioSimulator”的版本间的差异

来自PRTS
跳转至: 导航搜索
 
(未显示2个用户的236个中间版本)
第1行: 第1行:
<noinclude>{{#Widget:Krliov/test2|datas_txt={{用户:Krliov/testpage2}}|pic_back={{用户:Krliov/testpage3}}|pic_char={{用户:Krliov/testpage4}}|datas=
+
<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>
[back]bg_cher_1
+
<includeonly>
[char]char_130_doberm_ex
+
<div id="system_main" style="position:relative;width:800px;height:450px;background-color:#000000;" onclick="txt_system()">
杜宾:可恶……
+
<div class="button_style" id="button_auto" style="right:120px;" onclick="txt_auto()">自动▶</div>
这里,究竟怎么了?
+
<div class="button_style" id="button_reset" style="right:0px;color:#808080;" onclick="txt_reset()">重置▶</div>
[clear_char]
+
<div id="system_blocker">
[back]avg_2_2
+
<div class="pic_style" id="pic_back" style="display:none;" onclick="txt_click(1)"></div>
整合运动成员:这边的屋子,也都给我搜干净!
+
<div class="pic_style" id="pic_image" style="display:none;" onclick="txt_click(2)"></div>
女性:放开他……不!你们……
+
<div id="pic_char_1" style="display:none;" onclick="txt_click(11)">
整合运动成员:反抗?太迟了!可恨的切尔诺伯格人!
+
<div class="char_style" id="pic_char" style="left:0px;"></div>
男性:快跑!不要管我......孩子就......
+
</div>
孩童:妈妈……妈妈……!
+
<div id="pic_char_2" style="display:none;" onclick="txt_click(12)">
}}</noinclude>
+
<div class="char_style" id="pic_char_left" style="left:0px;"></div>
<includeonly><div style="position:relative;width:800px;height:450px;background-color:#000000;" onclick="txt_start()" id="system_main">
+
<div class="char_style" id="pic_char_right" style="left:0px;"></div>
<div class="button_style" id="button_auto" style="right:100px;" onclick="txt_auto()">自动▶</div>
+
</div>
<div class="button_style" id="button_reset" style="right:0px;color:#808080;" onclick="txt_reset()">重置▶</div>
+
<div id="system_cutin" style="display:none;" onclick="txt_click(10)">
<div class="pic_style" id="pic_back" style="display:none;" onclick="txt_click(1)"></div>
+
<div class="cutin_style" id="char_cutin_1" style="left:150px;display:none;"></div>
<div class="pic_style" id="pic_image" style="display:none;" onclick="txt_click(2)"></div>
+
<div class="cutin_style" id="char_cutin_2" style="left:150px;display:none;"></div>
<div class="char_style" id="pic_char_1" style="display:none;" onclick="txt_click(11)">
+
</div>
<div id="pic_char" style="float:left;position:absolute;left:200px;top:25px;"></div></div>
+
</div>
<div class="char_style" id="pic_char_2" style="display:none;" onclick="txt_click(12)">
+
<div id="system_decision" style="display:none;">
<div id="pic_char_left" style="float:left;position:absolute;left:100px;top:25px;"></div>
+
<div class="decision_style" id="decision_1" style="top:120px;display:block;" onclick="txt_decision(0)">...</div>
<div id="pic_char_right" style="float:right;position:absolute;right:100px;top:25px;"></div></div>
+
<div class="decision_style" id="decision_2" style="top:180px;display:block;" onclick="txt_decision(1)">....</div>
<div class="dialog_style" id="dialog_main" style="display:block;" onclick="txt_click()">
+
<div class="decision_style" id="decision_3" style="top:240px;display:block;" onclick="txt_decision(2)">.....</div>
<div style="position:absolute;text-align:right;width:150px;height:60px;padding:5px 10px 0px 10px;color:#929292;font-size:18px;" id="txt_name">剧情模拟器</div>
+
</div>
<div style="float:right;height:60px;width:600px;background-color:rgba(0,0,0,.85);padding:5px 10px 0px 10px;color:white;font-size:15px;" id="txt_output">单击开始剧情回顾</div>
+
<div id="system_dialog" style="display:block;" onclick="txt_click(0)">
</div>
+
<div class="dialog_style" style="left:5px;width:150px;text-align:right;color:#929292;font-size:18px;" id="txt_name">剧情模拟器</div>
</div>
+
<div class="dialog_style" style="right:5px;width:600px;font-size:15px;" id="txt_output">单击开始剧情回顾</div>
 +
</div>
 +
</div>
 +
<audio id="system_music" hidden>
 +
</audio>
 +
<audio id="system_sound" hidden>
 +
</audio>
 
<style>
 
<style>
 
.char_style{
 
.char_style{
z-index:2;
+
z-index:1;
width:400px;
+
position:absolute;
height:400px;
+
width:800px;
background-clip:"padding-box";
+
height:440px;
}
+
background-repeat:no-repeat;
#pic_image{
+
// background-attachment:fixed;
z-index:2;
+
// background-position:top;
 +
// background-size:600px;
 
}
 
}
 
.button_style{
 
.button_style{
z-index:2;
+
z-index:4;
 
position:absolute;
 
position:absolute;
 
float:right;
 
float:right;
第44行: 第51行:
 
width:100px;
 
width:100px;
 
height:20px;
 
height:20px;
font-size:14px;
+
font-size:15px;
 
top:20px;
 
top:20px;
 
padding:0px 5px;
 
padding:0px 5px;
第51行: 第58行:
 
}
 
}
 
.pic_style{
 
.pic_style{
z-index:1;
+
position:absolute;
 
width:800px;
 
width:800px;
 
height:450px;
 
height:450px;
 +
background-position:top;
 +
background-size:800px 450px;
 +
}
 +
#pic_image{
 +
z-index:2;
 
}
 
}
 
.dialog_style{
 
.dialog_style{
z-index:2;
+
z-index:3;
 
position:absolute;
 
position:absolute;
width:790px;
+
height:80px;
right:5px;
 
 
bottom:5px;
 
bottom:5px;
background-color:rgba(0,0,0,.8);
+
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;
 
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>
 
</style>
<script type="csv" id="datas_txt_temp"><!--{$datas_txt}--></script>
+
<script type="csv" id="datas_txt"><!--{$data_txt}--></script>
<script type="csv" id="datas_txt"><!--{$datas}--></script>
+
<script type="csv" id="datas_back"><!--{$data_back}--></script>
<script type="csv" id="datas_back"><!--{$pic_back}--></script>
+
<script type="csv" id="datas_char"><!--{$data_char}--></script>
<script type="csv" id="datas_char"><!--{$pic_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>
 
<script>
 
var txt_max = 0,txt_num = 0,now_txt = "",now_txt_max = 0,now_txt_num = 0,now_txt_temp = "";
 
var txt_max = 0,txt_num = 0,now_txt = "",now_txt_max = 0,now_txt_num = 0,now_txt_temp = "";
var timer_id,flag_timer = false;
+
var timer_id = -1,flag_timer = false;
var timer_id_auto,timer_id_wait,flag_auto = false;
+
var timer_id_auto = -1,flag_auto = false;
 +
var timer_id_wait = -1,timer_id_temp = -1;
 +
var timer_id_blocker = -1,blocker_now = 100,blocker_new = 100;
 +
var timer_id_music = -1,music_stats = "",music_loop = "",music_volume = 0.8,flag_music = false;
 
var reset_enabled = false,auto_enabled = true,click_enabled = true,system_enabled = true;
 
var reset_enabled = false,auto_enabled = true,click_enabled = true,system_enabled = true;
 
var auto_num = 0;
 
var auto_num = 0;
 
var data_temp = "";
 
var data_temp = "";
var data_txt = {};
+
var data_nickname = "<!--{$data_name}-->";
var data_txt_test = {};
+
var decision_value = [1,2,3];
var data_pic_back = {};
+
var decision_mode = false,decision_select = 1,name_checked = false;
var data_pic_char = {};
+
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  
 
try  
 
{
 
{
data_temp = document.getElementById("datas_txt_temp").innerHTML;
 
data_txt_test = data_temp.split("\n");
 
 
data_temp = document.getElementById("datas_txt").innerHTML;
 
data_temp = document.getElementById("datas_txt").innerHTML;
 
data_txt = data_temp.split("\n");
 
data_txt = data_temp.split("\n");
第89行: 第175行:
 
catch(err)
 
catch(err)
 
{
 
{
var data_txt = new Array();
+
console.error("ERROR:The data_txt loaded failed,please check the input and try again.");
console.error("ERROR:The datas 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');
data_txt.push("Krliov:There has something wrong when loaded datas,please check the input. :3");
 
 
auto_enabled = false;
 
auto_enabled = false;
 
click_enabled = false;
 
click_enabled = false;
第103行: 第188行:
 
var [name,path] = num.split(",");
 
var [name,path] = num.split(",");
 
data_pic_back[name] = path;
 
data_pic_back[name] = path;
 +
queue.loadFile(path);
 
}
 
}
 
}
 
}
 
catch(err)
 
catch(err)
 
{
 
{
var data_txt = new Array();
+
console.error("ERROR:The data_back loaded failed,please check the input and try again.");
console.error("ERROR:The pic_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');
data_txt.push("Krliov:There has something wrong when loaded pic_back,please check the input. :3");
 
 
auto_enabled = false;
 
auto_enabled = false;
 
click_enabled = false;
 
click_enabled = false;
第121行: 第206行:
 
var [name,path] = num.split(",");
 
var [name,path] = num.split(",");
 
data_pic_char[name] = path;
 
data_pic_char[name] = path;
 +
queue.loadFile(path);
 +
}
 +
}
 +
catch(err)
 +
{
 +
console.error("ERROR:The data_char loaded failed,please check the input and try again.");
 +
data_txt.push('[name="Krliov"]  There has something wrong when loaded data_char,please check the input. :3');
 +
auto_enabled = false;
 +
click_enabled = false;
 +
system_enabled = false;
 +
}
 +
try
 +
{
 +
data_temp = document.getElementById("datas_audio").innerHTML;
 +
for (var num of data_temp.split("\n"))
 +
{
 +
var [name,path] = num.split(",");
 +
data_audio[name] = path;
 +
queue.loadFile(path);
 
}
 
}
 
}
 
}
 
catch(err)
 
catch(err)
 
{
 
{
var data_txt = new Array();
+
console.error("ERROR:The data_audio loaded failed,please check the input and try again.");
console.error("ERROR:The pic_char 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');
data_txt.push("Krliov:There has something wrong when loaded pic_char,please check the input. :3");
 
 
auto_enabled = false;
 
auto_enabled = false;
 
click_enabled = false;
 
click_enabled = false;
 
system_enabled = false;
 
system_enabled = false;
 
}
 
}
 +
data_temp = document.getElementById("datas_link").innerHTML.toLowerCase();
 +
data_link = JSON.parse(data_temp);
 
console.log(data_txt);
 
console.log(data_txt);
console.log(data_txt_test);
 
 
console.log(data_pic_back);
 
console.log(data_pic_back);
 
console.log(data_pic_char);
 
console.log(data_pic_char);
function txt_start()
+
console.log(data_audio);
 +
console.log(data_link);
 +
function txt_system()
 
{
 
{
if (system_enabled == false)
+
if (system_enabled == false || document.getElementById("pic_back").style.display == "block")
 
{
 
{
console.log("system didn't passed.");
+
if(mw.config.values.debug==true){console.log("system didn't passed.");}
 
return;
 
return;
 
}
 
}
console.log("system passed.");
+
if(mw.config.values.debug==true){console.log("system passed.");}
 
txt_click(-1);
 
txt_click(-1);
 
}
 
}
 
function txt_click(enter_id)
 
function txt_click(enter_id)
 
{
 
{
if(click_enabled == false && enter_id == undefined)
+
if(timer_id_temp == -1)
 
{
 
{
console.log("Has disregard the default settings.");
+
timer_id_temp = setTimeout("fun_delay('system')",100);
 
}
 
}
else if(click_enabled == false)
+
system_enabled = false;
 +
if(click_enabled == false)
 
{
 
{
 +
if(mw.config.values.debug==true){console.log("click didn't passed.");}
 
return;
 
return;
 
}
 
}
else if(system_enabled == true)
+
if(mw.config.values.debug==true)
 +
{
 +
console.log("click passed.");
 +
console.log("enter_id=" + enter_id);
 +
}
 +
if(txt_num == 0)
 +
{
 +
fun_setting("pre");
 +
}
 +
if(reset_enabled == false)
 
{
 
{
if (mw.config.values.debug == true)
 
{
 
txt_max = data_txt_test.length;
 
}
 
else
 
{
 
txt_max = data_txt.length;
 
}
 
console.log("txt_max=" + txt_max);
 
system_enabled = false;
 
 
reset_enabled = true;
 
reset_enabled = true;
 
document.getElementById("button_reset").style.color = "";
 
document.getElementById("button_reset").style.color = "";
 
}
 
}
console.log("enter_id=" + enter_id);
 
 
if(flag_auto == true)
 
if(flag_auto == true)
 
{
 
{
第178行: 第284行:
 
if(flag_timer == true)
 
if(flag_timer == true)
 
{
 
{
// console.log("The timer has been stopped force.");
+
txt_stop("f");
txt_stop();
 
 
document.getElementById("txt_output").innerHTML = now_txt;
 
document.getElementById("txt_output").innerHTML = now_txt;
 
return;
 
return;
 
}
 
}
 
txt_next();
 
txt_next();
 +
return;
 
}
 
}
 
function txt_next()
 
function txt_next()
第189行: 第295行:
 
var place = -1;
 
var place = -1;
 
//before
 
//before
 +
fun_timer_clear("wait");
 
if (txt_num == txt_max)
 
if (txt_num == txt_max)
 
{
 
{
console.log("txt_num=" + txt_num + " ,txt_max=" + txt_max)
+
if(mw.config.values.debug==true){console.log("txt_num=" + txt_num + " ,txt_max=" + txt_max);}
 
if(flag_auto == true)
 
if(flag_auto == true)
 
{
 
{
 
auto_stop();
 
auto_stop();
 +
}
 +
if(flag_music == true)
 +
{
 +
music_stop();
 
}
 
}
 
document.getElementById("pic_back").style.display = "none";
 
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_1").style.display = "none";
 
document.getElementById("pic_char_2").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_name").innerHTML = "剧情模拟器";
 
document.getElementById("txt_output").innerHTML = "剧情模拟已结束,单击将重新开始剧情回顾";
 
document.getElementById("txt_output").innerHTML = "剧情模拟已结束,单击将重新开始剧情回顾";
document.getElementById("dialog_main").style.display = "block";
+
document.getElementById("system_dialog").style.display = "block";
system_enabled = true;
+
if(timer_id_temp == -1)
 +
{
 +
timer_id_temp = setTimeout("fun_delay('system')",100);
 +
}
 
reset_enabled = false;
 
reset_enabled = false;
 
document.getElementById("button_reset").style.color = "#808080";
 
document.getElementById("button_reset").style.color = "#808080";
第213行: 第331行:
 
if (mw.config.values.debug == true)
 
if (mw.config.values.debug == true)
 
{
 
{
if (data_txt_test[txt_num] == "")
+
if (data_txt[txt_num] == "")
 
{
 
{
ret = -3;
+
ret = -2;
 +
if(decision_mode == true && name_checked == true)
 +
{
 +
decision_mode = false;
 +
}
 
}
 
}
 
else
 
else
第226行: 第348行:
 
if (data_txt[txt_num] == "")
 
if (data_txt[txt_num] == "")
 
{
 
{
ret = -3;
+
ret = -2;
 +
if(decision_mode == true && name_checked == true)
 +
{
 +
decision_mode = false;
 +
}
 
}
 
}
 
else
 
else
第233行: 第359行:
 
}
 
}
 
}
 
}
if(ret == -3)
+
if(ret == -2)
 
{
 
{
console.log("Has skipped the space part.Data number:" + txt_num);
+
if(mw.config.values.debug==true){console.log("Has skipped the space part.Data number:" + txt_num);}
 
txt_num++;
 
txt_num++;
 
txt_next();
 
txt_next();
 
return;
 
return;
 
}
 
}
else if(ret == -2)
+
else if(ret == -1)
 
{
 
{
console.log("Break and wait timer.");
+
if(mw.config.values.debug==true){console.log("Has skipped the unused part.Data number:" + txt_num);}
 
txt_num++;
 
txt_num++;
 +
txt_next();
 
return;
 
return;
 
}
 
}
else if(ret == -1)
+
else if(ret == 1)
 
{
 
{
console.log("Has skipped the unused part.Data number:" + txt_num);
+
if(mw.config.values.debug==true){console.log("Data analyze complete.Data number:" + txt_num);}
 
txt_num++;
 
txt_num++;
 
txt_next();
 
txt_next();
 
return;
 
return;
 
}
 
}
else if(ret == 1)
+
else if(ret == 2)
 
{
 
{
console.log("Data analyze complete.Data number:" + txt_num);
+
if(mw.config.values.debug==true){console.log("Break and wait.");}
 
txt_num++;
 
txt_num++;
txt_next();
 
 
return;
 
return;
 
}
 
}
console.log("Data number:" + txt_num);
+
if(mw.config.values.debug==true){console.log("Data number:" + txt_num);}
 
if(txt_num < txt_max && txt_num >= 0)
 
if(txt_num < txt_max && txt_num >= 0)
 
{
 
{
txt_dynamic(50);
+
txt_dynamic();
 
}
 
}
 
}
 
}
 
function txt_check()
 
function txt_check()
 
{
 
{
var place = 0,temp = "";
+
if(data_txt[txt_num].match("^\\s+$")) //ONLY SPACE REGEX
if(data_txt[txt_num].indexOf(":") > 0)
 
 
{
 
{
place = data_txt[txt_num].indexOf(":");
+
return -1;
document.getElementById("txt_name").innerHTML = data_txt[txt_num].substr(0,place);
 
now_txt = data_txt[txt_num].substr(place + 1);
 
console.log("now_txt=" +  now_txt);
 
return 0;
 
 
}
 
}
if(data_txt[txt_num].startsWith("[clear]"))
+
else if(data_txt[txt_num].match("^\\s*//.*$")) //COMMENT REGEX
 
{
 
{
document.getElementById("pic_back").style.display = "none";
+
return -1;
document.getElementById("pic_char_1").style.display = "none";
 
document.getElementById("pic_char_2").style.display = "none";
 
return 1;
 
 
}
 
}
else if(data_txt[txt_num].startsWith("[clear_back]"))
+
var data_command = data_txt[txt_num].match("^\\[\\s*(?:(.*)\\((.*)\\)|(?:([\\.|\\w]*)|(.*)))\\s*\\]\\s*(.*)"); //COMMAND REGEX
 +
if (data_command == null)
 
{
 
{
document.getElementById("pic_back").style.display = "none";
+
document.getElementById("txt_name").innerHTML = "";
return 1;
+
now_txt = data_txt[txt_num];
 +
document.getElementById("system_dialog").style.display = "block";
 +
return 0;
 
}
 
}
else if(data_txt[txt_num].startsWith("[clear_char]"))
+
if (data_command[1] != undefined)
 
{
 
{
document.getElementById("pic_char_1").style.display = "none";
+
var command_set = {};
document.getElementById("pic_char_2").style.display = "none";
+
data_command[2] = data_command[2].toLowerCase();
 +
data_command[2] = data_command[2].replace(/\s+|["'\$]|(m_dia_)|(m_sys_)|(m_bat_)/g,"");
 +
for (num of data_command[2].split(","))
 +
{
 +
var [type,value] = num.split("=");
 +
command_set[type] = value;
 +
}
 +
switch (data_command[1].toLowerCase())
 +
{
 +
case 'header':
 +
return -1;
 +
case 'playmusic':
 +
var obj_music = document.getElementById("system_music");
 +
var times=0;
 +
if(command_set.intro == undefined)
 +
{
 +
console.error("Command Analyze error:Music intro is not exist.");
 +
return -1;
 +
}
 +
if(data_audio[command_set.intro] == undefined)
 +
{
 +
console.warn("Audio Data:" + command_set.intro + " is not exist,please check the data list.");
 +
}
 +
obj_music.src = data_audio[command_set.intro];
 +
if(command_set.key == undefined)
 +
{
 +
console.warn("Music key is no exist,has use the intro to instead.");
 +
music_loop = data_audio[command_set.intro];
 +
}
 +
else
 +
{
 +
music_loop = data_audio[command_set.key];
 +
}
 +
obj_music.load();
 +
if(command_set.volume != undefined)
 +
{
 +
obj_music.volume = command_set.volume;
 +
}
 +
if (command_set.delay != undefined)
 +
{
 +
times = command_set.delay * 1000;
 +
}
 +
obj_music.loop = false;
 +
music_stats = "intro";
 +
setTimeout("fun_delay('music')",times);
 +
flag_music = true;
 +
return 1;
 +
case 'playsound':
 +
return -1;
 +
case 'stopmusic':
 +
music_stop();
 +
return 1;
 +
case 'delay':
 +
if (command_set.time == undefined)
 +
{
 +
return -1;
 +
}
 +
if(timer_id_wait == -1)
 +
{
 +
fun_setting("cmd_close");
 +
timer_id_wait = setTimeout("fun_delay('delay')",command_set.time*1000);
 +
}
 +
return 2;
 +
case 'blocker':
 +
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;
 +
if(temp_d1 > 100)
 +
{
 +
temp_d1 = 100;
 +
}
 +
if(isNaN(temp_d2) == true)
 +
{
 +
console.warn("fadetime isn't a number,use the default setting to instead.");
 +
temp_d2 = 1;
 +
}
 +
temp_d2 *= 20;
 +
blocker_new = temp_d1;
 +
temp_c1 = (blocker_new - blocker_now) / temp_d2;
 +
if(timer_id_blocker == -1)
 +
{
 +
fun_setting("cmd_close");
 +
timer_id_blocker = setInterval("blocker_dynamic(" + temp_c1 +")",50);
 +
}
 +
return 2;
 +
case 'decision':
 +
if(command_set.options == undefined)
 +
{
 +
return -1;
 +
}
 +
var data_decision = command_set.options.split(";");
 +
var temp_c1 = command_set.values.split(";");
 +
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 = "";
 +
obj_2.style.fontSize = "";
 +
obj_3.style.fontSize = "";
 +
decision_value = [-1,-1,-1];
 +
switch (data_decision.length)
 +
{
 +
case 1:
 +
decision_value[1] = temp_c1[0];
 +
if(data_decision[0].length > 12)
 +
{
 +
obj_2.style.fontSize = "10px";
 +
}
 +
obj_1.style.display = "none";
 +
obj_2.innerHTML = data_decision[0];
 +
obj_2.style.display = "block";
 +
obj_3.style.display = "none";
 +
break;
 +
case 2:
 +
decision_value[0] = temp_c1[0];
 +
decision_value[2] = temp_c1[1];
 +
if(data_decision[0].length > 12)
 +
{
 +
obj_1.style.fontSize = "10px";
 +
}
 +
if(data_decision[1].length > 12)
 +
{
 +
obj_3.style.fontSize = "10px";
 +
}
 +
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;
 +
case 3:
 +
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";
 +
}
 +
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;
 +
default:
 +
console.error("decision data error.");
 +
return -1;
 +
}
 +
if(flag_auto == true)
 +
{
 +
fun_timer_clear("auto");
 +
}
 +
fun_setting("cmd_close");
 +
document.getElementById("system_decision").style.display = "block";
 +
return 2;
 +
case 'predicate':
 +
if (command_set.references == undefined)
 +
{
 +
return -1;
 +
}
 +
if (command_set.references.includes(decision_select) == true)
 +
{
 +
decision_mode = false;
 +
break;
 +
}
 +
name_checked = false;
 +
decision_mode = true;
 +
break;
 +
case 'background':
 +
var obj_back = document.getElementById("pic_back");
 +
if(command_set.image == undefined)
 +
{
 +
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);
 +
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;
 +
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;
 
return 1;
 
}
 
}
else if(data_txt[txt_num].startsWith("[back]"))
+
else if(data_command[3] != undefined)
 
{
 
{
place = data_txt[txt_num].indexOf("]") + 1;
+
switch(data_command[3].toLowerCase())
temp = data_txt[txt_num].substr(place);
+
{
document.getElementById("pic_back").innerHTML = "<img alt=\"" + temp + "\" width=\"800\" height=\"450\" src=\"" + data_pic_back[temp] + "\">";
+
case 'dialog':
document.getElementById("pic_back").style.display = "block";
+
document.getElementById("txt_name").innerHTML = "";
 +
document.getElementById("txt_output").innerHTML = "";
 +
document.getElementById("system_dialog").style.display = "none";
 +
break;
 +
case 'background':
 +
document.getElementById("pic_back").style.display = "none";
 +
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;
 
return 1;
 
}
 
}
else if(data_txt[txt_num].startsWith("[char]"))
+
else if(data_command[4] != undefined)
{
 
place = data_txt[txt_num].indexOf("]") + 1;
 
temp = data_txt[txt_num].substr(place);
 
document.getElementById("pic_char").innerHTML = "<img alt=\"" + temp + "\" width=\"400\" height=\"400\" src=\"" + data_pic_char[temp] + "\">";
 
document.getElementById("pic_char_1").style.display = "block";
 
document.getElementById("pic_char_2").style.display = "none";
 
return 1;
 
}
 
else if(data_txt[txt_num].startsWith("[char_"))
 
 
{
 
{
var pic_left = "",pic_right = "";
+
if(decision_mode == true)
var char_left = document.getElementById("pic_char_left");
 
var char_right = document.getElementById("pic_char_right");
 
place = data_txt[txt_num].indexOf("]") + 1;
 
temp = data_txt[txt_num].substr(place);
 
temp = temp.split(",");
 
if(temp.length <= 1)
 
 
{
 
{
console.error("Command analyze failed.");
+
name_checked = true;
 
return -1;
 
return -1;
 
}
 
}
pic_left=temp[0];
+
document.getElementById("txt_name").innerHTML = data_command[4].replace(/(^[^"]+)"([^"]*)"/,"$2");
pic_right=temp[1];
+
now_txt = data_command[5].replace("{@nickname}",data_nickname);
char_left.innerHTML = "<img alt=\"" + pic_left + "\" width=\"400\" height=\"400\" src=\"" + data_pic_char[pic_left] + "\">";
+
document.getElementById("system_dialog").style.display = "block";
char_right.innerHTML = "<img alt=\"" + pic_right + "\" width=\"400\" height=\"400\" src=\"" + data_pic_char[pic_right] + "\">";
 
if (data_txt[txt_num].startsWith("[char_left]"))
 
{
 
char_left.style.display = "block";
 
char_right.style.display = "none";
 
}
 
else if (data_txt[txt_num].startsWith("[char_right]"))
 
{
 
char_right.style.display = "block";
 
char_left.style.display = "none";
 
}
 
else if (data_txt[txt_num].startsWith("[char_both]"))
 
{
 
char_left.style.display = "block";
 
char_right.style.display = "block";
 
}
 
document.getElementById("pic_char_1").style.display = "block";
 
document.getElementById("pic_char_2").style.display = "block";
 
return 1;
 
 
}
 
}
now_txt = data_txt[txt_num];
 
 
return 0;
 
return 0;
 
}
 
}
 
function txt_auto()
 
function txt_auto()
 
{
 
{
 +
if(timer_id_temp == -1)
 +
{
 +
timer_id_temp = setTimeout("fun_delay('system')",100);
 +
}
 +
system_enabled = false;
 
if(auto_enabled == false)
 
if(auto_enabled == false)
 
{
 
{
console.log("auto didn't passed.");
+
if(mw.config.values.debug==true){console.log("auto didn't passed.");}
 
return;
 
return;
 
}
 
}
console.log("auto passed.");
+
if(mw.config.values.debug==true){console.log("auto passed.");}
reset_enabled = true;
+
if(reset_enabled == false)
document.getElementById("button_reset").style.color = "";
+
{
 +
reset_enabled = true;
 +
document.getElementById("button_reset").style.color = "";
 +
}
 
if(flag_auto == false)
 
if(flag_auto == false)
 
{
 
{
if(system_enabled == true)
+
flag_auto = true;
 +
if(txt_num == 0)
 
{  
 
{  
if(mw.config.values.debug == true)
+
fun_setting("pre");
{
+
}
txt_max = data_txt_test.length;
+
if(timer_id_auto == -1)
}
+
{
else
+
auto_num = 1;
{
+
timer_id_auto = setInterval("auto_dynamic()",400);
txt_max = data_txt.length;
+
}
}
+
if(timer_id_wait == -1)
console.log("txt_max=" + txt_max);
+
{
system_enabled = false;
+
timer_id_wait = setTimeout("txt_next()",now_txt_max*80+Math.min(txt_num,1)*1000);
 
}
 
}
auto_num = 1;
 
timer_id_auto = setInterval("auto_dynamic()",400);
 
flag_auto = true;
 
timer_id_wait = setTimeout("txt_next()",now_txt_max*80+Math.min(now_txt_max,1)*1000);
 
 
}
 
}
 
else if(flag_auto == true)
 
else if(flag_auto == true)
第388行: 第842行:
 
function txt_reset()
 
function txt_reset()
 
{
 
{
 +
if(timer_id_temp == -1)
 +
{
 +
timer_id_temp = setTimeout("fun_delay('system')",100);
 +
}
 +
system_enabled = false;
 
if(reset_enabled == false)
 
if(reset_enabled == false)
 
{
 
{
console.log("reset didn't passed.");
+
if(mw.config.values.debug==true){console.log("reset didn't passed.");}
 
return;
 
return;
 
}
 
}
system_enabled = false;
+
if(mw.config.values.debug==true){console.log("reset passed.");}
console.log("reset passed.");
 
 
if(flag_auto == true)
 
if(flag_auto == true)
 
{
 
{
第403行: 第861行:
 
txt_stop();
 
txt_stop();
 
}
 
}
 +
if(flag_music == true)
 +
{
 +
music_stop();
 +
}
 +
fun_timer_clear("wait");
 +
fun_timer_clear("blocker");
 
document.getElementById("pic_back").style.display = "none";
 
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_1").style.display = "none";
 
document.getElementById("pic_char_2").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_name").innerHTML = "剧情模拟器";
 
document.getElementById("txt_output").innerHTML = "剧情模拟已重置,单击开始剧情回顾";
 
document.getElementById("txt_output").innerHTML = "剧情模拟已重置,单击开始剧情回顾";
document.getElementById("dialog_main").style.display = "block";
+
document.getElementById("system_dialog").style.display = "block";
 +
fun_setting("cmd_open");
 
reset_enabled = false;
 
reset_enabled = false;
system_enabled = true;
 
 
document.getElementById("button_reset").style.color = "#808080"
 
document.getElementById("button_reset").style.color = "#808080"
 
txt_num = 0;
 
txt_num = 0;
 
now_txt_max = 0;
 
now_txt_max = 0;
 
return;
 
return;
 +
}
 +
function txt_decision(choice)
 +
{
 +
if(timer_id_temp == -1)
 +
{
 +
timer_id_temp = setTimeout("fun_delay('system')",100);
 +
}
 +
system_enabled = false;
 +
decision_select = decision_value[choice];
 +
fun_setting("cmd_open");
 +
document.getElementById("system_decision").style.display = "none";
 +
if(flag_auto == true && timer_id_auto == -1)
 +
{
 +
timer_id_auto = setInterval("auto_dynamic()",400);
 +
}
 +
txt_next();
 
}
 
}
 
function auto_stop()
 
function auto_stop()
 
{
 
{
clearInterval(timer_id_auto);
+
fun_timer_clear("auto");
 +
fun_timer_clear("wait");
 
document.getElementById("button_auto").innerHTML = "自动▶";
 
document.getElementById("button_auto").innerHTML = "自动▶";
if(flag_timer == false && flag_auto == true)
 
{
 
clearTimeout(timer_id_wait);
 
}
 
 
flag_auto = false;
 
flag_auto = false;
 
}
 
}
function txt_stop()
+
function txt_stop(stop_type)
 
{
 
{
clearInterval(timer_id);
+
if(mw.config.values.debug==true)
flag_timer = false;
+
{
 +
if(stop_type == "n")
 +
{
 +
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)
 +
{
 +
timer_id_wait = setTimeout("txt_next()",now_txt_max*80+Math.min(txt_num,1)*1000);
 +
}
 +
fun_timer_clear("id");
 
now_txt_num = 0;
 
now_txt_num = 0;
now_txt = "";
 
 
now_txt_temp = "";
 
now_txt_temp = "";
 
txt_num++;
 
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");
 +
fun_timer_clear("music");
 +
obj_music_1.pause();
 +
obj_music_1.currentTime = 0;
 +
obj_music_1.loop = false;
 +
obj_music_1.src = "";
 +
flag_music = false;
 
}
 
}
 
function auto_dynamic()
 
function auto_dynamic()
第453行: 第974行:
 
auto_num++;
 
auto_num++;
 
}
 
}
function txt_dynamic(interval)
+
function txt_dynamic()
 
{
 
{
 +
var interval = 50;
 +
if(mw.config.values.debug == true)
 +
{
 +
interval = txt_interval;
 +
}
 
now_txt_max = now_txt.length;
 
now_txt_max = now_txt.length;
flag_timer = true;
+
if(timer_id == -1)
timer_id = setInterval("timer1()",50);
+
{
 +
flag_timer = true;
 +
timer_id = setInterval("timer1()",interval);
 +
}
 +
}
 +
function blocker_dynamic(temp_c)
 +
{
 +
blocker_now = blocker_now + temp_c;
 +
document.getElementById("system_blocker").style.filter = "brightness(" + blocker_now + "%)";
 +
if(blocker_now < blocker_new && temp_c > 0)
 +
{
 +
return;
 +
}
 +
else if(blocker_now > blocker_new && temp_c < 0)
 +
{
 +
return;
 +
}
 +
blocker_now = blocker_new;
 +
fun_timer_clear("blocker");
 +
fun_setting("cmd_open");
 +
document.getElementById("system_blocker").style.filter = "brightness(" + blocker_now + "%)";
 +
txt_next();
 
}
 
}
 
function timer1()
 
function timer1()
第468行: 第1,015行:
 
return;
 
return;
 
}
 
}
// console.log("The timer has been stopped naturally.");
+
txt_stop("n");
txt_stop();
+
}
if(flag_auto == true)
+
function timer2()
 +
{
 +
var obj_music = document.getElementById("system_music");
 +
if(obj_music.ended == false)
 +
{
 +
return;
 +
}
 +
flag_music = false;
 +
if(music_stats == "intro")
 +
{
 +
music_stats = "loop";
 +
obj_music.currentTime = 0;
 +
obj_music.loop = true;
 +
obj_music.src = music_loop;
 +
obj_music.play();
 +
fun_timer_clear("music");
 +
flag_music = true;
 +
}
 +
}
 +
function fun_setting(mode)
 +
{
 +
if(mode == "pre")
 +
{
 +
if (mw.config.values.debug == true)
 +
{
 +
txt_max = data_txt.length;
 +
console.log("txt_max=" + txt_max);
 +
}
 +
else if(txt_max == 0)
 +
{
 +
txt_max = data_txt.length;
 +
}
 +
reset_enabled = true;
 +
document.getElementById("txt_name").innerHTML = "";
 +
document.getElementById("txt_output").innerHTML = "";
 +
document.getElementById("system_dialog").style.display = "none";
 +
document.getElementById("button_reset").style.color = "";
 +
}
 +
else if(mode == "cmd_close")
 +
{
 +
click_enabled = false;
 +
auto_enabled = false;
 +
}
 +
else if(mode == "cmd_open")
 +
{
 +
click_enabled = true;
 +
auto_enabled = true;
 +
}
 +
 +
}
 +
function fun_delay(key_cmd)
 +
{
 +
if(key_cmd == "system")
 +
{
 +
fun_timer_clear("temp");
 +
if(mw.config.values.debug==true)
 +
{
 +
console.log("system_enabeld has been set to true.");
 +
}
 +
system_enabled = true;
 +
}
 +
else if(key_cmd == "music")
 +
{
 +
document.getElementById("system_music").play();
 +
if(timer_id_music == -1)
 +
{
 +
timer_id_music = setInterval("timer2()",100);
 +
}
 +
}
 +
else if(key_cmd == "sound")
 +
{
 +
document.getElementById("system_sound").play();
 +
}
 +
else if(key_cmd == "delay")
 +
{
 +
fun_timer_clear("wait");
 +
fun_setting("cmd_open");
 +
txt_next();
 +
}
 +
else if(key_cmd == "cutin_1")
 +
{
 +
document.getElementById("char_cutin_1").style.display = "none";
 +
fun_animation_clear("char_cutin_1");
 +
fun_setting("cmd_open");
 +
txt_next();
 +
}
 +
else if(key_cmd == "cutin_2")
 +
{
 +
document.getElementById("char_cutin_2").style.display = "none";
 +
fun_animation_clear("char_cutin_2");
 +
fun_setting("cmd_open");
 +
txt_next();
 +
}
 +
}
 +
function fun_timer_clear(key_id)
 +
{
 +
if(key_id == "id" && timer_id != -1)
 +
{
 +
clearInterval(timer_id);
 +
timer_id = -1;
 +
}
 +
else if(key_id == "temp" && timer_id_temp != -1)
 +
{
 +
clearTimeout(timer_id_temp);
 +
timer_id_temp = -1;
 +
}
 +
else if(key_id == "auto" && timer_id_auto != -1)
 +
{
 +
clearInterval(timer_id_auto);
 +
timer_id_auto = -1;
 +
}
 +
else if(key_id == "wait" && timer_id_wait != -1)
 +
{
 +
clearTimeout(timer_id_wait);
 +
timer_id_wait = -1;
 +
}
 +
else if(key_id == "music" && timer_id_music != -1)
 +
{
 +
clearTimeout(timer_id_music);
 +
timer_id_music = -1;
 +
}
 +
else if(key_id == "blocker" && timer_id_blocker != -1)
 +
{
 +
clearInterval(timer_id_blocker);
 +
timer_id_blocker = -1;
 +
}
 +
}
 +
function fun_animation_clear(obj_id)
 +
{
 +
document.getElementById(obj_id).style.animation = "";
 +
}
 +
function fun_char_link(temp_data)
 +
{
 +
var place,temp_d1,temp_d2;
 +
place = temp_data.lastIndexOf("#");
 +
if(place > 0)
 +
{
 +
temp_d1 = temp_data.substr(0,place);
 +
temp_d2 = temp_data.substr(place + 1);
 +
if(mw.config.values.debug == true){console.log("temp_d1=" + temp_d1 + ",temp_d2=" + temp_d2);}
 +
try{
 +
temp_d2--;
 +
}
 +
catch(err){
 +
if(mw.config.values.debug == true){console.error("Data analyze error,use the default char to instead");}
 +
temp_d2 = 0;
 +
}
 +
return [temp_d1,temp_d2];
 +
}
 +
place = temp_data.lastIndexOf("@");
 +
if(place > 0)
 
{
 
{
timer_id_wait = setTimeout("txt_next()",now_txt_max*80+1000)
+
temp_d1 = temp_data.substr(0,place);
 +
temp_d2 = temp_data.substr(place1 + 1);
 +
if(mw.config.values.debug == true){console.log("temp_d1=" + temp_d1 + ",temp_d2=" + temp_d2);}
 +
for(place = 0;place<data_link[temp_d1].length;place++)
 +
{
 +
if(data_link[temp_d1][place].name == temp_d2)
 +
{
 +
return [temp_d1,place];
 +
}
 +
}
 +
if(place == data_link[temp_d1].length)
 +
{
 +
if(mw.config.values.debug == true){console.error("Data analyze error,use the default char to instead");}
 +
}
 
}
 
}
 +
return [temp_data,0];
 
}
 
}
 
function txt_check_test()
 
function txt_check_test()
 
{
 
{
if(data_txt_test[txt_num].match("^\\s+$")) //ONLY SPACE REGEX
+
if(data_txt[txt_num].match("^\\s+$")) //ONLY SPACE REGEX
 
{
 
{
 
return -1;
 
return -1;
 
}
 
}
else if(data_txt_test[txt_num].match("^\\s*//.*$")) //COMMENT REGEX
+
else if(data_txt[txt_num].match("^\\s*//.*$")) //COMMENT REGEX
 
{
 
{
 
return -1;
 
return -1;
 
}
 
}
var data_command = data_txt_test[txt_num].match("^\\[\\s*(?:(.*)\\((.*)\\)|(?:([\\.|\\w]*)|(.*)))\\s*\\]\\s*(.*)"); //COMMAND REGEX
+
var data_command = data_txt[txt_num].match("^\\[\\s*(?:(.*)\\((.*)\\)|(?:([\\.|\\w]*)|(.*)))\\s*\\]\\s*(.*)"); //COMMAND REGEX
 
console.log(data_command);
 
console.log(data_command);
 +
if (data_command == null)
 +
{
 +
document.getElementById("txt_name").innerHTML = "";
 +
now_txt = data_txt[txt_num];
 +
document.getElementById("system_dialog").style.display = "block";
 +
return 0;
 +
}
 
if (data_command[1] != undefined)
 
if (data_command[1] != undefined)
 
{
 
{
 
var command_set = {};
 
var command_set = {};
data_command[2] = data_command[2].replace(/\s+|["$]|#[^\,]+/g,"");
+
data_command[2] = data_command[2].toLowerCase();
 +
data_command[2] = data_command[2].replace(/\s+|["'\$]|(m_dia_)|(m_sys_)|(m_bat_)/g,"");
 +
console.log(data_command[2]);
 
for (num of data_command[2].split(","))
 
for (num of data_command[2].split(","))
 
{
 
{
第496行: 第1,216行:
 
command_set[type] = value;
 
command_set[type] = value;
 
}
 
}
switch (data_command[1])
+
console.log(command_set);
 +
switch (data_command[1].toLowerCase())
 
{
 
{
case 'HEADER':
+
case 'header':
 
return -1;
 
return -1;
break;
+
case 'playmusic':
case 'PlayMusic':
+
var obj_music = document.getElementById("system_music");
return -1;
+
var times=0;
break;
+
if(command_set.intro == undefined)
case 'StopMusic':
+
{
 +
console.error("Command Analyze error:Music intro is not exist.");
 +
return -1;
 +
}
 +
if(data_audio[command_set.intro] == undefined)
 +
{
 +
console.warn("Audio Data:" + command_set.intro + " is not exist,please check the data list.");
 +
}
 +
obj_music.src = data_audio[command_set.intro];
 +
if(command_set.key == undefined)
 +
{
 +
console.warn("Music key is no exist,has use the intro to instead.");
 +
music_loop = data_audio[command_set.intro];
 +
}
 +
else
 +
{
 +
music_loop = data_audio[command_set.key];
 +
}
 +
obj_music.load();
 +
if(command_set.volume != undefined)
 +
{
 +
obj_music.volume = command_set.volume;
 +
}
 +
if (command_set.delay != undefined)
 +
{
 +
times = command_set.delay * 1000;
 +
}
 +
obj_music.loop = false;
 +
music_stats = "intro";
 +
setTimeout("fun_delay('music')",times);
 +
flag_music = true;
 +
return 1;
 +
case 'playsound':
 
return -1;
 
return -1;
break;
+
case 'stopmusic':
case 'Delay':
+
music_stop();
 +
return 1;
 +
case 'delay':
 
if (command_set.time == undefined)
 
if (command_set.time == undefined)
 
{
 
{
 
return -1;
 
return -1;
 
}
 
}
setTimeout("txt_next()",command_set.time*1000);
+
if(timer_id_wait == -1)
return -2;
+
{
break;
+
fun_setting("cmd_close");
case 'Blocker':
+
timer_id_wait = setTimeout("fun_delay('delay')",command_set.time*1000);
return -1;
+
}
break;
+
return 2;
case 'Decision':
+
case 'blocker':
return -1;
+
var temp_d1,temp_d2,temp_c1;
break;
+
temp_d1 = Number(command_set.a);
case 'Predicate':
+
temp_d2 = Number(command_set.fadetime);
return -1;
+
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;
 +
if(temp_d1 > 100)
 +
{
 +
temp_d1 = 100;
 +
}
 +
if(isNaN(temp_d2) == true)
 +
{
 +
console.warn("fadetime isn't a number,use the default setting to instead.");
 +
temp_d2 = 1;
 +
}
 +
temp_d2 *= 20;
 +
blocker_new = temp_d1;
 +
temp_c1 = (blocker_new - blocker_now) / temp_d2;
 +
if(timer_id_blocker == -1)
 +
{
 +
fun_setting("cmd_close");
 +
timer_id_blocker = setInterval("blocker_dynamic(" + temp_c1 +")",50);
 +
}
 +
return 2;
 +
case 'decision':
 +
if(command_set.options == undefined)
 +
{
 +
return -1;
 +
}
 +
var data_decision = command_set.options.split(";");
 +
var temp_c1 = command_set.values.split(";");
 +
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 = "";
 +
obj_2.style.fontSize = "";
 +
obj_3.style.fontSize = "";
 +
decision_value = [-1,-1,-1];
 +
switch (data_decision.length)
 +
{
 +
case 1:
 +
decision_value[1] = temp_c1[0];
 +
if(data_decision[0].length > 12)
 +
{
 +
obj_2.style.fontSize = "10px";
 +
}
 +
obj_1.style.display = "none";
 +
obj_2.innerHTML = data_decision[0];
 +
obj_2.style.display = "block";
 +
obj_3.style.display = "none";
 +
break;
 +
case 2:
 +
decision_value[0] = temp_c1[0];
 +
decision_value[2] = temp_c1[1];
 +
if(data_decision[0].length > 12)
 +
{
 +
obj_1.style.fontSize = "10px";
 +
}
 +
if(data_decision[1].length > 12)
 +
{
 +
obj_3.style.fontSize = "10px";
 +
}
 +
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;
 +
case 3:
 +
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";
 +
}
 +
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;
 +
default:
 +
console.error("decision data error.");
 +
return -1;
 +
}
 +
if(flag_auto == true)
 +
{
 +
fun_timer_clear("auto");
 +
}
 +
fun_setting("cmd_close");
 +
document.getElementById("system_decision").style.display = "block";
 +
return 2;
 +
case 'predicate':
 +
if (command_set.references == undefined)
 +
{
 +
return -1;
 +
}
 +
if (command_set.references.includes(decision_select) == true)
 +
{
 +
decision_mode = false;
 +
break;
 +
}
 +
name_checked = false;
 +
decision_mode = true;
 
break;
 
break;
case 'Background':
+
case 'background':
 
var obj_back = document.getElementById("pic_back");
 
var obj_back = document.getElementById("pic_back");
 
if(command_set.image == undefined)
 
if(command_set.image == undefined)
第531行: 第1,400行:
 
break;
 
break;
 
}
 
}
obj_back.innerHTML = "<img alt=\"" + command_set.image + "\" width=\"800\" height=\"450\" src=\"" + data_pic_back[command_set.image] + "\">";
+
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";
 
obj_back.style.display = "block";
 
break;
 
break;
case 'Image':
+
case 'image':
var obj_back = document.getElementById("pic_back");
 
 
var obj_image = document.getElementById("pic_image");
 
var obj_image = document.getElementById("pic_image");
 
if(command_set.image == undefined)
 
if(command_set.image == undefined)
 
{
 
{
obj_back.style.display = "block";
 
 
obj_image.style.display = "none";
 
obj_image.style.display = "none";
 
break;
 
break;
 
}
 
}
obj_back.style.display = "none";
+
if(data_pic_back[command_set.image] == undefined)
obj_image.innerHTML = "<img alt=\"" + command_set.image + "\" width=\"800\" height=\"450\" src=\"" + data_pic_back[command_set.image] + "\">";
+
{
 +
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";
 
obj_image.style.display = "block";
 
break;
 
break;
case 'ImageTween':
+
case 'imagetween':
 
return -1;
 
return -1;
break;
+
case 'camerashake':
case 'CameraShake':
 
 
return -1;
 
return -1;
break;
+
case 'character':
case 'Character':
 
 
obj_char_1 = document.getElementById("pic_char_1");
 
obj_char_1 = document.getElementById("pic_char_1");
 
obj_char_2 = document.getElementById("pic_char_2");
 
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)
 
if (command_set.name == undefined)
 
{
 
{
第563行: 第1,437行:
 
else if (command_set.name2 == undefined)
 
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_1.style.display = "block";
 
obj_char_2.style.display = "none";
 
obj_char_2.style.display = "none";
document.getElementById("pic_char").innerHTML = "<img alt=\"" + command_set.name + "\" width=\"400\" height=\"400\" src=\"" + data_pic_char[command_set.name] + "\">";
+
obj_char.style.backgroundImage = "url('" + data_pic_char[command_set.name] + "')";
 
}
 
}
 
else
 
else
第571行: 第1,466行:
 
var char_left = document.getElementById("pic_char_left");
 
var char_left = document.getElementById("pic_char_left");
 
var char_right = document.getElementById("pic_char_right");
 
var char_right = document.getElementById("pic_char_right");
if (command_set.focus == undefined)
+
[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)
 
{
 
{
char_left.style.filter = "";
+
console.warn("Char Data:" + command_set.name2 + " is not exist,please check the data list.");
char_right.style.filter = "";
 
 
}
 
}
else if (command_set.focus == 1)
+
if (command_set.focus == 1)
 
{
 
{
 
char_left.style.filter = "";
 
char_left.style.filter = "";
第584行: 第1,498行:
 
{
 
{
 
char_left.style.filter = "brightness(50%)";
 
char_left.style.filter = "brightness(50%)";
 +
char_right.style.filter = "";
 +
}
 +
else
 +
{
 +
char_left.style.filter = "";
 
char_right.style.filter = "";
 
char_right.style.filter = "";
 
}
 
}
 
obj_char_1.style.display = "none";
 
obj_char_1.style.display = "none";
 
obj_char_2.style.display = "block";
 
obj_char_2.style.display = "block";
char_left.innerHTML = "<img alt=\"" + command_set.name + "\" width=\"400\" height=\"400\" src=\"" + data_pic_char[command_set.name] + "\">";
+
char_left.style.backgroundImage = "url('" + data_pic_char[command_set.name] + "')";
char_right.innerHTML = "<img alt=\"" + command_set.name2 + "\" width=\"400\" height=\"400\" src=\"" + data_pic_char[command_set.name2] + "\">";
+
char_right.style.backgroundImage = "url('" + data_pic_char[command_set.name2] + "')";
 
}
 
}
 
break;
 
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:
 
default:
 
return -1;
 
return -1;
第599行: 第1,566行:
 
else if(data_command[3] != undefined)
 
else if(data_command[3] != undefined)
 
{
 
{
switch(data_command[3])
+
switch(data_command[3].toLowerCase())
 
{
 
{
case 'Dialog':
+
case 'dialog':
document.getElementById("dialog_main").style.display = "none";
+
document.getElementById("txt_name").innerHTML = "";
 +
document.getElementById("txt_output").innerHTML = "";
 +
document.getElementById("system_dialog").style.display = "none";
 
break;
 
break;
case 'Background':
+
case 'background':
 
document.getElementById("pic_back").style.display = "none";
 
document.getElementById("pic_back").style.display = "none";
 
break;
 
break;
case 'Image':
+
case 'image':
document.getElementById("pic_back").style.display = "block";
 
 
document.getElementById("pic_image").style.display = "none";
 
document.getElementById("pic_image").style.display = "none";
 
break;
 
break;
case 'Character':
+
case 'character':
 
document.getElementById("pic_char_1").style.display = "none";
 
document.getElementById("pic_char_1").style.display = "none";
 
document.getElementById("pic_char_2").style.display = "none";
 
document.getElementById("pic_char_2").style.display = "none";
第620行: 第1,588行:
 
else if(data_command[4] != undefined)
 
else if(data_command[4] != undefined)
 
{
 
{
 +
if(decision_mode == true)
 +
{
 +
name_checked = true;
 +
return -1;
 +
}
 
document.getElementById("txt_name").innerHTML = data_command[4].replace(/(^[^"]+)"([^"]*)"/,"$2");
 
document.getElementById("txt_name").innerHTML = data_command[4].replace(/(^[^"]+)"([^"]*)"/,"$2");
now_txt = data_command[5];
+
now_txt = data_command[5].replace("{@nickname}",data_nickname);
document.getElementById("dialog_main").style.display = "block";
+
document.getElementById("system_dialog").style.display = "block";
 
}
 
}
 
return 0;
 
return 0;

2019年11月13日 (三) 22:48的最新版本

自动▶
重置▶
剧情模拟器
单击开始剧情回顾