2020-10-15 17:23:55 +00:00
|
|
|
extends Spatial
|
|
|
|
|
|
|
|
onready var character = $character
|
|
|
|
var is_over_ui = false
|
|
|
|
|
|
|
|
|
|
|
|
func _ready():
|
2021-05-27 21:56:16 +00:00
|
|
|
|
|
|
|
$creature_creation_menu._on_race_id_pressed( 0 )
|
|
|
|
$creature_creation_menu._on_sex_id_pressed( 0 )
|
2020-10-15 17:23:55 +00:00
|
|
|
|
2021-05-27 21:56:16 +00:00
|
|
|
if Globals.creatures_editor_mode == Globals.CREATURES_EDITOR_MODE.player:
|
|
|
|
$creature_creation_menu/margin_box/window_box/content_box/tabs_box/definition/race.hide()
|
|
|
|
elif Globals.creatures_editor_mode == Globals.CREATURES_EDITOR_MODE.npc:
|
|
|
|
$creature_creation_menu.max_caracteristiques_points = 999
|
|
|
|
$creature_creation_menu/margin_box/window_box/tools_box/buttons_box/choose.hide()
|
2020-10-15 17:23:55 +00:00
|
|
|
|
|
|
|
func _input( event ):
|
|
|
|
|
2021-05-27 21:56:16 +00:00
|
|
|
if event is InputEventMouseMotion and Input.is_mouse_button_pressed( 1 ):
|
|
|
|
if self.character and not self.is_over_ui:
|
|
|
|
self.character.rotate_y( event.relative.x *0.01 )
|
|
|
|
|
|
|
|
if event is InputEventMouseMotion and Input.is_mouse_button_pressed( 3 ):
|
|
|
|
if not self.is_over_ui:
|
|
|
|
if $camera.current:
|
|
|
|
$camera.translation.x -= event.relative.x *0.001
|
|
|
|
$camera.translation.y += event.relative.y *0.001
|
|
|
|
elif $camera_head.current:
|
|
|
|
$camera_head.translation.x -= event.relative.x *0.001
|
|
|
|
$camera_head.translation.y += event.relative.y *0.001
|
|
|
|
|
|
|
|
if event.is_action_pressed( "camera_zoom_in" ) and not self.is_over_ui:
|
|
|
|
if $camera.current:
|
|
|
|
$camera.size -= 0.1
|
|
|
|
elif $camera_head.current:
|
|
|
|
$camera_head.size -= 0.1
|
|
|
|
|
|
|
|
elif event.is_action_pressed( "camera_zoom_out" ) and not self.is_over_ui:
|
|
|
|
if $camera.current:
|
|
|
|
$camera.size += 0.1
|
|
|
|
elif $camera_head.current:
|
|
|
|
$camera_head.size += 0.1
|
2020-10-15 17:23:55 +00:00
|
|
|
|
|
|
|
func _on_creature_creation_menu_updated(value_name, value):
|
|
|
|
|
2021-05-27 21:56:16 +00:00
|
|
|
var need_model_change = false
|
|
|
|
if value_name == "race":
|
|
|
|
need_model_change = true
|
|
|
|
elif value_name == "sex":
|
|
|
|
need_model_change = true
|
|
|
|
|
|
|
|
var need_creature_update =false
|
|
|
|
if self.character:
|
|
|
|
self.character.get_node( "creature" ).creature.set_data( value_name, value )
|
|
|
|
need_creature_update = true
|
|
|
|
|
|
|
|
if need_model_change:
|
|
|
|
var old_creature_datas = null
|
|
|
|
if self.character:
|
|
|
|
old_creature_datas = self.character.get_node( "creature" ).creature
|
|
|
|
var race = old_creature_datas.get_data( "race" )
|
|
|
|
var sex = old_creature_datas.get_data( "sex" )
|
|
|
|
if race == Globals.RACE.human and sex == Globals.SEX.female:
|
|
|
|
self.character.show()
|
|
|
|
self.character.change_creature( "res://scenes/creatures/human/human_female.tscn" )
|
|
|
|
need_creature_update = true
|
|
|
|
elif race == Globals.RACE.human and sex == Globals.SEX.male:
|
|
|
|
self.character.show()
|
|
|
|
self.character.change_creature( "res://scenes/creatures/human/human_male.tscn" )
|
|
|
|
need_creature_update = true
|
|
|
|
|
|
|
|
if self.character and old_creature_datas:
|
|
|
|
self.character.get_node( "creature" ).creature = old_creature_datas
|
|
|
|
|
|
|
|
if need_creature_update:
|
|
|
|
if self.character:
|
|
|
|
self.character.get_node( "creature" ).update()
|
|
|
|
|
2020-10-15 17:23:55 +00:00
|
|
|
|
|
|
|
func save_creature():
|
2021-05-27 21:56:16 +00:00
|
|
|
if self.character:
|
|
|
|
var emplacement = "pc"
|
|
|
|
if Globals.creatures_editor_mode == Globals.CREATURES_EDITOR_MODE.npc:
|
|
|
|
emplacement = "res"
|
|
|
|
self.character.get_node( "creature" ).creature.save( emplacement )
|
|
|
|
$creature_creation_menu/margin_box/window_box/tooltips.text = "Créature enregistrée."
|
|
|
|
$creature_creation_menu/margin_box/window_box/tooltips.set( "custom_colors/font_color", Color.green )
|
2020-10-15 17:23:55 +00:00
|
|
|
|
|
|
|
func load_creature( p_name = null ):
|
2021-05-27 21:56:16 +00:00
|
|
|
var creature = null
|
|
|
|
|
|
|
|
var race = Globals.get_race_id( $creature_creation_menu/margin_box/window_box/content_box/tabs_box/definition/race/value.text )
|
|
|
|
if race == Globals.RACE.human:
|
|
|
|
creature = Datas.Human.new()
|
|
|
|
else:
|
|
|
|
creature = Datas.Creature.new()
|
|
|
|
var filename = $creature_creation_menu/margin_box/window_box/content_box/tabs_box/definition/name/value/first_name.text + "_" + $creature_creation_menu/margin_box/window_box/content_box/tabs_box/definition/name/value/last_name.text+".creature"
|
|
|
|
if p_name:
|
|
|
|
filename = p_name + ".creature"
|
|
|
|
|
|
|
|
if Globals.creatures_editor_mode == Globals.CREATURES_EDITOR_MODE.npc:
|
|
|
|
creature.load( "res://ressources/files/creatures/"+filename )
|
|
|
|
else:
|
|
|
|
creature.load( "user://saves/save_temp/ressources/files/creatures/pc/"+filename )
|
|
|
|
|
|
|
|
if creature.get_filename() == "unknow.creature":
|
|
|
|
$creature_creation_menu/margin_box/window_box/tooltips.text = "Echec du chargement de la créature."
|
|
|
|
$creature_creation_menu/margin_box/window_box/tooltips.set( "custom_colors/font_color", Color.red )
|
|
|
|
else:
|
|
|
|
$creature_creation_menu/margin_box/window_box/tooltips.text = "Créature chargée avec succès."
|
|
|
|
$creature_creation_menu/margin_box/window_box/tooltips.set( "custom_colors/font_color", Color.green )
|
|
|
|
|
|
|
|
$creature_creation_menu.update_sliders( creature )
|
2020-10-15 17:23:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_creature_creation_menu_mouse_entered_ui():
|
2021-05-27 21:56:16 +00:00
|
|
|
self.is_over_ui = true
|
2020-10-15 17:23:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_creature_creation_menu_mouse_exited_ui():
|
2021-05-27 21:56:16 +00:00
|
|
|
self.is_over_ui = false
|
2020-10-15 17:23:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_creature_creation_menu_load_pressed():
|
2021-05-27 21:56:16 +00:00
|
|
|
self.load_creature()
|
2020-10-15 17:23:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_creature_creation_menu_save_pressed():
|
2021-05-27 21:56:16 +00:00
|
|
|
self.save_creature()
|
2020-10-15 17:23:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_creature_creation_menu_choose_pressed():
|
2021-05-27 21:56:16 +00:00
|
|
|
self.save_creature()
|
|
|
|
Globals.player_name = $creature_creation_menu/margin_box/window_box/content_box/tabs_box/definition/name/value/first_name.text + "_" + $creature_creation_menu/margin_box/window_box/content_box/tabs_box/definition/name/value/last_name.text
|
|
|
|
Globals.goto_scene( "res://scenes/game/game.tscn" )
|
2020-10-15 17:23:55 +00:00
|
|
|
|
|
|
|
func _on_creature_creation_menu_quit_pressed():
|
2021-05-27 21:56:16 +00:00
|
|
|
Globals.goto_scene( "res://scenes/main/main.tscn" )
|
2020-10-15 17:23:55 +00:00
|
|
|
|
|
|
|
func _on_creature_creation_menu_cloths_button_toggled(button_pressed):
|
2021-05-27 21:56:16 +00:00
|
|
|
if $character/creature.creature.get_data( "sex" ) == Globals.SEX.female:
|
|
|
|
if button_pressed:
|
|
|
|
$character/creature/cloths/mh_human_female_tshirt.show()
|
|
|
|
$character/creature/cloths/mh_human_female_pant.show()
|
|
|
|
$character/creature/cloths/mh_human_female_shoes.show()
|
|
|
|
else:
|
|
|
|
$character/creature/cloths/mh_human_female_tshirt.hide()
|
|
|
|
$character/creature/cloths/mh_human_female_pant.hide()
|
|
|
|
$character/creature/cloths/mh_human_female_shoes.hide()
|
|
|
|
elif $character/creature.creature.get_data( "sex" ) == Globals.SEX.male:
|
|
|
|
if button_pressed:
|
|
|
|
$character/creature/cloths/mh_human_male_tshirt.show()
|
|
|
|
$character/creature/cloths/mh_human_male_pant.show()
|
|
|
|
$character/creature/cloths/mh_human_male_shoes.show()
|
|
|
|
else:
|
|
|
|
$character/creature/cloths/mh_human_male_tshirt.hide()
|
|
|
|
$character/creature/cloths/mh_human_male_pant.hide()
|
|
|
|
$character/creature/cloths/mh_human_male_shoes.hide()
|
2020-10-15 17:23:55 +00:00
|
|
|
|
|
|
|
func _on_creature_creation_menu_underwear_button_toggled(button_pressed):
|
2021-05-27 21:56:16 +00:00
|
|
|
pass
|
2020-10-15 17:23:55 +00:00
|
|
|
# if button_pressed:
|
|
|
|
# $character/creature/cloths/mh_human_female_underwear_top.show()
|
|
|
|
# $character/creature/cloths/mh_human_female_underwear_bottom.show()
|
|
|
|
# else:
|
|
|
|
# $character/creature/cloths/mh_human_female_underwear_top.hide()
|
|
|
|
# $character/creature/cloths/mh_human_female_underwear_bottom.hide()
|
|
|
|
|
|
|
|
|
|
|
|
func _on_creature_creation_menu_zoom_head_button_toggled(button_pressed):
|
2021-05-27 21:56:16 +00:00
|
|
|
if button_pressed:
|
|
|
|
$camera_head.make_current()
|
|
|
|
else:
|
|
|
|
$camera.make_current()
|