face.gd 2.05 KB
Newer Older
Chloé Paris's avatar
Chloé Paris committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
extends WindowDialog

export (bool) var displayed
var point
const TEMPLE = Vector2(506, 311)
const LFOREHEAD = Vector2(462, 235)
const FOREHEAD = Vector2(349, 231)
const TOP = Vector2(489, 88)
const BEHIND = Vector2(661, 123)
const LSIDE = Vector2(609, 251)
const EYEBROW = Vector2(415, 291)
const IRIS = Vector2(419, 324)
const EYE = Vector2(420, 349)
const C = Vector2(334, 306)
const CHEEK = Vector2(457, 379)
const UPPER_JAW = Vector2(488, 450)
const LOWER_JAW = Vector2(487, 545)
const TIP = Vector2(395, 485)
const MOUTH = Vector2(329, 483)
const UPPER_LIP = Vector2(325, 450)
const NOSE = Vector2(307, 408)
const WING = Vector2(345, 375)
const EAR = Vector2(610, 390)
const LOBE = Vector2(583, 434)
const BEHIND_NECK = Vector2(603, 562)
const LOWER_LIP = Vector2(328, 518)
const CHIN = Vector2(329, 558)
const UNDER_CHIN = Vector2(389, 598)
const LIST = [TEMPLE,FOREHEAD,LFOREHEAD,TOP,BEHIND,LSIDE,EYEBROW,IRIS,EYE,C,CHEEK,UPPER_JAW,LOWER_JAW,TIP,MOUTH,UPPER_LIP,NOSE,WING,EAR,LOBE,BEHIND_NECK,LOWER_LIP,CHIN,UNDER_CHIN]
const name_list = ["TEMPLE","FOREHEAD","LFOREHEAD","TOP","BEHIND","LSIDE","EYEBROW","IRIS","EYE","C","CHEEK","UPPER_JAW","LOWER_JAW","TIP","MOUTH","UPPER_LIP","NOSE","WING","EAR","LOBE","BEHIND_NECK","LOWER_LIP","CHIN","UNDER_CHIN"]
var distance
var place = null

func _ready():
	get_close_button().hide()
	pass

func _process(delta):
	if displayed and Input.is_action_just_pressed("click"):
		point = get_viewport().get_mouse_position()
		place = name_list[find_closest(point)]
		signVar.placeTemp = place
		hide()
	if displayed and Input.is_action_just_pressed("ui_cancel"):
		hide()

func find_closest(point):
	var dist
	var distx
	var disty
	distx = abs(LIST[0].x - point.x)
	disty = abs(LIST[0].y - point.y)
	distance = distx*distx + disty*disty
	var where_index = 0
	for i in range(23):
		distx = LIST[i].x - point.x
		disty = LIST[i].y - point.y
		dist = distx*distx + disty*disty
		if dist < distance:
			where_index = i
			distance = dist
	return(where_index)

func _on_face_about_to_show():
	displayed = true

func _on_face_popup_hide():
	displayed = false