Closed randombyte-developer closed 7 years ago
It depends on what 'mode' ChatUI is loaded as. It can either be loaded as the full interface or as a 'service' purely for other plugins. This is controlled by the user with the interfaceEnabled
config setting.
A plugin can test for which state it's in with ChatUI.instance().isServiceOnlyMode()
interfaceEnabled=false
(isServiceOnlyMode() == true
)Grab the PlayerChatView
with ChatUI.getView(player)
We can safely cast this to ExternalServiceView
Now you can set the TopWindow
of the view with setWindow
A TopWindow
is something that has full control of the player's chat view, could also be called an 'overlay'.
As of right now, the text editor is a TopWindow
, so you can set the window with view.setWindow(new TextEditorWindow());
To close the window and resume normal chat (messages get buffered behind), call view.setWindow(null)
interfaceEnabled=true
(isServiceOnlyMode() == false
)You can either opt-in to being a 'feature' or be standalone. Features can be enabled/disabled in the config.
Features are essentially pluggable modules that 'install' themselves onto a PlayerChatView
. Features install themselves in the onNewPlayerView
method of AbstractFeature
.
If you're going standalone, get the view with ChatUI.getView(player)
In either case, you need to obtain a PlayerChatView
.
You need to check the view is an instance of ActivePlayerChatView
, if it's not, the player has disabled chatui in their own settings.
With the active view, calling getWindow()
will return a Window
capable of holding Tab
instances.
Because the text editor requires features that tabs have, you need to call createTab(title)
on the text editor.
Then the tab can be added to the window. view.getWindow().addTab(new TextEditorWindow().createTab(title), true);
You can also add buttons to the 'new tab' page with view.getNewTab().addButton(label, action)
An example of creating a text editor tab can be found in DemoContent
Hope that helps :)
PS: I'll be writing proper documentation to explain how to use the API.
Thanks! :) I'll try it out.
I have now added a more detailed write-up of integrating with Chat UI on the wiki so I will close this issue.
Hi!
Could you point me in the direction of creating a text editor? You don't have to provide code. Just the steps involved(I saw
registerFeature()
but don't know how to display just the editor to a player).