mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-11-29 05:24:30 +08:00
feat: 杀掉样板的工具栏
This commit is contained in:
1 parent
4d5f14e8a5
commit
f52f986bfa
41 files changed
+1473
-222
No files matched your search
+97
-77
@@ -312,7 +312,7 @@ interface LoadEvent<T extends keyof ResourceType> extends EmitableEvent {
|
||||
now: number,
|
||||
total: number
|
||||
) => void;
|
||||
load: (resource: ResourceMap[T]) => void | Promise<void>;
|
||||
load: (resource: ResourceMap[T]) => void | Promise<any>;
|
||||
loadStart: (resource: ResourceMap[T]) => void;
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@ export class LoadTask<
|
||||
* 执行加载过程,当加载完毕后,返回的Promise将会被resolve
|
||||
* @returns 加载的Promise
|
||||
*/
|
||||
load(): Promise<ResourceType[T]> {
|
||||
async load(): Promise<ResourceType[T]> {
|
||||
if (this.loadingStarted) {
|
||||
logger.warn(
|
||||
2,
|
||||
@@ -394,14 +394,13 @@ export class LoadTask<
|
||||
);
|
||||
});
|
||||
this.emit('loadStart', this.resource);
|
||||
return load.then(async value => {
|
||||
// @ts-ignore
|
||||
LoadTask.loadedTaskList.add(this);
|
||||
this.loaded = totalByte;
|
||||
LoadTask.loadedTask++;
|
||||
await Promise.all(this.emit('load', this.resource));
|
||||
return value;
|
||||
});
|
||||
const value = await load;
|
||||
// @ts-ignore
|
||||
LoadTask.loadedTaskList.add(this);
|
||||
this.loaded = totalByte;
|
||||
LoadTask.loadedTask++;
|
||||
await Promise.all(this.emit('load', this.resource));
|
||||
return await value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -619,79 +618,100 @@ export async function loadCompressedResource() {
|
||||
res.once('load', resource => {
|
||||
const res = resource.resource;
|
||||
if (!res) return;
|
||||
list.forEach(async v => {
|
||||
const { type, name, usage } = v;
|
||||
const asyncType = types[type];
|
||||
const value = await res
|
||||
.file(`${type}/${name}`)
|
||||
?.async(asyncType);
|
||||
return Promise.all(
|
||||
list.map(async v => {
|
||||
const { type, name, usage } = v;
|
||||
const asyncType = types[type];
|
||||
const value = await res
|
||||
.file(`${type}/${name}`)
|
||||
?.async(asyncType);
|
||||
|
||||
if (!value) return;
|
||||
if (!value) return;
|
||||
|
||||
// 图片类型的资源
|
||||
if (type === 'image') {
|
||||
const img = value as Blob;
|
||||
const image = new Image();
|
||||
image.src = URL.createObjectURL(img);
|
||||
image.addEventListener('load', () => {
|
||||
image.setAttribute('_width', image.width.toString());
|
||||
image.setAttribute('_height', image.height.toString());
|
||||
});
|
||||
// 图片类型的资源
|
||||
if (type === 'image') {
|
||||
const img = value as Blob;
|
||||
const image = new Image();
|
||||
image.src = URL.createObjectURL(img);
|
||||
image.addEventListener('load', () => {
|
||||
image.setAttribute(
|
||||
'_width',
|
||||
image.width.toString()
|
||||
);
|
||||
image.setAttribute(
|
||||
'_height',
|
||||
image.height.toString()
|
||||
);
|
||||
});
|
||||
|
||||
// 图片
|
||||
if (usage === 'image') {
|
||||
core.material.images.images[name as ImageIds] = image;
|
||||
} else if (usage === 'tileset') {
|
||||
// 额外素材
|
||||
core.material.images.tilesets[name] = image;
|
||||
} else if (usage === 'autotile') {
|
||||
// 自动元件
|
||||
autotiles[name.slice(0, -4) as AllIdsOf<'autotile'>] =
|
||||
image;
|
||||
const loading = Mota.require('var', 'loading');
|
||||
loading.addAutotileLoaded();
|
||||
loading.onAutotileLoaded(autotiles);
|
||||
core.material.images.autotile[
|
||||
name.slice(0, -4) as AllIdsOf<'autotile'>
|
||||
] = image;
|
||||
// 图片
|
||||
if (usage === 'image') {
|
||||
core.material.images.images[name as ImageIds] =
|
||||
image;
|
||||
} else if (usage === 'tileset') {
|
||||
// 额外素材
|
||||
core.material.images.tilesets[name] = image;
|
||||
} else if (usage === 'autotile') {
|
||||
// 自动元件
|
||||
autotiles[
|
||||
name.slice(0, -4) as AllIdsOf<'autotile'>
|
||||
] = image;
|
||||
const loading = Mota.require('var', 'loading');
|
||||
loading.addAutotileLoaded();
|
||||
loading.onAutotileLoaded(autotiles);
|
||||
core.material.images.autotile[
|
||||
name.slice(0, -4) as AllIdsOf<'autotile'>
|
||||
] = image;
|
||||
}
|
||||
} else if (type === 'material') {
|
||||
const img = value as Blob;
|
||||
const image = new Image();
|
||||
image.src = URL.createObjectURL(img);
|
||||
image.addEventListener('load', () => {
|
||||
image.setAttribute(
|
||||
'_width',
|
||||
image.width.toString()
|
||||
);
|
||||
image.setAttribute(
|
||||
'_height',
|
||||
image.height.toString()
|
||||
);
|
||||
});
|
||||
|
||||
// material
|
||||
if (materialImages.some(v => name === v + '.png')) {
|
||||
// @ts-ignore
|
||||
core.material.images[
|
||||
name.slice(0, -4) as SelectKey<
|
||||
MaterialImages,
|
||||
HTMLImageElement
|
||||
>
|
||||
] = image;
|
||||
} else if (weathers.some(v => name === v + '.png')) {
|
||||
// @ts-ignore
|
||||
core.animateFrame.weather[v] = image;
|
||||
}
|
||||
}
|
||||
} else if (type === 'material') {
|
||||
const img = value as Blob;
|
||||
const image = new Image();
|
||||
image.src = URL.createObjectURL(img);
|
||||
image.addEventListener('load', () => {
|
||||
image.setAttribute('_width', image.width.toString());
|
||||
image.setAttribute('_height', image.height.toString());
|
||||
});
|
||||
|
||||
// material
|
||||
if (materialImages.some(v => name === v + '.png')) {
|
||||
// @ts-ignore
|
||||
core.material.images[
|
||||
name.slice(0, -4) as SelectKey<
|
||||
MaterialImages,
|
||||
HTMLImageElement
|
||||
>
|
||||
] = image;
|
||||
} else if (weathers.some(v => name === v + '.png')) {
|
||||
// @ts-ignore
|
||||
core.animateFrame.weather[v] = image;
|
||||
} else {
|
||||
if (usage === 'font') {
|
||||
const font = value as ArrayBuffer;
|
||||
document.fonts.add(
|
||||
new FontFace(name.slice(0, -4), font)
|
||||
);
|
||||
} else if (usage === 'sound') {
|
||||
const sound = value as ArrayBuffer;
|
||||
Mota.require('var', 'sound').add(
|
||||
`sounds.${name}`,
|
||||
sound
|
||||
);
|
||||
} else if (usage === 'animate') {
|
||||
const ani = value as string;
|
||||
core.material.animates[
|
||||
name.slice(0, -8) as AnimationIds
|
||||
] = core.loader._loadAnimate(ani);
|
||||
}
|
||||
}
|
||||
|
||||
if (usage === 'font') {
|
||||
const font = value as ArrayBuffer;
|
||||
document.fonts.add(new FontFace(name.slice(0, -4), font));
|
||||
} else if (usage === 'sound') {
|
||||
const sound = value as ArrayBuffer;
|
||||
Mota.require('var', 'sound').add(`sounds.${name}`, sound);
|
||||
} else if (usage === 'animate') {
|
||||
const ani = value as string;
|
||||
core.material.animates[name.slice(0, -8) as AnimationIds] =
|
||||
core.loader._loadAnimate(ani);
|
||||
}
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -73,14 +73,14 @@ function addLightFromBlock(floors: FloorIds[], block: number, config: LightConfi
|
||||
Mota.require('var', 'hook').once('reset', () => {
|
||||
Shadow.init();
|
||||
addLightFromBlock(
|
||||
core.floorIds.slice(61, 70).concat(core.floorIds.slice(72)),
|
||||
core.floorIds.slice(61, 70).concat(core.floorIds.slice(72, 81)).concat(core.floorIds.slice(85, 103)),
|
||||
103,
|
||||
{ decay: 50, r: 300, color: [0.9333, 0.6, 0.333, 0.3] },
|
||||
{ background: [0, 0, 0, 0.26] },
|
||||
{ decay: 50, r: 250, color: [0, 0, 0, 0] }
|
||||
);
|
||||
addLightFromBlock(
|
||||
['MT50', 'MT60', 'MT61'],
|
||||
['MT50', 'MT60', 'MT61', 'MT72', 'MT73', 'MT74', 'MT75'],
|
||||
103,
|
||||
{ decay: 20, r: 150, color: [0.9333, 0.6, 0.333, 0.4], noShelter: true },
|
||||
{ background: [0, 0, 0, 0.4] }
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
} from '@/plugin/utils';
|
||||
import axios, { AxiosResponse, toFormData } from 'axios';
|
||||
import { Component, VNode, h, shallowReactive } from 'vue';
|
||||
/* @__PURE__ */ import { id, password } from '../../../../user';
|
||||
// /* @__PURE__ */ import { id, password } from '../../../../user';
|
||||
import { mainSetting } from '../setting';
|
||||
|
||||
type CSSObj = Partial<Record<CanParseCss, string>>;
|
||||
@@ -135,8 +135,8 @@ export class Danmaku extends EventEmitter<DanmakuEvent> {
|
||||
|
||||
this.posting = true;
|
||||
const form = toFormData(data);
|
||||
/* @__PURE__ */ form.append('userid', id);
|
||||
/* @__PURE__ */ form.append('password', password);
|
||||
// /* @__PURE__ */ form.append('userid', id);
|
||||
// /* @__PURE__ */ form.append('password', password);
|
||||
|
||||
try {
|
||||
const res = await axios.post<PostDanmakuResponse>(
|
||||
@@ -385,8 +385,8 @@ export class Danmaku extends EventEmitter<DanmakuEvent> {
|
||||
};
|
||||
|
||||
const form = toFormData(post);
|
||||
/* @__PURE__ */ form.append('userid', id);
|
||||
/* @__PURE__ */ form.append('password', password);
|
||||
// /* @__PURE__ */ form.append('userid', id);
|
||||
// /* @__PURE__ */ form.append('password', password);
|
||||
|
||||
const res = await axios.post<PostLikeResponse>(Danmaku.backend, form);
|
||||
if (res.data.code !== 0) {
|
||||
@@ -466,8 +466,8 @@ export class Danmaku extends EventEmitter<DanmakuEvent> {
|
||||
type: 1,
|
||||
towername: 'HumanBreak'
|
||||
});
|
||||
/* @__PURE__ */ form.append('userid', id);
|
||||
/* @__PURE__ */ form.append('password', password);
|
||||
// /* @__PURE__ */ form.append('userid', id);
|
||||
// /* @__PURE__ */ form.append('password', password);
|
||||
const data = await axios.post<DanmakuResponse>(Danmaku.backend, form);
|
||||
|
||||
data.data.list.forEach(v => {
|
||||
@@ -515,7 +515,9 @@ Danmaku.registerSpecContent('i', content => {
|
||||
});
|
||||
});
|
||||
|
||||
/* @__PURE__ */ Danmaku.backend = `/danmaku`;
|
||||
if (import.meta.env.DEV) {
|
||||
Danmaku.backend = `/danmaku`;
|
||||
}
|
||||
|
||||
Mota.require('var', 'hook').once('reset', () => {
|
||||
Danmaku.fetch();
|
||||
|
||||
@@ -11,6 +11,7 @@ import type {
|
||||
ToolbarItemMap,
|
||||
ToolbarItemType
|
||||
} from '../init/toolbar';
|
||||
import { isMobile } from '@/plugin/use';
|
||||
|
||||
interface CustomToolbarEvent extends EmitableEvent {
|
||||
add: (item: ValueOf<ToolbarItemMap>) => void;
|
||||
@@ -378,3 +379,51 @@ Mota.require('var', 'loading').once('coreInit', () => {
|
||||
Mota.require('var', 'hook').on('reset', () => {
|
||||
CustomToolbar.showAll();
|
||||
});
|
||||
|
||||
Mota.require('var', 'hook').once('reset', () => {
|
||||
const mainStorage = GameStorage.for(GameStorage.fromGame('main'));
|
||||
mainStorage.read();
|
||||
if (mainStorage.getValue('played', false)) {
|
||||
mainStorage.setValue('played', true);
|
||||
const defaultsTool =
|
||||
CustomToolbar.list.find(v => v.id === '@defaults') ??
|
||||
new CustomToolbar('@defaults', true);
|
||||
defaultsTool.closeAll();
|
||||
defaultsTool.items = reactive([]);
|
||||
defaultsTool.add({
|
||||
id: '@defaults_misc',
|
||||
type: 'misc',
|
||||
folded: false,
|
||||
noDefaultAction: true,
|
||||
items: [
|
||||
'book',
|
||||
'fly',
|
||||
'save',
|
||||
'load',
|
||||
'undo',
|
||||
'redo',
|
||||
'danmaku',
|
||||
'minimap',
|
||||
'toolbox',
|
||||
'equipbox',
|
||||
'shop',
|
||||
'virtualKey',
|
||||
'setting'
|
||||
]
|
||||
});
|
||||
// 计算位置
|
||||
if (isMobile) {
|
||||
// 手机端显示在最下方
|
||||
defaultsTool.setPos(25, window.innerHeight - 100);
|
||||
defaultsTool.setSize(window.innerWidth - 50, 100);
|
||||
} else {
|
||||
// 电脑显示在屏幕右方
|
||||
const x = window.innerWidth / 2 + core.domStyle.scale * 240 + 75;
|
||||
defaultsTool.setPos(x, window.innerHeight / 2 + 100);
|
||||
defaultsTool.setSize(window.innerWidth - x - 75, 200);
|
||||
}
|
||||
|
||||
defaultsTool.show();
|
||||
CustomToolbar.save();
|
||||
}
|
||||
});
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
SelectOption,
|
||||
Switch
|
||||
} from 'ant-design-vue';
|
||||
import { mainSetting } from '../setting';
|
||||
import { MotaSettingItem, mainSetting } from '../setting';
|
||||
import Minimap from '@/components/minimap.vue';
|
||||
import { gameKey } from './hotkey';
|
||||
import { FunctionalComponent, StyleValue, h } from 'vue';
|
||||
@@ -224,21 +224,13 @@ function MiscTool(props: CustomToolbarProps<'misc'>) {
|
||||
justify-content: center;
|
||||
font-size: ${18 * scale}px;
|
||||
`;
|
||||
const blockStyle = `
|
||||
min-width: ${40 * scale}px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: ${40 * scale}px;
|
||||
border: 1px solid #ddd;
|
||||
`;
|
||||
const toolStyle = `
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: ${40 * scale}px;
|
||||
height: ${40 * scale}px;
|
||||
border: 1px solid #ddd;
|
||||
margin-left: ${5 * scale}px;
|
||||
margin: ${5 * scale}px ${5 * scale}px ${5 * scale}px 0;
|
||||
justify-content: center;
|
||||
`;
|
||||
const toolActivedStyle = `
|
||||
@@ -247,7 +239,7 @@ function MiscTool(props: CustomToolbarProps<'misc'>) {
|
||||
min-width: ${40 * scale}px;
|
||||
height: ${40 * scale}px;
|
||||
border: 1px solid #ddd;
|
||||
margin-left: ${5 * scale}px;
|
||||
margin: ${5 * scale}px ${5 * scale}px ${5 * scale}px 0;
|
||||
justify-content: center;
|
||||
color: aqua;
|
||||
`;
|
||||
@@ -255,6 +247,7 @@ function MiscTool(props: CustomToolbarProps<'misc'>) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 ${5 * scale}px;
|
||||
flex-wrap: wrap;
|
||||
`;
|
||||
|
||||
return (
|
||||
@@ -272,7 +265,7 @@ function MiscTool(props: CustomToolbarProps<'misc'>) {
|
||||
<span
|
||||
class="button-text"
|
||||
onClick={triggerFold}
|
||||
style={blockStyle}
|
||||
style={toolStyle}
|
||||
>
|
||||
折叠
|
||||
</span>
|
||||
@@ -753,6 +746,9 @@ Mota.require('var', 'hook').once('reset', () => {
|
||||
CustomToolbar.misc.requestRefresh('minimap');
|
||||
}
|
||||
});
|
||||
const scale = mainSetting.getSetting('ui.toolbarScale') as Readonly<
|
||||
MotaSettingItem<number>
|
||||
>;
|
||||
|
||||
CustomToolbar.misc.register(
|
||||
'danmaku',
|
||||
@@ -760,6 +756,34 @@ Mota.require('var', 'hook').once('reset', () => {
|
||||
openDanmakuPoster,
|
||||
h('span', '发弹幕')
|
||||
);
|
||||
CustomToolbar.misc.register(
|
||||
'book',
|
||||
'怪物手册',
|
||||
() => {
|
||||
core.useItem('book', true);
|
||||
},
|
||||
<img
|
||||
src={core.statusBar.icons.book.src}
|
||||
style={{
|
||||
'object-fit': 'contain',
|
||||
width: `${(scale.value / 100) * 32}px`
|
||||
}}
|
||||
></img>
|
||||
);
|
||||
CustomToolbar.misc.register(
|
||||
'fly',
|
||||
'楼层飞行器',
|
||||
() => {
|
||||
core.useItem('fly', true);
|
||||
},
|
||||
<img
|
||||
src={core.statusBar.icons.fly.src}
|
||||
style={{
|
||||
'object-fit': 'contain',
|
||||
width: `${(scale.value / 100) * 32}px`
|
||||
}}
|
||||
></img>
|
||||
);
|
||||
CustomToolbar.misc.register(
|
||||
'toolbox',
|
||||
'道具栏',
|
||||
@@ -768,7 +792,24 @@ Mota.require('var', 'hook').once('reset', () => {
|
||||
},
|
||||
<img
|
||||
src={core.statusBar.icons.toolbox.src}
|
||||
style="object-fit: contain"
|
||||
style={{
|
||||
'object-fit': 'contain',
|
||||
width: `${(scale.value / 100) * 32}px`
|
||||
}}
|
||||
></img>
|
||||
);
|
||||
CustomToolbar.misc.register(
|
||||
'equipbox',
|
||||
'装备栏',
|
||||
() => {
|
||||
mainUi.open('equipbox');
|
||||
},
|
||||
<img
|
||||
src={core.statusBar.icons.equipbox.src}
|
||||
style={{
|
||||
'object-fit': 'contain',
|
||||
width: `${(scale.value / 100) * 32}px`
|
||||
}}
|
||||
></img>
|
||||
);
|
||||
CustomToolbar.misc.register(
|
||||
@@ -779,7 +820,10 @@ Mota.require('var', 'hook').once('reset', () => {
|
||||
},
|
||||
<img
|
||||
src={core.statusBar.icons.keyboard.src}
|
||||
style="object-fit: contain"
|
||||
style={{
|
||||
'object-fit': 'contain',
|
||||
width: `${(scale.value / 100) * 32}px`
|
||||
}}
|
||||
></img>
|
||||
);
|
||||
CustomToolbar.misc.register(
|
||||
@@ -790,7 +834,10 @@ Mota.require('var', 'hook').once('reset', () => {
|
||||
},
|
||||
<img
|
||||
src={core.statusBar.icons.shop.src}
|
||||
style="object-fit: contain"
|
||||
style={{
|
||||
'object-fit': 'contain',
|
||||
width: `${(scale.value / 100) * 32}px`
|
||||
}}
|
||||
></img>
|
||||
);
|
||||
CustomToolbar.misc.register(
|
||||
@@ -801,7 +848,10 @@ Mota.require('var', 'hook').once('reset', () => {
|
||||
},
|
||||
<img
|
||||
src={core.statusBar.icons.save.src}
|
||||
style="object-fit: contain"
|
||||
style={{
|
||||
'object-fit': 'contain',
|
||||
width: `${(scale.value / 100) * 32}px`
|
||||
}}
|
||||
></img>
|
||||
);
|
||||
CustomToolbar.misc.register(
|
||||
@@ -812,11 +862,14 @@ Mota.require('var', 'hook').once('reset', () => {
|
||||
},
|
||||
<img
|
||||
src={core.statusBar.icons.load.src}
|
||||
style="object-fit: contain"
|
||||
style={{
|
||||
'object-fit': 'contain',
|
||||
width: `${(scale.value / 100) * 32}px`
|
||||
}}
|
||||
></img>
|
||||
);
|
||||
CustomToolbar.misc.register(
|
||||
'redo',
|
||||
'undo',
|
||||
'回退(自动存档)',
|
||||
() => {
|
||||
core.doSL('autoSave', 'load');
|
||||
@@ -824,7 +877,7 @@ Mota.require('var', 'hook').once('reset', () => {
|
||||
h('span', '回退')
|
||||
);
|
||||
CustomToolbar.misc.register(
|
||||
'load',
|
||||
'redo',
|
||||
'恢复(撤销自动存档)',
|
||||
() => {
|
||||
core.doSL('autoSave', 'reload');
|
||||
@@ -839,7 +892,10 @@ Mota.require('var', 'hook').once('reset', () => {
|
||||
},
|
||||
<img
|
||||
src={core.statusBar.icons.settings.src}
|
||||
style="object-fit: contain"
|
||||
style={{
|
||||
'object-fit': 'contain',
|
||||
width: `${(scale.value / 100) * 32}px`
|
||||
}}
|
||||
></img>
|
||||
);
|
||||
CustomToolbar.misc.register(
|
||||
|
||||
@@ -499,7 +499,7 @@ loading.once('coreInit', () => {
|
||||
'screen.heroDetail': !!storage.getValue('screen.heroDetail', false),
|
||||
'screen.transition': !!storage.getValue('screen.transition', false),
|
||||
'screen.antiAlias': !!storage.getValue('screen.antiAlias', false),
|
||||
'screen.fontSize': storage.getValue('screen.fontSize', 16),
|
||||
'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),
|
||||
|
||||
Reference in new issue
Block a user