New GUI root for temporary GUI elements

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

Re: New GUI root for temporary GUI elements

Post by eradicator »

Delicous!
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 root for temporary GUI elements

Post by Therenas »

Incredible, thanks for the hard work!

User avatar
ownlyme
Filter Inserter
Filter Inserter
Posts: 400
Joined: Thu Dec 21, 2017 8:02 am
Contact:

Re: New GUI root for temporary GUI elements

Post by ownlyme »

am i dreaming?
i'll believe it when i see it o.o
i think this is my most-wished feature.
can we read the location of the player's crafting gui?
mods.factorio.com/user/ownlyme
My requests: uiAbove||Grenade arc||Blueprint allies||Creeps forget command/ don't get removed||Player Modifiers||textbox::selection||Better Heat IF||Singleplayer RCON||tank bug w/ min_range >= projectile_creation_distance

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

Re: New GUI root for temporary GUI elements

Post by Therenas »

ownlyme wrote:
Mon Jul 22, 2019 7:11 pm
am i dreaming?
i'll believe it when i see it o.o
i think this is my most-wished feature.
can we read the location of the player's crafting gui?
I kinda doubt this includes any interaction with base game UIs.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13201
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: New GUI root for temporary GUI elements

Post by Rseding91 »

You can't read the location of game GUIs and I don't think that will happen anytime soon (if ever).

player.screen is useuful really only in 1 scenario: you want a GUI that acts and functions identically to the normal game GUIs. Z-ordering is never preserved so don't think you're going to be able to put your GUIs over base game ones to "hide" them. You also won't be able to position your GUIs relative to game GUIs to make them act like additions/panels on the game GUIs.

I have a different idea for something like player.relative.add() which would position elements you give relative to some game GUI.

Something like:

Code: Select all

game.player.gui.relative.add({type="button", caption="Click me", relative_to={type="quickbar", position="left"}})
And then it would put your button to the left of the quickbar when the quickbar is visible.

It's just an idea at this point. I still need to figure out if it can be done in some reasonable way that it doesn't constantly get broken as people work on GUIs.
If you want to get ahold of me I'm almost always on Discord.

User avatar
ownlyme
Filter Inserter
Filter Inserter
Posts: 400
Joined: Thu Dec 21, 2017 8:02 am
Contact:

Re: New GUI root for temporary GUI elements

Post by ownlyme »

Rseding91 wrote:
Tue Jul 23, 2019 11:30 am
You can't read the location of game GUIs and I don't think that will happen anytime soon (if ever).

player.screen is useuful really only in 1 scenario: you want a GUI that acts and functions identically to the normal game GUIs. Z-ordering is never preserved so don't think you're going to be able to put your GUIs over base game ones to "hide" them. You also won't be able to position your GUIs relative to game GUIs to make them act like additions/panels on the game GUIs.

I have a different idea for something like player.relative.add() which would position elements you give relative to some game GUI.

Something like:

Code: Select all

game.player.gui.relative.add({type="button", caption="Click me", relative_to={type="quickbar", position="left"}})
And then it would put your button to the left of the quickbar when the quickbar is visible.

It's just an idea at this point. I still need to figure out if it can be done in some reasonable way that it doesn't constantly get broken as people work on GUIs.
This sounds interesting...
Maybe i should provide more information what i'm planning to do:

- Adding buttons /informational labels / progressbars to existing guis, for example:
- custom equipment adding the scripted stats to the equipment summary
- money label and selling /buying toggle to the player's crafting gui
- toggling an overlay for buying which spawns a frame that looks exactly like, but covers the crafting menu
- Adding the bonus cells progress bar, efficiency, temperature, output, etc to the realistic reactors entity gui

I was actually willing to accept that my gui elements wouldnt move with it's "parent", but its obviously critical that they are displayed above the game guis.

This buying/selling mod is the next one on my todo list, and the only idea i have right now, so i was really looking forward to this
(gonna be great, already have the price calculation perfectly figured out and an alpha version of the buying gui (as seen in my "DotA" mod), just gotta add some supply/demand mechanics and integrate the gui in some nice way)
mods.factorio.com/user/ownlyme
My requests: uiAbove||Grenade arc||Blueprint allies||Creeps forget command/ don't get removed||Player Modifiers||textbox::selection||Better Heat IF||Singleplayer RCON||tank bug w/ min_range >= projectile_creation_distance

