khanat-client/scenes/creatures/creature_creation_menu.gd

236 lines
7.9 KiB
GDScript3
Raw Permalink Normal View History

extends Control
signal updated( value_name, value )
signal mouse_entered_ui
signal mouse_exited_ui
signal load_pressed
signal save_pressed
signal choose_pressed
signal quit_pressed
signal cloths_button_toggled( button_pressed )
signal underwear_button_toggled( button_pressed )
signal zoom_head_button_toggled( button_pressed )
onready var race_popup = $margin_box/window_box/content_box/tabs_box/definition/race/value.get_popup()
onready var sex_popup = $margin_box/window_box/content_box/tabs_box/definition/sex/value.get_popup()
var max_caracteristiques_points = 5*5 + 5
func _ready():
# Race.
race_popup.add_item( Globals.race_label[ Globals.RACE.arche ] )
race_popup.add_item( Globals.race_label[ Globals.RACE.human ] )
race_popup.connect("id_pressed", self, "_on_race_id_pressed")
# Sex.
sex_popup.add_item( Globals.sex_label[ Globals.SEX.female ] )
sex_popup.add_item( Globals.sex_label[ Globals.SEX.male ] )
sex_popup.connect("id_pressed", self, "_on_sex_id_pressed")
func _on_race_id_pressed( ID ):
$margin_box/window_box/content_box/tabs_box/definition/race/value.text = race_popup.get_item_text( ID )
emit_signal( "updated", "race", ID )
func _on_sex_id_pressed( ID ):
$margin_box/window_box/content_box/tabs_box/definition/sex/value.text = sex_popup.get_item_text( ID )
emit_signal( "updated", "sex", ID )
if ID == Globals.SEX.male:
$margin_box/window_box/content_box/tabs_box/Corps/aspect/female_label.hide()
$margin_box/window_box/content_box/tabs_box/Corps/aspect/breast.hide()
$margin_box/window_box/content_box/tabs_box/Corps/aspect/pregnancy.hide()
else:
$margin_box/window_box/content_box/tabs_box/Corps/aspect/female_label.show()
$margin_box/window_box/content_box/tabs_box/Corps/aspect/breast.show()
$margin_box/window_box/content_box/tabs_box/Corps/aspect/pregnancy.show()
func update_sliders( p_creature ):
var race = p_creature.get_data( "race", Globals.RACE.human )
self._on_race_id_pressed( race )
var sex = p_creature.get_data( "sex", Globals.SEX.female )
self._on_sex_id_pressed( sex )
for child in $margin_box/window_box/content_box/tabs_box/Corps/aspect.get_children():
if not child is Label:
if child.get_node( "value" ) is ColorPickerButton:
child.get_node( "value" ).color = p_creature.get_data( child.name, Color.white )
else:
child.get_node( "value" ).value = p_creature.get_data( child.name, 0.0 )
for child in self.get_node( "margin_box/window_box/content_box/tabs_box/Tête/aspect" ).get_children():
if not child is Label:
if child.get_node( "value" ) is ColorPickerButton:
child.get_node( "value" ).color = p_creature.get_data( child.name, Color.white )
else:
child.get_node( "value" ).value = p_creature.get_data( child.name, 0.0 )
func update_caracteristique( p_name, p_value ):
var total_points = 0
for caracteristique in $margin_box/window_box/content_box/tabs_box/caracteristiques.get_children():
if not caracteristique.name == "lasting_points":
total_points += caracteristique.get_node( "value" ).value
$margin_box/window_box/content_box/tabs_box/caracteristiques/lasting_points/value.text = str(self.max_caracteristiques_points - total_points)
if int($margin_box/window_box/content_box/tabs_box/caracteristiques/lasting_points/value.text) < 0:
var other_points = total_points - p_value
var other_lasting_points = self.max_caracteristiques_points - other_points
self.get_node( "margin_box/window_box/content_box/tabs_box/caracteristiques/"+p_name+"/value" ).value = other_lasting_points
$margin_box/window_box/content_box/tabs_box/caracteristiques/lasting_points/value.text = "0"
func _on_first_name_text_entered(new_text):
emit_signal( "updated", "first_name", new_text )
func _on_last_name_text_entered(new_text):
emit_signal( "updated", "last_name", new_text )
func _on_size_value_changed(value):
emit_signal( "updated", "size", value )
func _on_fat_value_changed(value):
emit_signal( "updated", "fat", value )
func _on_muscle_value_changed(value):
emit_signal( "updated", "muscles", value )
func _on_breast_value_changed(value):
emit_signal( "updated", "breast", value )
func _on_pregnancy_value_changed(value):
emit_signal( "updated", "pregnancy", value )
func _on_skin_tone_value_changed(value):
emit_signal( "updated", "skin_tone", value )
func _on_hair_value_changed(value):
emit_signal( "updated", "hair", value )
func _on_hair_color_color_changed( color ):
emit_signal( "updated", "hair_color", color )
func _on_caucasian_value_changed(value):
emit_signal( "updated", "caucasian", value )
func _on_african_value_changed(value):
emit_signal( "updated", "african", value )
func _on_asian_value_changed(value):
emit_signal( "updated", "asian", value )
func _on_first_name_text_changed(new_text):
emit_signal( "updated", "first_name", new_text )
func _on_last_name_text_changed(new_text):
emit_signal( "updated", "last_name", new_text )
func _on_proportion_value_changed(value):
emit_signal( "updated", "proportion", value )
func _on_strength_value_changed(value):
self.update_caracteristique( "strength", value )
func _on_perception_value_changed(value):
self.update_caracteristique( "perception", value )
func _on_endurance_value_changed(value):
self.update_caracteristique( "endurance", value )
func _on_constitution_value_changed(value):
self.update_caracteristique( "constitution", value )
func _on_agility_value_changed(value):
self.update_caracteristique( "agility", value )
func _on_cleft_chin_value_changed(value):
emit_signal( "updated", "cleft_chin", value )
func _on_chin_angle_value_changed(value):
emit_signal( "updated", "chin_angle", value )
func _on_mouth_horiz_value_changed(value):
emit_signal( "updated", "mouth_horiz", value )
func _on_mouth_vert_value_changed(value):
emit_signal( "updated", "mouth_vert", value )
func _on_nose_galbe_value_changed(value):
emit_signal( "updated", "nose_galbe", value )
func _on_nose_grec_value_changed(value):
emit_signal( "updated", "nose_grec", value )
func _on_nose_horiz_value_changed(value):
emit_signal( "updated", "nose_horiz", value )
func _on_nose_depth_value_changed(value):
emit_signal( "updated", "nose_depth", value )
func _on_eyes_color_value_changed(value):
emit_signal( "updated", "eyes_color", value )
func _on_eyes_vert_value_changed(value):
emit_signal( "updated", "eyes_vert", value )
func _on_eyes_gap_value_changed(value):
emit_signal( "updated", "eyes_gap", value )
func _on_earlobes_value_changed(value):
emit_signal( "updated", "earlobes", value )
func _on_ears_wing_value_changed(value):
emit_signal( "updated", "ears_wing", value )
func _on_lips_up_shape_value_changed(value):
emit_signal( "updated", "lips_up_shape", value )
func _on_lips_up_shape_2_value_changed(value):
emit_signal( "updated", "lips_up_shape_2", value )
func _on_skin_value_changed(value):
emit_signal( "updated", "skin", value )
func _on_load_pressed():
emit_signal( "load_pressed" )
func _on_save_pressed():
emit_signal( "save_pressed" )
func _on_choose_pressed():
emit_signal( "choose_pressed" )
func _on_quit_pressed():
emit_signal( "quit_pressed" )
func _on_creature_creation_menu_mouse_entered():
emit_signal( "mouse_exited_ui")
func _on_creature_creation_menu_mouse_exited():
emit_signal( "mouse_entered_ui")
func _on_cloths_button_toggled(button_pressed):
emit_signal( "cloths_button_toggled", button_pressed )
if button_pressed:
$margin_box/window_box/content_box/preview_box/v_box_container/cloths_button.modulate.a = 1.0
else:
$margin_box/window_box/content_box/preview_box/v_box_container/cloths_button.modulate.a = 0.5
func _on_underwear_button_toggled(button_pressed):
emit_signal( "underwear_button_toggled", button_pressed )
if button_pressed:
$margin_box/window_box/content_box/preview_box/v_box_container/underwear_button.modulate.a = 1.0
else:
$margin_box/window_box/content_box/preview_box/v_box_container/underwear_button.modulate.a = 0.5
2021-06-22 16:22:58 +00:00
func _on_zoom_head_button_toggled(button_pressed):
emit_signal( "zoom_head_button_toggled", button_pressed )