2020-03-21 09:10:26 +00:00
|
|
|
extends Control
|
|
|
|
|
|
|
|
signal name_changed( value )
|
|
|
|
signal boobs_changed( value )
|
|
|
|
signal hip_changed( value )
|
|
|
|
signal male_scrotch( value )
|
|
|
|
signal male_throat( value )
|
|
|
|
signal pregnant( value )
|
|
|
|
signal valid_pressed
|
|
|
|
signal cancel_pressed
|
|
|
|
|
|
|
|
|
|
|
|
var Creatures = preload( "res://ressources/scripts/creatures.gd" )
|
|
|
|
|
|
|
|
var mouse_old_position = null
|
|
|
|
var mouse_delta = null
|
|
|
|
var camera_zoom = 0.0
|
|
|
|
var camera_zoom_speed = 0.1
|
|
|
|
|
2020-04-04 09:29:45 +00:00
|
|
|
var ra = Creatures.Ra_old.new()
|
2020-03-21 09:10:26 +00:00
|
|
|
|
|
|
|
var slot = null
|
|
|
|
|
|
|
|
func _ready():
|
2021-05-27 21:56:16 +00:00
|
|
|
$viewport/spring_arm/camera.make_current()
|
|
|
|
|
2020-03-21 09:10:26 +00:00
|
|
|
func _input( event ):
|
2021-05-27 21:56:16 +00:00
|
|
|
|
|
|
|
if event is InputEventMouseButton:
|
|
|
|
|
|
|
|
if event.is_action_pressed( "creatures_editor_rotate_view_y" ):
|
|
|
|
self.mouse_old_position = event.position
|
|
|
|
elif event.is_action_released( "creatures_editor_rotate_view_y" ):
|
|
|
|
self.mouse_old_position = null
|
|
|
|
self.mouse_delta = null
|
|
|
|
|
|
|
|
if event.is_action( "creatures_editor_zoom_in" ):
|
|
|
|
self.camera_zoom += self.camera_zoom_speed
|
|
|
|
elif event.is_action( "creatures_editor_zoom_out" ):
|
|
|
|
self.camera_zoom -= self.camera_zoom_speed
|
|
|
|
|
|
|
|
if event is InputEventMouseMotion:
|
|
|
|
if not mouse_old_position == null:
|
|
|
|
self.mouse_delta = mouse_old_position - event.position
|
|
|
|
self.mouse_old_position = event.position
|
|
|
|
|
|
|
|
|
2020-03-21 09:10:26 +00:00
|
|
|
func _process( delta ):
|
2021-05-27 21:56:16 +00:00
|
|
|
if self.mouse_delta:
|
|
|
|
$viewport/model/ra.rotate( Vector3( 0.0, 1.0, 0.0 ), deg2rad( -self.mouse_delta.x ) )
|
|
|
|
self.mouse_delta = Vector2( 0.0, 0.0 )
|
|
|
|
|
|
|
|
if self.camera_zoom:
|
|
|
|
$viewport/spring_arm/camera.size += self.camera_zoom
|
|
|
|
self.camera_zoom = 0.0
|
2020-03-21 09:10:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
func set_creature( p_creature ):
|
2021-05-27 21:56:16 +00:00
|
|
|
if p_creature is Creatures.Ra:
|
|
|
|
self.ra = p_creature
|
|
|
|
$screen_box/tools_box/boobs/value.value = p_creature.female_boobs
|
|
|
|
$screen_box/tools_box/hip/value.value = p_creature.female_hip
|
|
|
|
$screen_box/tools_box/male_scrotch/value.value = p_creature.male_pack
|
|
|
|
$screen_box/tools_box/male_throat/value.value = p_creature.male_throat
|
|
|
|
$screen_box/tools_box/pregnant/value.value = p_creature.female_pregnant
|
|
|
|
$screen_box/tools_box/color/value.value = p_creature.color
|
2020-03-21 09:10:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_name_text_changed( new_text ):
|
2021-05-27 21:56:16 +00:00
|
|
|
self.ra.pseudonym = new_text
|
|
|
|
|
2020-03-21 09:10:26 +00:00
|
|
|
func _on_boobs_value_changed( value ):
|
2021-05-27 21:56:16 +00:00
|
|
|
$viewport/model/ra/model/body.set( "blend_shapes/Boobs", value )
|
|
|
|
self.ra.female_boobs = value
|
2020-03-21 09:10:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_hip_value_changed(value):
|
2021-05-27 21:56:16 +00:00
|
|
|
$viewport/model/ra/model/body.set( "blend_shapes/Female_hip", value )
|
|
|
|
self.ra.female_hip = value
|
2020-03-21 09:10:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_male_scrotch_value_changed(value):
|
2021-05-27 21:56:16 +00:00
|
|
|
$viewport/model/ra/model/body.set( "blend_shapes/Male_Pack", value )
|
|
|
|
self.ra.male_pack = value
|
2020-03-21 09:10:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_male_throat_value_changed(value):
|
2021-05-27 21:56:16 +00:00
|
|
|
$viewport/model/ra/model/body.set( "blend_shapes/Male_Throat", value )
|
|
|
|
self.ra.male_throat = value
|
2020-03-21 09:10:26 +00:00
|
|
|
|
|
|
|
func _on_pregnant_value_changed(value):
|
2021-05-27 21:56:16 +00:00
|
|
|
$viewport/model/ra/model/body.set( "blend_shapes/Pregnant", value )
|
|
|
|
self.ra.female_pregnant = value
|
2020-03-21 09:10:26 +00:00
|
|
|
|
|
|
|
func _on_valid_pressed():
|
2021-05-27 21:56:16 +00:00
|
|
|
if not self.slot == null:
|
|
|
|
var directory = Directory.new()
|
|
|
|
if not directory.dir_exists( "user://creatures/" ):
|
|
|
|
directory.make_dir_recursive( "user://creatures/" )
|
2020-03-21 09:10:26 +00:00
|
|
|
|
2021-05-27 21:56:16 +00:00
|
|
|
var creature_file = File.new()
|
|
|
|
creature_file.open("user://creatures/slot_"+str(self.slot)+".creature", File.WRITE)
|
|
|
|
creature_file.store_line(to_json(self.ra.to_dictionary()))
|
|
|
|
creature_file.close()
|
2020-03-21 09:10:26 +00:00
|
|
|
|
2021-05-27 21:56:16 +00:00
|
|
|
emit_signal( "valid_pressed" )
|
2020-03-21 09:10:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_cancel_pressed():
|
2021-05-27 21:56:16 +00:00
|
|
|
emit_signal( "cancel_pressed" )
|
2020-03-21 09:10:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_color_changed(color):
|
2021-05-27 21:56:16 +00:00
|
|
|
$viewport/model/ra/model/body.get_surface_material( 0 ).set_shader_param( "albedo", color )
|
|
|
|
self.ra.color = color
|