Support for custom rendered controls

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
DeadMG
Burner Inserter
Burner Inserter
Posts: 16
Joined: Thu Oct 22, 2020 7:56 am
Contact:

Support for custom rendered controls

Post by DeadMG »

Firstly, apologies if this already in the won't-add section, I've had a quick search but didn't find it.

I'd like to make a request for better support for custom control rendering. The existing controls are nice but sometimes they don't quite cut it. I am looking at making a mod where the fundamental data structure the user is manipulating is a graph- obviously there is no builtin control for a graph, which is fine. However rendering custom controls is a bit awkward.

LuaStyle doesn't seem to offer anything similar to CSS's position:absolute, so it's kinda hard to make something that looks like a single control which is composed of many controls that implement different parts of it with positioning handled by the modder. So far I've used a hidden surface with camera element on it and LuaRendering, which can render "custom controls" surprisingly well if presumably a bit wasteful on performance.

Adding interactivity though is another matter as the click events don't report their location on the element that was clicked.

I assume that it would be a fairly large task to add support for proper CSS-style composite controls with absolute positioning/stacking, z-indexes and such. However what would definitely be "good enough for now especially for a kinda niche case" is if one control can receive slightly more detailed events. Specifically, add a position property to on_gui_click which says where on the element the user clicked. I can project that on to the hidden surface and figure out if they clicked on anything I actually care about on the other end; it's not like the user will expect great performance with a huge graph anyway.

Additionally, a little extra flexibility for on_gui_location_changed would be nice as well; this event can't currently understand the idea of dragging within a UI element itself. I would suggest adding a property, supports_internal_drag or something, which allows on_gui_location_changed to be fired when the user performs click-and-drag actions, with start/end points in element location space.

Obviously I would also be fine with the idea of better support for custom positioning of GUI elements, as strictly, there is nothing I want to do which is outside the bounds of what GUI elements can already do- clicking, dragging, etc. I just can't arrange them on the screen in a way that will actually look like what it needs to look like. I think that adding a little more location data/flexibility to the existing events should hopefully be a pretty low-effort good-enough solution which allows the modder to be creative if they really need to be.

Post Reply

Return to “Modding interface requests”