-
Notifications
You must be signed in to change notification settings - Fork 9
Information boxes
Giorgio Garofalo edited this page Feb 5, 2021
·
3 revisions
When the user sees information about a game element (from Show menu or by CTRL+clicking it) an information box is opened and an event is called: onInfoBoxOpen(box)
The box
object consists of two parts: head
, which contains the imageView
, and body
, which in most cases contains title
, subtitle
, text
and url
.
All of these values can be modified from inside the event.
function onInfoBoxOpen(box) {
if(box.getBody().getTitle().startsWith('Chorus')) {
box.getBody().setTitle('Chorus');
box.getBody().setText('Chorus is sick');
box.getBody().setUrl('https://chorusmc.org');
box.getHead().getImageView().setImage(getChorusIcon());
box.getHead().getImageView().setFitWidth(50);
}
}
However, after running this sample you'll notice that the text changes because of an ongoing HTTP connection. You can easily prevent the connection to start by calling box.setCallUpdate(false);
If you want to handle the box after the update, you can create a listener for onInfoBoxContentUpdate(box)
.