-
Notifications
You must be signed in to change notification settings - Fork 0
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
Main project discussion thread #2
Conversation
I've added a basic UI component for the command palette - here's a screenshot (on Nord theme ❤️ ) I've added three commands for now - converting some Mainframe functions into callbacks in the process, and all three are working correctly - properly registering and deregistering (although the Close Project one might be updated more frequently than necessary - I'm not sure). Added a new option to the debug toolbar dropdown for now, as you suggested. The "Command" box is for the search input (just a dummy for now, though). Please try it and point out any changes or improvements :) In the meantime, I'll continue with adding more commands, I guess. Also, please ignore the React warnings for now - I'll fix that in a while 😅 |
I've added all the global commands from the Trello list in Mainframe. Everything seems to be working well, but five of the commands' handlers are updated on every Mainframe rerender - I've marked these on Trello (see the "Commands added" list). I'll start with fixing them now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great progress! :D
I've not yet tried it but I read the code. :) As we already discussed the overall approach looks good.
I wrote tons of nitpicking, because I'm very picky (sorry ;)) but also because it's important to get the convention good now to avoid extra work later.
Overall this is a very good start. Looking forward to what is coming next 👍👍
I started with fixing the unnecessary handler updates, and turns out it will need a little bit more than just adding React.useCallbacks. For example, some functions use things that are defined after that function, and adding those things to dependency lists means I'll have to reorder the functions so that they're used after being declared. Also, every function that is somehow called in any of the command handlers will have to be wrapped in a useCallback to prevent unnecessary handler updates - so maybe around 10-15 (or 20) useCallbacks will be added. Should I proceed with this? Otherwise, I can focus on finishing the UI part first, then move on to fix these issues. |
I've added a very temporary keyboard shortcut for opening the command palette (see previous commit 07727fc). It's just a useEffect in Mainframe. The code looks pretty ugly - it's more like "yeah it works" than actual code. The vanilla JS logic is a bit different than before. I realized that there was an issue with the original approach I mentioned. The problem was that clicking on the empty space in properties panel, etc led to focus somehow going to the body tag, which is outside |
I think it's fine for now! Would be great to move this to a custom hook provided |
Done. I've moved the code to a custom hook in I'll probably move it to a more appropriate location (and make it more flexible) when I start with shortcuts, since this piece will be reused then to enable and disable shortcuts according to whether an overlay is open. |
Yes, we'll see how to handle customizable shortcuts later (we'll need them here, in commands, in KeyboardShortcuts.js and a few other places). It's fine to use a hardcoded shortcut for now because everything else is hardcoded. Shortcuts will probably be stored in preferences, with maybe a context/hook to get the shortcut and use it in a command/KeyboardShortcuts.js (in the most appropriated format). |
Done. Moved the edit layer effects logic into scene editor. Split the scene editor commands into panel-specific parts as you said, and its certainly cleaner now! |
The next thing (and maybe last thing related to commands?) is to add a command to ToolbarIcon. Here's what I'm thinking:
|
Right there are some limitations, so either we:
While I like the idea of adding a button = automatically adding a command, which is nice on the paper, it's maybe not worth the complexity (especially for options => this would mean adding a new abstraction about menu/options... not a big fan). So let's go for just adding commands in the Toolbar components and call it a day :) It should still result in something that is very easy to maintain and understand, so it's actually a better solution when thinking about it. |
I've added commands for almost every toolbar button in scene editor and events editor, and it's working fine. For each toolbar, I've created another file Also, I realized a few commands are still left - the ones corresponding to items under "Game settings" in Project Manager (Game properties, global variables, etc). Adding them to ProjectManager won't work directly because it gets rerendered only when its opened so dialog-related state updates won't trigger opening the dialog. I can add edit: Also, are there any other commands that are to be added now? |
@4ian I've fixed unnecessary updates for some commands, specifically the "Edit layer effects" command and three event sheet toolbar commands. With that, I don't think there are any more significant "update leaks" for any command. Some commands haven't been added, see above message for that. If there's nothing else left, should I clean up and create a PR on the main repository? |
I think it's a good time for a PR! :)
Sounds good, thanks for that!
I'm fine with both :)
I think that yes it's a good solution. Basically this means that the existing
If we have commands for all toolbars, for all stuff in the ProjectManager, I think we're in good shape! Let's open a PR and see if we miss commands and add them on the go :) |
Didn't really understand - is the term "project variables" already used for something else in GDevelop? |
No, it's a proper term for what you've done. It's just that I chose "global variable" for the interface shown to the user and for the documentation (like here). |
Closing this one. Opened #3 for work on shortcuts. |
No description provided.