chore: 调整设置内容,添加画面放缩,删除遗留内容

This commit is contained in:
unanmed 2025-09-29 13:03:29 +08:00
parent aef630006c
commit 695d069797
7 changed files with 67 additions and 124 deletions

View File

@ -159,8 +159,10 @@ export class FloorItemDetail implements ILayerGroupRenderExtends {
* @param block * @param block
*/ */
calAllItems(block: Set<number>) { calAllItems(block: Set<number>) {
if (!core.status.thisMap) return; const enable = mainSetting.getValue('screen.itemDetail');
if (!core.status.thisMap || !enable) return;
if (this.dirtyBlock.size === 0 || block.size === 0) return; if (this.dirtyBlock.size === 0 || block.size === 0) return;
let diff: Record<string | symbol, number | undefined> = {}; let diff: Record<string | symbol, number | undefined> = {};
const before = core.status.hero; const before = core.status.hero;
const hero = structuredClone(core.status.hero); const hero = structuredClone(core.status.hero);
@ -174,8 +176,7 @@ export class FloorItemDetail implements ILayerGroupRenderExtends {
core.status.hero = new Proxy(hero, handler); core.status.hero = new Proxy(hero, handler);
core.setFlag('__statistics__', true); core.setFlag('__statistics__', true);
block.forEach(v => { this.dirtyBlock.forEach(v => {
if (!this.dirtyBlock.has(v)) return;
const data = this.blockData.get(v); const data = this.blockData.get(v);
const detail = this.detailData.get(v); const detail = this.detailData.get(v);
detail?.clear(); detail?.clear();

View File

@ -20,39 +20,11 @@
"开启后,打怪物的时候会自动选择伤害最低的技能。同时显伤也会显示此状态下的伤害,", "开启后,打怪物的时候会自动选择伤害最低的技能。同时显伤也会显示此状态下的伤害,",
"临界也会考虑技能在内" "临界也会考虑技能在内"
], ],
"fixed": [
"开启后,当鼠标移动到怪物上时,会以盒子的形式展示该点的怪物信息。手机端此功能无效。",
"<br>",
"<br>",
"注当鼠标移动到怪物上时经过200毫秒才会显示信息防止误操作。"
],
"hotkey": ["设置游戏中会用到的一些快捷键"] "hotkey": ["设置游戏中会用到的一些快捷键"]
}, },
"utils": { "utils": {
"betterLoad": [
"<span style=\"color: yellow; font-weight: 700\">试验性功能</span>",
"<br>",
"开启后游戏将对加载进行优化,缩短进入游戏时的加载时长,而在游戏中对资源进行部分性按需加载,从而对加载进行优化。",
"该设置不会影响你的正常游戏,但如果网络环境较差,可能会导致部分楼层转换时间明显变长。",
"<br>",
"<br>",
"注:修改后刷新页面起效。"
],
"autoScale": [ "autoScale": [
"开启后,每次进入游戏时会自动缩放游戏画面至合适值。该项只对电脑端有效。", "开启后,每次进入游戏时会自动缩放游戏画面至合适值。该项只对电脑端有效。"
"<br>",
"<br>",
"缩放原则如下:",
"<br>",
"1. 首先尝试缩放至最大缩放比例",
"<br>",
"2. 如果缩放后游戏画面高度高于页面高度的95%,那么缩小一个缩放比例,否则保持最大比例"
] ]
},
"fx": {
"paraLight": [
"是否开启野外的平行光阴影,在野外将会显示平行光阴影,模拟太阳光,拥有不错的视觉效果"
],
"frag": ["开启后,在打败怪物后会触发怪物碎裂特效。"]
} }
} }

View File

@ -85,17 +85,25 @@ function handleScreenSetting<T extends number | boolean>(
if (key === 'fullscreen') { if (key === 'fullscreen') {
// 全屏 // 全屏
triggerFullscreen(n as boolean); triggerFullscreen(n as boolean);
} else if (key === 'heroDetail') {
// 勇士显伤
core.drawHero();
} else if (key === 'fontSize') { } else if (key === 'fontSize') {
// 字体大小 // 字体大小
root.style.fontSize = `${n}px`; root.style.fontSize = `${n}px`;
const absoluteSize = (n as number) * devicePixelRatio; const absoluteSize = (n as number) * devicePixelRatio;
storage.setValue('@@absoluteFontSize', absoluteSize); storage.setValue('@@absoluteFontSize', absoluteSize);
storage.write(); storage.write();
} else if (key === 'fontSizeStatus') { } else if (key === 'scale') {
// fontSize.value = n as number; const { MAIN_HEIGHT, MAIN_WIDTH } = Mota.require(
'@user/client-modules'
);
const max = Math.min(
(window.innerHeight / MAIN_HEIGHT) * 100,
(window.innerWidth / MAIN_WIDTH) * 100,
n as number
);
const scale = Number((Math.floor((max / 100) * 4) / 4).toFixed(2));
// @ts-expect-error 遗留问题
core.domStyle.scale = scale;
Mota.require('@user/client-modules').mainRenderer.setScale(scale);
} }
} }
@ -153,19 +161,12 @@ mainSetting
'显示设置', '显示设置',
new MotaSetting() new MotaSetting()
.register('fullscreen', '全屏游戏', false, COM.Boolean) .register('fullscreen', '全屏游戏', false, COM.Boolean)
.register('scale', '画面缩放', 100, COM.Number, [50, 500, 25])
.setDisplayFunc('scale', value => `${value}%`)
.register('halo', '光环显示', true, COM.Boolean) .register('halo', '光环显示', true, COM.Boolean)
.register('itemDetail', '宝石血瓶显伤', true, COM.Boolean) .register('itemDetail', '宝石血瓶显伤', true, COM.Boolean)
.register('heroDetail', '勇士显伤', false, COM.Boolean)
.register('transition', '界面动画', false, COM.Boolean) .register('transition', '界面动画', false, COM.Boolean)
.register('fontSize', '字体大小', 16, COM.Number, [2, 48, 1]) .register('fontSize', '字体大小', 16, COM.Number, [2, 48, 1])
.register(
'fontSizeStatus',
'状态栏字体',
16,
COM.Number,
[10, 300, 10]
)
.register('smoothView', '平滑镜头', true, COM.Boolean)
.register('criticalGem', '临界显示方式', false, COM.Boolean) .register('criticalGem', '临界显示方式', false, COM.Boolean)
.setDisplayFunc('criticalGem', value => (value ? '宝石数' : '攻击')) .setDisplayFunc('criticalGem', value => (value ? '宝石数' : '攻击'))
.register('keyScale', '虚拟键盘缩放', 100, COM.Number, [25, 5, 500]) .register('keyScale', '虚拟键盘缩放', 100, COM.Number, [25, 5, 500])
@ -176,7 +177,6 @@ mainSetting
'操作设置', '操作设置',
new MotaSetting() new MotaSetting()
.register('autoSkill', '自动切换技能', true, COM.Boolean) .register('autoSkill', '自动切换技能', true, COM.Boolean)
.register('fixed', '定点查看', true, COM.Boolean)
.register('hotkey', '快捷键', false, COM.HotkeySetting) .register('hotkey', '快捷键', false, COM.HotkeySetting)
.setDisplayFunc('hotkey', () => '') .setDisplayFunc('hotkey', () => '')
) )
@ -192,17 +192,17 @@ mainSetting
.register( .register(
'utils', 'utils',
'系统设置', '系统设置',
new MotaSetting() new MotaSetting().register('autoScale', '自动放缩', true, COM.Boolean)
.register('betterLoad', '优化加载', true, COM.Boolean)
.register('autoScale', '自动放缩', true, COM.Boolean)
) )
.register( .register(
'fx', 'fx',
'特效设置', '特效设置',
new MotaSetting() new MotaSetting().register(
.register('paraLight', '野外阴影', true, COM.Boolean) 'portalParticle',
.register('frag', '打怪特效', true, COM.Boolean) '传送门特效',
.register('portalParticle', '传送门特效', true, COM.Boolean) true,
COM.Boolean
)
) )
.register( .register(
'ui', 'ui',
@ -245,7 +245,6 @@ mainSetting
.setDescription('ui.danmaku', '是否显示弹幕') .setDescription('ui.danmaku', '是否显示弹幕')
.setDescription('ui.danmakuSpeed', '弹幕速度,刷新或开关弹幕显示后起效') .setDescription('ui.danmakuSpeed', '弹幕速度,刷新或开关弹幕显示后起效')
.setDescription('ui.tips', `是否在游戏画面右上角常亮显示小贴士`) .setDescription('ui.tips', `是否在游戏画面右上角常亮显示小贴士`)
.setDescription('screen.fontSizeStatus', `修改状态栏的字体大小`)
.setDescription( .setDescription(
'screen.blur', 'screen.blur',
'打开任意ui界面时是否有背景虚化效果移动端打开后可能会有掉帧或者发热现象。关闭ui后生效' '打开任意ui界面时是否有背景虚化效果移动端打开后可能会有掉帧或者发热现象。关闭ui后生效'
@ -286,24 +285,18 @@ export function createSetting() {
loading.once('coreInit', () => { loading.once('coreInit', () => {
mainSetting.reset({ mainSetting.reset({
'screen.fullscreen': !!document.fullscreenElement, 'screen.fullscreen': !!document.fullscreenElement,
'screen.scale': storage.getValue('screen.scale', 100),
'screen.halo': !!storage.getValue('screen.showHalo', true), 'screen.halo': !!storage.getValue('screen.showHalo', true),
'screen.itemDetail': !!storage.getValue('screen.itemDetail', true), 'screen.itemDetail': !!storage.getValue('screen.itemDetail', true),
'screen.heroDetail': !!storage.getValue('screen.heroDetail', false),
'screen.transition': !!storage.getValue('screen.transition', false), 'screen.transition': !!storage.getValue('screen.transition', false),
'screen.fontSize': storage.getValue( 'screen.fontSize': storage.getValue(
'screen.fontSize', 'screen.fontSize',
isMobile ? 9 : 16 isMobile ? 9 : 16
), ),
'screen.smoothView': !!storage.getValue('screen.smoothView', true),
'screen.criticalGem': !!storage.getValue( 'screen.criticalGem': !!storage.getValue(
'screen.criticalGem', 'screen.criticalGem',
false false
), ),
'screen.fontSizeStatus': storage.getValue(
'screen.fontSizeStatus',
100
),
'action.fixed': !!storage.getValue('action.fixed', true),
'audio.bgmEnabled': !!storage.getValue('audio.bgmEnabled', true), 'audio.bgmEnabled': !!storage.getValue('audio.bgmEnabled', true),
'audio.bgmVolume': storage.getValue('audio.bgmVolume', 80), 'audio.bgmVolume': storage.getValue('audio.bgmVolume', 80),
'audio.soundEnabled': !!storage.getValue( 'audio.soundEnabled': !!storage.getValue(
@ -311,10 +304,7 @@ export function createSetting() {
true true
), ),
'audio.soundVolume': storage.getValue('audio.soundVolume', 80), 'audio.soundVolume': storage.getValue('audio.soundVolume', 80),
'utils.betterLoad': !!storage.getValue('utils.betterLoad', true),
'utils.autoScale': !!storage.getValue('utils.autoScale', true), 'utils.autoScale': !!storage.getValue('utils.autoScale', true),
'fx.paraLight': !!storage.getValue('fx.paraLight', true),
'fx.frag': !!storage.getValue('fx.frag', true),
'fx.portalParticle': !!storage.getValue('fx.portalParticle', true), 'fx.portalParticle': !!storage.getValue('fx.portalParticle', true),
'ui.mapScale': storage.getValue( 'ui.mapScale': storage.getValue(
'ui.mapScale', 'ui.mapScale',

View File

@ -295,16 +295,12 @@ export function ensureArray<T>(arr: T): T extends any[] ? T : T[] {
} }
export async function triggerFullscreen(full: boolean) { export async function triggerFullscreen(full: boolean) {
const { maxGameScale } = Mota.require('@user/data-utils');
if (!!document.fullscreenElement && !full) { if (!!document.fullscreenElement && !full) {
if (window.jsinterface) { if (window.jsinterface) {
window.jsinterface.requestPortrait(); window.jsinterface.requestPortrait();
return; return;
} }
await document.exitFullscreen(); await document.exitFullscreen();
requestAnimationFrame(() => {
maxGameScale(1);
});
} }
if (full && !document.fullscreenElement) { if (full && !document.fullscreenElement) {
if (window.jsinterface) { if (window.jsinterface) {
@ -312,9 +308,6 @@ export async function triggerFullscreen(full: boolean) {
return; return;
} }
await document.body.requestFullscreen(); await document.body.requestFullscreen();
requestAnimationFrame(() => {
maxGameScale();
});
} }
} }

View File

@ -435,10 +435,9 @@ export abstract class RenderItem<E extends ERenderItemEvent = ERenderItemEvent>
ctx.globalAlpha = this.alpha; ctx.globalAlpha = this.alpha;
ctx.globalCompositeOperation = this.composite; ctx.globalCompositeOperation = this.composite;
if (this.enableCache) { if (this.enableCache) {
const { width, height, ctx } = this.cache; const { width, height } = this.cache;
if (this.cacheDirty) { if (this.cacheDirty) {
const { canvas } = this.cache; this.cache.clear();
ctx.clearRect(0, 0, canvas.width, canvas.height);
this.render(this.cache, tran); this.render(this.cache, tran);
this.cacheDirty = false; this.cacheDirty = false;
} }

View File

@ -2993,16 +2993,7 @@ control.prototype.checkBgm = function () {
}; };
///// 设置屏幕放缩 ////// ///// 设置屏幕放缩 //////
control.prototype.setDisplayScale = function (delta) { control.prototype.setDisplayScale = function (delta) {};
var index = core.domStyle.availableScale.indexOf(core.domStyle.scale);
if (index < 0) return;
index =
(index + delta + core.domStyle.availableScale.length) %
core.domStyle.availableScale.length;
core.domStyle.scale = core.domStyle.availableScale[index];
core.setLocalStorage('scale', core.domStyle.scale);
core.resize();
};
// ------ 状态栏,工具栏等相关 ------ // // ------ 状态栏,工具栏等相关 ------ //
@ -3085,33 +3076,33 @@ control.prototype.resize = function () {
const width = window.innerWidth; const width = window.innerWidth;
const height = window.innerHeight; const height = window.innerHeight;
if (window.innerWidth >= 600) { // if (window.innerWidth >= 600) {
// 横屏 // // 横屏
core.domStyle.isVertical = false; // core.domStyle.isVertical = false;
core.domStyle.availableScale = []; // core.domStyle.availableScale = [];
const maxScale = Math.min(width / core._PX_, height / core._PY_); // const maxScale = Math.min(width / core._PX_, height / core._PY_);
[1, 1.25, 1.5, 1.75, 2, 2.25, 2.5].forEach(function (v) { // [1, 1.25, 1.5, 1.75, 2, 2.25, 2.5].forEach(function (v) {
if (v < maxScale) { // if (v < maxScale) {
core.domStyle.availableScale.push(v); // core.domStyle.availableScale.push(v);
} // }
}); // });
if (!core.domStyle.availableScale.includes(core.domStyle.scale)) { // if (!core.domStyle.availableScale.includes(core.domStyle.scale)) {
core.domStyle.scale = 1; // core.domStyle.scale = 1;
} // }
} else { // } else {
// 竖屏 // // 竖屏
core.domStyle.isVertical = true; // core.domStyle.isVertical = true;
core.domStyle.scale = window.innerWidth / core._PX_; // core.domStyle.scale = window.innerWidth / core._PX_;
core.domStyle.availableScale = []; // core.domStyle.availableScale = [];
} // }
if (!core.domStyle.isVertical) { // if (!core.domStyle.isVertical) {
const height = window.innerHeight; // const height = window.innerHeight;
const width = window.innerWidth; // const width = window.innerWidth;
const maxScale = Math.min(height / core._PY_, width / core._PX_); // const maxScale = Math.min(height / core._PY_, width / core._PX_);
const target = Number((Math.floor(maxScale * 4) / 4).toFixed(2)); // const target = Number((Math.floor(maxScale * 4) / 4).toFixed(2));
core.domStyle.scale = target - 0.25; // core.domStyle.scale = target - 0.25;
} // }
this._doResize({}); this._doResize({});
this.setToolbarButton(); this.setToolbarButton();

View File

@ -297,21 +297,18 @@ main.prototype.loadAsync = async function (mode, callback) {
if (main.mode === 'editor') return; if (main.mode === 'editor') return;
// 自动放缩最大化 // 自动放缩最大化
let auto = Mota.require('@motajs/legacy-ui').mainSetting.getValue( const mainSetting = Mota.require('@motajs/legacy-ui').mainSetting;
'autoScale', const auto = mainSetting.getValue('utils.autoScale', true);
true
);
if (auto && !core.domStyle.isVertical) { // 暂时不考虑手机端
if (auto) {
const height = window.innerHeight; const height = window.innerHeight;
const width = window.innerWidth; const width = window.innerWidth;
const maxScale = Math.min(height / core._PY_, width / core._PX_); const maxScale = Math.min(height / core._PY_, width / core._PX_);
const target = Number((Math.floor(maxScale * 4) / 4).toFixed(2)); const target = Number((Math.floor(maxScale * 4) / 4).toFixed(2));
core.domStyle.scale = target - 0.25; mainSetting.setValue('screen.scale', Math.round(target * 100) - 25);
}
if (core.domStyle.isVertical) {
core.domStyle.scale = window.innerWidth / core._PX_;
} }
Mota.r(() => { Mota.r(() => {
Mota.require('@user/client-modules').mainRenderer.setScale( Mota.require('@user/client-modules').mainRenderer.setScale(
core.domStyle.scale core.domStyle.scale