backlog制作完毕,cgText重构
This commit is contained in:
parent
4936449f67
commit
4609a85797
@ -965,8 +965,7 @@ action
|
||||
| animationDrawable_s
|
||||
| over_s
|
||||
| overlist_s
|
||||
| playStereo_s
|
||||
| moveStereo_s
|
||||
| cgtextList_s
|
||||
| pass_s
|
||||
;
|
||||
|
||||
@ -1125,22 +1124,33 @@ overtextEmpty
|
||||
var code = [];
|
||||
return code;
|
||||
*/;
|
||||
cgtextList_s
|
||||
: '切换剧情文本库' EvalString Newline
|
||||
|
||||
|
||||
/* cgtextList_s
|
||||
tooltip : cgtextList:设置cg剧情文本库
|
||||
helpUrl : /_docs/#/instruction
|
||||
default : ["chapter0"]
|
||||
var code = '{"type": "cgtextList", "textList":"'+EvalString_0+'"},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
cgtext_s
|
||||
: '背景' EvalString? '回忆滤镜' Bool? '移除对话框' Bool? '头像' EvalString?'名字' EvalString?'坐标PX' Number'打字间隔' Int? BGNL? Newline
|
||||
: '背景' EvalString? '回忆滤镜' Bool? '移除对话框' Bool? '剧情库序列' Int '头像' EvalString?'坐标PX' Number'打字间隔' Int? BGNL? Newline
|
||||
'自动等待时长' Int '音频文件(需在全塔属性——使用音效注册)'EvalString? BGNL? Newline
|
||||
EvalString? BGNL? Newline textcgDrawingList+? Newline
|
||||
textcgDrawingList+? Newline
|
||||
|
||||
|
||||
/* cgtext_s
|
||||
tooltip : cgtext:显示一段包含cg的文字(剧情)
|
||||
helpUrl : /_docs/#/instruction
|
||||
allImages : ['EvalString_0','EvalString_1']
|
||||
allSounds : ['EvalString_3']
|
||||
default : ["bg_5043.webp",false,"face_050445.webp",false,"菲奥奈",-300,0,2000,"","这句话显示在对话框内",[{ "name":"tati_050145a.webp" , "px": 100,"filter":false }]]
|
||||
allSounds : ['EvalString_2']
|
||||
default : ["bg_5043.webp",false,false,0,"face_050445.webp",-300,0,2000,"","这句话显示在对话框内",[{ "name":"tati_050145a.webp" , "px": 100,"filter":false }]]
|
||||
var head ='{ "name": "'+EvalString_1+'", "px": '+Number_0+' }'
|
||||
var list=',"bodyList": [\n'+textcgDrawingList_0.slice(0,-1)+'\n]'
|
||||
var code = '{"type": "cgtext", "bg":"'+EvalString_0+'","memory":'+Bool_0+',"WindowSkin":'+Bool_1+',"head":'+head+' ,"name":"'+EvalString_2+'","time":'+Int_0+',"wait":'+Int_1+',"sound":"'+EvalString_3+'","text": "'+EvalString_4+'"'+list+' },\n';
|
||||
var code = '{"type": "cgtext", "bg":"'+EvalString_0+'","memory":'+Bool_0+',"WindowSkin":'+Bool_1+',"head":'+head+' ,"index":"'+Int_0+'","time":'+Int_1+',"wait":'+Int_2+',"sound":"'+EvalString_2+'"'+list+' },\n';
|
||||
return code;
|
||||
*/;
|
||||
textcgDrawingList
|
||||
@ -3078,39 +3088,8 @@ var code = '{"type": "playSound", "name": "'+EvalString_0+'"'+Bool_0+IntString_0
|
||||
return code;
|
||||
*/;
|
||||
|
||||
playStereo_s
|
||||
: '播放音效(立体音)' EvalString '左声道音量' Int '右声道音量' Int '启用立体音' Bool? Newline
|
||||
|
||||
|
||||
/* playStereo_s
|
||||
tooltip : playSound: 播放音效(立体音)
|
||||
helpUrl : /_docs/#/instruction
|
||||
default : ["item.mp3",1,1,true]
|
||||
colour : this.imageColor
|
||||
allSounds : ['EvalString_0']
|
||||
material : ["./project/sounds/", "EvalString_0"]
|
||||
|
||||
var code = '{"type": "playStereo", "name": "'+EvalString_0+'", "left": '+Int_0+', "right": '+Int_1+', "split": '+Bool_0+'},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
moveStereo_s
|
||||
: '播放渐变音效(立体音)' EvalString '左声道音量' Int '右声道音量' Int '启用立体音' Bool? BGNL? Newline
|
||||
'左声道目标音量' Int '右声道目标音量' Int '渐变时长'Int Newline
|
||||
|
||||
|
||||
/* moveStereo_s
|
||||
tooltip : playSound: 播放渐变音效(立体音)
|
||||
helpUrl : /_docs/#/instruction
|
||||
default : ["item.mp3",1,1,true,10,10,1000]
|
||||
colour : this.imageColor
|
||||
allSounds : ['EvalString_0']
|
||||
material : ["./project/sounds/", "EvalString_0"]
|
||||
|
||||
var code = '{"type": "moveStereo", "name": "'+EvalString_0+'", "left": '+Int_0+', "right": '+Int_1+', "split": '+Bool_0+', "leftTo": '+Int_2+', "rightTo": '+Int_3+', "time": '+Int_4+'},\n';
|
||||
return code;
|
||||
*/;
|
||||
|
||||
playSound_1_s
|
||||
: '播放系统音效' NameMap_List '停止之前音效' Bool? '音调' IntString? '等待播放完毕' Bool? Newline
|
||||
|
||||
|
@ -542,6 +542,12 @@ MotaActionParser = function () {
|
||||
);
|
||||
}
|
||||
break;
|
||||
case "cgtextList":
|
||||
this.next = MotaActionBlocks["cgtextList_s"].xmlText([
|
||||
data.textList,
|
||||
this.next,
|
||||
]);
|
||||
break;
|
||||
case "cgtext": // cg对话框
|
||||
var buildcgDrawing = function (obj) {
|
||||
obj = MotaActionFunctions.processcgDrawing(obj || []);
|
||||
@ -563,13 +569,12 @@ MotaActionParser = function () {
|
||||
data.bg,
|
||||
data.memory,
|
||||
data.WindowSkin,
|
||||
data.index,
|
||||
data.head.name,
|
||||
data.name || "",
|
||||
data.head.px || -300,
|
||||
data.time,
|
||||
data.wait,
|
||||
data.sound,
|
||||
data.text,
|
||||
buildcgDrawing(data.bodyList),
|
||||
this.next,
|
||||
]);
|
||||
@ -1520,27 +1525,6 @@ MotaActionParser = function () {
|
||||
]);
|
||||
}
|
||||
break;
|
||||
case "playStereo":
|
||||
this.next = MotaActionBlocks["playStereo_s"].xmlText([
|
||||
data.name,
|
||||
data.left,
|
||||
data.right,
|
||||
data.split || true,
|
||||
this.next,
|
||||
]);
|
||||
break;
|
||||
case "moveStereo":
|
||||
this.next = MotaActionBlocks["moveStereo_s"].xmlText([
|
||||
data.name,
|
||||
data.left,
|
||||
data.right,
|
||||
data.split || true,
|
||||
data.leftTo,
|
||||
data.rightTo,
|
||||
data.time,
|
||||
this.next,
|
||||
]);
|
||||
break;
|
||||
case "playSound":
|
||||
var knownItems = MotaActionBlocks["NameMap_List"].options.map(function (
|
||||
one
|
||||
|
2891
libs/control.js
2891
libs/control.js
File diff suppressed because it is too large
Load Diff
2903
libs/events.js
2903
libs/events.js
File diff suppressed because it is too large
Load Diff
566
libs/loader.js
566
libs/loader.js
@ -1,27 +1,24 @@
|
||||
|
||||
/*
|
||||
loader.js:负责对资源的加载
|
||||
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
function loader () {
|
||||
function loader() {
|
||||
this._init();
|
||||
}
|
||||
|
||||
loader.prototype._init = function () {
|
||||
|
||||
}
|
||||
loader.prototype._init = function () {};
|
||||
|
||||
////// 设置加载进度条进度 //////
|
||||
loader.prototype._setStartProgressVal = function (val) {
|
||||
core.dom.startTopProgress.style.width = val + '%';
|
||||
}
|
||||
core.dom.startTopProgress.style.width = val + "%";
|
||||
};
|
||||
|
||||
////// 设置加载进度条提示文字 //////
|
||||
loader.prototype._setStartLoadTipText = function (text) {
|
||||
core.dom.startTopLoadTips.innerText = text;
|
||||
}
|
||||
};
|
||||
|
||||
loader.prototype._load = function (callback) {
|
||||
this._loadMusics();
|
||||
@ -30,7 +27,7 @@ loader.prototype._load = function (callback) {
|
||||
} else {
|
||||
this._load_sync(callback);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
loader.prototype._load_sync = function (callback) {
|
||||
this._loadAnimates_sync();
|
||||
@ -39,13 +36,13 @@ loader.prototype._load_sync = function (callback) {
|
||||
core.loader._loadExtraImages_sync(function () {
|
||||
core.loader._loadAutotiles_sync(function () {
|
||||
core.loader._loadTilesets_sync(callback);
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
loader.prototype._load_async = function (callback) {
|
||||
core.loader._setStartLoadTipText('正在加载资源文件...');
|
||||
core.loader._setStartLoadTipText("正在加载资源文件...");
|
||||
const all = {};
|
||||
|
||||
const _makeOnProgress = function (name) {
|
||||
@ -53,24 +50,31 @@ loader.prototype._load_async = function (callback) {
|
||||
return (loaded, total) => {
|
||||
all[name].loaded = loaded;
|
||||
all[name].total = total;
|
||||
let allLoaded = 0, allTotal = 0;
|
||||
let allLoaded = 0,
|
||||
allTotal = 0;
|
||||
for (const one of Object.values(all)) {
|
||||
allLoaded += one.loaded;
|
||||
allTotal += one.total;
|
||||
}
|
||||
console.log(allLoaded. allTotal);
|
||||
console.log(allLoaded.allTotal);
|
||||
if (allTotal > 0) {
|
||||
if (allLoaded == allTotal) {
|
||||
core.loader._setStartLoadTipText("正在处理资源文件... 请稍候...");
|
||||
} else {
|
||||
core.loader._setStartLoadTipText('正在加载资源文件... ' +
|
||||
core.formatSize(allLoaded) + " / " + core.formatSize(allTotal) +
|
||||
" (" + (allLoaded / allTotal * 100).toFixed(2) + "%)");
|
||||
core.loader._setStartLoadTipText(
|
||||
"正在加载资源文件... " +
|
||||
core.formatSize(allLoaded) +
|
||||
" / " +
|
||||
core.formatSize(allTotal) +
|
||||
" (" +
|
||||
((allLoaded / allTotal) * 100).toFixed(2) +
|
||||
"%)"
|
||||
);
|
||||
}
|
||||
core.loader._setStartProgressVal(allLoaded / allTotal * 100);
|
||||
core.loader._setStartProgressVal((allLoaded / allTotal) * 100);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
const _makeOnFinished = function (name) {
|
||||
return () => {
|
||||
setTimeout(() => {
|
||||
@ -80,58 +84,121 @@ loader.prototype._load_async = function (callback) {
|
||||
}
|
||||
callback();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
if (main.splitChunkMap) {
|
||||
this._loadAnimates_chunked(main.splitChunkMap.animates, _makeOnProgress, _makeOnFinished);
|
||||
this._loadSounds_chunked(main.splitChunkMap.sounds, _makeOnProgress, _makeOnFinished);
|
||||
this._loadMaterials_chunked(main.splitChunkMap.materials, _makeOnProgress, _makeOnFinished);
|
||||
this._loadExtraImages_chunked(main.splitChunkMap.images, _makeOnProgress, _makeOnFinished);
|
||||
this._loadAutotiles_chunked(main.splitChunkMap.autotiles, _makeOnProgress, _makeOnFinished);
|
||||
this._loadTilesets_chunked(main.splitChunkMap.tilesets, _makeOnProgress, _makeOnFinished);
|
||||
this._loadAnimates_chunked(
|
||||
main.splitChunkMap.animates,
|
||||
_makeOnProgress,
|
||||
_makeOnFinished
|
||||
);
|
||||
this._loadSounds_chunked(
|
||||
main.splitChunkMap.sounds,
|
||||
_makeOnProgress,
|
||||
_makeOnFinished
|
||||
);
|
||||
this._loadMaterials_chunked(
|
||||
main.splitChunkMap.materials,
|
||||
_makeOnProgress,
|
||||
_makeOnFinished
|
||||
);
|
||||
this._loadExtraImages_chunked(
|
||||
main.splitChunkMap.images,
|
||||
_makeOnProgress,
|
||||
_makeOnFinished
|
||||
);
|
||||
this._loadAutotiles_chunked(
|
||||
main.splitChunkMap.autotiles,
|
||||
_makeOnProgress,
|
||||
_makeOnFinished
|
||||
);
|
||||
this._loadTilesets_chunked(
|
||||
main.splitChunkMap.tilesets,
|
||||
_makeOnProgress,
|
||||
_makeOnFinished
|
||||
);
|
||||
} else {
|
||||
this._loadAnimates_async(_makeOnProgress('animates'), _makeOnFinished('animates'));
|
||||
this._loadSounds_async(_makeOnProgress('sounds'), _makeOnFinished('sounds'));
|
||||
this._loadMaterials_async(_makeOnProgress('materials'), _makeOnFinished('materials'));
|
||||
this._loadExtraImages_async(_makeOnProgress('images'), _makeOnFinished('images'));
|
||||
this._loadAutotiles_async(_makeOnProgress('autotiles'), _makeOnFinished('autotiles'));
|
||||
this._loadTilesets_async(_makeOnProgress('tilesets'), _makeOnFinished('tilesets'));
|
||||
this._loadAnimates_async(
|
||||
_makeOnProgress("animates"),
|
||||
_makeOnFinished("animates")
|
||||
);
|
||||
this._loadSounds_async(
|
||||
_makeOnProgress("sounds"),
|
||||
_makeOnFinished("sounds")
|
||||
);
|
||||
this._loadMaterials_async(
|
||||
_makeOnProgress("materials"),
|
||||
_makeOnFinished("materials")
|
||||
);
|
||||
this._loadExtraImages_async(
|
||||
_makeOnProgress("images"),
|
||||
_makeOnFinished("images")
|
||||
);
|
||||
this._loadAutotiles_async(
|
||||
_makeOnProgress("autotiles"),
|
||||
_makeOnFinished("autotiles")
|
||||
);
|
||||
this._loadTilesets_async(
|
||||
_makeOnProgress("tilesets"),
|
||||
_makeOnFinished("tilesets")
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ----- 加载资源文件 ------ //
|
||||
|
||||
loader.prototype._loadMaterials_sync = function (callback) {
|
||||
this._setStartLoadTipText("正在加载资源文件...");
|
||||
this.loadImages("materials", core.materials, core.material.images, function () {
|
||||
this.loadImages(
|
||||
"materials",
|
||||
core.materials,
|
||||
core.material.images,
|
||||
function () {
|
||||
core.loader._loadMaterials_afterLoad();
|
||||
callback();
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
loader.prototype._loadMaterials_async = function (onprogress, onfinished) {
|
||||
this.loadImagesFromZip('project/materials/materials.h5data', core.materials, core.material.images, onprogress, function () {
|
||||
this.loadImagesFromZip(
|
||||
"project/materials/materials.h5data",
|
||||
core.materials,
|
||||
core.material.images,
|
||||
onprogress,
|
||||
function () {
|
||||
core.loader._loadMaterials_afterLoad();
|
||||
onfinished();
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
loader.prototype._loadMaterials_chunked = async function (chunks, makeOnProgress, makeOnFinished) {
|
||||
await this._loadImagesFromChunks(chunks, core.materials, core.material.images, makeOnProgress, makeOnFinished);
|
||||
loader.prototype._loadMaterials_chunked = async function (
|
||||
chunks,
|
||||
makeOnProgress,
|
||||
makeOnFinished
|
||||
) {
|
||||
await this._loadImagesFromChunks(
|
||||
chunks,
|
||||
core.materials,
|
||||
core.material.images,
|
||||
makeOnProgress,
|
||||
makeOnFinished
|
||||
);
|
||||
core.loader._loadMaterials_afterLoad();
|
||||
}
|
||||
};
|
||||
|
||||
loader.prototype._loadMaterials_afterLoad = function () {
|
||||
const images = core.splitImage(core.material.images['icons']);
|
||||
const images = core.splitImage(core.material.images["icons"]);
|
||||
for (let key in core.statusBar.icons) {
|
||||
if (typeof core.statusBar.icons[key] == 'number') {
|
||||
if (typeof core.statusBar.icons[key] == "number") {
|
||||
core.statusBar.icons[key] = images[core.statusBar.icons[key]];
|
||||
if (core.statusBar.image[key] != null)
|
||||
core.statusBar.image[key].src = core.statusBar.icons[key].src;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ------ 加载使用的图片 ------ //
|
||||
|
||||
@ -139,38 +206,54 @@ loader.prototype._loadExtraImages_sync = function (callback) {
|
||||
core.material.images.images = {};
|
||||
this._setStartLoadTipText("正在加载图片文件...");
|
||||
core.loadImages("images", core.images, core.material.images.images, callback);
|
||||
}
|
||||
};
|
||||
|
||||
loader.prototype._loadExtraImages_async = function (onprogress, onfinished) {
|
||||
core.material.images.images = {};
|
||||
|
||||
// Check .gif
|
||||
const gifs = images.filter(function (name) {
|
||||
return name.toLowerCase().endsWith('.gif');
|
||||
return name.toLowerCase().endsWith(".gif");
|
||||
});
|
||||
// gif没有被压缩在zip中,延迟加载...
|
||||
this._loadExtraImages_loadLazy(gifs);
|
||||
|
||||
images = images.filter((name) => !name.toLowerCase().endsWith('.gif'));
|
||||
images = images.filter((name) => !name.toLowerCase().endsWith(".gif"));
|
||||
|
||||
this.loadImagesFromZip('project/images/images.h5data', images, core.material.images.images, onprogress, onfinished);
|
||||
}
|
||||
this.loadImagesFromZip(
|
||||
"project/images/images.h5data",
|
||||
images,
|
||||
core.material.images.images,
|
||||
onprogress,
|
||||
onfinished
|
||||
);
|
||||
};
|
||||
|
||||
loader.prototype._loadExtraImages_chunked = function (chunks, makeOnProgress, makeOnFinished) {
|
||||
loader.prototype._loadExtraImages_chunked = function (
|
||||
chunks,
|
||||
makeOnProgress,
|
||||
makeOnFinished
|
||||
) {
|
||||
core.material.images.images = {};
|
||||
let images = core.images;
|
||||
|
||||
// Check .gif
|
||||
const gifs = images.filter(function (name) {
|
||||
return name.toLowerCase().endsWith('.gif');
|
||||
return name.toLowerCase().endsWith(".gif");
|
||||
});
|
||||
// gif没有被压缩在zip中,延迟加载...
|
||||
this._loadExtraImages_loadLazy(gifs);
|
||||
|
||||
images = images.filter((name) => !name.toLowerCase().endsWith('.gif'));
|
||||
images = images.filter((name) => !name.toLowerCase().endsWith(".gif"));
|
||||
|
||||
this._loadImagesFromChunks(chunks, images, core.material.images.images, makeOnProgress, makeOnFinished);
|
||||
}
|
||||
this._loadImagesFromChunks(
|
||||
chunks,
|
||||
images,
|
||||
core.material.images.images,
|
||||
makeOnProgress,
|
||||
makeOnFinished
|
||||
);
|
||||
};
|
||||
|
||||
loader.prototype._loadExtraImages_loadLazy = function (list) {
|
||||
list.forEach(function (gif) {
|
||||
@ -180,7 +263,7 @@ loader.prototype._loadExtraImages_loadLazy = function (list) {
|
||||
}
|
||||
});
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
|
||||
// ------ 加载自动元件 ------ //
|
||||
|
||||
@ -194,27 +277,43 @@ loader.prototype._loadAutotiles_sync = function (callback) {
|
||||
core.loader._loadAutotiles_afterLoad(keys, autotiles);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
loader.prototype._loadAutotiles_async = function (onprogress, onfinished) {
|
||||
core.material.images.autotile = {};
|
||||
var keys = Object.keys(core.material.icons.autotile);
|
||||
var autotiles = {};
|
||||
|
||||
this.loadImagesFromZip('project/autotiles/autotiles.h5data', keys, autotiles, onprogress, function () {
|
||||
this.loadImagesFromZip(
|
||||
"project/autotiles/autotiles.h5data",
|
||||
keys,
|
||||
autotiles,
|
||||
onprogress,
|
||||
function () {
|
||||
core.loader._loadAutotiles_afterLoad(keys, autotiles);
|
||||
onfinished();
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
loader.prototype._loadAutotiles_chunked = async function (chunks, makeOnProgress, makeOnFinished) {
|
||||
loader.prototype._loadAutotiles_chunked = async function (
|
||||
chunks,
|
||||
makeOnProgress,
|
||||
makeOnFinished
|
||||
) {
|
||||
core.material.images.autotile = {};
|
||||
const keys = Object.keys(core.material.icons.autotile);
|
||||
const autotiles = {};
|
||||
|
||||
await this._loadImagesFromChunks(chunks, keys, autotiles, makeOnProgress, makeOnFinished);
|
||||
await this._loadImagesFromChunks(
|
||||
chunks,
|
||||
keys,
|
||||
autotiles,
|
||||
makeOnProgress,
|
||||
makeOnFinished
|
||||
);
|
||||
core.loader._loadAutotiles_afterLoad(keys, autotiles);
|
||||
}
|
||||
};
|
||||
|
||||
loader.prototype._loadAutotiles_afterLoad = function (keys, autotiles) {
|
||||
// autotile需要保证顺序
|
||||
@ -225,33 +324,53 @@ loader.prototype._loadAutotiles_afterLoad = function (keys, autotiles) {
|
||||
setTimeout(function () {
|
||||
core.maps._makeAutotileEdges();
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// ------ 加载额外素材 ------ //
|
||||
|
||||
loader.prototype._loadTilesets_sync = function (callback) {
|
||||
core.material.images.tilesets = {};
|
||||
this._setStartLoadTipText("正在加载额外素材...");
|
||||
this.loadImages("tilesets", core.tilesets, core.material.images.tilesets, function () {
|
||||
this.loadImages(
|
||||
"tilesets",
|
||||
core.tilesets,
|
||||
core.material.images.tilesets,
|
||||
function () {
|
||||
core.loader._loadTilesets_afterLoad();
|
||||
callback();
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
loader.prototype._loadTilesets_async = function (onprogress, onfinished) {
|
||||
core.material.images.tilesets = {};
|
||||
this.loadImagesFromZip('project/tilesets/tilesets.h5data', core.tilesets, core.material.images.tilesets, onprogress, function () {
|
||||
this.loadImagesFromZip(
|
||||
"project/tilesets/tilesets.h5data",
|
||||
core.tilesets,
|
||||
core.material.images.tilesets,
|
||||
onprogress,
|
||||
function () {
|
||||
core.loader._loadTilesets_afterLoad();
|
||||
onfinished();
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
loader.prototype._loadTilesets_chunked = async function (chunks, makeOnProgress, makeOnFinished) {
|
||||
loader.prototype._loadTilesets_chunked = async function (
|
||||
chunks,
|
||||
makeOnProgress,
|
||||
makeOnFinished
|
||||
) {
|
||||
core.material.images.tilesets = {};
|
||||
await this._loadImagesFromChunks(chunks, core.tilesets, core.material.images.tilesets, makeOnProgress, makeOnFinished);
|
||||
await this._loadImagesFromChunks(
|
||||
chunks,
|
||||
core.tilesets,
|
||||
core.material.images.tilesets,
|
||||
makeOnProgress,
|
||||
makeOnFinished
|
||||
);
|
||||
core.loader._loadTilesets_afterLoad();
|
||||
}
|
||||
};
|
||||
|
||||
loader.prototype._loadTilesets_afterLoad = function () {
|
||||
// 检查宽高是32倍数,如果出错在控制台报错
|
||||
@ -264,7 +383,7 @@ loader.prototype._loadTilesets_afterLoad = function () {
|
||||
console.warn("警告!" + imgName + "上的图块素材个数大于3000!");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ------ 实际加载一系列图片 ------ //
|
||||
|
||||
@ -276,10 +395,9 @@ loader.prototype.loadImages = function (dir, names, toSave, callback) {
|
||||
var items = 0;
|
||||
for (var i = 0; i < names.length; i++) {
|
||||
this.loadImage(dir, names[i], function (id, image) {
|
||||
core.loader._setStartLoadTipText('正在加载图片 ' + id + "...");
|
||||
core.loader._setStartLoadTipText("正在加载图片 " + id + "...");
|
||||
if (toSave[id] !== undefined) {
|
||||
if (image != null)
|
||||
toSave[id] = image;
|
||||
if (image != null) toSave[id] = image;
|
||||
return;
|
||||
}
|
||||
toSave[id] = image;
|
||||
@ -288,46 +406,51 @@ loader.prototype.loadImages = function (dir, names, toSave, callback) {
|
||||
if (items == names.length) {
|
||||
if (callback) callback();
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
loader.prototype.loadImage = function (dir, imgName, callback) {
|
||||
try {
|
||||
var name = imgName;
|
||||
if (name.indexOf(".") < 0)
|
||||
name = name + ".png";
|
||||
if (name.indexOf(".") < 0) name = name + ".png";
|
||||
var image = new Image();
|
||||
image.onload = function () {
|
||||
image.setAttribute('_width', image.width);
|
||||
image.setAttribute('_height', image.height);
|
||||
image.setAttribute("_width", image.width);
|
||||
image.setAttribute("_height", image.height);
|
||||
callback(imgName, image);
|
||||
}
|
||||
};
|
||||
image.onerror = function () {
|
||||
callback(imgName, null);
|
||||
}
|
||||
image.src = 'project/' + dir + '/' + name + "?v=" + main.version;
|
||||
if (name.endsWith('.gif'))
|
||||
callback(imgName, null);
|
||||
}
|
||||
catch (e) {
|
||||
};
|
||||
image.src = "project/" + dir + "/" + name + "?v=" + main.version;
|
||||
if (name.endsWith(".gif")) callback(imgName, null);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ------ 从zip中加载一系列图片 ------ //
|
||||
|
||||
loader.prototype.loadImagesFromZip = function (url, names, toSave, onprogress, onfinished) {
|
||||
loader.prototype.loadImagesFromZip = function (
|
||||
url,
|
||||
names,
|
||||
toSave,
|
||||
onprogress,
|
||||
onfinished
|
||||
) {
|
||||
if (!names || names.length == 0) {
|
||||
if (onfinished) onfinished();
|
||||
return;
|
||||
}
|
||||
|
||||
core.unzip(url + "?v=" + main.version, function (data) {
|
||||
core.unzip(
|
||||
url + "?v=" + main.version,
|
||||
function (data) {
|
||||
var cnt = 1;
|
||||
names.forEach(function (name) {
|
||||
var imgName = name;
|
||||
if (imgName.indexOf('.') < 0) imgName += '.png';
|
||||
if (imgName.indexOf(".") < 0) imgName += ".png";
|
||||
if (imgName in data) {
|
||||
var img = new Image();
|
||||
var url = URL.createObjectURL(data[imgName]);
|
||||
@ -335,21 +458,32 @@ loader.prototype.loadImagesFromZip = function (url, names, toSave, onprogress, o
|
||||
img.onload = function () {
|
||||
cnt--;
|
||||
URL.revokeObjectURL(url);
|
||||
img.setAttribute('_width', img.width);
|
||||
img.setAttribute('_height', img.height);
|
||||
img.setAttribute("_width", img.width);
|
||||
img.setAttribute("_height", img.height);
|
||||
if (cnt == 0 && onfinished) onfinished();
|
||||
}
|
||||
};
|
||||
img.src = url;
|
||||
toSave[name] = img;
|
||||
}
|
||||
});
|
||||
cnt--;
|
||||
if (cnt == 0 && onfinished) onfinished();
|
||||
}, null, false, onprogress);
|
||||
}
|
||||
},
|
||||
null,
|
||||
false,
|
||||
onprogress
|
||||
);
|
||||
};
|
||||
|
||||
loader.prototype._loadImagesFromChunks = async function (chunks, names, toSave, makeOnProgress, makeOnFinished) {
|
||||
await Promise.all(chunks.map((chunk) => {
|
||||
loader.prototype._loadImagesFromChunks = async function (
|
||||
chunks,
|
||||
names,
|
||||
toSave,
|
||||
makeOnProgress,
|
||||
makeOnFinished
|
||||
) {
|
||||
await Promise.all(
|
||||
chunks.map((chunk) => {
|
||||
const onfinished = makeOnFinished(chunk);
|
||||
const onprogress = makeOnProgress(chunk);
|
||||
return new Promise((resolve) => {
|
||||
@ -358,8 +492,9 @@ loader.prototype._loadImagesFromChunks = async function (chunks, names, toSave,
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}));
|
||||
}
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
// ------ 加载动画文件 ------ //
|
||||
|
||||
@ -368,37 +503,67 @@ loader.prototype._loadAnimates_sync = function () {
|
||||
|
||||
if (main.supportBunch) {
|
||||
if (core.animates.length > 0) {
|
||||
core.http('GET', '__all_animates__?v=' + main.version + '&id=' + core.animates.join(','), null, function (content) {
|
||||
var u = content.split('@@@~~~###~~~@@@');
|
||||
core.http(
|
||||
"GET",
|
||||
"__all_animates__?v=" + main.version + "&id=" + core.animates.join(","),
|
||||
null,
|
||||
function (content) {
|
||||
var u = content.split("@@@~~~###~~~@@@");
|
||||
for (var i = 0; i < core.animates.length; ++i) {
|
||||
if (u[i] != '') {
|
||||
core.material.animates[core.animates[i]] = core.loader._loadAnimate(u[i]);
|
||||
if (u[i] != "") {
|
||||
core.material.animates[core.animates[i]] =
|
||||
core.loader._loadAnimate(u[i]);
|
||||
} else {
|
||||
console.error('无法找到动画文件' + core.animates[i] + '!');
|
||||
console.error("无法找到动画文件" + core.animates[i] + "!");
|
||||
}
|
||||
}
|
||||
}, "text/plain; charset=x-user-defined");
|
||||
},
|
||||
"text/plain; charset=x-user-defined"
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
core.animates.forEach(function (t) {
|
||||
core.http('GET', 'project/animates/' + t + ".animate?v=" + main.version, null, function (content) {
|
||||
core.http(
|
||||
"GET",
|
||||
"project/animates/" + t + ".animate?v=" + main.version,
|
||||
null,
|
||||
function (content) {
|
||||
core.material.animates[t] = core.loader._loadAnimate(content);
|
||||
}, function (e) {
|
||||
},
|
||||
function (e) {
|
||||
console.error(e);
|
||||
core.material.animates[t] = null;
|
||||
}, "text/plain; charset=x-user-defined")
|
||||
},
|
||||
"text/plain; charset=x-user-defined"
|
||||
);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
loader.prototype._loadAnimates_async = function (onprogress, onfinished) {
|
||||
this._loadFileFromZip('project/animates/animates.h5data', this._saveAnimate, true, onprogress, onfinished);
|
||||
}
|
||||
this._loadFileFromZip(
|
||||
"project/animates/animates.h5data",
|
||||
this._saveAnimate,
|
||||
true,
|
||||
onprogress,
|
||||
onfinished
|
||||
);
|
||||
};
|
||||
|
||||
loader.prototype._loadAnimates_chunked = function (chunks, makeOnProgress, makeOnFinished) {
|
||||
this._loadFileFromChunks(chunks, this._saveAnimate, true, makeOnProgress, makeOnFinished);
|
||||
}
|
||||
loader.prototype._loadAnimates_chunked = function (
|
||||
chunks,
|
||||
makeOnProgress,
|
||||
makeOnFinished
|
||||
) {
|
||||
this._loadFileFromChunks(
|
||||
chunks,
|
||||
this._saveAnimate,
|
||||
true,
|
||||
makeOnProgress,
|
||||
makeOnFinished
|
||||
);
|
||||
};
|
||||
|
||||
loader.prototype._saveAnimate = function (animates, onfinished) {
|
||||
for (var name in animates) {
|
||||
@ -409,7 +574,7 @@ loader.prototype._saveAnimate = function (animates, onfinished) {
|
||||
}
|
||||
}
|
||||
onfinished();
|
||||
}
|
||||
};
|
||||
|
||||
loader.prototype._loadAnimate = function (content) {
|
||||
try {
|
||||
@ -422,8 +587,7 @@ loader.prototype._loadAnimate = function (content) {
|
||||
content.bitmaps.forEach(function (t2) {
|
||||
if (!t2) {
|
||||
data.images.push(null);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
try {
|
||||
var image = new Image();
|
||||
image.src = t2;
|
||||
@ -433,31 +597,30 @@ loader.prototype._loadAnimate = function (content) {
|
||||
data.images.push(null);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
data.frame = content.frame_max;
|
||||
data.frames = [];
|
||||
content.frames.forEach(function (t2) {
|
||||
var info = [];
|
||||
t2.forEach(function (t3) {
|
||||
info.push({
|
||||
'index': t3[0],
|
||||
'x': t3[1],
|
||||
'y': t3[2],
|
||||
'zoom': t3[3],
|
||||
'opacity': t3[4],
|
||||
'mirror': t3[5] || 0,
|
||||
'angle': t3[6] || 0,
|
||||
})
|
||||
})
|
||||
index: t3[0],
|
||||
x: t3[1],
|
||||
y: t3[2],
|
||||
zoom: t3[3],
|
||||
opacity: t3[4],
|
||||
mirror: t3[5] || 0,
|
||||
angle: t3[6] || 0,
|
||||
});
|
||||
});
|
||||
data.frames.push(info);
|
||||
});
|
||||
return data;
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ------ 加载音乐和音效 ------ //
|
||||
|
||||
@ -467,22 +630,38 @@ loader.prototype._loadMusics = function () {
|
||||
});
|
||||
// 直接开始播放
|
||||
core.playBgm(main.startBgm);
|
||||
}
|
||||
};
|
||||
|
||||
loader.prototype._loadSounds_sync = function () {
|
||||
this._setStartLoadTipText("正在加载音效文件...");
|
||||
core.sounds.forEach(function (t) {
|
||||
core.loader.loadOneSound(t);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
loader.prototype._loadSounds_async = function (onprogress, onfinished) {
|
||||
this._loadFileFromZip('project/sounds/sounds.h5data', this._saveSounds, false, onprogress, onfinished);
|
||||
}
|
||||
this._loadFileFromZip(
|
||||
"project/sounds/sounds.h5data",
|
||||
this._saveSounds,
|
||||
false,
|
||||
onprogress,
|
||||
onfinished
|
||||
);
|
||||
};
|
||||
|
||||
loader.prototype._loadSounds_chunked = function (chunks, makeOnProgress, makeOnFinished) {
|
||||
this._loadFileFromChunks(chunks, this._saveSounds, false, makeOnProgress, makeOnFinished);
|
||||
}
|
||||
loader.prototype._loadSounds_chunked = function (
|
||||
chunks,
|
||||
makeOnProgress,
|
||||
makeOnFinished
|
||||
) {
|
||||
this._loadFileFromChunks(
|
||||
chunks,
|
||||
this._saveSounds,
|
||||
false,
|
||||
makeOnProgress,
|
||||
makeOnFinished
|
||||
);
|
||||
};
|
||||
|
||||
loader.prototype._saveSounds = function (data, onfinished) {
|
||||
// 延迟解析
|
||||
@ -494,25 +673,34 @@ loader.prototype._saveSounds = function (data, onfinished) {
|
||||
}
|
||||
onfinished();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
loader.prototype.loadOneMusic = function (name) {
|
||||
var music = new Audio();
|
||||
music.preload = 'none';
|
||||
if (main.bgmRemote) music.src = main.bgmRemoteRoot + core.firstData.name + '/' + name;
|
||||
else music.src = 'project/bgms/' + name;
|
||||
music.loop = 'loop';
|
||||
music.preload = "none";
|
||||
if (main.bgmRemote)
|
||||
music.src = main.bgmRemoteRoot + core.firstData.name + "/" + name;
|
||||
else music.src = "project/bgms/" + name;
|
||||
music.loop = "loop";
|
||||
core.material.bgms[name] = music;
|
||||
}
|
||||
};
|
||||
|
||||
loader.prototype.loadOneSound = function (name) {
|
||||
core.http('GET', 'project/sounds/' + name + "?v=" + main.version, null, function (data) {
|
||||
core.http(
|
||||
"GET",
|
||||
"project/sounds/" + name + "?v=" + main.version,
|
||||
null,
|
||||
function (data) {
|
||||
core.loader._loadOneSound_decodeData(name, data);
|
||||
}, function (e) {
|
||||
},
|
||||
function (e) {
|
||||
console.error(e);
|
||||
core.material.sounds[name] = null;
|
||||
}, null, 'arraybuffer');
|
||||
}
|
||||
},
|
||||
null,
|
||||
"arraybuffer"
|
||||
);
|
||||
};
|
||||
|
||||
loader.prototype._loadOneSound_decodeData = function (name, data) {
|
||||
if (data instanceof Blob) {
|
||||
@ -520,23 +708,26 @@ loader.prototype._loadOneSound_decodeData = function (name, data) {
|
||||
blobReader.init(function () {
|
||||
blobReader.readUint8Array(0, blobReader.size, function (uint8) {
|
||||
core.loader._loadOneSound_decodeData(name, uint8.buffer);
|
||||
})
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
core.musicStatus.audioContext.decodeAudioData(data, function (buffer) {
|
||||
core.musicStatus.audioContext.decodeAudioData(
|
||||
data,
|
||||
function (buffer) {
|
||||
core.material.sounds[name] = buffer;
|
||||
}, function (e) {
|
||||
console.error(e);
|
||||
core.material.sounds[name] = null;
|
||||
})
|
||||
}
|
||||
catch (e) {
|
||||
},
|
||||
function (e) {
|
||||
console.error(e);
|
||||
core.material.sounds[name] = null;
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
core.material.sounds[name] = null;
|
||||
}
|
||||
};
|
||||
|
||||
loader.prototype.loadBgm = function (name) {
|
||||
name = core.getMappedName(name);
|
||||
@ -547,8 +738,7 @@ loader.prototype.loadBgm = function (name) {
|
||||
var index = core.musicStatus.cachedBgms.indexOf(name);
|
||||
if (index >= 0) {
|
||||
core.musicStatus.cachedBgms.splice(index, 1);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// 预加载BGM
|
||||
this._preloadBgm(core.material.bgms[name]);
|
||||
// core.material.bgms[name].load();
|
||||
@ -559,18 +749,20 @@ loader.prototype.loadBgm = function (name) {
|
||||
}
|
||||
// 移动到缓存最前方
|
||||
core.musicStatus.cachedBgms.unshift(name);
|
||||
}
|
||||
};
|
||||
|
||||
loader.prototype._preloadBgm = function (bgm) {
|
||||
bgm.volume = 0;
|
||||
bgm.play();
|
||||
}
|
||||
};
|
||||
|
||||
loader.prototype.freeBgm = function (name) {
|
||||
name = core.getMappedName(name);
|
||||
if (!core.material.bgms[name]) return;
|
||||
// 从cachedBgms中删除
|
||||
core.musicStatus.cachedBgms = core.musicStatus.cachedBgms.filter(function (t) {
|
||||
core.musicStatus.cachedBgms = core.musicStatus.cachedBgms.filter(function (
|
||||
t
|
||||
) {
|
||||
return t != name;
|
||||
});
|
||||
// 清掉缓存
|
||||
@ -584,16 +776,35 @@ loader.prototype.freeBgm = function (name) {
|
||||
setTimeout(function () {
|
||||
core.loader.loadOneMusic(name);
|
||||
}, 3000);
|
||||
}
|
||||
};
|
||||
|
||||
loader.prototype._loadFileFromZip = function (url, save, convertToText, onprogress, onfinished) {
|
||||
core.unzip(url + '?v=' + main.version, function (data) {
|
||||
loader.prototype._loadFileFromZip = function (
|
||||
url,
|
||||
save,
|
||||
convertToText,
|
||||
onprogress,
|
||||
onfinished
|
||||
) {
|
||||
core.unzip(
|
||||
url + "?v=" + main.version,
|
||||
function (data) {
|
||||
save(data, onfinished);
|
||||
}, null, convertToText, onprogress);
|
||||
}
|
||||
},
|
||||
null,
|
||||
convertToText,
|
||||
onprogress
|
||||
);
|
||||
};
|
||||
|
||||
loader.prototype._loadFileFromChunks = async function (chunks, save, convertToText, makeOnProgress, makeOnFinished) {
|
||||
await Promise.all(chunks.map((chunk) => {
|
||||
loader.prototype._loadFileFromChunks = async function (
|
||||
chunks,
|
||||
save,
|
||||
convertToText,
|
||||
makeOnProgress,
|
||||
makeOnFinished
|
||||
) {
|
||||
await Promise.all(
|
||||
chunks.map((chunk) => {
|
||||
const onfinished = makeOnFinished(chunk);
|
||||
const onprogress = makeOnProgress(chunk);
|
||||
return new Promise((resolve) => {
|
||||
@ -602,5 +813,6 @@ loader.prototype._loadFileFromChunks = async function (chunks, save, convertToTe
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}));
|
||||
}
|
||||
})
|
||||
);
|
||||
};
|
||||
|
6
main.js
6
main.js
@ -909,7 +909,7 @@ main.prototype.listen = function () {
|
||||
////// 点击“开始游戏”时 //////
|
||||
main.dom.playGame.onclick = function () {
|
||||
main.dom.startButtons.style.display = "none";
|
||||
main.core.control.checkBgm();
|
||||
main.core.checkBgm();
|
||||
|
||||
if (main.levelChoose.length == 0) {
|
||||
core.events.startGame("");
|
||||
@ -922,13 +922,13 @@ main.prototype.listen = function () {
|
||||
|
||||
////// 点击“载入游戏”时 //////
|
||||
main.dom.loadGame.onclick = function () {
|
||||
main.core.control.checkBgm();
|
||||
main.core.checkBgm();
|
||||
main.core.load();
|
||||
};
|
||||
|
||||
////// 点击“录像回放”时 //////
|
||||
main.dom.replayGame.onclick = function () {
|
||||
main.core.control.checkBgm();
|
||||
main.core.checkBgm();
|
||||
main.core.chooseReplayFile();
|
||||
};
|
||||
|
||||
|
Binary file not shown.
BIN
project/bgms/theme.opus
Normal file
BIN
project/bgms/theme.opus
Normal file
Binary file not shown.
@ -905,7 +905,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
||||
"Halbmond.opus",
|
||||
"ed.opus",
|
||||
"op.opus",
|
||||
"theme.mp3"
|
||||
"theme.opus"
|
||||
],
|
||||
"sounds": [
|
||||
"aiy010000010.opus",
|
||||
@ -998,7 +998,6 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
||||
"aiy820000010.opus",
|
||||
"aiy820000020.opus",
|
||||
"attack.opus",
|
||||
"attack.opus",
|
||||
"bomb.opus",
|
||||
"cancel.opus",
|
||||
"centerFly.opus",
|
||||
@ -1062,7 +1061,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
||||
"饰品",
|
||||
"饰品"
|
||||
],
|
||||
"startBgm": "theme.mp3",
|
||||
"startBgm": "theme.opus",
|
||||
"styles": {
|
||||
"startBackground": "project/images/background.webp",
|
||||
"startVerticalBackground": "project/images/backgroundvertical.webp",
|
||||
@ -1446,7 +1445,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": "function(){\ncore.control.checkBgm()\n}"
|
||||
"function": "function(){\ncore.checkBgm()\n}"
|
||||
},
|
||||
{
|
||||
"type": "if",
|
||||
|
1430
project/events.js
1430
project/events.js
File diff suppressed because it is too large
Load Diff
@ -888,7 +888,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
core.openBook(true);
|
||||
break;
|
||||
case 71: // G:使用楼传器
|
||||
core.ui._drawViewMaps(core.floorIds.indexOf(core.status.floorId));
|
||||
flags.canMoveFloor = core.canMoveFloor()
|
||||
if (core.isPlaying()) core.ui._drawViewMaps(core.floorIds.indexOf(core.status.floorId));
|
||||
core.status.route.push("key:71");
|
||||
break;
|
||||
case 65: // A:读取自动存档(回退)
|
||||
core.doSL("autoSave", "load");
|
||||
|
@ -332,7 +332,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"text": "可以自由往来去过的楼层",
|
||||
"hideInReplay": true,
|
||||
"hideInToolbox": true,
|
||||
"useItemEffect": "//core.ui.drawFly(core.floorIds.indexOf(core.status.floorId));\ncore.ui._drawViewMaps(core.floorIds.indexOf(core.status.floorId));",
|
||||
"useItemEffect": "//core.ui.drawFly(core.floorIds.indexOf(core.status.floorId));\nflags.canMoveFloor = core.canMoveFloor()\nif (core.isPlaying()) core.ui._drawViewMaps(core.floorIds.indexOf(core.status.floorId));",
|
||||
"canUseItemEffect": "(function () {\n\tif (core.flags.flyNearStair && !core.nearStair() && !core.canMoveFloor())\n\t\treturn false;\n\treturn core.status.maps[core.status.floorId].canFlyFrom;\n})();"
|
||||
},
|
||||
"coin": {
|
||||
|
1611
project/plugins.js
1611
project/plugins.js
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user