Compare commits

..

No commits in common. "e65ea56a6848ab24f95f58a7092c928683a589c1" and "aef630006cc4b5994ce25b123fe27ab093e75fce" have entirely different histories.

9 changed files with 124 additions and 69 deletions

View File

@ -1277,7 +1277,6 @@ export class TextContentParser {
break;
}
case TextGuessStatus.NeedSplit: {
this.bsStart = this.blockPointer;
this.bsEnd = this.wordBreak.length;
this.splitTextLoop(node, width);
break;

View File

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

View File

@ -142,7 +142,6 @@ export const ViewMap = defineComponent<ViewMapProps>(props => {
const openBook = () => core.openBook(true);
const fly = () => {
if (!core.hasItem('fly')) return;
const id = viewableFloor[now.value];
const success = core.flyTo(id);
if (success) close();

View File

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

View File

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

View File

@ -295,12 +295,16 @@ export function ensureArray<T>(arr: T): T extends any[] ? T : T[] {
}
export async function triggerFullscreen(full: boolean) {
const { maxGameScale } = Mota.require('@user/data-utils');
if (!!document.fullscreenElement && !full) {
if (window.jsinterface) {
window.jsinterface.requestPortrait();
return;
}
await document.exitFullscreen();
requestAnimationFrame(() => {
maxGameScale(1);
});
}
if (full && !document.fullscreenElement) {
if (window.jsinterface) {
@ -308,6 +312,9 @@ export async function triggerFullscreen(full: boolean) {
return;
}
await document.body.requestFullscreen();
requestAnimationFrame(() => {
maxGameScale();
});
}
}
@ -342,10 +349,10 @@ export function formatSize(size: number) {
return size < 1 << 10
? `${size.toFixed(2)}B`
: size < 1 << 20
? `${(size / (1 << 10)).toFixed(2)}KB`
: size < 1 << 30
? `${(size / (1 << 20)).toFixed(2)}MB`
: `${(size / (1 << 30)).toFixed(2)}GB`;
? `${(size / (1 << 10)).toFixed(2)}KB`
: size < 1 << 30
? `${(size / (1 << 20)).toFixed(2)}MB`
: `${(size / (1 << 30)).toFixed(2)}GB`;
}
export function getIconHeight(icon: AllIds | 'hero') {

View File

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

View File

@ -2993,7 +2993,16 @@ 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();
};
// ------ 状态栏,工具栏等相关 ------ //
@ -3076,33 +3085,33 @@ control.prototype.resize = function () {
const width = window.innerWidth;
const height = window.innerHeight;
// if (window.innerWidth >= 600) {
// // 横屏
// core.domStyle.isVertical = false;
// core.domStyle.availableScale = [];
// 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) {
// if (v < maxScale) {
// core.domStyle.availableScale.push(v);
// }
// });
// if (!core.domStyle.availableScale.includes(core.domStyle.scale)) {
// core.domStyle.scale = 1;
// }
// } else {
// // 竖屏
// core.domStyle.isVertical = true;
// core.domStyle.scale = window.innerWidth / core._PX_;
// core.domStyle.availableScale = [];
// }
if (window.innerWidth >= 600) {
// 横屏
core.domStyle.isVertical = false;
core.domStyle.availableScale = [];
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) {
if (v < maxScale) {
core.domStyle.availableScale.push(v);
}
});
if (!core.domStyle.availableScale.includes(core.domStyle.scale)) {
core.domStyle.scale = 1;
}
} else {
// 竖屏
core.domStyle.isVertical = true;
core.domStyle.scale = window.innerWidth / core._PX_;
core.domStyle.availableScale = [];
}
// if (!core.domStyle.isVertical) {
// const height = window.innerHeight;
// const width = window.innerWidth;
// const maxScale = Math.min(height / core._PY_, width / core._PX_);
// const target = Number((Math.floor(maxScale * 4) / 4).toFixed(2));
// core.domStyle.scale = target - 0.25;
// }
if (!core.domStyle.isVertical) {
const height = window.innerHeight;
const width = window.innerWidth;
const maxScale = Math.min(height / core._PY_, width / core._PX_);
const target = Number((Math.floor(maxScale * 4) / 4).toFixed(2));
core.domStyle.scale = target - 0.25;
}
this._doResize({});
this.setToolbarButton();

View File

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