Best way to draw text in RenderOverlay?
Posted: Tue Jul 05, 2022 9:45 am
I want to make a simple UI addon that displays current powerups and their time in seconds. It seems to me that the best option for that is to use RenderOverlay to draw things, so it would always work, without interfering with other mods. So I tried to draw some texts, and I have problems controlling their position. First I tried Screen.DrawText at 0, 0.

The text position is always top left which is good, but it does not scale with UI, which is bad. I think I could use DTA_VirtualWidth / Height to match the HUD "resolution" ? Not sure how to do that right now.
I also tried StatusBar.DrawString at 0, 0

It is scaling now, cool but the position is wrong, it looks like there is a 320x200 rectangle in the mid-bottom and the 0, 0 is top-left of that rectangle. I also don't know how to do anything with that. Right now I just added some values based on scale (StatusBar.GetHUDScale()) but that's really crappy solution.

The text position is always top left which is good, but it does not scale with UI, which is bad. I think I could use DTA_VirtualWidth / Height to match the HUD "resolution" ? Not sure how to do that right now.
I also tried StatusBar.DrawString at 0, 0

It is scaling now, cool but the position is wrong, it looks like there is a 320x200 rectangle in the mid-bottom and the 0, 0 is top-left of that rectangle. I also don't know how to do anything with that. Right now I just added some values based on scale (StatusBar.GetHUDScale()) but that's really crappy solution.