diff --git a/public/libs/control.js b/public/libs/control.js index 47ce82f..5d86005 100644 --- a/public/libs/control.js +++ b/public/libs/control.js @@ -4231,21 +4231,14 @@ control.prototype._resize_gameGroup = function (obj) { control.prototype._resize_canvas = function (obj) { var innerWidth = core._PX_ * core.domStyle.scale + 'px', innerHeight = core._PY_ * core.domStyle.scale + 'px'; - if (!core.isPlaying()) { - for (var i = 0; i < core.dom.gameCanvas.length; ++i) { - var ctx = core.dom.gameCanvas[i].getContext('2d'); - core.resizeCanvas(ctx, core._PX_, core._PY_); - core.dom.gameCanvas[i].style.width = innerWidth; - core.dom.gameCanvas[i].style.height = innerHeight; - } - } else { - // requestAnimationFrame(function () { - for (var i = 0; i < core.dom.gameCanvas.length; ++i) { - core.dom.gameCanvas[i].style.width = innerWidth; - core.dom.gameCanvas[i].style.height = innerHeight; - } - // }); + + for (var i = 0; i < core.dom.gameCanvas.length; ++i) { + core.dom.gameCanvas[i].style.width = innerWidth; + core.dom.gameCanvas[i].style.height = innerHeight; + var ctx = core.dom.gameCanvas[i].getContext('2d'); + core.resizeCanvas(ctx, core._PX_, core._PY_); } + core.dom.gif.style.width = innerWidth; core.dom.gif.style.height = innerHeight; core.dom.gif2.style.width = innerWidth; diff --git a/public/main.js b/public/main.js index 2dc8a26..491e7f8 100644 --- a/public/main.js +++ b/public/main.js @@ -221,6 +221,8 @@ main.prototype.init = function (mode, callback) { var a = {}; var b = {}; new Proxy(a, b); + const aa = `${123}`; + aa; } catch (e) { alert('浏览器版本过低,无法游玩本塔!'); return; @@ -279,8 +281,8 @@ main.prototype.init = function (mode, callback) { ].forEach(function (t) { coreData[t] = main[t]; }); - main.core.init(coreData, callback); - main.core.resize(); + core.init(coreData, callback); + core.resize(); // 自动放缩最大化 if (core.getLocalStorage('autoScale') == null) { core.setLocalStorage('autoScale', true); @@ -290,45 +292,29 @@ main.prototype.init = function (mode, callback) { !core.domStyle.isVertical ) { try { - if (main.core) { - var index = - main.core.domStyle.availableScale.indexOf( - core.domStyle.scale - ); - main.core.control.setDisplayScale( - main.core.domStyle.availableScale.length - - 1 - - index - ); - if ( - !main.core.isPlaying() && - main.core.flags.enableHDCanvas - ) { - main.core.domStyle.ratio = Math.max( - window.devicePixelRatio || 1, - main.core.domStyle.scale - ); - main.core.resize(); - } - requestAnimationFrame(function () { - var style = getComputedStyle( - main.dom.gameGroup - ); - var height = parseFloat(style.height); - if (height > window.innerHeight * 0.95) { - main.core.control.setDisplayScale(-1); - if ( - !main.core.isPlaying() && - main.core.flags.enableHDCanvas - ) { - main.core.domStyle.ratio = Math.max( - window.devicePixelRatio || 1, - main.core.domStyle.scale - ); - main.core.resize(); + if (core) { + core.plugin.maxGameScale(); + if (!core.getLocalStorage('fullscreen', false)) { + requestAnimationFrame(function () { + var style = getComputedStyle( + main.dom.gameGroup + ); + var height = parseFloat(style.height); + if (height > window.innerHeight * 0.95) { + core.control.setDisplayScale(-1); + if ( + !core.isPlaying() && + core.flags.enableHDCanvas + ) { + core.domStyle.ratio = Math.max( + window.devicePixelRatio || 1, + core.domStyle.scale + ); + core.resize(); + } } - } - }); + }); + } } } catch (e) { console.error(e); diff --git a/public/project/plugins.js b/public/project/plugins.js index e439faf..3bfacab 100644 --- a/public/project/plugins.js +++ b/public/project/plugins.js @@ -4128,5 +4128,21 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { this.has = function (v) { return v !== null && v !== void 0; }; + + this.maxGameScale = function (n = 0) { + const index = core.domStyle.availableScale.indexOf( + core.domStyle.scale + ); + core.control.setDisplayScale( + core.domStyle.availableScale.length - 1 - index - n + ); + if (!core.isPlaying() && core.flags.enableHDCanvas) { + core.domStyle.ratio = Math.max( + window.devicePixelRatio || 1, + core.domStyle.scale + ); + core.resize(); + } + }; } }; diff --git a/src/data/settings.json b/src/data/settings.json index e45b501..bf8667d 100644 --- a/src/data/settings.json +++ b/src/data/settings.json @@ -1,4 +1,8 @@ { + "fullscreen": { + "text": "全屏游戏", + "desc": ["是否全屏进行游戏"] + }, "transition": { "text": "界面动画", "desc": [ diff --git a/src/plugin/settings.ts b/src/plugin/settings.ts index 8e734e4..b4d3209 100644 --- a/src/plugin/settings.ts +++ b/src/plugin/settings.ts @@ -1,50 +1,35 @@ import { ref, watch } from 'vue'; -/** - * 打开和关闭ui时是否展示动画 - */ +/** 打开和关闭ui时是否展示动画 */ export const transition = ref(false); -/** - * 道具详细信息 - */ +/** 道具详细信息 */ export const itemDetail = ref(true); -/** - * 自动切换技能 - */ +/** 自动切换技能 */ export const autoSkill = ref(true); -/** - * 自动放缩 - */ +/** 自动放缩 */ export const autoScale = ref(true); -/** - * 是否在地图上展示范围光环 - */ +/** 是否在地图上展示范围光环 */ export const showHalo = ref(true); -/** - * 是否展示已学习的技能 - */ +/** 是否展示已学习的技能 */ export const showStudied = ref(true); -/** - * 是否使用定点查看功能 - */ +/** 是否使用定点查看功能 */ export const useFixed = ref(true); -/** - * 是否使用勇士自动定位功能 - */ +/** 是否使用勇士自动定位功能 */ export const autoLocate = ref(true); -/** - * 是否开启抗锯齿 - */ +/** 是否开启抗锯齿 */ export const antiAliasing = ref(true); +/** 是否开启全屏 */ +export const fullscreen = ref(false); + watch(transition, n => { core.plugin.transition.value = n; core.setLocalStorage('transition', n); @@ -106,6 +91,7 @@ function reset() { showStudied.value = core.getLocalStorage('showStudied', true); showHalo.value = core.getLocalStorage('showHalo', true); antiAliasing.value = core.getLocalStorage('antiAliasing', false); + fullscreen.value = !!document.fullscreenElement; } function resetFlag() { @@ -118,6 +104,22 @@ function resetFlag() { autoLocate.value = flags.autoLocate ? true : false; } +export async function triggerFullscreen() { + if (document.fullscreenElement) { + await document.exitFullscreen(); + requestAnimationFrame(() => { + core.maxGameScale(1); + }); + fullscreen.value = false; + } else { + await document.body.requestFullscreen(); + requestAnimationFrame(() => { + core.maxGameScale(); + }); + fullscreen.value = true; + } +} + export default function init() { return { resetSettings: reset, resetFlagSettings: resetFlag }; } diff --git a/src/plugin/ui/achievement.ts b/src/plugin/ui/achievement.ts index 9f06d2f..55eb9a5 100644 --- a/src/plugin/ui/achievement.ts +++ b/src/plugin/ui/achievement.ts @@ -1,8 +1,11 @@ import list from '../../data/achievement.json'; +import { has } from '../utils'; type AchievementList = typeof list; type AchievementType = keyof AchievementList; +type AchievementData = Record; + export default function init() { return {}; } @@ -10,5 +13,15 @@ export default function init() { export function completeAchievement(type: AchievementType, index: number) {} export function hasCompletedAchievement(type: AchievementType, index: number) { - return true; + let data = core.getLocalStorage('achievement'); + if (!has(data)) { + const d = { + normal: [], + challenge: [], + explore: [] + }; + data = d; + core.setLocalStorage('achievement', d); + } + return data[type][index] ?? false; } diff --git a/src/types/plugin.d.ts b/src/types/plugin.d.ts index cfea028..cdd0487 100644 --- a/src/types/plugin.d.ts +++ b/src/types/plugin.d.ts @@ -140,6 +140,12 @@ interface PluginUtils { * @param value 要判断的值 */ has(value: T): value is NonNullable; + + /** + * 最大化游戏缩放 + * @param n 最大缩放再少多少个缩放 + */ + maxGameScale(n?: number): void; } interface PluginUis { diff --git a/src/ui/settings.vue b/src/ui/settings.vue index 698568b..9363ffb 100644 --- a/src/ui/settings.vue +++ b/src/ui/settings.vue @@ -2,6 +2,14 @@