khanat-client/addons/kh_slider/kh_h_slider.gd
2021-01-21 22:03:44 +01:00

45 lines
1.4 KiB
GDScript

tool
extends HBoxContainer
signal changed
signal value_changed( value )
export( Texture ) var minus_texture setget set_minus_texture, get_minus_texture
func set_minus_texture( value ):
minus_texture = value
if self.has_node( "kh_h_slider/minus" ):
$kh_h_slider/minus.texture_normal = minus_texture
func get_minus_texture():
return minus_texture
export( Texture ) var plus_texture setget set_plus_texture, get_plus_texture
func set_plus_texture( value ):
plus_texture = value
if self.has_node( "kh_h_slider/plus" ):
$kh_h_slider/plus.texture_normal = plus_texture
func get_plus_texture():
return plus_texture
func _ready():
self.add_child( preload( "res://addons/kh_slider/kh_h_slider.tscn" ).instance() )
$kh_h_slider/minus.connect( "pressed", self, "_on_minus_pressed" )
$kh_h_slider/value.connect( "changed", self, "_on_value_changed" )
$kh_h_slider/value.connect( "value_changed", self, "_on_value_value_changed" )
$kh_h_slider/plus.connect( "pressed", self, "_on_plus_pressed" )
$kh_h_slider/minus.texture_normal = minus_texture
$kh_h_slider/plus.texture_normal = plus_texture
func _on_minus_pressed():
$kh_h_slider/value.value -= $kh_h_slider/value.step
func _on_plus_pressed():
$kh_h_slider/value.value += $kh_h_slider/value.step
func _on_value_changed():
emit_signal( "changed" )
func _on_value_value_changed( value ):
emit_signal( "value_changed", value )