diff --git a/global.gd b/global.gd index d9f1049..8c3713e 100644 --- a/global.gd +++ b/global.gd @@ -5,12 +5,13 @@ const WINDOW_TITLE_INPUT = "GUI/Settings/Menus/TabContainer/Test/ScrollContainer #### Environment var time_scale = 0.1 - -#### Character -var character_name = "player" -var character_color = null -var character_gender = null -var character_slot = null +# +##### Character +#var character_name = "player" +#var character_color = null +#var character_gender = null +#var character_scale = 1 +#var character_slot = null #### BG loader onready var progress_texture = $background_loader/center_container/texture_progress @@ -178,8 +179,9 @@ func _on_login_scene_character_creation_finished(): if err: print("Error code when loading config file: ", err) - config_file.set_value(str(self.character_slot), "name", self.character_name) - config_file.set_value(str(self.character_slot), "color", self.character_color) + config_file.set_value(str(character.slot), "name", character.pseudo) + config_file.set_value(str(character.slot), "color", character.color) + config_file.set_value(str(character.size), "size", character.size) config_file.save( "user://player.cfg" ) self.change_level( "game", "res://game_scene/game_scene.tscn", null, get_tree().get_root().get_node("login_scene") ) diff --git a/global.tscn b/global.tscn index 5de1b0e..aa1c2d8 100644 --- a/global.tscn +++ b/global.tscn @@ -4,7 +4,7 @@ [ext_resource path="res://background_loader_scene/background_loader.tscn" type="PackedScene" id=2] [ext_resource path="res://scenes/GUI/GUI.tscn" type="PackedScene" id=3] -[node name="global" type="Node"] +[node name="global" type="Node" index="0"] pause_mode = 2 script = ExtResource( 1 ) diff --git a/login_scene/character_creation_box.gd b/login_scene/character_creation_box.gd index 1fdcb4d..5f9b5c7 100644 --- a/login_scene/character_creation_box.gd +++ b/login_scene/character_creation_box.gd @@ -1,17 +1,21 @@ extends MarginContainer -signal gender_value_changed( value ) +#signal character_changed +signal sex_bar_changed( value ) +signal size_bar_changed( value ) signal return_button_pressed signal creation_button_pressed -var m_first_name_list = [ "testm1", "testm2", "testm3" ] -var f_first_name_list = [ "testf1", "testf2", "testf3" ] -var name_list = [ "machin", "truc", "bidule", "chose" ] +######## +#### 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" ] - -func _on_h_scroll_bar_value_changed( value ): - emit_signal( "gender_value_changed", value ) +var syllabes_tcara = [ "Tmachin", "Ttruc", "Tbidule", "Tchose" ] +var syllabes_tcara_trad = [ "TradTmachin", "TradTtruc", "TradTbidule", "TradTchose" ] func _on_return_button_pressed(): @@ -21,29 +25,65 @@ func _on_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_generate_name_pressed(): - var sex_slider = $margin_container/v_box_container/sexe_box/h_box_container/h_scroll_bar - - var name = "player" - if sex_slider.value == 0: - var name_index = randi()%len(m_first_name_list) - name = m_first_name_list[ name_index ] - else: - var name_index = randi()%len(f_first_name_list) - name = f_first_name_list[ name_index ] + 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 + print("region: "+str(region) ) + var name = "" + var trad = "" + for nom_index in range( 0, nb_noms ): + for syllabe_index in range( 0, nb_syllabes ): + if region == "Culno": + print("Culno") + var index = randi()%len(syllabes_culno) + name += syllabes_culno[ index ] + trad += syllabes_culno_trad[ index ] + elif region == "Tcara": + print("Tcara") + var index = randi()%len(syllabes_tcara) + name += syllabes_tcara[ index ] + trad += syllabes_tcara_trad[ index ] + else: + print("Khanat") + var index = randi()%len(syllabes_khanat) + name += syllabes_khanat[ index ] + trad += syllabes_khanat_trad[ index ] + if nom_index+1 < nb_noms: + name += " " + trad += " / " - name += " " - name += name_list[ randi()%len(name_list) ] - $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( "Culno" ) popup.add_item( "Khanat" ) + popup.add_item( "Culno" ) popup.add_item( "Tcara" ) - popup_node.selected = 0 \ No newline at end of file + popup_node.selected = 1 + +func _on_sex_bar_value_changed( value ): +# if value == 0: +# character.gender = 0 +# character.color = Color( 0.0, 0.0, 1.0, 1.0 ) +# else: +# character.gender = 1 +# character.color = Color( 1.0, 0.25, 0.25, 1.0 ) + + emit_signal( "sex_bar_changed", value ) + +func _on_size_bar_value_changed( value ): +# character.size = value + + emit_signal( "size_bar_changed", value ) diff --git a/login_scene/character_creation_box.tscn b/login_scene/character_creation_box.tscn index a6d7029..7cb7261 100644 --- a/login_scene/character_creation_box.tscn +++ b/login_scene/character_creation_box.tscn @@ -22,7 +22,7 @@ use_filter = true font_data = ExtResource( 2 ) _sections_unfolded = [ "Extra Spacing", "Font", "Settings" ] -[node name="character_creation_box" type="MarginContainer" index="0"] +[node name="character_creation_box" type="MarginContainer"] anchor_left = 0.0 anchor_top = 0.0 @@ -54,7 +54,7 @@ anchor_bottom = 0.0 margin_left = 8.0 margin_top = 8.0 margin_right = 1016.0 -margin_bottom = 184.0 +margin_bottom = 210.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 = 184.0 +margin_bottom = 210.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 = 168.0 +margin_bottom = 194.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 1 @@ -105,14 +105,31 @@ size_flags_vertical = 6 alignment = 0 _sections_unfolded = [ "Size Flags", "Theme", "custom_constants" ] -[node name="name_box" type="HBoxContainer" parent="margin_container/v_box_container" index="0"] +[node name="h_separator" type="HSeparator" parent="margin_container/v_box_container" index="0"] anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 margin_right = 992.0 -margin_bottom = 24.0 +margin_bottom = 4.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 + +[node name="name_box" type="HBoxContainer" parent="margin_container/v_box_container" index="1"] + +editor/display_folded = true +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_top = 8.0 +margin_right = 992.0 +margin_bottom = 32.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 1 @@ -169,16 +186,16 @@ caret_blink_speed = 0.65 caret_position = 0 _sections_unfolded = [ "Placeholder", "Size Flags" ] -[node name="generate_name_box" type="HBoxContainer" parent="margin_container/v_box_container" index="1"] +[node name="generate_name_box" type="HBoxContainer" parent="margin_container/v_box_container" index="2"] editor/display_folded = true anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_top = 28.0 +margin_top = 36.0 margin_right = 992.0 -margin_bottom = 52.0 +margin_bottom = 60.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 1 @@ -269,11 +286,11 @@ mouse_filter = 0 mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 1 -min_value = 0.0 +min_value = 1.0 max_value = 100.0 step = 1.0 page = 0.0 -value = 0.0 +value = 1.0 exp_edit = false rounded = false editable = true @@ -316,11 +333,11 @@ mouse_filter = 0 mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 1 -min_value = 0.0 +min_value = 1.0 max_value = 100.0 step = 1.0 page = 0.0 -value = 0.0 +value = 1.0 exp_edit = false rounded = false editable = true @@ -352,23 +369,7 @@ flat = false align = 1 _sections_unfolded = [ "Focus", "Size Flags", "Theme" ] -[node name="h_separator" type="HSeparator" parent="margin_container/v_box_container" index="2"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 56.0 -margin_right = 992.0 -margin_bottom = 60.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 - -[node name="sexe_box" type="HBoxContainer" parent="margin_container/v_box_container" index="3"] +[node name="h_separator2" type="HSeparator" parent="margin_container/v_box_container" index="3"] anchor_left = 0.0 anchor_top = 0.0 @@ -376,7 +377,23 @@ anchor_right = 0.0 anchor_bottom = 0.0 margin_top = 64.0 margin_right = 992.0 -margin_bottom = 78.0 +margin_bottom = 68.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 + +[node name="sexe_box" type="HBoxContainer" parent="margin_container/v_box_container" index="4"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_top = 72.0 +margin_right = 992.0 +margin_bottom = 86.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 1 @@ -443,7 +460,7 @@ percent_visible = 1.0 lines_skipped = 0 max_lines_visible = -1 -[node name="h_scroll_bar" type="HScrollBar" parent="margin_container/v_box_container/sexe_box/h_box_container" index="1"] +[node name="sex_bar" type="HScrollBar" parent="margin_container/v_box_container/sexe_box/h_box_container" index="1"] anchor_left = 0.0 anchor_top = 0.0 @@ -488,23 +505,7 @@ percent_visible = 1.0 lines_skipped = 0 max_lines_visible = -1 -[node name="h_separator2" type="HSeparator" parent="margin_container/v_box_container" index="4"] - -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 0.0 -anchor_bottom = 0.0 -margin_top = 82.0 -margin_right = 992.0 -margin_bottom = 86.0 -rect_pivot_offset = Vector2( 0, 0 ) -rect_clip_content = false -mouse_filter = 0 -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="5"] +[node name="size_box" type="HBoxContainer" parent="margin_container/v_box_container" index="5"] anchor_left = 0.0 anchor_top = 0.0 @@ -512,9 +513,145 @@ anchor_right = 0.0 anchor_bottom = 0.0 margin_top = 90.0 margin_right = 992.0 +margin_bottom = 104.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/size_box" index="0"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_right = 494.0 +margin_bottom = 14.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 = "Size:" +align = 1 +percent_visible = 1.0 +lines_skipped = 0 +max_lines_visible = -1 +_sections_unfolded = [ "Size Flags" ] + +[node name="h_box_container" type="HBoxContainer" parent="margin_container/v_box_container/size_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 = 14.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 1 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 3 +size_flags_vertical = 1 +alignment = 0 +_sections_unfolded = [ "Size Flags" ] + +[node name="petit" type="Label" parent="margin_container/v_box_container/size_box/h_box_container" index="0"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_right = 30.0 +margin_bottom = 14.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 2 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 4 +text = "Petit" +percent_visible = 1.0 +lines_skipped = 0 +max_lines_visible = -1 + +[node name="size_bar" type="HScrollBar" parent="margin_container/v_box_container/size_box/h_box_container" index="1"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 34.0 +margin_right = 452.0 +margin_bottom = 12.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 3 +size_flags_vertical = 0 +min_value = 0.5 +max_value = 1.5 +step = 0.5 +page = 0.0 +value = 1.0 +exp_edit = false +rounded = false +custom_step = -1.0 +_sections_unfolded = [ "Size Flags", "custom_icons" ] + +[node name="grand" type="Label" parent="margin_container/v_box_container/size_box/h_box_container" index="2"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 456.0 +margin_right = 494.0 +margin_bottom = 14.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 2 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 4 +text = "Grand" +percent_visible = 1.0 +lines_skipped = 0 +max_lines_visible = -1 + +[node name="h_separator3" type="HSeparator" parent="margin_container/v_box_container" index="6"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_top = 108.0 +margin_right = 992.0 margin_bottom = 112.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false +mouse_filter = 0 +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="7"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_top = 116.0 +margin_right = 992.0 +margin_bottom = 138.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false mouse_filter = 2 mouse_default_cursor_shape = 0 size_flags_horizontal = 1 @@ -528,15 +665,15 @@ 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="6"] +[node name="valid_button" type="Button" 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 = 116.0 +margin_top = 142.0 margin_right = 992.0 -margin_bottom = 136.0 +margin_bottom = 162.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false focus_mode = 2 @@ -552,15 +689,15 @@ text = "Valider" flat = false align = 1 -[node name="return_button" type="Button" parent="margin_container/v_box_container" index="7"] +[node name="return_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 = 140.0 +margin_top = 166.0 margin_right = 992.0 -margin_bottom = 160.0 +margin_bottom = 186.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false focus_mode = 2 @@ -578,7 +715,9 @@ align = 1 [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/h_scroll_bar" to="." method="_on_h_scroll_bar_value_changed"] +[connection signal="value_changed" from="margin_container/v_box_container/sexe_box/h_box_container/sex_bar" to="." method="_on_sex_bar_value_changed"] + +[connection signal="value_changed" from="margin_container/v_box_container/size_box/h_box_container/size_bar" to="." method="_on_size_bar_value_changed"] [connection signal="pressed" from="margin_container/v_box_container/valid_button" to="." method="_on_valid_button_pressed"] diff --git a/login_scene/character_selection_menu.gd b/login_scene/character_selection_menu.gd index 557e238..10c974d 100644 --- a/login_scene/character_selection_menu.gd +++ b/login_scene/character_selection_menu.gd @@ -5,9 +5,9 @@ signal return_button_pressed var preview_slot = 0 +var character_preview = null var character_mesh = null var name_input = null -onready var error_label = $h_box_container/character_creation_box/margin_container/v_box_container/error_label func update_character_slots(): @@ -22,8 +22,11 @@ func update_character_slots(): useds_slot.append( int(section) ) if not has_node( "h_box_container/character_slots/slot_box_"+section ): last_slot = int(section) - var character_name = config_file.get_value( section, "name" ) + var character_name = config_file.get_value( section, "name" ) + if not character_name: + character_name = "NameNotFound" + var slot_box = HBoxContainer.new() slot_box.name = "slot_box_"+section slot_box.size_flags_horizontal = SIZE_FILL @@ -72,8 +75,15 @@ func update_character_slots(): create_new_characer_button.connect( "pressed", self, "_on_create_pressed", [next_slot] ) func _ready(): - character_mesh = character.get_node("MeshInstance") - name_input = $h_box_container/character_creation_box/margin_container/v_box_container/name_box/line_edit + self.character_preview = $viewport/character + self.character_mesh = $viewport/character.get_node("MeshInstance") + self.name_input = $h_box_container/character_creation_box/margin_container/v_box_container/name_box/line_edit + + self.character_preview.update() +# var parent = character.get_parent() +# parent.remove_child( character ) +# $viewport.add_child( character ) + update_character_slots() @@ -81,11 +91,11 @@ func _on_character_slots_return_button_pressed(): emit_signal( "return_button_pressed" ) func _on_create_pressed( slot ): - global.character_slot = slot + self.character_preview.slot = slot $h_box_container/character_slots.hide() $h_box_container/character_creation_box.show() - _on_character_creation_box_gender_value_changed( $h_box_container/character_creation_box/margin_container/v_box_container/sexe_box/h_box_container/h_scroll_bar.value ) - + self.character_preview.update() + func _on_choose_pressed( slot ): emit_signal( "character_selected", slot ) @@ -116,16 +126,18 @@ func update_preview(): if err: print("Error code when loading player config file: ", err) if config_file.has_section( str(slot) ): - $viewport/character_preview/MeshInstance.get_surface_material(0).set_shader_param("albedo", config_file.get_value( str(slot), "color" ) ) + # Color + var color = config_file.get_value( str(slot), "color" ) + if not color: + color = Color( 1, 0.25, 0.25, 1 ) + character_mesh.get_surface_material(0).set_shader_param("albedo", color ) -func _on_character_creation_box_gender_value_changed(value): - if value == 1: - global.character_gender = 1 - character_mesh.get_surface_material(0).set_shader_param("albedo", Color( 1.0, 0.25, 0.25, 1.0 ) ) - else: - global.character_gender = 0 - character_mesh.get_surface_material(0).set_shader_param("albedo", Color( 0.0, 0.0, 1.0, 1.0 ) ) + # Size + var size = config_file.get_value( str(slot), "size" ) + if not size: + size = 1 + character_preview.scale = Vector3( size, size, size ) @@ -135,24 +147,39 @@ func _on_character_creation_box_return_button_pressed(): $h_box_container/character_creation_box.hide() func _on_character_creation_box_creation_button_pressed(): - if not name_input.text or name_input.text == "": - error_label.text = "You need to choose a character's name." + if not self.name_input.text or self.name_input.text == "": + $h_box_container/character_creation_box.show_error( "You need to choose a character's name." ) return - global.character_name = name_input.text - global.character_color = character_mesh.get_surface_material(0).get_shader_param("albedo") + character_preview.pseudo = self.name_input.text +# character.color = character_mesh.get_surface_material(0).get_shader_param("albedo") +# character.size = character_mesh.scale.x var config_file = ConfigFile.new() var err = config_file.load( "user://player.cfg" ) if err: print("Error code when loading player config file: ", err) - config_file.set_value( str(global.character_slot), "name", global.character_name) - config_file.set_value( str(global.character_slot), "color", global.character_color) + config_file.set_value( str(character.slot), "name", character.pseudo) + config_file.set_value( str(character.slot), "color", character.color) + config_file.set_value( str(character.slot), "size", character.size) config_file.save( "user://player.cfg" ) $h_box_container/character_slots.show() $h_box_container/character_creation_box.hide() update_character_slots() +func _on_character_creation_box_character_changed(): + self.character_preview.update() +func _on_character_creation_box_sex_bar_changed( value ): + if value == 0: + self.character_preview.gender = 0 + self.character_preview.color = Color( 0.0, 0.0, 1.0, 1.0 ) + else: + self.character_preview.gender = 1 + self.character_preview.color = Color( 1.0, 0.25, 0.25, 1.0 ) + self.character_preview.update() +func _on_character_creation_box_size_bar_changed( value ): + self.character_preview.size = value + self.character_preview.update() diff --git a/login_scene/character_selection_menu.tscn b/login_scene/character_selection_menu.tscn index 1fbf477..da50c2d 100644 --- a/login_scene/character_selection_menu.tscn +++ b/login_scene/character_selection_menu.tscn @@ -12,7 +12,7 @@ resource_local_to_scene = true flags = 0 viewport_path = NodePath("viewport") -[node name="character_selection_menu" type="Control"] +[node name="character_selection_menu" type="Control" index="0"] anchor_left = 0.0 anchor_top = 0.0 @@ -33,7 +33,7 @@ size = Vector2( 256, 256 ) own_world = false world = null transparent_bg = false -msaa = 0 +msaa = 2 hdr = true disable_3d = false usage = 2 @@ -53,7 +53,7 @@ shadow_atlas_quad_2 = 3 shadow_atlas_quad_3 = 4 _sections_unfolded = [ "Render Target", "Rendering" ] -[node name="character_preview" parent="viewport" index="0" instance=ExtResource( 2 )] +[node name="character" parent="viewport" index="0" instance=ExtResource( 2 )] [node name="texture_rect" type="TextureRect" parent="." index="1"] @@ -93,9 +93,9 @@ _sections_unfolded = [ "Size Flags", "custom_constants" ] visible = false margin_left = 58.0 -margin_top = 226.0 -margin_right = 539.0 -margin_bottom = 374.0 +margin_top = 191.0 +margin_right = 600.0 +margin_bottom = 409.0 [node name="nine_patch_rect" type="NinePatchRect" parent="h_box_container" index="2"] @@ -121,8 +121,10 @@ _sections_unfolded = [ "Axis Stretch", "Margin", "Rect", "Size Flags" ] [connection signal="creation_button_pressed" from="h_box_container/character_creation_box" to="." method="_on_character_creation_box_creation_button_pressed"] -[connection signal="gender_value_changed" from="h_box_container/character_creation_box" to="." method="_on_character_creation_box_gender_value_changed"] - [connection signal="return_button_pressed" from="h_box_container/character_creation_box" to="." method="_on_character_creation_box_return_button_pressed"] +[connection signal="sex_bar_changed" from="h_box_container/character_creation_box" to="." method="_on_character_creation_box_sex_bar_changed"] + +[connection signal="size_bar_changed" from="h_box_container/character_creation_box" to="." method="_on_character_creation_box_size_bar_changed"] + diff --git a/login_scene/login_scene.gd b/login_scene/login_scene.gd index 5a0e36c..6a05bfe 100644 --- a/login_scene/login_scene.gd +++ b/login_scene/login_scene.gd @@ -21,9 +21,9 @@ func _on_character_selection_menu_character_selected(slot): var err = config_file.load( "user://player.cfg" ) if err: print("Error code when loading player config file: ", err) - global.character_slot = slot - global.character_name = config_file.get_value( str(slot), "name", "player") - global.character_color = config_file.get_value( str(slot), "color", Color(1.0, 63.0, 63.0, 1.0) ) + character.slot = slot + character.pseudo = config_file.get_value( str(slot), "name", "player") + character.color = config_file.get_value( str(slot), "color", Color(1.0, 63.0, 63.0, 1.0) ) emit_signal( "character_creation_finished" ) diff --git a/scenes/GUI/HUD/Windows.gd b/scenes/GUI/HUD/Windows.gd index 19b449d..0bba564 100644 --- a/scenes/GUI/HUD/Windows.gd +++ b/scenes/GUI/HUD/Windows.gd @@ -5,18 +5,6 @@ func _ready(): for child in self.get_children(): child.connect( "window_clicked", self, "_on_window_clicked" ) -# var new_label = Label.new() -# new_label.set_name( "azerty" ) -# new_label.set_text( "azertyuiop sdfghjklm wxcvbn" ) -# new_label.set_autowrap( true ) -# $ui_window.add_child( new_label ) -# new_label = Label.new() -# new_label.set_name( "azerty2" ) -# new_label.set_text( "2azertyuiop2 2sdfghjklm2 wxcvbn2" ) -# new_label.set_autowrap( true ) -# $ui_window.add_child( new_label ) - - func _on_window_clicked( window ): var index = 0 for child in self.get_children(): diff --git a/scenes/Game/Character/Character.gd b/scenes/Game/Character/Character.gd index b7e2e30..749cc1a 100644 --- a/scenes/Game/Character/Character.gd +++ b/scenes/Game/Character/Character.gd @@ -1,5 +1,13 @@ extends KinematicBody +######## +#### Caracteristic +var pseudo = "" +var color = Color( 1.0, 0.25, 0.25, 1.0 ) +var gender = 1 +var size = 1 +var slot = 0 + var dir = Vector3() const GRAVITY = -24.8 var vel = Vector3() @@ -10,7 +18,6 @@ const FLY_SPEED = 7 const DEACCEL= 16 const MAX_SLOPE_ANGLE = 40 - var MOUSE_SENSITIVITY = 0.05 onready var camera_rotation = $Camera_rotation_helper @@ -26,7 +33,7 @@ var oubli = 0 func set_info_billboard_position(): var above_head = $infos_spatial - player_infos_billboard.get_node("label").text = global.character_name + player_infos_billboard.get_node("label").text = self.pseudo var offset = Vector2(-(player_infos_billboard.get_size().x/2), 0) var unprojected_translation = camera.unproject_position(above_head.global_transform.xform(Vector3(0,0,0))) player_infos_billboard.rect_position = (unprojected_translation + offset) @@ -35,17 +42,20 @@ func _ready(): # camera.make_current() show_face_camera() set_info_billboard_position() + self.update() #func _enter_tree(): # print("qsdfghjklkjhgfdsqsdfghj") # if self.get_parent().has_node( "start_position" ): # self.translation = self.get_parent().get_node( "start_position" ).translation -func update( start_position ): +func update( start_position = null ): if start_position: self.translation = start_position.translation self.rotation = start_position.rotation - $MeshInstance.get_surface_material(0).set_shader_param( "albedo", global.character_color ) + + self.scale = Vector3( self.size, self.size, self.size ) + $MeshInstance.get_surface_material(0).set_shader_param( "albedo", self.color ) func _process(delta): process_input(delta) diff --git a/scenes/Game/Character/Character.tscn b/scenes/Game/Character/Character.tscn index 848ca16..9b3390a 100644 --- a/scenes/Game/Character/Character.tscn +++ b/scenes/Game/Character/Character.tscn @@ -67,7 +67,7 @@ _sections_unfolded = [ "shader_param" ] radius = 0.520354 -[node name="Character" type="KinematicBody" index="0"] +[node name="Character" type="KinematicBody"] transform = Transform( 0.371345, 0, 0, 0, 0.218854, 0, 0, 0, 0.371345, -0.00167466, -0.475751, 6.02408 ) input_ray_pickable = true @@ -93,7 +93,7 @@ script = ExtResource( 2 ) visible = false mouse_default_cursor_shape = 2 -_sections_unfolded = [ "Mouse", "Rect", "Size Flags", "Visibility" ] +_sections_unfolded = [ "Focus", "Mouse", "Rect", "Size Flags", "Visibility" ] [node name="Camera_rotation_helper" type="Spatial" parent="." index="1"] @@ -116,17 +116,17 @@ _sections_unfolded = [ "Transform" ] [node name="face_camera" type="Camera" parent="Camera_rotation_helper" index="1"] -transform = Transform( -1, 0, -8.74228e-008, 0, 1, 0, 8.74228e-008, 0, -1, 0, 4.27531, -0.805639 ) +transform = Transform( -1, 0, -8.74228e-008, 0, 1, 0, 8.74228e-008, 0, -1, 0, 4.27532, -2.96733 ) keep_aspect = 1 cull_mask = 1048575 environment = null h_offset = 0.0 v_offset = 0.0 doppler_tracking = 0 -projection = 0 +projection = 1 current = false fov = 70.0 -size = 1.0 +size = 2.0 near = 0.05 far = 100.0 _sections_unfolded = [ "Transform" ]