main.log &&

This commit is contained in:
ckcz123 2019-01-16 19:09:42 +08:00
parent 2906d2cb7e
commit 3de7cae269
11 changed files with 72 additions and 53 deletions

View File

@ -56,7 +56,7 @@
callback(null, data); callback(null, data);
} }
}, function (e) { }, function (e) {
console.log(e); main.log(e);
callback(e+":请检查启动服务是否处于正常运行状态。"); callback(e+":请检查启动服务是否处于正常运行状态。");
}, "text/plain; charset=x-user-defined"); }, "text/plain; charset=x-user-defined");
} }

View File

@ -1851,7 +1851,7 @@ core.insertAction([
try { try {
eval(core.floors[core.status.floorId].parallelDo); eval(core.floors[core.status.floorId].parallelDo);
} catch (e) { } catch (e) {
console.log(e); main.log(e);
} }
} }

View File

@ -275,7 +275,7 @@ control.prototype.setRequestAnimationFrame = function () {
} }
} }
catch (e) { catch (e) {
console.log(e); main.log(e);
} }
}); });
} }
@ -2206,7 +2206,7 @@ control.prototype.doSL = function (id, type) {
if (id == 'autoSave') core.saves.autosave.data = core.clone(data); if (id == 'autoSave') core.saves.autosave.data = core.clone(data);
afterGet(data); afterGet(data);
}, function(err) { }, function(err) {
console.log(err); main.log(err);
alert("无效的存档"); alert("无效的存档");
}) })
} }
@ -2248,7 +2248,7 @@ control.prototype.doSL = function (id, type) {
if (id == 'autoSave') core.saves.autosave.data = core.clone(data); if (id == 'autoSave') core.saves.autosave.data = core.clone(data);
afterGet(data); afterGet(data);
}, function(err) { }, function(err) {
console.log(err); main.log(err);
alert("无效的存档"); alert("无效的存档");
}) })
} }
@ -2425,7 +2425,7 @@ control.prototype.getSaves = function (index, callback) {
core.getLocalForage("save"+index, null, function(data) { core.getLocalForage("save"+index, null, function(data) {
if (core.isset(callback)) callback(data); if (core.isset(callback)) callback(data);
}, function(err) { }, function(err) {
console.log(err); main.log(err);
if (core.isset(callback)) if (core.isset(callback))
callback(null); callback(null);
}) })
@ -2445,7 +2445,7 @@ control.prototype.getSaves = function (index, callback) {
saves.push(data); saves.push(data);
load(index+1, callback); load(index+1, callback);
}, function(err) { }, function(err) {
console.log(err); main.log(err);
load(index+1, callback); load(index+1, callback);
}) })
} }
@ -2556,7 +2556,7 @@ control.prototype.playBgm = function (bgm) {
core.material.bgms[bgm].pause(); core.material.bgms[bgm].pause();
} }
catch (e) { catch (e) {
console.log(e); main.log(e);
} }
return; return;
} }
@ -2589,7 +2589,7 @@ control.prototype.playBgm = function (bgm) {
} }
catch (e) { catch (e) {
console.log("无法播放BGM "+bgm); console.log("无法播放BGM "+bgm);
console.log(e); main.log(e);
core.musicStatus.playingBgm = null; core.musicStatus.playingBgm = null;
} }
} }
@ -2604,7 +2604,7 @@ control.prototype.pauseBgm = function () {
} }
catch (e) { catch (e) {
console.log("无法暂停BGM"); console.log("无法暂停BGM");
console.log(e); main.log(e);
} }
this.setMusicBtn(); this.setMusicBtn();
@ -2620,7 +2620,7 @@ control.prototype.resumeBgm = function () {
} }
catch (e) { catch (e) {
console.log("无法恢复BGM"); console.log("无法恢复BGM");
console.log(e); main.log(e);
} }
this.setMusicBtn(); this.setMusicBtn();
} }
@ -2666,7 +2666,7 @@ control.prototype.playSound = function (sound) {
source.noteOn(0); source.noteOn(0);
} }
catch (ee) { catch (ee) {
console.log(ee); main.log(ee);
} }
} }
} }
@ -2677,7 +2677,7 @@ control.prototype.playSound = function (sound) {
} }
catch (eee) { catch (eee) {
console.log("无法播放SE "+sound); console.log("无法播放SE "+sound);
console.log(eee); main.log(eee);
} }
} }

View File

