2019-12-17 15:05:27 +10:30
|
|
|
tool
|
2021-01-24 02:49:08 +10:30
|
|
|
extends Control
|
2019-11-10 15:09:14 +10:30
|
|
|
|
|
|
|
# Draw the bezel for radial gamemode
|
2019-11-18 13:11:02 +10:30
|
|
|
var center := Vector2(0.0, 0.0)
|
2019-11-10 15:09:14 +10:30
|
|
|
|
2019-12-17 15:05:27 +10:30
|
|
|
func arc_point_list(center: Vector2, radius: float, angle_from:=0.0, angle_to:=360.0, points:=20) -> PoolVector2Array:
|
|
|
|
var point_list = PoolVector2Array()
|
|
|
|
for i in range(points):
|
|
|
|
var angle = deg2rad(angle_from + i * (angle_to - angle_from) / (points-1))
|
|
|
|
point_list.push_back(center + polar2cartesian(radius, angle))
|
|
|
|
return point_list
|
|
|
|
|
2019-11-10 15:09:14 +10:30
|
|
|
func _draw():
|
2020-03-12 23:05:12 +10:30
|
|
|
var bezel_colors := PoolColorArray([GameTheme.bezel_color])
|
2019-11-10 15:09:14 +10:30
|
|
|
var bezel_points: PoolVector2Array
|
2020-03-12 23:05:12 +10:30
|
|
|
|
2019-12-17 15:05:27 +10:30
|
|
|
var screen_size = $"/root".get_visible_rect().size
|
|
|
|
var screen_height = 1080 # min(screen_size.x, screen_size.y)
|
2020-03-12 23:05:12 +10:30
|
|
|
|
2019-12-17 15:05:27 +10:30
|
|
|
var screen_height2 = screen_height/2.0
|
2019-11-10 15:09:14 +10:30
|
|
|
|
2019-12-17 15:05:27 +10:30
|
|
|
# draw_rect(Rect2(-screen_height2, -screen_height2, -x_margin, screen_height), GameTheme.bezel_color)
|
|
|
|
# draw_rect(Rect2(screen_height2, -screen_height2, x_margin, screen_height), GameTheme.bezel_color)
|
2019-11-10 15:09:14 +10:30
|
|
|
|
2019-11-18 13:11:02 +10:30
|
|
|
bezel_points = arc_point_list(center, screen_height2, 0, -90)
|
|
|
|
bezel_points.push_back(Vector2(screen_height2, -screen_height2))
|
2019-11-10 15:09:14 +10:30
|
|
|
draw_polygon(bezel_points, bezel_colors)
|
|
|
|
|
2019-11-18 13:11:02 +10:30
|
|
|
bezel_points = arc_point_list(center, screen_height2, -90, -180)
|
|
|
|
bezel_points.push_back(Vector2(-screen_height2, -screen_height2))
|
2019-11-10 15:09:14 +10:30
|
|
|
draw_polygon(bezel_points, bezel_colors)
|
|
|
|
|
2019-11-18 13:11:02 +10:30
|
|
|
bezel_points = arc_point_list(center, screen_height2, -180, -270)
|
|
|
|
bezel_points.push_back(Vector2(-screen_height2, screen_height2))
|
2019-11-10 15:09:14 +10:30
|
|
|
draw_polygon(bezel_points, bezel_colors)
|
|
|
|
|
2019-11-18 13:11:02 +10:30
|
|
|
bezel_points = arc_point_list(center, screen_height2, -270, -360)
|
|
|
|
bezel_points.push_back(Vector2(screen_height2, screen_height2))
|
2019-11-10 15:09:14 +10:30
|
|
|
draw_polygon(bezel_points, bezel_colors)
|
2019-12-17 15:05:27 +10:30
|
|
|
|
|
|
|
func _ready():
|
2020-03-12 23:05:12 +10:30
|
|
|
$"/root".connect("size_changed", self, "update")
|