197 lines
7 KiB
GDScript
197 lines
7 KiB
GDScript
extends Control
|
|
|
|
|
|
signal select_race(race)
|
|
signal update_blend(name_property, value)
|
|
|
|
var rng = RandomNumberGenerator.new()
|
|
var current_race = "raference"
|
|
|
|
const syllabe = ["ba", "be", "bi", "bo", "bu", "bou", "by",
|
|
"ca", "ce", "ci", "co", "cu", "cou", "cy",
|
|
"da", "de", "di", "do", "du", "dou", "dy",
|
|
"fa", "fe", "fi", "fo", "fu", "fou", "fy",
|
|
"ga", "ge", "gi", "go", "gu", "gou", "gy",
|
|
"ha", "he", "hi", "ho", "hu", "hou", "hy",
|
|
"ja", "je", "ji", "jo", "ju", "jou", "jy",
|
|
"ka", "ke", "ki", "ko", "ku", "kou", "ky",
|
|
"la", "le", "li", "lo", "lu", "lou", "ly",
|
|
"ma", "me", "mi", "mo", "mu", "mou", "my",
|
|
"na", "ne", "ni", "no", "nu", "nou", "ny",
|
|
"pa", "pe", "pi", "po", "pu", "pou", "py",
|
|
"qa", "qe", "qi", "qo", "qu", "qou", "qy",
|
|
"ra", "re", "ri", "ro", "ru", "rou", "sy",
|
|
"sa", "se", "si", "so", "su", "sou", "sy",
|
|
"ta", "te", "ti", "to", "tu", "tou", "ty",
|
|
"va", "ve", "vi", "vo", "vu", "vou", "vy",
|
|
"wa", "we", "wi", "wo", "wu", "wou", "wy",
|
|
"xa", "xe", "xi", "xo", "xu", "xou", "xy",
|
|
"za", "ze", "zi", "zo", "zu", "zou", "zy"
|
|
]
|
|
|
|
const arche_begin = []
|
|
const arche_end = ["par", "tar", "lar", "nar", "var", "xar", "rar", "sar"]
|
|
|
|
const isidor_begin = []
|
|
const isidor_end = ["por", "tor", "lor", "nor"]
|
|
|
|
const raference_begin = []
|
|
const raference_end = ["rat", "rap", "ral", "ran"]
|
|
|
|
func _ready():
|
|
rng.randomize()
|
|
$create/diplay/panel_left/margin/property.hide()
|
|
$create/diplay/panel_left/margin/name.hide()
|
|
$create/diplay/panel_left/margin/race.show()
|
|
|
|
|
|
func _on_arche_pressed():
|
|
current_race = "arche"
|
|
emit_signal("select_race", current_race)
|
|
|
|
|
|
func _on_isidor_pressed():
|
|
current_race = "isidor"
|
|
emit_signal("select_race", current_race)
|
|
|
|
|
|
func _on_raference_pressed():
|
|
current_race = "raference"
|
|
emit_signal("select_race", current_race)
|
|
|
|
|
|
func _on_quit_pressed():
|
|
Config.msg_debug("Quit")
|
|
# emit_signal( "quit_pressed" )
|
|
Globals.goto_scene( "res://scenes/interfaces/creatures_menu/creatures_menu_ui.tscn" )
|
|
|
|
|
|
func _on_race_next_pressed():
|
|
$create/diplay/panel_left/margin/race.hide()
|
|
$create/diplay/panel_left/margin/property.hide()
|
|
$create/diplay/panel_left/margin/name.show()
|
|
|
|
|
|
func _on_name_previous_pressed():
|
|
$create/diplay/panel_left/margin/property.hide()
|
|
$create/diplay/panel_left/margin/name.hide()
|
|
$create/diplay/panel_left/margin/race.show()
|
|
|
|
|
|
func _on_name_next_pressed():
|
|
$create/diplay/panel_left/margin/race.hide()
|
|
$create/diplay/panel_left/margin/name.hide()
|
|
$create/diplay/panel_left/margin/property.show()
|
|
|
|
|
|
func _on_property_previous_pressed():
|
|
$create/diplay/panel_left/margin/property.hide()
|
|
$create/diplay/panel_left/margin/race.hide()
|
|
$create/diplay/panel_left/margin/name.show()
|
|
|
|
|
|
func _on_property_next_pressed():
|
|
Config.msg_debug("First name: " + $create/diplay/panel_left/margin/name/v_box_container/FirstName/line_edit.text)
|
|
Config.msg_debug("Last name: " + $create/diplay/panel_left/margin/name/v_box_container/LastName/line_edit.text)
|
|
Config.msg_debug("Race: " + current_race)
|
|
for key in $create/diplay/panel_left/margin/property/panel/blend_shape/list.get_children():
|
|
for pop in key.get_children():
|
|
if pop is HBoxContainer:
|
|
Config.msg_debug( str(pop.name_property) + ": " + str(pop.get_node("property").value) )
|
|
Globals.player['FirstName'] = $create/diplay/panel_left/margin/name/v_box_container/FirstName/line_edit.text
|
|
Globals.player['LastName'] = $create/diplay/panel_left/margin/name/v_box_container/LastName/line_edit.text
|
|
Globals.player['Race'] = current_race
|
|
Globals.player['blend_shape'] = {}
|
|
for key in $create/diplay/panel_left/margin/property/panel/blend_shape/list.get_children():
|
|
for pop in key.get_children():
|
|
if pop is HBoxContainer:
|
|
Globals.player['blend_shape'][ str(pop.name_property) ] = pop.get_node("property").value
|
|
Globals.goto_scene("res://scenes/game/alpha.tscn")
|
|
|
|
|
|
func generate_name_key(minsyllabe:int, maxsyllabe:int, start:Array = [], end:Array = []) -> String:
|
|
var nbsyllabe = rng.randi_range(minsyllabe, maxsyllabe)
|
|
var last = rng.randi_range(0, end.size()-1)
|
|
var ret = ""
|
|
for _i in range(0, nbsyllabe):
|
|
var x = rng.randi_range(0, syllabe.size()-1)
|
|
ret += syllabe[x]
|
|
if end.size() > 0:
|
|
ret += end[last]
|
|
return ret
|
|
|
|
|
|
func generate_name():
|
|
var first_name: String = ""
|
|
var last_name: String = ""
|
|
match current_race:
|
|
"arche":
|
|
first_name = generate_name_key(1, 3, arche_begin, arche_end)
|
|
last_name = generate_name_key(2, 5)
|
|
"isidor":
|
|
first_name = generate_name_key(1, 3, isidor_begin, isidor_end)
|
|
last_name = generate_name_key(2, 5)
|
|
"raference":
|
|
first_name = generate_name_key(1, 3, raference_begin, raference_end)
|
|
last_name = generate_name_key(2, 5)
|
|
_:
|
|
first_name = "paf"
|
|
last_name = "pouf"
|
|
$create/diplay/panel_left/margin/name/v_box_container/FirstName/line_edit.text = first_name
|
|
$create/diplay/panel_left/margin/name/v_box_container/LastName/line_edit.text = last_name
|
|
|
|
|
|
func update_property( blend_shapes ):
|
|
#Config.msg_debug("")
|
|
for child in $create/diplay/panel_left/margin/property/panel/blend_shape/list.get_children():
|
|
$create/diplay/panel_left/margin/property/panel/blend_shape/list.remove_child(child)
|
|
# var list_group:Array = []
|
|
var list:Dictionary = {}
|
|
var tab:PoolStringArray
|
|
var global_box = preload( "res://scenes/creature_creation/property_label.tscn" ).instance()
|
|
global_box.get_node("label" ).text = "General"
|
|
$create/diplay/panel_left/margin/property/panel/blend_shape/list.add_child(global_box)
|
|
list["General"] = global_box
|
|
for key in blend_shapes:
|
|
tab = key.split("/", true, 1)
|
|
#Config.msg_debug(key + " : " + str(tab.size()) )
|
|
if tab.size() == 2:
|
|
if not list.has(tab[0]):
|
|
var property_label_box = preload( "res://scenes/creature_creation/property_label.tscn" ).instance()
|
|
property_label_box.get_node("label" ).text = tab[0]
|
|
$create/diplay/panel_left/margin/property/panel/blend_shape/list.add_child(property_label_box)
|
|
list[tab[0]] = property_label_box
|
|
for key in blend_shapes:
|
|
var blend_shapes_box = preload( "res://scenes/creature_creation/property_box.tscn" ).instance()
|
|
var name_prop = key
|
|
tab = key.split("/", true, 1)
|
|
if tab.size() == 2:
|
|
name_prop = tab[1]
|
|
blend_shapes_box.name_property = key
|
|
blend_shapes_box.get_node( "label" ).text = name_prop
|
|
blend_shapes_box.get_node( "property" ).min_value = 0.0
|
|
blend_shapes_box.get_node( "property" ).max_value = 1.0
|
|
blend_shapes_box.get_node( "property" ).step = 0.01
|
|
blend_shapes_box.get_node( "property" ).value = 0.0
|
|
blend_shapes_box.connect( "changed", self, "_on_creature_update_property" )
|
|
tab = key.split("/", true, 1)
|
|
if tab.size() == 2:
|
|
list[tab[0]].add_child(blend_shapes_box)
|
|
else:
|
|
list["General"].add_child(blend_shapes_box)
|
|
for key in list:
|
|
for i in list[key].get_children():
|
|
if i.has_node("property"):
|
|
var vf = rng.randf_range(0.0, 100.0) / 100.0
|
|
Config.msg_debug("de:" + str(vf))
|
|
i.get_node( "property" ).value = vf
|
|
generate_name()
|
|
|
|
|
|
func _on_creature_update_property(key, name_property):
|
|
Config.msg_debug( name_property + ": " + str(key))
|
|
emit_signal( "update_blend", name_property, key )
|
|
|
|
|
|
func _on_generate_name_pressed():
|
|
generate_name()
|