summaryrefslogtreecommitdiff
path: root/client.gd
blob: 516ba4d3d49fc06aeac805655d10133e290082ec (plain)
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
extends Node


var account: Dictionary = {
	"id": "",
}

var character: Dictionary = {
	"name": "",
	"info": null,
}


func show_message_window(
	message: String,
	title: String = "",
	attached_to: Control = null,
	anchor: Side = SIDE_TOP
) -> GameWindow:
	var window = preload("res://ui/message_window.tscn").instantiate()
	window.message = message
	window.title = title
	
	# add window first to get the correct size
	get_tree().current_scene.add_child(window)
	
	# attach window to control
	if attached_to:
		window.global_position = attached_to.global_position
		
		if anchor == SIDE_TOP:
			window.global_position.y -= window.size.y
			window.size.x = max(window.size.x, attached_to.size.x)
		elif anchor == SIDE_BOTTOM:
			window.global_position.y += attached_to.size.y
			window.size.x = max(window.size.x, attached_to.size.x)
		elif anchor == SIDE_LEFT:
			window.global_position.x -= window.size.x
			window.size.y = max(window.size.y, attached_to.size.y)
		elif anchor == SIDE_RIGHT:
			window.global_position.x += attached_to.size.x
			window.size.y = max(window.size.y, attached_to.size.y)
	
	# else add window in center
	else:
		window.global_position = get_viewport().get_visible_rect().size * 0.5 - window.size * 0.5
	
	window.minimum_size = window.size
	
	return window