MrBounty / PZ-UI_API

UI API for the game project zomboid
18 stars 4 forks source link

How to "Destroy" Window? #13

Open TsiamDev opened 8 months ago

TsiamDev commented 8 months ago

I simply did:

local lastVisibleUI = UI.isUIVisible UI:close() UI = nil UI = MyCreateNewUI() -- A user defined function that creates a new UI window UI.isUIVisible = lastVisibleUI

But I am not sure whether this approach creates memory leaks.

It certainly creates some overhead since it creates/destroys the window repeatedly, but it is just one window so it is not noticeable I guess.

Please let me know if there is a better way of doing this.

MrBounty commented 1 month ago

I'm not sure for this, it's been a while since I played with PZ code.

I think you will need to check the UI manager of PZ, there is a function to destroy an UI but I don't remember it. This mod is not really to create and delete a lot of UI. Just to get some simple stuff for small mods or rapid testing.