扣车按钮&无人折返按钮
This commit is contained in:
parent
b504c7482b
commit
c1741e0aba
@ -27,15 +27,30 @@
|
||||
<path d="M20.7727 14.2727C20.7045 13.697 20.428 13.25 19.9432 12.9318C19.4583 12.6136 18.8636 12.4545 18.1591 12.4545C17.6439 12.4545 17.1932 12.5379 16.8068 12.7045C16.4242 12.8712 16.125 13.1004 15.9091 13.392C15.697 13.6837 15.5909 14.0152 15.5909 14.3864C15.5909 14.697 15.6648 14.964 15.8125 15.1875C15.964 15.4072 16.1572 15.5909 16.392 15.7386C16.6269 15.8826 16.8731 16.0019 17.1307 16.0966C17.3883 16.1875 17.625 16.2614 17.8409 16.3182L19.0227 16.6364C19.3258 16.7159 19.6629 16.8258 20.0341 16.9659C20.4091 17.1061 20.767 17.2973 21.108 17.5398C21.4527 17.7784 21.7367 18.0852 21.9602 18.4602C22.1837 18.8352 22.2955 19.2955 22.2955 19.8409C22.2955 20.4697 22.1307 21.0379 21.8011 21.5455C21.4754 22.053 20.9981 22.4564 20.3693 22.7557C19.7443 23.0549 18.9848 23.2045 18.0909 23.2045C17.2576 23.2045 16.536 23.0701 15.9261 22.8011C15.3201 22.5322 14.8428 22.1572 14.4943 21.6761C14.1496 21.1951 13.9545 20.6364 13.9091 20H15.3636C15.4015 20.4394 15.5492 20.803 15.8068 21.0909C16.0682 21.375 16.3977 21.5871 16.7955 21.7273C17.197 21.8636 17.6288 21.9318 18.0909 21.9318C18.6288 21.9318 19.1117 21.8447 19.5398 21.6705C19.9678 21.4924 20.3068 21.2462 20.5568 20.9318C20.8068 20.6136 20.9318 20.2424 20.9318 19.8182C20.9318 19.4318 20.8239 19.1174 20.608 18.875C20.392 18.6326 20.108 18.4356 19.7557 18.2841C19.4034 18.1326 19.0227 18 18.6136 17.8864L17.1818 17.4773C16.2727 17.2159 15.553 16.8428 15.0227 16.358C14.4924 15.8731 14.2273 15.2386 14.2273 14.4545C14.2273 13.803 14.4034 13.2348 14.7557 12.75C15.1117 12.2614 15.589 11.8826 16.1875 11.6136C16.7898 11.3409 17.4621 11.2045 18.2045 11.2045C18.9545 11.2045 19.6212 11.339 20.2045 11.608C20.7879 11.8731 21.25 12.2367 21.5909 12.6989C21.9356 13.161 22.1174 13.6856 22.1364 14.2727H20.7727Z" fill="white"/>
|
||||
<line y1="32" x2="35" y2="32" stroke="white" stroke-width="4"/>
|
||||
</symbol>
|
||||
<symbol id="icon-ibp-box" viewBox="0 0 35 34" fill="none">
|
||||
<rect x="1" y="1" width="33" height="32" stroke="white" stroke-width="2"/>
|
||||
<path d="M16.4659 9.81818V20H15.233V9.81818H16.4659Z" fill="white"/>
|
||||
<line y1="32" x2="35" y2="32" stroke="white" stroke-width="4"/>
|
||||
</symbol>
|
||||
<symbol id="icon-gated-box" viewBox="0 0 35 34" fill="none">
|
||||
<rect x="1" y="1" width="33" height="32" stroke="white" stroke-width="2"/>
|
||||
<path d="M14.4091 23V11.3636H18.3409C19.2538 11.3636 20 11.5284 20.5795 11.858C21.1629 12.1837 21.5947 12.625 21.875 13.1818C22.1553 13.7386 22.2955 14.3598 22.2955 15.0455C22.2955 15.7311 22.1553 16.3542 21.875 16.9148C21.5985 17.4754 21.1705 17.9223 20.5909 18.2557C20.0114 18.5852 19.2689 18.75 18.3636 18.75H15.5455V17.5H18.3182C18.9432 17.5 19.4451 17.392 19.8239 17.1761C20.2027 16.9602 20.4773 16.6686 20.6477 16.3011C20.822 15.9299 20.9091 15.5114 20.9091 15.0455C20.9091 14.5795 20.822 14.1629 20.6477 13.7955C20.4773 13.428 20.2008 13.1402 19.8182 12.9318C19.4356 12.7197 18.928 12.6136 18.2955 12.6136H15.8182V23H14.4091Z" fill="white"/>
|
||||
<line y1="32" x2="35" y2="32" stroke="white" stroke-width="4"/>
|
||||
</symbol>
|
||||
<symbol id="icon-esb-button" viewBox="0 0 35 34" fill="none">
|
||||
<rect x="1" y="1" width="33" height="32" stroke="white" stroke-width="2"/>
|
||||
<line y1="32" x2="35" y2="32" stroke="white" stroke-width="4"/>
|
||||
<circle cx="17.5" cy="16.5" r="7.5" fill="white"/>
|
||||
<rect x="1" y="1" width="31" height="30" stroke="white" stroke-width="2"/>
|
||||
<line x1="0.0576497" y1="28.5011" x2="33.0333" y2="29.7694" stroke="white" stroke-width="3"/>
|
||||
<path d="M13.233 20V9.81818H19.3778V10.9119H14.4659V14.3523H19.0597V15.446H14.4659V18.9062H19.4574V20H13.233Z" fill="white"/>
|
||||
</symbol>
|
||||
<symbol id="icon-hold-button" viewBox="0 0 35 34" fill="none">
|
||||
<rect x="1" y="1" width="31" height="30" stroke="white" stroke-width="2"/>
|
||||
<line x1="0.0576497" y1="28.5011" x2="33.0333" y2="29.7694" stroke="white" stroke-width="3"/>
|
||||
<path d="M12.233 19V8.81818H13.4659V13.3523H18.8949V8.81818H20.1278V19H18.8949V14.446H13.4659V19H12.233Z" fill="white"/>
|
||||
</symbol>
|
||||
<symbol id="icon-unattenged-button" viewBox="0 0 35 34" fill="none">
|
||||
<rect x="1" y="1" width="31" height="30" stroke="white" stroke-width="2"/>
|
||||
<line x1="0.0576497" y1="28.5011" x2="33.0333" y2="29.7694" stroke="white" stroke-width="3"/>
|
||||
<path d="M12.0824 21L9.2983 10.8182H10.5511L12.679 19.1108H12.7784L14.946 10.8182H16.3381L18.5057 19.1108H18.6051L20.733 10.8182H21.9858L19.2017 21H17.929L15.6818 12.8864H15.6023L13.3551 21H12.0824Z" fill="white"/>
|
||||
</symbol>
|
||||
<symbol id="icon-psl-light" viewBox="0 0 30 30" fill="none">
|
||||
<circle cx="15" cy="15" r="14.5" stroke="white"/>
|
||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 13 KiB |
@ -1 +1 @@
|
||||
Subproject commit f232ff605d44f4c989a823f2416215e4c3bb60b9
|
||||
Subproject commit 16d15c8515368725a811c9349c95ffdafb4dd991
|
@ -148,6 +148,12 @@
|
||||
<flood-gate-property
|
||||
v-else-if="drawStore.selectedGraphicType === FloodGate.Type"
|
||||
></flood-gate-property>
|
||||
<hold-button-property
|
||||
v-else-if="drawStore.selectedGraphicType === HoldButton.Type"
|
||||
></hold-button-property>
|
||||
<unattenged-button-property
|
||||
v-else-if="drawStore.selectedGraphicType === UnattengedButton.Type"
|
||||
></unattenged-button-property>
|
||||
</q-card-section>
|
||||
</template>
|
||||
<template v-else-if="drawStore.selectedGraphics.length > 1">
|
||||
@ -232,6 +238,10 @@ import CarWashingProperty from './properties/CarWashingProperty.vue';
|
||||
import { CarWashing } from 'src/graphics/carWashing/CarWashing';
|
||||
import { FloodGate } from 'src/graphics/floodGate/FloodGate';
|
||||
import FloodGateProperty from './properties/FloodGateProperty.vue';
|
||||
import { HoldButton } from 'src/graphics/holdButton/HoldButton';
|
||||
import HoldButtonProperty from './properties/HoldButtonProperty.vue';
|
||||
import { UnattengedButton } from 'src/graphics/unattengedButton/UnattengedButton';
|
||||
import UnattengedButtonProperty from './properties/UnattengedButtonProperty.vue';
|
||||
|
||||
const drawStore = useDrawStore();
|
||||
</script>
|
||||
|
55
src/components/draw-app/properties/HoldButtonProperty.vue
Normal file
55
src/components/draw-app/properties/HoldButtonProperty.vue
Normal file
@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<q-form>
|
||||
<q-input
|
||||
outlined
|
||||
readonly
|
||||
v-model="holdButtonModel.id"
|
||||
label="id"
|
||||
hint=""
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
style="margin-top: 10px"
|
||||
v-model="holdButtonModel.code"
|
||||
@blur="onUpdate"
|
||||
label="编号"
|
||||
/>
|
||||
<q-select
|
||||
outlined
|
||||
style="margin-top: 10px"
|
||||
v-model="holdButtonModel.refStand"
|
||||
:options="platformList"
|
||||
:map-options="true"
|
||||
:emit-value="true"
|
||||
@update:model-value="onUpdate"
|
||||
label="关联站台"
|
||||
></q-select>
|
||||
</q-form>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useFormData } from 'src/components/DrawAppFormUtils';
|
||||
import { HoldButtonData } from 'src/drawApp/graphics/HoldButtonInteraction';
|
||||
import { Platform } from 'src/graphics/platform/Platform';
|
||||
import { useDrawStore } from 'src/stores/draw-store';
|
||||
import { onMounted, reactive } from 'vue';
|
||||
|
||||
const drawStore = useDrawStore();
|
||||
const { data: holdButtonModel, onUpdate } = useFormData(
|
||||
new HoldButtonData(),
|
||||
drawStore.getDrawApp()
|
||||
);
|
||||
const platformList: { label: string; value: number }[] = reactive([]);
|
||||
|
||||
onMounted(() => {
|
||||
const platforms = drawStore
|
||||
.getDrawApp()
|
||||
.queryStore.queryByType<Platform>(Platform.Type);
|
||||
platforms.forEach((p) => {
|
||||
platformList.push({
|
||||
value: p.id,
|
||||
label: `${p.datas.code}`,
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
@ -24,17 +24,6 @@
|
||||
@update:model-value="onUpdate"
|
||||
label="关联站台"
|
||||
></q-select>
|
||||
<q-select
|
||||
outlined
|
||||
style="margin-top: 10px"
|
||||
v-model="spksSwitchModel.refSections"
|
||||
:options="sectionList"
|
||||
:multiple="true"
|
||||
:map-options="true"
|
||||
:emit-value="true"
|
||||
@update:model-value="onUpdate"
|
||||
label="关联物理区段"
|
||||
></q-select>
|
||||
</q-form>
|
||||
</template>
|
||||
|
||||
|
@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<q-form>
|
||||
<q-input
|
||||
outlined
|
||||
readonly
|
||||
v-model="unattengedButtonModel.id"
|
||||
label="id"
|
||||
hint=""
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
style="margin-top: 10px"
|
||||
v-model="unattengedButtonModel.code"
|
||||
@blur="onUpdate"
|
||||
label="编号"
|
||||
/>
|
||||
<q-select
|
||||
outlined
|
||||
style="margin-top: 10px"
|
||||
v-model="unattengedButtonModel.refStand"
|
||||
:options="platformList"
|
||||
:map-options="true"
|
||||
:emit-value="true"
|
||||
@update:model-value="onUpdate"
|
||||
label="关联站台"
|
||||
></q-select>
|
||||
</q-form>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useFormData } from 'src/components/DrawAppFormUtils';
|
||||
import { UnattengedButtonData } from 'src/drawApp/graphics/UnattengedButtonInteraction';
|
||||
import { Platform } from 'src/graphics/platform/Platform';
|
||||
import { useDrawStore } from 'src/stores/draw-store';
|
||||
import { onMounted, reactive } from 'vue';
|
||||
|
||||
const drawStore = useDrawStore();
|
||||
const { data: unattengedButtonModel, onUpdate } = useFormData(
|
||||
new UnattengedButtonData(),
|
||||
drawStore.getDrawApp()
|
||||
);
|
||||
const platformList: { label: string; value: number }[] = reactive([]);
|
||||
|
||||
onMounted(() => {
|
||||
const platforms = drawStore
|
||||
.getDrawApp()
|
||||
.queryStore.queryByType<Platform>(Platform.Type);
|
||||
platforms.forEach((p) => {
|
||||
platformList.push({
|
||||
value: p.id,
|
||||
label: `${p.datas.code}`,
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
@ -24,6 +24,8 @@ import { PslBox } from 'src/graphics/pslBox/PslBox';
|
||||
import { GarageDoor } from 'src/graphics/garageDoor/GarageDoor';
|
||||
import { CarWashing } from 'src/graphics/carWashing/CarWashing';
|
||||
import { FloodGate } from 'src/graphics/floodGate/FloodGate';
|
||||
import { HoldButton } from 'src/graphics/holdButton/HoldButton';
|
||||
import { UnattengedButton } from 'src/graphics/unattengedButton/UnattengedButton';
|
||||
|
||||
export const drawCommonLayerList = [
|
||||
// 图层列表 默认显示的图层defaultShow: true
|
||||
@ -61,4 +63,6 @@ export const drawCommonLayerList = [
|
||||
{ label: '车库门', value: GarageDoor.Type, defaultShow: true },
|
||||
{ label: '洗车机', value: CarWashing.Type, defaultShow: true },
|
||||
{ label: '防淹门', value: FloodGate.Type, defaultShow: true },
|
||||
{ label: '扣车按钮', value: HoldButton.Type, defaultShow: true },
|
||||
{ label: '无人折返按钮', value: UnattengedButton.Type, defaultShow: true },
|
||||
];
|
||||
|
@ -91,6 +91,10 @@ import {
|
||||
SpksSwitchData,
|
||||
DrawSpksSwitchInteraction,
|
||||
} from './graphics/SpksSwitchInteraction';
|
||||
import { HoldButton, HoldButtonTemplate } from 'src/graphics/holdButton/HoldButton';
|
||||
import { DrawHoldButtonInteraction, HoldButtonData } from './graphics/HoldButtonInteraction';
|
||||
import { UnattengedButton, UnattengedButtonTemplate } from 'src/graphics/unattengedButton/UnattengedButton';
|
||||
import { UnattengedButtonData, DrawUnattengedButtonInteraction } from './graphics/UnattengedButtonInteraction';
|
||||
import { GatedBox, GatedBoxTemplate } from 'src/graphics/gatedBox/GatedBox';
|
||||
import {
|
||||
GatedBoxData,
|
||||
@ -103,6 +107,8 @@ import {
|
||||
// EsbButtonState,
|
||||
// } from './graphics/EsbButtonInteraction';
|
||||
import { SpksSwitchDraw } from 'src/graphics/spksSwitch/SpksSwitchDrawAssistant';
|
||||
import { HoldButtonDraw } from 'src/graphics/holdButton/HoldButtonDrawAssistant';
|
||||
import { UnattengedButtonDraw } from 'src/graphics/unattengedButton/UnattengedButtonDrawAssistant';
|
||||
import { GatedBoxDraw } from 'src/graphics/gatedBox/GatedBoxDrawAssistant';
|
||||
// import { EsbButtonDraw } from 'src/graphics/esbButton/EsbButtonDrawAssistant';
|
||||
import { TransponderDraw } from 'src/graphics/transponder/TransponderDrawAssistant';
|
||||
@ -228,6 +234,8 @@ export function initCommonDrawApp(app: IDrawApp) {
|
||||
);
|
||||
new StopPositionDraw(app, new StopPositionTemplate(new StopPositionData()));
|
||||
new SpksSwitchDraw(app, new SpksSwitchTemplate(new SpksSwitchData()));
|
||||
new HoldButtonDraw(app, new HoldButtonTemplate(new HoldButtonData()));
|
||||
new UnattengedButtonDraw(app, new UnattengedButtonTemplate(new UnattengedButtonData()));
|
||||
new GatedBoxDraw(app, new GatedBoxTemplate(new GatedBoxData()));
|
||||
// new EsbButtonDraw(
|
||||
// app,
|
||||
@ -264,6 +272,8 @@ export function initCommonDrawApp(app: IDrawApp) {
|
||||
DrawSignalInteraction.init(app);
|
||||
DrawStopPositionInteraction.init(app);
|
||||
DrawSpksSwitchInteraction.init(app);
|
||||
DrawHoldButtonInteraction.init(app);
|
||||
DrawUnattengedButtonInteraction.init(app);
|
||||
DrawGatedBoxInteraction.init(app);
|
||||
// DrawEsbButtonInteraction.init(app);
|
||||
|
||||
@ -352,10 +362,10 @@ export function initCommonDrawApp(app: IDrawApp) {
|
||||
prev.localToCanvasPoint(prev.getStartPoint()),
|
||||
mousePos
|
||||
) >
|
||||
distance2(
|
||||
cur.localToCanvasPoint(cur.getStartPoint()),
|
||||
mousePos
|
||||
))
|
||||
distance2(
|
||||
cur.localToCanvasPoint(cur.getStartPoint()),
|
||||
mousePos
|
||||
))
|
||||
? cur
|
||||
: prev;
|
||||
});
|
||||
@ -447,6 +457,12 @@ export function loadCommonDrawDatas(
|
||||
storage.spksSwitchs.forEach((spksSwitch) => {
|
||||
datas.push(new SpksSwitchData(spksSwitch));
|
||||
});
|
||||
storage.holdButtons.forEach((holdButton) => {
|
||||
datas.push(new HoldButtonData(holdButton));
|
||||
})
|
||||
storage.unattengedButtons.forEach((unattengedButton) => {
|
||||
datas.push(new UnattengedButtonData(unattengedButton));
|
||||
})
|
||||
storage.gateBoxs.forEach((gatedBox) => {
|
||||
datas.push(new GatedBoxData(gatedBox));
|
||||
});
|
||||
@ -536,6 +552,14 @@ export function saveCommonDrawDatas(app: IDrawApp) {
|
||||
} else if (SpksSwitch.Type === g.type) {
|
||||
const spksSwitchData = (g as SpksSwitch).saveData();
|
||||
storage.spksSwitchs.push((spksSwitchData as SpksSwitchData).data);
|
||||
} else if (HoldButton.Type === g.type) {
|
||||
const holdButtonData = (g as HoldButton).saveData();
|
||||
storage.holdButtons.push((holdButtonData as HoldButtonData).data);
|
||||
} else if (UnattengedButton.Type === g.type) {
|
||||
const unattengedButtonData = (g as UnattengedButton).saveData();
|
||||
storage.unattengedButtons.push(
|
||||
(unattengedButtonData as UnattengedButtonData).data
|
||||
);
|
||||
} else if (GatedBox.Type === g.type) {
|
||||
const gatedBoxData = (g as GatedBox).saveData();
|
||||
storage.gateBoxs.push((gatedBoxData as GatedBoxData).data);
|
||||
|
107
src/drawApp/graphics/HoldButtonInteraction.ts
Normal file
107
src/drawApp/graphics/HoldButtonInteraction.ts
Normal file
@ -0,0 +1,107 @@
|
||||
import * as pb_1 from 'google-protobuf';
|
||||
import { DisplayObject, FederatedMouseEvent } from 'pixi.js';
|
||||
import { IHoldButtonData, HoldButton } from 'src/graphics/holdButton/HoldButton';
|
||||
import {
|
||||
IGraphicApp,
|
||||
GraphicInteractionPlugin,
|
||||
JlGraphic,
|
||||
IGraphicScene,
|
||||
MenuItemOptions,
|
||||
ContextMenu,
|
||||
} from 'jl-graphic';
|
||||
|
||||
import { graphicData } from 'src/protos/stationLayoutGraphics';
|
||||
import { GraphicDataBase } from './GraphicDataBase';
|
||||
import { useIbpStore } from 'src/stores/ibp-store';
|
||||
import { Station } from 'src/graphics/station/Station';
|
||||
import { Platform } from 'src/graphics/platform/Platform';
|
||||
|
||||
export class HoldButtonData extends GraphicDataBase implements IHoldButtonData {
|
||||
constructor(data?: graphicData.HoldButton) {
|
||||
let holdButton;
|
||||
if (!data) {
|
||||
holdButton = new graphicData.HoldButton({
|
||||
common: GraphicDataBase.defaultCommonInfo(HoldButton.Type),
|
||||
});
|
||||
} else {
|
||||
holdButton = data;
|
||||
}
|
||||
super(holdButton);
|
||||
}
|
||||
|
||||
public get data(): graphicData.HoldButton {
|
||||
return this.getData<graphicData.HoldButton>();
|
||||
}
|
||||
get code(): string {
|
||||
return this.data.code;
|
||||
}
|
||||
set code(v: string) {
|
||||
this.data.code = v;
|
||||
}
|
||||
get flip(): boolean {
|
||||
return this.data.flip;
|
||||
}
|
||||
set flip(v: boolean) {
|
||||
this.data.flip = v;
|
||||
}
|
||||
get refStand(): number {
|
||||
return this.data.refStand;
|
||||
}
|
||||
set refStand(v: number) {
|
||||
this.data.refStand = v;
|
||||
}
|
||||
clone(): HoldButtonData {
|
||||
return new HoldButtonData(this.data.cloneMessage());
|
||||
}
|
||||
copyFrom(data: HoldButtonData): void {
|
||||
pb_1.Message.copyInto(data.data, this.data);
|
||||
}
|
||||
eq(other: HoldButtonData): boolean {
|
||||
return pb_1.Message.equals(this.data, other.data);
|
||||
}
|
||||
}
|
||||
|
||||
const flipConfig: MenuItemOptions = {
|
||||
name: '上下翻转',
|
||||
};
|
||||
const HoldButtonEditMenu: ContextMenu = ContextMenu.init({
|
||||
name: '扣车按钮编辑菜单',
|
||||
groups: [
|
||||
{
|
||||
items: [flipConfig],
|
||||
},
|
||||
],
|
||||
});
|
||||
export class DrawHoldButtonInteraction extends GraphicInteractionPlugin<HoldButton> {
|
||||
static Name = 'hold_button_draw_right_menu';
|
||||
constructor(app: IGraphicApp) {
|
||||
super(DrawHoldButtonInteraction.Name, app);
|
||||
app.registerMenu(HoldButtonEditMenu);
|
||||
}
|
||||
static init(app: IGraphicApp) {
|
||||
return new DrawHoldButtonInteraction(app);
|
||||
}
|
||||
filter(...grahpics: JlGraphic[]): HoldButton[] | undefined {
|
||||
return grahpics
|
||||
.filter((g) => g.type === HoldButton.Type)
|
||||
.map((g) => g as HoldButton);
|
||||
}
|
||||
bind(g: HoldButton): void {
|
||||
g.on('_rightclick', this.onContextMenu, this);
|
||||
}
|
||||
|
||||
unbind(g: HoldButton): void {
|
||||
g.off('_rightclick', this.onContextMenu, this);
|
||||
}
|
||||
|
||||
onContextMenu(e: FederatedMouseEvent) {
|
||||
const target = e.target as DisplayObject;
|
||||
const holdButton = target.getGraphic() as HoldButton;
|
||||
this.app.updateSelected(holdButton);
|
||||
flipConfig.handler = () => {
|
||||
holdButton.datas.flip = !holdButton.datas.flip;
|
||||
holdButton.repaint();
|
||||
};
|
||||
HoldButtonEditMenu.open(e.global);
|
||||
}
|
||||
}
|
@ -53,12 +53,12 @@ export class SpksSwitchData extends GraphicDataBase implements ISpksSwitchData {
|
||||
set refStand(v: number) {
|
||||
this.data.refStand = v;
|
||||
}
|
||||
get refSections(): number[] {
|
||||
return this.data.refSections;
|
||||
}
|
||||
set refSections(v: number[]) {
|
||||
this.data.refSections = v;
|
||||
}
|
||||
// get refSections(): number[] {
|
||||
// return this.data.refSections;
|
||||
// }
|
||||
// set refSections(v: number[]) {
|
||||
// this.data.refSections = v;
|
||||
// }
|
||||
clone(): SpksSwitchData {
|
||||
return new SpksSwitchData(this.data.cloneMessage());
|
||||
}
|
||||
@ -114,36 +114,3 @@ export class DrawSpksSwitchInteraction extends GraphicInteractionPlugin<SpksSwit
|
||||
SpksSwitchEditMenu.open(e.global);
|
||||
}
|
||||
}
|
||||
|
||||
export class SpksSwitchOperationInteraction extends GraphicInteractionPlugin<SpksSwitch> {
|
||||
static Name = 'spks_switch_operation';
|
||||
constructor(app: IGraphicScene) {
|
||||
super(SpksSwitchOperationInteraction.Name, app);
|
||||
}
|
||||
static init(app: IGraphicScene) {
|
||||
return new SpksSwitchOperationInteraction(app);
|
||||
}
|
||||
filter(...grahpics: JlGraphic[]): SpksSwitch[] | undefined {
|
||||
return grahpics.filter((g): g is SpksSwitch => g instanceof SpksSwitch);
|
||||
}
|
||||
bind(g: SpksSwitch): void {
|
||||
g.eventMode = 'static';
|
||||
g.cursor = 'pointer';
|
||||
g.on('_leftclick', this.onLeftClick, this);
|
||||
}
|
||||
unbind(g: SpksSwitch): void {
|
||||
g.off('_leftclick', this.onLeftClick, this);
|
||||
}
|
||||
onLeftClick(e: FederatedMouseEvent) {
|
||||
const target = e.target as DisplayObject;
|
||||
const spksSwitch = target.getGraphic() as SpksSwitch;
|
||||
const stand = this.app.queryStore.queryById<Platform>(
|
||||
spksSwitch.datas.refStand
|
||||
);
|
||||
const station = this.app.queryStore.queryById<Station>(
|
||||
stand.datas.refStation
|
||||
);
|
||||
|
||||
useIbpStore().openIbpScene(station);
|
||||
}
|
||||
}
|
||||
|
107
src/drawApp/graphics/UnattengedButtonInteraction.ts
Normal file
107
src/drawApp/graphics/UnattengedButtonInteraction.ts
Normal file
@ -0,0 +1,107 @@
|
||||
import * as pb_1 from 'google-protobuf';
|
||||
import { DisplayObject, FederatedMouseEvent } from 'pixi.js';
|
||||
import { IUnattengedButtonData, UnattengedButton } from 'src/graphics/unattengedButton/UnattengedButton';
|
||||
import {
|
||||
IGraphicApp,
|
||||
GraphicInteractionPlugin,
|
||||
JlGraphic,
|
||||
IGraphicScene,
|
||||
MenuItemOptions,
|
||||
ContextMenu,
|
||||
} from 'jl-graphic';
|
||||
|
||||
import { graphicData } from 'src/protos/stationLayoutGraphics';
|
||||
import { GraphicDataBase } from './GraphicDataBase';
|
||||
import { useIbpStore } from 'src/stores/ibp-store';
|
||||
import { Station } from 'src/graphics/station/Station';
|
||||
import { Platform } from 'src/graphics/platform/Platform';
|
||||
|
||||
export class UnattengedButtonData extends GraphicDataBase implements IUnattengedButtonData {
|
||||
constructor(data?: graphicData.UnattengedButton) {
|
||||
let unattengedButton;
|
||||
if (!data) {
|
||||
unattengedButton = new graphicData.UnattengedButton({
|
||||
common: GraphicDataBase.defaultCommonInfo(UnattengedButton.Type),
|
||||
});
|
||||
} else {
|
||||
unattengedButton = data;
|
||||
}
|
||||
super(unattengedButton);
|
||||
}
|
||||
|
||||
public get data(): graphicData.UnattengedButton {
|
||||
return this.getData<graphicData.UnattengedButton>();
|
||||
}
|
||||
get code(): string {
|
||||
return this.data.code;
|
||||
}
|
||||
set code(v: string) {
|
||||
this.data.code = v;
|
||||
}
|
||||
get flip(): boolean {
|
||||
return this.data.flip;
|
||||
}
|
||||
set flip(v: boolean) {
|
||||
this.data.flip = v;
|
||||
}
|
||||
get refStand(): number {
|
||||
return this.data.refStand;
|
||||
}
|
||||
set refStand(v: number) {
|
||||
this.data.refStand = v;
|
||||
}
|
||||
clone(): UnattengedButtonData {
|
||||
return new UnattengedButtonData(this.data.cloneMessage());
|
||||
}
|
||||
copyFrom(data: UnattengedButtonData): void {
|
||||
pb_1.Message.copyInto(data.data, this.data);
|
||||
}
|
||||
eq(other: UnattengedButtonData): boolean {
|
||||
return pb_1.Message.equals(this.data, other.data);
|
||||
}
|
||||
}
|
||||
|
||||
const flipConfig: MenuItemOptions = {
|
||||
name: '上下翻转',
|
||||
};
|
||||
const UnattengedButtonEditMenu: ContextMenu = ContextMenu.init({
|
||||
name: '无人折返按钮编辑菜单',
|
||||
groups: [
|
||||
{
|
||||
items: [flipConfig],
|
||||
},
|
||||
],
|
||||
});
|
||||
export class DrawUnattengedButtonInteraction extends GraphicInteractionPlugin<UnattengedButton> {
|
||||
static Name = 'unattenged_button_draw_right_menu';
|
||||
constructor(app: IGraphicApp) {
|
||||
super(DrawUnattengedButtonInteraction.Name, app);
|
||||
app.registerMenu(UnattengedButtonEditMenu);
|
||||
}
|
||||
static init(app: IGraphicApp) {
|
||||
return new DrawUnattengedButtonInteraction(app);
|
||||
}
|
||||
filter(...grahpics: JlGraphic[]): UnattengedButton[] | undefined {
|
||||
return grahpics
|
||||
.filter((g) => g.type === UnattengedButton.Type)
|
||||
.map((g) => g as UnattengedButton);
|
||||
}
|
||||
bind(g: UnattengedButton): void {
|
||||
g.on('_rightclick', this.onContextMenu, this);
|
||||
}
|
||||
|
||||
unbind(g: UnattengedButton): void {
|
||||
g.off('_rightclick', this.onContextMenu, this);
|
||||
}
|
||||
|
||||
onContextMenu(e: FederatedMouseEvent) {
|
||||
const target = e.target as DisplayObject;
|
||||
const unattengedButton = target.getGraphic() as UnattengedButton;
|
||||
this.app.updateSelected(unattengedButton);
|
||||
flipConfig.handler = () => {
|
||||
unattengedButton.datas.flip = !unattengedButton.datas.flip;
|
||||
unattengedButton.repaint();
|
||||
};
|
||||
UnattengedButtonEditMenu.open(e.global);
|
||||
}
|
||||
}
|
@ -122,7 +122,6 @@ import { EsbButton, EsbButtonTemplate } from 'src/graphics/esbButton/EsbButton';
|
||||
import { StopPositionData } from './graphics/StopPositionInteraction';
|
||||
import {
|
||||
SpksSwitchData,
|
||||
SpksSwitchOperationInteraction,
|
||||
} from './graphics/SpksSwitchInteraction';
|
||||
import { GatedBoxData } from './graphics/GatedBoxInteraction';
|
||||
import {
|
||||
@ -195,6 +194,8 @@ import {
|
||||
FloodGateOperationInteraction,
|
||||
FloodGateState,
|
||||
} from './graphics/FloodGateInteraction';
|
||||
import { HoldButton } from 'src/graphics/holdButton/HoldButton';
|
||||
import { UnattengedButton } from 'src/graphics/unattengedButton/UnattengedButton';
|
||||
|
||||
const showOptions: MenuItemOptions = {
|
||||
name: '显示控制',
|
||||
@ -260,6 +261,8 @@ export const layerList = [
|
||||
{ label: '车库门', value: GarageDoor.Type, defaultShow: true },
|
||||
{ label: '洗车机', value: CarWashing.Type, defaultShow: true },
|
||||
{ label: '防淹门', value: FloodGate.Type, defaultShow: true },
|
||||
{ label: '扣车按钮', value: HoldButton.Type, defaultShow: true },
|
||||
{ label: '无人折返按钮', value: UnattengedButton.Type, defaultShow: true },
|
||||
];
|
||||
|
||||
let lineScene: IGraphicScene;
|
||||
@ -343,7 +346,6 @@ export function initLineScene(lineApp: IGraphicApp, sceneName: string) {
|
||||
TurnoutOperationPlugin.init(lineScene);
|
||||
TransponderOperationPlugin.init(lineScene);
|
||||
EsbButtonOperationInteraction.init(lineScene);
|
||||
SpksSwitchOperationInteraction.init(lineScene);
|
||||
AutoReturnBoxOperationInteraction.init(lineScene);
|
||||
PslBoxOperateInteraction.init(lineScene);
|
||||
IbpBoxOperateInteraction.init(lineScene);
|
||||
|
@ -42,7 +42,7 @@ const esbButtonConsts = {
|
||||
export class EsbButton extends JlGraphic {
|
||||
static Type = 'esbButton';
|
||||
codeGraph: VectorText = new VectorText('');
|
||||
circleBody: Graphics = new Graphics();
|
||||
textGraph: VectorText = new VectorText('E');
|
||||
rectBody: Graphics = new Graphics();
|
||||
lineBody: Graphics = new Graphics();
|
||||
|
||||
@ -51,7 +51,7 @@ export class EsbButton extends JlGraphic {
|
||||
this.addChild(this.codeGraph);
|
||||
this.addChild(this.rectBody);
|
||||
this.addChild(this.lineBody);
|
||||
this.addChild(this.circleBody);
|
||||
this.addChild(this.textGraph);
|
||||
this.codeGraph.name = 'esb_code';
|
||||
}
|
||||
get code(): string {
|
||||
@ -80,15 +80,9 @@ export class EsbButton extends JlGraphic {
|
||||
} else {
|
||||
codeGraph.position.set(-30, 0);
|
||||
}
|
||||
this.circleBody.clear();
|
||||
this.circleBody.beginFill(
|
||||
this.state.down
|
||||
? esbButtonConsts.pressedColor
|
||||
: esbButtonConsts.bodyCircleColor,
|
||||
1
|
||||
);
|
||||
this.circleBody.drawCircle(0, 0, esbButtonConsts.bodyCircleRadius);
|
||||
this.circleBody.endFill();
|
||||
this.textGraph.style.fill = esbButtonConsts.codeColor;
|
||||
this.textGraph.setVectorFontSize(esbButtonConsts.codeFontSize);
|
||||
this.textGraph.anchor.set(0.5);
|
||||
this.rectBody.clear();
|
||||
this.rectBody.beginFill(esbButtonConsts.bodyColor, 0);
|
||||
this.rectBody.lineStyle(
|
||||
|
102
src/graphics/holdButton/HoldButton.ts
Normal file
102
src/graphics/holdButton/HoldButton.ts
Normal file
@ -0,0 +1,102 @@
|
||||
import { Graphics } from 'pixi.js';
|
||||
import {
|
||||
GraphicData,
|
||||
JlGraphic,
|
||||
JlGraphicTemplate,
|
||||
VectorText,
|
||||
} from 'jl-graphic';
|
||||
|
||||
export interface IHoldButtonData extends GraphicData {
|
||||
get code(): string;
|
||||
set code(v: string);
|
||||
get flip(): boolean;
|
||||
set flip(v: boolean);
|
||||
get refStand(): number;
|
||||
set refStand(v: number);
|
||||
}
|
||||
|
||||
const holdButtonConsts = {
|
||||
codeFontSize: 12,
|
||||
codeColor: 0xffffff,
|
||||
bodyLineColor: 0xffffff,
|
||||
bodyLineWidth: 4,
|
||||
bodyRectLineColor: 0xffffff,
|
||||
bodyRectLineWidth: 2,
|
||||
bodyRectWidth: 20,
|
||||
bodyRectHeight: 20,
|
||||
bodyColor: 0x000000,
|
||||
};
|
||||
export class HoldButton extends JlGraphic {
|
||||
static Type = 'holdButton';
|
||||
codeGraph: VectorText = new VectorText('');
|
||||
rectBody: Graphics = new Graphics();
|
||||
lineBody: Graphics = new Graphics();
|
||||
textGraph: VectorText = new VectorText('H');
|
||||
|
||||
constructor() {
|
||||
super(HoldButton.Type);
|
||||
this.addChild(this.codeGraph);
|
||||
this.addChild(this.rectBody);
|
||||
this.addChild(this.lineBody);
|
||||
this.addChild(this.textGraph);
|
||||
this.codeGraph.name = 'hold_button_code';
|
||||
}
|
||||
get datas(): IHoldButtonData {
|
||||
return this.getDatas<IHoldButtonData>();
|
||||
}
|
||||
doRepaint(): void {
|
||||
const codeGraph = this.codeGraph;
|
||||
codeGraph.text = this.datas.code;
|
||||
codeGraph.style.fill = holdButtonConsts.codeColor;
|
||||
codeGraph.setVectorFontSize(holdButtonConsts.codeFontSize);
|
||||
const codeTransform = this.datas?.childTransforms?.find(
|
||||
(item) => item.name === 'hold_button_code'
|
||||
);
|
||||
if (codeTransform) {
|
||||
const position = codeTransform?.transform.position;
|
||||
const rotation = codeTransform?.transform?.rotation;
|
||||
codeGraph.position.set(position?.x, position?.y);
|
||||
codeGraph.rotation = rotation || 0;
|
||||
} else {
|
||||
codeGraph.position.set(20, 0);
|
||||
}
|
||||
codeGraph.anchor.set(0.5);
|
||||
this.textGraph.style.fill = holdButtonConsts.codeColor;
|
||||
this.textGraph.setVectorFontSize(holdButtonConsts.codeFontSize);
|
||||
this.textGraph.anchor.set(0.5);
|
||||
this.rectBody.clear();
|
||||
this.rectBody.beginFill(holdButtonConsts.bodyColor, 0);
|
||||
this.rectBody.lineStyle(
|
||||
holdButtonConsts.bodyRectLineWidth,
|
||||
holdButtonConsts.bodyRectLineColor
|
||||
);
|
||||
this.rectBody.drawRect(
|
||||
-holdButtonConsts.bodyRectWidth / 2,
|
||||
-holdButtonConsts.bodyRectHeight / 2,
|
||||
holdButtonConsts.bodyRectWidth,
|
||||
holdButtonConsts.bodyRectHeight
|
||||
);
|
||||
this.rectBody.endFill();
|
||||
this.lineBody.clear();
|
||||
const lineY = this.datas.flip
|
||||
? holdButtonConsts.bodyRectHeight / 2
|
||||
: -holdButtonConsts.bodyRectHeight / 2;
|
||||
this.lineBody.lineStyle(
|
||||
holdButtonConsts.bodyLineWidth,
|
||||
holdButtonConsts.bodyLineColor
|
||||
);
|
||||
this.lineBody.moveTo(-holdButtonConsts.bodyRectWidth / 2, lineY);
|
||||
this.lineBody.lineTo(holdButtonConsts.bodyRectWidth / 2, lineY);
|
||||
}
|
||||
}
|
||||
|
||||
export class HoldButtonTemplate extends JlGraphicTemplate<HoldButton> {
|
||||
constructor(dataTemplate: IHoldButtonData) {
|
||||
super(HoldButton.Type, { dataTemplate });
|
||||
}
|
||||
new(): HoldButton {
|
||||
const holdButton = new HoldButton();
|
||||
holdButton.loadData(this.datas);
|
||||
return holdButton;
|
||||
}
|
||||
}
|
128
src/graphics/holdButton/HoldButtonDrawAssistant.ts
Normal file
128
src/graphics/holdButton/HoldButtonDrawAssistant.ts
Normal file
@ -0,0 +1,128 @@
|
||||
import { DisplayObject, FederatedMouseEvent, Point } from 'pixi.js';
|
||||
import {
|
||||
AbsorbableLine,
|
||||
AbsorbablePosition,
|
||||
GraphicDrawAssistant,
|
||||
GraphicInteractionPlugin,
|
||||
GraphicTransformEvent,
|
||||
IDrawApp,
|
||||
JlGraphic,
|
||||
} from 'jl-graphic';
|
||||
import { IHoldButtonData, HoldButton, HoldButtonTemplate } from './HoldButton';
|
||||
|
||||
export interface IHoldButtonDataDrawOptions {
|
||||
newData: () => IHoldButtonData;
|
||||
}
|
||||
export class HoldButtonDraw extends GraphicDrawAssistant<
|
||||
HoldButtonTemplate,
|
||||
IHoldButtonData
|
||||
> {
|
||||
_holdButton: HoldButton | null = null;
|
||||
constructor(app: IDrawApp, template: HoldButtonTemplate) {
|
||||
super(
|
||||
app,
|
||||
template,
|
||||
'svguse:../../drawIcon.svg#icon-hold-button',
|
||||
'扣车按钮HoldButton'
|
||||
);
|
||||
HoldButtonInteraction.init(app);
|
||||
}
|
||||
public get holdButton(): HoldButton {
|
||||
if (!this._holdButton) {
|
||||
this._holdButton = this.graphicTemplate.new();
|
||||
this._holdButton.loadData(this.graphicTemplate.datas);
|
||||
this.container.addChild(this._holdButton);
|
||||
}
|
||||
return this._holdButton;
|
||||
}
|
||||
|
||||
onLeftUp(e: FederatedMouseEvent): void {
|
||||
this.container.position.copyFrom(this.toCanvasCoordinates(e.global));
|
||||
this.createAndStore(true);
|
||||
}
|
||||
|
||||
redraw(p: Point): void {
|
||||
this.holdButton.repaint();
|
||||
this.container.position.set(p.x, p.y);
|
||||
}
|
||||
|
||||
prepareData(data: IHoldButtonData): boolean {
|
||||
data.transform = this.container.saveTransform();
|
||||
data.code = 'H';
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 构建吸附线
|
||||
* @param holdButton
|
||||
*/
|
||||
function buildAbsorbablePositions(
|
||||
holdButton: HoldButton
|
||||
): AbsorbablePosition[] {
|
||||
const aps: AbsorbablePosition[] = [];
|
||||
const holdButtons = holdButton.queryStore.queryByType<HoldButton>(
|
||||
HoldButton.Type
|
||||
);
|
||||
const canvas = holdButton.getCanvas();
|
||||
holdButtons.forEach((item) => {
|
||||
if (item.id === holdButton.id) {
|
||||
return;
|
||||
}
|
||||
const ala = new AbsorbableLine(
|
||||
new Point(item.x, 0),
|
||||
new Point(item.x, canvas.height)
|
||||
);
|
||||
const alb = new AbsorbableLine(
|
||||
new Point(0, item.y),
|
||||
new Point(canvas.width, item.y)
|
||||
);
|
||||
aps.push(ala);
|
||||
aps.push(alb);
|
||||
});
|
||||
return aps;
|
||||
}
|
||||
|
||||
export class HoldButtonInteraction extends GraphicInteractionPlugin<HoldButton> {
|
||||
static Name = 'hold_button_transform';
|
||||
constructor(app: IDrawApp) {
|
||||
super(HoldButtonInteraction.Name, app);
|
||||
}
|
||||
static init(app: IDrawApp) {
|
||||
return new HoldButtonInteraction(app);
|
||||
}
|
||||
filter(...grahpics: JlGraphic[]): HoldButton[] | undefined {
|
||||
return grahpics
|
||||
.filter((g) => g.type === HoldButton.Type)
|
||||
.map((g) => g as HoldButton);
|
||||
}
|
||||
bind(g: HoldButton): void {
|
||||
g.eventMode = 'static';
|
||||
g.cursor = 'pointer';
|
||||
g.scalable = true;
|
||||
g.rotatable = true;
|
||||
g.codeGraph.draggable = true;
|
||||
g.codeGraph.selectable = true;
|
||||
g.codeGraph.rotatable = true;
|
||||
g.codeGraph.transformSave = true;
|
||||
g.codeGraph.eventMode = 'static';
|
||||
g.on('transformstart', this.transformstart, this);
|
||||
}
|
||||
unbind(g: HoldButton): void {
|
||||
g.eventMode = 'none';
|
||||
g.scalable = false;
|
||||
g.rotatable = false;
|
||||
g.codeGraph.draggable = false;
|
||||
g.codeGraph.selectable = false;
|
||||
g.codeGraph.rotatable = false;
|
||||
g.codeGraph.transformSave = false;
|
||||
g.codeGraph.eventMode = 'none';
|
||||
g.off('transformstart', this.transformstart, this);
|
||||
}
|
||||
transformstart(e: GraphicTransformEvent) {
|
||||
const target = e.target as DisplayObject;
|
||||
const holdButton = target.getGraphic() as HoldButton;
|
||||
holdButton.getGraphicApp().setOptions({
|
||||
absorbablePositions: buildAbsorbablePositions(holdButton),
|
||||
});
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ export interface IIbpBoxDrawOptions {
|
||||
export class IbpBoxDraw extends GraphicDrawAssistant<IbpBoxTemplate, IIbpBox> {
|
||||
_gatedBox: IbpBox | null = null;
|
||||
constructor(app: IDrawApp, template: IbpBoxTemplate) {
|
||||
super(app, template, 'svguse:../../drawIcon.svg#icon-spks-switch', 'Ibp');
|
||||
super(app, template, 'svguse:../../drawIcon.svg#icon-ibp-box', 'Ibp');
|
||||
IbpBoxInteraction.init(app);
|
||||
}
|
||||
public get gatedBox(): IbpBox {
|
||||
|
@ -13,8 +13,8 @@ export interface ISpksSwitchData extends GraphicData {
|
||||
set flip(v: boolean);
|
||||
get refStand(): number;
|
||||
set refStand(v: number);
|
||||
get refSections(): number[];
|
||||
set refSections(v: number[]);
|
||||
// get refSections(): number[];
|
||||
// set refSections(v: number[]);
|
||||
}
|
||||
|
||||
const spksSwitchConsts = {
|
||||
|
103
src/graphics/unattengedButton/UnattengedButton.ts
Normal file
103
src/graphics/unattengedButton/UnattengedButton.ts
Normal file
@ -0,0 +1,103 @@
|
||||
import { Graphics } from 'pixi.js';
|
||||
import {
|
||||
GraphicData,
|
||||
JlGraphic,
|
||||
JlGraphicTemplate,
|
||||
VectorText,
|
||||
} from 'jl-graphic';
|
||||
|
||||
export interface IUnattengedButtonData extends GraphicData {
|
||||
get code(): string;
|
||||
set code(v: string);
|
||||
get flip(): boolean;
|
||||
set flip(v: boolean);
|
||||
get refStand(): number;
|
||||
set refStand(v: number);
|
||||
}
|
||||
|
||||
const unattengedButtonConsts = {
|
||||
codeFontSize: 12,
|
||||
codeColor: 0xffffff,
|
||||
bodyLineColor: 0xffffff,
|
||||
bodyLineWidth: 4,
|
||||
bodyRectLineColor: 0xffffff,
|
||||
bodyRectLineWidth: 2,
|
||||
bodyRectWidth: 20,
|
||||
bodyRectHeight: 20,
|
||||
bodyColor: 0x000000,
|
||||
};
|
||||
export class UnattengedButton extends JlGraphic {
|
||||
static Type = 'unattengedButton';
|
||||
codeGraph: VectorText = new VectorText('');
|
||||
rectBody: Graphics = new Graphics();
|
||||
lineBody: Graphics = new Graphics();
|
||||
textGraph: VectorText = new VectorText('W');
|
||||
|
||||
constructor() {
|
||||
super(UnattengedButton.Type);
|
||||
this.addChild(this.codeGraph);
|
||||
this.addChild(this.rectBody);
|
||||
this.addChild(this.lineBody);
|
||||
this.addChild(this.textGraph);
|
||||
this.codeGraph.name = 'unattenged_button_code';
|
||||
}
|
||||
get datas(): IUnattengedButtonData {
|
||||
return this.getDatas<IUnattengedButtonData>();
|
||||
}
|
||||
doRepaint(): void {
|
||||
console.log('111111111')
|
||||
const codeGraph = this.codeGraph;
|
||||
codeGraph.text = this.datas.code;
|
||||
codeGraph.style.fill = unattengedButtonConsts.codeColor;
|
||||
codeGraph.setVectorFontSize(unattengedButtonConsts.codeFontSize);
|
||||
const codeTransform = this.datas?.childTransforms?.find(
|
||||
(item) => item.name === 'unattenged_button_code'
|
||||
);
|
||||
if (codeTransform) {
|
||||
const position = codeTransform?.transform.position;
|
||||
const rotation = codeTransform?.transform?.rotation;
|
||||
codeGraph.position.set(position?.x, position?.y);
|
||||
codeGraph.rotation = rotation || 0;
|
||||
} else {
|
||||
codeGraph.position.set(20, 0);
|
||||
}
|
||||
codeGraph.anchor.set(0.5);
|
||||
this.textGraph.style.fill = unattengedButtonConsts.codeColor;
|
||||
this.textGraph.setVectorFontSize(unattengedButtonConsts.codeFontSize);
|
||||
this.textGraph.anchor.set(0.5);
|
||||
this.rectBody.clear();
|
||||
this.rectBody.beginFill(unattengedButtonConsts.bodyColor, 0);
|
||||
this.rectBody.lineStyle(
|
||||
unattengedButtonConsts.bodyRectLineWidth,
|
||||
unattengedButtonConsts.bodyRectLineColor
|
||||
);
|
||||
this.rectBody.drawRect(
|
||||
-unattengedButtonConsts.bodyRectWidth / 2,
|
||||
-unattengedButtonConsts.bodyRectHeight / 2,
|
||||
unattengedButtonConsts.bodyRectWidth,
|
||||
unattengedButtonConsts.bodyRectHeight
|
||||
);
|
||||
this.rectBody.endFill();
|
||||
this.lineBody.clear();
|
||||
const lineY = this.datas.flip
|
||||
? unattengedButtonConsts.bodyRectHeight / 2
|
||||
: -unattengedButtonConsts.bodyRectHeight / 2;
|
||||
this.lineBody.lineStyle(
|
||||
unattengedButtonConsts.bodyLineWidth,
|
||||
unattengedButtonConsts.bodyLineColor
|
||||
);
|
||||
this.lineBody.moveTo(-unattengedButtonConsts.bodyRectWidth / 2, lineY);
|
||||
this.lineBody.lineTo(unattengedButtonConsts.bodyRectWidth / 2, lineY);
|
||||
}
|
||||
}
|
||||
|
||||
export class UnattengedButtonTemplate extends JlGraphicTemplate<UnattengedButton> {
|
||||
constructor(dataTemplate: IUnattengedButtonData) {
|
||||
super(UnattengedButton.Type, { dataTemplate });
|
||||
}
|
||||
new(): UnattengedButton {
|
||||
const unattengedButton = new UnattengedButton();
|
||||
unattengedButton.loadData(this.datas);
|
||||
return unattengedButton;
|
||||
}
|
||||
}
|
128
src/graphics/unattengedButton/UnattengedButtonDrawAssistant.ts
Normal file
128
src/graphics/unattengedButton/UnattengedButtonDrawAssistant.ts
Normal file
@ -0,0 +1,128 @@
|
||||
import { DisplayObject, FederatedMouseEvent, Point } from 'pixi.js';
|
||||
import {
|
||||
AbsorbableLine,
|
||||
AbsorbablePosition,
|
||||
GraphicDrawAssistant,
|
||||
GraphicInteractionPlugin,
|
||||
GraphicTransformEvent,
|
||||
IDrawApp,
|
||||
JlGraphic,
|
||||
} from 'jl-graphic';
|
||||
import { IUnattengedButtonData, UnattengedButton, UnattengedButtonTemplate } from './UnattengedButton';
|
||||
|
||||
export interface IUnattengedButtonDataOptions {
|
||||
newData: () => IUnattengedButtonData;
|
||||
}
|
||||
export class UnattengedButtonDraw extends GraphicDrawAssistant<
|
||||
UnattengedButtonTemplate,
|
||||
IUnattengedButtonData
|
||||
> {
|
||||
_unattengedButton: UnattengedButton | null = null;
|
||||
constructor(app: IDrawApp, template: UnattengedButtonTemplate) {
|
||||
super(
|
||||
app,
|
||||
template,
|
||||
'svguse:../../drawIcon.svg#icon-unattenged-button',
|
||||
'无人折返按钮UnattengedButton'
|
||||
);
|
||||
UnattengedButtonInteraction.init(app);
|
||||
}
|
||||
public get unattengedButton(): UnattengedButton {
|
||||
if (!this._unattengedButton) {
|
||||
this._unattengedButton = this.graphicTemplate.new();
|
||||
this._unattengedButton.loadData(this.graphicTemplate.datas);
|
||||
this.container.addChild(this._unattengedButton);
|
||||
}
|
||||
return this._unattengedButton;
|
||||
}
|
||||
|
||||
onLeftUp(e: FederatedMouseEvent): void {
|
||||
this.container.position.copyFrom(this.toCanvasCoordinates(e.global));
|
||||
this.createAndStore(true);
|
||||
}
|
||||
|
||||
redraw(p: Point): void {
|
||||
this.unattengedButton.repaint();
|
||||
this.container.position.set(p.x, p.y);
|
||||
}
|
||||
|
||||
prepareData(data: IUnattengedButtonData): boolean {
|
||||
data.transform = this.container.saveTransform();
|
||||
data.code = 'W';
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 构建吸附线
|
||||
* @param unattengedButton
|
||||
*/
|
||||
function buildAbsorbablePositions(
|
||||
unattengedButton: UnattengedButton
|
||||
): AbsorbablePosition[] {
|
||||
const aps: AbsorbablePosition[] = [];
|
||||
const unattengedButtons = unattengedButton.queryStore.queryByType<UnattengedButton>(
|
||||
UnattengedButton.Type
|
||||
);
|
||||
const canvas = unattengedButton.getCanvas();
|
||||
unattengedButtons.forEach((item) => {
|
||||
if (item.id === unattengedButton.id) {
|
||||
return;
|
||||
}
|
||||
const ala = new AbsorbableLine(
|
||||
new Point(item.x, 0),
|
||||
new Point(item.x, canvas.height)
|
||||
);
|
||||
const alb = new AbsorbableLine(
|
||||
new Point(0, item.y),
|
||||
new Point(canvas.width, item.y)
|
||||
);
|
||||
aps.push(ala);
|
||||
aps.push(alb);
|
||||
});
|
||||
return aps;
|
||||
}
|
||||
|
||||
export class UnattengedButtonInteraction extends GraphicInteractionPlugin<UnattengedButton> {
|
||||
static Name = 'unattenged_button_transform';
|
||||
constructor(app: IDrawApp) {
|
||||
super(UnattengedButtonInteraction.Name, app);
|
||||
}
|
||||
static init(app: IDrawApp) {
|
||||
return new UnattengedButtonInteraction(app);
|
||||
}
|
||||
filter(...grahpics: JlGraphic[]): UnattengedButton[] | undefined {
|
||||
return grahpics
|
||||
.filter((g) => g.type === UnattengedButton.Type)
|
||||
.map((g) => g as UnattengedButton);
|
||||
}
|
||||
bind(g: UnattengedButton): void {
|
||||
g.eventMode = 'static';
|
||||
g.cursor = 'pointer';
|
||||
g.scalable = true;
|
||||
g.rotatable = true;
|
||||
g.codeGraph.draggable = true;
|
||||
g.codeGraph.selectable = true;
|
||||
g.codeGraph.rotatable = true;
|
||||
g.codeGraph.transformSave = true;
|
||||
g.codeGraph.eventMode = 'static';
|
||||
g.on('transformstart', this.transformstart, this);
|
||||
}
|
||||
unbind(g: UnattengedButton): void {
|
||||
g.eventMode = 'none';
|
||||
g.scalable = false;
|
||||
g.rotatable = false;
|
||||
g.codeGraph.draggable = false;
|
||||
g.codeGraph.selectable = false;
|
||||
g.codeGraph.rotatable = false;
|
||||
g.codeGraph.transformSave = false;
|
||||
g.codeGraph.eventMode = 'none';
|
||||
g.off('transformstart', this.transformstart, this);
|
||||
}
|
||||
transformstart(e: GraphicTransformEvent) {
|
||||
const target = e.target as DisplayObject;
|
||||
const unattengedButton = target.getGraphic() as UnattengedButton;
|
||||
unattengedButton.getGraphicApp().setOptions({
|
||||
absorbablePositions: buildAbsorbablePositions(unattengedButton),
|
||||
});
|
||||
}
|
||||
}
|
@ -278,6 +278,8 @@ import { PslBox } from 'src/graphics/pslBox/PslBox';
|
||||
import { CarWashing } from 'src/graphics/carWashing/CarWashing';
|
||||
import { GarageDoor } from 'src/graphics/garageDoor/GarageDoor';
|
||||
import { FloodGate } from 'src/graphics/floodGate/FloodGate';
|
||||
import { HoldButton } from 'src/graphics/holdButton/HoldButton';
|
||||
import { UnattengedButton } from 'src/graphics/unattengedButton/UnattengedButton';
|
||||
|
||||
const $q = useQuasar();
|
||||
const route = useRoute();
|
||||
@ -450,6 +452,8 @@ onMounted(() => {
|
||||
CarWashing.Type,
|
||||
GarageDoor.Type,
|
||||
FloodGate.Type,
|
||||
HoldButton.Type,
|
||||
UnattengedButton.Type,
|
||||
];
|
||||
switch (drawStore.categoryType) {
|
||||
case CategoryType.TH:
|
||||
|
@ -56,9 +56,11 @@ export namespace graphicData {
|
||||
garageDoors?: GarageDoor[];
|
||||
floodGates?: GarageDoor[];
|
||||
lianSuoData?: LianSuoData;
|
||||
holdButtons?: HoldButton[];
|
||||
unattengedButtons?: UnattengedButton[];
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 32, 33, 34, 35, 37, 39, 40, 41, 42, 43, 44, 45, 46, 47], this.#one_of_decls);
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 32, 33, 34, 35, 37, 39, 40, 41, 42, 43, 44, 45, 46, 47, 50, 51], this.#one_of_decls);
|
||||
if (!Array.isArray(data) && typeof data == "object") {
|
||||
if ("canvas" in data && data.canvas != undefined) {
|
||||
this.canvas = data.canvas;
|
||||
@ -189,6 +191,12 @@ export namespace graphicData {
|
||||
if ("lianSuoData" in data && data.lianSuoData != undefined) {
|
||||
this.lianSuoData = data.lianSuoData;
|
||||
}
|
||||
if ("holdButtons" in data && data.holdButtons != undefined) {
|
||||
this.holdButtons = data.holdButtons;
|
||||
}
|
||||
if ("unattengedButtons" in data && data.unattengedButtons != undefined) {
|
||||
this.unattengedButtons = data.unattengedButtons;
|
||||
}
|
||||
}
|
||||
}
|
||||
get canvas() {
|
||||
@ -464,6 +472,18 @@ export namespace graphicData {
|
||||
get has_lianSuoData() {
|
||||
return pb_1.Message.getField(this, 49) != null;
|
||||
}
|
||||
get holdButtons() {
|
||||
return pb_1.Message.getRepeatedWrapperField(this, HoldButton, 50) as HoldButton[];
|
||||
}
|
||||
set holdButtons(value: HoldButton[]) {
|
||||
pb_1.Message.setRepeatedWrapperField(this, 50, value);
|
||||
}
|
||||
get unattengedButtons() {
|
||||
return pb_1.Message.getRepeatedWrapperField(this, UnattengedButton, 51) as UnattengedButton[];
|
||||
}
|
||||
set unattengedButtons(value: UnattengedButton[]) {
|
||||
pb_1.Message.setRepeatedWrapperField(this, 51, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
canvas?: ReturnType<typeof Canvas.prototype.toObject>;
|
||||
Platforms?: ReturnType<typeof Platform.prototype.toObject>[];
|
||||
@ -508,6 +528,8 @@ export namespace graphicData {
|
||||
garageDoors?: ReturnType<typeof GarageDoor.prototype.toObject>[];
|
||||
floodGates?: ReturnType<typeof GarageDoor.prototype.toObject>[];
|
||||
lianSuoData?: ReturnType<typeof LianSuoData.prototype.toObject>;
|
||||
holdButtons?: ReturnType<typeof HoldButton.prototype.toObject>[];
|
||||
unattengedButtons?: ReturnType<typeof UnattengedButton.prototype.toObject>[];
|
||||
}): RtssGraphicStorage {
|
||||
const message = new RtssGraphicStorage({});
|
||||
if (data.canvas != null) {
|
||||
@ -639,6 +661,12 @@ export namespace graphicData {
|
||||
if (data.lianSuoData != null) {
|
||||
message.lianSuoData = LianSuoData.fromObject(data.lianSuoData);
|
||||
}
|
||||
if (data.holdButtons != null) {
|
||||
message.holdButtons = data.holdButtons.map(item => HoldButton.fromObject(item));
|
||||
}
|
||||
if (data.unattengedButtons != null) {
|
||||
message.unattengedButtons = data.unattengedButtons.map(item => UnattengedButton.fromObject(item));
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
@ -686,6 +714,8 @@ export namespace graphicData {
|
||||
garageDoors?: ReturnType<typeof GarageDoor.prototype.toObject>[];
|
||||
floodGates?: ReturnType<typeof GarageDoor.prototype.toObject>[];
|
||||
lianSuoData?: ReturnType<typeof LianSuoData.prototype.toObject>;
|
||||
holdButtons?: ReturnType<typeof HoldButton.prototype.toObject>[];
|
||||
unattengedButtons?: ReturnType<typeof UnattengedButton.prototype.toObject>[];
|
||||
} = {};
|
||||
if (this.canvas != null) {
|
||||
data.canvas = this.canvas.toObject();
|
||||
@ -816,6 +846,12 @@ export namespace graphicData {
|
||||
if (this.lianSuoData != null) {
|
||||
data.lianSuoData = this.lianSuoData.toObject();
|
||||
}
|
||||
if (this.holdButtons != null) {
|
||||
data.holdButtons = this.holdButtons.map((item: HoldButton) => item.toObject());
|
||||
}
|
||||
if (this.unattengedButtons != null) {
|
||||
data.unattengedButtons = this.unattengedButtons.map((item: UnattengedButton) => item.toObject());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
@ -908,6 +944,10 @@ export namespace graphicData {
|
||||
writer.writeRepeatedMessage(47, this.floodGates, (item: GarageDoor) => item.serialize(writer));
|
||||
if (this.has_lianSuoData)
|
||||
writer.writeMessage(49, this.lianSuoData, () => this.lianSuoData.serialize(writer));
|
||||
if (this.holdButtons.length)
|
||||
writer.writeRepeatedMessage(50, this.holdButtons, (item: HoldButton) => item.serialize(writer));
|
||||
if (this.unattengedButtons.length)
|
||||
writer.writeRepeatedMessage(51, this.unattengedButtons, (item: UnattengedButton) => item.serialize(writer));
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
@ -1046,6 +1086,12 @@ export namespace graphicData {
|
||||
case 49:
|
||||
reader.readMessage(message.lianSuoData, () => message.lianSuoData = LianSuoData.deserialize(reader));
|
||||
break;
|
||||
case 50:
|
||||
reader.readMessage(message.holdButtons, () => pb_1.Message.addToRepeatedWrapperField(message, 50, HoldButton.deserialize(reader), HoldButton));
|
||||
break;
|
||||
case 51:
|
||||
reader.readMessage(message.unattengedButtons, () => pb_1.Message.addToRepeatedWrapperField(message, 51, UnattengedButton.deserialize(reader), UnattengedButton));
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
@ -6418,11 +6464,10 @@ export namespace graphicData {
|
||||
common?: CommonInfo;
|
||||
code?: string;
|
||||
flip?: boolean;
|
||||
refSections?: number[];
|
||||
refStand?: number;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [8], this.#one_of_decls);
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
if (!Array.isArray(data) && typeof data == "object") {
|
||||
if ("common" in data && data.common != undefined) {
|
||||
this.common = data.common;
|
||||
@ -6433,9 +6478,6 @@ export namespace graphicData {
|
||||
if ("flip" in data && data.flip != undefined) {
|
||||
this.flip = data.flip;
|
||||
}
|
||||
if ("refSections" in data && data.refSections != undefined) {
|
||||
this.refSections = data.refSections;
|
||||
}
|
||||
if ("refStand" in data && data.refStand != undefined) {
|
||||
this.refStand = data.refStand;
|
||||
}
|
||||
@ -6462,12 +6504,6 @@ export namespace graphicData {
|
||||
set flip(value: boolean) {
|
||||
pb_1.Message.setField(this, 3, value);
|
||||
}
|
||||
get refSections() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 8, []) as number[];
|
||||
}
|
||||
set refSections(value: number[]) {
|
||||
pb_1.Message.setField(this, 8, value);
|
||||
}
|
||||
get refStand() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 9, 0) as number;
|
||||
}
|
||||
@ -6478,7 +6514,6 @@ export namespace graphicData {
|
||||
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
|
||||
code?: string;
|
||||
flip?: boolean;
|
||||
refSections?: number[];
|
||||
refStand?: number;
|
||||
}): SpksSwitch {
|
||||
const message = new SpksSwitch({});
|
||||
@ -6491,9 +6526,6 @@ export namespace graphicData {
|
||||
if (data.flip != null) {
|
||||
message.flip = data.flip;
|
||||
}
|
||||
if (data.refSections != null) {
|
||||
message.refSections = data.refSections;
|
||||
}
|
||||
if (data.refStand != null) {
|
||||
message.refStand = data.refStand;
|
||||
}
|
||||
@ -6504,7 +6536,6 @@ export namespace graphicData {
|
||||
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
|
||||
code?: string;
|
||||
flip?: boolean;
|
||||
refSections?: number[];
|
||||
refStand?: number;
|
||||
} = {};
|
||||
if (this.common != null) {
|
||||
@ -6516,9 +6547,6 @@ export namespace graphicData {
|
||||
if (this.flip != null) {
|
||||
data.flip = this.flip;
|
||||
}
|
||||
if (this.refSections != null) {
|
||||
data.refSections = this.refSections;
|
||||
}
|
||||
if (this.refStand != null) {
|
||||
data.refStand = this.refStand;
|
||||
}
|
||||
@ -6534,8 +6562,6 @@ export namespace graphicData {
|
||||
writer.writeString(2, this.code);
|
||||
if (this.flip != false)
|
||||
writer.writeBool(3, this.flip);
|
||||
if (this.refSections.length)
|
||||
writer.writePackedUint32(8, this.refSections);
|
||||
if (this.refStand != 0)
|
||||
writer.writeUint32(9, this.refStand);
|
||||
if (!w)
|
||||
@ -6556,9 +6582,6 @@ export namespace graphicData {
|
||||
case 3:
|
||||
message.flip = reader.readBool();
|
||||
break;
|
||||
case 8:
|
||||
message.refSections = reader.readPackedUint32();
|
||||
break;
|
||||
case 9:
|
||||
message.refStand = reader.readUint32();
|
||||
break;
|
||||
@ -9605,4 +9628,282 @@ export namespace graphicData {
|
||||
return LianSuoData.deserialize(bytes);
|
||||
}
|
||||
}
|
||||
export class UnattengedButton extends pb_1.Message {
|
||||
#one_of_decls: number[][] = [];
|
||||
constructor(data?: any[] | {
|
||||
common?: CommonInfo;
|
||||
code?: string;
|
||||
flip?: boolean;
|
||||
refStand?: number;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
if (!Array.isArray(data) && typeof data == "object") {
|
||||
if ("common" in data && data.common != undefined) {
|
||||
this.common = data.common;
|
||||
}
|
||||
if ("code" in data && data.code != undefined) {
|
||||
this.code = data.code;
|
||||
}
|
||||
if ("flip" in data && data.flip != undefined) {
|
||||
this.flip = data.flip;
|
||||
}
|
||||
if ("refStand" in data && data.refStand != undefined) {
|
||||
this.refStand = data.refStand;
|
||||
}
|
||||
}
|
||||
}
|
||||
get common() {
|
||||
return pb_1.Message.getWrapperField(this, CommonInfo, 1) as CommonInfo;
|
||||
}
|
||||
set common(value: CommonInfo) {
|
||||
pb_1.Message.setWrapperField(this, 1, value);
|
||||
}
|
||||
get has_common() {
|
||||
return pb_1.Message.getField(this, 1) != null;
|
||||
}
|
||||
get code() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
|
||||
}
|
||||
set code(value: string) {
|
||||
pb_1.Message.setField(this, 2, value);
|
||||
}
|
||||
get flip() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 3, false) as boolean;
|
||||
}
|
||||
set flip(value: boolean) {
|
||||
pb_1.Message.setField(this, 3, value);
|
||||
}
|
||||
get refStand() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 4, 0) as number;
|
||||
}
|
||||
set refStand(value: number) {
|
||||
pb_1.Message.setField(this, 4, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
|
||||
code?: string;
|
||||
flip?: boolean;
|
||||
refStand?: number;
|
||||
}): UnattengedButton {
|
||||
const message = new UnattengedButton({});
|
||||
if (data.common != null) {
|
||||
message.common = CommonInfo.fromObject(data.common);
|
||||
}
|
||||
if (data.code != null) {
|
||||
message.code = data.code;
|
||||
}
|
||||
if (data.flip != null) {
|
||||
message.flip = data.flip;
|
||||
}
|
||||
if (data.refStand != null) {
|
||||
message.refStand = data.refStand;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
const data: {
|
||||
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
|
||||
code?: string;
|
||||
flip?: boolean;
|
||||
refStand?: number;
|
||||
} = {};
|
||||
if (this.common != null) {
|
||||
data.common = this.common.toObject();
|
||||
}
|
||||
if (this.code != null) {
|
||||
data.code = this.code;
|
||||
}
|
||||
if (this.flip != null) {
|
||||
data.flip = this.flip;
|
||||
}
|
||||
if (this.refStand != null) {
|
||||
data.refStand = this.refStand;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
serialize(w: pb_1.BinaryWriter): void;
|
||||
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
|
||||
const writer = w || new pb_1.BinaryWriter();
|
||||
if (this.has_common)
|
||||
writer.writeMessage(1, this.common, () => this.common.serialize(writer));
|
||||
if (this.code.length)
|
||||
writer.writeString(2, this.code);
|
||||
if (this.flip != false)
|
||||
writer.writeBool(3, this.flip);
|
||||
if (this.refStand != 0)
|
||||
writer.writeUint32(4, this.refStand);
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): UnattengedButton {
|
||||
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new UnattengedButton();
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup())
|
||||
break;
|
||||
switch (reader.getFieldNumber()) {
|
||||
case 1:
|
||||
reader.readMessage(message.common, () => message.common = CommonInfo.deserialize(reader));
|
||||
break;
|
||||
case 2:
|
||||
message.code = reader.readString();
|
||||
break;
|
||||
case 3:
|
||||
message.flip = reader.readBool();
|
||||
break;
|
||||
case 4:
|
||||
message.refStand = reader.readUint32();
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
serializeBinary(): Uint8Array {
|
||||
return this.serialize();
|
||||
}
|
||||
static deserializeBinary(bytes: Uint8Array): UnattengedButton {
|
||||
return UnattengedButton.deserialize(bytes);
|
||||
}
|
||||
}
|
||||
export class HoldButton extends pb_1.Message {
|
||||
#one_of_decls: number[][] = [];
|
||||
constructor(data?: any[] | {
|
||||
common?: CommonInfo;
|
||||
code?: string;
|
||||
flip?: boolean;
|
||||
refStand?: number;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
if (!Array.isArray(data) && typeof data == "object") {
|
||||
if ("common" in data && data.common != undefined) {
|
||||
this.common = data.common;
|
||||
}
|
||||
if ("code" in data && data.code != undefined) {
|
||||
this.code = data.code;
|
||||
}
|
||||
if ("flip" in data && data.flip != undefined) {
|
||||
this.flip = data.flip;
|
||||
}
|
||||
if ("refStand" in data && data.refStand != undefined) {
|
||||
this.refStand = data.refStand;
|
||||
}
|
||||
}
|
||||
}
|
||||
get common() {
|
||||
return pb_1.Message.getWrapperField(this, CommonInfo, 1) as CommonInfo;
|
||||
}
|
||||
set common(value: CommonInfo) {
|
||||
pb_1.Message.setWrapperField(this, 1, value);
|
||||
}
|
||||
get has_common() {
|
||||
return pb_1.Message.getField(this, 1) != null;
|
||||
}
|
||||
get code() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
|
||||
}
|
||||
set code(value: string) {
|
||||
pb_1.Message.setField(this, 2, value);
|
||||
}
|
||||
get flip() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 3, false) as boolean;
|
||||
}
|
||||
set flip(value: boolean) {
|
||||
pb_1.Message.setField(this, 3, value);
|
||||
}
|
||||
get refStand() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 4, 0) as number;
|
||||
}
|
||||
set refStand(value: number) {
|
||||
pb_1.Message.setField(this, 4, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
|
||||
code?: string;
|
||||
flip?: boolean;
|
||||
refStand?: number;
|
||||
}): HoldButton {
|
||||
const message = new HoldButton({});
|
||||
if (data.common != null) {
|
||||
message.common = CommonInfo.fromObject(data.common);
|
||||
}
|
||||
if (data.code != null) {
|
||||
message.code = data.code;
|
||||
}
|
||||
if (data.flip != null) {
|
||||
message.flip = data.flip;
|
||||
}
|
||||
if (data.refStand != null) {
|
||||
message.refStand = data.refStand;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
const data: {
|
||||
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
|
||||
code?: string;
|
||||
flip?: boolean;
|
||||
refStand?: number;
|
||||
} = {};
|
||||
if (this.common != null) {
|
||||
data.common = this.common.toObject();
|
||||
}
|
||||
if (this.code != null) {
|
||||
data.code = this.code;
|
||||
}
|
||||
if (this.flip != null) {
|
||||
data.flip = this.flip;
|
||||
}
|
||||
if (this.refStand != null) {
|
||||
data.refStand = this.refStand;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
serialize(w: pb_1.BinaryWriter): void;
|
||||
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
|
||||
const writer = w || new pb_1.BinaryWriter();
|
||||
if (this.has_common)
|
||||
writer.writeMessage(1, this.common, () => this.common.serialize(writer));
|
||||
if (this.code.length)
|
||||
writer.writeString(2, this.code);
|
||||
if (this.flip != false)
|
||||
writer.writeBool(3, this.flip);
|
||||
if (this.refStand != 0)
|
||||
writer.writeUint32(4, this.refStand);
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): HoldButton {
|
||||
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new HoldButton();
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup())
|
||||
break;
|
||||
switch (reader.getFieldNumber()) {
|
||||
case 1:
|
||||
reader.readMessage(message.common, () => message.common = CommonInfo.deserialize(reader));
|
||||
break;
|
||||
case 2:
|
||||
message.code = reader.readString();
|
||||
break;
|
||||
case 3:
|
||||
message.flip = reader.readBool();
|
||||
break;
|
||||
case 4:
|
||||
message.refStand = reader.readUint32();
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
serializeBinary(): Uint8Array {
|
||||
return this.serialize();
|
||||
}
|
||||
static deserializeBinary(bytes: Uint8Array): HoldButton {
|
||||
return HoldButton.deserialize(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user