mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-11-30 22:34:31 +08:00
feat: 指南
This commit is contained in:
1 parent
53fd0493e1
commit
877a6644c8
38 files changed
+4130
-150
No files matched your search
+11
-17
@@ -78,16 +78,7 @@ export class SoundEffect extends AudioPlayer {
|
||||
if (stereo) {
|
||||
this.panner = ac.createPanner();
|
||||
this.panner.connect(this.gain);
|
||||
if (channel === 1) {
|
||||
this.merger = ac.createChannelMerger();
|
||||
this.merger.connect(this.panner);
|
||||
this.baseNode = [
|
||||
{ node: this.merger, channel: 0 },
|
||||
{ node: this.merger, channel: 1 }
|
||||
];
|
||||
} else {
|
||||
this.baseNode = [{ node: this.panner }];
|
||||
}
|
||||
this.baseNode = [{ node: this.panner }];
|
||||
} else {
|
||||
this.baseNode = [{ node: this.gain }];
|
||||
}
|
||||
@@ -136,15 +127,18 @@ export class SoundEffect extends AudioPlayer {
|
||||
* @param source 立体声声源位置与朝向
|
||||
* @param listener 听者的位置、头顶方向、面朝方向
|
||||
*/
|
||||
setPanner(source: Partial<Panner>, listener: Partial<Listener>) {
|
||||
setPanner(source?: Partial<Panner>, listener?: Partial<Listener>) {
|
||||
if (!this.panner) return;
|
||||
console.log(2);
|
||||
for (const [key, value] of Object.entries(source)) {
|
||||
this.panner[key as keyof Panner].value = value;
|
||||
if (source) {
|
||||
for (const [key, value] of Object.entries(source)) {
|
||||
this.panner[key as keyof Panner].value = value;
|
||||
}
|
||||
}
|
||||
const l = AudioPlayer.ac.listener;
|
||||
for (const [key, value] of Object.entries(listener)) {
|
||||
l[key as keyof Listener].value = value;
|
||||
if (listener) {
|
||||
const l = AudioPlayer.ac.listener;
|
||||
for (const [key, value] of Object.entries(listener)) {
|
||||
l[key as keyof Listener].value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ export class IndexedEventEmitter<
|
||||
event: K,
|
||||
symbol: IndexedSymbol,
|
||||
fn: T[K],
|
||||
options: Partial<ListenerOptions>
|
||||
options?: Partial<ListenerOptions>
|
||||
) {
|
||||
const map = this.ensureMap(event);
|
||||
if (map.has(symbol)) {
|
||||
|
||||
+25
-3
@@ -26,7 +26,7 @@ import {
|
||||
} from './main/custom/hotkey';
|
||||
import { Keyboard, generateKeyboardEvent } from './main/custom/keyboard';
|
||||
import './main/layout';
|
||||
import { MComponent, icon, m } from './main/layout';
|
||||
import { MComponent, m } from './main/layout';
|
||||
import { createSettingComponents } from './main/init/settings';
|
||||
import {
|
||||
createToolbarComponents,
|
||||
@@ -45,6 +45,17 @@ import * as fixedTools from '@/plugin/ui/fixed';
|
||||
import * as flyTools from '@/plugin/ui/fly';
|
||||
import * as statusBarTools from '@/plugin/ui/statusBar';
|
||||
import * as toolboxTools from '@/plugin/ui/toolbox';
|
||||
import * as UI from '@ui/index';
|
||||
import Box from '@/components/box.vue';
|
||||
import BoxAnimate from '@/components/boxAnimate.vue.vue';
|
||||
import Colomn from '@/components/colomn.vue.vue';
|
||||
import EnemyOne from '@/components/enemyOne.vue.vue';
|
||||
import Scroll from '@/components/scroll.vue.vue';
|
||||
import EnemyCritical from '@/panel/enemyCritical.vue';
|
||||
import EnemySpecial from '@/panel/enemySpecial.vue.vue';
|
||||
import EnemyTarget from '@/panel/enemyTarget.vue.vue';
|
||||
import KeyboardPanel from '@/panel/keyboard.vue.vue';
|
||||
import { MCGenerator } from './main/layout';
|
||||
|
||||
// ----- 类注册
|
||||
Mota.register('class', 'AudioPlayer', AudioPlayer);
|
||||
@@ -63,7 +74,6 @@ Mota.register('class', 'UiController', UiController);
|
||||
Mota.register('class', 'MComponent', MComponent);
|
||||
// ----- 函数注册
|
||||
Mota.register('fn', 'm', m);
|
||||
Mota.register('fn', 'icon', icon);
|
||||
Mota.register('fn', 'unwrapBinary', unwarpBinary);
|
||||
Mota.register('fn', 'checkAssist', checkAssist);
|
||||
Mota.register('fn', 'isAssist', isAssist);
|
||||
@@ -81,7 +91,6 @@ Mota.register('var', 'KeyCode', KeyCode);
|
||||
Mota.register('var', 'ScanCode', ScanCode);
|
||||
Mota.register('var', 'settingStorage', settingStorage);
|
||||
Mota.register('var', 'status', status);
|
||||
|
||||
// ----- 模块注册
|
||||
Mota.register('module', 'CustomComponents', {
|
||||
createSettingComponents,
|
||||
@@ -104,6 +113,19 @@ Mota.register('module', 'UITools', {
|
||||
statusBar: statusBarTools,
|
||||
toolbox: toolboxTools
|
||||
});
|
||||
Mota.register('module', 'UI', UI);
|
||||
Mota.register('module', 'UIComponents', {
|
||||
Box,
|
||||
BoxAnimate,
|
||||
Colomn,
|
||||
EnemyOne,
|
||||
Scroll,
|
||||
EnemyCritical,
|
||||
EnemySpecial,
|
||||
EnemyTarget,
|
||||
Keyboard: KeyboardPanel
|
||||
});
|
||||
Mota.register('module', 'MCGenerator', MCGenerator);
|
||||
|
||||
main.renderLoaded = true;
|
||||
Mota.require('var', 'hook').emit('renderLoaded');
|
||||
@@ -137,7 +137,7 @@ export class Hotkey extends EventEmitter<HotkeyEvent> {
|
||||
* 释放一个作用域,释放后作用域将退回至删除的作用域的上一级
|
||||
* @param symbol 要释放的作用域的symbol
|
||||
*/
|
||||
dispose(symbol: symbol) {
|
||||
dispose(symbol: symbol = this.scopeStack.at(-1) ?? Symbol()) {
|
||||
for (const key of Object.values(this.data)) {
|
||||
key.func.delete(symbol);
|
||||
}
|
||||
|
||||
@@ -74,16 +74,6 @@ gameKey
|
||||
name: '浏览地图_2',
|
||||
defaults: KeyCode.PageDown
|
||||
})
|
||||
.register({
|
||||
id: 'skillTree',
|
||||
name: '技能树',
|
||||
defaults: KeyCode.KeyJ
|
||||
})
|
||||
.register({
|
||||
id: 'desc',
|
||||
name: '百科全书',
|
||||
defaults: KeyCode.KeyH
|
||||
})
|
||||
// --------------------
|
||||
.group('function', '功能按键')
|
||||
.register({
|
||||
@@ -256,20 +246,6 @@ gameKey
|
||||
defaults: KeyCode.KeyC
|
||||
})
|
||||
// --------------------
|
||||
.group('@ui_start', '开始界面')
|
||||
.register({
|
||||
id: '@start_up',
|
||||
name: '上移光标',
|
||||
defaults: KeyCode.UpArrow,
|
||||
type: 'down'
|
||||
})
|
||||
.register({
|
||||
id: '@start_down',
|
||||
name: '下移光标',
|
||||
defaults: KeyCode.DownArrow,
|
||||
type: 'down'
|
||||
})
|
||||
// --------------------
|
||||
.group('@ui_book', '怪物手册')
|
||||
.register({
|
||||
id: '@book_up',
|
||||
|
||||
@@ -9,7 +9,7 @@ interface Components {
|
||||
Number: SettingComponent;
|
||||
HotkeySetting: SettingComponent;
|
||||
ToolbarEditor: SettingComponent;
|
||||
RadioSetting: (items: string[]) => SettingComponent;
|
||||
Radio: (items: string[]) => SettingComponent;
|
||||
}
|
||||
|
||||
export type { Components as SettingDisplayComponents };
|
||||
@@ -21,7 +21,7 @@ export function createSettingComponents() {
|
||||
Number: NumberSetting,
|
||||
HotkeySetting,
|
||||
ToolbarEditor,
|
||||
RadioSetting
|
||||
Radio: RadioSetting
|
||||
};
|
||||
return com;
|
||||
}
|
||||
|
||||
+134
-60
@@ -5,10 +5,12 @@ import {
|
||||
VNode,
|
||||
VNodeChild,
|
||||
defineComponent,
|
||||
h,
|
||||
h as hVue,
|
||||
isVNode,
|
||||
onMounted
|
||||
} from 'vue';
|
||||
import BoxAnimate from '@/components/boxAnimate.vue';
|
||||
import { ensureArray } from '@/plugin/utils';
|
||||
|
||||
interface VForRenderer {
|
||||
type: '@v-for';
|
||||
@@ -18,7 +20,7 @@ interface VForRenderer {
|
||||
|
||||
interface MotaComponent extends MotaComponentConfig {
|
||||
type: string;
|
||||
children: MComponent[] | MComponent;
|
||||
children: (MComponent | MotaComponent | VNode)[];
|
||||
}
|
||||
|
||||
interface MotaComponentConfig {
|
||||
@@ -32,7 +34,7 @@ interface MotaComponentConfig {
|
||||
velse?: boolean;
|
||||
}
|
||||
|
||||
type OnSetupFunction = (props: Record<string, any>) => void;
|
||||
type OnSetupFunction = (props: Record<string, any>, ctx: SetupContext) => void;
|
||||
type SetupFunction = (
|
||||
props: Record<string, any>,
|
||||
ctx: SetupContext
|
||||
@@ -43,6 +45,7 @@ type RetFunction = (
|
||||
) => VNodeChild | VNodeChild[];
|
||||
type OnMountedFunction = (
|
||||
props: Record<string, any>,
|
||||
ctx: SetupContext,
|
||||
canvas: HTMLCanvasElement[]
|
||||
) => void;
|
||||
|
||||
@@ -51,6 +54,12 @@ type NonComponentConfig = Omit<
|
||||
'innerText' | 'component' | 'slots' | 'dComponent'
|
||||
>;
|
||||
|
||||
type MComponentChildren =
|
||||
| (MComponent | MotaComponent | VNode)[]
|
||||
| MComponent
|
||||
| MotaComponent
|
||||
| VNode;
|
||||
|
||||
export class MComponent {
|
||||
static mountNum: number = 0;
|
||||
|
||||
@@ -88,7 +97,7 @@ export class MComponent {
|
||||
* @param children 渲染内容的子内容
|
||||
* @param config 渲染内容的配置信息,参考 {@link MComponent.h}
|
||||
*/
|
||||
div(children?: MComponent[] | MComponent, config?: NonComponentConfig) {
|
||||
div(children?: MComponentChildren, config?: NonComponentConfig) {
|
||||
return this.h('div', children, config);
|
||||
}
|
||||
|
||||
@@ -97,7 +106,7 @@ export class MComponent {
|
||||
* @param children 渲染内容的子内容
|
||||
* @param config 渲染内容的配置信息,参考 {@link MComponent.h}
|
||||
*/
|
||||
span(children?: MComponent[] | MComponent, config?: NonComponentConfig) {
|
||||
span(children?: MComponentChildren, config?: NonComponentConfig) {
|
||||
return this.h('span', children, config);
|
||||
}
|
||||
|
||||
@@ -136,11 +145,7 @@ export class MComponent {
|
||||
* 或者MComponent.vNode函数生成。
|
||||
*/
|
||||
vfor<T>(items: T[] | (() => T[]), map: (value: T, index: number) => VNode) {
|
||||
this.content.push({
|
||||
type: '@v-for',
|
||||
items,
|
||||
map
|
||||
});
|
||||
this.content.push(MCGenerator.vfor(items, map));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -180,32 +185,10 @@ export class MComponent {
|
||||
*/
|
||||
h(
|
||||
type: string | Component | MComponent,
|
||||
children?: MComponent[] | MComponent,
|
||||
children?: MComponentChildren,
|
||||
config: MotaComponentConfig = {}
|
||||
): this {
|
||||
if (typeof type === 'string') {
|
||||
this.content.push({
|
||||
type,
|
||||
children: children ?? [],
|
||||
props: config.props,
|
||||
innerText: config.innerText,
|
||||
slots: config.slots,
|
||||
vif: config.vif,
|
||||
velse: config.velse,
|
||||
component: config.component
|
||||
});
|
||||
} else {
|
||||
this.content.push({
|
||||
type: 'component',
|
||||
children: children ?? [],
|
||||
props: config.props,
|
||||
innerText: config.innerText,
|
||||
slots: config.slots,
|
||||
vif: config.vif,
|
||||
velse: config.velse,
|
||||
component: type
|
||||
});
|
||||
}
|
||||
this.content.push(MCGenerator.h(type, children, config));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -253,11 +236,12 @@ export class MComponent {
|
||||
return defineComponent(
|
||||
(props, ctx) => {
|
||||
const mountNum = MComponent.mountNum++;
|
||||
this.onSetupFn?.(props);
|
||||
this.onSetupFn?.(props, ctx);
|
||||
|
||||
onMounted(() => {
|
||||
this.onMountedFn?.(
|
||||
props,
|
||||
ctx,
|
||||
Array.from(
|
||||
document.getElementsByClassName(
|
||||
`--mota-component-canvas-${mountNum}`
|
||||
@@ -269,8 +253,6 @@ export class MComponent {
|
||||
if (this.retFn) return () => this.retFn!(props, ctx);
|
||||
else {
|
||||
return () => {
|
||||
console.log(ctx.slots.default);
|
||||
|
||||
const vNodes = MComponent.vNode(
|
||||
this.content,
|
||||
mountNum
|
||||
@@ -312,12 +294,19 @@ export class MComponent {
|
||||
* @param children 要生成VNode的内容列表
|
||||
* @param mount 组件生成时的挂载id,一般不需要填,用于画布获取
|
||||
*/
|
||||
static vNode(children: (MotaComponent | VForRenderer)[], mount?: number) {
|
||||
static vNode(
|
||||
children: (MotaComponent | VForRenderer | VNode)[],
|
||||
mount?: number
|
||||
) {
|
||||
const mountNum = mount ?? this.mountNum++;
|
||||
|
||||
const res: VNode[] = [];
|
||||
const vifRes: Map<number, boolean> = new Map();
|
||||
children.forEach((v, i) => {
|
||||
if (isVNode(v)) {
|
||||
res.push(v);
|
||||
return;
|
||||
}
|
||||
if (v.type === '@v-for') {
|
||||
const node = v as VForRenderer;
|
||||
const items =
|
||||
@@ -346,7 +335,7 @@ export class MComponent {
|
||||
);
|
||||
}
|
||||
if (v.dComponent) {
|
||||
res.push(h(v.dComponent(), props, v.slots));
|
||||
res.push(hVue(v.dComponent(), props, v.slots));
|
||||
} else {
|
||||
if (v.component instanceof MComponent) {
|
||||
res.push(
|
||||
@@ -356,12 +345,12 @@ export class MComponent {
|
||||
)
|
||||
);
|
||||
} else {
|
||||
res.push(h(v.component!, props, v.slots));
|
||||
res.push(hVue(v.component!, props, v.slots));
|
||||
}
|
||||
}
|
||||
} else if (v.type === 'text') {
|
||||
res.push(
|
||||
h(
|
||||
hVue(
|
||||
'span',
|
||||
typeof v.innerText === 'function'
|
||||
? v.innerText()
|
||||
@@ -372,15 +361,17 @@ export class MComponent {
|
||||
const cls = `--mota-component-canvas-${mountNum}`;
|
||||
const mix = !!props.class ? cls + ' ' + props.class : cls;
|
||||
props.class = mix;
|
||||
res.push(h('canvas', props, node.slots));
|
||||
res.push(hVue('canvas', props, node.slots));
|
||||
} else {
|
||||
// 这个时候不可能会有插槽,只会有子内容,因此直接渲染子内容
|
||||
const content = [node.children].flat(2);
|
||||
const content = node.children;
|
||||
const vn = this.vNode(
|
||||
content.map(v => v.content).flat(),
|
||||
content
|
||||
.map(v => (v instanceof MComponent ? v.content : v))
|
||||
.flat(),
|
||||
mountNum
|
||||
);
|
||||
res.push(h(v.type, props, vn));
|
||||
res.push(hVue(v.type, props, vn));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -406,7 +397,7 @@ export class MComponent {
|
||||
* @param props 要传递的props
|
||||
*/
|
||||
static prop(component: Component, props: Record<string, any>) {
|
||||
return h(component, props);
|
||||
return hVue(component, props);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,18 +409,101 @@ export function m() {
|
||||
return new MComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成一个图标的VNode
|
||||
* @param id 图标的id
|
||||
* @param width 显示宽度,单位像素
|
||||
* @param height 显示高度,单位像素
|
||||
* @param noBoarder 显示的时候是否没有边框和背景
|
||||
*/
|
||||
export function icon(
|
||||
id: AllIds,
|
||||
width?: number,
|
||||
height?: number,
|
||||
noBoarder?: number
|
||||
) {
|
||||
return h(BoxAnimate, { id, width, height, noBoarder });
|
||||
export namespace MCGenerator {
|
||||
export function h(
|
||||
type: string | Component | MComponent,
|
||||
children?: MComponentChildren,
|
||||
config: MotaComponentConfig = {}
|
||||
): MotaComponent {
|
||||
if (typeof type === 'string') {
|
||||
return {
|
||||
type,
|
||||
children: ensureArray(children ?? []),
|
||||
props: config.props,
|
||||
innerText: config.innerText,
|
||||
slots: config.slots,
|
||||
vif: config.vif,
|
||||
velse: config.velse,
|
||||
component: config.component
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
type: 'component',
|
||||
children: ensureArray(children ?? []),
|
||||
props: config.props,
|
||||
innerText: config.innerText,
|
||||
slots: config.slots,
|
||||
vif: config.vif,
|
||||
velse: config.velse,
|
||||
component: type
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function div(
|
||||
children?: MComponentChildren,
|
||||
config?: NonComponentConfig
|
||||
): MotaComponent {
|
||||
return h('div', children, config);
|
||||
}
|
||||
|
||||
export function span(
|
||||
children?: MComponentChildren,
|
||||
config?: NonComponentConfig
|
||||
): MotaComponent {
|
||||
return h('span', children, config);
|
||||
}
|
||||
|
||||
export function canvas(config?: NonComponentConfig): MotaComponent {
|
||||
return h('canvas', [], config);
|
||||
}
|
||||
|
||||
export function text(
|
||||
text: string | (() => string),
|
||||
config: NonComponentConfig = {}
|
||||
): MotaComponent {
|
||||
return h('text', [], { ...config, innerText: text });
|
||||
}
|
||||
|
||||
export function com(
|
||||
component: Component | MComponent,
|
||||
config: Omit<MotaComponentConfig, 'innerText' | 'component'>
|
||||
): MotaComponent {
|
||||
return h(component, [], config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成一个图标的VNode
|
||||
* @param id 图标的id
|
||||
* @param width 显示宽度,单位像素
|
||||
* @param height 显示高度,单位像素
|
||||
* @param noBoarder 显示的时候是否没有边框和背景
|
||||
*/
|
||||
export function icon(
|
||||
id: AllIds,
|
||||
width?: number,
|
||||
height?: number,
|
||||
noBoarder?: number
|
||||
): VNode {
|
||||
return hVue(BoxAnimate, { id, width, height, noBoarder });
|
||||
}
|
||||
|
||||
export function vfor<T>(
|
||||
items: T[] | (() => T[]),
|
||||
map: (value: T, index: number) => VNode
|
||||
): VForRenderer {
|
||||
return {
|
||||
type: '@v-for',
|
||||
items,
|
||||
map
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 为一个常量创建为一个函数
|
||||
* @param value 要创建成函数的值
|
||||
*/
|
||||
export function f<T>(value: T): () => T {
|
||||
return () => value;
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ export class MotaSetting extends EventEmitter<SettingEvent> {
|
||||
let now: MotaSetting = this;
|
||||
|
||||
for (let i = 0; i < list.length - 1; i++) {
|
||||
const item = now.list[list[i]].value;
|
||||
const item = now.list[list[i]]?.value;
|
||||
if (!(item instanceof MotaSetting)) {
|
||||
throw new Error(
|
||||
`Cannot get setting. The parent isn't a MotaSetting instance.` +
|
||||
@@ -267,7 +267,7 @@ export class SettingDisplayer extends EventEmitter<SettingDisplayerEvent> {
|
||||
this.displayInfo = [];
|
||||
|
||||
for (let i = 0; i < list.length - 1; i++) {
|
||||
const item = now.list[list[i]].value;
|
||||
const item = now.list[list[i]]?.value;
|
||||
if (!(item instanceof MotaSetting)) {
|
||||
throw new Error(
|
||||
`Cannot get setting. The parent isn't a MotaSetting instance.` +
|
||||
@@ -443,13 +443,9 @@ mainSetting
|
||||
.register(
|
||||
'ui',
|
||||
'ui设置',
|
||||
new MotaSetting().register(
|
||||
'mapScale',
|
||||
'小地图楼传缩放',
|
||||
100,
|
||||
COM.Number,
|
||||
[50, 1000, 50]
|
||||
)
|
||||
new MotaSetting()
|
||||
.register('mapScale', '小地图缩放', 100, COM.Number, [50, 1000, 50])
|
||||
.setDisplayFunc('mapScale', value => `${value}%`)
|
||||
);
|
||||
|
||||
const loading = Mota.require('var', 'loading');
|
||||
|
||||
@@ -78,7 +78,7 @@ export class GameStorage<T extends object = any> {
|
||||
* @param key 存储名称
|
||||
*/
|
||||
static fromGame(key: string) {
|
||||
return `HumanBreak_${key}`;
|
||||
return `${data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.firstData.name}_${key}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@ interface HaloType {
|
||||
};
|
||||
}
|
||||
|
||||
interface EnemyInfo extends Partial<SelectType<Enemy, number | undefined>> {
|
||||
interface EnemyInfo extends Partial<Enemy> {
|
||||
atk: number;
|
||||
def: number;
|
||||
hp: number;
|
||||
@@ -68,7 +68,7 @@ interface CriticalDamageDelta extends Omit<DamageDelta, 'info'> {
|
||||
atkDelta: number;
|
||||
}
|
||||
|
||||
type HaloFn = (info: EnemyInfo, enemy: Enemy) => void;
|
||||
type HaloFn = (info: EnemyInfo, enemy: EnemyInfo) => void;
|
||||
|
||||
export class EnemyCollection implements RangeCollection<DamageEnemy> {
|
||||
floorId: FloorIds;
|
||||
@@ -165,13 +165,13 @@ export class EnemyCollection implements RangeCollection<DamageEnemy> {
|
||||
if (!recursion) {
|
||||
arr.forEach(v => {
|
||||
enemys.forEach(e => {
|
||||
e.injectHalo(v, enemy.enemy);
|
||||
e.injectHalo(v, enemy.info);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
enemys.forEach(e => {
|
||||
arr.forEach(v => {
|
||||
e.injectHalo(v, enemy.enemy);
|
||||
e.injectHalo(v, enemy.info);
|
||||
e.preProvideHalo();
|
||||
});
|
||||
});
|
||||
@@ -446,7 +446,7 @@ export class DamageEnemy<T extends EnemyIds = EnemyIds> {
|
||||
/**
|
||||
* 接受其他怪的光环
|
||||
*/
|
||||
injectHalo(halo: HaloFn, enemy: Enemy) {
|
||||
injectHalo(halo: HaloFn, enemy: EnemyInfo) {
|
||||
halo(this.info, enemy);
|
||||
}
|
||||
|
||||
|
||||
+24
-2
@@ -27,7 +27,7 @@ import type { specials } from './enemy/special';
|
||||
import type { Range } from '@/plugin/game/range';
|
||||
import type { KeyCode, ScanCode } from '@/plugin/keyCodes';
|
||||
import type { Ref } from 'vue';
|
||||
import type { MComponent, m, icon } from '@/core/main/layout';
|
||||
import type { MComponent, m, MCGenerator } from '@/core/main/layout';
|
||||
import type { addAnimate, removeAnimate } from '@/plugin/animateController';
|
||||
import type { createSettingComponents } from '@/core/main/init/settings';
|
||||
import type {
|
||||
@@ -72,6 +72,16 @@ import type * as _lodash from 'lodash-es';
|
||||
import type * as _lzString from 'lz-string';
|
||||
import type * as _mutateAnimate from 'mutate-animate';
|
||||
import type * as _vue from 'vue';
|
||||
import type * as UI from '@ui/index';
|
||||
import type Box from '@/components/box.vue';
|
||||
import type BoxAnimate from '@/components/boxAnimate.vue.vue';
|
||||
import type Colomn from '@/components/colomn.vue.vue';
|
||||
import type EnemyOne from '@/components/enemyOne.vue.vue';
|
||||
import type Scroll from '@/components/scroll.vue.vue';
|
||||
import type EnemyCritical from '@/panel/enemyCritical.vue';
|
||||
import type EnemySpecial from '@/panel/enemySpecial.vue.vue';
|
||||
import type EnemyTarget from '@/panel/enemyTarget.vue.vue';
|
||||
import type KeyboardPanel from '@/panel/keyboard.vue.vue';
|
||||
|
||||
export interface ClassInterface {
|
||||
// 渲染进程与游戏进程通用
|
||||
@@ -105,7 +115,6 @@ type _IHero = typeof hero;
|
||||
export interface FunctionInterface extends _IBattle, _IHero {
|
||||
// 定义于渲染进程,录像验证中会出错
|
||||
m: typeof m;
|
||||
icon: typeof icon;
|
||||
unwrapBinary: typeof unwarpBinary;
|
||||
checkAssist: typeof checkAssist;
|
||||
isAssist: typeof isAssist;
|
||||
@@ -150,6 +159,19 @@ export interface ModuleInterface {
|
||||
typeof statusBarTools &
|
||||
typeof toolboxTools;
|
||||
Damage: typeof Damage;
|
||||
UI: typeof UI;
|
||||
UIComponents: {
|
||||
Box: typeof Box;
|
||||
BoxAnimate: typeof BoxAnimate;
|
||||
Colomn: typeof Colomn;
|
||||
EnemyOne: typeof EnemyOne;
|
||||
Scroll: typeof Scroll;
|
||||
EnemyCritical: typeof EnemyCritical;
|
||||
EnemySpecial: typeof EnemySpecial;
|
||||
EnemyTarget: typeof EnemyTarget;
|
||||
KeyboardPanel: typeof KeyboardPanel;
|
||||
};
|
||||
MCGenerator: typeof MCGenerator;
|
||||
}
|
||||
|
||||
export interface SystemInterfaceMap {
|
||||
|
||||
+231
-1
@@ -1,11 +1,20 @@
|
||||
import { loading } from '@/game/game';
|
||||
|
||||
let _shouldProcessKeyUp = true;
|
||||
|
||||
export function openShop(shopId: string, noRoute: boolean) {
|
||||
const shop = core.status.shops[shopId] as ItemShopEvent;
|
||||
const shop = core.status.shops[shopId] as any;
|
||||
// Step 1: 检查能否打开此商店
|
||||
if (!canOpenShop(shopId)) {
|
||||
core.drawTip('该商店尚未开启');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Step 2: (如有必要)记录打开商店的脚本事件
|
||||
if (!noRoute && !shop.item) {
|
||||
core.status.route.push('shop:' + shopId);
|
||||
}
|
||||
|
||||
// Step 3: 检查道具商店 or 公共事件
|
||||
if (shop.item) {
|
||||
Mota.r(() => {
|
||||
@@ -17,9 +26,124 @@ export function openShop(shopId: string, noRoute: boolean) {
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (shop.commonEvent) {
|
||||
core.insertCommonEvent(shop.commonEvent, shop.args);
|
||||
return;
|
||||
}
|
||||
|
||||
_shouldProcessKeyUp = true;
|
||||
|
||||
// Step 4: 执行标准公共商店
|
||||
core.insertAction(_convertShop(shop));
|
||||
return true;
|
||||
}
|
||||
|
||||
////// 将一个全局商店转变成可预览的公共事件 //////
|
||||
function _convertShop(shop: any) {
|
||||
return [
|
||||
{
|
||||
type: 'function',
|
||||
function: "function() {core.addFlag('@temp@shop', 1);}"
|
||||
},
|
||||
{
|
||||
type: 'while',
|
||||
condition: 'true',
|
||||
data: [
|
||||
// 检测能否访问该商店
|
||||
{
|
||||
type: 'if',
|
||||
condition: "core.isShopVisited('" + shop.id + "')",
|
||||
true: [
|
||||
// 可以访问,直接插入执行效果
|
||||
{
|
||||
type: 'function',
|
||||
function:
|
||||
"function() { core.plugin._convertShop_replaceChoices('" +
|
||||
shop.id +
|
||||
"', false) }"
|
||||
}
|
||||
],
|
||||
false: [
|
||||
// 不能访问的情况下:检测能否预览
|
||||
{
|
||||
type: 'if',
|
||||
condition: shop.disablePreview,
|
||||
true: [
|
||||
// 不可预览,提示并退出
|
||||
{ type: 'playSound', name: '操作失败' },
|
||||
'当前无法访问该商店!',
|
||||
{ type: 'break' }
|
||||
],
|
||||
false: [
|
||||
// 可以预览:将商店全部内容进行替换
|
||||
{
|
||||
type: 'tip',
|
||||
text: '当前处于预览模式,不可购买'
|
||||
},
|
||||
{
|
||||
type: 'function',
|
||||
function:
|
||||
"function() { core.plugin._convertShop_replaceChoices('" +
|
||||
shop.id +
|
||||
"', true) }"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'function',
|
||||
function: "function() {core.addFlag('@temp@shop', -1);}"
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
function _convertShop_replaceChoices(shopId: string, previewMode: boolean) {
|
||||
var shop = core.status.shops[shopId] as any;
|
||||
var choices = (shop.choices || [])
|
||||
.filter(function (choice: any) {
|
||||
if (choice.condition == null || choice.condition == '') return true;
|
||||
try {
|
||||
return core.calValue(choice.condition);
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
.map(function (choice: any) {
|
||||
var ableToBuy = core.calValue(choice.need);
|
||||
return {
|
||||
text: choice.text,
|
||||
icon: choice.icon,
|
||||
color:
|
||||
ableToBuy && !previewMode
|
||||
? choice.color
|
||||
: [153, 153, 153, 1],
|
||||
action:
|
||||
ableToBuy && !previewMode
|
||||
? [{ type: 'playSound', name: '商店' }].concat(
|
||||
choice.action
|
||||
)
|
||||
: [
|
||||
{ type: 'playSound', name: '操作失败' },
|
||||
{
|
||||
type: 'tip',
|
||||
text: previewMode
|
||||
? '预览模式下不可购买'
|
||||
: '购买条件不足'
|
||||
}
|
||||
]
|
||||
};
|
||||
})
|
||||
.concat({
|
||||
text: '离开',
|
||||
action: [{ type: 'playSound', name: '取消' }, { type: 'break' }]
|
||||
});
|
||||
core.insertAction({ type: 'choices', text: shop.text, choices: choices });
|
||||
}
|
||||
|
||||
/// 是否访问过某个快捷商店
|
||||
export function isShopVisited(id: string) {
|
||||
flags.__shops__ ??= {};
|
||||
@@ -64,3 +188,109 @@ export function canUseQuickShop() {
|
||||
return '当前楼层不能使用快捷商店。';
|
||||
return null;
|
||||
}
|
||||
|
||||
loading.once('coreInit', () => {
|
||||
/// 允许商店X键退出
|
||||
core.registerAction(
|
||||
'keyUp',
|
||||
'shops',
|
||||
function (keycode) {
|
||||
if (!core.status.lockControl || core.status.event.id != 'action')
|
||||
return false;
|
||||
if ((keycode == 13 || keycode == 32) && !_shouldProcessKeyUp) {
|
||||
_shouldProcessKeyUp = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
!core.hasFlag('@temp@shop') ||
|
||||
// @ts-ignore
|
||||
core.status.event.data!.type != 'choices'
|
||||
)
|
||||
return false;
|
||||
// @ts-ignore
|
||||
var data = core.status.event.data.current;
|
||||
var choices = data.choices;
|
||||
// @ts-ignore
|
||||
var topIndex = core.actions._getChoicesTopIndex(choices.length);
|
||||
if (keycode == 88 || keycode == 27) {
|
||||
// X, ESC
|
||||
// @ts-ignore
|
||||
core.actions._clickAction(
|
||||
core._HALF_WIDTH_ || core.__HALF_SIZE__,
|
||||
topIndex + choices.length - 1
|
||||
);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
60
|
||||
);
|
||||
|
||||
/// 允许长按空格或回车连续执行操作
|
||||
core.registerAction(
|
||||
'keyDown',
|
||||
'shops',
|
||||
function (keycode) {
|
||||
if (
|
||||
!core.status.lockControl ||
|
||||
!core.hasFlag('@temp@shop') ||
|
||||
core.status.event.id != 'action'
|
||||
)
|
||||
return false;
|
||||
// @ts-ignore
|
||||
if (core.status.event.data.type != 'choices') return false;
|
||||
// @ts-ignore
|
||||
core.status.onShopLongDown = true;
|
||||
// @ts-ignore
|
||||
var data = core.status.event.data.current;
|
||||
var choices = data.choices;
|
||||
// @ts-ignore
|
||||
var topIndex = core.actions._getChoicesTopIndex(choices.length);
|
||||
if (keycode == 13 || keycode == 32) {
|
||||
// Space, Enter
|
||||
// @ts-ignore
|
||||
core.actions._clickAction(
|
||||
core._HALF_WIDTH_ || core.__HALF_SIZE__,
|
||||
topIndex + core.status.event.selection
|
||||
);
|
||||
_shouldProcessKeyUp = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
60
|
||||
);
|
||||
|
||||
// 允许长按屏幕连续执行操作
|
||||
core.registerAction(
|
||||
'longClick',
|
||||
'shops',
|
||||
function (x, y, px, py) {
|
||||
if (
|
||||
!core.status.lockControl ||
|
||||
!core.hasFlag('@temp@shop') ||
|
||||
core.status.event.id != 'action'
|
||||
)
|
||||
return false;
|
||||
// @ts-ignore
|
||||
if (core.status.event.data.type != 'choices') return false;
|
||||
// @ts-ignore
|
||||
var data = core.status.event.data.current;
|
||||
var choices = data.choices;
|
||||
// @ts-ignore
|
||||
var topIndex = core.actions._getChoicesTopIndex(choices.length);
|
||||
if (
|
||||
Math.abs(x - (core._HALF_WIDTH_ || core.__HALF_SIZE__)) <= 2 &&
|
||||
y >= topIndex &&
|
||||
y < topIndex + choices.length
|
||||
) {
|
||||
// @ts-ignore
|
||||
core.actions._clickAction(x, y);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
60
|
||||
);
|
||||
});
|
||||
+2
-6
@@ -68,16 +68,14 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, onMounted, onUnmounted, ref, shallowRef } from 'vue';
|
||||
import { computed, onUnmounted, ref, shallowRef } from 'vue';
|
||||
import {
|
||||
mainSetting,
|
||||
MotaSetting,
|
||||
MotaSettingItem,
|
||||
SettingDisplayer,
|
||||
SettingDisplayInfo,
|
||||
SettingText
|
||||
SettingDisplayInfo
|
||||
} from '../core/main/setting';
|
||||
import settingText from '../data/settings.json';
|
||||
import { RightOutlined, LeftOutlined } from '@ant-design/icons-vue';
|
||||
import { splitText } from '../plugin/utils';
|
||||
import Scroll from '../components/scroll.vue';
|
||||
@@ -88,13 +86,11 @@ import { mainUi } from '@/core/main/init/ui';
|
||||
|
||||
const props = defineProps<{
|
||||
info?: MotaSetting;
|
||||
text?: SettingText;
|
||||
num: number;
|
||||
ui: GameUi;
|
||||
}>();
|
||||
|
||||
const setting = props.info ?? mainSetting;
|
||||
const text = props.text ?? (settingText as SettingText);
|
||||
const display = shallowRef<SettingDisplayInfo[]>([]);
|
||||
const selectedItem = computed(() => display.value.at(-1)?.item);
|
||||
const update = ref(false);
|
||||
|
||||
Reference in new issue
Block a user