Modding the ResourceReadout (UI at the left side of the screen)

Started by obuw, February 18, 2019, 07:56:41 PM

Previous topic - Next topic

obuw

Hello all,

I'd like to make a mod that modifies or replaces the resource list that shows all your resources at the left side of the screen.

Basically I'd like to have a UI like a stockpile where you select which resources you'd like to display, and then it would only display those resources in the list and hide the rest.

I'm somewhat familiar with the basics of rimworld modding, I've made and tinkered with some xml mods in the past. But I've never done a UI mod before. So I'd really appreciate it if someone could point me in the right direction.

For starters, what exactly is the UI element called? (Edit: it's called ResourceReadout). Can I access any of its code or settings from, say, the core mod? Are there any relevant tutorials dealing with this kind of UI work that might be of use? Or perhaps any mods that do something similar that I could take a look at? I've been searching around but coming up empty so far.

Many thanks!

Mehni

ResourceReadout

Yes, you can use pretty much all code from RimWorld.

https://rimworldwiki.com/wiki/Modding_Tutorials/ModSettings

The modding tutorials on the wiki are good. Read them all.

As far as the approach goes, I'd use Harmony's methodreplacer to swap out the constructor. It wouldn't be *very* compatible, but "imma overhaul the entire resource list" wasn't going to be very compatible from the start.

Make your code performant. Stuff that runs on the UI like that is going to need it.

obuw

Thanks for the reply.

Um, not sure why you thought ModSettings would be relevant? Oh maybe you thought I want the user to select resources from a mod settings page? Naw it will be an ingame menu.

So doing a search for ResourceReadout, I only find references to resourceReadoutPriority and resourceReadoutAlwaysShow. Do I need to decompile the source to see the ResourceReadout code and how it displays stuff?

Mehni

Quote from: obuw on February 19, 2019, 03:47:10 AM
Thanks for the reply.

Um, not sure why you thought ModSettings would be relevant? Oh maybe you thought I want the user to select resources from a mod settings page? Naw it will be an ingame menu.

So doing a search for ResourceReadout, I only find references to resourceReadoutPriority and resourceReadoutAlwaysShow. Do I need to decompile the source to see the ResourceReadout code and how it displays stuff?
The mod settings were indeed what I thought you meant.

Yes, you will need to decompile the source. https://rimworldwiki.com/wiki/Modding_Tutorials/Decompiling_source_code

obuw

Okay, thanks.

Oh and by the way I just checked your mod list, thanks for all your fine work! I'm sure I must have used several of your mods in my various playthroughs. The Numbers mod for instance is super handy!

I think I might actually look into your food alert mod and use that as a starting point. Sounds somewhat similar to what I'm trying to do. Well, sortof. Close enough to make it a starting point. :-)

Zaarjin

Hi obuw !

Did you make any progress on modding the ResourceReadout?
I'm looking for something that would at least allow seeing important resources at the top.

After asking this question in this week main reddit post, I decided to look into modding Rimworld and found your post. I've ended up doing a quick hack.

I will probably stick to that temporary solution as coding a different UI or adding a custom category dynamically to objects from the game would require more work than the hour I've already spent to do this hack.

Thanks!