Quelques amelioration de la création de perso.

This commit is contained in:
osquallo 2018-09-15 11:00:55 +02:00
parent b82a3772f9
commit 32b456f99f
6 changed files with 194 additions and 71 deletions

View file

@ -49,6 +49,14 @@ func _ready():
# print("qsdfghjklkjhgfdsqsdfghj")
# if self.get_parent().has_node( "start_position" ):
# self.translation = self.get_parent().get_node( "start_position" ).translation
func set_default_values():
self.pseudo = ""
self.color = Color( 1.0, 0.25, 0.25, 1.0 )
self.gender = 1
self.size = 1.0
self.slot = 0
self.ears_size = 0.0
self.eyes_color = Color( 0.0, 1.0, 0.0, 1.0 )
func update( start_position = null ):
if start_position:

View file

@ -149,7 +149,7 @@ use_filter = false
font_data = ExtResource( 2 )
_sections_unfolded = [ "Font", "Settings" ]
[node name="Settings" type="MarginContainer"]
[node name="Settings" type="MarginContainer" index="0"]
anchor_left = 0.0
anchor_top = 0.0
@ -1295,7 +1295,6 @@ _sections_unfolded = [ "Size Flags" ]
[node name="Test" type="MarginContainer" parent="Menus/TabContainer" index="2"]
editor/display_folded = true
visible = false
anchor_left = 0.0
anchor_top = 0.0
@ -1603,7 +1602,7 @@ flat = false
align = 1
items = [ ]
script = ExtResource( 5 )
_sections_unfolded = [ "custom_constants" ]
_sections_unfolded = [ "Mouse", "custom_constants" ]
[node name="ColorPickerButton" type="ColorPickerButton" parent="Menus/TabContainer/Test/ScrollContainer/VBoxContainer" index="7"]

View file

@ -1,9 +1,10 @@
extends MarginContainer
#signal character_changed
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
@ -19,6 +20,19 @@ var syllabes_khanat_trad = [ "TradKmachin", "TradKtruc", "TradKbidule", "TradKch
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" )
@ -35,6 +49,19 @@ 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
@ -63,14 +90,6 @@ func _on_generate_name_pressed():
$margin_container/v_box_container/name_box/line_edit.text = name
self.show_help( trad )
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
func _on_sex_bar_value_changed( value ):
emit_signal( "sex_bar_changed", value )
@ -78,7 +97,10 @@ func _on_sex_bar_value_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 )

View file

