Release 1.2.6 Add get_druid from registered druid widgets for various… - #346
Conversation
There was a problem hiding this comment.
Pull request overview
This PR prepares the 1.2.6 release by introducing a new way to retrieve a registered Druid instance from game object scripts (druid.get_druid) and adding an instance-level style setter (druid_instance:set_style), alongside the usual version/documentation bumps.
Changes:
- Add
druid.get_druid(gui_url)to return the registered Druid instance (without cross-context event wrapping). - Add
druid_instance:set_style(style)to change the style used for subsequently created components. - Bump project/version references and record the new APIs in the changelog.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| wiki/changelog.md | Adds 1.2.6 release notes describing the new APIs. |
| README.md | Updates dependency ZIP tag to 1.2.6. |
| game.project | Bumps project version to 1.2.6. |
| druid/system/druid_instance.lua | Adds set_style on the Druid instance to change the style for future components. |
| druid/druid.lua | Adds get_druid and stores registered instance in widget registration entries. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| ### Druid 1.2.6 | ||
| - [System] Add `druid.get_druid(gui_url)` to get the Druid instance bound with `druid.register_druid_as_widget()` from a game object script | ||
| - Returns the instance as is, without cross-context events wrapping, unlike `druid.get_widget()` | ||
| - Returns `nil` if there is no Druid instance registered for this url | ||
| - [System] Add `druid_instance:set_style(style)` to set the style of the Druid instance | ||
| - The style is applied to the components created after this call, already created components keep their style | ||
| - Allows to set the style from a game object script: `druid.get_druid(url):set_style(my_style)` |
| function M.get_druid(gui_url) | ||
| if type(gui_url) == "string" then | ||
| gui_url = msg.url(nil, nil, gui_url) | ||
| end | ||
|
|
||
| gui_url = gui_url or msg.url() | ||
| local registered_druids = REGISTERED_GUI_WIDGETS[gui_url.socket] | ||
| if not registered_druids then | ||
| return nil | ||
| end | ||
|
|
||
| for index = 1, #registered_druids do | ||
| local druid = registered_druids[index] | ||
| if druid.fragment == gui_url.fragment and druid.path == gui_url.path then | ||
| return druid.instance | ||
| end | ||
| end | ||
|
|
||
| return nil | ||
| end |
| ---Set a style of Druid instance. Pass nil to reset to the default style. | ||
| ---The style is applied to the components created after this call, already created components keep their style. | ||
| ---@param style table|nil The Druid style table | ||
| ---@return druid.instance self The Druid instance itself for chaining | ||
| function M:set_style(style) | ||
| self._style = style or settings.default_style | ||
|
|
||
| return self | ||
| end |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #346 +/- ##
==========================================
- Coverage 70.75% 70.57% -0.19%
==========================================
Files 32 32
Lines 4562 4577 +15
==========================================
+ Hits 3228 3230 +2
- Misses 1334 1347 +13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… manipulations