按键按下时的实际操作

This commit is contained in:
unanmed 2023-08-09 12:55:10 +08:00
parent 1673eb7a4b
commit 31a8e2d502
4 changed files with 110 additions and 46 deletions

View File

@ -1,5 +1,6 @@
import { KeyCode } from '../../../plugin/keyCodes'; import { KeyCode } from '../../../plugin/keyCodes';
import { deleteWith, generateBinary, has } from '../../../plugin/utils'; import { getLocFromMouseLoc } from '../../../plugin/ui/fixed';
import { deleteWith, generateBinary, has, tip } from '../../../plugin/utils';
import { EmitableEvent, EventEmitter } from '../../common/eventEmitter'; import { EmitableEvent, EventEmitter } from '../../common/eventEmitter';
import { GameStorage } from '../storage'; import { GameStorage } from '../storage';
@ -142,118 +143,175 @@ export const hotkey = new Hotkey('gameKey');
hotkey hotkey
.register('book', '怪物手册', { .register('book', '怪物手册', {
defaults: KeyCode.KeyX, defaults: KeyCode.KeyX,
func: () => {} func: () => {
core.openBook(true);
}
}) })
.register('save', '存档界面', { .register('save', '存档界面', {
defaults: KeyCode.KeyS, defaults: KeyCode.KeyS,
func: () => {} func: () => {
core.save(true);
}
}) })
.register('load', '读档界面', { .register('load', '读档界面', {
defaults: KeyCode.KeyD, defaults: KeyCode.KeyD,
func: () => {} func: () => {
core.load(true);
}
}) })
.register('undo1', '撤回', { .register('undo', '退', {
defaults: KeyCode.KeyA, defaults: KeyCode.KeyA,
func: () => {} func: () => {
core.doSL('autoSave', 'load');
}
}) })
.register('undo2', '撤回 手机端', { .register('redo', '撤销回退', {
defaults: KeyCode.Digit5,
func: () => {}
})
.register('redo1', '重做', {
defaults: KeyCode.KeyW, defaults: KeyCode.KeyW,
func: () => {} func: () => {
}) core.doSL('autoSave', 'reload');
.register('redo2', '重做 手机端', { }
defaults: KeyCode.Digit6,
func: () => {}
}) })
.register('toolbox', '道具栏', { .register('toolbox', '道具栏', {
defaults: KeyCode.KeyT, defaults: KeyCode.KeyT,
func: () => {} func: () => {
core.openToolbox(true);
}
}) })
.register('equipbox', '装备栏', { .register('equipbox', '装备栏', {
defaults: KeyCode.KeyQ, defaults: KeyCode.KeyQ,
func: () => {} func: () => {
core.openEquipbox(true);
}
}) })
.register('fly', '楼层传送', { .register('fly', '楼层传送', {
defaults: KeyCode.KeyG, defaults: KeyCode.KeyG,
func: () => {} func: () => {
core.useFly(true);
}
}) })
.register('turn', '勇士转向', { .register('turn', '勇士转向', {
defaults: KeyCode.KeyZ, defaults: KeyCode.KeyZ,
func: () => {} func: () => {
core.turnHero();
}
}) })
.register('getNext1', '轻按', { .register('getNext', '轻按', {
defaults: KeyCode.Space, defaults: KeyCode.Space,
func: () => {} func: () => {
}) core.getNextItem();
.register('getNext2', '轻按 手机端', { }
defaults: KeyCode.Digit7,
func: () => {}
}) })
.register('menu', '菜单', { .register('menu', '菜单', {
defaults: KeyCode.Escape, defaults: KeyCode.Escape,
func: () => {} func: () => {
core.openSettings(true);
}
}) })
.register('replay', '录像回放', { .register('replay', '录像回放', {
defaults: KeyCode.KeyR, defaults: KeyCode.KeyR,
func: () => {} func: () => {
core.ui._drawReplay();
}
}) })
.register('restart', '开始菜单', { .register('restart', '开始菜单', {
defaults: KeyCode.KeyN, defaults: KeyCode.KeyN,
func: () => {} func: () => {
core.confirmRestart();
}
}) })
.register('shop', '快捷商店', { .register('shop', '快捷商店', {
defaults: KeyCode.KeyV, defaults: KeyCode.KeyV,
func: () => {} func: () => {
core.openQuickShop(true);
}
}) })
.register('statistics', '数据统计', { .register('statistics', '数据统计', {
defaults: KeyCode.KeyB, defaults: KeyCode.KeyB,
func: () => {} func: () => {
core.ui._drawStatistics();
}
}) })
.register('viewMap1', '浏览地图', { .register('viewMap1', '浏览地图', {
defaults: KeyCode.PageUp, defaults: KeyCode.PageUp,
func: () => {} func: () => {
core.ui._drawViewMaps();
}
}) })
.register('viewMap2', '浏览地图', { .register('viewMap2', '浏览地图', {
defaults: KeyCode.PageDown, defaults: KeyCode.PageDown,
func: () => {} func: () => {
core.ui._drawViewMaps();
}
}) })
.register('comment', '评论区', { .register('comment', '评论区', {
defaults: KeyCode.KeyP, defaults: KeyCode.KeyP,
func: () => {} func: () => {
core.actions._clickGameInfo_openComments();
}
}) })
.register('mark', '标记怪物', { .register('mark', '标记怪物', {
defaults: KeyCode.KeyM, defaults: KeyCode.KeyM,
func: () => {} func: () => {
const [x, y] = flags.mouseLoc ?? [];
const [mx, my] = getLocFromMouseLoc(x, y);
const blocks = core.getMapBlocksObj();
const block = blocks[`${mx},${my}`];
if (block.event.cls.startsWith('enemy')) {
const id = block.event.id as EnemyIds;
const name = core.material.enemys[id].name;
if (ancTe.plugin.mark.hasMarkedEnemy(id)) {
tip('success', `已取消标记${name}`);
ancTe.plugin.mark.unmarkEnemy(id);
} else {
tip('success', `已标记${name}`);
ancTe.plugin.mark.checkMarkedEnemy(false);
}
}
}
}) })
.register('skillTree', '技能树', { .register('skillTree', '技能树', {
defaults: KeyCode.KeyJ, defaults: KeyCode.KeyJ,
func: () => {} func: () => {
core.useItem('skill1', true);
}
}) })
.register('desc', '百科全书', { .register('desc', '百科全书', {
defaults: KeyCode.KeyH, defaults: KeyCode.KeyH,
func: () => {} func: () => {
core.useItem('I560', true);
}
}) })
.register('special', '鼠标位置怪物属性', { .register('special', '鼠标位置怪物属性', {
defaults: KeyCode.KeyE, defaults: KeyCode.KeyE,
func: () => {} func: () => {
const [x, y] = flags.mouseLoc ?? [];
const [mx, my] = getLocFromMouseLoc(x, y);
if (core.getBlockCls(mx, my)?.startsWith('enemy')) {
core.plugin.fixedDetailPanel = 'special';
ancTe.plugin.fixed.showFixed.value = false;
ancTe.plugin.ui.fixedDetailOpened.value = true;
}
}
}) })
.register('critical', '鼠标位置怪物临界', { .register('critical', '鼠标位置怪物临界', {
defaults: KeyCode.KeyC, defaults: KeyCode.KeyC,
func: () => {} func: () => {
const [x, y] = flags.mouseLoc ?? [];
const [mx, my] = getLocFromMouseLoc(x, y);
if (core.getBlockCls(mx, my)?.startsWith('enemy')) {
core.plugin.fixedDetailPanel = 'critical';
ancTe.plugin.fixed.showFixed.value = false;
ancTe.plugin.ui.fixedDetailOpened.value = true;
}
}
}) })
.group('action', '游戏操作', [ .group('action', '游戏操作', [
'save', 'save',
'load', 'load',
'undo1', 'undo',
'undo2', 'redo',
'redo1',
'redo2',
'turn', 'turn',
'getNext1', 'getNext',
'getNext2',
'mark' 'mark'
]) ])
.group('view', '快捷查看', [ .group('view', '快捷查看', [

View File

@ -35,7 +35,7 @@ export class GameStorage<T> {
} }
getValue<K extends keyof T>(key: K): T[K] | null; getValue<K extends keyof T>(key: K): T[K] | null;
getValue<K extends keyof T>(key: K, defaults?: T[K]): T[K]; getValue<K extends keyof T>(key: K, defaults: T[K]): T[K];
getValue<K extends keyof T>(key: K, defaults?: T[K]) { getValue<K extends keyof T>(key: K, defaults?: T[K]) {
if (this.data[key]) return this.data[key]; if (this.data[key]) return this.data[key];
else { else {

View File

@ -134,6 +134,8 @@ interface Actions extends VoidedActionFuncs {
_out(x: number): boolean; _out(x: number): boolean;
_getNextFlyFloor(delta: number, index: number): number; _getNextFlyFloor(delta: number, index: number): number;
_clickGameInfo_openComments();
} }
declare const actions: new () => Actions; declare const actions: new () => Actions;

4
src/types/ui.d.ts vendored
View File

@ -822,6 +822,10 @@ interface Ui {
* *
*/ */
_drawViewMaps(); _drawViewMaps();
_drawReplay();
_drawStatistics();
} }
declare const ui: new () => Ui; declare const ui: new () => Ui;