amelioration de la selection/creation de personnage.

This commit is contained in:
osquallo 2018-08-08 14:31:51 +02:00
parent e068c04f3e
commit c7f0b0aa16
12 changed files with 101 additions and 67 deletions

View file

@ -1,32 +1,20 @@
extends Node
# class member variables go here, for example:
# var a = 2
# var b = "textvar"
const WINDOW_TITLE_INPUT = "GUI/Settings/Menus/TabContainer/Test/ScrollContainer/VBoxContainer/TitleBox/Title"
func _ready():
change_title()
get_tree().get_root().connect("size_changed", self, "on_window_size_changed")
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) )
global.character.get_node( "MeshInstance" ).get_surface_material(0).albedo_color = global.character_color
print( str(global.character_name) )
print( str(global.character_color) )
$GUI.pause()
global.character_camera.make_current()
# $Game.hide()
#
# # BugGodot?: Meme si tous les nodes parent sont caché les gridmaps s'affichent quand meme :/
# # ce qui les rends quelque peu inutilisables.
# $Game/World/GridMaps/Ground.hide()
# $Game/World/GridMaps/wall.hide()
# $Game/World/GridMaps/ceilling.hide()
func _process(delta):
pass

View file

@ -12,14 +12,25 @@ func _on_login_menu_login_button_pressed():
func _on_character_creation_menu_valid_button_pressed():
$character_creation_menu.hide()
emit_signal( "character_creation_finished" )
func _on_character_selection_menu_character_selected(slot):
print( "selected character slot "+str( slot )+"." )
func _on_character_selection_menu_character_selected( slot ):
global.character_slot = slot
$character_selection_menu.hide()
$character_creation_menu.show()
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) ):
global.character_name = config_file.get_value(str(global.character_slot), "name" )
global.character_color = config_file.get_value(str(global.character_slot), "color" )
emit_signal( "character_creation_finished" )
else:
$character_selection_menu.hide()
$character_creation_menu.show()
func _on_character_creation_menu_return_button_pressed():

View file

@ -2,10 +2,6 @@ extends MarginContainer
signal character_creation_finished
#func _ready():
# $Home.show()
# $Settings.hide()
func _on_Home_setting_pressed():
$Home.hide()
$Settings.show()

View file

@ -14,7 +14,7 @@
[ext_resource path="res://scenes/GUI/HUD/trauma.gd" type="Script" id=12]
[ext_resource path="res://scenes/GUI/HUD/douleur.gd" type="Script" id=13]
[node name="HUD" type="MarginContainer" index="0"]
[node name="HUD" type="MarginContainer"]
anchor_left = 0.0
anchor_top = 0.0

View file

@ -1,6 +1,6 @@
extends Control
var player_mesh = null
var character_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
@ -8,21 +8,25 @@ signal valid_button_pressed
signal return_button_pressed
func _ready():
player_mesh = $v_box_container/h_box_container/center_container/character_creation_scene/mesh_instance
character_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:
player_mesh.get_surface_material(0).albedo_color = Color( 1.0, 0.25, 0.25, 1.0 )
global.character_sex = 1
character_mesh.get_surface_material(0).albedo_color = Color( 1.0, 0.25, 0.25, 1.0 )
else:
player_mesh.get_surface_material(0).albedo_color = Color( 0.0, 0.0, 1.0, 1.0 )
global.character_sex = 0
character_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
global.character_name = name_input.text
global.character_color = character_mesh.get_surface_material(0).albedo_color
emit_signal( "valid_button_pressed" )

View file

@ -4,7 +4,7 @@
[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]
[sub_resource type="DynamicFont" id=1]
size = 14
use_mipmaps = false
@ -12,19 +12,19 @@ use_filter = false
font_data = ExtResource( 1 )
_sections_unfolded = [ "Extra Spacing", "Font", "Settings" ]
[sub_resource type="Theme" id=4]
[sub_resource type="Theme" id=2]
default_font = SubResource( 3 )
default_font = SubResource( 1 )
[sub_resource type="Gradient" id=1]
[sub_resource type="Gradient" id=3]
offsets = PoolRealArray( 0 )
colors = PoolColorArray( 0, 0, 0, 1 )
[sub_resource type="GradientTexture" id=2]
[sub_resource type="GradientTexture" id=4]
flags = 4
gradient = SubResource( 1 )
gradient = SubResource( 3 )
width = 2048
[sub_resource type="DynamicFont" id=5]
@ -47,7 +47,7 @@ mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
theme = SubResource( 4 )
theme = SubResource( 2 )
script = ExtResource( 2 )
_sections_unfolded = [ "Theme" ]
@ -161,7 +161,7 @@ mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
texture = SubResource( 2 )
texture = SubResource( 4 )
_sections_unfolded = [ "Material", "Size Flags", "Visibility" ]
[node name="margin_container" type="MarginContainer" parent="v_box_container/h_box_container/margin_container" index="1"]

