更改

跳转至: 导航搜索

Widget:ScenarioSimulator

添加5,749字节2019年10月21日 (星期一)
无编辑摘要
<noinclude>{{#Widget:Krliov/test2|datas_txt={{用户:Krliov/testpage2}}|pic_back={{用户:Krliov/testpage3}}|pic_char={{用户:Krliov/testpage4}}|datas=
[back]bg_cher_1
[char]char_130_doberm_ex
<div class="button_style" id="button_auto" style="right:100px;" onclick="txt_auto()">自动▶</div>
<div class="button_style" id="button_reset" style="right:0px;color:#808080;" onclick="txt_reset()">重置▶</div>
<div class="pic_style" id="pic_back" style="display:blocknone;width" onclick="txt_click(1)"></div> <div class="pic_style" id="pic_image" style="display:800px;height:450pxnone;" onclick="txt_click(02)"></div> <div class="char_style" id="pic_char_1" style="display:none;" onclick="txt_click(111)"> <div id="pic_char" style="float:left;position:absolute;left:200px;top:25px;width:400px;height:400px;"></div></div> <div class="char_style" id="pic_char_2" style="display:none;" onclick="txt_click(212)"> <div id="pic_char_left" style="float:left;position:absolute;left:100px;top:25px;width:400px;height:400px;"></div> <div id="pic_char_right" style="float:right;position:absolute;right:100px;top:25px;width:400px;height:400px;"></div></div> <div class="dialog_style" id="dialog_main" style="positiondisplay:absolute;width:790px;right:5px; bottom:5px;background-color:rgba(0,0,0,.8)block;" onclick="txt_click()">
<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 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>
<style>
.char_style{
z-index:2;
width:400px;
height:400px;
background-clip:"padding-box";
}
#pic_image{
z-index:2;
}
.button_style{
z-index:2;
position:absolute;
float:right;
padding:0px 5px;
text-align:left;
cursor:default;
}
.pic_style{
z-index:1;
width:800px;
height:450px;
}
.dialog_style{
z-index:2;
position:absolute;
width:790px;
right:5px;
bottom:5px;
background-color:rgba(0,0,0,.8);
cursor:default;
}
</style>
<script type="csv" id="datas_txt_temp"><!--{$datas_txt}--></script>
<script type="csv" id="datas_txt"><!--{$datas}--></script>
<script type="csv" id="datas_back"><!--{$pic_back}--></script>
<script type="csv" id="datas_char"><!--{$pic_char}--></script>
<script>
//(window.RLQ = window.RLQ || []).push(function () {//$(document).ready(function() {var txt_now txt_max = 0,txt_num = 0,txt_num_max now_txt = "",now_txt_max = 0,now_txt_num = 0,now_txt_temp = "";
var timer_id,flag_timer = false;
var timer_id_auto,timer_id_wait,flag_auto = false;
var reset_enabled = false,auto_enabled = true,click_enabled = true,system_enabled = true;
var auto_num = 0;
var txt_temp = "";
var data_temp = "";
var data_txt = {};
var data_txt_test = {};
var data_pic_back = {};
var data_pic_char = {};
try
{
data_temp = document.getElementById("datas_txt_temp").innerHTML;
data_txt_test = data_temp.split("\n");
data_temp = document.getElementById("datas_txt").innerHTML;
data_txt = data_temp.split("\n");
catch(err)
{
var data_txt = new Array();
console.error("ERROR:The datas loaded failed,please check the input and try again.");
data_txt.push("Krliov:There has something wrong when loaded datas,please check the input. :3");
auto_enabled = false;
click_enabled = false;
system_enabled = false;
}
var txt_max = data_txt.length;
try
{
catch(err)
{
var data_txt = new Array();
console.error("ERROR:The pic_back loaded failed,please check the input and try again.");
data_txt.push("Krliov:There has something wrong when loaded pic_back,please check the input. :3");
auto_enabled = false;
click_enabled = false;
system_enabled = false;
}
catch(err)
{
var data_txt = new Array();
console.error("ERROR:The pic_char loaded failed,please check the input and try again.");
data_txt.push("Krliov:There has something wrong when loaded pic_char,please check the input. :3");
auto_enabled = false;
click_enabled = false;
system_enabled = false;
}
console.log(data_txt);
console.log(data_txt_test);
console.log(data_pic_back);
console.log(data_pic_char);
//})
//});
function txt_start()
{
if (system_enabled == false)
{
// console.log("system didn't passed.");
return;
}
// console.log("system passed.");
txt_click(-1);
}
function txt_click(enter_id)
{
if(click_enabled == false && enter_id == undefined) { console.log("Has disregard the default settings."); } else if(click_enabled == false)
{
return;
}
// else if(system_enabled == true) { if (mw.config.values.debug == true) { txt_max = data_txt_test.length; } else { txt_max = data_txt.length; } console.log("idtxt_max=" + enter_idtxt_max); system_enabled = false; reset_enabled = true; document.getElementById("button_reset").style .color = "right:0px"; } console.log("enter_id=" + enter_id);
if(flag_auto == true)
{
// console.log("The timer has been stopped force.");
txt_stop();
txt_now--; place = data_txt[txt_now].indexOf(":"); var _temp; if (place > 0) { _temp = data_txt[txt_now].substr(place + 1); } else { _temp = data_txt[txt_now]; } document.getElementById("txt_output").innerHTML = _temp; txt_now++now_txt;
return;
}
var place = -1;
//before
if (txt_now txt_num == txt_max)
{
console.log("txt_num=" + txt_num + " ,txt_max=" + txt_max)
if(flag_auto == true)
{
auto_stop();
}
document.getElementById("pic_back").innerHTML style.display = "none"; document.getElementById("pic_char_1").style .display = "display:none;"; document.getElementById("pic_char_2").style .display = "display:none;";
document.getElementById("txt_name").innerHTML = "剧情模拟器";
document.getElementById("txt_output").innerHTML = "剧情模拟已结束,单击将重新开始剧情回顾";
document.getElementById("dialog_main").style.display = "block";
system_enabled = true;
reset_enabled = false;
document.getElementById("button_reset").style .color = "right:0px;color:#808080";" txt_now txt_num = 0; txt_num_max now_txt_max = 0;
return;
}
//check var ret = 0; else if(data_txt[txt_now]mw.config.values.indexOf(":") > 0debug == true)
{
place = data_txtif (data_txt_test[txt_nowtxt_num].indexOf(== ":") { ret = -3;// console.log(data_txt[txt_now].substr(0,place)); } else document.getElementById("txt_name").innerHTML { ret = data_txt[txt_now].substrtxt_check_test(0,place); txt_num = place + 1;}
}
//check else var { if (data_txt[txt_num] == "") { ret = 0-3; } else { ret = txt_check(); } } if (debug ret == -3) { console.log("Has skipped the space part.Data number:" + txt_num); txt_num++; txt_next(); return; } else if(ret == true-2)
{
ret = txt_check_testconsole.log("Break and wait timer."); txt_num++; return;
}
else if (debug ret == false-1)
{
ret = txt_checkconsole.log("Has skipped the unused part.Data number:" + txt_num); txt_num++; txt_next(); return;
}
else if(ret == 1)
{
txt_nowconsole.log("Data analyze complete.Data number:" + txt_num); txt_num++;
txt_next();
return;
}
else console.log("Data number:" + txt_num); if(txt_now txt_num < txt_max && txt_now txt_num >= 0)
{
txt_dynamic(50);
{
var place = 0,temp = "";
if(data_txt[txt_nowtxt_num].indexOf(":") > 0) { place = data_txt[txt_num].indexOf(":"); 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]"))
{
document.getElementById("pic_back").innerHTML style.display = "none"; document.getElementById("pic_char_1").style .display = "display:none;"; document.getElementById("pic_char_2").style .display = "display:none;";
return 1;
}
else if(data_txt[txt_nowtxt_num].startsWith("[clear_back]"))
{
document.getElementById("pic_back").innerHTML style.display = "none";
return 1;
}
else if(data_txt[txt_nowtxt_num].startsWith("[clear_char]"))
{
document.getElementById("pic_char_1").style .display = "display:none;"; document.getElementById("pic_char_2").style .display = "display:none;";
return 1;
}
else if(data_txt[txt_nowtxt_num].startsWith("[back]"))
{
place = data_txt[txt_nowtxt_num].indexOf("]") + 1; temp = data_txt[txt_nowtxt_num].substr(place);
document.getElementById("pic_back").innerHTML = "<img alt=\"" + temp + "\" width=\"800\" height=\"450\" src=\"" + data_pic_back[temp] + "\">";
document.getElementById("pic_back").style.display = "block";
return 1;
}
else if(data_txt[txt_nowtxt_num].startsWith("[char]"))
{
place = data_txt[txt_nowtxt_num].indexOf("]") + 1; temp = data_txt[txt_nowtxt_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 = "display:block;"; document.getElementById("pic_char_2").style .display = "display:none;";
return 1;
}
else if(data_txt[txt_nowtxt_num].startsWith("[char_"))
{
var pic_left = "",pic_right = "";
var char_left = document.getElementById("pic_char_left");
var char_right = document.getElementById("pic_char_right");
place = data_txt[txt_nowtxt_num].indexOf("]") + 1; temp = data_txt[txt_nowtxt_num].substr(place);
temp = temp.split(",");
if(temp.length <= 1)
{
console.error("Command analyze failed.");
return-1;
}
pic_left=temp[0];
char_left.innerHTML = "<img alt=\"" + pic_left + "\" width=\"400\" height=\"400\" src=\"" + data_pic_char[pic_left] + "\">";
char_right.innerHTML = "<img alt=\"" + pic_right + "\" width=\"400\" height=\"400\" src=\"" + data_pic_char[pic_right] + "\">";
if (data_txt[txt_nowtxt_num].startsWith("[char_left]"))
{
char_left.style .display = "float:left;position:absolute;left:100px;top:25px;width:400px;height:400px;block"; char_right.style .display = "display:none;";
}
else if (data_txt[txt_nowtxt_num].startsWith("[char_right]"))
{
char_right.style .display = "float:right;position:absolute;right:100px;top:25px;width:400px;height:400px;block"; char_left.style .display = "display:none;";
}
else if (data_txt[txt_nowtxt_num].startsWith("[char_both]"))
{
char_left.style .display = "float:left;position:absolute;left:100px;top:25px;width:400px;height:400px;block"; char_right.style .display = "float:right;position:absolute;right:100px;top:25px;width:400px;height:400px;block";
}
document.getElementById("pic_char_1").style .display = "display:none;block"; document.getElementById("pic_char_2").style .display = "display:block;";
return 1;
}
now_txt = data_txt[txt_num];
return 0;
}
if(auto_enabled == false)
{
console.log("auto didn't passed.");
return;
}
console.log("auto passed.");
reset_enabled = true;
document.getElementById("button_reset").style .color = "right:0px";"
if(flag_auto == false)
{
if (system_enabled == true) { 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;
}
timer_id_auto = setInterval("auto_dynamic()",400);
flag_auto = true;
timer_id_wait = setTimeout("txt_next()",txt_num_maxnow_txt_max*80+Math.min(txt_num_maxnow_txt_max,1)*1000);
}
else if(flag_auto == true)
if(reset_enabled == false)
{
system_enabled = true;// console.log("reset didn't passed.");
return;
}
system_enabled = false;
// console.log("reset passed.");
if(flag_auto == true)
{
txt_stop();
}
document.getElementById("pic_back").innerHTML style.display = "none"; document.getElementById("pic_char_1").style .display = "display:none;"; document.getElementById("pic_char_2").style .display = "display:none;";
document.getElementById("txt_name").innerHTML = "剧情模拟器";
document.getElementById("txt_output").innerHTML = "剧情模拟已重置,单击开始剧情回顾";
document.getElementById("dialog_main").style.display = "block";
reset_enabled = false;
system_enabled = true; document.getElementById("button_reset").style .color = "right:0px;color:#808080;" txt_now txt_num = 0; txt_num_max now_txt_max = 0;
return;
}
clearInterval(timer_id);
flag_timer = false;
txt_num now_txt_num = 0; txt_temp now_txt = ""; now_txt_temp = ""; txt_nowtxt_num++;
}
function auto_dynamic()
function txt_dynamic(interval)
{
txt_num_max now_txt_max = data_txt[txt_now]now_txt.length;
flag_timer = true;
timer_id = setInterval("timer1()",50);
function timer1()
{
if (txt_num now_txt_num < txt_num_maxnow_txt_max)
{
txt_temp now_txt_temp = txt_temp now_txt_temp + data_txt[txt_now]now_txt.substr(txt_numnow_txt_num,1); document.getElementById("txt_output").innerHTML = txt_tempnow_txt_temp; txt_numnow_txt_num++;
return;
}
if(flag_auto == true)
{
timer_id_wait = setTimeout("txt_next()",txt_num_maxnow_txt_max*80+1000)
}
}
function txt_check_test()
{
if(data_txtdata_txt_test[txt_nowtxt_num].match("^\\s+$")) //ONLY SPACE REGEX
{
return -1;
}
else if(data_txtdata_txt_test[txt_nowtxt_num].match("^\\s*//.*$")) //COMMENT REGEX
{
return -1;
}
var data_command = data_txtdata_txt_test[txt_nowtxt_num].match("^\\[\\s*(?:(.*)\\((.*)\\)|(?:([\\.|\\w]*)|(.*)))\\s*\\]\\s*(.*)"); //COMMAND REGEX console.log(data_command); if (data_command[1] != undefined) { var command_set = {}; data_command[2] = data_command[2].replace(/\s+|["$]|#[^\,]+/g,""); for (num of data_command[2].split(",")) { var [type,value] = num.split("="); command_set[type] = value; } switch (data_command[1]) { case 'HEADER': return -1; break; case 'PlayMusic': return -1; break; case 'StopMusic': return -1; break; case 'Delay': if (command_set.time == undefined) { return -1; } setTimeout("txt_next()",command_set.time*1000); return -2; break; case 'Blocker': return -1; break; case 'Decision': return -1; break; case 'Predicate': return -1; break; case 'Background': var obj_back = document.getElementById("pic_back"); if(command_set.image == undefined) { obj_back.style.display = "none"; break; } obj_back.innerHTML = "<img alt=\"" + command_set.image + "\" width=\"800\" height=\"450\" src=\"" + data_pic_back[command_set.image] + "\">"; obj_back.style.display = "block"; break; case 'Image': var obj_back = document.getElementById("pic_back"); var obj_image = document.getElementById("pic_image"); if(command_set.image == undefined) { obj_back.style.display = "block"; obj_image.style.display = "none"; break; } obj_back.style.display = "none"; obj_image.innerHTML = "<img alt=\"" + command_set.image + "\" width=\"800\" height=\"450\" src=\"" + data_pic_back[command_set.image] + "\">"; obj_image.style.display = "block"; break; case 'ImageTween': return -1; break; case 'CameraShake': return -1; break; case 'Character': obj_char_1 = document.getElementById("pic_char_1"); obj_char_2 = document.getElementById("pic_char_2"); if (command_set.name == undefined) { obj_char_1.style.display = "none"; obj_char_2.style.display = "none"; } else if (command_set.name2 == undefined) { obj_char_1.style.display = "block"; 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] + "\">"; } else { var char_left = document.getElementById("pic_char_left"); var char_right = document.getElementById("pic_char_right"); if (command_set.focus == undefined) { char_left.style.filter = ""; char_right.style.filter = ""; } else 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 = ""; } obj_char_1.style.display = "none"; 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_right.innerHTML = "<img alt=\"" + command_set.name2 + "\" width=\"400\" height=\"400\" src=\"" + data_pic_char[command_set.name2] + "\">"; } break; default: return -1; } return 1; } else if(data_command[3] != undefined) { switch(data_command[3]) { case 'Dialog': document.getElementById("dialog_main").style.display = "none"; break; case 'Background': document.getElementById("pic_back").style.display = "none"; break; case 'Image': document.getElementById("pic_back").style.display = "block"; 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; } else if(data_command[4] != undefined) { document.getElementById("txt_name").innerHTML = data_command[4].replace(/(^[^"]+)"([^"]*)"/,"$2"); now_txt = data_command[5]; document.getElementById("dialog_main").style.display = "block"; }
return 0;
}
</script>
</includeonly>
Angestellter、Editor、管理员小部件编辑者
1,585
个编辑

导航菜单