blob: cd59593fbc10e8d1f22b710ad18a65154a965d35 (
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 Panel
var level_idx = 0
var stylebox = StyleBoxFlat.new()
var background_color = "#225f30"
var background_color_selected = "#3c9f54"
func _ready():
var level = Global.get_level(self.level_idx)
stylebox = self.get("theme_override_styles/panel")
$ClearMark.text = ""
if level.cleared_by.idx == Enum.PLAYER.FIRST:
$ClearMark.text = "X"
elif level.cleared_by.idx == Enum.PLAYER.SECOND:
$ClearMark.text = "O"
elif level.cleared_by.idx == Enum.PLAYER.THIRD:
$ClearMark.text = "P"
$Time.text = str(level.time) + "s"
$Name.text = level.cleared_by.name
func set_rect_size(x, y):
self.size.x = x
self.size.y = y
$ClearMark.position = Vector2(0, 0)
$ClearMark.size.x = x
$ClearMark.size.y = y
$ClearMark.add_theme_font_size_override('font_size', y / 2)
$Time.position = Vector2(3, 3)
$Name.position = Vector2(3, y - $Name.size.y)
func set_selected(is_selected = true):
if is_selected:
var box = stylebox.duplicate()
box.bg_color = Color.from_string(self.background_color_selected, self.background_color)
self.set("theme_override_styles/panel", box)
else:
var box = stylebox.duplicate()
box.bg_color = Color.from_string(self.background_color, self.background_color)
self.set("theme_override_styles/panel", box)
|