diff --git a/game_scene/character_infos_billboard.tscn b/game_scene/character_infos_billboard.tscn new file mode 100644 index 0000000..860b3ea --- /dev/null +++ b/game_scene/character_infos_billboard.tscn @@ -0,0 +1,40 @@ +[gd_scene format=2] + +[node name="character_info_billboard" type="VBoxContainer"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_right = 40.0 +margin_bottom = 40.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 1 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 2 +size_flags_vertical = 2 +alignment = 0 +_sections_unfolded = [ "Rect", "Size Flags" ] + +[node name="label" type="Label" parent="." index="0"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_right = 40.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 = "Name" +align = 1 +percent_visible = 1.0 +lines_skipped = 0 +max_lines_visible = -1 + + diff --git a/game_scene/game_scene.gd b/game_scene/game_scene.gd index 44be287..c8f5eb8 100644 --- a/game_scene/game_scene.gd +++ b/game_scene/game_scene.gd @@ -13,8 +13,10 @@ func _ready(): global.character = get_node( "Game/Character" ) global.character_camera = get_node( "Game/Character/Camera_rotation_helper/Camera" ) - - + + global.character.get_node( "MeshInstance" ).get_surface_material(0).albedo_color = global.player_color + print( str(global.player_name) ) + print( str(global.player_color) ) $GUI.pause() global.character_camera.make_current() @@ -25,7 +27,6 @@ func _ready(): # $Game/World/GridMaps/Ground.hide() # $Game/World/GridMaps/wall.hide() # $Game/World/GridMaps/ceilling.hide() - get_tree().get_root().print_tree_pretty() func _process(delta): pass diff --git a/login_scene/login_scene.gd b/login_scene/login_scene.gd index 8f3b534..4d1fb58 100644 --- a/login_scene/login_scene.gd +++ b/login_scene/login_scene.gd @@ -6,8 +6,6 @@ signal character_creation_finished func _ready(): global.character_creation_camera = get_node( "character_creation_menu/v_box_container/h_box_container/center_container/character_creation_scene/camera" ) - get_tree().get_root().print_tree_pretty() - func _on_login_menu_login_button_pressed(): $login_menu.hide() $character_selection_menu.show() diff --git a/login_scene/login_scene.tscn b/login_scene/login_scene.tscn index 4d977ff..641d318 100644 --- a/login_scene/login_scene.tscn +++ b/login_scene/login_scene.tscn @@ -5,7 +5,7 @@ [ext_resource path="res://scenes/GUI/character_selection/character_selection_menu.tscn" type="PackedScene" id=3] [ext_resource path="res://scenes/GUI/login/login_menu.tscn" type="PackedScene" id=4] -[node name="login_scene" type="Node" index="0"] +[node name="login_scene" type="Node"] script = ExtResource( 1 ) diff --git a/scenes/GUI/character_creation/character_creation_menu.gd b/scenes/GUI/character_creation/character_creation_menu.gd index 431eb95..c0e3b25 100644 --- a/scenes/GUI/character_creation/character_creation_menu.gd +++ b/scenes/GUI/character_creation/character_creation_menu.gd @@ -1,20 +1,28 @@ extends Control -var character +var player_mesh = null +var name_input = null +onready var error_label = $v_box_container/h_box_container/margin_container/margin_container/v_box_container/error_label signal valid_button_pressed signal return_button_pressed -func _ready(): - character = $v_box_container/h_box_container/center_container/character_creation_scene/mesh_instance - +func _ready(): + player_mesh = $v_box_container/h_box_container/center_container/character_creation_scene/mesh_instance + name_input = $v_box_container/h_box_container/margin_container/margin_container/v_box_container/name_box/line_edit + func _on_h_scroll_bar_value_changed(value): if value == 1: - character.get_surface_material(0).albedo_color = Color( 1.0, 0.25, 0.25, 1.0 ) + player_mesh.get_surface_material(0).albedo_color = Color( 1.0, 0.25, 0.25, 1.0 ) else: - character.get_surface_material(0).albedo_color = Color( 0.0, 0.0, 1.0, 1.0 ) + player_mesh.get_surface_material(0).albedo_color = Color( 0.0, 0.0, 1.0, 1.0 ) func _on_valid_button_pressed(): + if not name_input.text or name_input.text == "": + error_label.text = "You need to choose a character's name." + return + global.player_name = name_input.text + global.player_color = player_mesh.get_surface_material(0).albedo_color emit_signal( "valid_button_pressed" ) diff --git a/scenes/GUI/character_creation/character_creation_menu.tscn b/scenes/GUI/character_creation/character_creation_menu.tscn index d975985..c359714 100644 --- a/scenes/GUI/character_creation/character_creation_menu.tscn +++ b/scenes/GUI/character_creation/character_creation_menu.tscn @@ -1,7 +1,20 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=9 format=2] -[ext_resource path="res://scenes/GUI/character_creation/character_creation_menu.gd" type="Script" id=1] -[ext_resource path="res://scenes/GUI/character_creation/character_creation_scene.tscn" type="PackedScene" id=2] +[ext_resource path="res://assets/GUI/fonts/ryzom.ttf" type="DynamicFontData" id=1] +[ext_resource path="res://scenes/GUI/character_creation/character_creation_menu.gd" type="Script" id=2] +[ext_resource path="res://scenes/GUI/character_creation/character_creation_scene.tscn" type="PackedScene" id=3] + +[sub_resource type="DynamicFont" id=3] + +size = 14 +use_mipmaps = false +use_filter = false +font_data = ExtResource( 1 ) +_sections_unfolded = [ "Extra Spacing", "Font", "Settings" ] + +[sub_resource type="Theme" id=4] + +default_font = SubResource( 3 ) [sub_resource type="Gradient" id=1] @@ -14,6 +27,14 @@ flags = 4 gradient = SubResource( 1 ) width = 2048 +[sub_resource type="DynamicFont" id=5] + +size = 18 +use_mipmaps = false +use_filter = true +font_data = ExtResource( 1 ) +_sections_unfolded = [ "Extra Spacing", "Font", "Settings" ] + [node name="character_creation_menu" type="Control"] anchor_left = 0.0 @@ -26,7 +47,9 @@ mouse_filter = 0 mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 1 -script = ExtResource( 1 ) +theme = SubResource( 4 ) +script = ExtResource( 2 ) +_sections_unfolded = [ "Theme" ] [node name="v_box_container" type="VBoxContainer" parent="." index="0"] @@ -50,7 +73,7 @@ anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 margin_right = 1024.0 -margin_bottom = 14.0 +margin_bottom = 17.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 0 @@ -67,9 +90,9 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_left = 490.0 -margin_right = 534.0 -margin_bottom = 14.0 +margin_left = 486.0 +margin_right = 537.0 +margin_bottom = 17.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 2 @@ -88,9 +111,9 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_top = 18.0 +margin_top = 21.0 margin_right = 1024.0 -margin_bottom = 582.0 +margin_bottom = 579.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 1 @@ -106,9 +129,9 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_top = 221.0 +margin_top = 199.0 margin_right = 510.0 -margin_bottom = 343.0 +margin_bottom = 359.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 0 @@ -123,7 +146,7 @@ _sections_unfolded = [ "Material", "Size Flags", "custom_constants" ] [node name="nine_patch_rect" type="NinePatchRect" parent="v_box_container/h_box_container/margin_container" index="0"] -modulate = Color( 1, 1, 1, 0.501961 ) +modulate = Color( 1, 1, 1, 0.752941 ) anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 @@ -131,7 +154,7 @@ anchor_bottom = 0.0 margin_left = 8.0 margin_top = 8.0 margin_right = 502.0 -margin_bottom = 114.0 +margin_bottom = 152.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 2 @@ -139,7 +162,7 @@ mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 1 texture = SubResource( 2 ) -_sections_unfolded = [ "Size Flags", "Visibility" ] +_sections_unfolded = [ "Material", "Size Flags", "Visibility" ] [node name="margin_container" type="MarginContainer" parent="v_box_container/h_box_container/margin_container" index="1"] @@ -150,7 +173,7 @@ anchor_bottom = 0.0 margin_left = 8.0 margin_top = 8.0 margin_right = 502.0 -margin_bottom = 114.0 +margin_bottom = 152.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 0 @@ -172,7 +195,7 @@ anchor_bottom = 0.0 margin_left = 8.0 margin_top = 8.0 margin_right = 486.0 -margin_bottom = 98.0 +margin_bottom = 136.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 1 @@ -189,7 +212,7 @@ anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 margin_right = 478.0 -margin_bottom = 24.0 +margin_bottom = 27.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 1 @@ -206,7 +229,7 @@ anchor_right = 0.0 anchor_bottom = 0.0 margin_top = 5.0 margin_right = 237.0 -margin_bottom = 19.0 +margin_bottom = 22.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 2 @@ -228,7 +251,7 @@ anchor_right = 0.0 anchor_bottom = 0.0 margin_left = 241.0 margin_right = 478.0 -margin_bottom = 24.0 +margin_bottom = 27.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false focus_mode = 2 @@ -236,6 +259,7 @@ mouse_filter = 0 mouse_default_cursor_shape = 1 size_flags_horizontal = 3 size_flags_vertical = 1 +text = "player" focus_mode = 2 context_menu_enabled = true placeholder_text = "Enter the character's name here." @@ -247,14 +271,13 @@ _sections_unfolded = [ "Placeholder", "Size Flags" ] [node name="sexe_box" type="HBoxContainer" parent="v_box_container/h_box_container/margin_container/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 = 28.0 +margin_top = 31.0 margin_right = 478.0 -margin_bottom = 42.0 +margin_bottom = 48.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 1 @@ -270,7 +293,7 @@ anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 margin_right = 237.0 -margin_bottom = 14.0 +margin_bottom = 17.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 2 @@ -292,7 +315,7 @@ anchor_right = 0.0 anchor_bottom = 0.0 margin_left = 241.0 margin_right = 478.0 -margin_bottom = 14.0 +margin_bottom = 17.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 1 @@ -309,7 +332,7 @@ anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 margin_right = 12.0 -margin_bottom = 14.0 +margin_bottom = 17.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 2 @@ -328,7 +351,7 @@ anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 margin_left = 16.0 -margin_right = 226.0 +margin_right = 225.0 margin_bottom = 12.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false @@ -352,9 +375,9 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_left = 230.0 +margin_left = 229.0 margin_right = 237.0 -margin_bottom = 14.0 +margin_bottom = 17.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 2 @@ -366,15 +389,39 @@ percent_visible = 1.0 lines_skipped = 0 max_lines_visible = -1 -[node name="valid_button" type="Button" parent="v_box_container/h_box_container/margin_container/margin_container/v_box_container" index="2"] +[node name="error_label" type="Label" parent="v_box_container/h_box_container/margin_container/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 = 46.0 +margin_top = 52.0 margin_right = 478.0 -margin_bottom = 66.0 +margin_bottom = 74.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 +custom_fonts/font = SubResource( 5 ) +custom_colors/font_color = Color( 1, 0, 0, 1 ) +align = 1 +autowrap = true +percent_visible = 1.0 +lines_skipped = 0 +max_lines_visible = -1 +_sections_unfolded = [ "custom_colors", "custom_fonts", "custom_styles" ] + +[node name="valid_button" type="Button" parent="v_box_container/h_box_container/margin_container/margin_container/v_box_container" index="3"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_top = 78.0 +margin_right = 478.0 +margin_bottom = 101.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false focus_mode = 2 @@ -390,15 +437,15 @@ text = "Valider" flat = false align = 1 -[node name="return_button" type="Button" parent="v_box_container/h_box_container/margin_container/margin_container/v_box_container" index="3"] +[node name="return_button" type="Button" parent="v_box_container/h_box_container/margin_container/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 = 70.0 +margin_top = 105.0 margin_right = 478.0 -margin_bottom = 90.0 +margin_bottom = 128.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false focus_mode = 2 @@ -422,7 +469,7 @@ anchor_right = 0.0 anchor_bottom = 0.0 margin_left = 514.0 margin_right = 1024.0 -margin_bottom = 564.0 +margin_bottom = 558.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 0 @@ -432,7 +479,7 @@ size_flags_vertical = 1 use_top_left = false _sections_unfolded = [ "Size Flags", "Visibility" ] -[node name="character_creation_scene" parent="v_box_container/h_box_container/center_container" index="0" instance=ExtResource( 2 )] +[node name="character_creation_scene" parent="v_box_container/h_box_container/center_container" index="0" instance=ExtResource( 3 )] [node name="footer" type="CenterContainer" parent="v_box_container" index="2"] @@ -441,7 +488,7 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_top = 586.0 +margin_top = 583.0 margin_right = 1024.0 margin_bottom = 600.0 rect_pivot_offset = Vector2( 0, 0 ) @@ -459,9 +506,9 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -margin_left = 493.0 -margin_right = 531.0 -margin_bottom = 14.0 +margin_left = 490.0 +margin_right = 533.0 +margin_bottom = 17.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 2 diff --git a/scenes/Game/Character/Character.gd b/scenes/Game/Character/Character.gd index ea1a8c2..304f62d 100644 --- a/scenes/Game/Character/Character.gd +++ b/scenes/Game/Character/Character.gd @@ -10,23 +10,40 @@ const FLY_SPEED = 7 const DEACCEL= 16 const MAX_SLOPE_ANGLE = 40 -var camera_rotation -var camera -var flashlight var MOUSE_SENSITIVITY = 0.05 +onready var camera_rotation = $Camera_rotation_helper +onready var camera = $Camera_rotation_helper/Camera +onready var player_infos_billboard = $infos_spatial/character_infos_billboard +onready var player_mesh = $MeshInstance +onready var flashlight = $MeshInstance/Flashlight + +func set_info_billboard_position(): + var above_head = $infos_spatial + player_infos_billboard.get_node("label").text = global.player_name + var offset = Vector2(-(player_infos_billboard.get_size().x/2), 0) +# var offset = Vector2( 0.0, 0.0 ) +# player_infos_billboard.rect_position = (camera.unproject_position(above_head.get_translation()) - offset) + var unprojected_translation = camera.unproject_position(above_head.global_transform.xform(Vector3(0,0,0))) +# player_infos_billboard.rect_position = Vector2( unprojected_translation.x, unprojected_translation.y + player_infos_billboard.rect_position = (unprojected_translation + offset) +# player_infos_billboard.rect_position = Vector2( above_head.get_translation().x, above_head.get_translation().y ) func _ready(): - camera_rotation = $Camera_rotation_helper - camera = $Camera_rotation_helper/Camera +# camera_rotation = $Camera_rotation_helper +# camera = $Camera_rotation_helper/Camera camera.make_current() - flashlight = $MeshInstance/Flashlight + + set_info_billboard_position() + + func _process(delta): process_input(delta) process_movement(delta) + set_info_billboard_position() func process_input(delta): if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED: diff --git a/scenes/Game/Character/Character.tscn b/scenes/Game/Character/Character.tscn index e819aeb..82ce769 100644 --- a/scenes/Game/Character/Character.tscn +++ b/scenes/Game/Character/Character.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://scenes/Game/Character/Character.gd" type="Script" id=1] +[ext_resource path="res://game_scene/character_infos_billboard.tscn" type="PackedScene" id=2] [sub_resource type="SphereShape" id=1] @@ -66,7 +67,7 @@ uv2_triplanar_sharpness = 1.0 proximity_fade_enable = false distance_fade_enable = false -[node name="Character" type="KinematicBody"] +[node name="Character" type="KinematicBody" index="0"] transform = Transform( 1, 0, 0, 0, 0.589355, 0, 0, 0, 1, -0.0409546, 1.06519, 6.02408 ) input_ray_pickable = true @@ -81,7 +82,7 @@ axis_lock_angular_y = false axis_lock_angular_z = false collision/safe_margin = 0.001 script = ExtResource( 1 ) -_sections_unfolded = [ "Axis Lock", "collision" ] +_sections_unfolded = [ "Axis Lock", "Transform", "collision" ] [node name="Camera_rotation_helper" type="Spatial" parent="." index="0"] @@ -113,6 +114,7 @@ _sections_unfolded = [ "Transform" ] [node name="MeshInstance" type="MeshInstance" parent="." index="2"] +editor/display_folded = true transform = Transform( 0.281766, 0, 0, 0, 0.491282, 0, 0, 0, 0.26834, 0.0433697, 4.3256, 0 ) layers = 1 material_override = null @@ -151,4 +153,10 @@ spot_angle = 22.2473 spot_angle_attenuation = 1.0 _sections_unfolded = [ "Light", "Shadow" ] +[node name="infos_spatial" type="Spatial" parent="." index="3"] + +transform = Transform( 0.281766, 0, 0, 0, 0.491282, 0, 0, 0, 0.26834, 0.0433697, 5.31268, 0 ) + +[node name="character_infos_billboard" parent="infos_spatial" index="0" instance=ExtResource( 2 )] + diff --git a/scenes/global.gd b/scenes/global.gd index 34dd179..bcd7085 100644 --- a/scenes/global.gd +++ b/scenes/global.gd @@ -3,8 +3,12 @@ extends Node var current_scene = null var character = null var character_camera = null +var character_creation_mesh = null var character_creation_camera = null +var player_name +var player_color + func _ready(): var root = get_tree().get_root() # current_scene = root.get_child(root.get_child_count() -1)