[go: up one dir, main page]

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

Expose GridMapEditorPlugin to scripts and add methods to manipulate to the selection and selected palette item #99639

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

badsectoracula
Copy link
Contributor

This PR allows editor scripts and plugins to access GridMapEditorPlugin and adds methods for extending the editor's functionality by allowing manipulation of the selection and selected palette item.

This addresses godotengine/godot-proposals#11161. It can also help with custom grid map tools that could be added later by scripts as i wrote in godotengine/godot-proposals#11206 (comment).

The video below shows how it could be used to implement a script that replaces tiles in the selection:

Godot.Gridmap.Selection.Plugin.webm

(obviously this is just an example -and probably the replace functionality should be core part of the editor- to show how the API can be used but it could also be used for making game-specific tools like assigning data -to be stored elsewhere, like in a node- to cells, or to pre-fill a gridmap with some procedural code that can be then manually edited, or to quickly set data and/or colors -especially useful for data as they can be something different than color- if #94282 is merged, etc)

@badsectoracula badsectoracula requested review from a team as code owners November 24, 2024 17:48
@badsectoracula badsectoracula force-pushed the get-selected-gridmap-cells branch 2 times, most recently from 6589c81 to ea8cf77 Compare November 24, 2024 17:54
Copy link
Contributor
@Mickeon Mickeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surface-level look at the docs

modules/gridmap/doc_classes/GridMapEditorPlugin.xml Outdated Show resolved Hide resolved
modules/gridmap/doc_classes/GridMapEditorPlugin.xml Outdated Show resolved Hide resolved
modules/gridmap/doc_classes/GridMapEditorPlugin.xml Outdated Show resolved Hide resolved
modules/gridmap/doc_classes/GridMapEditorPlugin.xml Outdated Show resolved Hide resolved
@badsectoracula
Copy link
Contributor Author

Latest PR fixed CI and made the modifications to the docs and API @Mickeon suggested and fixed the issues stemmed from multiple instantiations of the GridMapEditorPlugin class during its registration that i didn't notice. Instead of doing it the constructor, the UI control is now created when the plugin is attached to the tree (and destroyed when it is detached), which i think is a better place to create it anyway.

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.

2 participants