Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't store deprecated auto_translate property #90685

Merged
merged 1 commit into from
Apr 15, 2024

Conversation

timothyqiu
Copy link
Member

With the introduction of Node.auto_translate_mode, Control.auto_translate becomes a proxy for it.

But auto_translate is currently still stored in tscn files. This results in unexpected behavior: If a parent node is set to have disabled translate mode, all child nodes will set the mode to "disabled" when that scene is instantiated (instead of keeping "inherit") .

This PR makes Control.auto_translate property not stored. It is still OK to open old scenes using auto_translate. But the property will not exist anymore once the scene is saved.

CC @YeldhamDev


To reproduce the problem, save the following script and run godot --headless -s /path/to/mrp.gd.

mrp.gd
extends SceneTree

func _process(delta: float) -> bool:
    var parent := Node.new()
    parent.name = "Parent"
    root.add_child(parent)
    var child := Control.new()
    child.name = "Child"
    parent.add_child(child)
    child.owner = parent

    print("=== Init State ===")
    _show_state(parent)

    print("=== Disable Parent ===")
    parent.auto_translate_mode = 2
    _show_state(parent)

    print("=== Instantiated ===")
    var packed := PackedScene.new()
    packed.pack(parent)
    var scene := packed.instantiate()
    _show_state(scene)
    scene.free()

    return true


func _show_state(node: Node) -> void:
    var mode: String
    match node.auto_translate_mode:
        0:
            mode = "Inherit"
        1:
            mode = "Always"
        2:
            mode = "Disabled"

    if node is Control:
        print("%8s\tMode:%8s\tAuto:%s" % [node.name, mode, node.is_auto_translating()])
    else:
        print("%8s\tMode:%8s" % [node.name, mode])

    for child in node.get_children():
        _show_state(child)

Output:

=== Init State ===
  Parent	Mode: Inherit
   Child	Mode: Inherit	Auto:true
=== Disable Parent ===
  Parent	Mode:Disabled
   Child	Mode: Inherit	Auto:false
=== Instantiated ===
  Parent	Mode:Disabled
   Child	Mode:Disabled	Auto:false

The "Instantiated" section should be the same as the "Disable Parent" section.

@timothyqiu timothyqiu requested a review from a team as a code owner April 15, 2024 06:12
@YeldhamDev YeldhamDev added this to the 4.3 milestone Apr 15, 2024
@timothyqiu timothyqiu requested a review from a team as a code owner April 15, 2024 06:23
@akien-mga akien-mga merged commit a44b0b6 into godotengine:master Apr 15, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@timothyqiu timothyqiu deleted the auto-translate-legacy branch April 15, 2024 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants