💡Custom Boot Styles
Make your own custom boot style!
Directly after GRILO reads the configuration file, GRILO proceeds to call the boot style parser to populate all the customized boot styles. It checks for .dll files found under the GRILO/Styles directory and parses them as appropriate.
If the .DLL file is parsed correctly according to the .NET runtime type, the installer will proceed to check the file for any types implementing the BaseBootStyle abstract class.
If found, it adds the custom boot style to the custom boot styles list with the name of the file as the name of the style.
When GRILO attempts to parse the name of your custom boot style, it first finds the base boot styles that exist under GRILO. If it can't be found, it attempts to grab a boot style from the custom boot style list that the parser loaded. If it still can't be found, it uses the default bootloader style.
Implementing your style
To implement your custom boot style, these steps must be followed:
Press
Create a new projecton Visual Studio homepageFind
Class Libraryand double-click itWrite your mod name, like in our example,
MyFirstMod.Make sure that .NET 6.0 is used. Press
Create.Right-click on
Dependencies->Manage NuGet Packages, findGRILO.Bootloader, and install it.Once the package is installed, go to the
Class1.cssource fileWrite next to the class file
: BaseBootStyle, IBootStyleand import the required namespace byusing GRILO.Bootloader.BootStyle;.Override the necessary methods using the
overridekeyword for each one as appropriate.public override Dictionary<ConsoleKeyInfo, Action<BootAppInfo>> CustomKeys { get; }public override string Render()public override string RenderHighlight(int chosenBootEntry)public override string RenderModalDialog(string content)public override string RenderBootingMessage(string chosenBootName)public override string RenderBootFailedMessage(string content)
Now, implement everything as you wish. Once you're done, click on the Build menu and select Build Solution.
Once the solution is built, open the file explorer to the solution directory by right-clicking on the solution and selecting
Open Folder in File Explorer.Navigate to the output directory and copy the
.dllfile toSplashesunder the%localappdata%/GRILOfolder.Make note of the file name and open the GRILO configuration file,
BootloaderConfig.jsonChange the value of
Boot styleto the file name of your custom boot styleStart GRILO. Your custom GRILO bootloader style should appear instead of the regular one.
Key handling
Your custom boot style can make use of the custom key bindings to do custom actions. They can be defined by overriding the CustomKeys dictionary with a new dictionary containing the console key and the action with the boot app info passed to it as an argument, like below:
public override Dictionary<ConsoleKeyInfo, Action<BootAppInfo>> CustomKeys { get; } = new()
{
{ new ConsoleKeyInfo(...), (bai) => ... }
}If any key other than the UP ARROW, DOWN ARROW, and ENTER, the key handler attempts to parse the key according to the custom key list defined by your boot style. If the key pressed is the same as one of the defined keys, the handler executes the action with the chosen boot application, whose type is BootAppInfo, as the argument passed to it.
Bootloader state
You can also access the bootloader state by referencing the BootloaderState class. This class provides you with the following options:
WaitingForBootKeyWaitingForFirstBootKey
This can be used for your custom boot styles to change their behavior, depending on the state.
Last updated