Ajout d'un apercu lors de la selection du personnage

This commit is contained in:
osquallo 2018-08-09 11:07:21 +02:00
parent d6a0c69205
commit 8fa563afb4
3 changed files with 180 additions and 169 deletions

View file

@ -0,0 +1,98 @@
[gd_scene load_steps=3 format=2]
[sub_resource type="SphereMesh" id=1]
custom_aabb = AABB( 0, 0, 0, 0, 0, 0 )
radius = 1.0
height = 2.0
radial_segments = 64
rings = 32
is_hemisphere = false
[sub_resource type="SpatialMaterial" id=2]
render_priority = 0
flags_transparent = false
flags_unshaded = false
flags_vertex_lighting = false
flags_no_depth_test = false
flags_use_point_size = false
flags_world_triplanar = false
flags_fixed_size = false
flags_albedo_tex_force_srgb = false
vertex_color_use_as_albedo = false
vertex_color_is_srgb = false
params_diffuse_mode = 0
params_specular_mode = 0
params_blend_mode = 0
params_cull_mode = 0
params_depth_draw_mode = 0
params_line_width = 1.0
params_point_size = 1.0
params_billboard_mode = 0
params_grow = false
params_use_alpha_scissor = false
albedo_color = Color( 1, 0.247059, 0.247059, 1 )
metallic = 0.0
metallic_specular = 0.5
metallic_texture_channel = 0
roughness = 0.0
roughness_texture_channel = 0
emission_enabled = false
normal_enabled = false
rim_enabled = false
clearcoat_enabled = false
anisotropy_enabled = false
ao_enabled = false
depth_enabled = false
subsurf_scatter_enabled = false
transmission_enabled = false
refraction_enabled = false
detail_enabled = false
uv1_scale = Vector3( 1, 1, 1 )
uv1_offset = Vector3( 0, 0, 0 )
uv1_triplanar = false
uv1_triplanar_sharpness = 1.0
uv2_scale = Vector3( 1, 1, 1 )
uv2_offset = Vector3( 0, 0, 0 )
uv2_triplanar = false
uv2_triplanar_sharpness = 1.0
proximity_fade_enable = false
distance_fade_enable = false
_sections_unfolded = [ "Albedo" ]
[node name="character_preview" type="Spatial"]
[node name="camera" type="Camera" parent="." index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 2.38397 )
keep_aspect = 1
cull_mask = 1048575
environment = null
h_offset = 0.0
v_offset = 0.0
doppler_tracking = 0
projection = 0
current = true
fov = 70.0
size = 1.0
near = 0.05
far = 100.0
[node name="character" type="MeshInstance" parent="." index="1"]
layers = 1
material_override = null
cast_shadow = 1
extra_cull_margin = 0.0
use_in_baked_light = false
lod_min_distance = 0.0
lod_min_hysteresis = 0.0
lod_max_distance = 0.0
lod_max_hysteresis = 0.0
mesh = SubResource( 1 )
skeleton = NodePath("..")
material/0 = SubResource( 2 )
_sections_unfolded = [ "material" ]

View file

