khanat-client/scenes/interfaces/creatures_editor/creatures_editor_ui.gd

117 lines
3.7 KiB
GDScript3
Raw Normal View History

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
var ra = Creatures.Ra_old.new()
2020-03-21 09:10:26 +00:00
var slot = null
func _ready():
$viewport/spring_arm/camera.make_current()
func _input( event ):
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
func _process( delta ):
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
func set_creature( p_creature ):
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
func _on_name_text_changed( new_text ):
self.ra.pseudonym = new_text
func _on_boobs_value_changed( value ):
$viewport/model/ra/model/body.set( "blend_shapes/Boobs", value )
self.ra.female_boobs = value
func _on_hip_value_changed(value):
$viewport/model/ra/model/body.set( "blend_shapes/Female_hip", value )
self.ra.female_hip = value
func _on_male_scrotch_value_changed(value):
$viewport/model/ra/model/body.set( "blend_shapes/Male_Pack", value )
self.ra.male_pack = value
func _on_male_throat_value_changed(value):
$viewport/model/ra/model/body.set( "blend_shapes/Male_Throat", value )
self.ra.male_throat = value
func _on_pregnant_value_changed(value):
$viewport/model/ra/model/body.set( "blend_shapes/Pregnant", value )
self.ra.female_pregnant = value
func _on_valid_pressed():
if not self.slot == null:
var directory = Directory.new()
if not directory.dir_exists( "user://creatures/" ):
directory.make_dir_recursive( "user://creatures/" )
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()
emit_signal( "valid_pressed" )
func _on_cancel_pressed():
emit_signal( "cancel_pressed" )
func _on_color_changed(color):
$viewport/model/ra/model/body.get_surface_material( 0 ).set_shader_param( "albedo", color )
self.ra.color = color