Weather, bgm, statusBar
This commit is contained in:
parent
676dc50092
commit
aa3229620d
255
libs/control.js
255
libs/control.js
@ -195,7 +195,7 @@ control.prototype._animationFrame_heroMoving = function (timestamp) {
|
|||||||
|
|
||||||
control.prototype._animationFrame_weather = function (timestamp) {
|
control.prototype._animationFrame_weather = function (timestamp) {
|
||||||
var weather = core.animateFrame.weather;
|
var weather = core.animateFrame.weather;
|
||||||
if (timestamp - weather.time <= 30 || weather.level <= 0 || !core.dymCanvas.weather) return;
|
if (timestamp - weather.time <= 30 || !core.dymCanvas.weather) return;
|
||||||
core.control["_animationFrame_weather_"+weather.type]();
|
core.control["_animationFrame_weather_"+weather.type]();
|
||||||
weather.time = timestamp;
|
weather.time = timestamp;
|
||||||
}
|
}
|
||||||
@ -1861,35 +1861,28 @@ control.prototype.debug = function() {
|
|||||||
|
|
||||||
////// 更改天气效果 //////
|
////// 更改天气效果 //////
|
||||||
control.prototype.setWeather = function (type, level) {
|
control.prototype.setWeather = function (type, level) {
|
||||||
|
|
||||||
// 非雨雪
|
// 非雨雪
|
||||||
if (type!='rain' && type!='snow' && type!='fog') {
|
if (type == null) {
|
||||||
// core.clearMap('weather');
|
|
||||||
core.deleteCanvas('weather')
|
core.deleteCanvas('weather')
|
||||||
core.animateFrame.weather.type = null;
|
core.animateFrame.weather.type = null;
|
||||||
core.animateFrame.weather.level = 0;
|
|
||||||
core.animateFrame.weather.nodes = [];
|
core.animateFrame.weather.nodes = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
level = parseInt(level);
|
|
||||||
|
|
||||||
// 当前天气:则忽略
|
// 当前天气:则忽略
|
||||||
if (type==core.animateFrame.weather.type && !core.isset(level)) {
|
if (type==core.animateFrame.weather.type && level == null) return;
|
||||||
return;
|
level = core.clamp(parseInt(level) || 5, 1, 10);
|
||||||
}
|
|
||||||
|
|
||||||
if (!core.isset(level)) level=5;
|
|
||||||
if (level<1) level=1; if (level>10) level=10;
|
|
||||||
level *= parseInt(20*core.bigmap.width*core.bigmap.height/(core.__SIZE__*core.__SIZE__));
|
level *= parseInt(20*core.bigmap.width*core.bigmap.height/(core.__SIZE__*core.__SIZE__));
|
||||||
// 计算当前的宽高
|
|
||||||
|
|
||||||
|
// 计算当前的宽高
|
||||||
core.createCanvas('weather', 0, 0, core.__PIXELS__, core.__PIXELS__, 80);
|
core.createCanvas('weather', 0, 0, core.__PIXELS__, core.__PIXELS__, 80);
|
||||||
core.animateFrame.weather.type = type;
|
core.animateFrame.weather.type = type;
|
||||||
core.animateFrame.weather.level = level;
|
|
||||||
core.animateFrame.weather.nodes = [];
|
core.animateFrame.weather.nodes = [];
|
||||||
|
this._setWeather_createNodes(type, level);
|
||||||
|
}
|
||||||
|
|
||||||
if (type == 'rain') {
|
control.prototype._setWeather_createNodes = function (type, level) {
|
||||||
|
switch (type) {
|
||||||
|
case 'rain':
|
||||||
for (var a=0;a<level;a++) {
|
for (var a=0;a<level;a++) {
|
||||||
core.animateFrame.weather.nodes.push({
|
core.animateFrame.weather.nodes.push({
|
||||||
'x': Math.random()*core.bigmap.width*32,
|
'x': Math.random()*core.bigmap.width*32,
|
||||||
@ -1899,8 +1892,8 @@ control.prototype.setWeather = function (type, level) {
|
|||||||
'ys': Math.random() * 10 + 10
|
'ys': Math.random() * 10 + 10
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if (type=='snow') {
|
case 'snow':
|
||||||
for (var a=0;a<level;a++) {
|
for (var a=0;a<level;a++) {
|
||||||
core.animateFrame.weather.nodes.push({
|
core.animateFrame.weather.nodes.push({
|
||||||
'x': Math.random()*core.bigmap.width*32,
|
'x': Math.random()*core.bigmap.width*32,
|
||||||
@ -1909,8 +1902,8 @@ control.prototype.setWeather = function (type, level) {
|
|||||||
'd': Math.random() * Math.min(level, 200),
|
'd': Math.random() * Math.min(level, 200),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if (type=='fog') {
|
case 'fog':
|
||||||
if (core.animateFrame.weather.fog) {
|
if (core.animateFrame.weather.fog) {
|
||||||
for (var a=0;a<level/10;a++) {
|
for (var a=0;a<level/10;a++) {
|
||||||
core.animateFrame.weather.nodes.push({
|
core.animateFrame.weather.nodes.push({
|
||||||
@ -1921,23 +1914,18 @@ control.prototype.setWeather = function (type, level) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 更改画面色调 //////
|
////// 更改画面色调 //////
|
||||||
control.prototype.setFg = function(color, time, callback) {
|
control.prototype.setFg = function(color, time, callback) {
|
||||||
if (!core.isset(time)) time=750;
|
if (time == null) time=750;
|
||||||
if (time<=0) time=0;
|
if (time<=0) time=0;
|
||||||
|
if (!core.status.curtainColor)
|
||||||
if (!core.isset(core.status.curtainColor)) {
|
|
||||||
core.status.curtainColor = [0,0,0,0];
|
core.status.curtainColor = [0,0,0,0];
|
||||||
}
|
if (!color) color = [0,0,0,0];
|
||||||
|
if (color[3] == null) color[3] = 1;
|
||||||
var nowColor = core.status.curtainColor;
|
|
||||||
|
|
||||||
if (!core.isset(color))
|
|
||||||
color = [0,0,0,0];
|
|
||||||
if (!core.isset(color[3])) color[3] = 1;
|
|
||||||
color[3] = core.clamp(color[3],0,1);
|
color[3] = core.clamp(color[3],0,1);
|
||||||
|
|
||||||
if (time==0) {
|
if (time==0) {
|
||||||
@ -1945,46 +1933,47 @@ control.prototype.setFg = function(color, time, callback) {
|
|||||||
core.clearMap('curtain');
|
core.clearMap('curtain');
|
||||||
core.fillRect('curtain', 0, 0, core.__PIXELS__, core.__PIXELS__, core.arrayToRGBA(color));
|
core.fillRect('curtain', 0, 0, core.__PIXELS__, core.__PIXELS__, core.arrayToRGBA(color));
|
||||||
core.status.curtainColor = color;
|
core.status.curtainColor = color;
|
||||||
if (core.isset(callback)) callback();
|
if (callback) callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var per_time = 10, step = parseInt(time / per_time);
|
this._setFg_animate(core.status.curtainColor, color, callback);
|
||||||
|
}
|
||||||
|
|
||||||
var changeAnimate = setInterval(function() {
|
control.prototype._setFg_animate = function (nowColor, color, callback) {
|
||||||
|
var per_time = 10, step = parseInt(time / per_time);
|
||||||
|
var animate = setInterval(function() {
|
||||||
nowColor = [
|
nowColor = [
|
||||||
parseInt(nowColor[0]*(step-1)+color[0])/step,
|
(nowColor[0]*(step-1)+color[0])/step,
|
||||||
parseInt(nowColor[1]*(step-1)+color[1])/step,
|
(nowColor[1]*(step-1)+color[1])/step,
|
||||||
parseInt(nowColor[2]*(step-1)+color[2])/step,
|
(nowColor[2]*(step-1)+color[2])/step,
|
||||||
(nowColor[3]*(step-1)+color[3])/step,
|
(nowColor[3]*(step-1)+color[3])/step,
|
||||||
];
|
];
|
||||||
core.clearMap('curtain');
|
core.clearMap('curtain');
|
||||||
core.fillRect('curtain', 0, 0, core.__PIXELS__, core.__PIXELS__, core.arrayToRGBA(nowColor));
|
core.fillRect('curtain', 0, 0, core.__PIXELS__, core.__PIXELS__, core.arrayToRGBA(nowColor));
|
||||||
step--;
|
step--;
|
||||||
|
|
||||||
if (step <= 0) {
|
if (step <= 0) {
|
||||||
delete core.animateFrame.asyncId[changeAnimate];
|
delete core.animate.asyncId[animate];
|
||||||
clearInterval(changeAnimate);
|
clearInterval(animate);
|
||||||
core.status.curtainColor = color;
|
core.status.curtainColor = color;
|
||||||
// core.status.replay.animate=false;
|
|
||||||
if (core.isset(callback)) callback();
|
if (core.isset(callback)) callback();
|
||||||
}
|
}
|
||||||
}, per_time);
|
}, per_time);
|
||||||
|
|
||||||
core.animateFrame.asyncId[changeAnimate] = true;
|
core.animateFrame.asyncId[animate] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 画面闪烁 //////
|
////// 画面闪烁 //////
|
||||||
control.prototype.screenFlash = function (color, time, times, callback) {
|
control.prototype.screenFlash = function (color, time, times, callback) {
|
||||||
times = times || 1;
|
times = times || 1;
|
||||||
time = time/3;
|
time = time / 3;
|
||||||
var nowColor = core.clone(core.status.curtainColor);
|
var nowColor = core.clone(core.status.curtainColor);
|
||||||
core.setFg(color, time, function() {
|
core.setFg(color, time, function() {
|
||||||
core.setFg(nowColor, time * 2, function() {
|
core.setFg(nowColor, time * 2, function() {
|
||||||
if (times > 1)
|
if (times > 1)
|
||||||
core.screenFlash(color, time * 3, times - 1, callback);
|
core.screenFlash(color, time * 3, times - 1, callback);
|
||||||
else {
|
else {
|
||||||
if (core.isset(callback)) callback();
|
if (callback) callback();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1992,9 +1981,7 @@ control.prototype.screenFlash = function (color, time, times, callback) {
|
|||||||
|
|
||||||
////// 播放背景音乐 //////
|
////// 播放背景音乐 //////
|
||||||
control.prototype.playBgm = function (bgm, startTime) {
|
control.prototype.playBgm = function (bgm, startTime) {
|
||||||
if (main.mode!='play')return;
|
if (main.mode!='play' || !core.material.bgms[bgm]) return;
|
||||||
// 音频不存在
|
|
||||||
if (!core.isset(core.material.bgms[bgm])) return;
|
|
||||||
// 如果不允许播放
|
// 如果不允许播放
|
||||||
if (!core.musicStatus.bgmStatus) {
|
if (!core.musicStatus.bgmStatus) {
|
||||||
try {
|
try {
|
||||||
@ -2010,22 +1997,7 @@ control.prototype.playBgm = function (bgm, startTime) {
|
|||||||
this.setMusicBtn();
|
this.setMusicBtn();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 缓存BGM
|
this._playBgm_play(bgm, startTime);
|
||||||
core.loader.loadBgm(bgm);
|
|
||||||
// 如果当前正在播放,且和本BGM相同,直接忽略
|
|
||||||
if (core.musicStatus.playingBgm == bgm && !core.material.bgms[core.musicStatus.playingBgm].paused) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 如果正在播放中,暂停
|
|
||||||
if (core.isset(core.musicStatus.playingBgm)) {
|
|
||||||
core.material.bgms[core.musicStatus.playingBgm].pause();
|
|
||||||
}
|
|
||||||
// 播放当前BGM
|
|
||||||
core.material.bgms[bgm].volume = core.musicStatus.volume;
|
|
||||||
core.material.bgms[bgm].currentTime = startTime || 0;
|
|
||||||
core.material.bgms[bgm].play();
|
|
||||||
core.musicStatus.playingBgm = bgm;
|
|
||||||
core.musicStatus.lastBgm = bgm;
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.log("无法播放BGM "+bgm);
|
console.log("无法播放BGM "+bgm);
|
||||||
@ -2034,11 +2006,30 @@ control.prototype.playBgm = function (bgm, startTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
control.prototype._playBgm_play = function (bgm, startTime) {
|
||||||
|
// 缓存BGM
|
||||||
|
core.loader.loadBgm(bgm);
|
||||||
|
// 如果当前正在播放,且和本BGM相同,直接忽略
|
||||||
|
if (core.musicStatus.playingBgm == bgm && !core.material.bgms[core.musicStatus.playingBgm].paused) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 如果正在播放中,暂停
|
||||||
|
if (core.musicStatus.playingBgm) {
|
||||||
|
core.material.bgms[core.musicStatus.playingBgm].pause();
|
||||||
|
}
|
||||||
|
// 播放当前BGM
|
||||||
|
core.material.bgms[bgm].volume = core.musicStatus.volume;
|
||||||
|
core.material.bgms[bgm].currentTime = startTime || 0;
|
||||||
|
core.material.bgms[bgm].play();
|
||||||
|
core.musicStatus.playingBgm = bgm;
|
||||||
|
core.musicStatus.lastBgm = bgm;
|
||||||
|
}
|
||||||
|
|
||||||
////// 暂停背景音乐的播放 //////
|
////// 暂停背景音乐的播放 //////
|
||||||
control.prototype.pauseBgm = function () {
|
control.prototype.pauseBgm = function () {
|
||||||
// 直接暂停播放
|
if (main.mode!='play')return;
|
||||||
try {
|
try {
|
||||||
if (core.isset(core.musicStatus.playingBgm)) {
|
if (core.musicStatus.playingBgm) {
|
||||||
core.material.bgms[core.musicStatus.playingBgm].pause();
|
core.material.bgms[core.musicStatus.playingBgm].pause();
|
||||||
core.musicStatus.playingBgm = null;
|
core.musicStatus.playingBgm = null;
|
||||||
}
|
}
|
||||||
@ -2053,8 +2044,6 @@ control.prototype.pauseBgm = function () {
|
|||||||
////// 恢复背景音乐的播放 //////
|
////// 恢复背景音乐的播放 //////
|
||||||
control.prototype.resumeBgm = function () {
|
control.prototype.resumeBgm = function () {
|
||||||
if (main.mode!='play')return;
|
if (main.mode!='play')return;
|
||||||
|
|
||||||
// 恢复BGM
|
|
||||||
try {
|
try {
|
||||||
core.playBgm(core.musicStatus.playingBgm || core.musicStatus.lastBgm);
|
core.playBgm(core.musicStatus.playingBgm || core.musicStatus.lastBgm);
|
||||||
}
|
}
|
||||||
@ -2074,25 +2063,19 @@ control.prototype.setMusicBtn = function () {
|
|||||||
|
|
||||||
////// 更改背景音乐的播放 //////
|
////// 更改背景音乐的播放 //////
|
||||||
control.prototype.triggerBgm = function () {
|
control.prototype.triggerBgm = function () {
|
||||||
if (main.mode!='play')return;
|
if (main.mode!='play') return;
|
||||||
|
|
||||||
core.musicStatus.bgmStatus = !core.musicStatus.bgmStatus;
|
core.musicStatus.bgmStatus = !core.musicStatus.bgmStatus;
|
||||||
if (core.musicStatus.bgmStatus)
|
if (core.musicStatus.bgmStatus)
|
||||||
this.resumeBgm();
|
this.resumeBgm();
|
||||||
else {
|
else
|
||||||
this.pauseBgm();
|
this.pauseBgm();
|
||||||
}
|
|
||||||
core.setLocalStorage('bgmStatus', core.musicStatus.bgmStatus);
|
core.setLocalStorage('bgmStatus', core.musicStatus.bgmStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 播放音频 //////
|
////// 播放音频 //////
|
||||||
control.prototype.playSound = function (sound) {
|
control.prototype.playSound = function (sound) {
|
||||||
if (main.mode!='play')return;
|
if (main.mode!='play' || !core.musicStatus.soundStatus || !core.material.sounds[sound]) return;
|
||||||
// 如果不允许播放
|
|
||||||
if (!core.musicStatus.soundStatus) return;
|
|
||||||
// 音频不存在
|
|
||||||
if (!core.isset(core.material.sounds[sound])) return;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (core.musicStatus.audioContext != null) {
|
if (core.musicStatus.audioContext != null) {
|
||||||
var source = core.musicStatus.audioContext.createBufferSource();
|
var source = core.musicStatus.audioContext.createBufferSource();
|
||||||
@ -2102,18 +2085,8 @@ control.prototype.playSound = function (sound) {
|
|||||||
source.onended = function () {
|
source.onended = function () {
|
||||||
delete core.musicStatus.playingSounds[id];
|
delete core.musicStatus.playingSounds[id];
|
||||||
}
|
}
|
||||||
try {
|
if (source.start) source.start(0);
|
||||||
source.start(0);
|
else if (source.noteOn) source.noteOn(0);
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
try {
|
|
||||||
source.noteOn(0);
|
|
||||||
}
|
|
||||||
catch (ee) {
|
|
||||||
main.log(ee);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
core.musicStatus.playingSounds[id] = source;
|
core.musicStatus.playingSounds[id] = source;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -2121,75 +2094,67 @@ control.prototype.playSound = function (sound) {
|
|||||||
core.material.sounds[sound].play();
|
core.material.sounds[sound].play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (eee) {
|
catch (e) {
|
||||||
console.log("无法播放SE "+sound);
|
console.log("无法播放SE "+sound);
|
||||||
main.log(eee);
|
main.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////// 停止所有音频 //////
|
||||||
control.prototype.stopSound = function () {
|
control.prototype.stopSound = function () {
|
||||||
for (var i in core.musicStatus.playingSounds) {
|
for (var i in core.musicStatus.playingSounds) {
|
||||||
var source = core.musicStatus.playingSounds[i];
|
var source = core.musicStatus.playingSounds[i];
|
||||||
try {
|
try {
|
||||||
source.stop();
|
if (source[i].stop) source[i].stop();
|
||||||
}
|
else if (source[i].noteOff) source[i].noteOff();
|
||||||
catch (e) {
|
|
||||||
try {
|
|
||||||
source.noteOff(0);
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
main.log(e);
|
main.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
core.musicStatus.playingSounds = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////// 检查bgm状态 //////
|
||||||
control.prototype.checkBgm = function() {
|
control.prototype.checkBgm = function() {
|
||||||
core.playBgm(core.musicStatus.playingBgm || main.startBgm);
|
core.playBgm(core.musicStatus.playingBgm || main.startBgm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------ 状态栏,工具栏等相关 ------ //
|
||||||
|
|
||||||
////// 清空状态栏 //////
|
////// 清空状态栏 //////
|
||||||
control.prototype.clearStatusBar = function() {
|
control.prototype.clearStatusBar = function() {
|
||||||
Object.keys(core.statusBar).forEach(function (e) {
|
Object.keys(core.statusBar).forEach(function (e) {
|
||||||
core.statusBar[e].innerHTML = "";
|
core.statusBar[e].innerHTML = "";
|
||||||
})
|
})
|
||||||
core.statusBar.image.book.style.opacity = 0.3;
|
core.statusBar.image.book.style.opacity = 0.3;
|
||||||
if (!core.flags.equipboxButton) {
|
if (!core.flags.equipboxButton)
|
||||||
core.statusBar.image.fly.style.opacity = 0.3;
|
core.statusBar.image.fly.style.opacity = 0.3;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 更新状态栏 //////
|
////// 更新状态栏 //////
|
||||||
control.prototype.updateStatusBar = function () {
|
control.prototype.updateStatusBar = function () {
|
||||||
|
|
||||||
if (core.isPlaying())
|
if (core.isPlaying())
|
||||||
this.controldata.updateStatusBar();
|
this.controldata.updateStatusBar();
|
||||||
|
this._updateStatusBar_setToolboxImage();
|
||||||
|
}
|
||||||
|
|
||||||
// 回放
|
control.prototype._updateStatusBar_setToolboxImage = function () {
|
||||||
if (core.isReplaying()) {
|
if (core.isReplaying()) {
|
||||||
core.statusBar.image.book.src = core.status.replay.pausing ? core.statusBar.icons.play.src : core.statusBar.icons.pause.src;
|
core.statusBar.image.book.src = core.status.replay.pausing ? core.statusBar.icons.play.src : core.statusBar.icons.pause.src;
|
||||||
core.statusBar.image.book.style.opacity = 1;
|
core.statusBar.image.book.style.opacity = 1;
|
||||||
|
|
||||||
core.statusBar.image.fly.src = core.statusBar.icons.stop.src;
|
core.statusBar.image.fly.src = core.statusBar.icons.stop.src;
|
||||||
core.statusBar.image.fly.style.opacity = 1;
|
core.statusBar.image.fly.style.opacity = 1;
|
||||||
|
|
||||||
core.statusBar.image.toolbox.src = core.statusBar.icons.rewind.src;
|
core.statusBar.image.toolbox.src = core.statusBar.icons.rewind.src;
|
||||||
|
|
||||||
core.statusBar.image.keyboard.src = core.statusBar.icons.book.src;
|
core.statusBar.image.keyboard.src = core.statusBar.icons.book.src;
|
||||||
|
|
||||||
core.statusBar.image.shop.src = core.statusBar.icons.floor.src;
|
core.statusBar.image.shop.src = core.statusBar.icons.floor.src;
|
||||||
|
|
||||||
core.statusBar.image.save.src = core.statusBar.icons.speedDown.src;
|
core.statusBar.image.save.src = core.statusBar.icons.speedDown.src;
|
||||||
|
|
||||||
core.statusBar.image.load.src = core.statusBar.icons.speedUp.src;
|
core.statusBar.image.load.src = core.statusBar.icons.speedUp.src;
|
||||||
|
|
||||||
core.statusBar.image.settings.src = core.statusBar.icons.save.src;
|
core.statusBar.image.settings.src = core.statusBar.icons.save.src;
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.statusBar.image.book.src = core.statusBar.icons.book.src;
|
core.statusBar.image.book.src = core.statusBar.icons.book.src;
|
||||||
core.statusBar.image.book.style.opacity = core.hasItem('book') ? 1 : 0.3;
|
core.statusBar.image.book.style.opacity = core.hasItem('book') ? 1 : 0.3;
|
||||||
|
|
||||||
if (!core.flags.equipboxButton) {
|
if (!core.flags.equipboxButton) {
|
||||||
core.statusBar.image.fly.src = core.statusBar.icons.fly.src;
|
core.statusBar.image.fly.src = core.statusBar.icons.fly.src;
|
||||||
core.statusBar.image.fly.style.opacity = core.hasItem('fly') ? 1 : 0.3;
|
core.statusBar.image.fly.style.opacity = core.hasItem('fly') ? 1 : 0.3;
|
||||||
@ -2198,52 +2163,46 @@ control.prototype.updateStatusBar = function () {
|
|||||||
core.statusBar.image.fly.src = core.statusBar.icons.equipbox.src;
|
core.statusBar.image.fly.src = core.statusBar.icons.equipbox.src;
|
||||||
core.statusBar.image.fly.style.opacity = 1;
|
core.statusBar.image.fly.style.opacity = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
core.statusBar.image.toolbox.src = core.statusBar.icons.toolbox.src;
|
core.statusBar.image.toolbox.src = core.statusBar.icons.toolbox.src;
|
||||||
|
|
||||||
core.statusBar.image.keyboard.src = core.statusBar.icons.keyboard.src;
|
core.statusBar.image.keyboard.src = core.statusBar.icons.keyboard.src;
|
||||||
|
|
||||||
core.statusBar.image.shop.src = core.statusBar.icons.shop.src;
|
core.statusBar.image.shop.src = core.statusBar.icons.shop.src;
|
||||||
|
|
||||||
core.statusBar.image.save.src = core.statusBar.icons.save.src;
|
core.statusBar.image.save.src = core.statusBar.icons.save.src;
|
||||||
|
|
||||||
core.statusBar.image.load.src = core.statusBar.icons.load.src;
|
core.statusBar.image.load.src = core.statusBar.icons.load.src;
|
||||||
|
|
||||||
core.statusBar.image.settings.src = core.statusBar.icons.settings.src;
|
core.statusBar.image.settings.src = core.statusBar.icons.settings.src;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
control.prototype.triggerStatusBar = function (name, showToolbox) {
|
control.prototype.showStatusBar = function () {
|
||||||
if (name!='hide') name='show';
|
if (core.domStyle.showStatusBar) return;
|
||||||
|
|
||||||
// 如果是隐藏 -> 显示工具栏,则先显示
|
|
||||||
if (name == 'hide' && !core.domStyle.showStatusBar) {
|
|
||||||
this.triggerStatusBar("show");
|
|
||||||
this.triggerStatusBar("hide", showToolbox);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var statusItems = core.dom.status;
|
var statusItems = core.dom.status;
|
||||||
var toolItems = core.dom.tools;
|
core.domStyle.showStatusBar = true;
|
||||||
core.domStyle.showStatusBar = name == 'show';
|
core.removeFlag('hideStatusBar');
|
||||||
core.setFlag('hideStatusBar', core.domStyle.showStatusBar?null:true);
|
// 显示
|
||||||
core.setFlag('showToolbox', showToolbox?true:null);
|
for (var i = 0; i < statusItems.length; ++i)
|
||||||
if (!core.domStyle.showStatusBar) {
|
statusItems[i].style.opacity = 1;
|
||||||
|
this.setToolbarButton(false);
|
||||||
|
core.dom.tools.hard.style.display = 'block';
|
||||||
|
}
|
||||||
|
|
||||||
|
control.prototype.hideStatusBar = function (showToolbox) {
|
||||||
|
// 如果原本就是隐藏的,则先显示
|
||||||
|
if (!core.domStyle.showStatusBar)
|
||||||
|
this.showStatusBar();
|
||||||
|
|
||||||
|
var statusItems = core.dom.status, toolItems = core.dom.tools;
|
||||||
|
core.domStyle.showStatusBar = false;
|
||||||
|
core.setFlag('hideStatusBar', true);
|
||||||
|
core.setFlag('showToolbox', showToolbox || null);
|
||||||
|
// 隐藏
|
||||||
for (var i = 0; i < statusItems.length; ++i)
|
for (var i = 0; i < statusItems.length; ++i)
|
||||||
statusItems[i].style.opacity = 0;
|
statusItems[i].style.opacity = 0;
|
||||||
if (!core.domStyle.isVertical || !showToolbox) {
|
if (!core.domStyle.isVertical || !showToolbox) {
|
||||||
for (var i = 0; i < toolItems.length; ++i)
|
for (var i = 0; i < toolItems.length; ++i)
|
||||||
toolItems[i].style.display = 'none';
|
toolItems[i].style.display = 'none';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (var i = 0; i < statusItems.length; ++i)
|
|
||||||
statusItems[i].style.opacity = 1;
|
|
||||||
this.setToolbarButton(false);
|
|
||||||
core.dom.tools.hard.style.display = 'block';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////// 更新状态栏的勇士图标 //////
|
||||||
control.prototype.updateHeroIcon = function (name) {
|
control.prototype.updateHeroIcon = function (name) {
|
||||||
name = name || "hero.png";
|
name = name || "hero.png";
|
||||||
if (core.statusBar.icons.name == name) return;
|
if (core.statusBar.icons.name == name) return;
|
||||||
@ -2261,11 +2220,10 @@ control.prototype.updateHeroIcon = function (name) {
|
|||||||
context.drawImage(image, 0, 0, 32, height, left, 0, width, 32);
|
context.drawImage(image, 0, 0, 32, height, left, 0, width, 32);
|
||||||
|
|
||||||
core.statusBar.image.name.src = canvas.toDataURL("image/png");
|
core.statusBar.image.name.src = canvas.toDataURL("image/png");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
control.prototype.updateGlobalAttribute = function (name) {
|
control.prototype.updateGlobalAttribute = function (name) {
|
||||||
if (!core.isset(name)) return;
|
if (name == null) name = Object.keys(core.status.globalAttribute);
|
||||||
if (name instanceof Array) {
|
if (name instanceof Array) {
|
||||||
name.forEach(function (t) {
|
name.forEach(function (t) {
|
||||||
core.control.updateGlobalAttribute(t);
|
core.control.updateGlobalAttribute(t);
|
||||||
@ -2273,7 +2231,7 @@ control.prototype.updateGlobalAttribute = function (name) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var attribute = core.status.globalAttribute || core.initStatus.globalAttribute;
|
var attribute = core.status.globalAttribute || core.initStatus.globalAttribute;
|
||||||
if (!core.isset(attribute)) return;
|
if (attribute == null) return;
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 'statusLeftBackground':
|
case 'statusLeftBackground':
|
||||||
if (!core.domStyle.isVertical) {
|
if (!core.domStyle.isVertical) {
|
||||||
@ -2334,11 +2292,10 @@ control.prototype.setToolbarButton = function (useButton) {
|
|||||||
else core.dom.tools.hard.style.display = 'block';
|
else core.dom.tools.hard.style.display = 'block';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!core.isset(useButton)) useButton = core.domStyle.toolbarBtn;
|
if (useButton == null) useButton = core.domStyle.toolbarBtn;
|
||||||
if (!core.domStyle.isVertical) useButton = false;
|
if (!core.domStyle.isVertical || !core.platform.extendKeyboard) useButton = false;
|
||||||
if (!core.platform.extendKeyboard) useButton = false;
|
|
||||||
|
|
||||||
core.domStyle.toolbarBtn = useButton;
|
core.domStyle.toolbarBtn = useButton;
|
||||||
|
|
||||||
if (useButton) {
|
if (useButton) {
|
||||||
["book","fly","toolbox","keyboard","shop","save","load","settings"].forEach(function (t) {
|
["book","fly","toolbox","keyboard","shop","save","load","settings"].forEach(function (t) {
|
||||||
core.statusBar.image[t].style.display = 'none';
|
core.statusBar.image[t].style.display = 'none';
|
||||||
@ -2360,14 +2317,16 @@ control.prototype.setToolbarButton = function (useButton) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
control.prototype.needDraw = function(id) {
|
////// ------ resize处理 ------ //
|
||||||
if (!core.isset(id)) {
|
|
||||||
|
control.prototype._shouldDisplayStatus = function(id) {
|
||||||
|
if (id == null) {
|
||||||
var toDraw = [], status = core.dom.status;
|
var toDraw = [], status = core.dom.status;
|
||||||
for (var i = 0; i<status.length; ++i) {
|
for (var i = 0; i<status.length; ++i) {
|
||||||
var dom = core.dom.status[i], idCol = dom.id;
|
var dom = core.dom.status[i], idCol = dom.id;
|
||||||
if (idCol.indexOf("Col")!=idCol.length-3) continue;
|
if (idCol.indexOf("Col")!=idCol.length-3) continue;
|
||||||
var id = idCol.substring(0, idCol.length-3);
|
var id = idCol.substring(0, idCol.length-3);
|
||||||
if (!this.needDraw(id)) continue;
|
if (!this._shouldDisplayStatus(id)) continue;
|
||||||
toDraw.push(id);
|
toDraw.push(id);
|
||||||
}
|
}
|
||||||
return toDraw;
|
return toDraw;
|
||||||
@ -2425,7 +2384,7 @@ control.prototype.resize = function(clientWidth, clientHeight) {
|
|||||||
fontSize, toolbarFontSize, margin, statusBackground, toolsBackground,
|
fontSize, toolbarFontSize, margin, statusBackground, toolsBackground,
|
||||||
statusCanvasWidth, statusCanvasHeight, musicBtnBottom, musicBtnRight;
|
statusCanvasWidth, statusCanvasHeight, musicBtnBottom, musicBtnRight;
|
||||||
|
|
||||||
var toDraw = this.needDraw();
|
var toDraw = this._shouldDisplayStatus();
|
||||||
var count = toDraw.length;
|
var count = toDraw.length;
|
||||||
var statusCanvas = core.flags.statusCanvas, statusCanvasRows = core.flags.statusCanvasRowsOnMobile || 3;
|
var statusCanvas = core.flags.statusCanvas, statusCanvasRows = core.flags.statusCanvasRowsOnMobile || 3;
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,6 @@ function core() {
|
|||||||
'weather': {
|
'weather': {
|
||||||
'time': 0,
|
'time': 0,
|
||||||
'type': null,
|
'type': null,
|
||||||
'level': 0,
|
|
||||||
'nodes': [],
|
'nodes': [],
|
||||||
'data': null,
|
'data': null,
|
||||||
'fog': null,
|
'fog': null,
|
||||||
|
|||||||
@ -59,7 +59,7 @@ events.prototype._startGame_start = function (hard, seed, route, callback) {
|
|||||||
|
|
||||||
var todo = [];
|
var todo = [];
|
||||||
if (core.flags.startUsingCanvas) {
|
if (core.flags.startUsingCanvas) {
|
||||||
core.control.triggerStatusBar('hide');
|
core.hideStatusBar();
|
||||||
core.dom.musicBtn.style.display = 'block';
|
core.dom.musicBtn.style.display = 'block';
|
||||||
core.push(todo, core.firstData.startCanvas);
|
core.push(todo, core.firstData.startCanvas);
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ events.prototype._startGame_start = function (hard, seed, route, callback) {
|
|||||||
|
|
||||||
events.prototype._startGame_afterStart = function (nowLoc, callback) {
|
events.prototype._startGame_afterStart = function (nowLoc, callback) {
|
||||||
core.ui.closePanel();
|
core.ui.closePanel();
|
||||||
core.control.triggerStatusBar('show');
|
core.showStatusBar();
|
||||||
core.dom.musicBtn.style.display = 'none';
|
core.dom.musicBtn.style.display = 'none';
|
||||||
core.changeFloor(core.firstData.floorId, null, nowLoc, null, callback);
|
core.changeFloor(core.firstData.floorId, null, nowLoc, null, callback);
|
||||||
this._startGame_upload();
|
this._startGame_upload();
|
||||||
@ -1395,12 +1395,12 @@ events.prototype._action_update = function (data, x, y, prefix) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
events.prototype._action_showStatusBar = function (data, x, y, prefix) {
|
events.prototype._action_showStatusBar = function (data, x, y, prefix) {
|
||||||
core.control.triggerStatusBar("show");
|
core.showStatusBar();
|
||||||
core.doAction();
|
core.doAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
events.prototype._action_hideStatusBar = function (data, x, y, prefix) {
|
events.prototype._action_hideStatusBar = function (data, x, y, prefix) {
|
||||||
core.control.triggerStatusBar("hide", data.toolbox);
|
core.hideStatusBar(data.toolbox);
|
||||||
core.doAction();
|
core.doAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1775,7 +1775,7 @@ events.prototype.setGlobalAttribute = function (name, value) {
|
|||||||
value = eval(value);
|
value = eval(value);
|
||||||
}
|
}
|
||||||
core.status.globalAttribute[name] = value;
|
core.status.globalAttribute[name] = value;
|
||||||
core.control.updateGlobalAttribute(name);
|
core.updateGlobalAttribute(name);
|
||||||
core.setFlag('globalAttribute', core.status.globalAttribute);
|
core.setFlag('globalAttribute', core.status.globalAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,8 +36,12 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
core.flags[key] = globalFlags[key];
|
core.flags[key] = globalFlags[key];
|
||||||
// 初始化界面,状态栏等
|
// 初始化界面,状态栏等
|
||||||
core.resize();
|
core.resize();
|
||||||
core.updateGlobalAttribute(Object.keys(core.status.globalAttribute));
|
core.updateGlobalAttribute();
|
||||||
core.triggerStatusBar(core.hasFlag('hideStatusBar') ? 'hide' : 'show', core.hasFlag('showToolbox'));
|
// 状态栏是否显示
|
||||||
|
if (core.hasFlag('hideStatusBar'))
|
||||||
|
core.hideStatusBar(core.hasFlag('showToolbox'));
|
||||||
|
else
|
||||||
|
core.showStatusBar();
|
||||||
// 隐藏右下角的音乐按钮
|
// 隐藏右下角的音乐按钮
|
||||||
core.dom.musicBtn.style.display = 'none';
|
core.dom.musicBtn.style.display = 'none';
|
||||||
},
|
},
|
||||||
@ -940,7 +944,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
|||||||
var toAttribute = core.getFlag('globalAttribute', core.status.globalAttribute);
|
var toAttribute = core.getFlag('globalAttribute', core.status.globalAttribute);
|
||||||
if (!core.same(toAttribute, core.status.globalAttribute)) {
|
if (!core.same(toAttribute, core.status.globalAttribute)) {
|
||||||
core.status.globalAttribute = toAttribute;
|
core.status.globalAttribute = toAttribute;
|
||||||
core.control.updateGlobalAttribute(Object.keys(toAttribute));
|
core.updateGlobalAttribute();
|
||||||
}
|
}
|
||||||
// 重置音量
|
// 重置音量
|
||||||
core.events.setVolume(core.getFlag("__volume__", 1), 0);
|
core.events.setVolume(core.getFlag("__volume__", 1), 0);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user