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

Ability to change order of elements in export (Array) #23

Closed
JustYourAverageJosh opened this issue Sep 5, 2019 · 3 comments · Fixed by godotengine/godot#47538
Closed
Milestone

Comments

@JustYourAverageJosh
Copy link

JustYourAverageJosh commented Sep 5, 2019

Describe the project you are working on:

Any project that uses an export (Array). for example an export (Array, PackedScene)

Describe how this feature / enhancement will help your project:

If I need to iterate through array, but need it to be in a certain order, and I want to add an element (in this case a packedscene) at a certain index. Right now I have to erase every element until I get to the index I want, insert the new element, then reinsert every element after.

Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
Current:
export_array

There are a few ways to add this, for example:
-arrows next to the element index number to move it up or down the array
-Being able to drag the elements to sort them (however would not work with more than 1 page)
-Editable index number that will re-arrange elements according to the number you change it to
-"Insert at index #" option at top of the array
export_array_new

Describe implementation detail for your proposal (in code), if possible:

Sorry, I'm not sure how it would be implemented in code :(

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

Possibly, for example by making a new export var and, in code, inserting that var to the export array at the index you want, but the point of exports are to be able to change it through the inspector right?

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

Yes, this is a enhancement to the already implemented export arrays, which makes them easier to edit.

@girng
Copy link

girng commented Sep 5, 2019

interesting idea.
is it possible to make it work with https://docs.godotengine.org/en/3.1/classes/class_array.html#class-array-method-sort-custom? or would it need added functionality to the core?

@Xrayez
Copy link
Contributor

Xrayez commented Sep 5, 2019

I actually had to implement a custom EditorPlugin just to be able to rearrange those array elements more easily.

@willnationsdev
Copy link
Contributor

willnationsdev commented Sep 5, 2019

In order to make this change, someone would need to add the up/down arrows (which I believe is a SpinBox control node) to be adjacent to the displayed index inside the EditorPropertyArray class in editor/editor_properties_array_dict.h/.cpp. Might also require changes to its ::setup() method. You would then need to connect to the value changes in the SpinBox and program it to trigger a swap operation with the element above/below it (involves copying the value, FYI).

Edit: a more complicated operation would be to add drag-n-drop support, as also suggested by OP, where people click and drag from a specific drag icon (I think that's usually three horizontal lines or something? Could be wrong...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants