diff --git a/assets/Prefabs/ItemPrefab.prefab b/assets/Prefabs/ItemPrefab.prefab index 4659696..01264ca 100644 --- a/assets/Prefabs/ItemPrefab.prefab +++ b/assets/Prefabs/ItemPrefab.prefab @@ -1068,12 +1068,15 @@ "nameLabel": { "__id__": 13 }, - "timeLabel": { - "__id__": 19 - }, "button": { "__id__": 7 }, + "ErrorButton": { + "__id__": 33 + }, + "ErrorNumber": { + "__id__": 26 + }, "_id": "" }, { diff --git a/assets/Scenes/scene.scene b/assets/Scenes/scene.scene index af567a6..60a95ce 100644 --- a/assets/Scenes/scene.scene +++ b/assets/Scenes/scene.scene @@ -29,19 +29,19 @@ "__id__": 182 }, { - "__id__": 370 + "__id__": 361 }, { - "__id__": 372 + "__id__": 363 }, { - "__id__": 374 + "__id__": 365 } ], "_active": true, "_components": [], "_prefab": { - "__id__": 375 + "__id__": 366 }, "_lpos": { "__type__": "cc.Vec3", @@ -72,7 +72,7 @@ }, "autoReleaseAssets": false, "_globals": { - "__id__": 376 + "__id__": 367 }, "_id": "955c22b7-7b7e-4af8-ad45-8415a0c23e60" }, @@ -6060,21 +6060,18 @@ }, { "__id__": 349 - }, - { - "__id__": 358 } ], "_active": true, "_components": [ { - "__id__": 367 + "__id__": 358 }, { - "__id__": 368 + "__id__": 359 }, { - "__id__": 369 + "__id__": 360 } ], "_prefab": null, @@ -6166,7 +6163,7 @@ "_priority": 1073741824, "_fov": 45, "_fovAxis": 0, - "_orthoHeight": 472.5233644859813, + "_orthoHeight": 360, "_near": 1, "_far": 2000, "_color": { @@ -7230,7 +7227,7 @@ "_lpos": { "__type__": "cc.Vec3", "x": 439.502, - "y": -191.435, + "y": -241.275, "z": 0 }, "_lrot": { @@ -7738,7 +7735,7 @@ "_string": "О1. Назначение оборудования\nДанное оборудование предназначено для высокоточной обработки металлических и неметаллических материалов в условиях промышленного производства. Оно может использоваться для фрезерования, сверления, резки и других технологических операций, что позволяет обеспечить высокую производительность и качество обработки деталей.\n\n2. Общее описание\nОборудование представляет собой многофункциональный станок с числовым программным управлением (ЧПУ), выполненный в прочном металлическом корпусе с защитными кожухами. Конструкция разработана с учетом требований к устойчивости, безопасности эксплуатации и удобству обслуживания. Благодаря современным технологиям автоматизации, система обеспечивает высокую точность и воспроизводимость операций даже при длительном цикле работы.\n\n3. Технические характеристики\n\n Мощность и энергоэффективность:\n Номинальная мощность двигателя – 15 кВт.\n Энергоэффективное управление и режимы энергосбережения обеспечивают снижение эксплуатационных затрат.\n Рабочее пространство:\n Рабочий стол с площадью до 1200×600 мм, что позволяет обрабатывать крупногабаритные заготовки.\n Скоростной режим:\n Максимальная скорость вращения шпинделя до 12 000 об/мин, что способствует высокой точности обработки.", "_horizontalAlign": 0, "_verticalAlign": 0, - "_actualFontSize": 17.5546875, + "_actualFontSize": 23.041666666666664, "_fontSize": 12, "_fontFamily": "Ubuntu", "_lineHeight": 14.8, @@ -8478,7 +8475,7 @@ "_string": "Описание", "_horizontalAlign": 1, "_verticalAlign": 1, - "_actualFontSize": 29.2578125, + "_actualFontSize": 38.40277777777778, "_fontSize": 20, "_fontFamily": "Arial", "_lineHeight": 20, @@ -8793,7 +8790,7 @@ "_string": "Оперативное", "_horizontalAlign": 1, "_verticalAlign": 1, - "_actualFontSize": 29.2578125, + "_actualFontSize": 38.40277777777778, "_fontSize": 20, "_fontFamily": "Arial", "_lineHeight": 20, @@ -10138,7 +10135,7 @@ "_lpos": { "__type__": "cc.Vec3", "x": -26.205, - "y": 269.981, + "y": 269, "z": 0 }, "_lrot": { @@ -10176,7 +10173,7 @@ "__prefab": null, "_contentSize": { "__type__": "cc.Size", - "width": 185.92852970627504, + "width": 185.98346024525316, "height": 25.2 }, "_anchorPoint": { @@ -10209,7 +10206,7 @@ "_string": "Список оборудования", "_horizontalAlign": 1, "_verticalAlign": 1, - "_actualFontSize": 24.869140625, + "_actualFontSize": 32.64236111111111, "_fontSize": 17, "_fontFamily": "Arial", "_lineHeight": 20, @@ -10866,8 +10863,8 @@ "_prefab": null, "_lpos": { "__type__": "cc.Vec3", - "x": 1158, - "y": 491.463, + "x": 1159.774, + "y": 494.282, "z": 0 }, "_lrot": { @@ -11073,7 +11070,7 @@ "_contentSize": { "__type__": "cc.Size", "width": 12, - "height": 320 + "height": 450 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -11201,7 +11198,7 @@ "_lpos": { "__type__": "cc.Vec3", "x": 0, - "y": -30, + "y": -32.884, "z": 0 }, "_lrot": { @@ -11336,8 +11333,8 @@ "__prefab": null, "_contentSize": { "__type__": "cc.Size", - "width": 131.29300525700936, - "height": 25.2 + "width": 131.31855097903482, + "height": 25.200000000000003 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -11369,7 +11366,7 @@ "_string": "ScrollView content", "_horizontalAlign": 0, "_verticalAlign": 0, - "_actualFontSize": 23.40625, + "_actualFontSize": 30.72222222222222, "_fontSize": 16, "_fontFamily": "Arial", "_lineHeight": 20, @@ -11443,7 +11440,7 @@ "_contentSize": { "__type__": "cc.Size", "width": 240, - "height": 250 + "height": 370 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -11529,8 +11526,8 @@ "_prefab": null, "_lpos": { "__type__": "cc.Vec3", - "x": -5, - "y": 132.423, + "x": 3.21, + "y": 177.048, "z": 0 }, "_lrot": { @@ -11569,7 +11566,7 @@ "_contentSize": { "__type__": "cc.Size", "width": 200, - "height": 50.4 + "height": 60 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -11601,10 +11598,10 @@ "_string": "Список всех аварий", "_horizontalAlign": 1, "_verticalAlign": 1, - "_actualFontSize": 26.33203125, - "_fontSize": 18, + "_actualFontSize": 26.881944444444443, + "_fontSize": 14, "_fontFamily": "Arial", - "_lineHeight": 20, + "_lineHeight": 16, "_overflow": 1, "_enableWrapText": true, "_font": { @@ -11656,7 +11653,7 @@ "_contentSize": { "__type__": "cc.Size", "width": 240, - "height": 320 + "height": 450 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -11887,7 +11884,7 @@ "_prefab": null, "_lpos": { "__type__": "cc.Vec3", - "x": 1157.264, + "x": 978.842, "y": 673.481, "z": 0 }, @@ -12200,7 +12197,7 @@ "_string": "button", "_horizontalAlign": 1, "_verticalAlign": 1, - "_actualFontSize": 29.2578125, + "_actualFontSize": 38.40277777777778, "_fontSize": 20, "_fontFamily": "Arial", "_lineHeight": 40, @@ -12329,7 +12326,7 @@ }, { "__type__": "cc.Node", - "_name": "FilterTestButton", + "_name": "ResetFilterTestButton", "_objFlags": 0, "__editorExtras__": {}, "_parent": { @@ -12358,8 +12355,8 @@ "_prefab": null, "_lpos": { "__type__": "cc.Vec3", - "x": 229.025, - "y": 189.172, + "x": 228.886, + "y": 143.799, "z": 0 }, "_lrot": { @@ -12383,7 +12380,7 @@ "y": 0, "z": 0 }, - "_id": "83sgIokiFBk7wkeaoWR+He" + "_id": "6cMwTS6O5DpbcB0MgY0WNV" }, { "__type__": "cc.Node", @@ -12431,7 +12428,7 @@ "y": 0, "z": 0 }, - "_id": "40qF6uAspJM6Ovua0JsSV2" + "_id": "f55kgU1FZJCbKi4eHxaiRb" }, { "__type__": "cc.UITransform", @@ -12445,7 +12442,7 @@ "__prefab": null, "_contentSize": { "__type__": "cc.Size", - "width": 100, + "width": 200, "height": 40 }, "_anchorPoint": { @@ -12453,7 +12450,7 @@ "x": 0.5, "y": 0.5 }, - "_id": "32ylU8qWlPTaoYigYj2dSn" + "_id": "02xvRQrodN17yRWf5j4Ged" }, { "__type__": "cc.Label", @@ -12475,10 +12472,10 @@ "b": 0, "a": 255 }, - "_string": "Фильтр", + "_string": "Сброс Фильтра", "_horizontalAlign": 1, "_verticalAlign": 1, - "_actualFontSize": 29.2578125, + "_actualFontSize": 38.40277777777778, "_fontSize": 20, "_fontFamily": "Arial", "_lineHeight": 40, @@ -12515,7 +12512,7 @@ "y": 2 }, "_shadowBlur": 2, - "_id": "75N/WzIFtCa4BM1Z2T6ICl" + "_id": "2c7/I9rNRD8JNJA4H0VVAI" }, { "__type__": "cc.UITransform", @@ -12529,7 +12526,7 @@ "__prefab": null, "_contentSize": { "__type__": "cc.Size", - "width": 100, + "width": 200, "height": 40 }, "_anchorPoint": { @@ -12537,7 +12534,7 @@ "x": 0.5, "y": 0.5 }, - "_id": "b5RwhGtOtIKL/GMt9YWUgV" + "_id": "2cPYw1Px1Aerh2lH9nozjE" }, { "__type__": "cc.Sprite", @@ -12576,7 +12573,7 @@ "_isTrimmedMode": true, "_useGrayscale": false, "_atlas": null, - "_id": "38ozS7YddKsJtWsyO9KZDl" + "_id": "0boPCu5kVHLretOoam7Gbn" }, { "__type__": "cc.Button", @@ -12644,356 +12641,12 @@ "_target": { "__id__": 349 }, - "_id": "0dFqnUHZBE+5WOPV2tTzE+" - }, - { - "__type__": "cc.ClickEvent", - "target": { - "__id__": 349 - }, - "component": "", - "_componentId": "1cb33l9KXNOPIiY+PBp7vtc", - "handler": "onButtonClick", - "customEventData": "" - }, - { - "__type__": "1cb33l9KXNOPIiY+PBp7vtc", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 349 - }, - "_enabled": true, - "__prefab": null, - "errorListNode": { - "__id__": 305 - }, - "_id": "8ez2FYn/1E64Zl+wE4mJRG" - }, - { - "__type__": "cc.Node", - "_name": "ResetFilterTestButton", - "_objFlags": 0, - "__editorExtras__": {}, - "_parent": { - "__id__": 182 - }, - "_children": [ - { - "__id__": 359 - } - ], - "_active": true, - "_components": [ - { - "__id__": 362 - }, - { - "__id__": 363 - }, - { - "__id__": 364 - }, - { - "__id__": 366 - } - ], - "_prefab": null, - "_lpos": { - "__type__": "cc.Vec3", - "x": 228.886, - "y": 143.799, - "z": 0 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": 0, - "y": 0, - "z": 0, - "w": 1 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 1, - "y": 1, - "z": 1 - }, - "_mobility": 0, - "_layer": 33554432, - "_euler": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_id": "6cMwTS6O5DpbcB0MgY0WNV" - }, - { - "__type__": "cc.Node", - "_name": "Label", - "_objFlags": 512, - "__editorExtras__": {}, - "_parent": { - "__id__": 358 - }, - "_children": [], - "_active": true, - "_components": [ - { - "__id__": 360 - }, - { - "__id__": 361 - } - ], - "_prefab": null, - "_lpos": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": 0, - "y": 0, - "z": 0, - "w": 1 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 1, - "y": 1, - "z": 1 - }, - "_mobility": 0, - "_layer": 33554432, - "_euler": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_id": "f55kgU1FZJCbKi4eHxaiRb" - }, - { - "__type__": "cc.UITransform", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 359 - }, - "_enabled": true, - "__prefab": null, - "_contentSize": { - "__type__": "cc.Size", - "width": 200, - "height": 40 - }, - "_anchorPoint": { - "__type__": "cc.Vec2", - "x": 0.5, - "y": 0.5 - }, - "_id": "02xvRQrodN17yRWf5j4Ged" - }, - { - "__type__": "cc.Label", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 359 - }, - "_enabled": true, - "__prefab": null, - "_customMaterial": null, - "_srcBlendFactor": 2, - "_dstBlendFactor": 4, - "_color": { - "__type__": "cc.Color", - "r": 0, - "g": 0, - "b": 0, - "a": 255 - }, - "_string": "Сброс Фильтра", - "_horizontalAlign": 1, - "_verticalAlign": 1, - "_actualFontSize": 29.2578125, - "_fontSize": 20, - "_fontFamily": "Arial", - "_lineHeight": 40, - "_overflow": 1, - "_enableWrapText": false, - "_font": null, - "_isSystemFontUsed": true, - "_spacingX": 0, - "_isItalic": false, - "_isBold": false, - "_isUnderline": false, - "_underlineHeight": 2, - "_cacheMode": 0, - "_enableOutline": false, - "_outlineColor": { - "__type__": "cc.Color", - "r": 0, - "g": 0, - "b": 0, - "a": 255 - }, - "_outlineWidth": 2, - "_enableShadow": false, - "_shadowColor": { - "__type__": "cc.Color", - "r": 0, - "g": 0, - "b": 0, - "a": 255 - }, - "_shadowOffset": { - "__type__": "cc.Vec2", - "x": 2, - "y": 2 - }, - "_shadowBlur": 2, - "_id": "2c7/I9rNRD8JNJA4H0VVAI" - }, - { - "__type__": "cc.UITransform", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 358 - }, - "_enabled": true, - "__prefab": null, - "_contentSize": { - "__type__": "cc.Size", - "width": 200, - "height": 40 - }, - "_anchorPoint": { - "__type__": "cc.Vec2", - "x": 0.5, - "y": 0.5 - }, - "_id": "2cPYw1Px1Aerh2lH9nozjE" - }, - { - "__type__": "cc.Sprite", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 358 - }, - "_enabled": true, - "__prefab": null, - "_customMaterial": null, - "_srcBlendFactor": 2, - "_dstBlendFactor": 4, - "_color": { - "__type__": "cc.Color", - "r": 255, - "g": 255, - "b": 255, - "a": 255 - }, - "_spriteFrame": { - "__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@f9941", - "__expectedType__": "cc.SpriteFrame" - }, - "_type": 1, - "_fillType": 0, - "_sizeMode": 0, - "_fillCenter": { - "__type__": "cc.Vec2", - "x": 0, - "y": 0 - }, - "_fillStart": 0, - "_fillRange": 0, - "_isTrimmedMode": true, - "_useGrayscale": false, - "_atlas": null, - "_id": "0boPCu5kVHLretOoam7Gbn" - }, - { - "__type__": "cc.Button", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 358 - }, - "_enabled": true, - "__prefab": null, - "clickEvents": [ - { - "__id__": 365 - } - ], - "_interactable": true, - "_transition": 2, - "_normalColor": { - "__type__": "cc.Color", - "r": 214, - "g": 214, - "b": 214, - "a": 255 - }, - "_hoverColor": { - "__type__": "cc.Color", - "r": 211, - "g": 211, - "b": 211, - "a": 255 - }, - "_pressedColor": { - "__type__": "cc.Color", - "r": 255, - "g": 255, - "b": 255, - "a": 255 - }, - "_disabledColor": { - "__type__": "cc.Color", - "r": 124, - "g": 124, - "b": 124, - "a": 255 - }, - "_normalSprite": { - "__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@f9941", - "__expectedType__": "cc.SpriteFrame" - }, - "_hoverSprite": { - "__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@f9941", - "__expectedType__": "cc.SpriteFrame" - }, - "_pressedSprite": { - "__uuid__": "544e49d6-3f05-4fa8-9a9e-091f98fc2ce8@f9941", - "__expectedType__": "cc.SpriteFrame" - }, - "_disabledSprite": { - "__uuid__": "951249e0-9f16-456d-8b85-a6ca954da16b@f9941", - "__expectedType__": "cc.SpriteFrame" - }, - "_duration": 0.1, - "_zoomScale": 1.2, - "_target": { - "__id__": 358 - }, "_id": "33SFmTof9KuIMvxa16+Mnb" }, { "__type__": "cc.ClickEvent", "target": { - "__id__": 358 + "__id__": 349 }, "component": "", "_componentId": "1cb33l9KXNOPIiY+PBp7vtc", @@ -13006,7 +12659,7 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 358 + "__id__": 349 }, "_enabled": true, "__prefab": null, @@ -13095,7 +12748,7 @@ "_active": true, "_components": [ { - "__id__": 371 + "__id__": 362 } ], "_prefab": null, @@ -13134,7 +12787,7 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 370 + "__id__": 361 }, "_enabled": true, "__prefab": null, @@ -13163,7 +12816,7 @@ "_active": true, "_components": [ { - "__id__": 373 + "__id__": 364 } ], "_prefab": null, @@ -13202,7 +12855,7 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 372 + "__id__": 363 }, "_enabled": true, "__prefab": null, @@ -13261,28 +12914,28 @@ { "__type__": "cc.SceneGlobals", "ambient": { - "__id__": 377 + "__id__": 368 }, "shadows": { - "__id__": 378 + "__id__": 369 }, "_skybox": { - "__id__": 379 + "__id__": 370 }, "fog": { - "__id__": 380 + "__id__": 371 }, "octree": { - "__id__": 381 + "__id__": 372 }, "skin": { - "__id__": 382 + "__id__": 373 }, "lightProbeInfo": { - "__id__": 383 + "__id__": 374 }, "postSettings": { - "__id__": 384 + "__id__": 375 }, "bakedWithStationaryMainLight": false, "bakedWithHighpLightmap": false diff --git a/assets/Scripts/ui/ErrorLazyLoadList.ts b/assets/Scripts/ui/ErrorLazyLoadList.ts index 04487b5..0e1778d 100644 --- a/assets/Scripts/ui/ErrorLazyLoadList.ts +++ b/assets/Scripts/ui/ErrorLazyLoadList.ts @@ -7,6 +7,8 @@ const { ccclass, property } = _decorator; @ccclass("ErrorLazyLoadList") export class ErrorLazyLoadList extends Component { + // Добавляем синглтон + public static instance: ErrorLazyLoadList | null = null; @property(Prefab) public errorItemPrefab: Prefab = null!; @@ -34,13 +36,14 @@ export class ErrorLazyLoadList extends Component { private _content: Node = null!; private _contentUI: UITransform = null!; - onLoad() { + onLoad() { + // Назначаем синглтон + ErrorLazyLoadList.instance = this; + if (!this.scrollView.content) { console.error("ScrollView.content is null!"); return; } - // Начальный заголовок можно задать здесь - // Приводим content к типу Node, импортированному из 'cc' this._content = this.scrollView.content; this._contentUI = this._content.getComponent(UITransform)!; if (!this._contentUI) { @@ -62,6 +65,12 @@ export class ErrorLazyLoadList extends Component { this.waitForErrorManager(); } + onDestroy() { + if (ErrorLazyLoadList.instance === this) { + ErrorLazyLoadList.instance = null; + } + } + private waitForErrorManager() { if (!ErrorManager.instance) { console.warn("ErrorManager.instance not found, retrying..."); @@ -85,9 +94,7 @@ export class ErrorLazyLoadList extends Component { }); } } - // Сохраняем полные данные this._data = flattened; - // Если фильтр не активирован, используем все данные if (!this._filteredData) { this._totalCount = this._data.length; this._loadedCount = 0; @@ -104,7 +111,6 @@ export class ErrorLazyLoadList extends Component { const endIndex = Math.min(this._loadedCount + batchSize, currentData.length); for (let i = startIndex; i < endIndex; i++) { let item: Node; - // Если фильтрация активна, используем другой префаб и соответствующий компонент if (this._filteredData) { item = instantiate(this.errorItemNamedPrefab); const errorItemNamedButton = item.getComponent("ErrorItemNamedButton") as unknown as ErrorItemNamedButton; @@ -128,20 +134,6 @@ export class ErrorLazyLoadList extends Component { this._loadedCount = endIndex; this._contentUI.height = currentData.length * (this._itemHeight + this.spacing) + this.spacing; } - - - update(dt: number) { - if (!this.scrollView.content) return; - const threshold = 50; - const visibleHeight = this.scrollView.node.getComponent(UITransform)!.height; - const offset = Math.abs(this.scrollView.content.position.y); - const currentData = this._filteredData || this._data; - if (offset >= (this._contentUI.height - visibleHeight - threshold)) { - if (this._loadedCount < currentData.length) { - this.loadNextBatch(20); - } - } - } /** * Фильтрует список по имени оборудования. diff --git a/assets/Scripts/ux/ItemButton.ts b/assets/Scripts/ux/ItemButton.ts index 183b4c3..aee9b5e 100644 --- a/assets/Scripts/ux/ItemButton.ts +++ b/assets/Scripts/ux/ItemButton.ts @@ -1,9 +1,10 @@ -// ItemButton.ts import { _decorator, Component, Label, Button, Node, Event } from 'cc'; import { apiSensors } from '../stores/apiSensors'; import { EquipmentManager } from '../stores/EquipmentManager'; import { PulsatingHighlighter } from '../PulsatingHighlighter'; import { CameraMover } from '../CameraMover'; +import { ErrorLazyLoadList } from '../ui/ErrorLazyLoadList'; + const { ccclass, property } = _decorator; @@ -12,13 +13,18 @@ export class ItemButton extends Component { @property(Label) public nameLabel: Label | null = null; - @property(Label) - public timeLabel: Label | null = null; - @property(Button) public button: Button | null = null; - // Индекс элемента, если требуется + // Кнопка для запуска фильтрации ошибок + @property(Button) + public ErrorButton: Button | null = null; + + // Свойство для вывода количества ошибок на оборудовании + @property(Label) + public ErrorNumber: Label | null = null; + + // Индекс элемента (если требуется) public itemIndex: number = 0; private itemData: apiSensors | null = null; @@ -28,32 +34,31 @@ export class ItemButton extends Component { if (this.nameLabel) { this.nameLabel.string = data.name; } - if (this.timeLabel) { - this.timeLabel.string = data.connect_time; - } } onLoad() { - // Назначаем обработчик на кнопку, а не на весь префаб if (this.button) { this.button.node.on('click', this.onClick, this); } else { console.warn('Компонент Button не назначен в ItemButton.'); } + + if (this.ErrorButton) { + this.ErrorButton.node.on('click', this.onErrorClick, this); + } else { + console.warn('Компонент ErrorButton не назначен в ItemButton.'); + } } onDestroy() { if (this.button) { this.button.node.off('click', this.onClick, this); } + if (this.ErrorButton) { + this.ErrorButton.node.off('click', this.onErrorClick, this); + } } - /** - * Рекурсивный поиск узла по имени. - * @param root Корневой узел для поиска. - * @param name Имя, которое нужно найти. - * @returns Найденный узел или null. - */ private _findNodeByName(root: Node, name: string): Node | null { if (root.name === name) return root; for (let i = 0; i < root.children.length; i++) { @@ -64,16 +69,14 @@ export class ItemButton extends Component { } public onClick(event?: Event) { - console.log('Нажата кнопка для элемента:', this.itemData); + console.log('Нажата основная кнопка для элемента:', this.itemData); if (!this.itemData) return; - // Проверяем наличие EquipmentManager if (!EquipmentManager.instance) { console.warn('EquipmentManager не доступен!'); return; } - // Находим датчик в списке оборудования по имени const sensors = EquipmentManager.instance.dataList; const sensorData = sensors.find(s => s.name === this.itemData!.name); if (!sensorData) { @@ -81,7 +84,6 @@ export class ItemButton extends Component { return; } - // Определяем цвет подсветки по значению датчика let color = ""; if (sensorData.value === 2) { color = "red"; @@ -94,21 +96,18 @@ export class ItemButton extends Component { return; } - // Получаем корневой узел сцены const scene = this.node.scene; if (!scene) { console.warn('Сцена не найдена!'); return; } - // Ищем узел с таким же именем, как у датчика const targetNode = this._findNodeByName(scene, this.itemData.name); if (!targetNode) { console.warn(`Узел с именем ${this.itemData.name} не найден в сцене.`); return; } - // Если у найденного узла есть компонент PulsatingHighlighter, запускаем подсветку const highlighter = targetNode.getComponent(PulsatingHighlighter); if (highlighter) { highlighter.switchToColor(color); @@ -116,7 +115,6 @@ export class ItemButton extends Component { console.warn(`Узел ${this.itemData.name} не содержит PulsatingHighlighter.`); } - // Находим в сцене компонент CameraMover и перемещаем камеру к выбранному узлу const cameraMover = scene.getComponentInChildren(CameraMover); if (cameraMover) { cameraMover.moveToTarget(targetNode); @@ -124,4 +122,16 @@ export class ItemButton extends Component { console.warn('CameraMover не найден в сцене!'); } } + + public onErrorClick(event?: Event) { + console.log('Нажата кнопка Error для элемента:', this.itemData); + if (!this.itemData) return; + + // Используем статическую переменную ErrorLazyLoadList.instance + if (!ErrorLazyLoadList.instance) { + console.warn('ErrorLazyLoadList.instance не найден!'); + return; + } + ErrorLazyLoadList.instance.filterBySensor(this.itemData.name); + } }