[closed] Custom dialog placement

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

[closed] Custom dialog placement

Post by ZombieKnight »

Hi
How to place my custom dialog, so it's displayed and horizontal_alignment = "center" is related only to the "map part" of the screen?
Last edited by ZombieKnight on April 20th, 2024, 5:49 am, edited 1 time in total.
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
Celtic_Minstrel
Developer
Posts: 2241
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Custom dialog placement

Post by Celtic_Minstrel »

The dialog doesn't know anything about the map screen, so it's technically not possible. Since the sidebar is a fixed width as far as I know, you can probably get this to work with the default theme, at least; it would probably break if someone uses a different theme though. Basically, you would have to not use horizontal_alignment = center and instead manipulate things somehow so that the dialog is not centered on the screen. I don't know the details of how this would work.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: Custom dialog placement

Post by ZombieKnight »

Couldn't be gui.show_narration code re-used?
I haven't found ho it's done there.
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
Celtic_Minstrel
Developer
Posts: 2241
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Custom dialog placement

Post by Celtic_Minstrel »

gui.show_narration is written in C++, so while technically yes it could be reused, that doesn't help you any. Unless the placement is done in the WML – you're welcome to take a look.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
white_haired_uncle
Posts: 1226
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: Custom dialog placement

Post by white_haired_uncle »

I wonder if you could make the dialog transparent, then position the widgets carefully so it appears the dialog is where you want.
Speak softly, and carry Doombringer.
User avatar
Celtic_Minstrel
Developer
Posts: 2241
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Custom dialog placement

Post by Celtic_Minstrel »

I'm pretty sure there's no need to do that. There's allowance in either [window] or [window_definition] for specifying where the dialog window should appear on the screen, so you really just need to work out the right numbers or formulas to get the effect you want. (If it's in [window_definition] you'd also need to add the custom definition from Lua. Maybe you can actually use the same definition as the narration dialog, but I'm not sure if that works.)
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: Custom dialog placement

Post by ZombieKnight »

Wait can I create more dialogs easy, using more [resolution]s?
If so which sizes should I make it for?
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
Celtic_Minstrel
Developer
Posts: 2241
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Custom dialog placement

Post by Celtic_Minstrel »

The Lua API only lets you use a single [resolution] (you pass the content of that tag to gui.show_dialog). You could of course have your own logic to choose between resolution tags, though I think you don't have access to the screen size…

So in other words, you can't use the [window] tag for a Lua dialog. [window_definition] likely works though, using gui.add_widget_definition, although I don't think anyone has tested this, so I could be wrong. I would expect positioning data to be in the definition, but I haven't checked.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: Custom dialog placement

Post by ZombieKnight »

Um. What I need are three numbers: (I think)
1. Distance between the left side of the screen and the left side of the map
2. Wight of the map
3. Distance between the bottom of the screen and the bottom of the map
Is that true?
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
Celtic_Minstrel
Developer
Posts: 2241
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Custom dialog placement

Post by Celtic_Minstrel »

That's technically true, but you, personally, don't need to know those numbers. There are variables in the GUI2 positioning system that already contain the correct numbers. You may also need the height of the menubar, which strangely isn't in a variable (it seems to be 30).

I recommend you look at the file gui/dialogs/wml_message.cfg in the Wesnoth data folder to see how the WML message actually does it. You might even be able to just copy-paste it. (It turns out I was wrong by the way – positioning info goes in [resolution], not [window_definition].)
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: Custom dialog placement

Post by ZombieKnight »

Celtic_Minstrel wrote: April 17th, 2024, 1:10 pm There are variables in the GUI2 positioning system that already contain the correct numbers.
Which, how are they named?
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
Celtic_Minstrel
Developer
Posts: 2241
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Custom dialog placement

Post by Celtic_Minstrel »

Celtic_Minstrel wrote: April 17th, 2024, 1:10 pm I recommend you look at the file gui/dialogs/wml_message.cfg in the Wesnoth data folder to see how the WML message actually does it.
Look at how it's done there. The variables in question are used – specifically, look at where x, y, width, and height are set in the resolution tag.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: Custom dialog placement

Post by ZombieKnight »

Okay, I'll do my best, I'll report later.
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: Custom dialog placement

Post by ZombieKnight »

Made as advised (thanks ^^) vars gamemap_x_offset, gamemap_width, screen_height are used there;

Code: Select all

		x = "(gamemap_x_offset)"
		y = 30
		width = "(gamemap_width)"
		height = "(screen_height - 30)"
(I haven't found any "gamemap_x_offset =" in the code)
When I type 'gamemap_x_offset' into the Lua console returns an error.
Any idea where are these stored/how to get them?
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
Ravana
Forum Moderator
Posts: 3018
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Custom dialog placement

Post by Ravana »

Search finds where it is published.
Post Reply