[closed] Custom dialog placement
Moderator: Forum Moderators
- ZombieKnight
- Posts: 282
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
[closed] Custom dialog placement
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?
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...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
- Celtic_Minstrel
- Developer
- Posts: 2290
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Custom dialog placement
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.- ZombieKnight
- Posts: 282
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Custom dialog placement
Couldn't be gui.show_narration code re-used?
I haven't found ho it's done there.
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...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
- Celtic_Minstrel
- Developer
- Posts: 2290
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Custom dialog placement
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.
-
- Posts: 1308
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: Custom dialog placement
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.
- Celtic_Minstrel
- Developer
- Posts: 2290
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Custom dialog placement
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.)- ZombieKnight
- Posts: 282
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Custom dialog placement
Wait can I create more dialogs easy, using more [resolution]s?
If so which sizes should I make it for?
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...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
- Celtic_Minstrel
- Developer
- Posts: 2290
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Custom dialog placement
The Lua API only lets you use a single
So in other words, you can't use the
[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.- ZombieKnight
- Posts: 282
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Custom dialog placement
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?
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...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
- Celtic_Minstrel
- Developer
- Posts: 2290
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Custom dialog placement
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
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]
.)- ZombieKnight
- Posts: 282
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Custom dialog placement
Which, how are they named?Celtic_Minstrel wrote: ↑April 17th, 2024, 1:10 pm There are variables in the GUI2 positioning system that already contain the correct numbers.
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
- Celtic_Minstrel
- Developer
- Posts: 2290
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Custom dialog placement
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.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.
- ZombieKnight
- Posts: 282
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Custom dialog placement
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...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
- ZombieKnight
- Posts: 282
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Custom dialog placement
Made as advised (thanks ^^) vars gamemap_x_offset, gamemap_width, screen_height are used there;
(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?
Code: Select all
x = "(gamemap_x_offset)"
y = 30
width = "(gamemap_width)"
height = "(screen_height - 30)"
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...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
Re: Custom dialog placement
Search finds where it is published.