@ -293,13 +293,13 @@ core.prototype.init = function (coreData, callback) {
core.removeLocalForage("__test__"); core.removeLocalForage("__test__");
} }
} }
catch (e) {console.log(e); core.platform.useLocalForage=false;} catch (e) {main.log(e); core.platform.useLocalForage=false;}
}, function(e) {console.log(e); core.platform.useLocalForage=false;}) }, function(e) {main.log(e); core.platform.useLocalForage=false;})
} }
catch (e) {console.log(e); core.platform.useLocalForage=false;} catch (e) {main.log(e); core.platform.useLocalForage=false;}
}, function(e) {console.log(e); core.platform.useLocalForage=false;}) }, function(e) {main.log(e); core.platform.useLocalForage=false;})
} }
catch (e) {console.log(e); core.platform.useLocalForage=false;} catch (e) {main.log(e); core.platform.useLocalForage=false;}
} }
core.platform.extendKeyboard = core.getLocalStorage("extendKeyboard", false); core.platform.extendKeyboard = core.getLocalStorage("extendKeyboard", false);

View File

@ -978,7 +978,7 @@ events.prototype.doAction = function() {
core.setFlag((prefix||"global")+"@"+data.name.substring(7), value); core.setFlag((prefix||"global")+"@"+data.name.substring(7), value);
} }
} }
catch (e) {console.log(e)} catch (e) {main.log(e)}
core.updateStatusBar(); core.updateStatusBar();
this.doAction(); this.doAction();
break; break;
@ -1052,7 +1052,7 @@ events.prototype.doAction = function() {
value = core.decodeBase64(action.substring(7)); value = core.decodeBase64(action.substring(7));
} }
catch (e) { catch (e) {
console.log(e); main.log(e);
core.stopReplay(); core.stopReplay();
core.drawTip("录像文件出错"); core.drawTip("录像文件出错");
return; return;
@ -1147,7 +1147,7 @@ events.prototype.doAction = function() {
} }
} }
} catch (e) { } catch (e) {
console.log(e); main.log(e);
} }
if (!data.async) if (!data.async)
this.doAction(); this.doAction();

View File

@ -35,7 +35,7 @@ items.prototype.getItemEffect = function(itemId, itemNum) {
eval(this.itemEffect[itemId]); eval(this.itemEffect[itemId]);
} }
catch (e) { catch (e) {
console.log(e); main.log(e);
} }
} }
core.status.hero.statistics.hp += core.status.hero.hp - curr_hp; core.status.hero.statistics.hp += core.status.hero.hp - curr_hp;
@ -55,7 +55,7 @@ items.prototype.getItemEffectTip = function(itemId) {
try { try {
return eval(this.itemEffectTip[itemId])||""; return eval(this.itemEffectTip[itemId])||"";
} catch (e) { } catch (e) {
console.log(e); main.log(e);
return ""; return "";
} }
} }
@ -76,7 +76,7 @@ items.prototype.useItem = function (itemId, callback) {
eval(this.useItemEffect[itemId]); eval(this.useItemEffect[itemId]);
} }
catch (e) { catch (e) {
console.log(e); main.log(e);
} }
} }
// 记录路线 // 记录路线
@ -107,7 +107,7 @@ items.prototype.canUseItem = function (itemId) {
able = eval(this.canUseItemEffect[itemId]); able = eval(this.canUseItemEffect[itemId]);
} }
catch (e) { catch (e) {
console.log(e); main.log(e);
} }
} }
if (!able) core.status.event.data = null; if (!able) core.status.event.data = null;
@ -218,7 +218,7 @@ items.prototype.loadEquip = function (equipId, callback) {
} }
} }
catch (e) { catch (e) {
console.log(e); main.log(e);
} }
} }

View File

