fade-in/out popup
This commit is contained in:
		
							parent
							
								
									c6b9a06419
								
							
						
					
					
						commit
						6b2587a90d
					
				
					 2 changed files with 20 additions and 2 deletions
				
			
		| 
						 | 
					@ -7,6 +7,9 @@ signal start_triggered(config)
 | 
				
			||||||
const pref_path = "user://preferences.cfg"
 | 
					const pref_path = "user://preferences.cfg"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var preferences = ConfigFile.new()
 | 
					var preferences = ConfigFile.new()
 | 
				
			||||||
 | 
					var fade_duration = 0.2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					onready var tween = $Tween
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func _init():
 | 
					func _init():
 | 
				
			||||||
	var err = preferences.load(pref_path)
 | 
						var err = preferences.load(pref_path)
 | 
				
			||||||
| 
						 | 
					@ -14,8 +17,14 @@ func _init():
 | 
				
			||||||
func _ready():
 | 
					func _ready():
 | 
				
			||||||
	pass
 | 
						pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func fade_out():
 | 
				
			||||||
 | 
						tween.remove_all()
 | 
				
			||||||
 | 
						tween.interpolate_property(self, "modulate:a", 1.0, 0.0, fade_duration, Tween.TRANS_LINEAR, Tween.EASE_IN)
 | 
				
			||||||
 | 
						tween.interpolate_callback(self, fade_duration, "hide")
 | 
				
			||||||
 | 
						tween.start()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func _on_Cancel_pressed():
 | 
					func _on_Cancel_pressed():
 | 
				
			||||||
	self.hide()
 | 
						fade_out()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func _on_Start_pressed():
 | 
					func _on_Start_pressed():
 | 
				
			||||||
	if $Panel/HBoxContainer/Easy.pressed:
 | 
						if $Panel/HBoxContainer/Easy.pressed:
 | 
				
			||||||
| 
						 | 
					@ -28,7 +37,7 @@ func _on_Start_pressed():
 | 
				
			||||||
	preferences.save(pref_path)
 | 
						preferences.save(pref_path)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	emit_signal("start_triggered", preferences)
 | 
						emit_signal("start_triggered", preferences)
 | 
				
			||||||
	self.hide()
 | 
						fade_out()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func _on_NewGamePanel_about_to_show():
 | 
					func _on_NewGamePanel_about_to_show():
 | 
				
			||||||
	$Panel/HBoxContainer/Easy.pressed = false
 | 
						$Panel/HBoxContainer/Easy.pressed = false
 | 
				
			||||||
| 
						 | 
					@ -48,3 +57,7 @@ func _on_NewGamePanel_about_to_show():
 | 
				
			||||||
			$Panel/HBoxContainer/Normal.pressed = true
 | 
								$Panel/HBoxContainer/Normal.pressed = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	$Panel/Start.grab_focus()
 | 
						$Panel/Start.grab_focus()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						tween.interpolate_property(self, "modulate:a", 0.0, 1.0, 0.3, Tween.TRANS_LINEAR, Tween.EASE_IN)
 | 
				
			||||||
 | 
						tween.start()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,9 @@ anchor_bottom = 1.0
 | 
				
			||||||
theme = ExtResource( 1 )
 | 
					theme = ExtResource( 1 )
 | 
				
			||||||
popup_exclusive = true
 | 
					popup_exclusive = true
 | 
				
			||||||
script = ExtResource( 3 )
 | 
					script = ExtResource( 3 )
 | 
				
			||||||
 | 
					__meta__ = {
 | 
				
			||||||
 | 
					"_edit_use_anchors_": false
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[node name="Panel" type="Panel" parent="."]
 | 
					[node name="Panel" type="Panel" parent="."]
 | 
				
			||||||
anchor_right = 1.0
 | 
					anchor_right = 1.0
 | 
				
			||||||
| 
						 | 
					@ -85,6 +88,8 @@ margin_bottom = -20.0
 | 
				
			||||||
rect_min_size = Vector2( 200, 70 )
 | 
					rect_min_size = Vector2( 200, 70 )
 | 
				
			||||||
text = "Cancel"
 | 
					text = "Cancel"
 | 
				
			||||||
flat = true
 | 
					flat = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[node name="Tween" type="Tween" parent="."]
 | 
				
			||||||
[connection signal="about_to_show" from="." to="." method="_on_NewGamePanel_about_to_show"]
 | 
					[connection signal="about_to_show" from="." to="." method="_on_NewGamePanel_about_to_show"]
 | 
				
			||||||
[connection signal="pressed" from="Panel/Start" to="." method="_on_Start_pressed"]
 | 
					[connection signal="pressed" from="Panel/Start" to="." method="_on_Start_pressed"]
 | 
				
			||||||
[connection signal="pressed" from="Panel/Cancel" to="." method="_on_Cancel_pressed"]
 | 
					[connection signal="pressed" from="Panel/Cancel" to="." method="_on_Cancel_pressed"]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue