UI - Modders! Why you do things that way?

Hey folks!
So I’m deep diving into some new UI functionality for ya’ll and I gotta say I’m very impressed by the hackery you guys have pulled off. I believe I’ve added some functionality that will make a lot of ya’ll lives way better, but I’m very curious to know what things you are pulling off that you really think should be done in a much easier way.

An example of something I saw you guys doing was having UI buttons actually setting zero size elements visible or not to basically track button presses. Then, in the game update loop, you were checking to see if the item was visible or not to see if the button was pressed and then running some logic and setting the element hidden again to reset.

Very nutty and impressive in its resourcefulness, but omg. So we’ve made that easier by allowing you to now include LUA script files at the top of UI screen definitions. This allows you to call custom functions specifically for the UI screen you are working on.

Anyway, what other hackery are you guys doing that you’d really don’t think you should be having to do.

Thanks!

2 Likes

As modders sometimes it’s easier to use your own solution rather than try to figure out the official, possibly undocumented, method.
The trickery you posted about though, I’m not sure that is even necessary in the first place… never the less, lua functionality is appreciated anywhere we can get it. You might want to double check that the lua script has the correct access level that the modders wished for (I’m assuming gamerule level).

I’m not overly familiar with the UI in Homeworld yet so I can’t offer any suggestions about it right now, but surely in the future.

Burleson,

In Homeworld 2, you could display text on the screen by adding a “autoexec.lua” file to the Bin folder. The code below is an example of how to display an in-game timer. You didn’t have to use “-overridebigfile” or anything, it simply worked.

This no longer works in HWR. I’m guessing that “dr_text2d” in the code below is no longer supported. Do you know if there’s a function that replaced dr_text2d, to display text on screen in HWR?

function updateTimer()
dr_clear(“timer”);
dr_setautoclear(“timer”,0);
local time = Universe_GameTime();
local h = floor(time / 3600);
local m = floor(time / 60 - h * 60);
local s = floor(time - m * 60 - h * 3600);
local str = format("%2.0f:%2.0f:%2.0f", h, m, s);
dr_text2d(“timer”,0.478,0.17,str,255,255,255);
local rdy = 0;
end
Rule_AddInterval(“updateTimer”, 3)

@Cloaked That’s a debug render function that we don’t fully support anymore. (We don’t fully support any debug render functions.) That said, looking at the source code it doesn’t look like we directly changed anything to prevent it from working… Will ask BitVenom

For onscreen timers, I’d do what Mikali is doing for his timer mod. Very simple and clean. Aside from that, I’m working on some ways to get more flexible timers accessible to the UI that don’t require as much LUA math.

I believe I used that code for some things, but I’m not sure if it ever got to public versions. You should see the mess of my attempts to reproduce HW1 research UI and functionality. It got working at some point, but I had no confidence in it being multiplayer viable.

If memory serves I got the technique from looking at FX mod code, so I imagine that’s where you saw it :slight_smile:

1 Like

I didn’t intentionally break any DR stuff - Indeed I’d say it has largely survived as-is. That said, that is a REALLY bad idea. That code is insanely expensive - I won’t go into internal details, but it’s about as far from speed oriented as you can get.

Even if that system was fast - the code you’ve shown is using it in a pretty expensive way (creating a whole new DR layer (called ‘timer’) - then manually adding an object to it very frequently. I’m not sure what units AddInterval takes (seconds?).

When you want to do pop-up text, why not just throw a string into the same queue/UI element that things like ‘Game Saved’ or location names use? It’s not major deal to add another (named) element to that view that can either auto-sort or just have a floating, fixed location - and tell it to show certain text when needed.

1 Like

I’m trying to update the build ui with new types of build families, but for some reason the finalbuild script decompressed with the community tools has a few bugs. Would it be possible to have a correct finalbuild.lua script to play with?

[quote=“Burleson, post:4, topic:199525, full:true”]For onscreen timers, I’d do what Mikali is doing for his timer mod. Very simple and clean. Aside from that, I’m working on some ways to get more flexible timers accessible to the UI that don’t require as much LUA math.
[/quote]
I asked Mikali, but you definitely mean my timer mod :stuck_out_tongue:

I have no idea who wrote the code above, but all the Gamespy vets used that autoexec.lua timer file for hw2. The important thing was that you could play online with other people who didn’t have it. I was just hoping there was a simple way to get a autoexec.lua timer working again for HWR. My timer mod doesn’t work online with people who don’t have it.