Skip to content

Installation and Mod Integration

Zach Hembree edited this page Feb 24, 2023 · 3 revisions

Applicable Version(s): 0.9.9+

Before you get started making mods with this framework, you'll need to do the following:

  1. Install the client:

    • Get the latest release from RichHudFramework.Client and copy the Shared and Client folders to /{ModName}/Data/Scripts/{ModName}/RichHudFramework. That last folder isn't strictly necessary; it's just there to keep everything organized.

      There are four versions of the client:

      • The full version, provided in the source zip. If you're not sure what you need, just stick with this.
      • MinLib: A version of the client with a reduced UI library
      • Term: A version of the client stripped down to just the terminal
      • Font: A version of the client stripped down to just the Font Manager
  2. Have the client initialized from your main class:

    • Add the RichHudFramework.Client namespace with a using statement and call RichHudClient.Init() on session Init. You could technically initialize the client as early as LoadData() but RichHudMaster won't respond until Init() is called.
  3. Add Rich HUD Master to your mod list:

    • Get a copy of RHM either by subscribing to it in the workshop or by downloading the latest release from GitHub and installing it manually.

    • Once you've published your mod to the workshop you'll need to add the workshop version of RHM to your mod's dependency list.

    • Before you ask, no it doesn't matter in which order the master module and your mod are loaded.

If you're basing your main class on MySessionComponentBase, then it should look something like this:

using RichHudFramework.Client;
using VRage.Game;
using VRage.Game.Components;

// It doesn't matter whether or not this class is being updated; it simply wasn't
// required for this example.
[MySessionComponentDescriptor(MyUpdateOrder.NoUpdate)]
public sealed class MainModClass : MySessionComponentBase
{
    public override void Init(MyObjectBuilder_SessionComponent sessionComponent)
    {
        RichHudClient.Init(DebugName, HudInit, ClientReset);
    }

    private void HudInit()
    {
        /*Your mod has been successfully registered with RichHudMaster
        and it is now safe to start using the framework.*/
    }

    public override void Draw()
    {
        if (RichHudClient.Registered)
        {
            /* If you need to update framework members externally, then 
            you'll need to make sure you don't start updating until your
            mod client has been registered. */
        }
    }

    private void ClientReset()
    {
        /* At this point, your client has been unregistered and all of 
        your framework members will stop working.
		
        This will be called in one of three cases:
        1) The game session is unloading.
        2) An unhandled exception has been thrown and caught on either the client
        or on master.
        3) RichHudClient.Reset() has been called manually.
        */
    }
}

In most cases, you won't be using the ClientReset callback; everything is automatically purged when UnloadData() is called anyways. Its primary purpose is just to let you know if it's closed unexpectedly for the reasons stated above.

If you're designing your mod to be reloadable during the game session, then you can use RichHudClient.Reset() to reset the client before reinitializing your mod.

Important: If your mod defines multiple session components decorated with the MySessionComponentDescriptor attribute, it's important that you initialize the client from only one session component. In that case, the client would be initialized by whichever component happens to init first, and the init callback will only be invoked for that component, not any of the others.