User avatar
ownlyme
Filter Inserter
Filter Inserter
Posts: 400
Joined: Thu Dec 21, 2017 8:02 am
Contact:

Re: New GUI root for temporary GUI elements

Post by ownlyme »

Rseding91 wrote:
Tue Jul 23, 2019 11:30 am
You can't read the location of game GUIs and I don't think that will happen anytime soon (if ever).

player.screen is useuful really only in 1 scenario: you want a GUI that acts and functions identically to the normal game GUIs. Z-ordering is never preserved so don't think you're going to be able to put your GUIs over base game ones to "hide" them. You also won't be able to position your GUIs relative to game GUIs to make them act like additions/panels on the game GUIs.

I have a different idea for something like player.relative.add() which would position elements you give relative to some game GUI.

Something like:

Code: Select all

game.player.gui.relative.add({type="button", caption="Click me", relative_to={type="quickbar", position="left"}})
And then it would put your button to the left of the quickbar when the quickbar is visible.

It's just an idea at this point. I still need to figure out if it can be done in some reasonable way that it doesn't constantly get broken as people work on GUIs.
it works! :)
i can draw elements on top of the crafting gui :)
but i'd still appreciate your idea with the relative adding, would really polish the whole experience.
i'll start making my gui now, thank you very much for the latest patch :)
mods.factorio.com/user/ownlyme
My requests: uiAbove||Grenade arc||Blueprint allies||Creeps forget command/ don't get removed||Player Modifiers||textbox::selection||Better Heat IF||Singleplayer RCON||tank bug w/ min_range >= projectile_creation_distance

Rseding91
Factorio Staff
Factorio Staff
Posts: 13201
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: New GUI root for temporary GUI elements

Post by Rseding91 »

ownlyme wrote:
Thu Jul 25, 2019 5:30 pm
i can draw elements on top of the crafting gui :)
Right up until you save/load and then it's under it. Or just close the GUI and open it again and it's now under it.
If you want to get ahold of me I'm almost always on Discord.

User avatar
ownlyme
Filter Inserter
Filter Inserter
Posts: 400
Joined: Thu Dec 21, 2017 8:02 am
Contact:

Re: New GUI root for temporary GUI elements

Post by ownlyme »

Rseding91 wrote:
Thu Jul 25, 2019 8:20 pm
ownlyme wrote:
Thu Jul 25, 2019 5:30 pm
i can draw elements on top of the crafting gui :)
Right up until you save/load and then it's under it. Or just close the GUI and open it again and it's now under it.
Thats no problem, since it's only created when the crafting gui is opened.
If you want the opposite effect, you could probably use the hiding feature and never destroy the gui.
When a savegame is loaded, we can just re-create our guis.
Imo we have all the tools to control the z-ordering on our end
mods.factorio.com/user/ownlyme
My requests: uiAbove||Grenade arc||Blueprint allies||Creeps forget command/ don't get removed||Player Modifiers||textbox::selection||Better Heat IF||Singleplayer RCON||tank bug w/ min_range >= projectile_creation_distance

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

Re: New GUI root for temporary GUI elements

Post by eradicator »

