harpy eagle wrote:
sven wrote:Hmm.. I'm not quite sure what's going wrong here. Would you send me a copy of your crashy attempted mod? (In theory, I think something along the lines of what you're describing ought to work.)
Here it is. The crash happens when I click on the food icon in the top bar to open the panel.
Ok, so first some background (for the benefit of anyone other than harpy eagle who may be reading this post). UI_File is an interesting hack (see file_env.lua). The idea is that if you wrap a file's definitions in UI_File | function(_ENV), then what you're doing is creating a function with the same name as your file. Calling that function will add a new set of function / table definitions to a given environment. So, for example, when GalaxyMap.lua is run, it creates the new environment gui.GalaxyMap, and then populates it with all sorts of inter-dependent UI functions by calling various UI_File functions.
harpy eagle clearly understands all this, and has thus attempted to add a new set of tables and function definitions to gui.GalaxyMap by calling
Code: Select all
However, that doesn't work. Why, exactly, it doesn't work is a bit mystifying. As best as I can tell, the core of the issue is that the resize_callbacks defined in PlanetPopPane.lua are never getting called. The exact details of *why* it's not getting called continue to elude me (there's a lot of fiddly stuff that goes on involving resize callbacks), but, at a high level, the answer is probably "because I never expected mods to patch into UI ENVs like this".
The pattern used in most places in the code is to call
in some function that's evaluating during the the execution of GalaxyMap.lua. If I switch harpy eagle's mod to use a version of this pattern, say by inserting PlanetPopPane(_ENV) into the top of the UI_File function call in @TopBarContents.lua; the mod appears to work fine. So... I guess that's the fix.