GUI questions

Place to get help with not working mods / modding interface.
User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2529
Joined: Fri Nov 06, 2015 7:41 pm

GUI questions

Post by Deadlock989 »

1.
I find myself occasionally having to do things like this when handling button clicks and I want to change the state of other things in the gui:

Code: Select all

local map_button = event.element.parent.parent.parent.parent.parent["left-column"]["display-map-marker"]
I mean jeez. I'm missing a trick, right?
2.
How do you get a table to be horizontally centred within its parent flow or frame? Can't figure it out.
3.
I have a WIP that emulates the item filter GUI but in a dark styley:

Untitled.jpg
Untitled.jpg (88.94 KiB) Viewed 545 times
It uses tabs with a custom style (for icon tabs, use rich text with a bigger font size). The problem is, there can be n item groups and there's only space for 6. More than 6, and horrible dead space appears somewhere, you can push that dead space around but dead is dead. In the current gui, it's buttons and not tabs - you can have multiple rows of buttons but tabs are restricted to one row because they are tabs.

What to do? I thought about having left and right arrow buttons appear next to the tabs if there are more than 6 tabs, so you can switch the visibility of the tabs into groups-of-tabs - but how to position a button within that tab space? (If you're wondering why not just use the choose-elem-button element which pops open the native item filter gui, it's because I want multiple kinds of filter at once, not just items, and choose-elem buttons don't support that.)
User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2529
Joined: Fri Nov 06, 2015 7:41 pm

Re: GUI questions

Post by Deadlock989 »

1. Wrote a recursive function that searches for element by name top-down, because who wants to change all the references when you change the nesting of one frame. Wheel successfully reinvented.

2. Turns out things like frames and tabs have an additional embedded flow as part of their style, you have to define a new style for the frame that sets horizontal_align to true within that flow style.

Code: Select all

	display_deep_frame = {
		type = "frame_style",
		parent = "inside_deep_frame",
		vertical_flow_style = {
          		type = "vertical_flow_style",
        		vertical_spacing = 0,
			horizontal_align = "center",
	        },
	},
Post Reply

Return to “Modding help”