Modding Feature: UI Components Setter Functions or Return by Reference

Discuss modding questions and implementation details.
Post Reply
IAmTheClayman
Posts: 9
Joined: Fri Dec 07, 2018 7:31 am

Modding Feature: UI Components Setter Functions or Return by Reference

Post by IAmTheClayman »

Would it be possible to either add public 'setter' functions to all UI components or otherwise allow the getter function to return components by reference rather than copy? It seems like it is currently incredibly difficult to make mods that in any way alter existing UI components.

For example, I am working on a mod with the goal of replacing the existing vertical Vitals bars with horizontal bars like those scene in Skyrim and ESO. Unfortunately the DaggerfallHUD class only has the following two public methods pertaining to HUDVItals:

Code: Select all

public HUDVitals HUDVitals
{
     get { return vitals; }
}
public bool ShowVitals { get; set; }        
So it appears that currently a mod could deactivate the display of the default Vitals, but there is not way to easily implement a custom layout for Vitals. I'd love to be able to do something as simple as

Code: Select all

GameObject.Find("DaggerfallUI").GetComponent<DaggerfallUI>().DaggerfallHUD.HUDVitals = new NewHUDVitals();
where NewHUDVitals inherits from HUDVitals.cs but allows me to change the scale, layout, rotation, etc. of Vitals bars.

Narf the Mouse
Posts: 833
Joined: Mon Nov 30, 2015 6:32 pm

Re: Modding Feature: UI Components Setter Functions or Return by Reference

Post by Narf the Mouse »

You can do what you want with System.Reflection; however, it's hacky, and not guaranteed to keep working.
Previous experience tells me it's very easy to misunderstand the tone, intent, or meaning of what I've posted. If you have questions, ask.

IAmTheClayman
Posts: 9
Joined: Fri Dec 07, 2018 7:31 am

Re: Modding Feature: UI Components Setter Functions or Return by Reference

Post by IAmTheClayman »

Narf the Mouse wrote: Mon Nov 11, 2019 8:52 am You can do what you want with System.Reflection; however, it's hacky, and not guaranteed to keep working.
Ooof. I did modding via reflection for a project in Outward since that game didn't have any modding tools and it was a nightmare.

Narf the Mouse
Posts: 833
Joined: Mon Nov 30, 2015 6:32 pm

Re: Modding Feature: UI Components Setter Functions or Return by Reference

Post by Narf the Mouse »

IAmTheClayman wrote: Mon Nov 11, 2019 3:54 pm
Narf the Mouse wrote: Mon Nov 11, 2019 8:52 am You can do what you want with System.Reflection; however, it's hacky, and not guaranteed to keep working.
Ooof. I did modding via reflection for a project in Outward since that game didn't have any modding tools and it was a nightmare.
In the simplest case, all you may need to do is get the backing FieldInfo for the vitals field returned by HUDVitals, and use the FieldInfo's SetValue method.

But yeah it'll probably be more complicated than that, and it might even be easier to wait for official mod support for HUDVitals.
Previous experience tells me it's very easy to misunderstand the tone, intent, or meaning of what I've posted. If you have questions, ask.

Post Reply