Skip to content

Instantly share code, notes, and snippets.

@ncwhale
Last active October 5, 2016 10:43
Show Gist options
  • Save ncwhale/59452e471e89c7e385df25f111c7c2e7 to your computer and use it in GitHub Desktop.
Save ncwhale/59452e471e89c7e385df25f111c7c2e7 to your computer and use it in GitHub Desktop.
#53 周刊弹幕,已手工修订喵
if(!$G._get("exists")) {
$G._set('exists', true);
var buttonInfos = {
'B_30':{startTime:120.77,avNum:'av6025863',text:'【东方原创编曲】幽雅的盛开,墨染的樱花 ~ Ordinary Remix',delay:8,x:5.5,y:224.5,width:497.5,height:60},
'B_29':{startTime:128.85,avNum:'av6411176',text:'【东方MMD】咲夜的命运之夜・序章',delay:12,x:5.5,y:224.5,width:497.5,height:60},
'B_28':{startTime:148.93,avNum:'av6392037',text:'【东方手书】若鹭姬的鱼卵三明治',delay:11,x:5.5,y:224.5,width:497.5,height:60},
'B_27':{startTime:168.97,avNum:'av6326230',text:'【东方/幻想万华镜】花朵艳丽 终会散落',delay:11,x:5.5,y:224.5,width:497.5,height:60},
'B_26':{startTime:189.06,avNum:'av6452468',text:'【東方MMD】和服版霊夢酱的極楽浄土【唯美向】',delay:11,x:5.5,y:224.5,width:497.5,height:60},
'B_25':{startTime:209.1,avNum:'av3388284',text:'【囧星人】猴子也能懂的东方Project (修正版) #0~#6 未完',delay:7,x:5.5,y:224.5,width:497.5,height:60},
'B_24':{startTime:217.18,avNum:'av6383583',text:'【东方MMD】偷油记',delay:11,x:5.5,y:224.5,width:497.5,height:60},
'B_23':{startTime:237.27,avNum:'av6387200',text:'【東方MMD】蕾米莉亚与咲夜的阴毛【MMD紙芝居】',delay:11,x:5.5,y:224.5,width:497.5,height:60},
'B_22':{startTime:257.31,avNum:'av6399956',text:'【东方MMD中文内嵌】虫师莉格露 第四话中篇「宿生石」',delay:11,x:5.5,y:224.5,width:497.5,height:60},
'B_21':{startTime:277.35,avNum:'av1095131',text:'【东方纯音乐】蝉在叫 人坏掉!',delay:7,x:5.5,y:224.5,width:497.5,height:60},
'B_9747':{startTime:290.89,avNum:'av332884',text:'有生之年系列 「东方梦幻伪乡 ~ First Disaster」PV[取消PICKUP]',delay:11,x:5.5,y:224.5,width:497.5,height:60},
'B_7789':{startTime:320.93,avNum:'av967809',text:'7789',delay:11,x:0,y:0,width:128,height:60},
'B_1512':{startTime:366.13,avNum:'av5954788',text:'1512',delay:11,x:0,y:0,width:128,height:60},
'B_753':{startTime:411.21,avNum:'av387057',text:'753',delay:12,x:0,y:0,width:128,height:60},
'B_20':{startTime:447.09,avNum:'av6394848',text:'【东方MMD】妖梦穿越回到过去 1',delay:12,x:5.5,y:224.5,width:497.5,height:60},
'B_19':{startTime:472.21,avNum:'av6451125',text:'【东方手书】Enami教授的东方漫画 其6【全程核能】',delay:11,x:5.5,y:224.5,width:497.5,height:60},
'B_18':{startTime:497.21,avNum:'av6411231',text:'【东方MMD】咲夜的命运之夜・本篇',delay:12,x:5.5,y:224.5,width:497.5,height:60},
'B_17':{startTime:522.34,avNum:'av6427109',text:'【东方MMD】今天的红魔馆也很热闹',delay:11,x:5.5,y:224.5,width:497.5,height:60},
'B_16':{startTime:547.38,avNum:'av6399128',text:'【东方手书MAD】这样就好 be as you are (KOKIA) 纪念红泪',delay:11,x:5.5,y:224.5,width:497.5,height:60},
'B_15':{startTime:572.46,avNum:'av6328024',text:'【東方MMD】红魔馆全体人员被卡住了!【高萌】',delay:12,x:5.5,y:224.5,width:497.5,height:60},
'B_14':{startTime:597.55,avNum:'av6396093',text:'【东方自作Arrange】红~绀3面BOSS组曲',delay:11,x:5.5,y:224.5,width:497.5,height:60},
'B_13':{startTime:622.59,avNum:'av706',text:'【東方】Bad Apple!! PV【影絵】',delay:7,x:5.5,y:224.5,width:497.5,height:60},
'B_12':{startTime:630.67,avNum:'av6439508',text:'【东方MMD】呐,荷取酱~',delay:12,x:5.5,y:224.5,width:497.5,height:60},
'B_11':{startTime:655.71,avNum:'av6390938',text:'【东方MMD】东方少女的日常「东方少女之伟人传」',delay:12,x:5.5,y:224.5,width:497.5,height:60},
'B_10':{startTime:722.01,avNum:'av6411238',text:'【东方MMD】咲夜不经意间的夜晚',delay:12,x:5.5,y:224.5,width:497.5,height:60},
'B_9':{startTime:757.17,avNum:'av6423352',text:'【东方手书】兔子和支援和空想【强推】',delay:11,x:5.5,y:224.5,width:497.5,height:60},
'B_8':{startTime:792.21,avNum:'av5988727',text:'幻想万华镜日配中字1-7合集 + pv合集 【东方project】',delay:7,x:5.5,y:224.5,width:497.5,height:60},
'B_7':{startTime:800.3,avNum:'av6401161',text:'【东方原创小品集】探女探女快说话 作品集【第二部】',delay:12,x:5.5,y:224.5,width:497.5,height:60},
'B_6':{startTime:835.34,avNum:'av6460144',text:'【东方MMD】阿燐感冒的故事 看病~【强烈推荐!!!】',delay:12,x:5.5,y:224.5,width:497.5,height:60},
'B_5':{startTime:870.42,avNum:'av6374698',text:'【东方手书】辉夜的新刊【漫画】',delay:12,x:5.5,y:224.5,width:497.5,height:60},
'B_4':{startTime:905.51,avNum:'av6421315',text:'半藏杀死了重要的弟弟',delay:12,x:5.5,y:224.5,width:497.5,height:60},
'B_H215':{startTime:946.17,avNum:'av1327465',text:'H215',delay:11,x:5.5,y:224.5,width:497.5,height:60},
'B_H216':{startTime:976.26,avNum:'av1333283',text:'H216',delay:11,x:5.5,y:224.5,width:497.5,height:60},
'B_H217':{startTime:1006.34,avNum:'av1401707',text:'H217',delay:11,x:5.5,y:224.5,width:497.5,height:60},
'B_H218':{startTime:1036.34,avNum:'av1420092',text:'H218',delay:12,x:5.5,y:224.5,width:497.5,height:60},
'B_H219':{startTime:1066.46,avNum:'av1430542',text:'H219',delay:12,x:5.5,y:224.5,width:497.5,height:60},
'B_3':{startTime:1102.42,avNum:'av6415212',text:'【东方MMD中文内嵌】第4回幻想乡生存游戏大会EP04「恶月升起」',delay:11,x:5.5,y:224.5,width:497.5,height:60},
'B_2':{startTime:1163.51,avNum:'av6404559',text:'【东方手书】胖次消失的日子【漫画】',delay:12,x:5.5,y:224.5,width:497.5,height:60},
'B_1':{startTime:1224.59,avNum:'av6433281',text:'【東方偶像鄉 MMD】紅魔組「Classic」',delay:12,x:5.5,y:224.5,width:497.5,height:60},
'buttonPrev':{ startTime: 54.5, delay: 15.0, x: 0, y:0, width: 128, height: 60, avNum: 'av6420273',text:'上一期', alpha: 0.9}
};
/*Code Start here!*/
var createButton, newButton, newStagesDispatcher, newTimebaseObject, savedPlayerState;
savedPlayerState = Player.state;
Player.pause();
var optional = function (value, defaultValue) { return (value == null) ? defaultValue : value; };
var rectFill = function (shape, x, y, width, height, color, alpha)
{
shape.graphics.beginFill(optional(color, 0x9999FF), optional(alpha, 1.0));
shape.graphics.drawRect(x, y, width, height);
shape.graphics.endFill();
};
var setProperties = function (object, properties, ignores)
{
if (ignores)
{
foreach(properties, function (key, val)
{
if (ignores.indexOf(key) == -1 && object.hasOwnProperty(key))
object['' + key] = val;
});
}
else
{
foreach(properties, function (key, val)
{
if (object.hasOwnProperty(key))
object['' + key] = val;
});
}
};
var newCanvas = function (param)
{
var object = $.createCanvas({});
ScriptManager.popEl(object);
if (param && param.parent){
param.parent.addChild(object);
}
object.transform.matrix3D = null;
if (param){
setProperties(object, param, ['parent']);
}
return object;
};
newTimebaseObject = function(param) {
return {
startTime: param.startTime * 1000 ^ 0,
endTime: (param.startTime + param.delay) * 1000 ^ 0,
displayObject: {},
onInit: function() {
if (param.onInit) {
param.onInit.call(this);
}
},
onPlay: function() {
this.displayObject.visible = true;
},
onComplete: function() {
this.displayObject.visible = false;
},
setDisplayObject: function(displayObject) {
this.displayObject = displayObject;
return displayObject;
}
};
};
newButton = function(param) {
var object;
object = $.createButton({
onclick: param.onClick
});
ScriptManager.popEl(object);
if (param && param.parent) {
param.parent.addChild(object);
}
object.transform.matrix3D = null;
if (param) {
setProperties(object, param, ['parent']);
}
return object;
};
var stage_config;
createButton = function(buttonInfo, stageCanvas) {
return newTimebaseObject({
startTime: buttonInfo.startTime,
delay: buttonInfo.delay,
onInit: function() {
var button, holder, ref;
holder = this.setDisplayObject(newCanvas({
parent: stageCanvas
}));
button = newButton({
onClick: function() {
Player.jump(buttonInfo.avNum, 1, true);
Player.pause();
},
parent: holder
});
button.x = buttonInfo.x;
button.y = buttonInfo.y;
button.width = buttonInfo.width;
button.height = buttonInfo.height;
button.text = (ref = buttonInfo.text) != null ? ref : "";
button.alpha = (ref = buttonInfo.alpha) != null ? ref : 0.5;
}
});
};
newStagesDispatcher = function() {
return {
run: function(param) {
var currentPlayerTime, currentSystemTime, deltaTime, lastHeight, lastPlayerTime, lastSystemTime, lastWidth, playerBaseTimeInSystem, playerTimeInSeconds;
if (param.onInit) {
param.onInit();
}
if (param.onPlayerSeeked) {
param.onPlayerSeeked(0);
}
lastWidth = 0;
lastHeight = 0;
currentSystemTime = getTimer();
lastSystemTime = currentSystemTime;
currentPlayerTime = Player.time;
lastPlayerTime = currentPlayerTime;
playerTimeInSeconds = 0;
playerBaseTimeInSystem = 0;
deltaTime = 0;
$.root.addEventListener("enterFrame", function() {
currentSystemTime = getTimer();
currentPlayerTime = Player.time;
deltaTime = currentSystemTime - lastSystemTime;
lastSystemTime = currentSystemTime;
if (lastWidth !== $.width || lastHeight !== $.height) {
lastWidth = $.width;
lastHeight = $.height;
if (param.onPlayerSizeChanged) {
param.onPlayerSizeChanged();
}
}
if (Player.state === "playing") {
param.onPlayerSeeked(currentPlayerTime);
}
});
}
};
};
load("libBitmap", function() {
var StagesDispatcher = newStagesDispatcher();
var stage_config = {
buttons: [],
layerRoot: {},
onInit: function() {
var mask, stage;
this.layerRoot = {
canvas: newCanvas({ parent: $.root }),
width: 640,
height: 360
};
stage = this.layerRoot;
stageCanvas = stage.canvas;
//rectFill(stageCanvas, 0, 0, this.layerRoot.width, this.layerRoot.height, 0xFF0000, 0.1);
mask = newCanvas({ parent: stageCanvas });
rectFill(mask, 0, 0, this.layerRoot.width, this.layerRoot.height);
stageCanvas.mask = mask;
foreach(buttonInfos, function(k, v) {
trace(k);
stage_config.addButton(createButton(v, stageCanvas));
});
},
addButton: function(button) {
if(button.onInit){ button.onInit(); }
this.buttons.push(button);
},
onPlayerSizeChanged: function() {
var scale, x, y;
scale = Math.min($.width / this.layerRoot.width, $.height / this.layerRoot.height);
x = ($.width - (this.layerRoot.width * scale)) / 2;
y = ($.height - (this.layerRoot.height * scale)) / 2;
this.layerRoot.canvas.scaleX = scale;
this.layerRoot.canvas.scaleY = scale;
this.layerRoot.canvas.x = x;
this.layerRoot.canvas.y = y;
},
onPlayerSeeked: function(now) {
var button, i, length, results;
if (this.buttons.length) {
length = this.buttons.length;
i = 0;
while (i < length) {
button = this.buttons[i ^ 0];
if (now > button.startTime && now < button.endTime) {
button.onPlay();
} else {
button.onComplete();
}
++i;
}
}
}
};
StagesDispatcher.run(stage_config);
if (savedPlayerState === "playing") {
Player.play();
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment