khanat-client/addons/kh_slider/kh_h_slider.gd

46 lines
1.4 KiB
GDScript3
Raw Permalink Normal View History

2020-03-21 09:10:26 +00:00
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
2020-03-21 09:10:26 +00:00
func get_minus_texture():
return minus_texture
2020-03-21 09:10:26 +00:00
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
2020-03-21 09:10:26 +00:00
func get_plus_texture():
return plus_texture
2020-03-21 09:10:26 +00:00
func _ready():
self.add_child( load( "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
2020-03-21 09:10:26 +00:00
func _on_minus_pressed():
$kh_h_slider/value.value -= $kh_h_slider/value.step
2020-03-21 09:10:26 +00:00
func _on_plus_pressed():
$kh_h_slider/value.value += $kh_h_slider/value.step
2020-03-21 09:10:26 +00:00
func _on_value_changed():
emit_signal( "changed" )
2020-03-21 09:10:26 +00:00
func _on_value_value_changed( value ):
emit_signal( "value_changed", value )