- Horizontal or vertical dividers (ie: agui::HorizontalLine/VerticalLine)
- Fillers available as an element (vertical and horizontal)
- Tabbed frames (agui::TabbedFrames)
- Sliders with stepping options
New gui elements for use
-
- Long Handed Inserter
- Posts: 96
- Joined: Sun Mar 25, 2018 5:34 am
- Contact:
New gui elements for use
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:
Re: New gui elements for use
+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:
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!
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.
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: New gui elements for use
And writing happily to the log file? 16ms for updating a slider smells fishy.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!
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: New gui elements for use
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.
Re: New gui elements for use
Seconded, give us more GUI elements to play with
![Smile :)](./images/smilies/icon_e_smile.gif)
Already possible with what we currently have, but it is a hassle. A proper implementation would make using them so much easier.
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.
Re: New gui elements for use
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
https://mods.factorio.com/mod/Actual_Craft_Time
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: New gui elements for use
Or maybe @OP is reading the statistics wrong. I get 0.03ms with the following:
I wholly support the request for a proper notched slider though. Snapping it like this looks very ugly.
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)
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: New gui elements for use
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.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
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: New gui elements for use
yeah, thats how it feels. Maybe you could tell him how to do better? (if you want ofc)
Re: New gui elements for use
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.
Re: New gui elements for use
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:
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.
Back on the topic of stepped sliders, I went ahead and added logic for it to my mod. However, then it looks like this:
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.
Re: New gui elements for use
that gif make me lol. Thats how it feels to play factorio... xDDDDDDDDDDDDDDDD
Re: New gui elements for use
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.