For a sprite button, I can have it overlay a number (for count), by adding a "number = 100" to the LuaGuiElement.
However, with Space Age, there are icons like this (this is the signal display from a combinator):
How do I get the quality overlay for a sprite (or a sprite button)? There is a workaround using a "choose-elem-button" which allows using "item-with-quality" and then in turn use that to display an item with the quality overlay but that can not display a number.
Is there a way to draw a sprite-button that looks like the button in the constant combinator? If not, is it possible to add some additional attributes to sprite-button (and probably also sprite) that allows for the quality overlay?
Display quality overlay on a sprite and sprite-button
Re: Display quality overlay on a sprite and sprite-button
[ replying to my own post first]
At this point, I can get the hovers over the icons to work (by using the elem_tooltip attribute):
However, the icons still do not show the quality information:
In the filter selector at the botttom, the icons have a quality marker (this is a table of choose-elem-buttons which display the quality). In the top, the elements (sprite-button) are all plain, even though the tooltips show the quality correctly (see the hover).
The question is still on how to get the quality marker on the sprite buttons.
At this point, I can get the hovers over the icons to work (by using the elem_tooltip attribute):
Code: Select all
button.elem_tooltip = {
type = 'item-with-quality',
name = signal_name,
quality = signal.signal.quality,
}
In the filter selector at the botttom, the icons have a quality marker (this is a table of choose-elem-buttons which display the quality). In the top, the elements (sprite-button) are all plain, even though the tooltips show the quality correctly (see the hover).
The question is still on how to get the quality marker on the sprite buttons.
Re: Display quality overlay on a sprite and sprite-button
[pinging this topic]
This is still sorely lacking and I have a few circuit network related mods that suffer from the fact that there is no gui element that can do what the builtin combinators can (show a number and quality at the same time).
Please? Pretty please? Pretty pretty pleeeeease?
(At least give us a “will do at some point/will never do/here is a workaround”. Heck, at this point I would settle for “overlay two sprites on a sprite button”)
This is still sorely lacking and I have a few circuit network related mods that suffer from the fact that there is no gui element that can do what the builtin combinators can (show a number and quality at the same time).
Please? Pretty please? Pretty pretty pleeeeease?
(At least give us a “will do at some point/will never do/here is a workaround”. Heck, at this point I would settle for “overlay two sprites on a sprite button”)
Re: Display quality overlay on a sprite and sprite-button
Guess what, any GUI element can have children. It's more cursed than it seems. Make of it what you will.hgschmie wrote: Tue Jan 21, 2025 10:49 pm (At least give us a “will do at some point/will never do/here is a workaround”. Heck, at this point I would settle for “overlay two sprites on a sprite button”)
Re: Display quality overlay on a sprite and sprite-button
You know, this was a shockingly good comment. Thank you for this.curiosity wrote: Wed Jan 22, 2025 7:27 pmGuess what, any GUI element can have children. It's more cursed than it seems. Make of it what you will.hgschmie wrote: Tue Jan 21, 2025 10:49 pm (At least give us a “will do at some point/will never do/here is a workaround”. Heck, at this point I would settle for “overlay two sprites on a sprite button”)
this actually works:
add to prototypes:
Code: Select all
data.raw['gui-style'].default['quality_style'] = {
type = 'image_style',
left_padding = 16,
}
Code: Select all
local button = parent_gui_element.add {
type = "sprite-button",
sprite = signal.signal.type .. "/" .. signal.signal.name,
number = signal.count,
}
if signal.signal.quality and signal.signal.quality ~= 'normal' then
button.add {
type = 'sprite',
style = 'quality_style',
sprite = 'quality/' .. signal.signal.quality,
}
end
why not at the bottom left as the builtin buttons do? Because this image consists of multiple layers:
1) the background image
2) the icon
3) the quality overlay
4) the number
The builtin buttons render (bottom to top): 1, 2, 3, 4. So the number is on top of the quality overlay.
This workaround renders 1, 2, 4, 3. So the quality overlay would cover part of the number. Moving it to the top right corner avoids that.
Re: Display quality overlay on a sprite and sprite-button
Thanks for documenting this.
I had to set the size in the style definition and restrict the sprite widget to
(setting the actual sprite happens somewhere else)
I had to set the size in the style definition and restrict the sprite widget to
Code: Select all
resize_to_sprite = false
I havent lost my mind, it's backed up on tape somewhere.