mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-10-29 10:22:59 +08:00
fix: 录像验证
This commit is contained in:
parent
991d94568b
commit
0856c12aee
@ -48,6 +48,7 @@ export function patchDamage() {
|
||||
}
|
||||
|
||||
function renderThumbnailDamage(col: EnemyCollection) {
|
||||
if (main.replayChecking) return;
|
||||
core.status.damage.data = [];
|
||||
core.status.damage.extraData = [];
|
||||
|
||||
|
||||
@ -2,23 +2,50 @@
|
||||
|
||||
export function initUI() {
|
||||
if (main.mode === 'editor') return;
|
||||
const { mainUi, fixedUi, mainSetting } = Mota.require('@motajs/legacy-ui');
|
||||
if (!main.replayChecking) {
|
||||
const { mainUi, fixedUi, mainSetting } =
|
||||
Mota.require('@motajs/legacy-ui');
|
||||
|
||||
ui.prototype.drawBook = function () {
|
||||
if (!core.isReplaying()) return mainUi.open('book');
|
||||
};
|
||||
ui.prototype.drawBook = function () {
|
||||
if (!core.isReplaying()) return mainUi.open('book');
|
||||
};
|
||||
|
||||
ui.prototype._drawToolbox = function () {
|
||||
if (!core.isReplaying()) return mainUi.open('toolbox');
|
||||
};
|
||||
ui.prototype._drawToolbox = function () {
|
||||
if (!core.isReplaying()) return mainUi.open('toolbox');
|
||||
};
|
||||
|
||||
ui.prototype._drawEquipbox = function () {
|
||||
if (!core.isReplaying()) return mainUi.open('equipbox');
|
||||
};
|
||||
ui.prototype._drawEquipbox = function () {
|
||||
if (!core.isReplaying()) return mainUi.open('equipbox');
|
||||
};
|
||||
|
||||
ui.prototype.drawFly = function () {
|
||||
if (!core.isReplaying()) return mainUi.open('fly');
|
||||
};
|
||||
ui.prototype.drawFly = function () {
|
||||
if (!core.isReplaying()) return mainUi.open('fly');
|
||||
};
|
||||
|
||||
control.prototype.showStatusBar = function () {
|
||||
if (main.mode === 'editor') return;
|
||||
core.removeFlag('hideStatusBar');
|
||||
if (mainSetting.getValue('ui.tips')) {
|
||||
if (!fixedUi.hasName('tips')) {
|
||||
fixedUi.open('tips');
|
||||
}
|
||||
}
|
||||
core.updateStatusBar();
|
||||
};
|
||||
|
||||
control.prototype.hideStatusBar = function (showToolbox) {
|
||||
if (main.mode === 'editor') return;
|
||||
|
||||
// 如果原本就是隐藏的,则先显示
|
||||
if (!core.domStyle.showStatusBar) this.showStatusBar();
|
||||
if (core.isReplaying()) showToolbox = true;
|
||||
fixedUi.closeByName('tips');
|
||||
|
||||
core.setFlag('hideStatusBar', true);
|
||||
core.setFlag('showToolbox', showToolbox || null);
|
||||
core.updateStatusBar();
|
||||
};
|
||||
}
|
||||
|
||||
control.prototype.updateStatusBar_update = function () {
|
||||
core.control.updateNextFrame = false;
|
||||
@ -29,28 +56,4 @@ export function initUI() {
|
||||
core.control.noAutoEvents = true;
|
||||
Mota.require('@user/data-base').hook.emit('statusBarUpdate');
|
||||
};
|
||||
|
||||
control.prototype.showStatusBar = function () {
|
||||
if (main.mode === 'editor') return;
|
||||
core.removeFlag('hideStatusBar');
|
||||
if (mainSetting.getValue('ui.tips')) {
|
||||
if (!fixedUi.hasName('tips')) {
|
||||
fixedUi.open('tips');
|
||||
}
|
||||
}
|
||||
core.updateStatusBar();
|
||||
};
|
||||
|
||||
control.prototype.hideStatusBar = function (showToolbox) {
|
||||
if (main.mode === 'editor') return;
|
||||
|
||||
// 如果原本就是隐藏的,则先显示
|
||||
if (!core.domStyle.showStatusBar) this.showStatusBar();
|
||||
if (core.isReplaying()) showToolbox = true;
|
||||
fixedUi.closeByName('tips');
|
||||
|
||||
core.setFlag('hideStatusBar', true);
|
||||
core.setFlag('showToolbox', showToolbox || null);
|
||||
core.updateStatusBar();
|
||||
};
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ editor_uievent_wrapper = function (editor) {
|
||||
}
|
||||
core.saveCanvas('uievent');
|
||||
core.status.event.selection = data.selected || 0;
|
||||
core.drawChoices(core.replaceText(data.text), data.choices, data.width, 'uievent');
|
||||
core.drawChoices2(core.replaceText(data.text), data.choices, data.width, 'uievent');
|
||||
core.status.event.selection = null;
|
||||
core.loadCanvas('uievent');
|
||||
return;
|
||||
|
||||
@ -320,6 +320,8 @@ core.prototype.initSync = function (coreData, callback) {
|
||||
this._init_platform();
|
||||
this._init_others();
|
||||
|
||||
core.initStatus.maps = core.maps._initMaps();
|
||||
|
||||
core.loader._load(function () {
|
||||
core._afterLoadResources(callback);
|
||||
});
|
||||
|
||||
@ -42,7 +42,7 @@ events.prototype._startGame_start = function (hard, seed, route, callback) {
|
||||
core.firstData.hero,
|
||||
hard,
|
||||
null,
|
||||
core.cloneArray(core.initStatus.maps)
|
||||
core.clone(core.initStatus.maps)
|
||||
);
|
||||
core.setHeroLoc('x', -1);
|
||||
core.setHeroLoc('y', -1);
|
||||
@ -1566,6 +1566,10 @@ events.prototype.__action_doAsyncFunc = function (isAsync, func) {
|
||||
};
|
||||
|
||||
events.prototype._action_text = function (data) {
|
||||
if (main.replayChecking) {
|
||||
core.doAction();
|
||||
return;
|
||||
}
|
||||
if (this.__action_checkReplaying()) return;
|
||||
const Store = Mota.require('@user/client-modules').TextboxStore;
|
||||
const { textbox = 'main-textbox', text, icon = 'none', title = '' } = data;
|
||||
@ -1595,6 +1599,10 @@ events.prototype._action_text = function (data) {
|
||||
};
|
||||
|
||||
events.prototype._action_autoText = function (data) {
|
||||
if (main.replayChecking) {
|
||||
core.doAction();
|
||||
return;
|
||||
}
|
||||
if (this.__action_checkReplaying()) return;
|
||||
const Store = Mota.require('@user/client-modules').TextboxStore;
|
||||
const { textbox = 'main-textbox', text, icon = 'none', title = '' } = data;
|
||||
@ -1641,6 +1649,10 @@ events.prototype._action__label = function (data, x, y, prefix) {
|
||||
};
|
||||
|
||||
events.prototype._action_setText = function (data) {
|
||||
if (main.replayChecking) {
|
||||
core.doAction();
|
||||
return;
|
||||
}
|
||||
const isNil = value => value === null || value === void 0;
|
||||
const { textbox = 'main-textbox' } = data;
|
||||
const Store = Mota.require('@user/client-modules').TextboxStore;
|
||||
@ -1743,7 +1755,7 @@ events.prototype._action_confirm = function (data, x, y, prefix) {
|
||||
};
|
||||
|
||||
events.prototype._action_choices = function (data, x, y, prefix) {
|
||||
core.ui.drawChoices(
|
||||
core.ui.drawChoices2(
|
||||
core.replaceText(data.text, prefix),
|
||||
data.choices,
|
||||
data.width
|
||||
|
||||
@ -3682,112 +3682,12 @@ maps.prototype._moveDetachedBlock = function (
|
||||
opacity,
|
||||
canvases
|
||||
) {
|
||||
var height = blockInfo.height,
|
||||
posX = blockInfo.posX,
|
||||
posY = blockInfo.posY,
|
||||
image = blockInfo.image;
|
||||
var headCanvas = canvases.headCanvas,
|
||||
bodyCanvas = canvases.bodyCanvas,
|
||||
damageCanvas = canvases.damageCanvas;
|
||||
if (headCanvas) {
|
||||
core.dymCanvas[headCanvas].clearRect(0, 0, 32, height);
|
||||
core.dymCanvas[headCanvas].drawImage(
|
||||
image,
|
||||
posX * 32,
|
||||
posY * height,
|
||||
32,
|
||||
height - 32,
|
||||
0,
|
||||
0,
|
||||
32,
|
||||
height - 32
|
||||
);
|
||||
core.relocateCanvas(
|
||||
headCanvas,
|
||||
nowX - core.bigmap.offsetX,
|
||||
nowY + 32 - height - core.bigmap.offsetY
|
||||
);
|
||||
core.setOpacity(headCanvas, opacity);
|
||||
}
|
||||
if (bodyCanvas) {
|
||||
if (blockInfo.bigImage) {
|
||||
var face = blockInfo.face;
|
||||
if (!blockInfo.faceIds) face = 'down';
|
||||
else if (!blockInfo.faceIds[face]) {
|
||||
// 维持此时朝向
|
||||
face = 'down';
|
||||
for (var f in blockInfo.faceIds) {
|
||||
if (blockInfo.faceIds[f] == blockInfo.id) {
|
||||
face = f;
|
||||
}
|
||||
}
|
||||
}
|
||||
var bigImageInfo = this._getBigImageInfo(
|
||||
blockInfo.bigImage,
|
||||
face,
|
||||
blockInfo.posX
|
||||
);
|
||||
var per_width = bigImageInfo.per_width,
|
||||
per_height = bigImageInfo.per_height;
|
||||
core.dymCanvas[bodyCanvas].clearRect(
|
||||
0,
|
||||
0,
|
||||
bigImageInfo.per_width,
|
||||
bigImageInfo.per_height
|
||||
);
|
||||
core.dymCanvas[bodyCanvas].drawImage(
|
||||
blockInfo.bigImage,
|
||||
bigImageInfo.sx,
|
||||
bigImageInfo.sy,
|
||||
per_width,
|
||||
per_height,
|
||||
0,
|
||||
0,
|
||||
per_width,
|
||||
per_height
|
||||
);
|
||||
core.relocateCanvas(
|
||||
bodyCanvas,
|
||||
nowX - core.bigmap.offsetX + bigImageInfo.dx,
|
||||
nowY - core.bigmap.offsetY + bigImageInfo.dy
|
||||
);
|
||||
core.setOpacity(bodyCanvas, opacity);
|
||||
} else {
|
||||
core.dymCanvas[bodyCanvas].clearRect(0, 0, 32, 32);
|
||||
core.dymCanvas[bodyCanvas].drawImage(
|
||||
image,
|
||||
posX * 32,
|
||||
posY * height + height - 32,
|
||||
32,
|
||||
32,
|
||||
0,
|
||||
0,
|
||||
32,
|
||||
32
|
||||
);
|
||||
core.relocateCanvas(
|
||||
bodyCanvas,
|
||||
nowX - core.bigmap.offsetX,
|
||||
nowY - core.bigmap.offsetY
|
||||
);
|
||||
core.setOpacity(bodyCanvas, opacity);
|
||||
}
|
||||
}
|
||||
if (damageCanvas) {
|
||||
core.relocateCanvas(
|
||||
damageCanvas,
|
||||
nowX - core.bigmap.offsetX,
|
||||
nowY - core.bigmap.offsetY
|
||||
);
|
||||
core.setOpacity(damageCanvas, opacity);
|
||||
}
|
||||
// Deprecated.
|
||||
};
|
||||
|
||||
////// 删除独立的block canvas //////
|
||||
maps.prototype._deleteDetachedBlock = function (canvases) {
|
||||
core.deleteCanvas(canvases.headCanvas);
|
||||
core.deleteCanvas(canvases.bodyCanvas);
|
||||
core.deleteCanvas(canvases.damageCanvas);
|
||||
// Deprecated.
|
||||
};
|
||||
|
||||
maps.prototype._getAndRemoveBlock = function (x, y) {
|
||||
|
||||
@ -2228,7 +2228,7 @@ ui.prototype.textImage = function (content, lineHeight) {
|
||||
};
|
||||
|
||||
////// 绘制一个选项界面 //////
|
||||
ui.prototype.drawChoices = async function (content, choices, width, noRoute) {
|
||||
ui.prototype.drawChoices2 = async function (content, choices, width, noRoute) {
|
||||
if (main.replayChecking) {
|
||||
const selected = (() => {
|
||||
const route = core.status.replay.toReplay[0];
|
||||
@ -2238,6 +2238,7 @@ ui.prototype.drawChoices = async function (content, choices, width, noRoute) {
|
||||
return Number(route.slice(8));
|
||||
}
|
||||
})();
|
||||
core.status.replay.toReplay.shift();
|
||||
core.insertAction(choices[selected].action);
|
||||
core.doAction();
|
||||
} else {
|
||||
@ -2295,6 +2296,7 @@ ui.prototype.drawConfirmBox = async function (
|
||||
return Number(route.slice(8)) === 1;
|
||||
}
|
||||
})();
|
||||
core.status.replay.toReplay.shift();
|
||||
if (confirm) {
|
||||
yesCallback?.();
|
||||
} else {
|
||||
|
||||
@ -109,7 +109,7 @@ function main() {
|
||||
this.canvas = {};
|
||||
|
||||
this.__VERSION__ = '2.10.0';
|
||||
this.__VERSION_CODE__ = 510;
|
||||
this.__VERSION_CODE__ = 610;
|
||||
}
|
||||
// >>>> body end
|
||||
|
||||
@ -183,15 +183,12 @@ main.prototype.loadSync = function (mode, callback) {
|
||||
coreData[t] = main[t];
|
||||
});
|
||||
|
||||
core.initSync(coreData, callback);
|
||||
core.initSync(coreData, () => {});
|
||||
main.loading.emit('coreInit');
|
||||
core.initStatus.maps = core.maps._initMaps();
|
||||
core.resize();
|
||||
main.core = core;
|
||||
|
||||
core.completeAchievement = () => 0;
|
||||
|
||||
core.plugin = { drawLight: 0 };
|
||||
callback?.();
|
||||
};
|
||||
|
||||
main.prototype.loadAsync = async function (mode, callback) {
|
||||
|
||||
@ -185,9 +185,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
||||
},
|
||||
"flags": {},
|
||||
"followers": [],
|
||||
"steps": 0,
|
||||
"magicDef": 0,
|
||||
"magicRed": 0
|
||||
"steps": 0
|
||||
},
|
||||
"startCanvas": [
|
||||
{
|
||||
|
||||
@ -17,6 +17,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
|
||||
core.status.played = true;
|
||||
// 初始化人物,图标,统计信息
|
||||
core.status.hero = core.clone(hero);
|
||||
core.status.hero.buff ??= {};
|
||||
window.hero = core.status.hero;
|
||||
window.flags = core.status.hero.flags;
|
||||
core.events.setHeroIcon(core.status.hero.image, true);
|
||||
@ -56,27 +57,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
|
||||
} else {
|
||||
flags.autoSkill ??= true;
|
||||
}
|
||||
|
||||
// 兼容性调整
|
||||
const h = core.status.hero;
|
||||
if (h.magicDef === void 0 || h.magicDef === null) {
|
||||
h.magicDef = 0;
|
||||
}
|
||||
if (!core.status.hero.buff) {
|
||||
const buff = {};
|
||||
core.status.hero.buff = buff;
|
||||
const toDelete = [];
|
||||
for (const [key, value] of Object.entries(flags)) {
|
||||
if (/__\w+_buff__/.test(key)) {
|
||||
const name = key.slice(2, -7);
|
||||
buff[name] = value;
|
||||
toDelete.push(key);
|
||||
}
|
||||
}
|
||||
toDelete.forEach(v => {
|
||||
delete flags[v];
|
||||
});
|
||||
}
|
||||
},
|
||||
win: function (reason, norank, noexit) {
|
||||
// 游戏获胜事件
|
||||
@ -88,12 +68,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
|
||||
core.status.extraEvent = core.clone(core.status.event);
|
||||
}
|
||||
|
||||
if (reason === '智慧之始') {
|
||||
core.status.hero.hp +=
|
||||
core.itemCount('yellowKey') * 5000 +
|
||||
core.itemCount('blueKey') * 15000;
|
||||
}
|
||||
|
||||
// 游戏获胜事件
|
||||
core.ui.closePanel();
|
||||
var replaying = core.isReplaying();
|
||||
@ -171,21 +145,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
|
||||
if (bgm instanceof Array) bgm = bgm[0];
|
||||
if (!core.hasFlag('__bgm__')) core.playBgm(bgm);
|
||||
}
|
||||
// 更改画面色调
|
||||
var color = core.getFlag('__color__', null);
|
||||
if (!color && core.status.maps[floorId].color)
|
||||
color = core.status.maps[floorId].color;
|
||||
core.clearMap('curtain');
|
||||
core.status.curtainColor = color;
|
||||
if (color)
|
||||
core.fillRect(
|
||||
'curtain',
|
||||
0,
|
||||
0,
|
||||
core._PX_,
|
||||
core._PY_,
|
||||
core.arrayToRGBA(color)
|
||||
);
|
||||
// 更改天气
|
||||
var weather = core.getFlag('__weather__', null);
|
||||
if (!weather && core.status.maps[floorId].weather)
|
||||
@ -234,8 +193,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
|
||||
core.visitFloor(floorId);
|
||||
}
|
||||
}
|
||||
// if (!flags.debug && !main.replayChecking)
|
||||
// Mota.require('completion_r').checkVisitedFloor();
|
||||
Mota.require('@user/data-base').hook.emit(
|
||||
'afterChangeFloor',
|
||||
floorId
|
||||
@ -348,16 +305,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
|
||||
|
||||
core.removeFlag('__fromLoad__');
|
||||
if (callback) callback();
|
||||
|
||||
Mota.r(() => {
|
||||
if (flags.onChase) {
|
||||
const chase = Mota.require(
|
||||
'@user/legacy-plugin-client'
|
||||
);
|
||||
const controller = chase.initChase(0);
|
||||
controller.start(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Mota.require('@user/data-base').hook.emit('loadData');
|
||||
|
||||
@ -13,6 +13,8 @@ import { RequiredData, RequiredIconsData, ResourceType } from './types';
|
||||
import { splitResource, SplittedResource } from './build-resource';
|
||||
import { formatSize } from './utils';
|
||||
|
||||
const DEBUG_REPLAY = true;
|
||||
|
||||
const ansi = {
|
||||
clear: '\x1b[2J\x1b[0f'
|
||||
};
|
||||
@ -92,7 +94,8 @@ async function buildData(outDir: string, entry: string) {
|
||||
name: 'ProcessData',
|
||||
fileName: 'data',
|
||||
formats: ['iife']
|
||||
}
|
||||
},
|
||||
minify: !DEBUG_REPLAY
|
||||
}
|
||||
} satisfies UserConfig);
|
||||
|
||||
|
||||
6
src/types/declaration/ui.d.ts
vendored
6
src/types/declaration/ui.d.ts
vendored
@ -759,10 +759,10 @@ interface Ui {
|
||||
textImage(content: string, lineHeight?: number): HTMLCanvasElement;
|
||||
|
||||
/**
|
||||
* @deprecated 已失效,考虑换用新的渲染系统中的 `getChoices` 接口\
|
||||
* 绘制一个选项界面
|
||||
* @deprecated 可使用,考虑换用新的渲染系统中的 `getChoices` 接口\
|
||||
* 绘制一个选项界面。不用 drawChoices 命名是为了避免录像验证问题。
|
||||
*/
|
||||
drawChoices(
|
||||
drawChoices2(
|
||||
content: string,
|
||||
choices: object[],
|
||||
width?: number,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user