kill main.log

This commit is contained in:
unamed 2022-02-02 00:32:58 +08:00
parent f7f3e66cd6
commit 1ad1e12df6
18 changed files with 2178 additions and 2162 deletions

View File

@ -326,17 +326,21 @@ editor_blockly = function () {
alert('已成功设置此属性为显示文章的预览属性!') alert('已成功设置此属性为显示文章的预览属性!')
break; break;
case 'waitContext_2': // 等待用户操作坐标预览 case 'waitContext_2': // 等待用户操作坐标预览
editor.uievent.previewUI([{"type": "fillRect", "x": obj.px[0], "y": obj.py[0], editor.uievent.previewUI([{
"type": "fillRect", "x": obj.px[0], "y": obj.py[0],
"width": "(" + obj.px[1] + ")-(" + obj.px[0] + ")", "height": "(" + obj.py[1] + ")-(" + obj.py[0] + ")", "width": "(" + obj.px[1] + ")-(" + obj.px[0] + ")", "height": "(" + obj.py[1] + ")-(" + obj.py[0] + ")",
"style": "rgba(255,0,0,0.5)"}]); "style": "rgba(255,0,0,0.5)"
}]);
break; break;
case 'showImage_s': // 显示图片 case 'showImage_s': // 显示图片
case 'showImage_1_s': case 'showImage_1_s':
if (obj.sloc) { if (obj.sloc) {
editor.uievent.previewUI([ editor.uievent.previewUI([
{ type: "setAttribute", alpha: obj.opacity }, { type: "setAttribute", alpha: obj.opacity },
{type: "drawImage", image: obj.image, x: obj.sloc[0], y: obj.sloc[1], w: obj.sloc[2], h: obj.sloc[3], {
x1: obj.loc[0], y1: obj.loc[1], w1: obj.loc[2], h1: obj.loc[3], reverse: obj.reverse} type: "drawImage", image: obj.image, x: obj.sloc[0], y: obj.sloc[1], w: obj.sloc[2], h: obj.sloc[3],
x1: obj.loc[0], y1: obj.loc[1], w1: obj.loc[2], h1: obj.loc[3], reverse: obj.reverse
}
]); ]);
} else { } else {
editor.uievent.previewUI([ editor.uievent.previewUI([
@ -358,8 +362,10 @@ editor_blockly = function () {
case 'floorOneImage': // 楼层贴图 case 'floorOneImage': // 楼层贴图
obj.w = obj.w / (obj.frame || 1); obj.w = obj.w / (obj.frame || 1);
editor.uievent.previewUI([ editor.uievent.previewUI([
{type: "drawImage", image: obj.name, x: obj.sx || 0, y: obj.sy || 0, w: obj.w, h: obj.h, {
x1: obj.x, y1: obj.y, w1: obj.w, h1: obj.h, reverse: obj.reverse} type: "drawImage", image: obj.name, x: obj.sx || 0, y: obj.sy || 0, w: obj.w, h: obj.h,
x1: obj.x, y1: obj.y, w1: obj.w, h1: obj.h, reverse: obj.reverse
}
]); ]);
break; break;
case 'previewUI_s': // 预览 case 'previewUI_s': // 预览
@ -370,7 +376,7 @@ editor_blockly = function () {
editor.uievent.previewUI([obj]); editor.uievent.previewUI([obj]);
} }
} }
} catch (e) {main.log(e);} } catch (ee) { console.error(ee) }
} }

View File

@ -431,8 +431,8 @@ editor_mappanel_wrapper = function (editor) {
else if (e.detail) else if (e.detail)
wheel(Math.sign(e.detail)); wheel(Math.sign(e.detail));
} }
catch (ee) { catch (e) {
console.log(ee); console.error(e);
} }
return false; return false;
} }

View File

@ -311,7 +311,7 @@ editor_uievent_wrapper = function (editor) {
index += Math.sign(e.wheelDelta); index += Math.sign(e.wheelDelta);
else if (e.detail) else if (e.detail)
index += Math.sign(e.detail); index += Math.sign(e.detail);
} catch (ee) { main.log(ee); } } catch (ee) { console.error(ee) }
index = core.clamp(index, 0, core.floorIds.length - 1); index = core.clamp(index, 0, core.floorIds.length - 1);
uievent.values.multipoints = []; uievent.values.multipoints = [];
uievent.setPoint(core.floorIds[index]); uievent.setPoint(core.floorIds[index]);

View File

