lolibar

statusbar tools for windows written in C#

Stars
3

lolibar | statusbar for Windows [ 10, 11 ] | C#

🪼Introduction

This project is toolkit for modders, which grants capabilities to create statusbars. There're no ready-to-use executable on Releases page, so if you want to gain one, you can configure it using this toolkit!

🪼Alternatives

🪼Pre-requirements

All modding operations is highly recommended to do in Visual Studio 2022. Moreover, to build this project, you have to install .NET8.0 SDK. Actually, you can use other .net sdks as well, but main branch targets to .net8.0, so any issues with different .net versions you have to solve locally.

🪼Modding Basics

Have you ever tried to write mods for video games? So, this toolkit provides the same vibes:

namespace LolibarApp.Mods;

class ExampleEmptyMod : LolibarMod
{
    public override void PreInitialize()
    {
        // Put your Pre-Initialization code here...
    }
    public override void Initialize()
    {
        // Put your Initialization code here...
    }
    public override void Update()
    {
        // Put your Updatable code here...
    }
}

As you can see, this code looks familiar with any other mod body. You can handle every single part of Lolibar's libraries here!

🪼Your First mod

[!TIP] All mods is highly recommended to be stored in Mods folder.

The first step of your modding journey - create a mod class. Let me explain basics on MyFirstMod.cs example:

namespace LolibarApp.Mods;

class MyFirstMod : LolibarMod
{
    public override void PreInitialize() { }
    public override void Initialize() { }
    public override void Update() { }
}

Code you can see above is absolute minimum your mod must contain. Without that, Lolibar won't compile properly. Now, talk about every part in details ↓↓↓

namespace LolibarApp.Mods;

namespace have to be set as LolibarApp.Mods unless you want to prevent your mod from being detected by ModLoader.

public override void PreInitialize() { }

PreInitialize() hook useful to initialize something before Initialize() hook invoked, because calls before initialization process started. I recommend you to setup all properties in there. What is properties? Let's talk about them, referencing to LolibarProperties class:

// Properties stores values, which uses in Lolibar's resources.
// It can be anything, starting from styles, such as Main Color (BarColor),
// ending with triggers, simulates or provides something.

// Basic example:
public override void PreInitialize()
{
    BarUpdateDelay            = 250;
    BarHeight                 = 36;
    BarColor                  = LolibarHelper.SetColor("#2a3247");
    BarContainersContentColor = LolibarHelper.SetColor("#6f85bd");
}

This example overrides 4 different properties, which will be applied to all Lolibar's components including Lolibar itself during initialization process.

public override void Initialize() { }

Initialize() hook is about to initialize something on application's launch. The most common usage is initialization of the containers. What is container? Let's get into it, referencing to LolibarContainer class:

// All "Buttons" / "Data Fields" inside your statusbar
// have to be generated by LolibarContainer class.
// This class automatically does job of formatting,
// structing and comparing content inside specified components.
// So that component's Frankenstein can be called simply - `Container`.

// How to create one, using LolibarContainer class:
public override void Initialize()
{
    LolibarContainer HelloContainer = new()
    {
        Name          = "HelloContainer",
        Parent        = Lolibar.BarCenterContainer,
        Text          = "Hello!",
        HasBackground = true
    };
    HelloContainer.Create();
}

Result of the initialization process we can observe after Lolibar's launch.

Here we can see a new object instance, that has a couple of local properties inside. Let me explain about those, which certain example has:

  • Name - Initial container name. Uses for automatic resources initialization;
  • Parent - Any other container, where this should be placed;
  • Text - Text content of the container;
  • HasBackground - Trigger to draw border around the container. It's semi-transparent and fits well with the whole statusbar theme.

I've used Lolibar.BarCenterContainer here, which is tricky part to put HelloContainer into one of default containers. Lolibar has 3 default containers to place custom ones inside:

  • BarLeftContainer - Most left side of the statusbar;
  • BarRightContainer - Most right side of the statusbar.
  • BarCenterContainer - This container is centered relative to BarLeftContainer and BarRightContainer. Ain't a center of the status bar!

We've drawn a static container. Now, let's update it's content, using Update() hook:

public override void Update() { }

This hook is about to update something along statusbar's execution process. Update() hook has an Update Delay - time span, between loop iterations. Yes, Update() is an infinite loop hook, so keep it in mind. The interations delay can be modified by BarUpdateDelay property, which can be setup in PreInitialize() hook as well. To understand Update()'s principles better, check Examples section. By the way, Examples section is great start point in your modding journey, because it has various examples of how to create one or other thing. Anyway, let's get back into updating info in HelloContainer:

using LolibarApp.Source.Tools;
using LolibarApp.Source;

namespace LolibarApp.Mods;

class MyFirstMod : LolibarMod
{
    // I've made it external to get access to it from other hook.
    LolibarContainer HelloContainer;

    public override void PreInitialize() { }
    public override void Initialize()
    {
        HelloContainer = new()
        {
            Name = "HelloContainer",
            Parent = Lolibar.BarCenterContainer,
            Text = "Hello!",
            HasBackground = true
        };
        HelloContainer.Create();
    }
    public override void Update() 
    {
        HelloContainer.Text = DateTime.Now.ToString();   // Change instance's text content ...
        HelloContainer.Update();                         // ... And update it in resources

        // Now, text inside `HelloContainer` will be equal current system's time every `BarUpdateDelay`.
    }
}
// Simple enough, isn't it? 🐳

HelloContainer shows current time.

To build 'n run Lolibar project, you need to select preferred profile at the top of the VS and push any of buttons.

🪼Next steps

Inspired enough to start modding? Then, get into Examples section to learn more about Lolibar's capabilities. As I mentioned before, Examples section is great start point in your modding journey. Especially Basics section. Good luck!

🪼Special thanks

🪼At the end...

😎My lolibar's mod showcase

☕Have any questions or suggestions? Feel free to contact me on my Discord Server!