[Update]新增左下page2可以跟著又下無人機選擇顯示資訊
parent
8c56b063df
commit
81d50ca5dc
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,11 @@
|
||||
export enum DroneDetailString {
|
||||
id,
|
||||
high,
|
||||
speed,
|
||||
acceleration,
|
||||
direction,
|
||||
pitch,
|
||||
yaw,
|
||||
roll,
|
||||
mode
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.8",
|
||||
"uuid": "c5c4b503-049f-4e7f-813a-1eb3783da16b",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
export default class DetailPanelItem extends cc.Component {
|
||||
@property(cc.Label)
|
||||
keyLabel: cc.Label = null;
|
||||
|
||||
@property(cc.Label)
|
||||
valueLabel: cc.Label = null;
|
||||
|
||||
protected _keyName: string = '';
|
||||
|
||||
get keyName(): string {
|
||||
return this._keyName
|
||||
}
|
||||
|
||||
set keyName(key: string) {
|
||||
this._keyName = key
|
||||
}
|
||||
|
||||
setItemInfo(key: string, value: string) {
|
||||
this.keyLabel.string = key
|
||||
this.valueLabel.string = value
|
||||
this.keyName = key
|
||||
}
|
||||
|
||||
updateItemInfo(value: string) {
|
||||
this.valueLabel.string = value
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.8",
|
||||
"uuid": "b4ff3b44-c871-4c36-aeb8-00302cb49e7f",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
@ -0,0 +1,105 @@
|
||||
import { reaction } from "../Library/mobx/mobx";
|
||||
import BaseComp from "../external/BaseComp";
|
||||
import { CommonModel } from "./CommonModel";
|
||||
import { CustomToggleGroup } from "../external/CustomToggleGroup";
|
||||
import { CustomToggle } from "../external/CustomToggleItem";
|
||||
import { Drone_Event } from "../define/Event";
|
||||
import DetailPanelItem from "./DetailPanelItem";
|
||||
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
export default class InfoPageTabManager extends BaseComp {
|
||||
@property([cc.Node])
|
||||
pageContent: Array<cc.Node> = []
|
||||
|
||||
@property([CustomToggle])
|
||||
pageToggle: Array<CustomToggle> = [];
|
||||
|
||||
@property(cc.Prefab)
|
||||
detailPanelItemPrefab: cc.Prefab = null;
|
||||
1
|
||||
protected _nowDroneId: string = ''
|
||||
|
||||
set nowDroneId(id: string) {
|
||||
this._nowDroneId = id
|
||||
}
|
||||
|
||||
get nowDroneId(): string {
|
||||
return this._nowDroneId
|
||||
}
|
||||
onEnable() {
|
||||
super.onEnable()
|
||||
this.on(Drone_Event.DRONE_CLICK, this.onSingleDroneClick.bind(this))
|
||||
}
|
||||
|
||||
onDisable() {
|
||||
this.off(Drone_Event.DRONE_CLICK)
|
||||
super.onDisable();
|
||||
}
|
||||
|
||||
onSingleDroneClick(id: string) {
|
||||
this.nowDroneId = id
|
||||
this.setShowPageDetail()
|
||||
}
|
||||
|
||||
onTabChecked(customToggle: CustomToggle) {
|
||||
if (customToggle.isChecked) {
|
||||
const nowShowTabIndex = customToggle.checkEvents[0].customEventData
|
||||
const setDetailCase = {
|
||||
0: () => this.setFlyDroneInfo(),
|
||||
1: (_nowShowTabIndex: number) => this.setDroneValueInfo(_nowShowTabIndex),
|
||||
2: (_nowShowTabIndex: number) => this.setWeather(_nowShowTabIndex),
|
||||
3: () => this.setDroneCamera()
|
||||
}
|
||||
setDetailCase.hasOwnProperty(nowShowTabIndex) && setDetailCase[nowShowTabIndex](nowShowTabIndex)
|
||||
}
|
||||
}
|
||||
|
||||
setShowPageDetail() {
|
||||
let nowShowTabIndex = this.pageToggle.findIndex(toggle => toggle.isChecked);
|
||||
const setDetailCase = {
|
||||
0: () => this.setFlyDroneInfo(),
|
||||
1: (_nowShowTabIndex: number) => this.setDroneValueInfo(_nowShowTabIndex),
|
||||
2: (_nowShowTabIndex: number) => this.setWeather(_nowShowTabIndex),
|
||||
3: () => this.setDroneCamera()
|
||||
}
|
||||
setDetailCase.hasOwnProperty(nowShowTabIndex) && setDetailCase[nowShowTabIndex](nowShowTabIndex);
|
||||
}
|
||||
|
||||
setFlyDroneInfo() {
|
||||
// TO-DO
|
||||
}
|
||||
|
||||
setDroneValueInfo(nowShowTabIndex: number) {
|
||||
const targetContent = this.pageContent[nowShowTabIndex]
|
||||
const data = CommonModel.inst.droneDetailValue.find(detail => detail.id === this.nowDroneId)
|
||||
if (data) {
|
||||
Object.keys(data).forEach(idString => {
|
||||
if(idString !== 'id') {
|
||||
let item = targetContent.children.find( node => {
|
||||
return node?.getComponent(DetailPanelItem).keyName === idString
|
||||
})
|
||||
|
||||
if(item) {
|
||||
item.getComponent(DetailPanelItem).updateItemInfo(data[idString])
|
||||
} else {
|
||||
let node = cc.instantiate(this.detailPanelItemPrefab)
|
||||
let detailPanelItemComp = node.getComponent(DetailPanelItem)
|
||||
detailPanelItemComp.setItemInfo(idString, data[idString])
|
||||
node.parent = targetContent
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
setWeather(nowShowTabIndex: number) {
|
||||
// TO-DO
|
||||
}
|
||||
|
||||
setDroneCamera() {
|
||||
// TO-DO
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.8",
|
||||
"uuid": "bc79276c-6eb2-4ef8-b39d-6616d7223b0f",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
Loading…
Reference in New Issue