106 lines
4 KiB
GDScript
106 lines
4 KiB
GDScript
extends MarginContainer
|
|
|
|
signal character_preview_need_update
|
|
signal sex_bar_changed( value )
|
|
signal size_bar_changed( value )
|
|
signal ears_size_bar_changed( value )
|
|
signal eyes_color_changed( value )
|
|
|
|
signal return_button_pressed
|
|
signal creation_button_pressed
|
|
|
|
########
|
|
#### Name generator.
|
|
var syllabes_culno = [ "Cmachin", "Ctruc", "Cbidule", "Cchose" ]
|
|
var syllabes_culno_trad = [ "TradCmachin", "TradCtruc", "TradCbidule", "TradCchose" ]
|
|
|
|
var syllabes_khanat = [ "Kmachin", "Ktruc", "Kbidule", "Kchose" ]
|
|
var syllabes_khanat_trad = [ "TradKmachin", "TradKtruc", "TradKbidule", "TradKchose" ]
|
|
|
|
var syllabes_tcara = [ "Tmachin", "Ttruc", "Tbidule", "Tchose" ]
|
|
var syllabes_tcara_trad = [ "TradTmachin", "TradTtruc", "TradTbidule", "TradTchose" ]
|
|
|
|
var character_preview
|
|
|
|
func _ready():
|
|
|
|
var popup_node = $margin_container/v_box_container/generate_name_box/region_menu
|
|
var popup = popup_node.get_popup()
|
|
popup.add_item( "Khanat" )
|
|
popup.add_item( "Culno" )
|
|
popup.add_item( "Tcara" )
|
|
popup_node.selected = 1
|
|
|
|
self.character_preview = self.get_node( "../../../viewport/character" )
|
|
|
|
|
|
func _on_return_button_pressed():
|
|
emit_signal( "return_button_pressed" )
|
|
|
|
|
|
func _on_valid_button_pressed():
|
|
emit_signal( "creation_button_pressed" )
|
|
|
|
func show_error( string ):
|
|
$margin_container/v_box_container/error_label.set( "custom_colors/font_color", Color( 1, 0, 0, 1 ))
|
|
$margin_container/v_box_container/error_label.text = string
|
|
|
|
func show_help( string ):
|
|
$margin_container/v_box_container/error_label.set( "custom_colors/font_color", Color( 0, 1, 0, 1 ))
|
|
$margin_container/v_box_container/error_label.text = string
|
|
|
|
func _on_character_creation_box_visibility_changed():
|
|
emit_signal( "character_preview_need_update" )
|
|
# self.character_preview.pseudo = $margin_container/v_box_container/name_box/line_edit.text
|
|
# self.character_preview.gender = $margin_container/v_box_container/sexe_box/h_box_container/sex_bar.value
|
|
# if self.character_preview.gender == 1:
|
|
# self.character_preview.color = Color( 1.0, 0.25, 0.25, 1.0 )
|
|
# else:
|
|
# self.character_preview.color = Color( 0.0, 0.0, 1.0, 1.0 )
|
|
# self.character_preview.size = $margin_container/v_box_container/size_box/h_box_container/size_bar.value
|
|
# self.character_preview.ears_size = $margin_container/v_box_container/ears_size_box/ears_size.value
|
|
# self.character_preview.eyes_color = $margin_container/v_box_container/eyes_color_box/eyes_color.color
|
|
# self.character_preview.update()
|
|
|
|
func _on_generate_name_pressed():
|
|
var nb_syllabes = $margin_container/v_box_container/generate_name_box/nb_syllabe.value
|
|
var nb_noms = $margin_container/v_box_container/generate_name_box/nb_nom.value
|
|
var region = $margin_container/v_box_container/generate_name_box/region_menu.text
|
|
|
|
var name = ""
|
|
var trad = ""
|
|
for nom_index in range( 0, nb_noms ):
|
|
for syllabe_index in range( 0, nb_syllabes ):
|
|
if region == "Culno":
|
|
var index = randi()%len(syllabes_culno)
|
|
name += syllabes_culno[ index ]
|
|
trad += syllabes_culno_trad[ index ]
|
|
elif region == "Tcara":
|
|
var index = randi()%len(syllabes_tcara)
|
|
name += syllabes_tcara[ index ]
|
|
trad += syllabes_tcara_trad[ index ]
|
|
else:
|
|
var index = randi()%len(syllabes_khanat)
|
|
name += syllabes_khanat[ index ]
|
|
trad += syllabes_khanat_trad[ index ]
|
|
if nom_index+1 < nb_noms:
|
|
name += " "
|
|
trad += " / "
|
|
|
|
$margin_container/v_box_container/name_box/line_edit.text = name
|
|
self.show_help( trad )
|
|
|
|
|
|
func _on_sex_bar_value_changed( value ):
|
|
emit_signal( "sex_bar_changed", value )
|
|
|
|
func _on_size_bar_value_changed( value ):
|
|
emit_signal( "size_bar_changed", value )
|
|
|
|
func _on_ears_size_value_changed(value):
|
|
emit_signal( "ears_size_bar_changed", value )
|
|
|
|
func _on_eyes_color_color_changed(color):
|
|
emit_signal( "eyes_color_changed", color )
|
|
|
|
|