extends Control var loadprey = Global.preytoedit # Called when the node enters the scene tree for the first time. func _ready(): if loadprey.empty(): get_tree().change_scene("res://preyMenu.tscn") else: Global.preytoedit = "" $preyprev/TextureRect.texture = Global.preydata[loadprey].get("SpriteMain") $preyprev.rect_scale = Global.preydata[loadprey].get("size",Vector2.ONE) # set gui options to loaded value $C/opts/HB/PName.text = loadprey $C/opts/HB/InitScale.value = Global.preydata[loadprey].get("size",Vector2.ONE).x $C/opts/HB/ShrunkScale.value = Global.preydata[loadprey].get("shrunksize",Vector2.ONE).x $C/opts/HB/ColScale.value = Global.preydata[loadprey].get("collectsize",Vector2.ONE).x $C/opts/HB/Health.value = Global.preydata[loadprey].get("health",2000) $preyprev/coll.rect_min_size = Global.capsuletorect( Global.preydata[loadprey].get("shape"), (Global.preydata[loadprey].get("shaperot",0) == 90) ) $preview/prey.data = Global.preydata[loadprey] $preview/prey._load_data() $C/opts/HB/HBW.value = $preyprev/coll.rect_min_size.x $C/opts/HB/HBH.value = $preyprev/coll.rect_min_size.y $C/opts/HB/Squeeze.value = Global.preydata[loadprey].get("squeeze",0.7) _on_InitScale_mouse_entered() func _on_SaveButton_pressed(): var oldload = loadprey loadprey = $C/opts/HB/PName.text if not Global.preydata.has(loadprey): Global.preydata[loadprey] = Global.preydata[oldload]#.duplicate(true) Global.preydata.erase(oldload) Global.preydata[loadprey]["size"] = Vector2($C/opts/HB/InitScale.value,$C/opts/HB/InitScale.value) Global.preydata[loadprey]["shrunksize"] = Vector2($C/opts/HB/ShrunkScale.value,$C/opts/HB/ShrunkScale.value) Global.preydata[loadprey]["collectsize"] = Vector2($C/opts/HB/ColScale.value,$C/opts/HB/ColScale.value) Global.preydata[loadprey]["health"] = $C/opts/HB/Health.value Global.preydata[loadprey]["squeeze"] = $C/opts/HB/Squeeze.value var shape = Global.recttocapsule(Vector2($C/opts/HB/HBW.value,$C/opts/HB/HBH.value),Global.preydata[loadprey]["shape"]) Global.preydata[loadprey]["shaperot"] = shape[1] $preview/prey.data = Global.preydata[loadprey] $preview/prey._load_data() #save to file if prey is on disk if Global.preydata[loadprey].get("file",null) != null: Global.save_prey(Global.preydata[loadprey]["file"],loadprey) func _on_InitScale_value_changed(value): $preyprev.rect_scale = Vector2(value,value) func _on_InitScale_mouse_entered(): $preyprev.rect_scale = Vector2($C/opts/HB/InitScale.value,$C/opts/HB/InitScale.value) func _on_ShrunkScale_value_changed(value): $preyprev.rect_scale = Vector2(value,value) func _on_ShrunkScale_mouse_entered(): $preyprev.rect_scale = Vector2($C/opts/HB/ShrunkScale.value,$C/opts/HB/ShrunkScale.value) func _on_ColScale_value_changed(value): $preyprev.rect_scale = Vector2(value,value) func _on_ColScale_mouse_entered(): $preyprev.rect_scale = Vector2($C/opts/HB/ColScale.value,$C/opts/HB/ColScale.value) func _on_HBW_value_changed(value): $preyprev/coll.rect_min_size.x = value func _on_HBH_value_changed(value): $preyprev/coll.rect_min_size.y = value