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
59c3b46cfc
commit
fef9950542
13 files changed
+421
-41
No files matched your search
@@ -28,6 +28,7 @@ interface CustomToolbarEvent extends EmitableEvent {
|
||||
interface ToolbarItemBase<T extends ToolbarItemType> {
|
||||
type: T;
|
||||
id: string;
|
||||
noDefaultAction?: boolean;
|
||||
}
|
||||
|
||||
// 快捷键
|
||||
@@ -52,6 +53,8 @@ interface MinimatToolbar extends ToolbarItemBase<'minimap'> {
|
||||
noBorder: boolean;
|
||||
showInfo: boolean;
|
||||
autoLocate: boolean;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
interface ToolbarItemMap {
|
||||
@@ -407,6 +410,28 @@ CustomToolbar.register(
|
||||
};
|
||||
}
|
||||
);
|
||||
CustomToolbar.register(
|
||||
'minimap',
|
||||
'小地图',
|
||||
function (id, item) {
|
||||
return true;
|
||||
},
|
||||
COM.MinimapTool,
|
||||
EDITOR.MinimapTool,
|
||||
item => {
|
||||
return {
|
||||
action: false,
|
||||
scale: 5,
|
||||
width: 300,
|
||||
height: 300,
|
||||
noBorder: false,
|
||||
showInfo: false,
|
||||
autoLocate: true,
|
||||
...item,
|
||||
noDefaultAction: true
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
Mota.require('var', 'loading').once('coreInit', () => {
|
||||
CustomToolbar.load();
|
||||
|
||||
@@ -147,6 +147,7 @@ function showSpecialSetting(id: string, vBind?: any) {
|
||||
mainUi.showAll();
|
||||
});
|
||||
mainUi.open(id, vBind);
|
||||
console.log(core.status.lockControl);
|
||||
}
|
||||
|
||||
function HotkeySetting(props: SettingComponentProps) {
|
||||
|
||||
@@ -7,7 +7,13 @@ import BoxAnimate from '@/components/boxAnimate.vue';
|
||||
import { checkAssist } from '../custom/hotkey';
|
||||
import { getVitualKeyOnce } from '@/plugin/utils';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import { Select, SelectOption } from 'ant-design-vue';
|
||||
import {
|
||||
Button,
|
||||
InputNumber,
|
||||
Select,
|
||||
SelectOption,
|
||||
Switch
|
||||
} from 'ant-design-vue';
|
||||
import { mainSetting } from '../setting';
|
||||
import Minimap from '@/components/minimap.vue';
|
||||
|
||||
@@ -18,6 +24,7 @@ interface Components {
|
||||
KeyTool: CustomToolbarComponent<'hotkey'>;
|
||||
ItemTool: CustomToolbarComponent<'item'>;
|
||||
AssistKeyTool: CustomToolbarComponent<'assistKey'>;
|
||||
MinimapTool: CustomToolbarComponent<'minimap'>;
|
||||
}
|
||||
|
||||
export function createToolbarComponents() {
|
||||
@@ -25,7 +32,8 @@ export function createToolbarComponents() {
|
||||
DefaultTool,
|
||||
KeyTool,
|
||||
ItemTool,
|
||||
AssistKeyTool
|
||||
AssistKeyTool,
|
||||
MinimapTool
|
||||
};
|
||||
return com;
|
||||
}
|
||||
@@ -35,7 +43,8 @@ export function createToolbarEditorComponents() {
|
||||
DefaultTool: DefaultToolEditor,
|
||||
KeyTool: KeyToolEdtior,
|
||||
ItemTool: ItemToolEditor,
|
||||
AssistKeyTool: AssistKeyToolEditor
|
||||
AssistKeyTool: AssistKeyToolEditor,
|
||||
MinimapTool: MinimapToolEditor
|
||||
};
|
||||
return com;
|
||||
}
|
||||
@@ -89,12 +98,20 @@ function AssistKeyTool(props: CustomToolbarProps<'assistKey'>) {
|
||||
);
|
||||
}
|
||||
|
||||
function MinimapToolbar(props: CustomToolbarProps<'minimap'>) {
|
||||
function MinimapTool(props: CustomToolbarProps<'minimap'>) {
|
||||
const { item, toolbar } = props;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Minimap></Minimap>
|
||||
<div style={{ width: `${item.width}px`, height: `${item.height}px` }}>
|
||||
<Minimap
|
||||
action={item.action}
|
||||
scale={item.scale}
|
||||
noBorder={item.noBorder}
|
||||
showInfo={item.showInfo}
|
||||
autoLocate={item.autoLocate}
|
||||
width={item.width}
|
||||
height={item.height}
|
||||
></Minimap>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -215,3 +232,155 @@ function AssistKeyToolEditor(props: CustomToolbarProps<'assistKey'>) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function MinimapToolEditor(props: CustomToolbarProps<'minimap'>) {
|
||||
const { item, toolbar } = props;
|
||||
|
||||
type K = keyof typeof item;
|
||||
const setConfig: <T extends K>(key: T, value: (typeof item)[T]) => void = (
|
||||
key,
|
||||
value
|
||||
) => {
|
||||
let v = value;
|
||||
if (key === 'height' || key === 'height') {
|
||||
if ((v as number) > 1000) (v as number) = 1000;
|
||||
if ((v as number) < 50) (v as number) = 50;
|
||||
} else if (key === 'scale') {
|
||||
if ((v as number) > 20) (v as number) = 20;
|
||||
if ((v as number) < 1) (v as number) = 1;
|
||||
}
|
||||
toolbar.set(item.id, { [key]: v });
|
||||
toolbar.refresh();
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
style="
|
||||
display: flex; flex-direction: column;
|
||||
align-items: center; padding: 0 5%; margin: 1%
|
||||
"
|
||||
>
|
||||
<div class="toolbar-editor-item">
|
||||
<span>宽度</span>
|
||||
<div style="width: 70%; display: flex; justify-content: end">
|
||||
<InputNumber
|
||||
class="number-input"
|
||||
size="large"
|
||||
// keyboard={true}
|
||||
min={50}
|
||||
max={1000}
|
||||
step={50}
|
||||
value={item.width}
|
||||
onChange={value => setConfig('width', value as number)}
|
||||
></InputNumber>
|
||||
<Button
|
||||
style="margin-left: 5%"
|
||||
class="number-button"
|
||||
type="primary"
|
||||
onClick={() => setConfig('width', item.width - 50)}
|
||||
>
|
||||
减少
|
||||
</Button>
|
||||
<Button
|
||||
style="margin-left: 5%"
|
||||
class="number-button"
|
||||
type="primary"
|
||||
onClick={() => setConfig('width', item.width + 50)}
|
||||
>
|
||||
增加
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="toolbar-editor-item">
|
||||
<span>高度</span>
|
||||
<div style="width: 70%; display: flex; justify-content: end">
|
||||
<InputNumber
|
||||
class="number-input"
|
||||
size="large"
|
||||
// keyboard={true}
|
||||
min={50}
|
||||
max={1000}
|
||||
step={50}
|
||||
value={item.height}
|
||||
onChange={value => setConfig('height', value as number)}
|
||||
></InputNumber>
|
||||
<Button
|
||||
style="margin-left: 5%"
|
||||
class="number-button"
|
||||
type="primary"
|
||||
onClick={() => setConfig('height', item.height - 50)}
|
||||
>
|
||||
减少
|
||||
</Button>
|
||||
<Button
|
||||
style="margin-left: 5%"
|
||||
class="number-button"
|
||||
type="primary"
|
||||
onClick={() => setConfig('height', item.height + 50)}
|
||||
>
|
||||
增加
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="toolbar-editor-item">
|
||||
<span>放缩比例</span>
|
||||
<div style="width: 70%; display: flex; justify-content: end">
|
||||
<InputNumber
|
||||
class="number-input"
|
||||
size="large"
|
||||
// keyboard={true}
|
||||
min={1}
|
||||
max={20}
|
||||
step={1}
|
||||
value={item.scale}
|
||||
onChange={value => setConfig('scale', value as number)}
|
||||
></InputNumber>
|
||||
<Button
|
||||
style="margin-left: 5%"
|
||||
class="number-button"
|
||||
type="primary"
|
||||
onClick={() => setConfig('scale', item.scale - 1)}
|
||||
>
|
||||
减少
|
||||
</Button>
|
||||
<Button
|
||||
style="margin-left: 5%"
|
||||
class="number-button"
|
||||
type="primary"
|
||||
onClick={() => setConfig('scale', item.scale + 1)}
|
||||
>
|
||||
增加
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="toolbar-editor-item">
|
||||
<span>无边框模式</span>
|
||||
<Switch
|
||||
checked={item.noBorder}
|
||||
onClick={() => setConfig('noBorder', !item.noBorder)}
|
||||
></Switch>
|
||||
</div>
|
||||
<div class="toolbar-editor-item">
|
||||
<span>显示漏怪</span>
|
||||
<Switch
|
||||
checked={item.showInfo}
|
||||
onClick={() => setConfig('showInfo', !item.showInfo)}
|
||||
></Switch>
|
||||
</div>
|
||||
<div class="toolbar-editor-item">
|
||||
<span>自动居中</span>
|
||||
<Switch
|
||||
checked={item.autoLocate}
|
||||
onClick={() => setConfig('autoLocate', !item.autoLocate)}
|
||||
></Switch>
|
||||
</div>
|
||||
<div class="toolbar-editor-item">
|
||||
<span>允许交互</span>
|
||||
<Switch
|
||||
checked={item.action}
|
||||
onClick={() => setConfig('action', !item.action)}
|
||||
></Switch>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user