@ -3,6 +3,9 @@ extends Control
signal character_selected( slot )
signal return_button_pressed
var preview_slot = 0
func _ready():
@ -17,27 +20,35 @@ func _ready():
var character_name = config_file.get_value( section, "name" )
var slot_box = HBoxContainer.new()
slot_box.name = "slot_box_"+section
slot_box.size_flags_horizontal = SIZE_FILL
slot_box.size_flags_vertical = SIZE_EXPAND
slot_box.set( "custom_constants/separation", 8)
$h_box_container/character_slots.add_child( slot_box )
slot_box.set_owner( $h_box_container/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
slot_box.add_child( label_name )
label_name.set_owner( slot_box )
# label_name.connect( "mouse_entered", self, "_on_name_mouse_entered_pressed", [int(section)] )
var choose_button = Button.new()
choose_button.text = "choose"
# choose_button.mouse_filter = MOUSE_FILTER_PASS
slot_box.add_child( choose_button )
choose_button.set_owner( slot_box )
choose_button.connect( "pressed", self, "_on_choose_pressed", [int(section)] )
choose_button.connect( "mouse_entered", self, "_on_name_mouse_entered_pressed", [int(section)] )
var delete_button = Button.new()
delete_button.text = "delete"
# delete_button.mouse_filter = MOUSE_FILTER_PASS
slot_box.add_child( delete_button )
delete_button.set_owner( slot_box )
delete_button.connect( "pressed", self, "_on_delete_pressed", [int(section), slot_box] )
delete_button.connect( "mouse_entered", self, "_on_name_mouse_entered_pressed", [int(section)] )
var create_new_characer_button = Button.new()
@ -68,7 +79,17 @@ func _on_slot0_character_button_pressed():
func _on_slot1_character_button_pressed():
emit_signal( "character_selected", 1 )
func _on_name_mouse_entered_pressed( slot ):
print("azertyuiop")
preview_slot = slot
update_preview()
func update_preview():
var slot = preview_slot
var config_file = ConfigFile.new()
var err = config_file.load( "user://player.cfg" )
if err:
print("Error code when loading player config file: ", err)
if config_file.has_section( str(slot) ):
$viewport/character_preview/character.get_surface_material(0).albedo_color = config_file.get_value( str(slot), "color" )

View file

@ -1,10 +1,16 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=5 format=2]
[ext_resource path="res://scenes/GUI/character_selection/character_selection_menu.gd" type="Script" id=1]
[ext_resource path="res://assets/GUI/images/new_launcher_bg_0-1.png" type="Texture" id=2]
[ext_resource path="res://assets/GUI/images/new_char.png" type="Texture" id=3]
[ext_resource path="res://login_scene/character_preview.tscn" type="PackedScene" id=2]
[ext_resource path="res://assets/GUI/images/new_launcher_bg_0-1.png" type="Texture" id=3]
[node name="character_selection_menu" type="Control"]
[sub_resource type="ViewportTexture" id=1]
resource_local_to_scene = true
flags = 0
viewport_path = NodePath("viewport")
[node name="character_selection_menu" type="Control" index="0"]
anchor_left = 0.0
anchor_top = 0.0
@ -18,7 +24,35 @@ size_flags_horizontal = 1
size_flags_vertical = 1
script = ExtResource( 1 )
[node name="texture_rect" type="TextureRect" parent="." index="0"]
[node name="viewport" type="Viewport" parent="." index="0"]
arvr = false
size = Vector2( 256, 256 )
own_world = false
world = null
transparent_bg = false
msaa = 0
hdr = true
disable_3d = false
usage = 2
debug_draw = 0
render_target_v_flip = false
render_target_clear_mode = 0
render_target_update_mode = 2
audio_listener_enable_2d = false
audio_listener_enable_3d = false
physics_object_picking = false
gui_disable_input = false
gui_snap_controls_to_pixels = true
shadow_atlas_size = 0
shadow_atlas_quad_0 = 2
shadow_atlas_quad_1 = 2
shadow_atlas_quad_2 = 3
shadow_atlas_quad_3 = 4
[node name="character_preview" parent="viewport" index="0" instance=ExtResource( 2 )]
[node name="texture_rect" type="TextureRect" parent="." index="1"]
anchor_left = 0.0
anchor_top = 0.0
@ -30,12 +64,12 @@ mouse_filter = 1
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
texture = ExtResource( 2 )
texture = ExtResource( 3 )
expand = true
stretch_mode = 7
_sections_unfolded = [ "Size Flags" ]
[node name="h_box_container" type="HBoxContainer" parent="." index="1"]
[node name="h_box_container" type="HBoxContainer" parent="." index="2"]
anchor_left = 0.0
anchor_top = 0.0
@ -45,13 +79,14 @@ 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 = 3
size_flags_horizontal = 2
size_flags_vertical = 2
alignment = 0
_sections_unfolded = [ "Size Flags" ]
_sections_unfolded = [ "Size Flags", "custom_constants" ]
[node name="character_slots" type="VBoxContainer" parent="h_box_container" index="0"]
editor/display_folded = true
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
@ -88,171 +123,28 @@ group = null
text = "Retour"
flat = false
align = 1
_sections_unfolded = [ "Size Flags" ]
_sections_unfolded = [ "Mouse", "Size Flags" ]
[node name="slot0_box" type="HBoxContainer" parent="h_box_container/character_slots" index="1"]
visible = false
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 201.0
margin_right = 342.0
margin_bottom = 329.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 = 2
custom_constants/separation = 8
alignment = 0
_sections_unfolded = [ "Size Flags", "custom_constants" ]
[node name="character_button" type="TextureButton" parent="h_box_container/character_slots/slot0_box" index="0"]
[node name="nine_patch_rect" type="NinePatchRect" parent="h_box_container" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 128.0
margin_bottom = 128.0
rect_min_size = Vector2( 128, 128 )
margin_left = 413.0
margin_top = 172.0
margin_right = 669.0
margin_bottom = 428.0
rect_min_size = Vector2( 256, 256 )
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 3
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
texture_normal = ExtResource( 3 )
_sections_unfolded = [ "Rect", "Size Flags", "Textures" ]
[node name="character_name" type="Button" parent="h_box_container/character_slots/slot0_box" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 136.0
margin_top = 54.0
margin_right = 342.0
margin_bottom = 74.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
text = "Créer un nouveau personnage."
flat = true
align = 1
_sections_unfolded = [ "Size Flags" ]
[node name="slot1_box" type="HBoxContainer" parent="h_box_container/character_slots" index="2"]
visible = false
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_top = 302.0
margin_right = 342.0
margin_bottom = 430.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 = 2
custom_constants/separation = 8
alignment = 0
_sections_unfolded = [ "Size Flags", "custom_constants" ]
[node name="character_button" type="TextureButton" parent="h_box_container/character_slots/slot1_box" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 128.0
margin_bottom = 128.0
rect_min_size = Vector2( 128, 128 )
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 = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
texture_normal = ExtResource( 3 )
_sections_unfolded = [ "Rect", "Size Flags", "Textures" ]
[node name="character_name" type="Button" parent="h_box_container/character_slots/slot1_box" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 136.0
margin_top = 54.0
margin_right = 342.0
margin_bottom = 74.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
text = "Créer un nouveau personnage."
flat = true
align = 1
_sections_unfolded = [ "Size Flags" ]
[node name="container" type="Container" parent="h_box_container" index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 58.0
margin_right = 1024.0
margin_bottom = 600.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 = 3
_sections_unfolded = [ "Size Flags" ]
size_flags_horizontal = 6
size_flags_vertical = 6
texture = SubResource( 1 )
_sections_unfolded = [ "Axis Stretch", "Margin", "Rect", "Size Flags" ]
[connection signal="pressed" from="h_box_container/character_slots/return_button" to="." method="_on_return_button_pressed"]
[connection signal="pressed" from="h_box_container/character_slots/slot0_box/character_button" to="." method="_on_slot0_character_button_pressed"]
[connection signal="pressed" from="h_box_container/character_slots/slot0_box/character_name" to="." method="_on_slot0_character_button_pressed"]
[connection signal="pressed" from="h_box_container/character_slots/slot1_box/character_button" to="." method="_on_slot1_character_button_pressed"]
[connection signal="pressed" from="h_box_container/character_slots/slot1_box/character_name" to="." method="_on_slot1_character_button_pressed"]