@ -106,7 +106,7 @@ actions.prototype.doRegisteredAction = function (action) {
return true; return true;
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
main.log("ERROR in actions[" + actions[i].name + "]."); main.log("ERROR in actions[" + actions[i].name + "].");
} }
} }

View File

@ -88,7 +88,7 @@ control.prototype._setRequestAnimationFrame = function () {
core.doFunc(b.func, core.control, timestamp); core.doFunc(b.func, core.control, timestamp);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
main.log("ERROR in requestAnimationFrame[" + b.name + "]:已自动注销该项。"); main.log("ERROR in requestAnimationFrame[" + b.name + "]:已自动注销该项。");
core.unregisterAnimationFrame(b.name); core.unregisterAnimationFrame(b.name);
} }
@ -215,7 +215,7 @@ control.prototype._animationFrame_weather = function (timestamp) {
try { try {
core.doFunc(core.control.weathers[type].frameFunc, core.control, timestamp, core.animateFrame.weather.level); core.doFunc(core.control.weathers[type].frameFunc, core.control, timestamp, core.animateFrame.weather.level);
} catch (e) { } catch (e) {
main.log(e); console.error(e);
main.log("ERROR in weather[" + type + "]:已自动注销该项。"); main.log("ERROR in weather[" + type + "]:已自动注销该项。");
core.unregisterWeather(type); core.unregisterWeather(type);
} }
@ -1626,7 +1626,7 @@ control.prototype._doReplayAction = function (action) {
try { try {
if (core.doFunc(this.replayActions[i].func, this, action)) return true; if (core.doFunc(this.replayActions[i].func, this, action)) return true;
} catch (e) { } catch (e) {
main.log(e); console.error(e);
main.log("ERROR in replayActions[" + this.replayActions[i].name + "]:已自动注销该项。"); main.log("ERROR in replayActions[" + this.replayActions[i].name + "]:已自动注销该项。");
core.unregisterReplayAction(this.replayActions[i].name); core.unregisterReplayAction(this.replayActions[i].name);
} }
@ -2677,7 +2677,7 @@ control.prototype.setWeather = function (type, level) {
try { try {
core.doFunc(this.weathers[type].initFunc, this, level); core.doFunc(this.weathers[type].initFunc, this, level);
} catch (e) { } catch (e) {
main.log(e); console.error(e);
main.log("ERROR in weather[" + type + "]:已自动注销该项。"); main.log("ERROR in weather[" + type + "]:已自动注销该项。");
core.unregisterWeather(type); core.unregisterWeather(type);
} }
@ -2842,7 +2842,7 @@ control.prototype.playBgm = function (bgm, startTime) {
core.material.bgms[bgm].pause(); core.material.bgms[bgm].pause();
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
} }
return; return;
} }
@ -3002,7 +3002,7 @@ control.prototype.stopSound = function (id) {
else if (source.noteOff) source.noteOff(); else if (source.noteOff) source.noteOff();
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
} }
delete core.musicStatus.playingSounds[id]; delete core.musicStatus.playingSounds[id];
} }
@ -3060,7 +3060,7 @@ control.prototype.updateStatusBar_update = function () {
if (!core.control.noAutoEvents) core.checkAutoEvents(); if (!core.control.noAutoEvents) core.checkAutoEvents();
core.control._updateStatusBar_setToolboxIcon(); core.control._updateStatusBar_setToolboxIcon();
core.clearRouteFolding(); core.clearRouteFolding();
}); })
core.control.needUpdate = false; core.control.needUpdate = false;
core.control.noAutoEvents = true; core.control.noAutoEvents = true;
} }
@ -3253,7 +3253,7 @@ control.prototype._doResize = function (obj) {
try { try {
if (core.doFunc(this.resizes[i].func, this, obj)) return true; if (core.doFunc(this.resizes[i].func, this, obj)) return true;
} catch (e) { } catch (e) {
main.log(e); console.error(e);
main.log("ERROR in resizes[" + this.resizes[i].name + "]:已自动注销该项。"); main.log("ERROR in resizes[" + this.resizes[i].name + "]:已自动注销该项。");
this.unregisterResize(this.resizes[i].name); this.unregisterResize(this.resizes[i].name);
} }

View File

@ -486,7 +486,7 @@ core.prototype._init_plugins = function () {
plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1[name].apply(core.plugin); plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1[name].apply(core.plugin);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
main.log("无法初始化插件" + name); main.log("无法初始化插件" + name);
} }
} }

View File

