General proofreading (#1262)

* General proofreading for grammar and spelling
* General formatting
* Addition of appropriate literals where appropriate, i.e. `&"foo"` for `StringName` cases and `^"foo/bar"` for `NodePath` cases
This commit is contained in:
A Thousand Ships
2025-10-11 10:39:59 +02:00
committed by GitHub
parent a01005f397
commit 0343cedd48
180 changed files with 721 additions and 692 deletions

View File

@@ -17,7 +17,7 @@ var shape := RID()
class Bullet:
var position := Vector2()
var speed := 1.0
# The body is stored as a RID, which is an "opaque" way to access resources.
# The body is stored as an RID, which is an "opaque" way to access resources.
# With large amounts of objects (thousands or more), it can be significantly
# faster to use RIDs compared to a high-level approach.
var body := RID()

View File

@@ -50,11 +50,11 @@ func _draw() -> void:
draw_circle(margin + offset, 40 - antialiasing_width_offset * 0.5, Color.ORANGE, true, -1.0, use_antialiasing)
# `draw_set_transform()` is a stateful command: it affects *all* `draw_` methods within this
# `_draw()` function after it. This can be used to translate, rotate or scale `draw_` methods
# `_draw()` function after it. This can be used to translate, rotate, or scale `draw_` methods
# that don't offer dedicated parameters for this (such as `draw_primitive()` not having a position parameter).
# To reset back to the initial transform, call `draw_set_transform(Vector2())`.
#
# Draw an horizontally stretched circle.
# Draw a horizontally stretched circle.
offset += Vector2(200, 0)
draw_set_transform(margin + offset, 0.0, Vector2(3.0, 1.0))
draw_circle(Vector2(), 40, Color.ORANGE, false, line_width_thin, use_antialiasing)
@@ -82,7 +82,7 @@ func _draw() -> void:
offset += Vector2(100, 0)
draw_arc(margin + offset, 40, -0.25 * TAU, 0.5 * TAU, POINT_COUNT_LOW, Color.YELLOW, 6.0 - antialiasing_width_offset, use_antialiasing)
# Draw an horizontally stretched arc.
# Draw a horizontally stretched arc.
offset += Vector2(200, 0)
draw_set_transform(margin + offset, 0.0, Vector2(3.0, 1.0))
draw_arc(Vector2(), 40, -0.25 * TAU, 0.5 * TAU, POINT_COUNT_LOW, Color.YELLOW, line_width_thin, use_antialiasing)

View File

@@ -40,12 +40,13 @@ func _ready() -> void:
multi_mesh.set_instance_color(4, Color(0.7, 1, 1))
multi_mesh.mesh = sphere_mesh
func _draw() -> void:
const margin := Vector2(300, 70)
var offset := Vector2()
# `draw_set_transform()` is a stateful command: it affects *all* `draw_` methods within this
# `_draw()` function after it. This can be used to translate, rotate or scale `draw_` methods
# `_draw()` function after it. This can be used to translate, rotate, or scale `draw_` methods
# that don't offer dedicated parameters for this (such as `draw_primitive()` not having a position parameter).
# To reset back to the initial transform, call `draw_set_transform(Vector2())`.
#

View File

@@ -38,7 +38,7 @@ func _draw() -> void:
var offset := Vector2()
# `draw_set_transform()` is a stateful command: it affects *all* `draw_` methods within this
# `_draw()` function after it. This can be used to translate, rotate or scale `draw_` methods
# `_draw()` function after it. This can be used to translate, rotate, or scale `draw_` methods
# that don't offer dedicated parameters for this (such as `draw_primitive()` not having a position parameter).
# To reset back to the initial transform, call `draw_set_transform(Vector2())`.
draw_set_transform(margin + offset)
@@ -57,7 +57,7 @@ func _draw() -> void:
draw_primitive(points.slice(0, 4), colors.slice(0, 4), PackedVector2Array())
# Draw a polygon with multiple colors that are interpolated between each point.
# Colors are specified in the same order as points' positions, but in a different array.
# Colors are specified in the same order as the points' positions, but in a different array.
offset = Vector2(0, 120)
draw_set_transform(margin + offset)
draw_polygon(points, colors)

View File

@@ -59,7 +59,7 @@ func _draw() -> void:
)
# `draw_set_transform()` is a stateful command: it affects *all* `draw_` methods within this
# `_draw()` function after it. This can be used to translate, rotate or scale `draw_` methods
# `_draw()` function after it. This can be used to translate, rotate, or scale `draw_` methods
# that don't offer dedicated parameters for this (such as `draw_rect()` not having a rotation parameter).
# To reset back to the initial transform, call `draw_set_transform(Vector2())`.
offset += Vector2(170, 0)

View File

@@ -13,7 +13,7 @@ func _draw() -> void:
draw_texture(ICON, margin + offset, Color.WHITE)
# `draw_set_transform()` is a stateful command: it affects *all* `draw_` methods within this
# `_draw()` function after it. This can be used to translate, rotate or scale `draw_` methods
# `_draw()` function after it. This can be used to translate, rotate, or scale `draw_` methods
# that don't offer dedicated parameters for this (such as `draw_rect()` not having a rotation parameter).
# To reset back to the initial transform, call `draw_set_transform(Vector2())`.
#

View File

@@ -46,6 +46,7 @@ func _on_MobTimer_timeout():
# Spawn the mob by adding it to the Main scene.
add_child(mob)
func _on_ScoreTimer_timeout():
score += 1
$HUD.update_score(score)

View File

@@ -3,7 +3,7 @@ extends Node2D
var bullet := preload("Bullet.tscn")
func _unhandled_input(input_event: InputEvent) -> void:
if input_event.is_action_pressed("fire"):
if input_event.is_action_pressed(&"fire"):
fire()

View File

@@ -10,6 +10,7 @@ var look_direction := Vector2.RIGHT:
look_direction = value
set_look_direction(value)
func take_damage(attacker: Node, amount: float, effect: Node = null) -> void:
if is_ancestor_of(attacker):
return

View File

@@ -36,6 +36,7 @@ func _unhandled_input(input_event: InputEvent) -> void:
if input_event.is_action_pressed(PLAYER_STATE.attack):
if current_state in [attack, stagger]:
return
_change_state(PLAYER_STATE.attack)
return

View File

@@ -2,7 +2,7 @@ extends "res://player/player_state.gd"
# Collection of important methods to handle direction and animation.
func handle_input(input_event: InputEvent) -> void:
if input_event.is_action_pressed("simulate_damage"):
if input_event.is_action_pressed(&"simulate_damage"):
finished.emit(PLAYER_STATE.stagger)

View File

@@ -22,7 +22,7 @@ func update(_delta: float) -> void:
finished.emit(PLAYER_STATE.idle)
update_look_direction(input_direction)
if Input.is_action_pressed("run"):
if Input.is_action_pressed(&"run"):
speed = max_run_speed
else:
speed = max_walk_speed
@@ -30,7 +30,7 @@ func update(_delta: float) -> void:
var collision_info := move(speed, input_direction)
if not collision_info:
return
if speed == max_run_speed and collision_info.collider.is_in_group("environment"):
if speed == max_run_speed and collision_info.collider.is_in_group(&"environment"):
return

View File

@@ -4,6 +4,7 @@ var speed := 0.0
var velocity := Vector2()
func handle_input(input_event: InputEvent) -> void:
if input_event.is_action_pressed("jump"):
if input_event.is_action_pressed(&"jump"):
finished.emit(PLAYER_STATE.jump)
return super.handle_input(input_event)

View File