@ -122,7 +122,7 @@ loader.prototype.loadImage = function (imgName, callback) {
image.src = 'project/images/' + name + "?v=" + main.version; image.src = 'project/images/' + name + "?v=" + main.version;
} }
catch (e) { catch (e) {
console.log(e); main.log(e);
} }
} }
@ -146,7 +146,7 @@ loader.prototype.loadAnimates = function () {
image.src = t2; image.src = t2;
data.images.push(image); data.images.push(image);
} catch (e) { } catch (e) {
console.log(e); main.log(e);
data.images.push(null); data.images.push(null);
} }
} }
@ -171,11 +171,11 @@ loader.prototype.loadAnimates = function () {
core.material.animates[t] = data; core.material.animates[t] = data;
} }
catch (e) { catch (e) {
console.log(e); main.log(e);
core.material.animates[t] = null; core.material.animates[t] = null;
} }
}, function (e) { }, function (e) {
console.log(e); main.log(e);
core.material.animates[t] = null; core.material.animates[t] = null;
}, "text/plain; charset=x-user-defined") }, "text/plain; charset=x-user-defined")
}) })
@ -206,11 +206,11 @@ loader.prototype.loadMusic = function () {
core.playBgm(t); core.playBgm(t);
} }
catch (e) { catch (e) {
console.log(e); main.log(e);
core.material.bgms[t] = null; core.material.bgms[t] = null;
} }
}, function (e) { }, function (e) {
console.log(e); main.log(e);
core.material.bgms[t] = null; core.material.bgms[t] = null;
}, "text/plain; charset=x-user-defined") }, "text/plain; charset=x-user-defined")
@ -234,16 +234,16 @@ loader.prototype.loadMusic = function () {
core.musicStatus.audioContext.decodeAudioData(data, function (buffer) { core.musicStatus.audioContext.decodeAudioData(data, function (buffer) {
core.material.sounds[t] = buffer; core.material.sounds[t] = buffer;
}, function (e) { }, function (e) {
console.log(e); main.log(e);
core.material.sounds[t] = null; core.material.sounds[t] = null;
}) })
} }
catch (ee) { catch (ee) {
console.log(ee); main.log(ee);
core.material.sounds[t] = null; core.material.sounds[t] = null;
} }
}, function (e) { }, function (e) {
console.log(e); main.log(e);
core.material.sounds[t] = null; core.material.sounds[t] = null;
}, null, 'arraybuffer'); }, null, 'arraybuffer');
} }

View File

@ -2367,14 +2367,14 @@ ui.prototype.drawSLPanel = function(index, refresh) {
core.saves.autosave.data = data; core.saves.autosave.data = data;
core.status.event.ui[i]=data; core.status.event.ui[i]=data;
loadSave(i+1, callback); loadSave(i+1, callback);
}, function(err) {console.log(err);}); }, function(err) {main.log(err);});
} }
} }
else { else {
core.getLocalForage("save"+(5*page+i), null, function(data) { core.getLocalForage("save"+(5*page+i), null, function(data) {
core.status.event.ui[i]=data; core.status.event.ui[i]=data;
loadSave(i+1, callback); loadSave(i+1, callback);
}, function(err) {console.log(err);}); }, function(err) {main.log(err);});
} }
} }

View File

@ -40,6 +40,14 @@ utils.prototype.init = function () {
return to; return to;
}; };
} }
if (typeof String.prototype.endsWith != "function") {
String.prototype.endsWith = function(search, this_len) {
if (this_len === undefined || this_len > this.length) {
this_len = this.length;
}
return this.substring(this_len - search.length, this_len) === search;
};
}
} }
@ -136,7 +144,7 @@ utils.prototype.setLocalStorage = function(key, value) {
return true; return true;
} }
catch (e) { catch (e) {
console.log(e); main.log(e);
return false; return false;
} }
} }
@ -160,7 +168,7 @@ utils.prototype.getLocalStorage = function(key, defaultValue) {
return defaultValue; return defaultValue;
} }
catch (e) { catch (e) {
console.log(e); main.log(e);
return defaultValue; return defaultValue;
} }
} }
@ -226,7 +234,7 @@ utils.prototype.getLocalForage = function (key, defaultValue, successCallback, e
successCallback(JSON.parse(output)); successCallback(JSON.parse(output));
return; return;
} }
catch (ee) {console.log(ee);} catch (ee) {main.log(ee);}
} }
if (core.isset(successCallback)) if (core.isset(successCallback))
successCallback(JSON.parse(value)); successCallback(JSON.parse(value));
@ -669,7 +677,7 @@ utils.prototype.readFileContent = function (content) {
} }
} }
catch (e) { catch (e) {
console.log(e); main.log(e);
alert(e); alert(e);
} }
alert("不是有效的JSON文件"); alert("不是有效的JSON文件");

33
main.js
View File

@ -309,6 +309,17 @@ main.prototype.setMainTipsText = function (text) {
main.dom.mainTips.innerHTML = text; main.dom.mainTips.innerHTML = text;
} }
main.prototype.log = function (e) {
if (e) {
if (main.core && main.core.platform && !main.core.platform.isPC) {
console.log((e.stack || e.toString()).replace("\n", " --- "));
}
else {
console.log(e);
}
}
}
main.prototype.listen = function () { main.prototype.listen = function () {
@ -316,7 +327,7 @@ main.prototype.listen = function () {
window.onresize = function () { window.onresize = function () {
try { try {
main.core.resize(main.dom.body.clientWidth, main.dom.body.clientHeight); main.core.resize(main.dom.body.clientWidth, main.dom.body.clientHeight);
}catch (e) { console.log(e); } }catch (e) { main.log(e); }
} }
////// 在界面上按下某按键时 ////// ////// 在界面上按下某按键时 //////
@ -324,7 +335,7 @@ main.dom.body.onkeydown = function(e) {
try { try {
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) { console.log(ee); } } catch (ee) { main.log(ee); }
} }
////// 在界面上放开某按键时 ////// ////// 在界面上放开某按键时 //////
@ -332,7 +343,7 @@ main.dom.body.onkeyup = function(e) {
try { try {
if (main.core && (main.core.isPlaying() || main.core.status.lockControl)) if (main.core && (main.core.isPlaying() || main.core.status.lockControl))
main.core.onkeyUp(e); main.core.onkeyUp(e);
} catch (ee) { console.log(ee); } } catch (ee) { main.log(ee); }
} }
////// 开始选择时 ////// ////// 开始选择时 //////
@ -347,7 +358,7 @@ main.dom.data.onmousedown = function (e) {
var loc = main.core.getClickLoc(e.clientX, e.clientY); var loc = main.core.getClickLoc(e.clientX, e.clientY);
if (loc == null) return; if (loc == null) return;
main.core.ondown(loc); main.core.ondown(loc);
} catch (ee) { console.log(ee); } } catch (ee) { main.log(ee); }
} }
////// 鼠标移动时 ////// ////// 鼠标移动时 //////
@ -357,14 +368,14 @@ main.dom.data.onmousemove = function (e) {
var loc = main.core.getClickLoc(e.clientX, e.clientY); var loc = main.core.getClickLoc(e.clientX, e.clientY);
if (loc == null) return; if (loc == null) return;
main.core.onmove(loc); main.core.onmove(loc);
}catch (ee) { console.log(ee); } }catch (ee) { main.log(ee); }
} }
////// 鼠标放开时 ////// ////// 鼠标放开时 //////
main.dom.data.onmouseup = function () { main.dom.data.onmouseup = function () {
try { try {
main.core.onup(); main.core.onup();
}catch (e) { console.log(e); } }catch (e) { main.log(e); }
} }
////// 鼠标滑轮滚动时 ////// ////// 鼠标滑轮滚动时 //////
@ -374,7 +385,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) { console.log(ee); } } catch (ee) { main.log(ee); }
} }
////// 手指在触摸屏开始触摸时 ////// ////// 手指在触摸屏开始触摸时 //////
@ -384,7 +395,7 @@ main.dom.data.ontouchstart = function (e) {
var loc = main.core.getClickLoc(e.targetTouches[0].clientX, e.targetTouches[0].clientY); var loc = main.core.getClickLoc(e.targetTouches[0].clientX, e.targetTouches[0].clientY);
if (loc == null) return; if (loc == null) return;
main.core.ondown(loc); main.core.ondown(loc);
}catch (ee) { console.log(ee); } }catch (ee) { main.log(ee); }
} }
////// 手指在触摸屏上移动时 ////// ////// 手指在触摸屏上移动时 //////
@ -394,7 +405,7 @@ main.dom.data.ontouchmove = function (e) {
var loc = main.core.getClickLoc(e.targetTouches[0].clientX, e.targetTouches[0].clientY); var loc = main.core.getClickLoc(e.targetTouches[0].clientX, e.targetTouches[0].clientY);
if (loc == null) return; if (loc == null) return;
main.core.onmove(loc); main.core.onmove(loc);
}catch (ee) { console.log(ee); } }catch (ee) { main.log(ee); }
} }
////// 手指离开触摸屏时 ////// ////// 手指离开触摸屏时 //////
@ -403,7 +414,7 @@ main.dom.data.ontouchend = function (e) {
e.preventDefault(); e.preventDefault();
main.core.onup(); main.core.onup();
} catch (e) { } catch (e) {
console.log(e); main.log(e);
} }
} }
@ -623,7 +634,7 @@ main.dom.musicBtn.onclick = function () {
try { try {
if (main.core) if (main.core)
main.core.triggerBgm(); main.core.triggerBgm();
} catch (e) {console.log(e);} } catch (e) {main.log(e);}
} }
window.onblur = function () { window.onblur = function () {

View File

@ -1211,7 +1211,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) {
console.log(e); main.log(e);
} }
} }