crownengine / crown

The flexible game engine.
https://www.crownengine.org
Other
2.14k stars 154 forks source link

tools: remove duplicated extension entries in the "All" filter #131

Closed dbartolini closed 1 year ago

dbartolini commented 1 year ago

In File > Import, notice duplicated "*.png".

arisprogramming commented 1 year ago

Please in which file should I notice duplicated "*.png"? Could you guide me on how to get to the file? I can't find any file named "Import"

NB: This is my first time I'm contributing to an open source project so if you could guide me to help you I'll appreciate. Thanks.

dbartolini commented 1 year ago

This is the line which populates the Gtk.FileFilter with duplicated entries: https://github.com/crownengine/crown/blob/0c543bbdf584ed7bf9aa8c7044f3b0a989e1201f/tools/level_editor/project.vala#L555

The filter is then used in the Import dialog File > Import, there you can notice the duplicated "*.png" entries: image

SeanKuehl commented 1 year ago

Hello, I'm looking to solve this issue. I'm not sure where the duplicate is coming from and my solution would be to search for and remove the duplicate from the list before it's added to the view. Would this solution be ok or were you looking to try and remove the duplicate .png at it's source?

dbartolini commented 1 year ago

Distinct ImporterData instances may support common extensions. Think SpriteImporter and TextureImporter, they both support png files and have that string in the extensions field of their ImporterData instance.

No check for duplicated extensions is being made when we aggregate extensions from all registered ImporterData structs: https://github.com/crownengine/crown/blob/0c543bbdf584ed7bf9aa8c7044f3b0a989e1201f/tools/level_editor/project.vala#L554

You can either skip adding duplicated extensions (by specializing add_all() for example) or remove duplicates in some way after they have been added.