Factorio Codex

by sfyb

Adds a Satisfactory like codex with quick search to Factorio, which can act as a calculator and display information about items, recipes, technologies and factories

Utilities
7 months ago
1.1
833

i reopen/don't close the last GUI

1 year, 2 months ago

I love the mod so far, super handy to not have to pull up a calculator on my PC every time I wanna do some quick maths.

The one thing I did notice though, which is kinda annoying, is that opening the codex closes other currently open UIs, which has been a bit annoying at times. What I would love is if the codex would either not close other UIs in the first place, or at least reopen them to the best of it's abilities.

1 year, 2 months ago
(updated 1 year, 2 months ago)

Thank you! I am glad you like this mod.

What I would love is if the codex would either not close other UIs in the first place, or at least reopen them to the best of it's abilities.

That sounds like a very good idea (I assume you mean the text input UI where you can do the calculations - from now I call this "quick search").
Sadly this feature cannot be implemented as-is because of a few quirks in Factorio.
Here are two options I came up with including their drawbacks:

  1. One of the better options might be to pin the other UIs so the quick search UI doesn't close them.
    Most mods include a little icon of a pin needle in the window title bar
    and when active it prevents the window from closing unless you press the "X" button yourself.

  2. Another option is to add ESC as a hotkey to close the quick search UI while preventing the UI from closing previous UIs.
    This will have the side effect that the quick search UI cannot be closed by opening another UI.
    Also the ESC key has to be pressed twice, the first time will bring up the game menu and the second time closes the game menu and quick search UI.

Since you mentioned reopening UIs, while this seems like a good workaround there is no universal way of reopening UIs
and every mod would need to implement a way for me to reopen their UIs. This would quickly become unmanageable.

So to summarize:
There is not much that I can do to prevent this issue without introducing other problems that occur more often.
In the future I might make this an option when I figure out how to properly have per-user settings.
In the meantime the best option is to pin the UIs you want to keep open.

1 year, 2 months ago

I think problem 2 could maybe be solved by "watching" player.opened (every tick, compare it with it's previous tick's state). In regards to opening the game menu, I would be surprised for that to be an issue, other mods (helmod for example) are also able to essentially do the same thing.

1 year, 2 months ago
(updated 1 year, 2 months ago)

think problem 2 could maybe be solved by "watching" player.opened (every tick, compare it with it's previous tick's state)

That's actually a really good idea. But it seems like Factorio doesn't put its native UIs into player.opened (the value will be nil) and any mod UI seems to have the same value (regardless of which mod and which UI is put into player.opened, according to lua serpent), which makes it impossible to differentiate between my quick search UI being in player.opened or not.

In regards to opening the game menu, I would be surprised for that to be an issue, other mods (helmod for example) are also able to essentially do the same thing.

This is usually not an issue because mods put their UI into player.opened but in order to prevent any currently open UI from being closed by the quick search UI I cannot put my UI in there. This means I don't get the features of LuaControl.opened. Therefore I would need to add something to close the UI again.
This would be done by the ESC hotkey, which causes the behavior I described.

New response