mirror of
				https://git.kittycat.homes/zoe/pegchamp.git
				synced 2024-08-15 03:15:39 +00:00 
			
		
		
		
	refactor volume slider
This commit is contained in:
		
							parent
							
								
									86da05b21a
								
							
						
					
					
						commit
						d5cd76a9a9
					
				
					 3 changed files with 8 additions and 3 deletions
				
			
		|  | @ -1,4 +1,5 @@ | |||
| extends HSlider | ||||
| var changes_to_save = false | ||||
| 
 | ||||
| export var bus_channel = "Master" | ||||
| 
 | ||||
|  | @ -7,6 +8,9 @@ func _ready(): | |||
| 
 | ||||
| func _on_MusicVolumeSlider_value_changed(value): | ||||
| 	AudioServer.set_bus_volume_db(AudioServer.get_bus_index(bus_channel),  linear2db(value)) | ||||
| 	changes_to_save = true | ||||
| 
 | ||||
| func save_volume(): | ||||
| 	Saves.save_game() | ||||
| 	if changes_to_save: | ||||
| 		Saves.save_game() | ||||
| 		changes_to_save = false; | ||||
|  |  | |||
|  | @ -19,7 +19,8 @@ __meta__ = { | |||
| 
 | ||||
| [node name="ButtonSFX" parent="." instance=ExtResource( 3 )] | ||||
| 
 | ||||
| [connection signal="changed" from="." to="." method="save_volume"] | ||||
| [connection signal="focus_entered" from="." to="ButtonSFX" method="on_hover"] | ||||
| [connection signal="focus_exited" from="." to="." method="save_volume"] | ||||
| [connection signal="mouse_entered" from="." to="ButtonSFX" method="on_hover"] | ||||
| [connection signal="mouse_exited" from="." to="." method="save_volume"] | ||||
| [connection signal="value_changed" from="." to="." method="_on_MusicVolumeSlider_value_changed"] | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue