diff --git a/assets/Prefabs/SensorFieldItem.prefab b/assets/Prefabs/SensorFieldItem.prefab index fccec7e..0a38f9c 100644 --- a/assets/Prefabs/SensorFieldItem.prefab +++ b/assets/Prefabs/SensorFieldItem.prefab @@ -175,7 +175,7 @@ "_string": "датчик оборотов погружного насоса", "_horizontalAlign": 1, "_verticalAlign": 1, - "_actualFontSize": 21.754687500000003, + "_actualFontSize": 15.5625, "_fontSize": 12, "_fontFamily": "Arial", "_lineHeight": 16, @@ -391,7 +391,7 @@ "_string": "км/ч", "_horizontalAlign": 1, "_verticalAlign": 1, - "_actualFontSize": 14, + "_actualFontSize": 12, "_fontSize": 14, "_fontFamily": "Arial", "_lineHeight": 29, @@ -753,10 +753,10 @@ "b": 0, "a": 255 }, - "_string": "", + "_string": "расширяемый текст описания", "_horizontalAlign": 1, "_verticalAlign": 1, - "_actualFontSize": 21.754687500000003, + "_actualFontSize": 15.5625, "_fontSize": 12, "_fontFamily": "Arial", "_lineHeight": 15, diff --git a/assets/Scenes/scene.scene b/assets/Scenes/scene.scene index ec76e81..8fda9f2 100644 --- a/assets/Scenes/scene.scene +++ b/assets/Scenes/scene.scene @@ -6157,7 +6157,7 @@ "_priority": 1073741824, "_fov": 45, "_fovAxis": 0, - "_orthoHeight": 381.2971342383107, + "_orthoHeight": 363.1807228915663, "_near": 1, "_far": 2000, "_color": { @@ -9633,7 +9633,7 @@ "__prefab": null, "_contentSize": { "__type__": "cc.Size", - "width": 185.9417589151045, + "width": 185.9389236634036, "height": 25.2 }, "_anchorPoint": { @@ -9666,7 +9666,7 @@ "_string": "Список оборудования", "_horizontalAlign": 1, "_verticalAlign": 1, - "_actualFontSize": 30.819140625000003, + "_actualFontSize": 22.046875, "_fontSize": 17, "_fontFamily": "Arial", "_lineHeight": 20, @@ -10395,7 +10395,7 @@ "_string": "Список всех аварий", "_horizontalAlign": 1, "_verticalAlign": 1, - "_actualFontSize": 25.380468750000002, + "_actualFontSize": 18.15625, "_fontSize": 14, "_fontFamily": "Arial", "_lineHeight": 16, @@ -10956,7 +10956,7 @@ "_string": "button", "_horizontalAlign": 1, "_verticalAlign": 1, - "_actualFontSize": 36.2578125, + "_actualFontSize": 25.9375, "_fontSize": 20, "_fontFamily": "Arial", "_lineHeight": 40, @@ -11264,7 +11264,7 @@ "__prefab": null, "_contentSize": { "__type__": "cc.Size", - "width": 131.29982762335703, + "width": 131.328125, "height": 25.2 }, "_anchorPoint": { @@ -11297,7 +11297,7 @@ "_string": "ScrollView content", "_horizontalAlign": 0, "_verticalAlign": 0, - "_actualFontSize": 29.00625, + "_actualFontSize": 20.75, "_fontSize": 16, "_fontFamily": "Arial", "_lineHeight": 20, diff --git a/assets/Scripts/stores/SensorDetailManager.ts b/assets/Scripts/stores/SensorDetailManager.ts index d72c1b5..0356e17 100644 --- a/assets/Scripts/stores/SensorDetailManager.ts +++ b/assets/Scripts/stores/SensorDetailManager.ts @@ -1,67 +1,79 @@ import { _decorator, Component, Node } from 'cc'; import { SensorDetailStore } from './SensorDetailStore'; -import { SensorDescriptionField } from './SensorDescriptionField'; import { ErrorLazyLoadList } from '../ui/ErrorLazyLoadList'; const { ccclass } = _decorator; @ccclass('SensorDetailManager') export class SensorDetailManager extends Component { private currentSensorName: string = ""; - + onLoad() { - // Подписываемся на событие выбора оборудования (например, от EquipmentManager) const equipmentManagerNode = this.node.scene.getChildByName('EquipmentManager'); if (equipmentManagerNode) { equipmentManagerNode.on('showSensorDetails', this.onShowSensorDetails, this); } } - + /** - * Обработчик события показа деталей датчика. - * Получает имя датчика, запрашивает данные и передаёт их компоненту, который отрисовывает список. - * @param sensorName Имя выбранного датчика/оборудования. - */ + * Обработчик события показа деталей датчика. + * Получает имя датчика, запрашивает данные и передаёт их компоненту, который отрисовывает список. + * @param sensorName Имя выбранного датчика/оборудования. + */ public onShowSensorDetails(sensorName: string) { + if (this.currentSensorName === sensorName && ErrorLazyLoadList.instance?.mode === 'details') { + // Если датчик не изменился и уже отображаем details, то ничего не делаем + return; + } + this.currentSensorName = sensorName; - // Запрашиваем детали через SensorDetailStore + + this.unschedule(this.updateSensorDetails); + SensorDetailStore.getInstance().fetchSensorDetails(sensorName) .then(data => { - if (data) { - // Передаём полученные данные в ErrorLazyLoadList для отрисовки - if (ErrorLazyLoadList.instance) { - ErrorLazyLoadList.instance.showSensorDetails(data); - } else { - console.warn("ErrorLazyLoadList.instance не найден!"); - } + if (data && ErrorLazyLoadList.instance) { + ErrorLazyLoadList.instance.showSensorDetails(data); } }); - // Если панель деталей была скрыта, делаем её активной + + if (this.node.active) { + this.schedule(this.updateSensorDetails, 5); + } + this.node.active = true; } - - // Включение периодического обновления при активации объекта (например, когда панель отображается) + + onEnable() { if (this.currentSensorName) { - this.schedule(this.updateSensorDetails, 10); + // Убедимся, что обновление не запускается дважды + this.unschedule(this.updateSensorDetails); + this.schedule(this.updateSensorDetails, 5); } } - - // Отключение обновлений при скрытии объекта (панель закрыта) + onDisable() { this.unschedule(this.updateSensorDetails); } - + + /** * Периодическое обновление данных датчика (если активно). * Получает обновлённые данные и передаёт их в ErrorLazyLoadList для перерисовки. */ private updateSensorDetails() { if (!this.currentSensorName) return; - SensorDetailStore.getInstance().fetchSensorDetails(this.currentSensorName) + + SensorDetailStore.getInstance() + .fetchSensorDetails(this.currentSensorName) .then(data => { if (data && ErrorLazyLoadList.instance) { - ErrorLazyLoadList.instance.showSensorDetails(data); + // Проверяем текущий режим перед обновлением + if (ErrorLazyLoadList.instance.mode === "details") { + ErrorLazyLoadList.instance.showSensorDetails(data); + } } }); } -} + +} \ No newline at end of file diff --git a/assets/Scripts/ui/ErrorLazyLoadList.ts b/assets/Scripts/ui/ErrorLazyLoadList.ts index 105640f..e1e91a2 100644 --- a/assets/Scripts/ui/ErrorLazyLoadList.ts +++ b/assets/Scripts/ui/ErrorLazyLoadList.ts @@ -47,6 +47,14 @@ export class ErrorLazyLoadList extends Component { private _itemHeight: number = 0; private _content: Node = null!; private _contentUI: UITransform = null!; + + /** + * для получения сведений о текущем режиме отображения + */ + public get mode(): "errors" | "details" { + return this._mode; + } + onLoad() { // Назначаем синглтон diff --git a/assets/Scripts/ux/ItemButton.ts b/assets/Scripts/ux/ItemButton.ts index d097870..272d430 100644 --- a/assets/Scripts/ux/ItemButton.ts +++ b/assets/Scripts/ux/ItemButton.ts @@ -108,6 +108,16 @@ export class ItemButton extends Component { console.warn("EquipmentManager не доступен!"); return; } + // Проверяем состояние списка через синглтон ToggleListButton + if (ToggleListButton.instance) { + // Если список выключен, включаем его + if (!ToggleListButton.instance.equipmentList.active) { + ToggleListButton.instance.toggleList(); + + } + } else { + console.warn("ToggleListButton.instance не инициализирован!"); + } const sensors = EquipmentManager.instance.dataList; const sensorData = sensors.find((s) => s.name === this.itemData.name); @@ -199,6 +209,8 @@ export class ItemButton extends Component { } } + + /** * Обновление состояния ошибки на кнопке в зависимости от данных оборудования. */ diff --git a/assets/Shaders.meta b/assets/Shaders.meta new file mode 100644 index 0000000..0417915 --- /dev/null +++ b/assets/Shaders.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.2.0", + "importer": "directory", + "imported": true, + "uuid": "81006b3c-7bc0-44a2-8399-ac9566d14eaa", + "files": [], + "subMetas": {}, + "userData": {} +}