ownlyme wrote:
Thu Jul 25, 2019 9:58 pm
When a savegame is loaded, we can just re-create our guis.
How so?
Rseding91 wrote:
Tue Jul 23, 2019 11:30 am
Z-ordering is never preserved
That is kinda sad. Will probably also cause problems when multiple mods try to draw to the same region of the screen (even if it's just partial overlap). How difficult would it be to have actual runtime-controllable z-order on guis?
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.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13201
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: New GUI root for temporary GUI elements

Post by Rseding91 »

eradicator wrote:
Fri Jul 26, 2019 4:19 am
ownlyme wrote:
Thu Jul 25, 2019 9:58 pm
When a savegame is loaded, we can just re-create our guis.
How so?
Rseding91 wrote:
Tue Jul 23, 2019 11:30 am
Z-ordering is never preserved
That is kinda sad. Will probably also cause problems when multiple mods try to draw to the same region of the screen (even if it's just partial overlap). How difficult would it be to have actual runtime-controllable z-order on guis?
Never going to happen. That's completely outside of what player.screen is supposed to do: you as a modder should never be using player.screen as "draw on the screen". You use it as "Show a GUI on the screen" and the order is what ever the player wants it to be by clicking on given GUIs.
If you want to get ahold of me I'm almost always on Discord.

User avatar
ownlyme
Filter Inserter
Filter Inserter
Posts: 400
Joined: Thu Dec 21, 2017 8:02 am
Contact:

Re: New GUI root for temporary GUI elements

Post by ownlyme »

eradicator wrote:
Fri Jul 26, 2019 4:19 am
ownlyme wrote:
Thu Jul 25, 2019 9:58 pm
When a savegame is loaded, we can just re-create our guis.
How so?
damn, good point..
in multiplayer, you can use on_player_joined_game, which also fires for the host, but currently i have no idea what to do in singleplayer... (except constantly recreating the guis)

edit: on savegame loading, the crafting gui appeared behind my custom frame, maybe this isnt such a big issue?

i personally don't have such a big problem with it since my screen elements are either conditionally created and destroyed (usually very soon) or use (hopefully) free space

I just read your new FFF where you used the wording
relative to the character GUI on the left side"
again, which made me concerned that the new way would only allow placing of elements *outside* of the game guis, but there are quite some free spots in the game guis (and definitively a lot of cases where the modder would want to place an element on top of the game guis)
mods.factorio.com/user/ownlyme
My requests: uiAbove||Grenade arc||Blueprint allies||Creeps forget command/ don't get removed||Player Modifiers||textbox::selection||Better Heat IF||Singleplayer RCON||tank bug w/ min_range >= projectile_creation_distance

Rseding91
Factorio Staff
Factorio Staff
Posts: 13201
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: New GUI root for temporary GUI elements

Post by Rseding91 »

There will be no system for placing GUIs "on top of" game GUIs. that's an unsupported thing that if you do in a mod you get zero support for.
If you want to get ahold of me I'm almost always on Discord.

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

Re: New GUI root for temporary GUI elements

Post by eradicator »

Rseding91 wrote:
Fri Jul 26, 2019 6:06 pm
There will be no system for placing GUIs "on top of" game GUIs. that's an unsupported thing that if you do in a mod you get zero support for.
Just another hack on the long list of "not supported" things (i don't have a personal usecase for it yet though).
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
ownlyme
Filter Inserter
Filter Inserter
Posts: 400
Joined: Thu Dec 21, 2017 8:02 am
Contact:

Re: New GUI root for temporary GUI elements

Post by ownlyme »

lol why?
thats the only thing the system would be useful for
i'm not even asking for any support, i just want to be able to shift my labels, buttons, etc to a position inside the gui^^ you can leave everything else to the modders :)

demo:
(equipment is a kinda tricky case where it's hard to calculate the position since you sometimes have mod texts (added by mod xyz) or item descriptions but otherwise it works perfectly)

Code: Select all

function equipment_text_position(player)
	local x = player.display_resolution.width*0.5
	local item_width = 404 * player.display_scale
	local stats_width = 168+15
	if player.opened.width >= 10 then
		stats_width = stats_width + 7
	end
	if player.opened.height >= 10 then
		stats_width = stats_width + 7
	end
	stats_width = stats_width * player.display_scale
	local grid_width = 33*player.opened.width*player.display_scale
	local equipment_width = math.max(304*player.display_scale, stats_width + grid_width)
	if player.opened.prototype.name == "radiation-suit-grid" then
		equipment_width = 402*player.display_scale
	end
	x=x+(item_width - equipment_width)/2
	x=x+15*player.display_scale+grid_width
	return {x , player.display_resolution.height*0.48}
end
it's done :)
https://mods.factorio.com/mod/assemblin ... _equipment
Only the first mod i'll be using the new feature in ;)
Attachments
Screenshot_4.jpg
Screenshot_4.jpg (81.95 KiB) Viewed 3333 times
mods.factorio.com/user/ownlyme
My requests: uiAbove||Grenade arc||Blueprint allies||Creeps forget command/ don't get removed||Player Modifiers||textbox::selection||Better Heat IF||Singleplayer RCON||tank bug w/ min_range >= projectile_creation_distance

Post Reply

Return to “Implemented mod requests”