immersive-home/app/content/ui/menu/view/view_menu.gd

92 lines
2.6 KiB
GDScript3
Raw Normal View History

2024-01-22 17:54:15 +02:00
extends Node3D
2024-05-22 19:38:28 +03:00
const Miniature = preload ("res://content/system/miniature/miniature.gd")
@onready var mini_view_button = $Content/MiniView
@onready var heat_map_button = $Content/HeatMap
@onready var humudity_map_button = $Content/HumidityMap
@onready var min_slider = $Content/MinSlider
@onready var max_slider = $Content/MaxSlider
@onready var opacity_slider = $Content/OpacitySlider
2024-01-22 17:54:15 +02:00
@onready var background = $Background
func _ready():
background.visible = false
2024-05-22 19:38:28 +03:00
if App.miniature.is_node_ready() == false:
await App.miniature.ready
mini_view_button.on_toggled.connect(func(active):
2024-05-22 19:38:28 +03:00
App.miniature.small.value=active
)
heat_map_button.on_toggled.connect(func(active):
if active == false:
2024-05-22 19:38:28 +03:00
if App.miniature.heatmap_type.value == Miniature.HeatmapType.TEMPERATURE:
App.miniature.heatmap_type.value=Miniature.HeatmapType.NONE
return
2024-05-22 19:38:28 +03:00
App.miniature.heatmap_type.value=Miniature.HeatmapType.TEMPERATURE
)
humudity_map_button.on_toggled.connect(func(active):
if active == false:
2024-05-22 19:38:28 +03:00
if App.miniature.heatmap_type.value == Miniature.HeatmapType.HUMIDITY:
App.miniature.heatmap_type.value=Miniature.HeatmapType.NONE
return
2024-05-22 19:38:28 +03:00
App.miniature.heatmap_type.value=Miniature.HeatmapType.HUMIDITY
)
R.effect(func(_arg):
2024-05-22 19:38:28 +03:00
heat_map_button.active=App.miniature.heatmap_type.value == Miniature.HeatmapType.TEMPERATURE
humudity_map_button.active=App.miniature.heatmap_type.value == Miniature.HeatmapType.HUMIDITY
)
min_slider.on_value_changed.connect(func(value):
2024-05-22 19:38:28 +03:00
if value >= App.miniature.selected_scale.value.y:
min_slider.value=App.miniature.selected_scale.value.y
return
2024-05-22 19:38:28 +03:00
App.miniature.selected_scale.value.x=value
)
max_slider.on_value_changed.connect(func(value):
2024-05-22 19:38:28 +03:00
if value <= App.miniature.selected_scale.value.x:
max_slider.value=App.miniature.selected_scale.value.x
return
2024-05-22 19:38:28 +03:00
App.miniature.selected_scale.value.y=value
)
R.effect(func(_arg):
2024-05-22 19:38:28 +03:00
min_slider.value=App.miniature.selected_scale.value.x
max_slider.value=App.miniature.selected_scale.value.y
2024-01-22 17:54:15 +02:00
)
# Update Slider
R.effect(func(_arg):
2024-05-22 19:38:28 +03:00
var minmax=App.miniature.get_base_scale()
min_slider.min=minmax.x
min_slider.max=minmax.y
max_slider.min=minmax.x
max_slider.max=minmax.y
2024-05-22 19:38:28 +03:00
var sensor_minmax=App.miniature.get_sensor_scale()
sensor_minmax.x=floor(sensor_minmax.x)
sensor_minmax.y=ceil(sensor_minmax.y)
2024-05-22 19:38:28 +03:00
App.miniature.selected_scale.value=sensor_minmax
min_slider.value=sensor_minmax.x
max_slider.value=sensor_minmax.y
2024-05-22 19:38:28 +03:00
var unit=App.miniature.get_sensor_unit()
min_slider.label_unit=unit
max_slider.label_unit=unit
)
2024-05-22 19:38:28 +03:00
R.bind(opacity_slider, "value", App.miniature.opacity, opacity_slider.on_value_changed)