fix: 录像验证

This commit is contained in:
unanmed 2024-03-11 22:02:55 +08:00
parent 3f808a848c
commit d4467b4d11
7 changed files with 81 additions and 43 deletions

View File

@ -10,3 +10,4 @@ public/editor.html
keyCodes.ts
*.md
setting.ts
dist/project/data.js

View File

@ -3394,58 +3394,74 @@ control.prototype.screenFlash = function (
control.prototype.playBgm = function (bgm, startTime) {
bgm = core.getMappedName(bgm);
if (main.mode !== 'play') return;
Mota.require('var', 'bgm').changeTo(bgm, startTime);
Mota.r(() => {
Mota.require('var', 'bgm').changeTo(bgm, startTime);
});
};
////// 暂停背景音乐的播放 //////
control.prototype.pauseBgm = function () {
if (main.mode !== 'play') return;
Mota.require('var', 'bgm').pause();
Mota.r(() => {
Mota.require('var', 'bgm').pause();
});
};
////// 恢复背景音乐的播放 //////
control.prototype.resumeBgm = function (resumeTime) {
if (main.mode !== 'play') return;
Mota.require('var', 'bgm').resume();
Mota.r(() => {
Mota.require('var', 'bgm').resume();
});
};
////// 更改背景音乐的播放 //////
control.prototype.triggerBgm = function () {
if (main.mode !== 'play') return;
const bgm = Mota.require('var', 'bgm');
bgm.disable = !bgm.disable;
Mota.r(() => {
const bgm = Mota.require('var', 'bgm');
bgm.disable = !bgm.disable;
if (!bgm.disable) this.resumeBgm();
else this.pauseBgm();
if (!bgm.disable) this.resumeBgm();
else this.pauseBgm();
});
};
// todo: deprecate playSound, stopSound, getPlayingSounds
////// 播放音频 //////
control.prototype.playSound = function (sound, pitch, callback) {
sound = core.getMappedName(sound);
Mota.require('var', 'sound').play(sound, callback);
Mota.r(() => {
sound = core.getMappedName(sound);
Mota.require('var', 'sound').play(sound, callback);
});
};
////// 停止所有音频 //////
control.prototype.stopSound = function (id) {
if (typeof id === 'number') Mota.require('var', 'sound').stop(id);
else Mota.require('var', 'sound').stopAll();
Mota.r(() => {
if (typeof id === 'number') Mota.require('var', 'sound').stop(id);
else Mota.require('var', 'sound').stopAll();
});
};
////// 获得当前正在播放的所有指定音效的id列表 //////
control.prototype.getPlayingSounds = function (name) {
name = core.getMappedName(name);
return Mota.require('var', 'sound').getPlaying(name);
Mota.r(() => {
name = core.getMappedName(name);
return Mota.require('var', 'sound').getPlaying(name);
});
};
////// 检查bgm状态 //////
control.prototype.checkBgm = function () {
const bgm = Mota.require('var', 'bgm');
if (bgm.disable) {
bgm.pause();
} else if (!bgm.playing) {
bgm.changeTo(bgm.now ?? main.startBgm);
}
Mota.r(() => {
const bgm = Mota.require('var', 'bgm');
if (bgm.disable) {
bgm.pause();
} else if (!bgm.playing) {
bgm.changeTo(bgm.now ?? main.startBgm);
}
});
};
///// 设置屏幕放缩 //////

View File

@ -306,6 +306,7 @@ core.prototype.initSync = function (coreData, callback) {
this._forwardFuncs();
for (var key in coreData) core[key] = coreData[key];
this._loadGameProcessSync();
this._loadPluginSync();
this._init_flags();
this._init_platform();
this._init_others();
@ -319,6 +320,18 @@ core.prototype._loadPluginAsync = async function () {
if (!main.useCompress) {
await main.loadScript(`project/plugins.js?v=${main.version}`);
}
this._initPlugins();
};
core.prototype._loadPluginSync = function () {
if (main.useCompress) main.loadMod('project', 'project', () => 0);
else {
main.pureData.forEach(v => main.loadMod('project', v, () => 0));
}
this._initPlugins();
};
core.prototype._initPlugins = function () {
for (const [key, value] of Object.entries(
plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1
)) {
@ -331,10 +344,6 @@ core.prototype._loadPluginAsync = async function () {
}
};
core.prototype._loadPluginSync = function () {
main.loadMod('project', 'plugins', () => 0);
};
core.prototype._loadGameProcess = async function () {
// 加载游戏进程代码
if (main.pluginUseCompress && main.replayChecking) {

View File

@ -486,7 +486,9 @@ loader.prototype._loadMusic_sync = function () {
core.loader.loadOneSound(t);
});
// 直接开始播放
core.playBgm(main.startBgm);
Mota.r(() => {
core.playBgm(main.startBgm);
});
};
loader.prototype._loadMusic_async = function (onprogress, onfinished) {
@ -525,12 +527,14 @@ loader.prototype.loadOneMusic = function (name) {
music.loop = 'loop';
core.material.bgms[name] = music;
} else {
if (!main.renderLoaded) {
Mota.require('var', 'hook').once('renderLoaded', () => {
Mota.require('var', 'bgm').add(`bgms.${name}`, music);
});
}
Mota.require('var', 'bgm').add(`bgms.${name}`, music);
Mota.r(() => {
if (!main.renderLoaded) {
Mota.require('var', 'hook').once('renderLoaded', () => {
Mota.require('var', 'bgm').add(`bgms.${name}`, music);
});
}
Mota.require('var', 'bgm').add(`bgms.${name}`, music);
});
}
};
@ -543,15 +547,17 @@ loader.prototype.loadOneSound = function (name) {
if (main.mode === 'editor') {
core.loader._loadOneSound_decodeData(name, data);
} else {
if (!main.renderLoaded) {
Mota.require('var', 'hook').once('renderLoaded', () => {
Mota.r(() => {
if (!main.renderLoaded) {
Mota.require('var', 'hook').once('renderLoaded', () => {
const sound = Mota.require('var', 'sound');
sound.add(`sounds.${name}`, data);
});
} else {
const sound = Mota.require('var', 'sound');
sound.add(`sounds.${name}`, data);
});
} else {
const sound = Mota.require('var', 'sound');
sound.add(`sounds.${name}`, data);
}
}
});
}
},
function (e) {

View File

@ -298,10 +298,15 @@ main.prototype.loadSync = function (mode, callback) {
});
core.initSync(coreData, callback);
main.loading.emit('coreLoaded');
main.loading.emit('coreInit');
core.initStatus.maps = core.maps._initMaps();
core.resize();
main.core = core;
core.completeAchievement = () => 0;
core.plugin = { drawLight: 0 };
};
main.prototype.loadAsync = async function (mode, callback) {

View File

@ -114,7 +114,7 @@ class GameListener extends EventEmitter<ListenerEvent> {
constructor() {
super();
if (main.replayChecking) return;
if (!!window.core) {
this.init();
} else {

View File

@ -31,10 +31,11 @@ export function init() {
floor.enemy.calMapDamage();
core.status.damage.data = [];
floor.enemy.render(true);
getItemDetail(floorId, onMap); // 宝石血瓶详细信息
this.drawDamage(ctx, floorId);
Mota.r(() => {
floor.enemy.render(true);
getItemDetail(floorId, onMap); // 宝石血瓶详细信息
this.drawDamage(ctx, floorId);
});
};
}