@ -312,7 +312,7 @@ events.prototype.doSystemEvent = function (type, data, callback) {
return core.doFunc(this.systemEvents[type], this, data, callback); return core.doFunc(this.systemEvents[type], this, data, callback);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
main.log("ERROR in systemEvents[" + type + "]"); main.log("ERROR in systemEvents[" + type + "]");
} }
} }
@ -347,7 +347,7 @@ events.prototype.trigger = function (x, y, callback) {
core.clearRouteFolding(); core.clearRouteFolding();
try { try {
eval(block.event.script); eval(block.event.script);
} catch (e) { main.log(e); } } catch (ee) { console.error(ee) }
} }
// 碰触事件 // 碰触事件
@ -380,7 +380,7 @@ events.prototype._trigger_inAction = function (x, y) {
// 执行该点的脚本 // 执行该点的脚本
try { try {
eval(block.event.script); eval(block.event.script);
} catch (e) { main.log(e); } } catch (ee) { console.error(ee) }
// 碰触事件 // 碰触事件
if (block.event.event) { if (block.event.event) {
@ -952,7 +952,7 @@ events.prototype.doEvent = function (data, x, y, prefix) {
return core.doFunc(this.actions[type], this, data, x, y, prefix); return core.doFunc(this.actions[type], this, data, x, y, prefix);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
main.log("ERROR in actions[" + type + "]"); main.log("ERROR in actions[" + type + "]");
} }
} }
@ -1104,7 +1104,7 @@ events.prototype.insertCommonEvent = function (name, args, x, y, callback, addTo
try { try {
if (args[i] != null) if (args[i] != null)
core.setFlag('arg' + (i + 1), args[i]); core.setFlag('arg' + (i + 1), args[i]);
} catch (e) { main.log(e); } } catch (ee) { console.error(ee) }
} }
} }
@ -1826,7 +1826,7 @@ events.prototype._action_insert = function (data, x, y, prefix) {
try { try {
if (data.args[i] != null) if (data.args[i] != null)
core.setFlag('arg' + (i + 1), data.args[i]); core.setFlag('arg' + (i + 1), data.args[i]);
} catch (e) { main.log(e); } } catch (ee) { console.error(ee) }
} }
} }
var loc = this.__action_getLoc(data.loc, x, y, prefix); var loc = this.__action_getLoc(data.loc, x, y, prefix);
@ -2363,7 +2363,7 @@ events.prototype._action_function = function (data, x, y, prefix) {
eval('(' + func + ')()'); eval('(' + func + ')()');
} }
} catch (e) { } catch (e) {
main.log(e); console.error(e);
} }
if (!data.async) if (!data.async)
core.doAction(); core.doAction();

View File

@ -39,7 +39,7 @@ items.prototype.getItemEffect = function (itemId, itemNum) {
eval(itemEffect); eval(itemEffect);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
} }
} }
core.status.hero.statistics.hp += core.status.hero.hp - curr_hp; core.status.hero.statistics.hp += core.status.hero.hp - curr_hp;
@ -50,7 +50,7 @@ items.prototype.getItemEffect = function (itemId, itemNum) {
core.insertAction(useItemEvent); core.insertAction(useItemEvent);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
} }
} }
core.updateStatusBar(); core.updateStatusBar();
@ -70,7 +70,7 @@ items.prototype.getItemEffectTip = function (itemId) {
try { try {
return core.replaceText(itemEffectTip) || ""; return core.replaceText(itemEffectTip) || "";
} catch (e) { } catch (e) {
main.log(e); console.error(e);
return ""; return "";
} }
} }
@ -100,7 +100,7 @@ items.prototype._useItemEffect = function (itemId) {
eval(useItemEffect); eval(useItemEffect);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
} }
} }
var useItemEvent = core.material.items[itemId].useItemEvent; var useItemEvent = core.material.items[itemId].useItemEvent;
@ -109,7 +109,7 @@ items.prototype._useItemEffect = function (itemId) {
core.insertAction(useItemEvent); core.insertAction(useItemEvent);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
} }
} }
} }
@ -135,7 +135,7 @@ items.prototype.canUseItem = function (itemId) {
return eval(canUseItemEffect); return eval(canUseItemEffect);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
return false; return false;
} }
} }
@ -269,7 +269,7 @@ items.prototype.canEquip = function (equipId, hint) {
} }
} }
catch (e) { catch (e) {
console.log(e); console.error(e);
return false; return false;
} }
} }

View File

