Open Captain-Of-Coit opened 11 months ago
It'll likely only change in the following way (subject to change):
import React, {useState} from 'React'
+import {registerPanel} from 'hookui-framework'
-const $MyPanel = () => {
+const $MyPanelContents = () => {
const [pressed, setPressed] = useState(false)
- // [...] entire $Panel
+ // [...] elements inside of $Panel body/content
}
-window._$hookui.registerPanel({
+registerPanel({
id: "example.hello-world",
name: "Hello World",
icon: "Media/Game/Icons/Trash.svg",
- component: $MyPanel
+ component: $MyPanelContents
})
Seems like I'll get to this today.
The good news is that you'll be able to continue to use your existing code for 0.4.0 without having to change anything, so mod authors don't have to stress about people updating to 0.4.0 while the players do so.
Then probably for 0.5.0 it'll be incompatible by then, but hopefully this should be making the whole process a lot easier for both players and mod authors :)
So, I've realized the Panels are kind of registered wrong.
Right now, you register a component and that one is what you toggle on/off. It can be whatever in reality, and if you pass in something like a empty div with text as a child and no styling, it'll inject just that, "breaking" the game UI
Instead, the
registerPanel
API will change to accept:So instead of passing in a panel, HookUI will create the panel and you'll pass in the contents of the panel
This issue will also contain potentially other API changes that will happen for 0.4.0, but not sure exactly if there will be more for now.