View file

@ -4,21 +4,52 @@ signal character_selected( slot )
signal return_button_pressed
func _ready():
# Called when the node is added to the scene for the first time.
# Initialization here
pass
#func _process(delta):
# # Called every frame. Delta is time since last frame.
# # Update game logic here.
# pass
var config_file = ConfigFile.new()
var err = config_file.load( "user://player.cfg" )
if err:
print("Error code when loading player config file: ", err)
var last_slot = 0
for section in config_file.get_sections():
last_slot = int(section)
var character_name = config_file.get_value( section, "name" )
var slot_box = HBoxContainer.new()
slot_box.size_flags_horizontal = SIZE_FILL
slot_box.size_flags_vertical = SIZE_EXPAND
$h_box_container/character_slots.add_child( slot_box )
slot_box.set_owner( $h_box_container/character_slots )
var label_name = Label.new()
label_name.text = character_name
slot_box.add_child( label_name )
label_name.set_owner( slot_box )
var choose_button = Button.new()
choose_button.text = "choose"
slot_box.add_child( choose_button )
choose_button.set_owner( slot_box )
choose_button.connect( "pressed", self, "_on_choose_pressed", [int(section)] )
var create_new_characer_button = Button.new()
create_new_characer_button.text = "Create"
create_new_characer_button.hint_tooltip = "Create a new character"
$h_box_container/character_slots.add_child( create_new_characer_button )
create_new_characer_button.set_owner( $h_box_container/character_slots )
create_new_characer_button.connect( "pressed", self, "_on_choose_pressed", [int(last_slot)+1] )
func _on_return_button_pressed():
emit_signal( "return_button_pressed" )
func _on_choose_pressed( slot ):
emit_signal( "character_selected", slot )
func _on_slot0_character_button_pressed():
emit_signal( "character_selected", 0 )
emit_signal( "character_selected", 0 )
func _on_slot1_character_button_pressed():
emit_signal( "character_selected", 1 )

View file

@ -4,7 +4,7 @@
[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]
[node name="character_selection_menu" type="Control"]
[node name="character_selection_menu" type="Control" index="0"]
anchor_left = 0.0
anchor_top = 0.0
@ -56,7 +56,7 @@ anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 342.0
margin_right = 54.0
margin_bottom = 600.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
@ -92,6 +92,7 @@ _sections_unfolded = [ "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
@ -160,13 +161,14 @@ _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 = 402.0
margin_top = 302.0
margin_right = 342.0
margin_bottom = 530.0
margin_bottom = 430.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
@ -232,7 +234,7 @@ anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 346.0
margin_left = 58.0
margin_right = 1024.0
margin_bottom = 600.0
rect_pivot_offset = Vector2( 0, 0 )

View file

@ -21,7 +21,7 @@ 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
player_infos_billboard.get_node("label").text = global.character_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)

View file

@ -28,15 +28,16 @@ func change_title():
title += " (" + String(OS.get_window_size().x) + "x" + String(OS.get_window_size().y) + ")"
OS.set_window_title( title )
#func _on_GUI_character_creation_finished():
# $Game.show()
# $Game/World/GridMaps/Ground.show()
# $Game/World/GridMaps/wall.show()
# $Game/World/GridMaps/ceilling.show()
# global.character_camera.make_current()
# $GUI/character_creation_menu/v_box_container/h_box_container/center_container/character_creation_scene.hide()
# $Game/Character/MeshInstance.get_surface_material(0).albedo_color = $GUI/character_creation_menu/v_box_container/h_box_container/center_container/character_creation_scene/mesh_instance.get_surface_material(0).albedo_color
func _on_login_scene_character_creation_finished():
var config_file = ConfigFile.new()
var err = config_file.load( "user://player.cfg" )
if err:
print("Error code when loading 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.save( "user://player.cfg" )
print("test")
global.goto_scene_loading( "res://game_scene/game_scene.tscn" )

View file

@ -5,7 +5,7 @@
[ext_resource path="res://assets/GUI/loading_screens/new_loading_bg_0.tga" type="Texture" id=3]
[ext_resource path="res://assets/GUI/loading_screens/new_loading_bg_1.tga" type="Texture" id=4]
[node name="Main" type="Node" index="0"]
[node name="Main" type="Node"]
script = ExtResource( 1 )
_sections_unfolded = [ "Pause" ]

View file

@ -6,8 +6,9 @@ var character_camera = null
var character_creation_mesh = null
var character_creation_camera = null
var player_name = null
var player_color = null
var character_name = null
var character_color = null
var character_sex = null
var character_slot = null
# BG loader