refactor: Whitespace removal from all .gd files (#494)

Co-authored-by: Balloonpopper <balloonpopper@git.com>
This commit is contained in:
balloonpopper
2022-02-18 09:00:53 +11:00
committed by GitHub
parent f01733d23b
commit 21df2af2c8
112 changed files with 1103 additions and 1103 deletions

View File

@@ -1,10 +1,10 @@
extends Node2D
# This scenes purpose is to help determining the angles between X and Y axis
# This scenes purpose is to help determining the angles between X and Y axis
# when clicking somewhere on the screen.
# Let us consider that player position is always 0,0.
# Let us consider that player position is always 0,0.
# Clicking right above his head is angle 0.
# Clicking on the right is angle 90.
# Clicking on the right is angle 90.
# Clicking under his feet is angle 180.
# etc.
@@ -28,7 +28,7 @@ enum Directions {
const starting_angles = [
0, # 0 NORTH
PI/4, # 1 NORTHEAST
PI/2, # 2 EAST
PI/2, # 2 EAST
3*PI/4, # 3 SOUTHEAST
PI, # 4 SOUTH
5*PI/4, # 5 SOUTHWEST
@@ -39,7 +39,7 @@ const starting_angles = [
var colors = [
ColorN("red"), # 0 NORTH
ColorN("green"), # 1 NORTHEAST
ColorN("blue"), # 2 EAST
ColorN("blue"), # 2 EAST
ColorN("black"), # 3 SOUTHEAST
ColorN("yellow"), # 4 SOUTH
ColorN("cyan"), # 5 SOUTHWEST
@@ -109,8 +109,8 @@ func _ready():
$player_animations.add_item("")
for anim_name in $player.get_animation_player().get_animations():
$player_animations.add_item(anim_name)
# Set initial angles
# Set initial angles
var initial_angle: float = 360.0 / 8.0
$VBoxContainer/angle_x/angle_horiz.text = str(40)
$VBoxContainer/angle_y/angle_vert.text = str(40)
@@ -118,7 +118,7 @@ func _ready():
angle_horizontal_axes = 40
angle_vertical_axes = 40
angle_diagonal_axes = 50
calculate_areas()
@@ -148,17 +148,17 @@ func calculate_areas(nb_directions: int = 8):
angle_area = deg2rad(angle_vertical_axes)
Directions.NORTHEAST,Directions.NORTHWEST,Directions.SOUTHEAST,Directions.SOUTHWEST:
angle_area = deg2rad(angle_diagonal_axes)
# Since angles start from EAST, offset by -PI/2 (= -90°) to start on up direction
# Then minus angle_area/2 to align on direction
start_angle = PI/2 + angle_area / 2
var angle_start = starting_angles[i] - start_angle
var angle_end = angle_start + angle_area
angles.push_back([angle_start, angle_end])
result_angles.push_back([clamp360(rad2deg(angle_start) + rad2deg(PI/2)),clamp360(rad2deg(angle_area))])
$VBoxContainer/VBoxContainer/angles/angle_array.text = str(result_angles)
construct_scene_nodes(angles)
@@ -184,7 +184,7 @@ func construct_scene_nodes(angles):
collision_shape.points = p_points
collision.set_shape(collision_shape)
area_node.add_child(collision)
$areas.add_child(polygon_node)
@@ -195,7 +195,7 @@ func _on_angle_horiz_text_changed(new_text: String):
# result_angles_anim.Directions.EAST.angle_area_deg = clamp360(angle_horizontal_axes)
# result_angles_anim.Directions.WEST.angle_area_deg = clamp360(angle_horizontal_axes)
calculate_areas()
func _on_angle_vert_text_changed(new_text: String):
if !new_text.is_valid_float():
@@ -220,7 +220,7 @@ func _on_angle_diag_text_changed(new_text: String):
func _on_area_click(viewport: Object, event: InputEvent, shape_idx: int, area_name: String):
if event is InputEventMouseButton and event.is_pressed():
pass
func clamp360(angle: float):
if angle < 0.0:
while angle < 0.0:

View File

@@ -16,7 +16,7 @@ const MAX_HEIGHT = 500
func _ready():
assert(!path_to_richtextlabel.is_empty())
$VBoxContainer/HBoxContainer/clamp_distance.text = str(global_distance_to_clamp)
# Add a white TextureRect behind the RTL to see its actual size
var texturerect_node = TextureRect.new()
get_node(path_to_richtextlabel).add_child(texturerect_node)
@@ -29,7 +29,7 @@ func _ready():
texturerect_node.anchor_right = 1.0
texturerect_node.anchor_bottom = 1.0
move_child(get_node(path_to_richtextlabel), 1)
update_line2d()
_on_new_text_pressed()
set_process_input(true)
@@ -56,7 +56,7 @@ func update_line2d():
$Line2D.add_point(Vector2(screen_width - global_distance_to_clamp, screen_height - global_distance_to_clamp))
$Line2D.add_point(Vector2(screen_width - global_distance_to_clamp, global_distance_to_clamp))
$Line2D.add_point(Vector2(global_distance_to_clamp, global_distance_to_clamp))
func _on_new_text_pressed():
var pressed_button = $HBoxContainer2/foo.group.get_pressed_button()
@@ -79,18 +79,18 @@ func tooltip_distance_to_edge_right(position: Vector2):
func _on_Control_mouse_moved(mouse_pos):
# printt("mousepos", mouse_pos)
# printt("label_container_pos", rect_position)
#var corrected_position = _offset(new_pos)
var corrected_position = mouse_pos
# clamp TOP
if tooltip_distance_to_edge_top(mouse_pos) <= global_distance_to_clamp:
corrected_position.y = global_distance_to_clamp
# clamp BOTTOM
if tooltip_distance_to_edge_bottom(mouse_pos + get_node(path_to_richtextlabel).rect_size) <= global_distance_to_clamp:
corrected_position.y = screen_height - global_distance_to_clamp - get_node(path_to_richtextlabel).rect_size.y
# clamp LEFT
if tooltip_distance_to_edge_left(mouse_pos - get_node(path_to_richtextlabel).rect_size/2) <= global_distance_to_clamp:
corrected_position.x = global_distance_to_clamp
@@ -98,7 +98,7 @@ func _on_Control_mouse_moved(mouse_pos):
# clamp RIGHT
if tooltip_distance_to_edge_right(mouse_pos + get_node(path_to_richtextlabel).rect_size/2) <= global_distance_to_clamp:
corrected_position.x = screen_width - global_distance_to_clamp - get_node(path_to_richtextlabel).rect_size.x
get_node(path_to_richtextlabel).anchor_right = 0.2
get_node(path_to_richtextlabel).rect_position = corrected_position
@@ -115,7 +115,7 @@ func _on_clamp_distance_text_changed(new_text):
func _offset(position):
var center_offset_x = rect_size.x / 2
var offset_y = 5
position.x -= center_offset_x
position.y += offset_y
return position
@@ -129,14 +129,14 @@ func update_size():
var content_height = rtl_node.get_content_height()
var nb_visible_characters = rtl_node.visible_characters
var nb_visible_lines = rtl_node.get_visible_line_count()
printt("BEFORE", "text_height", content_height, "rtl_height", rtl_node.rect_size.y)
# if text is too long and is wrapped
# var nblines = float(rtl_node.get_content_height()) / float(ONE_LINE_HEIGHT)
var nblines = nb_visible_lines
if nblines >= 1:
yield(get_tree(), "idle_frame")
yield(get_tree(), "idle_frame")
var text_height = rtl_node.get_content_height()
@@ -144,20 +144,20 @@ func update_size():
text_height = MAX_HEIGHT
if text_height <= MIN_HEIGHT:
text_height = MIN_HEIGHT
var parent_width = rtl_node.rect_size.x
# first, try to increase width until it goes above max_width
while parent_width < max_width && float(text_height) / float(ONE_LINE_HEIGHT) > 1.0:
rtl_node.rect_size.x += 1
parent_width = rtl_node.rect_size.x
rtl_node.rect_size.y = text_height
if rtl_node.rect_size.x >= max_width:
rtl_node.rect_size.x = max_width
## END RECT_SIZE ##
rtl_node.anchor_top = 0.0
rtl_node.anchor_right = 0.0