Toasts
Toasts are cool little popups that show on the top right of your game
These are useful for quick notifications that you want to disappear quickly
First you need to enable them in f2 - Misc - Enable notifications
Watch out though! Every user also has to enable this, so make sure your plugin page or interface is quite clear that this is necessary
Now to the code
Make a toast pop up with GameWrapper.Toast()
There are 7 parameters. The first two are required. They are
- The title, which is the word on top
- The text, which is the smaller text below
- The texture name which I’ll explain in the next paragraph
- The time to show the toast, which defaults to 3.5 seconds
- The ToastType, which chooses the color and defaults to black
- The width in pixels. The toast automatically resizes to fit your text, so don’t worry about these too much
- The height in pixels
If you want to have a custom image, load it in your onLoad() using GameWrapper.LoadToastTexture(). Provide the function with a name for your toast, and the path to the image. Most likely you’ll want it to be in the data folder.
Toasts can be one of 4 colors based on the ToastType
I’ve made an example using CoolPlugin. I put this code in the onLoad() in CoolPlugin.cpp and cool.png in the bakkesmod/data
folder
|
|
The result when I call cool_toast
from the f6 console
For perspective, it’s quite small but still legible
Full code here https://github.com/ubelhj/BakkesModStarterPlugin/tree/toasts