@@ -39,6 +39,7 @@ var combo := [{
var hit_objects := []
func _ready() -> void:
$AnimationPlayer.animation_finished.connect(_on_animation_finished)
body_entered.connect(_on_body_entered)
@@ -63,6 +64,7 @@ func _change_state(new_state: States) -> void:
$AnimationPlayer.play(attack_current["animation"])
visible = true
monitoring = true
state = new_state
@@ -71,7 +73,7 @@ func _unhandled_input(input_event: InputEvent) -> void:
return
if attack_input_state != AttackInputStates.LISTENING:
return
if input_event.is_action_pressed("attack"):
if input_event.is_action_pressed(&"attack"):
attack_input_state = AttackInputStates.REGISTERED
@@ -96,7 +98,7 @@ func set_ready_for_next_attack() -> void:
func _on_body_entered(body: Node2D) -> void:
if not body.has_node("Health"):
if not body.has_node(^"Health"):
return
if body.get_rid().get_id() in hit_objects:
return

View File

@@ -20,6 +20,7 @@ var _active := false:
_active = value
set_active(value)
func _enter_tree() -> void:
if start_state.is_empty():
start_state = get_child(0).get_path()

View File

@@ -10,7 +10,7 @@ func _unhandled_input(event: InputEvent) -> void:
if event is InputEventMouseMotion and event.button_mask > 0:
cave.position.x = clampf(cave.position.x + event.screen_relative.x, -CAVE_LIMIT, 0)
if event.is_action_pressed("toggle_glow_map"):
if event.is_action_pressed(&"toggle_glow_map"):
if $WorldEnvironment.environment.glow_map:
$WorldEnvironment.environment.glow_map = null
# Restore glow intensity to its default value

View File

@@ -31,8 +31,8 @@ var anim_directions = {
func _physics_process(_delta):
var motion = Vector2()
motion.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
motion.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
motion.x = Input.get_action_strength(&"move_right") - Input.get_action_strength(&"move_left")
motion.y = Input.get_action_strength(&"move_down") - Input.get_action_strength(&"move_up")
motion.y /= 2
motion = motion.normalized() * MOTION_SPEED
set_velocity(motion)

View File

@@ -2,16 +2,16 @@ extends Node2D
func _input(event: InputEvent) -> void:
if event.is_action_pressed("toggle_directional_light"):
if event.is_action_pressed(&"toggle_directional_light"):
$DirectionalLight2D.visible = not $DirectionalLight2D.visible
if event.is_action_pressed("toggle_point_lights"):
for point_light in get_tree().get_nodes_in_group("point_light"):
if event.is_action_pressed(&"toggle_point_lights"):
for point_light in get_tree().get_nodes_in_group(&"point_light"):
point_light.visible = not point_light.visible
if event.is_action_pressed("cycle_directional_light_shadows_quality"):
if event.is_action_pressed(&"cycle_directional_light_shadows_quality"):
$DirectionalLight2D.shadow_filter = wrapi($DirectionalLight2D.shadow_filter + 1, 0, 3)
if event.is_action_pressed("cycle_point_light_shadows_quality"):
for point_light in get_tree().get_nodes_in_group("point_light"):
if event.is_action_pressed(&"cycle_point_light_shadows_quality"):
for point_light in get_tree().get_nodes_in_group(&"point_light"):
point_light.shadow_filter = wrapi(point_light.shadow_filter + 1, 0, 3)

View File

@@ -15,7 +15,7 @@ func _ready() -> void:
# The "click" event is a custom input action defined in
# Project > Project Settings > Input Map tab.
func _unhandled_input(event: InputEvent) -> void:
if not event.is_action_pressed("click"):
if not event.is_action_pressed(&"click"):
return
set_movement_target(get_global_mouse_position())

View File

@@ -18,7 +18,7 @@ var _path := PackedVector2Array()
func _ready() -> void:
# Region should match the size of the playable area plus one (in tiles).
# In this demo, the playable area is 17×9 tiles, so the rect size is 18×10.
# Depending on the setup TileMapLayer's get_used_rect() can also be used.
# Depending on the setup, TileMapLayer's get_used_rect() can also be used.
_astar.region = Rect2i(0, 0, 18, 10)
_astar.cell_size = CELL_SIZE
_astar.offset = CELL_SIZE * 0.5

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://b3lu6ldhoxd3w"]
[ext_resource type="Script" uid="uid://ch8mb4cgm22pr" path="res://navmesh_chhunks_demo_2d.gd" id="1_d68tl"]
[ext_resource type="Script" uid="uid://ch8mb4cgm22pr" path="res://navmesh_chunks_demo_2d.gd" id="1_d68tl"]
[node name="NavMeshChunksDemo2D" type="Node2D"]
script = ExtResource("1_d68tl")
@@ -73,7 +73,7 @@ layout_mode = 2
[node name="Label" type="Label" parent="CanvasLayer/PanelContainer/MarginContainer/VBoxContainer"]
layout_mode = 2
text = "Use cursor button to set path start position"
text = "Use mouse cursor to set path start position"
[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/PanelContainer/MarginContainer/VBoxContainer"]
layout_mode = 2

View File

@@ -12,7 +12,7 @@ config_version=5
config/name="Navigation Mesh Chunks 2D"
config/tags=PackedStringArray("2d", "ai", "demo", "official")
run/main_scene="res://navmesh_chhunks_demo_2d.tscn"
run/main_scene="res://navmesh_chunks_demo_2d.tscn"
config/features=PackedStringArray("4.5", "GL Compatibility")
config/icon="res://icon.webp"

View File

@@ -7,32 +7,32 @@ func _ready() -> void:
if RenderingServer.get_current_rendering_method() == "gl_compatibility":
is_compatibility = true
text = "Space: Pause/Resume\nG: Toggle glow\n\n\n"
get_parent().get_node("UnsupportedLabel").visible = true
get_parent().get_node(^"UnsupportedLabel").visible = true
# Increase glow intensity to compensate for lower dynamic range.
get_node("../..").environment.glow_intensity = 4.0
get_node(^"../..").environment.glow_intensity = 4.0
func _input(event: InputEvent) -> void:
if event.is_action_pressed("toggle_pause"):
if event.is_action_pressed(&"toggle_pause"):
get_tree().paused = not get_tree().paused
if not is_compatibility and event.is_action_pressed("toggle_trails"):
if not is_compatibility and event.is_action_pressed(&"toggle_trails"):
# Particles disappear if trail type is changed while paused.
# Prevent changing particle type while paused to avoid confusion.
for particles in get_tree().get_nodes_in_group("trailable_particles"):
for particles in get_tree().get_nodes_in_group(&"trailable_particles"):
particles.trail_enabled = not particles.trail_enabled
if not is_compatibility and event.is_action_pressed("increase_trail_length"):
if not is_compatibility and event.is_action_pressed(&"increase_trail_length"):
# Particles disappear if trail type is changed while paused.
# Prevent changing particle type while paused to avoid confusion.
for particles in get_tree().get_nodes_in_group("trailable_particles"):
for particles in get_tree().get_nodes_in_group(&"trailable_particles"):
particles.trail_lifetime = clampf(particles.trail_lifetime + 0.05, 0.1, 1.0)
if not is_compatibility and event.is_action_pressed("decrease_trail_length"):
if not is_compatibility and event.is_action_pressed(&"decrease_trail_length"):
# Particles disappear if trail type is changed while paused.
# Prevent changing particle type while paused to avoid confusion.
for particles in get_tree().get_nodes_in_group("trailable_particles"):
for particles in get_tree().get_nodes_in_group(&"trailable_particles"):
particles.trail_lifetime = clampf(particles.trail_lifetime - 0.05, 0.1, 1.0)
if event.is_action_pressed("toggle_glow"):
get_node("../..").environment.glow_enabled = not get_node("../..").environment.glow_enabled
if event.is_action_pressed(&"toggle_glow"):
get_node(^"../..").environment.glow_enabled = not get_node(^"../..").environment.glow_enabled

View File

@@ -5,4 +5,4 @@ var taken := false
func _on_body_enter(body: Node2D) -> void:
if not taken and body is Player:
($AnimationPlayer as AnimationPlayer).play("taken")
($AnimationPlayer as AnimationPlayer).play(&"taken")

View File

@@ -11,5 +11,5 @@ func disable() -> void:
if disabled:
return
($AnimationPlayer as AnimationPlayer).play("shutdown")
($AnimationPlayer as AnimationPlayer).play(&"shutdown")
disabled = true

View File

@@ -19,8 +19,10 @@ class Circle2D:
func _draw() -> void:
draw_circle(center, radius, color)
var _drawn_nodes := []
func _enter_tree() -> void:
if not _enable_debug_collision:
get_tree().debug_collisions_hint = false

View File

@@ -81,7 +81,7 @@ func _ready() -> void:
var floor_slider: Control = find_child("FloorMaxAngle")
if floor_slider:
floor_slider.get_node("HSlider").value = _floor_max_angle
floor_slider.get_node(^"HSlider").value = _floor_max_angle
_start_test()

View File

@@ -146,7 +146,7 @@ func _remove_objects() -> void:
Log.print_log("* Removing objects...")
var timer := Time.get_ticks_usec()
# Remove objects in reversed order to avoid the overhead of changing children index in parent.
# Remove objects in reversed order to avoid the overhead of changing child index in parent.
var object_count := _objects.size()
for object_index in object_count:
root_node.remove_child(_objects[object_count - object_index - 1])

View File

@@ -199,7 +199,7 @@ func _despawn_objects() -> void:
if object_count == 0:
continue
# Remove objects in reversed order to avoid the overhead of changing children index in parent.
# Remove objects in reversed order to avoid the overhead of changing child index in parent.
for object_index in range(object_count):
var node: Node2D = spawn_parent.get_child(object_count - object_index - 1)
spawn_parent.remove_child(node)

View File

@@ -69,5 +69,6 @@ func _integrate_forces(state: PhysicsDirectBodyState2D) -> void:
_jumping = false
_velocity.y = 0.0
func is_on_floor() -> bool:
return _on_floor

View File

@@ -10,7 +10,7 @@ const WALK_SPEED = 22.0
var _state := State.WALKING
@onready var gravity: int = ProjectSettings.get("physics/2d/default_gravity")
@onready var gravity: int = ProjectSettings.get(&"physics/2d/default_gravity")
@onready var platform_detector := $PlatformDetector as RayCast2D
@onready var floor_detector_left := $FloorDetectorLeft as RayCast2D
@onready var floor_detector_right := $FloorDetectorRight as RayCast2D

View File

@@ -9,7 +9,7 @@ const LIMIT_BOTTOM = 690
func _ready():
for child in get_children():
if child is Player:
var camera = child.get_node("Camera")
var camera = child.get_node(^"Camera")
camera.limit_left = LIMIT_LEFT
camera.limit_top = LIMIT_TOP
camera.limit_right = LIMIT_RIGHT

View File

@@ -14,7 +14,7 @@ const TERMINAL_VELOCITY = 700
## Used to separate controls for multiple players in splitscreen.
@export var action_suffix := ""
var gravity: int = ProjectSettings.get("physics/2d/default_gravity")
var gravity: int = ProjectSettings.get(&"physics/2d/default_gravity")
@onready var platform_detector := $PlatformDetector as RayCast2D
@onready var animation_player := $AnimationPlayer as AnimationPlayer
@onready var shoot_timer := $ShootAnimation as Timer

View File

@@ -19,7 +19,7 @@ func initialize(combat_combatants: Array[PackedScene]) -> void:
var combatant := combatant_scene.instantiate()
if combatant is Combatant:
$Combatants.add_combatant(combatant)
combatant.get_node("Health").dead.connect(_on_combatant_death.bind(combatant))
combatant.get_node(^"Health").dead.connect(_on_combatant_death.bind(combatant))
else:
combatant.queue_free()
ui.initialize()
@@ -30,7 +30,7 @@ func clear_combat() -> void:
for n in $Combatants.get_children():
# Player characters.
n.queue_free()
for n in ui.get_node("Combatants").get_children():
for n in ui.get_node(^"Combatants").get_children():
# Health bars.
n.queue_free()

View File

@@ -8,7 +8,7 @@ signal turn_finished
var active := false: set = set_active
@onready var animation_playback: AnimationNodeStateMachinePlayback = $Sprite2D/AnimationTree.get("parameters/playback")
@onready var animation_playback: AnimationNodeStateMachinePlayback = $Sprite2D/AnimationTree.get(&"parameters/playback")
func set_active(value: bool) -> void:
active = value
@@ -37,4 +37,4 @@ func flee() -> void:
func take_damage(damage_to_take: float) -> void:
$Health.take_damage(damage_to_take)
animation_playback.start("take_damage")
animation_playback.start(&"take_damage")

View File

@@ -9,12 +9,12 @@ signal flee(winner: Combatant, loser: Combatant)
func initialize() -> void:
for combatant in combatants_node.get_children():
var health := combatant.get_node("Health")
var health := combatant.get_node(^"Health")
var info := info_scene.instantiate()
var health_info := info.get_node("VBoxContainer/HealthContainer/Health")
var health_info := info.get_node(^"VBoxContainer/HealthContainer/Health")
health_info.value = health.life
health_info.max_value = health.max_life
info.get_node("VBoxContainer/NameContainer/Name").text = combatant.name
info.get_node(^"VBoxContainer/NameContainer/Name").text = combatant.name
health.health_changed.connect(health_info.set_value)
$Combatants.add_child(info)
@@ -22,25 +22,25 @@ func initialize() -> void:
func _on_Attack_button_up() -> void:
if not combatants_node.get_node("Player").active:
if not combatants_node.get_node(^"Player").active:
return
combatants_node.get_node("Player").attack(combatants_node.get_node("Opponent"))
combatants_node.get_node(^"Player").attack(combatants_node.get_node(^"Opponent"))
func _on_Defend_button_up() -> void:
if not combatants_node.get_node("Player").active:
if not combatants_node.get_node(^"Player").active:
return
combatants_node.get_node("Player").defend()
combatants_node.get_node(^"Player").defend()
func _on_Flee_button_up() -> void:
if not combatants_node.get_node("Player").active:
if not combatants_node.get_node(^"Player").active:
return
combatants_node.get_node("Player").flee()
combatants_node.get_node(^"Player").flee()
var loser: Combatant = combatants_node.get_node("Player")
var winner: Combatant = combatants_node.get_node("Opponent")
var loser: Combatant = combatants_node.get_node(^"Player")
var winner: Combatant = combatants_node.get_node(^"Opponent")
flee.emit(winner, loser)

View File

@@ -11,7 +11,7 @@ func show_dialogue(player: Pawn, dialogue: Node) -> void:
$Button.grab_focus()
dialogue_node = dialogue
for c in dialogue.get_signal_connection_list("dialogue_started"):
for c in dialogue.get_signal_connection_list(&"dialogue_started"):
if player == c.callable.get_object():
dialogue_node.start_dialogue()
$Name.text = "[center]" + dialogue_node.dialogue_name + "[/center]"

View File

@@ -13,21 +13,21 @@ func _ready() -> void:
for n in $Exploration/Grid.get_children():
if not n.type == n.CellType.ACTOR:
continue
if not n.has_node("DialoguePlayer"):
if not n.has_node(^"DialoguePlayer"):
continue
n.get_node("DialoguePlayer").dialogue_finished.connect(_on_opponent_dialogue_finished.bind(n))
n.get_node(^"DialoguePlayer").dialogue_finished.connect(_on_opponent_dialogue_finished.bind(n))
remove_child(combat_screen)
func start_combat(combat_actors: Array[PackedScene]) -> void:
$AnimationPlayer.play("fade_to_black")
$AnimationPlayer.play(&"fade_to_black")
await $AnimationPlayer.animation_finished
remove_child($Exploration)
add_child(combat_screen)
combat_screen.show()
combat_screen.initialize(combat_actors)
$AnimationPlayer.play_backwards("fade_to_black")
$AnimationPlayer.play_backwards(&"fade_to_black")
func _on_opponent_dialogue_finished(opponent: Pawn) -> void:
@@ -40,7 +40,7 @@ func _on_opponent_dialogue_finished(opponent: Pawn) -> void:
func _on_combat_finished(winner: Combatant, _loser: Combatant) -> void:
remove_child(combat_screen)
$AnimationPlayer.play_backwards("fade_to_black")
$AnimationPlayer.play_backwards(&"fade_to_black")
add_child(exploration_screen)
var dialogue: Node = load("res://dialogue/dialogue_player/dialogue_player.tscn").instantiate()
@@ -51,7 +51,7 @@ func _on_combat_finished(winner: Combatant, _loser: Combatant) -> void:
await $AnimationPlayer.animation_finished
var player: Pawn = $Exploration/Grid/Player
exploration_screen.get_node("DialogueCanvas/DialogueUI").show_dialogue(player, dialogue)
exploration_screen.get_node(^"DialogueCanvas/DialogueUI").show_dialogue(player, dialogue)
combat_screen.clear_combat()
await dialogue.dialogue_finished
dialogue.queue_free()

View File

@@ -39,9 +39,9 @@ func request_move(pawn: Pawn, direction: Vector2i) -> Vector2i:
var target_pawn := get_cell_pawn(cell_target, cell_tile_id)
#print("Cell %s contains %s" % [cell_target, target_pawn.name])
if not target_pawn.has_node("DialoguePlayer"):
if not target_pawn.has_node(^"DialoguePlayer"):
return Vector2i.ZERO
dialogue_ui.show_dialogue(pawn, target_pawn.get_node("DialoguePlayer"))
dialogue_ui.show_dialogue(pawn, target_pawn.get_node(^"DialoguePlayer"))
return Vector2i.ZERO

View File

@@ -18,4 +18,4 @@ func _process(_delta: float) -> void:
func get_input_direction() -> Vector2:
return Input.get_vector("move_left", "move_right", "move_up", "move_down")
return Input.get_vector(&"move_left", &"move_right", &"move_up", &"move_down")

View File

@@ -9,8 +9,8 @@ var lost := false
var grid_size: float
@onready var grid : Grid = get_parent()
@onready var animation_playback: AnimationNodeStateMachinePlayback = $AnimationTree.get("parameters/playback")
@onready var walk_animation_time: float = $AnimationPlayer.get_animation("walk").length
@onready var animation_playback: AnimationNodeStateMachinePlayback = $AnimationTree.get(&"parameters/playback")
@onready var walk_animation_time: float = $AnimationPlayer.get_animation(&"walk").length
@onready var pose := $Pivot/Slime
@@ -27,28 +27,28 @@ func update_look_direction(direction: Vector2) -> void:
func move_to(target_position: Vector2) -> void:
set_process(false)
var move_direction := (target_position - position).normalized()
pose.play("idle")
animation_playback.start("walk")
pose.play(&"idle")
animation_playback.start(&"walk")
var tween := create_tween()
tween.set_ease(Tween.EASE_IN)
var end: Vector2 = $Pivot.position + move_direction * grid_size
tween.tween_property($Pivot, "position", end, walk_animation_time)
tween.tween_property($Pivot, ^"position", end, walk_animation_time)
await tween.finished
$Pivot.position = Vector2.ZERO
position = target_position
animation_playback.start("idle")
pose.play("idle")
animation_playback.start(&"idle")
pose.play(&"idle")
set_process(true)
func bump() -> void:
set_process(false)
pose.play("bump")
animation_playback.start("bump")
pose.play(&"bump")
animation_playback.start(&"bump")
await $AnimationTree.animation_finished
animation_playback.start("idle")
pose.play("idle")
animation_playback.start(&"idle")
pose.play(&"idle")
set_process(true)

View File

@@ -31,15 +31,15 @@ func _ready() -> void:
func _physics_process(delta: float) -> void:
var is_jumping := false
if Input.is_action_just_pressed("jump"):
if Input.is_action_just_pressed(&"jump"):
is_jumping = try_jump()
elif Input.is_action_just_released("jump") and velocity.y < 0.0:
elif Input.is_action_just_released(&"jump") and velocity.y < 0.0:
# The player let go of jump early, reduce vertical momentum.
velocity.y *= 0.6
# Fall.
velocity.y = minf(TERMINAL_VELOCITY, velocity.y + gravity * delta)
var direction := Input.get_axis("move_left", "move_right") * WALK_SPEED
var direction := Input.get_axis(&"move_left", &"move_right") * WALK_SPEED
velocity.x = move_toward(velocity.x, direction, ACCELERATION_SPEED * delta)
if no_move_horizontal_time > 0.0:

View File

@@ -74,7 +74,7 @@ func _process(delta: float) -> void:
fps_label.text = "%d FPS (%.2f mspf)" % [Engine.get_frames_per_second(), 1000.0 / Engine.get_frames_per_second()]
# Color FPS counter depending on framerate.
# The Gradient resource is stored as metadata within the FPSLabel node (accessible in the inspector).
fps_label.modulate = fps_label.get_meta("gradient").sample(remap(Engine.get_frames_per_second(), 0, 180, 0.0, 1.0))
fps_label.modulate = fps_label.get_meta(&"gradient").sample(remap(Engine.get_frames_per_second(), 0, 180, 0.0, 1.0))

View File

@@ -36,7 +36,7 @@ func _unhandled_input(event: InputEvent) -> void:
if not result.is_empty():
var decal := preload("res://decal.tscn").instantiate()
add_child(decal)
decal.get_node("Decal").modulate = Color(1.0,0.0,0)
decal.get_node(^"Decal").modulate = Color(1.0,0.0,0)
decal.position = result["position"]
decal.transform.basis = camera.global_transform.basis

View File

@@ -1,7 +1,7 @@
# Global Illumination
This demo showcases Godot's global illumination systems:
LightmapGI, VoxelGI, SDFGI, ReflectionProbe and screen-space effects like SSAO and SSIL.
LightmapGI, VoxelGI, SDFGI, ReflectionProbe, and screen-space effects like SSAO and SSIL.
Use the mouse to look around, <kbd>W</kbd>/<kbd>A</kbd>/<kbd>S</kbd>/<kbd>D</kbd>
or arrow keys to move.
@@ -17,7 +17,7 @@ Check out this demo on the asset library: https://godotengine.org/asset-library/
A sphere and box are parented to the camera to showcase dynamic object lighting.
A ReflectionProbe is parented to the sphere to showcase real-time reflections.
When the ReflectionProbe is hidden, it is disabled. In this case,
VoxelGI, SDFGI or environment lighting will be used to provide fallback reflections.
VoxelGI, SDFGI, or environment lighting will be used to provide fallback reflections.
A Decal node is parented to the moving sphere and cube to provide simple shadows for them.
This is especially effective when using the LightmapGI (All) global illumination mode,

View File

@@ -19,7 +19,7 @@ func _input(event: InputEvent) -> void:
rot.x = clamp(rot.x - event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
transform.basis = Basis.from_euler(rot)
if event.is_action_pressed("toggle_mouse_capture"):
if event.is_action_pressed(&"toggle_mouse_capture"):
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
else:

View File

@@ -74,7 +74,7 @@ func _ready() -> void:
# Remove unsupported VoxelGI/SDFGI references from the label.
reflection_probe_mode_texts[0] = "Disabled - Using environment reflections (Fast)"
set_gi_mode(GIMode.NONE)
# Darken lights's energy to compensate for sRGB blending (without affecting sky rendering).
# Darken lights' energy to compensate for sRGB blending (without affecting sky rendering).
# This only applies to lights with shadows enabled.
$GrateOmniLight.light_energy = 0.25
$GarageOmniLight.light_energy = 0.5
@@ -94,7 +94,7 @@ Escape or F10: Toggle mouse capture"""
func _input(event: InputEvent) -> void:
if event.is_action_pressed("cycle_gi_mode"):
if event.is_action_pressed(&"cycle_gi_mode"):
if is_compatibility:
# Only LightmapGI is supported in Compatibility.
# Note that the actual GI mode is the opposite of what's being set here, due to a bug
@@ -103,10 +103,10 @@ func _input(event: InputEvent) -> void:
else:
set_gi_mode(wrapi(gi_mode + 1, 0, GIMode.MAX))
if event.is_action_pressed("cycle_reflection_probe_mode"):
if event.is_action_pressed(&"cycle_reflection_probe_mode"):
set_reflection_probe_mode(wrapi(reflection_probe_mode + 1, 0, ReflectionProbeMode.MAX))
if event.is_action_pressed("cycle_ssil_mode"):
if event.is_action_pressed(&"cycle_ssil_mode"):
set_ssil_mode(wrapi(ssil_mode + 1, 0, SSILMode.MAX))

View File

@@ -35,7 +35,7 @@ func _ready() -> void:
mark_as_unsupported(%SSReflectionsOptionButton)
mark_as_unsupported(%SSILOptionButton)
mark_as_unsupported(%VolumetricFogOptionButton)
# Darken lights's energy to compensate for sRGB blending (without affecting sky rendering).
# Darken lights' energy to compensate for sRGB blending (without affecting sky rendering).
$Node3D/OmniLight3D.light_energy = 0.5
$Node3D/SpotLight3D.light_energy = 0.5
$Node3D/DirectionalLight3D.sky_mode = DirectionalLight3D.SKY_MODE_SKY_ONLY
@@ -59,7 +59,7 @@ func _process(delta: float) -> void:
fps_label.text = "%d FPS (%.2f mspf)" % [Engine.get_frames_per_second(), 1000.0 / Engine.get_frames_per_second()]
# Color FPS counter depending on framerate.
# The Gradient resource is stored as metadata within the FPSLabel node (accessible in the inspector).
fps_label.modulate = fps_label.get_meta("gradient").sample(remap(Engine.get_frames_per_second(), 0, 180, 0.0, 1.0))
fps_label.modulate = fps_label.get_meta(&"gradient").sample(remap(Engine.get_frames_per_second(), 0, 180, 0.0, 1.0))
func update_resolution_label() -> void:
@@ -174,7 +174,7 @@ func _on_fxaa_option_button_item_selected(index: int) -> void:
func _on_fullscreen_option_button_item_selected(index: int) -> void:
# To change between window, fullscreen and other window modes,
# To change between window, fullscreen, and other window modes,
# set the root mode to one of the options of Window.MODE_*.
# Other modes are maximized and minimized.
if index == 0: # Disabled (default)

View File

@@ -23,7 +23,7 @@ const CHAIN_MAX_ITER = 10
var temp = get_node(skeleton_path)
if temp != null:
# If it has the method "get_bone_global_pose" it is likely a Skeleton3D
if temp.has_method("get_bone_global_pose"):
if temp.has_method(&"get_bone_global_pose"):
skeleton = temp
bone_IDs = {}
@@ -109,7 +109,7 @@ func _ready():
if target == null:
# NOTE: You MUST have a node called Target as a child of this node!
# So we create one if one doesn't already exist.
if not has_node("Target"):
if not has_node(^"Target"):
target = Node3D.new()
add_child(target)
@@ -127,7 +127,7 @@ func _ready():
_make_editor_sphere_at_node(target, Color.MAGENTA)
if middle_joint_target == null:
if not has_node("MiddleJoint"):
if not has_node(^"MiddleJoint"):
middle_joint_target = Node3D.new()
add_child(middle_joint_target)
@@ -243,7 +243,7 @@ func solve_chain():
else:
dir = -target.global_transform.basis.z.normalized()
# Get the target position (accounting for the final bone and it's length)
# Get the target position (accounting for the final bone and its length)
var target_pos = target.global_transform.origin + (dir * bones_in_chain_lengths[bone_nodes.size()-1])
# If we are using middle joint target (and have more than 2 bones), move our middle joint towards it!

View File

@@ -6,7 +6,7 @@ extends Node3D
# Assign skeleton_path to whatever value is passed.
skeleton_path = value
# Because get_node doesn't work in the first call, we just want to assign instead.
# This is to get around a issue with NodePaths exposed to the editor.
# This is to get around an issue with NodePaths exposed to the editor.
if first_call:
return
_setup_skeleton_path()

View File

@@ -96,10 +96,10 @@ func process_input(delta):
if anim_done:
if current_anim != "Aiming":
anim_player.play("Aiming")
anim_player.play(&"Aiming")
current_anim = "Aiming"
else:
anim_player.play("Idle")
anim_player.play(&"Idle")
current_anim = "Idle"
anim_done = false

View File

@@ -54,7 +54,7 @@ func set_health(p_health: int) -> void:
$HealthBarBackground.outline_modulate = Color(0.15, 0.2, 0.15)
$HealthBarBackground.modulate = Color(0.15, 0.2, 0.15)
# Construct an health bar with `|` symbols brought very close to each other using
# Construct a health bar with `|` symbols brought very close to each other using
# a custom FontVariation on the HealthBarForeground and HealthBarBackground nodes.
var bar_text := ""
var bar_text_bg := ""

View File

@@ -74,7 +74,7 @@ func _on_enable_sun_toggled(button_pressed: bool) -> void:
func _on_animate_lights_toggled(button_pressed: bool) -> void:
for animatable_node in get_tree().get_nodes_in_group("animatable"):
for animatable_node in get_tree().get_nodes_in_group(&"animatable"):
animatable_node.set_process(button_pressed)

View File

@@ -26,7 +26,7 @@ will vary depending on your CPU and GPU model.
> **Warning**
>
> If you are using a engine build that is not fully optimized, you may notice
> If you are using an engine build that is not fully optimized, you may notice
> that enabling occlusion culling decreases performance. This is because
> occlusion culling is a demanding process on the CPU, which needs all the
> build-time optimization it can get.

View File

@@ -19,7 +19,7 @@ func _input(event: InputEvent) -> void:
rot.x = clamp(rot.x - event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
transform.basis = Basis.from_euler(rot)
if event.is_action_pressed("toggle_mouse_capture"):
if event.is_action_pressed(&"toggle_mouse_capture"):
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
else:

View File

@@ -3,16 +3,16 @@ extends Node3D
var open := false
func _input(event: InputEvent) -> void:
if event.is_action_pressed("toggle_doors"):
if event.is_action_pressed(&"toggle_doors"):
if open:
# Close the door.
# The occluder will be re-enabled when the animation ends
# using `_on_animation_player_animation_finished()`.
$AnimationPlayer.play_backwards("open")
$AnimationPlayer.play_backwards(&"open")
open = false
else:
# Open the door.
$AnimationPlayer.play("open")
$AnimationPlayer.play(&"open")
open = true
# Disable the occluder as soon as the door starts opening.
# The occluder is not part of the pivot to prevent it from having its

View File

@@ -1,16 +1,16 @@
extends Node3D
func _input(event: InputEvent) -> void:
if event.is_action_pressed("toggle_occlusion_culling"):
if event.is_action_pressed(&"toggle_occlusion_culling"):
get_viewport().use_occlusion_culling = not get_viewport().use_occlusion_culling
update_labels()
if event.is_action_pressed("toggle_mesh_lod"):
if event.is_action_pressed(&"toggle_mesh_lod"):
get_viewport().mesh_lod_threshold = 1.0 if is_zero_approx(get_viewport().mesh_lod_threshold) else 0.0
update_labels()
if event.is_action_pressed("cycle_draw_mode"):
if event.is_action_pressed(&"cycle_draw_mode"):
get_viewport().debug_draw = wrapi(get_viewport().debug_draw + 1, 0, 5) as Viewport.DebugDraw
update_labels()
if event.is_action_pressed("toggle_vsync"):
if event.is_action_pressed(&"toggle_vsync"):
if DisplayServer.window_get_vsync_mode() == DisplayServer.VSYNC_DISABLED:
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED)
else:

View File

@@ -1,7 +1,7 @@
# 3D Particles
This project showcases various 3D particle features supported by Godot, for both GPU-based and CPU-based particles.
This includes particle collision, attractors, trails and subemitters.
This includes particle collision, attractors, trails, and subemitters.
Language: GDScript

View File

@@ -67,7 +67,7 @@ func _on_lightbulb1_intensity_value_changed(value: float) -> void:
func _on_lightbulb1_temperature_value_changed(value: float) -> void:
lightbulb_1.light_temperature = value
$Light/Lightbulb1Temperature/Value.text = "%d K" % value
$Light/Lightbulb1Temperature/Value.add_theme_color_override("font_color", get_color_from_temperature(value))
$Light/Lightbulb1Temperature/Value.add_theme_color_override(&"font_color", get_color_from_temperature(value))
func _on_lightbulb2_intensity_value_changed(value: float) -> void:
@@ -78,7 +78,7 @@ func _on_lightbulb2_intensity_value_changed(value: float) -> void:
func _on_lightbulb2_temperature_value_changed(value: float) -> void:
lightbulb_2.light_temperature = value
$Light/Lightbulb2Temperature/Value.text = "%d K" % value
$Light/Lightbulb2Temperature/Value.add_theme_color_override("font_color", get_color_from_temperature(value))
$Light/Lightbulb2Temperature/Value.add_theme_color_override(&"font_color", get_color_from_temperature(value))
func _on_focus_distance_value_changed(value: float) -> void:

View File

@@ -114,7 +114,7 @@ func cycle_camera_type() -> void:
$Rig/Camera_TPS.make_current()
CameraType.CAM_TPS:
_cam_type = CameraType.CAM_FIXED
get_node("../Camera_Fixed").make_current()
get_node(^"../Camera_Fixed").make_current()
# Hide body in FPS view (but keep shadow casting to improve spatial awareness).
if _cam_type == CameraType.CAM_FPS:

View File

@@ -160,7 +160,7 @@ func start_test() -> void:
animation_player.playback_process_mode = AnimationPlayer.ANIMATION_PROCESS_PHYSICS
else:
animation_player.playback_process_mode = AnimationPlayer.ANIMATION_PROCESS_IDLE
animation_player.play("Move")
animation_player.play(&"Move")
$LabelBodyType.text = "Body Type: " + _body_type[_current_body_index] + " \nCollision Shape: " + _current_shape

View File

@@ -152,7 +152,7 @@ func _remove_objects() -> void:
Log.print_log("* Removing objects...")
var timer := Time.get_ticks_usec()
# Remove objects in reversed order to avoid the overhead of changing children index in parent.
# Remove objects in reversed order to avoid the overhead of changing child index in parent.
var object_count := _objects.size()
for object_index in object_count:
root_node.remove_child(_objects[object_count - object_index - 1])

View File

@@ -190,7 +190,7 @@ func _despawn_objects() -> void:
for spawn in spawns:
var spawn_parent := get_node(spawn)
# Remove objects in reversed order to avoid the overhead of changing children index in parent.
# Remove objects in reversed order to avoid the overhead of changing child index in parent.
var object_count := spawn_parent.get_child_count()
for object_index in object_count:
var node := spawn_parent.get_child(object_count - object_index - 1)

View File

@@ -36,7 +36,7 @@ var coins := 0
func _physics_process(delta: float) -> void:
if Input.is_action_pressed("reset_position") or global_position.y < -12:
if Input.is_action_pressed(&"reset_position") or global_position.y < -12:
# Player hit the reset button or fell off the map.
position = initial_position
velocity = Vector3.ZERO
@@ -48,10 +48,10 @@ func _physics_process(delta: float) -> void:
# Update coin count and its "parallax" copies.
# This gives text a pseudo-3D appearance while still using Label3D instead of the more limited TextMesh.
%CoinCount.text = str(coins)
%CoinCount.get_node("Parallax").text = str(coins)
%CoinCount.get_node("Parallax2").text = str(coins)
%CoinCount.get_node("Parallax3").text = str(coins)
%CoinCount.get_node("Parallax4").text = str(coins)
%CoinCount.get_node(^"Parallax").text = str(coins)
%CoinCount.get_node(^"Parallax2").text = str(coins)
%CoinCount.get_node(^"Parallax3").text = str(coins)
%CoinCount.get_node(^"Parallax4").text = str(coins)
velocity += gravity * delta
@@ -135,7 +135,7 @@ func _physics_process(delta: float) -> void:
horizontal_speed = 0
horizontal_velocity = horizontal_direction * horizontal_speed
if Input.is_action_just_released("jump") and velocity.y > 0.0:
if Input.is_action_just_released(&"jump") and velocity.y > 0.0:
# Reduce jump height if releasing the jump key before reaching the apex.
vertical_velocity *= 0.7

View File

@@ -14,7 +14,7 @@ resource dropdown.
> **Warning**
>
> Sky shaders are rendered every frame if they use the `TIME` variable or are
> otherwise updated every frame (e.g. if an uniform is updated in `_process()`
> otherwise updated every frame (e.g. if a uniform is updated in `_process()`
> or with an AnimationPlayer). This has a significant performance impact for
> complex sky shaders. The performance impact can be reduced by adjusting the
> radiance map properties in Environment, but it will remain significant.

View File

@@ -13,21 +13,21 @@ func _ready() -> void:
func _process(delta: float) -> void:
# Make the slider follow the day/night cycle.
$Panel/MarginContainer/VBoxContainer/TimeOfDay/HSlider.value = $AnimationPlayer.current_animation_position
$WorldEnvironment.environment.sky.sky_material.set_shader_parameter("cloud_time_offset", $AnimationPlayer.current_animation_position)
$WorldEnvironment.environment.sky.sky_material.set_shader_parameter(&"cloud_time_offset", $AnimationPlayer.current_animation_position)
$YawCamera/Camera3D.fov = lerpf($YawCamera/Camera3D.fov, desired_fov, 1.0 - exp(-delta * 10.0))
func _input(event: InputEvent) -> void:
if event.is_action_pressed("toggle_gui"):
if event.is_action_pressed(&"toggle_gui"):
$Panel.visible = not $Panel.visible
$Help.visible = not $Help.visible
if event.is_action_pressed("toggle_spheres"):
if event.is_action_pressed(&"toggle_spheres"):
$Spheres.visible = not $Spheres.visible
if event.is_action_pressed("toggle_mouse_capture"):
if event.is_action_pressed(&"toggle_mouse_capture"):
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
else:
@@ -40,9 +40,9 @@ func _input(event: InputEvent) -> void:
$YawCamera.rotation.y -= relative_motion.x * MOUSE_SENSITIVITY
# Mouse wheel currently doesn't work in input actions. Hardcode mouse wheel as a workaround.
if event.is_action_pressed("increase_camera_fov") or Input.is_mouse_button_pressed(MOUSE_BUTTON_WHEEL_DOWN):
if event.is_action_pressed(&"increase_camera_fov") or Input.is_mouse_button_pressed(MOUSE_BUTTON_WHEEL_DOWN):
desired_fov = clampf(desired_fov + 5.0, 20.0, 120.0)
if event.is_action_pressed("decrease_camera_fov") or Input.is_mouse_button_pressed(MOUSE_BUTTON_WHEEL_UP):
if event.is_action_pressed(&"decrease_camera_fov") or Input.is_mouse_button_pressed(MOUSE_BUTTON_WHEEL_UP):
desired_fov = clampf(desired_fov - 5.0, 20.0, 120.0)
@@ -81,12 +81,12 @@ func update_speed_label() -> void:
func _on_cloud_coverage_value_changed(value: float) -> void:
$WorldEnvironment.environment.sky.sky_material.set_shader_parameter("cloud_coverage", value)
$WorldEnvironment.environment.sky.sky_material.set_shader_parameter(&"cloud_coverage", value)
$Panel/MarginContainer/VBoxContainer/Clouds/CoverageValue.text = "%d%%" % (value * 100)
func _on_cloud_density_value_changed(value: float) -> void:
$WorldEnvironment.environment.sky.sky_material.set_shader_parameter("cloud_density", value)
$WorldEnvironment.environment.sky.sky_material.set_shader_parameter(&"cloud_density", value)
$Panel/MarginContainer/VBoxContainer/Clouds/DensityValue.text = "%d%%" % (value * 100)

View File

@@ -9,8 +9,8 @@ var velocity: Vector3 = Vector3.ZERO
func _process(delta: float) -> void:
var input_vector: Vector2 = Vector2.ZERO
input_vector.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
input_vector.y = Input.get_action_strength("move_back") - Input.get_action_strength("move_forward")
input_vector.x = Input.get_action_strength(&"move_right") - Input.get_action_strength(&"move_left")
input_vector.y = Input.get_action_strength(&"move_back") - Input.get_action_strength(&"move_forward")
if input_vector.length() > 0:
input_vector = input_vector.normalized()
@@ -20,8 +20,8 @@ func _process(delta: float) -> void:
# Play corresponding animation.
if abs(input_vector.x) > abs(input_vector.y):
sprite.play("walk_right" if input_vector.x > 0 else "walk_left")
sprite.play(&"walk_right" if input_vector.x > 0 else &"walk_left")
else:
sprite.play("walk_down" if input_vector.y > 0 else "walk_up")
sprite.play(&"walk_down" if input_vector.y > 0 else &"walk_up")
else:
sprite.stop()

View File

@@ -20,7 +20,7 @@ func _ready():
func _unhandled_input(event):
if event.is_action_pressed("ui_accept") and $UserInterface/Retry.visible:
if event.is_action_pressed(&"ui_accept") and $UserInterface/Retry.visible:
get_tree().reload_current_scene()
@@ -29,7 +29,7 @@ func _on_mob_timer_timeout():
var mob = mob_scene.instantiate()
# Choose a random location on the SpawnPath.
var mob_spawn_location = get_node("SpawnPath/SpawnLocation")
var mob_spawn_location = get_node(^"SpawnPath/SpawnLocation")
mob_spawn_location.progress_ratio = randf()
# Communicate the spawn location and the player's location to the mob.

View File

@@ -14,13 +14,13 @@ signal hit
func _physics_process(delta):
var direction = Vector3.ZERO
if Input.is_action_pressed("move_right"):
if Input.is_action_pressed(&"move_right"):
direction.x += 1
if Input.is_action_pressed("move_left"):
if Input.is_action_pressed(&"move_left"):
direction.x -= 1
if Input.is_action_pressed("move_back"):
if Input.is_action_pressed(&"move_back"):
direction.z += 1
if Input.is_action_pressed("move_forward"):
if Input.is_action_pressed(&"move_forward"):
direction.z -= 1
if direction != Vector3.ZERO:
@@ -36,7 +36,7 @@ func _physics_process(delta):
velocity.z = direction.z * speed
# Jumping.
if is_on_floor() and Input.is_action_just_pressed("jump"):
if is_on_floor() and Input.is_action_just_pressed(&"jump"):
velocity.y += jump_impulse
# We apply gravity every frame so the character always collides with the ground when moving.
@@ -52,7 +52,7 @@ func _physics_process(delta):
# If there are no "slides" this frame, the loop below won't run.
for index in range(get_slide_collision_count()):
var collision = get_slide_collision(index)
if collision.get_collider().is_in_group("mob"):
if collision.get_collider().is_in_group(&"mob"):
var mob = collision.get_collider()
if Vector3.UP.dot(collision.get_normal()) > 0.1:
mob.squash()

View File

@@ -7,15 +7,15 @@ class_name GradientBars extends Node3D
func set_num_steps(steps: int) -> void:
var shader_mat: ShaderMaterial = hdr_bar.material_override as ShaderMaterial
if shader_mat:
shader_mat.set_shader_parameter("steps", min(1, steps))
shader_mat.set_shader_parameter(&"steps", min(1, steps))
func set_color(color: Color) -> void:
var shader_mat: ShaderMaterial = sdr_bar.material_override as ShaderMaterial
if shader_mat:
shader_mat.set_shader_parameter("my_color", color)
shader_mat.set_shader_parameter(&"my_color", color)
shader_mat = hdr_bar.material_override as ShaderMaterial
if shader_mat:
shader_mat.set_shader_parameter("my_color", color)
shader_mat.set_shader_parameter(&"my_color", color)
label.text = "#" + color.to_html(false)

View File

@@ -22,10 +22,10 @@ func _on_steps_value_changed(value):
for bar_path in bars:
var bar = get_node(bar_path)
var shader_mat = bar.hdr_bar.material_override as ShaderMaterial
shader_mat.set_shader_parameter("steps", value)
shader_mat.set_shader_parameter(&"steps", value)
if hues:
var shader_mat = hues.material_override as ShaderMaterial
shader_mat.set_shader_parameter("steps", value)
shader_mat.set_shader_parameter(&"steps", value)
func _on_color_picker_button_color_changed(color):
@@ -37,10 +37,10 @@ func _on_exponential_toggled(button_pressed):
for bar_path in bars:
var bar = get_node(bar_path)
var shader_mat = bar.hdr_bar.material_override as ShaderMaterial
shader_mat.set_shader_parameter("exponential_view", button_pressed)
shader_mat.set_shader_parameter(&"exponential_view", button_pressed)
shader_mat = bar.sdr_bar.material_override as ShaderMaterial
shader_mat.set_shader_parameter("exponential_view", button_pressed)
shader_mat.set_shader_parameter(&"exponential_view", button_pressed)
if hues:
var shader_mat = hues.material_override as ShaderMaterial
shader_mat.set_shader_parameter("exponential_view", button_pressed)
shader_mat.set_shader_parameter(&"exponential_view", button_pressed)

View File

@@ -31,7 +31,7 @@ func _process(_delta: float) -> void:
text = "Speed: " + ("%.0f" % speed) + " mph"
# Change speedometer color depending on speed in m/s (regardless of unit).
add_theme_color_override("font_color", gradient.sample(remap(car_body.linear_velocity.length(), 0.0, 30.0, 0.0, 1.0)))
add_theme_color_override(&"font_color", gradient.sample(remap(car_body.linear_velocity.length(), 0.0, 30.0, 0.0, 1.0)))
func _on_spedometer_pressed() -> void:

View File

@@ -20,7 +20,7 @@ func _input(input_event: InputEvent) -> void:
rot.x = clampf(rot.x - input_event.relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
transform.basis = Basis.from_euler(rot)
if input_event.is_action_pressed("toggle_mouse_capture"):
if input_event.is_action_pressed(&"toggle_mouse_capture"):
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
else:

View File

@@ -18,9 +18,9 @@ func _ready() -> void:
func _process(delta: float) -> void:
var motion := Vector3(
Input.get_action_strength("move_right") - Input.get_action_strength("move_left"),
Input.get_action_strength(&"move_right") - Input.get_action_strength(&"move_left"),
0,
Input.get_action_strength("move_back") - Input.get_action_strength("move_forward")
Input.get_action_strength(&"move_back") - Input.get_action_strength(&"move_forward")
)
# Normalize motion to prevent diagonal movement from being
@@ -41,33 +41,33 @@ func _input(event: InputEvent) -> void:
rot.x = clamp(rot.x - event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
transform.basis = Basis.from_euler(rot)
if event.is_action_pressed("toggle_mouse_capture"):
if event.is_action_pressed(&"toggle_mouse_capture"):
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
else:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
if event.is_action_pressed("toggle_temporal_reprojection"):
if event.is_action_pressed(&"toggle_temporal_reprojection"):
get_world_3d().environment.volumetric_fog_temporal_reprojection_enabled = not get_world_3d().environment.volumetric_fog_temporal_reprojection_enabled
update_label()
elif event.is_action_pressed("increase_temporal_reprojection"):
elif event.is_action_pressed(&"increase_temporal_reprojection"):
get_world_3d().environment.volumetric_fog_temporal_reprojection_amount = clamp(get_world_3d().environment.volumetric_fog_temporal_reprojection_amount + 0.01, 0.5, 0.99)
update_label()
elif event.is_action_pressed("decrease_temporal_reprojection"):
elif event.is_action_pressed(&"decrease_temporal_reprojection"):
get_world_3d().environment.volumetric_fog_temporal_reprojection_amount = clamp(get_world_3d().environment.volumetric_fog_temporal_reprojection_amount - 0.01, 0.5, 0.99)
update_label()
elif event.is_action_pressed("increase_fog_density"):
elif event.is_action_pressed(&"increase_fog_density"):
get_world_3d().environment.volumetric_fog_density = clamp(get_world_3d().environment.volumetric_fog_density + 0.01, 0.0, 1.0)
update_label()
elif event.is_action_pressed("decrease_fog_density"):
elif event.is_action_pressed(&"decrease_fog_density"):
get_world_3d().environment.volumetric_fog_density = clamp(get_world_3d().environment.volumetric_fog_density - 0.01, 0.0, 1.0)
update_label()
elif event.is_action_pressed("increase_volumetric_fog_quality"):
elif event.is_action_pressed(&"increase_volumetric_fog_quality"):
volumetric_fog_volume_size = clamp(volumetric_fog_volume_size + 16, 16, 384)
volumetric_fog_volume_depth = clamp(volumetric_fog_volume_depth + 16, 16, 384)
RenderingServer.environment_set_volumetric_fog_volume_size(volumetric_fog_volume_size, volumetric_fog_volume_depth)
update_label()
elif event.is_action_pressed("decrease_volumetric_fog_quality"):
elif event.is_action_pressed(&"decrease_volumetric_fog_quality"):
volumetric_fog_volume_size = clamp(volumetric_fog_volume_size - 16, 16, 384)
volumetric_fog_volume_depth = clamp(volumetric_fog_volume_depth - 16, 16, 384)
RenderingServer.environment_set_volumetric_fog_volume_size(volumetric_fog_volume_size, volumetric_fog_volume_depth)

View File

@@ -62,7 +62,7 @@ func _process(_delta: float) -> void:
aim_preview.global_position = Vector3(ray_current_block_position) + Vector3(0.5, 0.5, 0.5)
var breaking := Input.is_action_just_pressed(&"break")
var placing := Input.is_action_just_pressed(&"place")
# Either both buttons were pressed or neither are, so stop.
# Either both buttons were pressed or neither is, so stop.
if breaking == placing:
return
@@ -87,7 +87,7 @@ func _physics_process(delta: float) -> void:
head.transform.origin.y = lerpf(head.transform.origin.y, EYE_HEIGHT_CROUCH if crouching else EYE_HEIGHT_STAND, 1.0 - exp(-delta * 16.0))
# Keyboard movement.
var movement_vec2: Vector2 = Input.get_vector("move_left", "move_right", "move_forward", "move_back")
var movement_vec2: Vector2 = Input.get_vector(&"move_left", &"move_right", &"move_forward", &"move_back")
var movement: Vector3 = transform.basis * (Vector3(movement_vec2.x, 0, movement_vec2.y))
if is_on_floor():

View File

@@ -9,7 +9,7 @@ var format := AudioStreamWAV.FORMAT_16_BITS # This is the default format on rec
func _ready() -> void:
var idx := AudioServer.get_bus_index("Record")
var idx := AudioServer.get_bus_index(&"Record")
effect = AudioServer.get_bus_effect(idx, 0)

View File

@@ -58,7 +58,7 @@ func _process(_delta: float) -> void:
_miss_old_notes()
if Input.is_action_just_pressed("main_key"):
if Input.is_action_just_pressed(&"main_key"):
_handle_keypress()
if _notes.is_empty():

View File

@@ -6,16 +6,19 @@ extends Resource
if mean_hit_error != value:
mean_hit_error = value
emit_changed()
@export var perfect_count: int = 0:
set(value):
if perfect_count != value:
perfect_count = value
emit_changed()
@export var good_count: int = 0:
set(value):
if good_count != value:
good_count = value
emit_changed()
@export var miss_count: int = 0:
set(value):
if miss_count != value:

View File

@@ -18,12 +18,14 @@ func _init(args: Variant) -> void:
x_filter = LowPassFilter.new()
dx_filter = LowPassFilter.new()
func alpha(rate: float, cutoff: float) -> float:
var tau: float = 1.0 / (2 * PI * cutoff)
var te: float = 1.0 / rate
return 1.0 / (1.0 + tau/te)
func filter(value: float, delta: float) -> float:
var rate: float = 1.0 / delta
var dx: float = (value - x_filter.last_value) * rate
@@ -32,12 +34,15 @@ func filter(value: float, delta: float) -> float:
var cutoff: float = min_cutoff + beta * abs(edx)
return x_filter.filter(value, alpha(rate, cutoff))
class LowPassFilter:
var last_value: float
func _init() -> void:
last_value = 0
func filter(value: float, alpha: float) -> float:
var result := alpha * value + (1 - alpha) * last_value
last_value = result

View File

@@ -4,9 +4,9 @@ var _guide_tween: Tween
func _process(_delta: float) -> void:
if Input.is_action_just_pressed("main_key"):
if Input.is_action_just_pressed(&"main_key"):
scale = 1.2 * Vector2.ONE
if _guide_tween:
_guide_tween.kill()
_guide_tween = create_tween().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_CUBIC)
_guide_tween.tween_property(self, "scale", Vector2.ONE, 0.2)
_guide_tween.tween_property(self, ^"scale", Vector2.ONE, 0.2)

View File

@@ -42,8 +42,8 @@ func hit_perfect() -> void:
var tween := create_tween()
tween.set_ease(Tween.EASE_OUT)
tween.set_trans(Tween.TRANS_QUAD)
tween.parallel().tween_property(self, "modulate:a", 0, 0.2)
tween.parallel().tween_property($Sprite2D, "scale", 1.5 * Vector2.ONE, 0.2)
tween.parallel().tween_property(self, ^"modulate:a", 0, 0.2)
tween.parallel().tween_property($Sprite2D, ^"scale", 1.5 * Vector2.ONE, 0.2)
tween.tween_callback(queue_free)
@@ -55,8 +55,8 @@ func hit_good() -> void:
var tween := create_tween()
tween.set_ease(Tween.EASE_OUT)
tween.set_trans(Tween.TRANS_QUAD)
tween.parallel().tween_property(self, "modulate:a", 0, 0.2)
tween.parallel().tween_property($Sprite2D, "scale", 1.2 * Vector2.ONE, 0.2)
tween.parallel().tween_property(self, ^"modulate:a", 0, 0.2)
tween.parallel().tween_property($Sprite2D, ^"scale", 1.2 * Vector2.ONE, 0.2)
tween.tween_callback(queue_free)
@@ -66,7 +66,7 @@ func miss(stop_movement: bool = true) -> void:
modulate = Color.DARK_RED
var tween := create_tween()
tween.parallel().tween_property(self, "modulate:a", 0, 0.5)
tween.parallel().tween_property(self, ^"modulate:a", 0, 0.5)
tween.tween_callback(queue_free)

View File

@@ -41,7 +41,7 @@ func _ready() -> void:
func _process(_delta: float) -> void:
if Input.is_action_just_pressed("restart"):
if Input.is_action_just_pressed(&"restart"):
get_tree().reload_current_scene()
$Control/ErrorGraphVBox/CenterContainer/TimeGraph.queue_redraw()
@@ -112,8 +112,8 @@ func _on_note_hit(beat: float, hit_type: Enums.HitType, hit_error: float) -> voi
_judgment_tween.kill()
_judgment_tween = create_tween()
_judgment_tween.tween_interval(0.2)
_judgment_tween.tween_property($Control/JudgmentHBox/LJudgmentLabel, "modulate:a", 0, 0.5)
_judgment_tween.parallel().tween_property($Control/JudgmentHBox/RJudgmentLabel, "modulate:a", 0, 0.5)
_judgment_tween.tween_property($Control/JudgmentHBox/LJudgmentLabel, ^"modulate:a", 0, 0.5)
_judgment_tween.parallel().tween_property($Control/JudgmentHBox/RJudgmentLabel, ^"modulate:a", 0, 0.5)
_hit_data.append(NoteHitData.new(beat, hit_type, hit_error))
$Control/ErrorGraphVBox/CenterContainer/JudgmentsGraph.queue_redraw()

View File

@@ -3,6 +3,6 @@ extends Node
func _process(_delta: float) -> void:
if Input.is_action_just_pressed("pause"):
if Input.is_action_just_pressed(&"pause"):
get_tree().paused = not get_tree().paused
$"../Control/PauseLabel".visible = get_tree().paused

View File

@@ -12,7 +12,7 @@ can try both options to compare the time it takes to generate the heightmap on
the CPU and GPU respectively.
For smaller noise textures, the CPU will often be faster, but the larger the
gains are by using the GPU. On a PC with a NVIDIA GeForce RTX 3060 and
gains are by using the GPU. On a PC with an NVIDIA GeForce RTX 3060 and
11th-generation Intel Core i7 processor, the compute shader was tested to be
faster for textures 1024×1024 and larger.

View File

@@ -41,10 +41,10 @@ func _ready() -> void:
# Get our texture from our material so we set our RID.
var material: ShaderMaterial = $MeshInstance3D.material_override
if material:
material.set_shader_parameter("effect_texture_size", texture_size)
material.set_shader_parameter(&"effect_texture_size", texture_size)
# Get our texture object.
texture = material.get_shader_parameter("effect_texture")
texture = material.get_shader_parameter(&"effect_texture")
func _exit_tree() -> void:

View File

@@ -119,7 +119,7 @@ func _draw() -> void:
# Draw, provided for convenience and NOT required for screen-reader support.
for i in range(item_aes.size()):
draw_rect(item_rects[selected], Color(0.8, 0.8, 0.8, 0.5), false, 1.0)
draw_string(get_theme_font("font"), item_rects[i].position + Vector2(0, 30), str(item_values[i]), HORIZONTAL_ALIGNMENT_CENTER, 40.0)
draw_string(get_theme_font(&"font"), item_rects[i].position + Vector2(0, 30), str(item_values[i]), HORIZONTAL_ALIGNMENT_CENTER, 40.0)
if has_focus():
draw_rect(Rect2(Vector2(), get_size()), Color(0, 0, 1, 0.5), false, 3.0)

View File

@@ -1,6 +1,6 @@
extends Control
@onready var variable_font_variation: FontVariation = $"TabContainer/Variable fonts/VariableFontPreview".get_theme_font("font")
@onready var variable_font_variation: FontVariation = $"TabContainer/Variable fonts/VariableFontPreview".get_theme_font(&"font")
func _ready() -> void:
@@ -51,7 +51,7 @@ func _on_LineEditCustomSTDst_tree_entered() -> void:
func _on_variable_size_value_changed(value: float) -> void:
$"TabContainer/Variable fonts/Variables/Size/Value".text = str(value)
# This is also available on non-variable fonts.
$"TabContainer/Variable fonts/VariableFontPreview".add_theme_font_size_override("font_size", value)
$"TabContainer/Variable fonts/VariableFontPreview".add_theme_font_size_override(&"font_size", value)
func _on_variable_weight_value_changed(value: float) -> void:
@@ -116,7 +116,7 @@ func _on_system_font_weight_value_changed(value: float) -> void:
$"TabContainer/System fonts/VBoxContainer/Fantasy/Value",
$"TabContainer/System fonts/VBoxContainer/Custom/Value"
]:
var system_font: SystemFont = label.get_theme_font("font")
var system_font: SystemFont = label.get_theme_font(&"font")
system_font.font_weight = int(value)
func _on_system_font_italic_toggled(button_pressed: bool) -> void:
@@ -128,10 +128,10 @@ func _on_system_font_italic_toggled(button_pressed: bool) -> void:
$"TabContainer/System fonts/VBoxContainer/Fantasy/Value",
$"TabContainer/System fonts/VBoxContainer/Custom/Value"
]:
var system_font: SystemFont = label.get_theme_font("font")
var system_font: SystemFont = label.get_theme_font(&"font")
system_font.font_italic = button_pressed
func _on_system_font_name_text_changed(new_text: String) -> void:
var system_font: SystemFont = $"TabContainer/System fonts/VBoxContainer/Custom/FontName".get_theme_font("font")
var system_font: SystemFont = $"TabContainer/System fonts/VBoxContainer/Custom/FontName".get_theme_font(&"font")
system_font.font_names[0] = new_text

View File

@@ -4,7 +4,7 @@ Showcases various Control nodes with their names affixed for easy recognition.
This demo is inspired by similar "control gallery" demos found in GUI toolkits
such as GTK.
The 3 main panels ("Basic controls", "Numbers" and "Lists")
The 3 main panels ("Basic controls", "Numbers", and "Lists")
are separated using HSplitContainer and VSplitContainer nodes.
This makes their individual size adjustable. Drag the empty
space between panels to resize them.

View File

@@ -82,7 +82,7 @@ func _process(_delta: float) -> void:
# add the brush object to draw_elements_array.
if brush_mode == BrushMode.CIRCLE_SHAPE or brush_mode == BrushMode.RECTANGLE_SHAPE:
add_brush(mouse_pos, brush_mode)
# We handle undo's differently than either pencil or eraser mode, so we need to set undo
# We handle undos differently than either pencil or eraser mode, so we need to set undo
# element_list_num to -2 so we can tell if we need to undo a shape. See undo_stroke for details.
undo_element_list_num = UNDO_MODE_SHAPE
# Since we've released the left mouse, we need to get a new mouse_click_start_pos next time
@@ -119,9 +119,9 @@ func undo_stroke() -> void:
# Now that we've undone a shape, we cannot undo again until another stoke is added.
undo_element_list_num = UNDO_NONE
# NOTE: if we only had shape brushes, then we could remove the above line and could let the user
# undo until we have a empty element list.
# undo until we have an empty element list.
# Otherwise we're removing a either a pencil stroke or a eraser stroke.
# Otherwise we're removing either a pencil stroke or an eraser stroke.
else:
# Figure out how many elements/brushes we've added in the last stroke.
var elements_to_remove := brush_data_list.size() - undo_element_list_num
@@ -204,7 +204,7 @@ func _draw() -> void:
draw_circle(brush.brush_pos, brush.brush_size / 2, brush.brush_color)
BrushMode.ERASER:
# NOTE: this is a really cheap way of erasing that isn't really erasing!
# However, this gives similar results in a fairy simple way!
# However, this gives similar results in a fairly simple way!
# Erasing works exactly the same was as pencil does for both the rectangle shape and the circle shape,
# but instead of using brush.brush_color, we instead use bg_color instead.

View File

@@ -2,20 +2,20 @@ extends Control
func _input(event: InputEvent) -> void:
if event.is_action_pressed(&"toggle_msdf_font"):
if %FontLabel.get_theme_font("font").multichannel_signed_distance_field:
%FontLabel.add_theme_font_override("font", preload("res://montserrat_semibold.ttf"))
if %FontLabel.get_theme_font(&"font").multichannel_signed_distance_field:
%FontLabel.add_theme_font_override(&"font", preload("res://montserrat_semibold.ttf"))
else:
%FontLabel.add_theme_font_override("font", preload("res://montserrat_semibold_msdf.ttf"))
%FontLabel.add_theme_font_override(&"font", preload("res://montserrat_semibold_msdf.ttf"))
update_label()
func update_label() -> void:
%FontMode.text = "Font rendering: %s" % (
"MSDF" if %FontLabel.get_theme_font("font").multichannel_signed_distance_field else "Traditional"
"MSDF" if %FontLabel.get_theme_font(&"font").multichannel_signed_distance_field else "Traditional"
)
func _on_outline_size_value_changed(value: float) -> void:
%FontLabel.add_theme_constant_override("outline_size", int(value))
%FontLabel.add_theme_constant_override(&"outline_size", int(value))
%Value.text = str(value)

View File

@@ -7,7 +7,7 @@ extends Control
var base_window_size := Vector2(
ProjectSettings.get_setting("display/window/size/viewport_width"),
ProjectSettings.get_setting("display/window/size/viewport_height")
)
)
# These defaults match this demo's project settings. Adjust as needed if adapting this
# in your own project.

View File

@@ -16,46 +16,46 @@ func _ready() -> void:
func _on_button_pressed() -> void:
# We have to modify the normal, hover and pressed styleboxes all at once
# We have to modify the normal, hover, and pressed styleboxes all at once
# to get a correct appearance when the button is hovered or pressed.
# We can't use a single StyleBox for all of them as these have different
# background colors.
var new_stylebox_normal: StyleBoxFlat = button.get_theme_stylebox("normal").duplicate()
var new_stylebox_normal: StyleBoxFlat = button.get_theme_stylebox(&"normal").duplicate()
new_stylebox_normal.border_color = Color(1, 1, 0)
var new_stylebox_hover: StyleBoxFlat = button.get_theme_stylebox("hover").duplicate()
var new_stylebox_hover: StyleBoxFlat = button.get_theme_stylebox(&"hover").duplicate()
new_stylebox_hover.border_color = Color(1, 1, 0)
var new_stylebox_pressed: StyleBoxFlat = button.get_theme_stylebox("pressed").duplicate()
var new_stylebox_pressed: StyleBoxFlat = button.get_theme_stylebox(&"pressed").duplicate()
new_stylebox_pressed.border_color = Color(1, 1, 0)
button.add_theme_stylebox_override("normal", new_stylebox_normal)
button.add_theme_stylebox_override("hover", new_stylebox_hover)
button.add_theme_stylebox_override("pressed", new_stylebox_pressed)
button.add_theme_stylebox_override(&"normal", new_stylebox_normal)
button.add_theme_stylebox_override(&"hover", new_stylebox_hover)
button.add_theme_stylebox_override(&"pressed", new_stylebox_pressed)
label.add_theme_color_override("font_color", Color(1, 1, 0.375))
label.add_theme_color_override(&"font_color", Color(1, 1, 0.375))
func _on_button2_pressed() -> void:
var new_stylebox_normal: StyleBoxFlat = button2.get_theme_stylebox("normal").duplicate()
var new_stylebox_normal: StyleBoxFlat = button2.get_theme_stylebox(&"normal").duplicate()
new_stylebox_normal.border_color = Color(0, 1, 0.5)
var new_stylebox_hover: StyleBoxFlat = button2.get_theme_stylebox("hover").duplicate()
var new_stylebox_hover: StyleBoxFlat = button2.get_theme_stylebox(&"hover").duplicate()
new_stylebox_hover.border_color = Color(0, 1, 0.5)
var new_stylebox_pressed: StyleBoxFlat = button2.get_theme_stylebox("pressed").duplicate()
var new_stylebox_pressed: StyleBoxFlat = button2.get_theme_stylebox(&"pressed").duplicate()
new_stylebox_pressed.border_color = Color(0, 1, 0.5)
button2.add_theme_stylebox_override("normal", new_stylebox_normal)
button2.add_theme_stylebox_override("hover", new_stylebox_hover)
button2.add_theme_stylebox_override("pressed", new_stylebox_pressed)
button2.add_theme_stylebox_override(&"normal", new_stylebox_normal)
button2.add_theme_stylebox_override(&"hover", new_stylebox_hover)
button2.add_theme_stylebox_override(&"pressed", new_stylebox_pressed)
label.add_theme_color_override("font_color", Color(0.375, 1, 0.75))
label.add_theme_color_override(&"font_color", Color(0.375, 1, 0.75))
func _on_reset_all_button_pressed() -> void:
button.remove_theme_stylebox_override("normal")
button.remove_theme_stylebox_override("hover")
button.remove_theme_stylebox_override("pressed")
button.remove_theme_stylebox_override(&"normal")
button.remove_theme_stylebox_override(&"hover")
button.remove_theme_stylebox_override(&"pressed")
button2.remove_theme_stylebox_override("normal")
button2.remove_theme_stylebox_override("hover")
button2.remove_theme_stylebox_override("pressed")
button2.remove_theme_stylebox_override(&"normal")
button2.remove_theme_stylebox_override(&"hover")
button2.remove_theme_stylebox_override(&"pressed")
label.remove_theme_color_override("font_color")
label.remove_theme_color_override(&"font_color")

View File

@@ -38,7 +38,7 @@ func _print_intro() -> void:
# In CSV translation, use the appropriate key in the Object.tr() function to fetch
# the corresponding translation.
# This is the same for scene nodes containing user-facing texts to be translated.
print(tr("KEY_INTRO"))
print(tr(&"KEY_INTRO"))
# CSV does not support plural translations. If you need pluralization, you must use PO instead.

View File

@@ -32,13 +32,13 @@ func _print_intro() -> void:
# In PO translation, you would use source string as the 'key' for the Object.tr() function.
# This is the same for scene nodes containing user-facing texts to be translated.
print(tr("Hello, this is a translation demo project."))
print(tr(&"Hello, this is a translation demo project."))
# PO plural translation example.
# The difference with CSV is that you must add the "plural_message" argument, because PO files
# expect the data (else undefine behaviour might occur).
var days_passed := randi_range(1, 3)
print(tr_n("One day ago.", "{days} days ago.", days_passed).format({ days = days_passed }))
print(tr_n(&"One day ago.", &"{days} days ago.", days_passed).format({ days = days_passed }))
func _on_go_to_csv_translation_demo_pressed() -> void:

View File

@@ -3,7 +3,7 @@
This project showcases how to load and save various file types without going
through Godot's resource importing system.
This is useful to load/save images, sounds, 3D scenes and ZIP archives at
This is useful to load/save images, sounds, 3D scenes, and ZIP archives at
run-time such as user-generated content, without requiring users to generate a
PCK file through Godot.

View File

@@ -234,7 +234,7 @@ func open_file(path: String) -> void:
font_file.load_dynamic_font(path)
if not font_file.data.is_empty():
font_viewer.add_theme_font_override("font", font_file)
font_viewer.add_theme_font_override(&"font", font_file)
reset_visibility()
font_viewer.visible = true
export_button.disabled = true
@@ -248,7 +248,7 @@ func open_file(path: String) -> void:
#
# Use `ProjectSettings.load_resource_pack()` to load PCK or ZIP files exported by Godot as
# additional data packs. That approach is preferred for DLCs, as it makes interacting with
# additional data packs seamless (virtual filesystem).
# additional data packs seamlessly (virtual filesystem).
zip_reader.open(path)
var files := zip_reader.get_files()
files.sort()

View File

@@ -42,7 +42,7 @@ func load_game() -> void:
player.sprite.rotation = config.get_value("player", "rotation")
# Remove existing enemies before adding new ones.
get_tree().call_group("enemy", "queue_free")
get_tree().call_group(&"enemy", &"queue_free")
var enemies: Array = config.get_value("enemies", "enemies")
var game := get_node(game_node)

View File

@@ -51,7 +51,7 @@ func load_game() -> void:
player.sprite.rotation = str_to_var(save_dict.player.rotation)
# Remove existing enemies before adding new ones.
get_tree().call_group("enemy", "queue_free")
get_tree().call_group(&"enemy", &"queue_free")
# Ensure the node structure is the same when loading.
var game := get_node(game_node)

Some files were not shown because too many files have changed in this diff Show More