godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.17k stars 98 forks source link

Allow adding an array of custom icons to the SceneTree #2682

Open Error7Studios opened 3 years ago

Error7Studios commented 3 years ago

Describe the project you are working on

RPG Framework

Describe the problem or limitation you are having in your project

I have a Character scene with a tool script, which has some exported properties. It is designed to be placed in the level while in the editor and given properties, such as whether it is an Enemy or a Player, (if a Player, which one), (if Enemy, whether they have a preset patrol path or not), a level stat, etc.

The problem is that you can't see at a glance which nodes you have assigned these properties to without clicking on each of them individually and checking the inspector.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Allow the user to add an array of custom icons to the SceneTree. They can then add code to their tool script to display certain icons when appropriate. This way, it would be possible to see which property values have been set for all those nodes at once.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Editor Icons Example

From the picture, you can see that the red icon means none of the required properties have been set, yellow means only some of them have, and green means all of them have.

Having the ability to assign each of the icons to a particular column would be nice, but the user can implement this on their own by putting empty icons in the cells where spaces are required.

If this enhancement will not be used often, can it be worked around with a few lines of script?

I think this would be used often by people that work with tool scripts.

Is there a reason why this should be core and not an add-on in the asset library?

I'm not sure if this would be possible with an add-on.

alexfreyre commented 3 years ago

interesting, would be useful a space so that the user can assign icons and change its order. Comes to my mind two ideas:


but I suggest some things along what is proposed:

in this editor section in the inspector or in a floating window via right click:

Calinou commented 3 years ago
  • add support to change the icon color of the current node (this apply only to the icon of this node not its class)

This could easily end up being confusing, on top of making it difficult to support both dark and light themes. (We can't assume that everyone working on a given project will be using the same editor theme configuration.)

Also, adding custom node icons can already be done using editor plugins or class_name.

alexfreyre commented 3 years ago

Also, adding custom node icons can already be done using editor plugins or class_name.

yeah, you are right :smile:

I stated the name and change the icon color to get a fast solution instead of create a new icon, if you put the name of the node to red or green you easily can distinguish a general state/group/parameter while working

trollodel commented 3 years ago

I would add something very similar as part of #2537, but IMO it should be controlled through the SceneTree directly in an editor plugin instead from tool scripts because:

dalexeev commented 3 years ago

Also, adding custom node icons can already be done using editor plugins or class_name.

It is also possible to add the icon using _get_configuration_warning:

tool
extends Node

func _get_configuration_warning() -> String:
    if condition:
        return "Tooltip"
    return ""

We can add the function Node._get_custom_icons() -> Array. For example:

@tool
extends Node

func _get_custom_icons() -> Array:
    var array := []
    if condition1:
        array.append({
                icon = load("res://icon1.png"),
                hint = "Tooltip 1",
                onclick = my_func_1,
        })
    if condition2:
        array.append({
                icon = load("res://icon2.png"),
                hint = "Tooltip 2",
                onclick = my_func_2,
        })
    # ...
    return array

This could easily end up being confusing, on top of making it difficult to support both dark and light themes.

I assume this is a user problem as they are not required to use this feature?

CookieBadger commented 1 year ago

I am trying hard to make some of my tools more intuitive and ran into an issue where something like the proposal by OP or by @alexfreyre could be very beneficial. Either coloring the nodes, giving them an icon or any other way of control over how they are displayed in the scene tree would help. @dalexeev thanks for the tip with the configuration warning. My main issue with this, that my node would then have to be a @tool and I would have to safeguard all game logic from running in the editor, because this method has to be overridden in the node itself. Or am I missing something here?