@ -54,7 +54,7 @@ anchor_bottom = 0.0
margin_left = 8.0
margin_top = 8.0
margin_right = 1016.0
margin_bottom = 228.0
margin_bottom = 252.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
@ -73,7 +73,7 @@ anchor_bottom = 0.0
margin_left = 8.0
margin_top = 8.0
margin_right = 1016.0
margin_bottom = 228.0
margin_bottom = 252.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
@ -95,7 +95,7 @@ anchor_bottom = 0.0
margin_left = 8.0
margin_top = 8.0
margin_right = 1000.0
margin_bottom = 212.0
margin_bottom = 236.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
@ -387,6 +387,7 @@ size_flags_vertical = 1
[node name="sexe_box" type="HBoxContainer" parent="margin_container/v_box_container" index="4"]
editor/display_folded = true
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
@ -425,6 +426,7 @@ _sections_unfolded = [ "Size Flags" ]
[node name="h_box_container" type="HBoxContainer" parent="margin_container/v_box_container/sexe_box" index="1"]
editor/display_folded = true
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
@ -507,6 +509,7 @@ max_lines_visible = -1
[node name="size_box" type="HBoxContainer" parent="margin_container/v_box_container" index="5"]
editor/display_folded = true
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
@ -545,6 +548,7 @@ _sections_unfolded = [ "Size Flags" ]
[node name="h_box_container" type="HBoxContainer" parent="margin_container/v_box_container/size_box" index="1"]
editor/display_folded = true
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
@ -688,7 +692,7 @@ rounded = false
custom_step = -1.0
_sections_unfolded = [ "Size Flags" ]
[node name="h_separator3" type="HSeparator" parent="margin_container/v_box_container" index="7"]
[node name="eyes_color_box" type="HBoxContainer" parent="margin_container/v_box_container" index="7"]
anchor_left = 0.0
anchor_top = 0.0
@ -696,7 +700,72 @@ anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 126.0
margin_right = 992.0
margin_bottom = 130.0
margin_bottom = 146.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
alignment = 0
[node name="label" type="Label" parent="margin_container/v_box_container/eyes_color_box" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 3.0
margin_right = 494.0
margin_bottom = 17.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 3
size_flags_vertical = 4
text = "Couleur des yeux"
align = 1
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
_sections_unfolded = [ "Size Flags" ]
[node name="eyes_color" type="ColorPickerButton" parent="margin_container/v_box_container/eyes_color_box" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 498.0
margin_right = 992.0
margin_bottom = 20.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 3
size_flags_vertical = 4
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
flat = false
align = 1
color = Color( 0, 1, 0.501961, 1 )
edit_alpha = true
_sections_unfolded = [ "Size Flags" ]
[node name="h_separator3" type="HSeparator" parent="margin_container/v_box_container" index="8"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 150.0
margin_right = 992.0
margin_bottom = 154.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
@ -704,15 +773,15 @@ mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
[node name="error_label" type="Label" parent="margin_container/v_box_container" index="8"]
[node name="error_label" type="Label" parent="margin_container/v_box_container" index="9"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 134.0
margin_top = 158.0
margin_right = 992.0
margin_bottom = 156.0
margin_bottom = 180.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
@ -728,31 +797,7 @@ lines_skipped = 0
max_lines_visible = -1
_sections_unfolded = [ "custom_colors", "custom_fonts", "custom_styles" ]
[node name="valid_button" type="Button" parent="margin_container/v_box_container" index="9"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 160.0
margin_right = 992.0
margin_bottom = 180.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
text = "Valider"
flat = false
align = 1
[node name="return_button" type="Button" parent="margin_container/v_box_container" index="10"]
[node name="valid_button" type="Button" parent="margin_container/v_box_container" index="10"]
anchor_left = 0.0
anchor_top = 0.0
@ -772,10 +817,36 @@ toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
text = "Valider"
flat = false
align = 1
[node name="return_button" type="Button" parent="margin_container/v_box_container" index="11"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 208.0
margin_right = 992.0
margin_bottom = 228.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
text = "Retour"
flat = false
align = 1
[connection signal="visibility_changed" from="." to="." method="_on_character_creation_box_visibility_changed"]
[connection signal="pressed" from="margin_container/v_box_container/generate_name_box/generate_name" to="." method="_on_generate_name_pressed"]
[connection signal="value_changed" from="margin_container/v_box_container/sexe_box/h_box_container/sex_bar" to="." method="_on_sex_bar_value_changed"]
@ -784,6 +855,8 @@ align = 1
[connection signal="value_changed" from="margin_container/v_box_container/ears_size_box/ears_size" to="." method="_on_ears_size_value_changed"]
[connection signal="color_changed" from="margin_container/v_box_container/eyes_color_box/eyes_color" to="." method="_on_eyes_color_color_changed"]
[connection signal="pressed" from="margin_container/v_box_container/valid_button" to="." method="_on_valid_button_pressed"]
[connection signal="pressed" from="margin_container/v_box_container/return_button" to="." method="_on_return_button_pressed"]

View file

@ -9,12 +9,35 @@ var character_preview = null
var character_mesh = null
var character_face_camera = null
var character_box = null
var character_creation_box = null
var name_input = null
var turn_direction = null
var zoom_direction = null
func _ready():
# $viewport/character/face_camera.make_current()
self.character_preview = $viewport/character
self.character_preview.set_default_values()
# self.character_preview.get_node( "Camera_rotation_helper/face_camera" ).make_current()
self.character_preview.get_node( "face_camera" ).make_current()
self.character_mesh = $viewport/character.get_node("suzanne/mesh")
# self.character_face_camera = $viewport/character/Camera_rotation_helper/face_camera
self.character_box = $margin_container/character_box
self.character_creation_box = $margin_container/character_box/character_creation_box
self.name_input = self.character_box.get_node( "character_creation_box/margin_container/v_box_container/name_box/line_edit" )
self.character_preview.update()
update_character_slots()
func update_character_slots():
var config_file = ConfigFile.new()
@ -42,10 +65,9 @@ func update_character_slots():
slot_box.connect( "mouse_entered", self, "_on_name_mouse_entered_pressed", [int(section)] )
var label_name = Label.new()
label_name.text = character_name#+ " ("+section+")"
label_name.text = character_name
label_name.size_flags_horizontal = SIZE_EXPAND
slot_box.add_child( label_name )
# label_name.connect( "mouse_entered", self, "_on_name_mouse_entered_pressed", [int(section)] )
var choose_button = Button.new()
choose_button.text = "Choisir"
@ -74,24 +96,6 @@ func update_character_slots():
self.character_box.get_node( "character_slots" ).add_child( create_new_characer_button )
create_new_characer_button.connect( "pressed", self, "_on_create_pressed", [next_slot] )
func _ready():
# $viewport/character/face_camera.make_current()
self.character_preview = $viewport/character
# self.character_preview.get_node( "Camera_rotation_helper/face_camera" ).make_current()
self.character_preview.get_node( "face_camera" ).make_current()
self.character_mesh = $viewport/character.get_node("suzanne/mesh")
# self.character_face_camera = $viewport/character/Camera_rotation_helper/face_camera
self.character_box = $margin_container/character_box
self.name_input = self.character_box.get_node( "character_creation_box/margin_container/v_box_container/name_box/line_edit" )
self.character_preview.update()
update_character_slots()
func _on_create_pressed( slot ):
self.character_preview.slot = slot
self.character_box.get_node( "character_slots" ).hide()
@ -189,6 +193,19 @@ func _on_character_creation_box_creation_button_pressed():
self.character_box.get_node( "character_creation_box" ).hide()
update_character_slots()
func _on_character_creation_box_character_preview_need_update():
self.character_preview.pseudo = self.character_creation_box.get_node( "margin_container/v_box_container/name_box/line_edit" ).text
self.character_preview.gender = self.character_creation_box.get_node( "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 = self.character_creation_box.get_node( "margin_container/v_box_container/size_box/h_box_container/size_bar" ).value
self.character_preview.ears_size = self.character_creation_box.get_node( "margin_container/v_box_container/ears_size_box/ears_size" ).value
self.character_preview.eyes_color = self.character_creation_box.get_node( "margin_container/v_box_container/eyes_color_box/eyes_color" ).color
self.character_preview.update()
func _on_character_creation_box_sex_bar_changed( value ):
if value == 0:
self.character_preview.gender = 0
@ -206,7 +223,9 @@ func _on_character_creation_box_ears_size_bar_changed( value ):
self.character_preview.ears_size = value
self.character_preview.update()
func _on_character_creation_box_eyes_color_changed(value):
self.character_preview.eyes_color = value
self.character_preview.update()
func _process( delta ):
@ -255,5 +274,3 @@ func _on_lights_toggled(button_pressed):
func _on_character_preview_image_resized():
$viewport.size = $margin_container/character_box/v_box_container/character_preview_image.rect_size

View file

@ -389,10 +389,14 @@ _sections_unfolded = [ "Axis Stretch", "Grow Direction", "Margin", "Mouse", "Rec
[connection signal="return_button_pressed" from="margin_container/character_box/character_slots" to="." method="_on_character_slots_return_button_pressed"]
[connection signal="character_preview_need_update" from="margin_container/character_box/character_creation_box" to="." method="_on_character_creation_box_character_preview_need_update"]
[connection signal="creation_button_pressed" from="margin_container/character_box/character_creation_box" to="." method="_on_character_creation_box_creation_button_pressed"]
[connection signal="ears_size_bar_changed" from="margin_container/character_box/character_creation_box" to="." method="_on_character_creation_box_ears_size_bar_changed"]
[connection signal="eyes_color_changed" from="margin_container/character_box/character_creation_box" to="." method="_on_character_creation_box_eyes_color_changed"]
[connection signal="return_button_pressed" from="margin_container/character_box/character_creation_box" to="." method="_on_character_creation_box_return_button_pressed"]
[connection signal="sex_bar_changed" from="margin_container/character_box/character_creation_box" to="." method="_on_character_creation_box_sex_bar_changed"]