@ -263,7 +263,7 @@ loader.prototype.loadImage = function (dir, imgName, callback) {
callback(imgName, null); callback(imgName, null);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
} }
} }
@ -362,7 +362,7 @@ loader.prototype._loadAnimate = function (content) {
image.src = t2; image.src = t2;
data.images.push(image); data.images.push(image);
} catch (e) { } catch (e) {
main.log(e); console.error(e);
data.images.push(null); data.images.push(null);
} }
} }
@ -387,7 +387,7 @@ loader.prototype._loadAnimate = function (content) {
return data; return data;
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
return null; return null;
} }
} }
@ -463,7 +463,7 @@ loader.prototype._loadOneSound_decodeData = function (name, data) {
}) })
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
core.material.sounds[name] = null; core.material.sounds[name] = null;
} }
} }

View File

@ -198,7 +198,7 @@ utils.prototype.decompress = function (value) {
return JSON.parse(value); return JSON.parse(value);
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
} }
return null; return null;
} }
@ -222,7 +222,7 @@ utils.prototype.setLocalStorage = function (key, value) {
return true; return true;
} }
catch (e) { catch (e) {
main.log(e); console.error(e);
return false; return false;
} }
} }
@ -1035,7 +1035,7 @@ utils.prototype.readFileContent = function (content) {
try { try {
obj = JSON.parse(content); obj = JSON.parse(content);
} catch (e) { } catch (e) {
main.log(e) console.error(e)
} }
} }

27
main.js
View File

