New gui elements for use

Post Reply
Staplergun
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Sun Mar 25, 2018 5:34 am
Contact:

New gui elements for use

Post by Staplergun »

I'm looking at some of the built in gui elements and I'm curious if we could get some new styles or elements available to us:
  • Horizontal or vertical dividers (ie: agui::HorizontalLine/VerticalLine)
  • Fillers available as an element (vertical and horizontal)
  • Tabbed frames (agui::TabbedFrames)
  • Sliders with stepping options

User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 451
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: New gui elements for use

Post by raiguard »

+1 for the stepped slider. You can already create a "notched slider" using the notched_slider style, but as you can see in this screenshot, it doesn't actually behave like a notched slider:
2019-06-21 22_09_38-Window.png
2019-06-21 22_09_38-Window.png (9.55 KiB) Viewed 3597 times
I suppose one could manually round the value to the nearest integer every time the slider moves, but that would be very performance-unfriendly. Dragging this slider around a bunch already causes my mod to use more than 16ms per tick, and all it's doing is updating a value in global and reflecting the new value in the adjacent textfield!
Don't forget, you're here forever.

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

Re: New gui elements for use

Post by eradicator »

Raiguard wrote:
Sat Jun 22, 2019 4:14 am
Dragging this slider around a bunch already causes my mod to use more than 16ms per tick, and all it's doing is updating a value in global and reflecting the new value in the adjacent textfield!
And writing happily to the log file? 16ms for updating a slider smells fishy.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 232
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: New gui elements for use

Post by Therenas »

Maybe the event related to changing the slider fires very frequently while the slider is being dragged?
Last edited by Therenas on Sat Jun 22, 2019 9:23 am, edited 1 time in total.

eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

Re: New gui elements for use

Post by eduran »

Seconded, give us more GUI elements to play with :)
Staplergun wrote:
Sat Jun 22, 2019 1:58 am
  • Tabbed frames (agui::TabbedFrames)
Already possible with what we currently have, but it is a hassle. A proper implementation would make using them so much easier.

Therenas wrote:
Sat Jun 22, 2019 9:15 am
Maybe the event related to changing the slider fires a lot of times per second when someone is dragging it?
It would have to fire a few hundred times per tick to be that slow. That indicates either something is buggy with the slider/event itself or the implementation for rounding and updating the text is super-slow.

nuhll
Filter Inserter
Filter Inserter
Posts: 922
Joined: Mon Apr 04, 2016 9:48 pm
Contact:

Re: New gui elements for use

Post by nuhll »

Yes dragging sliders make factorio very laggy and unresponsive, i dont know if its wrong implemented or not but this is the mod i mean:
https://mods.factorio.com/mod/Actual_Craft_Time

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

Re: New gui elements for use

Post by eradicator »

Or maybe @OP is reading the statistics wrong. I get 0.03ms with the following:

Code: Select all

/c
game.player.gui.center
  .add{type='frame'}
  .add{type='slider',minimum_value=1,maximum_value=4}
  .style = 'notched_slider'

script.on_event(defines.events.on_gui_value_changed,function(e)
  local slider = e.element
  slider.slider_value = math.floor(slider.slider_value+0.5)
  end)
I wholly support the request for a proper notched slider though. Snapping it like this looks very ugly.
Last edited by eradicator on Sat Jun 22, 2019 12:53 pm, edited 1 time in total.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

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

Re: New gui elements for use

Post by eradicator »

nuhll wrote:
Sat Jun 22, 2019 12:08 pm
Yes dragging sliders make factorio very laggy and unresponsive, i dont know if its wrong implemented or not but this is the mod i mean:
https://mods.factorio.com/mod/Actual_Craft_Time
Looked at the code and as expected the mod is naively doing *all* of the calculations *every* time the slider changes in the slightest way. As this can happen several tens of times *per tick* *per player* if you drag fast it's quite expensive to do (i can see it go up to 30.0ms). It'd be trivial to insert a check to at least do it only once per tick, or better per maybe 30 ticks, which would make it instantly several orders of magnitude faster.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

nuhll
Filter Inserter
Filter Inserter
Posts: 922
Joined: Mon Apr 04, 2016 9:48 pm
Contact:

Re: New gui elements for use

Post by nuhll »

yeah, thats how it feels. Maybe you could tell him how to do better? (if you want ofc)

Bilka
Factorio Staff
Factorio Staff
Posts: 3132
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: New gui elements for use

Post by Bilka »

I added lines in the next version. For the filler you can just use the graphical set from the style, set it on a flow/frame and use that as the filler texture.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 451
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: New gui elements for use

Post by raiguard »

Thanks bilka!

Back on the topic of stepped sliders, I went ahead and added logic for it to my mod. However, then it looks like this:
jiggly slider.gif
jiggly slider.gif (49.13 KiB) Viewed 3537 times
That's one jiggly boi. The problem is that by the time the change event fires, the game has already graphically updated the slider position. So even if you use math to round it, it will result in this flickering. The only "real" fix is to add native support for it to the API.
Don't forget, you're here forever.

nuhll
Filter Inserter
Filter Inserter
Posts: 922
Joined: Mon Apr 04, 2016 9:48 pm
Contact:

Re: New gui elements for use

Post by nuhll »

that gif make me lol. Thats how it feels to play factorio... xDDDDDDDDDDDDDDDD

Bilka
Factorio Staff
Factorio Staff
Posts: 3132
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: New gui elements for use

Post by Bilka »

Filler was added as empty-widget (it accepts the style) and stepping is now an option for sliders. Tabs are also a thing.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Post Reply

Return to “Implemented mod requests”