Scroll-pane scroll-bar graphical_set access.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Scroll-pane scroll-bar graphical_set access.

Post by eradicator »

I'm currently working on a themed mod gui and it looks like the scroll-panes scroll-bar looks can not be changed? At least none of the base games scroll_pane_style prototypes have a (default_)graphical_set and assigning one to a custom style doesn't have any effect.
scrollbar.png
scrollbar.png (186.01 KiB) Viewed 2568 times
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Scroll-pane scroll-bar graphical_set access.

Post by bobingabout »

Hey, I like the progress so far.
Shame we can't actually have more than just the default theme applied.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14912
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Scroll-pane scroll-bar graphical_set access.

Post by Rseding91 »

Scroll bars use "thumb_button_style", "top_button_style" and "bottom_button_style" which are internally button styles.

You should be able to set those on the default scroll bar style.
If you want to get ahold of me I'm almost always on Discord.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Scroll-pane scroll-bar graphical_set access.

Post by eradicator »

Hm, interesting. I can see there are type="horizontal/vertical_scrollbar_style" styles in the default gui that have the button styles you mentioned. But how do i get a reference to the scroll-bar gui element? .add{type='scroll-pane'} only returns a reference to the scroll-pane which doesn't accept scroll_bar_style and doesn't have any children. Perhaps .add should return should return the bar as a second return value?
local pane,bar = gui.add{type="scroll-pane"}
Unless i'm missing something else.

Thanks for the help btw ;)
Rseding91
Factorio Staff
Factorio Staff
Posts: 14912
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Scroll-pane scroll-bar graphical_set access.

Post by Rseding91 »

eradicator wrote:Hm, interesting. I can see there are type="horizontal/vertical_scrollbar_style" styles in the default gui that have the button styles you mentioned. But how do i get a reference to the scroll-bar gui element? .add{type='scroll-pane'} only returns a reference to the scroll-pane which doesn't accept scroll_bar_style and doesn't have any children. Perhaps .add should return should return the bar as a second return value?
local pane,bar = gui.add{type="scroll-pane"}
Unless i'm missing something else.

Thanks for the help btw ;)
You don't, you'd set the style on the parent GUI element that owns the scroll bars. That is, if it's exposed (I think it is but haven't checked).
If you want to get ahold of me I'm almost always on Discord.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Scroll-pane scroll-bar graphical_set access.

Post by eradicator »

I already tried that before and couldn't find it. Tested a brute force approach now and still can't find it:

Code: Select all

  local function force_style(element)
    element.style = 'vertical_scrollbar'
    end
  
  local function for_all_children(element)
    local err,stat = pcall(force_style, element)
    print(err)
    
    for _,child in pairs(element.children) do
      for_all_children(child)
      end
    
    end
  
  for_all_children(p.gui.center) 
According to pcall all attempts to set the style fail (and in the process makes the scroll bar vanish completely :P).

Edit:
(Hrng, pressed submit too early:P)
The code to create the scroll-pane is something like:

Code: Select all

local center = player.gui.center
local flow = center.add{type='flow'}
local frame = flow.add{type='frame'}
local pane = frame.add{type='scroll-pane'}
Rseding91
Factorio Staff
Factorio Staff
Posts: 14912
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Scroll-pane scroll-bar graphical_set access.

Post by Rseding91 »

I guess it isn't setup then. I'll see about getting support added for it.
If you want to get ahold of me I'm almost always on Discord.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Scroll-pane scroll-bar graphical_set access.

Post by eradicator »

Yay. Thanks =)
Post Reply

Return to “Implemented mod requests”