@ -331,8 +331,9 @@ main.prototype.setMainTipsText = function (text) {
main.dom.mainTips.innerHTML = text; main.dom.mainTips.innerHTML = text;
} }
main.prototype.log = function (e) { main.prototype.log = function (e, error) {
if (e) { if (e) {
if (error) return console.error(e);
if (main.core && main.core.platform && !main.core.platform.isPC) { if (main.core && main.core.platform && !main.core.platform.isPC) {
console.log((e.stack || e.toString())); console.log((e.stack || e.toString()));
} }
@ -405,7 +406,7 @@ main.prototype.listen = function () {
window.onresize = function () { window.onresize = function () {
try { try {
main.core.resize(); main.core.resize();
}catch (e) { main.log(e); } } catch (ee) { console.error(ee) }
} }
////// 在界面上按下某按键时 ////// ////// 在界面上按下某按键时 //////
@ -414,7 +415,7 @@ main.dom.body.onkeydown = function(e) {
if (main.dom.inputDiv.style.display == 'block') return; if (main.dom.inputDiv.style.display == 'block') return;
if (main.core && (main.core.isPlaying() || main.core.status.lockControl)) if (main.core && (main.core.isPlaying() || main.core.status.lockControl))
main.core.onkeyDown(e); main.core.onkeyDown(e);
} catch (ee) { main.log(ee); } } catch (ee) { console.error(ee) }
} }
////// 在界面上放开某按键时 ////// ////// 在界面上放开某按键时 //////
@ -450,7 +451,7 @@ main.dom.body.onkeyup = function(e) {
if (main.core && main.core.isPlaying && main.core.status && if (main.core && main.core.isPlaying && main.core.status &&
(main.core.isPlaying() || main.core.status.lockControl)) (main.core.isPlaying() || main.core.status.lockControl))
main.core.onkeyUp(e); main.core.onkeyUp(e);
} catch (ee) { main.log(ee); } } catch (ee) { console.error(ee) }
}; };
[main.dom.startButtons, main.dom.levelChooseButtons].forEach(function (dom) { [main.dom.startButtons, main.dom.levelChooseButtons].forEach(function (dom) {
@ -475,7 +476,7 @@ main.dom.data.onmousedown = function (e) {
var loc = main.core.actions._getClickLoc(e.clientX, e.clientY); var loc = main.core.actions._getClickLoc(e.clientX, e.clientY);
if (loc == null) return; if (loc == null) return;
main.core.ondown(loc); main.core.ondown(loc);
} catch (ee) { main.log(ee); } } catch (ee) { console.error(ee) }
} }
////// 鼠标移动时 ////// ////// 鼠标移动时 //////
@ -485,7 +486,7 @@ main.dom.data.onmousemove = function (e) {
var loc = main.core.actions._getClickLoc(e.clientX, e.clientY); var loc = main.core.actions._getClickLoc(e.clientX, e.clientY);
if (loc == null) return; if (loc == null) return;
main.core.onmove(loc); main.core.onmove(loc);
}catch (ee) { main.log(ee); } } catch (ee) { console.error(ee) }
} }
////// 鼠标放开时 ////// ////// 鼠标放开时 //////
@ -495,7 +496,7 @@ main.dom.data.onmouseup = function (e) {
var loc = main.core.actions._getClickLoc(e.clientX, e.clientY); var loc = main.core.actions._getClickLoc(e.clientX, e.clientY);
if (loc == null) return; if (loc == null) return;
main.core.onup(loc); main.core.onup(loc);
}catch (e) { main.log(e); } } catch (ee) { console.error(ee) }
} }
////// 鼠标滑轮滚动时 ////// ////// 鼠标滑轮滚动时 //////
@ -505,7 +506,7 @@ main.dom.data.onmousewheel = function(e) {
main.core.onmousewheel(Math.sign(e.wheelDelta)) main.core.onmousewheel(Math.sign(e.wheelDelta))
else if (e.detail) else if (e.detail)
main.core.onmousewheel(Math.sign(e.detail)); main.core.onmousewheel(Math.sign(e.detail));
} catch (ee) { main.log(ee); } } catch (ee) { console.error(ee) }
} }
////// 手指在触摸屏开始触摸时 ////// ////// 手指在触摸屏开始触摸时 //////
@ -516,7 +517,7 @@ main.dom.data.ontouchstart = function (e) {
if (loc == null) return; if (loc == null) return;
main.lastTouchLoc = loc; main.lastTouchLoc = loc;
main.core.ondown(loc); main.core.ondown(loc);
}catch (ee) { main.log(ee); } } catch (ee) { console.error(ee) }
} }
////// 手指在触摸屏上移动时 ////// ////// 手指在触摸屏上移动时 //////
@ -527,7 +528,7 @@ main.dom.data.ontouchmove = function (e) {
if (loc == null) return; if (loc == null) return;
main.lastTouchLoc = loc; main.lastTouchLoc = loc;
main.core.onmove(loc); main.core.onmove(loc);
}catch (ee) { main.log(ee); } } catch (ee) { console.error(ee) }
} }
////// 手指离开触摸屏时 ////// ////// 手指离开触摸屏时 //////
@ -539,7 +540,7 @@ main.dom.data.ontouchend = function (e) {
delete main.lastTouchLoc; delete main.lastTouchLoc;
main.core.onup(loc); main.core.onup(loc);
} catch (e) { } catch (e) {
main.log(e); console.error(e);
} }
} }
@ -548,7 +549,7 @@ main.dom.statusCanvas.onclick = function (e) {
e.preventDefault(); e.preventDefault();
main.core.onStatusBarClick(e); main.core.onStatusBarClick(e);
} catch (e) { } catch (e) {
main.log(e); console.error(e);
} }
} }
@ -781,7 +782,7 @@ main.dom.musicBtn.onclick = function () {
try { try {
if (main.core) if (main.core)
main.core.triggerBgm(); main.core.triggerBgm();
} catch (e) {main.log(e);} } catch (ee) { console.error(ee) }
} }
main.dom.enlargeBtn.onclick = function () { main.dom.enlargeBtn.onclick = function () {

View File

@ -1,3 +1,4 @@
/// <reference path="../runtime.d.ts" />
var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
{ {
"events": { "events": {
@ -1571,7 +1572,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
try { try {
eval(core.floors[core.status.floorId].parallelDo); eval(core.floors[core.status.floorId].parallelDo);
} catch (e) { } catch (e) {
main.log(e); console.error(e);
} }
} }
} }

View File

@ -1,3 +1,4 @@
/// <reference path="../runtime.d.ts" />
var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
{ {
"init": function () { "init": function () {
@ -1324,7 +1325,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
this._resetTitleCanvas = function () { this._resetTitleCanvas = function () {
if (!_isTitleCanvasEnabled) return; if (!_isTitleCanvasEnabled) return;
_isTitleCanvasEnabled = false; _isTitleCanvasEnabled = false;
window.onresize = function () { try { main.core.resize(); } catch (e) { main.log(e); } } window.onresize = function () { try { main.core.resize(); } catch (ee) { console.error(ee) } }
core.resize = function () { return core.control.resize(); } core.resize = function () { return core.control.resize(); }
core.resize(); core.resize();
core.actions._getClickLoc = _getClickLoc; core.actions._getClickLoc = _getClickLoc;

7
runtime.d.ts vendored
View File

@ -2924,6 +2924,13 @@ type core = {
} & control & events & loader & enemys & items & maps & ui & utils & icons & actions & plugins } & control & events & loader & enemys & items & maps & ui & utils & icons & actions & plugins
declare class main {
readonly core: core
/** 输出内容极不好用建议换成console*/
log(e: string | Error, error: boolean): void
}
declare let core: core declare let core: core
declare let flags: { [x: string]: any } declare let flags: { [x: string]: any }
declare let hero = core.status.hero declare let hero = core.status.hero