You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
	
	
		
			
				
					
						
							|  |  |  | extends Node3D | 
					
						
							|  |  |  | class_name UIManager | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @onready var ui_map: Dictionary = {"hud": $HudScreen, "status": $StatusScreen, "menu": $MenuScreen } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var pause_count: int = 0 | 
					
						
							|  |  |  | var top_ui_screen: Node | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func _ready(): | 
					
						
							|  |  |  | 	Global.ui_mgr = self | 
					
						
							|  |  |  | 	close_all() | 
					
						
							|  |  |  | 	open("hud") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func input_action(key: String, is_pressed: bool): | 
					
						
							|  |  |  | 	if top_ui_screen: | 
					
						
							|  |  |  | 		top_ui_screen.call("input_action", key, is_pressed) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func input_dir(dir: Vector2): | 
					
						
							|  |  |  | 	if top_ui_screen: | 
					
						
							|  |  |  | 		top_ui_screen.call("input_dir", dir) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func open(ui_name: String): | 
					
						
							|  |  |  | 	set_ui_visible(ui_name, true) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func close(ui_name: String): | 
					
						
							|  |  |  | 	set_ui_visible(ui_name, false) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func close_all(): | 
					
						
							|  |  |  | 	for ui_name in ui_map: | 
					
						
							|  |  |  | 		close(ui_name) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func pause_open(ui_name: String): | 
					
						
							|  |  |  | 	open(ui_name) | 
					
						
							|  |  |  | 	set_pause(true) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func pause_close(ui_name: String): | 
					
						
							|  |  |  | 	close(ui_name) | 
					
						
							|  |  |  | 	set_pause(false) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func set_ui_visible(ui_name: String, is_visible: bool) -> void: | 
					
						
							|  |  |  | 	if not ui_name in ui_map: | 
					
						
							|  |  |  | 		return | 
					
						
							|  |  |  | 	var ui_screen = ui_map[ui_name] | 
					
						
							|  |  |  | 	ui_screen.visible = is_visible | 
					
						
							|  |  |  | 	if is_visible: | 
					
						
							|  |  |  | 		top_ui_screen = ui_screen | 
					
						
							|  |  |  | 		print("top_ui_screen:", ui_name) | 
					
						
							|  |  |  | 	return | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func set_pause(is_pause: bool): | 
					
						
							|  |  |  | 	pause_count += 1 if is_pause else -1 | 
					
						
							|  |  |  | 	is_pause = pause_count > 0 | 
					
						
							|  |  |  | 	Global.is_control_pause = is_pause | 
					
						
							|  |  |  | 	get_tree().paused = is_pause |