Page 1 of 1
How to change buttoms/frame background
Posted: Sun Jun 23, 2013 9:24 pm
by ficolas
Messing with the buttons, in style.lua, I noticed that there is a monolith_image field, Im not sure about how this works, so I would like somebody to explain
(I have messed arround with that but I cant find out how it works)
Also,I wanna know if it is possible to change the background of the frame
Also, the GUI buttons look much better now with style

Re: How to change buttoms/frame background
Posted: Sun Jun 23, 2013 9:47 pm
by kovarex
Yes, you can change the background.
The monolith is the most simple, you just provide one image, and it is used to draw the background of the element. The image is stretched to fit the size of the element.
Re: How to change buttoms/frame background
Posted: Mon Jun 24, 2013 9:21 am
by ficolas
ok so I created this:
Code: Select all
data:extend({
soldering_iron =
{
type = "monolith",
top_monolith_border = 1,
right_monolith_border = 1,
bottom_monolith_border = 1,
left_monolith_border = 1,
monolith_image =
{
filename = "__F-mod__/resources/other/chipset.png",
width = 220,
height = 220,
x = 0,
y = 0
}
}
})
and if I do this in the code:
Code: Select all
game.player.gui.left.add({type="frame", name="menu", caption="Change frequency",direction="vertical",style="soldering_iron"})
it says that the style soldering_iron doesnt exist.
What do I need to do?
I also tried this:
Code: Select all
data:extend({
type = "gui-style",
name = "f-mod",
soldering_iron =
{
type = "frame_style",
font = "default-frame",
font_color = {r=1, g=1, b=1},
-- padding of the title area of the frame, when the frame title
-- is empty, the area doesn't exist and these values are not used
title_top_padding = 0,
title_left_padding = 0,
title_bottom_padding = 15,
title_right_padding = 0,
-- padding of the content area of the frame
top_padding = default_container_padding - 6,
right_padding = default_container_padding,
bottom_padding = default_container_padding,
left_padding = default_container_padding,
graphical_set =
{
type = "composition",
filename = "__F-mod__/resources/other/chipset.png",
corner_size = {220,220},
position = {0, 0}
},
flow_style=
{
horizontal_spacing = default_container_padding,
vertical_spacing = default_container_padding
}
},
})
Re: How to change buttoms/frame background
Posted: Mon Jun 24, 2013 12:58 pm
by kovarex
The problem is, that you have to extend the "default-gui" object, and the soldering_iron you have there is just specification of the graphical set, but it has to be part of some gui specification.
Let's say it is frame.
Code: Select all
local soldering_iron =
{
type="frame_style",
parent="frame_style",
graphical_set=
{
type = "monolith",
top_monolith_border = 1,
right_monolith_border = 1,
bottom_monolith_border = 1,
left_monolith_border = 1,
monolith_image =
{
filename = "__F-mod__/resources/other/chipset.png",
width = 220,
height = 220,
x = 0,
y = 0
}
}
}
-- Here I extend the default gui style with the soldering_iron style.
data.raw["gui-style"].default["soldering_iron"] = soldering_iron
P.S. Unfortunately, when testing this, I discovered a bug in the processing of custom gui elements, when I repaired it, it worked, but in the current 1.5.2 it won't work, with other small bugs, to have 1.5. really stable, I think we should make 1.5.3 as well

Re: How to change buttoms/frame background
Posted: Tue Jun 25, 2013 8:40 am
by cube
kovarex wrote:P.S. Unfortunately, when testing this, I discovered a bug in the processing of custom gui elements, when I repaired it, it worked, but in the current 1.5.2 it won't work, with other small bugs, to have 1.5. really stable, I think we should make 1.5.3 as well

...
0.5.2 and
0.5.3

Re: How to change buttoms/frame background
Posted: Tue Apr 19, 2016 9:49 pm
by JasonC
kovarex wrote:Yes, you can change the background.
The monolith is the most simple, you just provide one image, and it is used to draw the background of the element. The image is stretched to fit the size of the element.
@kovarex: Is there a way to prevent the monolith from scaling?
The algorithm is strange. It seems to automatically chop off the transparent areas around an image before scaling. So like if you have a 32x32 png with large transparent areas on the side, and a 32x32 monolith, it still stretches it. E.g. the in-game icon graphics used as monoliths in button styles yield:
Notice how the electric pole in the top left is stretched. It's a monolith image on a 32x32 button. It's opaque portions have been stretched to fill the 32x32 area, even though the png itself is 32x32.
Re: How to change buttoms/frame background
Posted: Tue Apr 19, 2016 11:10 pm
by JasonC
So it looks like (thanks Macros in chat) that for some reason only checkboxes with checkbox_styles support not scaling the image. So if you want a button but don't want the scaling, you have to create a checkbox with the image, then style it into something more button-esque.
Re: How to change buttoms/frame background
Posted: Wed Apr 20, 2016 8:12 pm
by JasonC
I've written a guide on this topic:
viewtopic.php?f=34&t=24007