blob: fa0fad8cd3bd9710be13b8270d6c06fbc1f8eae8 (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
class_name CharacterSelectionItem
extends PanelContainer
signal selected
var is_hovered := false:
set(value):
is_hovered = value
draw_highlight(value)
var is_selected := false:
set(value):
is_selected = value
draw_highlight(false)
if value:
selected.emit()
func _ready() -> void:
clear()
%SelectionBorder.visible = false
func initialize_with_info(info: CharacterInformation):
%Head.texture = load(
"%s/%s/000.png" % [
"res://client_data/data/sprite",
Constants.FilePaths.get_player_head(info.gender, info.head),
]
)
%Head.visible = true
%Body.texture = load(
"%s/%s/000.png" % [
"res://client_data/data/sprite",
Constants.FilePaths.get_player_body(info.gender, info.job),
]
)
%Body.visible = true
func clear():
%Head.visible = false
%Body.visible = false
func draw_highlight(is_highlighted: bool):
var style_box: StyleBoxFlat = get_theme_stylebox("panel").duplicate()
style_box.draw_center = is_highlighted
add_theme_stylebox_override("panel", style_box)
if is_selected:
%SelectionBorder.visible = true
var style_box2: StyleBoxFlat = get_theme_stylebox("panel").duplicate()
style_box2.border_color.a = 0.0
add_theme_stylebox_override("panel", style_box2)
# spacing "fix"
#%SelectionBorder.top_level = true
#await get_tree().process_frame
#%SelectionBorder.global_position = global_position
else:
%SelectionBorder.visible = false
var style_box2: StyleBoxFlat = get_theme_stylebox("panel").duplicate()
style_box2.border_color.a = 1.0
add_theme_stylebox_override("panel", style_box2)
func _on_gui_input(event: InputEvent) -> void:
if event.is_pressed():
is_selected = true
func _on_mouse_entered() -> void:
is_hovered = true
func _on_mouse_exited() -> void:
is_hovered = false
|