2022-05-14 20:51:48 +02:00
extends Control
const MAX_WIDTH = 1280
onready var margin_container = get_node ( " Panel/MarginContainer " )
func _ready ( ) :
# warning-ignore:return_value_discarded
Users . connect ( " switched " , self , " _on_user_switched " )
Users . emit_signal ( " switched " )
2022-06-04 13:33:00 +02:00
func _enter_tree ( ) :
Data . setup ( )
func _exit_tree ( ) :
Data . _save_data ( )
Data . messages . free ( )
Data . topics . free ( )
2022-05-14 20:51:48 +02:00
func _on_user_switched ( ) :
theme . get_stylebox ( " panel " , " Panel " ) . bg_color = Users . get_current ( ) . background_color
theme . get_stylebox ( " panel " , " PanelContainer " ) . bg_color = Users . get_current ( ) . panel_color
theme . get_stylebox ( " panel " , " PopupMenu " ) . bg_color = Users . get_current ( ) . popup_menu_color
theme . get_stylebox ( " grabber " , " VScrollBar " ) . bg_color = Users . get_current ( ) . scroll_bar_color
theme . get_stylebox ( " grabber_highlight " , " VScrollBar " ) . bg_color = Users . get_current ( ) . scroll_bar_highlight_color
theme . get_stylebox ( " grabber_pressed " , " VScrollBar " ) . bg_color = Users . get_current ( ) . scroll_bar_pressed_color
func _on_resized ( ) :
if ! margin_container :
return
var left_margin = theme . get_constant ( " margin_left " , " MarginContainer " )
var right_margin = theme . get_constant ( " margin_right " , " MarginContainer " )
var content_width = rect_size . x - left_margin - right_margin
if content_width > = MAX_WIDTH :
var difference = content_width - MAX_WIDTH
var additional_margin = 0.5 * difference
margin_container . add_constant_override (
" margin_left " , left_margin + additional_margin
)
margin_container . add_constant_override (
" margin_right " , right_margin + additional_margin
)
else :
margin_container . add_constant_override ( " margin_left " , left_margin )
margin_container . add_constant_override ( " margin_right " , right_margin )