-
-
Notifications
You must be signed in to change notification settings - Fork 1
Improve icon logic #9
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
Conversation
Signed-off-by: GitHub <noreply@github.com>
Signed-off-by: GitHub <noreply@github.com>
Removed unused UserInputService import. Signed-off-by: Ryan Luu <ryan.luu@ryanluu.dev>
Signed-off-by: Ryan Luu <ryan.luu@ryanluu.dev>
Signed-off-by: Ryan Luu <ryan.luu@ryanluu.dev>
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.
Pull request overview
This PR refactors the topbar icon logic to use an event-driven approach for synchronizing the icon's visual state with the inventory's open/close state, and improves the API documentation with practical code examples.
Key changes:
- Replaced manual input handling with
BackpackScript.StateChangedevent subscription to automatically sync icon state with inventory visibility - Modified icon toggle handler to only call
BackpackScript.OpenClose()when triggered by user interaction (viafromSourceparameter), preventing redundant toggles - Added descriptive code samples in the documentation demonstrating usage of
OpenClose()andStateChangedAPIs
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/TopbarIcon.client.luau | Refactored event handling to use BackpackScript.StateChanged for icon state synchronization and renamed image constants to uppercase |
| docs/api-reference.md | Added introductory text and code samples demonstrating OpenClose() and StateChanged usage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ryan Luu <ryan.luu@ryanluu.dev>
This pull request updates the documentation and refactors the
TopbarIcon.client.luauscript to improve clarity and functionality for the CoreGui backpack inventory toggle and state handling. The main changes include clearer sample code in the API docs and a more robust event-driven approach in the icon script.Documentation improvements:
OpenClose()from a button'sActivatedevent.StateChangedevent to detect when the inventory is opened or closed.Code refactoring and event handling:
TopbarIcon.client.luauto uppercase for clarity and consistency.BackpackScript.StateChanged.Eventto update the icon's selected state based on inventory open/close events.BackpackScript.OpenClose()when the toggle is initiated by the user, improving separation of concerns and preventing redundant toggles.