| | |
| | | } |
| | | }, [app, mapContainer, windowSize]) |
| | | |
| | | // model |
| | | React.useEffect(() => { |
| | | if (!mapContainer && !dataFetched) { |
| | | return; |
| | | } |
| | | // fn switch model |
| | | const switchModel = (model) => { |
| | | Utils.removeSelectedEffect(); |
| | | |
| | | setCurSPrite(null); |
| | | setDrawerVisible(false); |
| | | setSpriteBySettings(null); |
| | | setSettingsVisible(false); |
| | | |
| | | switch (model) { |
| | | case MapModel.OBSERVER_MODEL: |
| | | |
| | | player.hideGridlines(); |
| | | player.hideStarryBackground(); |
| | | |
| | | player.activateMapEvent(null); |
| | | |
| | | Utils.removeSelectedEffect(); |
| | | setCurSPrite(null); |
| | | setDeviceVisible(false); |
| | | setSettingsVisible(false); |
| | | |
| | | |
| | | mapContainer.children.forEach(child => { |
| | | Utils.viewFeature(child, setCurSPrite); |
| | | }) |
| | | break |
| | | case MapModel.MOVABLE_MODEL: |
| | | |
| | | player.showGridlines(); |
| | | player.hideStarryBackground(); |
| | | |
| | | player.activateMapEvent(Utils.MapEvent.SELECTION_BOX, model); |
| | | |
| | | Utils.removeSelectedEffect(); |
| | | setSpriteBySettings(null); |
| | | setSettingsVisible(false); |
| | | setDrawerVisible(false); |
| | | |
| | | mapContainer.children.forEach(child => { |
| | | Utils.beMovable(child, setDidClickSprite); |
| | | }) |
| | | break |
| | | case MapModel.SETTINGS_MODEL: |
| | | |
| | | player.showGridlines(); |
| | | player.showStarryBackground(); |
| | | |
| | | player.activateMapEvent(Utils.MapEvent.SELECTION_BOX, model); |
| | | |
| | | setDeviceVisible(false); |
| | | setDrawerVisible(false); |
| | | |
| | | mapContainer.children.forEach(child => { |
| | | Utils.beSettings(child, setSpriteBySettings); |
| | |
| | | default: |
| | | break |
| | | } |
| | | } |
| | | |
| | | // model |
| | | React.useEffect(() => { |
| | | if (!mapContainer && !dataFetched) { |
| | | return; |
| | | } |
| | | switchModel(model); |
| | | }, [model]); |
| | | |
| | | // Add New Device |
| | |
| | | const switchFloor = async (floor) => { |
| | | await Utils.fetchMapData(floor); |
| | | |
| | | Utils.removeSelectedEffect(); |
| | | |
| | | setCurSPrite(null); |
| | | setDrawerVisible(false); |
| | | setSpriteBySettings(null); |
| | | setSettingsVisible(false); |
| | | |
| | | mapContainer.children.forEach(child => { |
| | | Utils.viewFeature(child, setCurSPrite); |
| | | }) |
| | | switchModel(model); |
| | | |
| | | setTimeout(() => { |
| | | player.adaptScreen(); |
| | |
| | | if (deviceVisible) { |
| | | setDeviceVisible(false); |
| | | } else { |
| | | setDeviceVisible(true); |
| | | setModel(MapModel.MOVABLE_MODEL); |
| | | setDeviceVisible(true); |
| | | } |
| | | }} |
| | | /> |