[solved] Custom dialog text "center" placement
Moderator: Forum Moderators
- ZombieKnight
- Posts: 250
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
[solved] Custom dialog text "center" placement
Hi,
I've got this custom dialog code:
Any idea how to align the text into the middle of the game map?
This is there so the whole message is only on the game map:
Any idea what to do so the message is in the middle of the screen?
I've got this custom dialog code:
Any idea how to align the text into the middle of the game map?
Code: Select all
local narration = {
T.helptip { id="tooltip_large" }, -- mandatory field
T.tooltip { id="tooltip_large" }, -- mandatory field
maximum_height = "(screen_height - 30)",
maximum_width = "(gamemap_width)",
horizontal_placement = "left",
vertical_placement = "bottom",
vertical_grow = true,
click_dismiss = true,
T.grid {
T.row {
T.column {
T.stacked_widget{
id = "narration_stacked_widget",
definition = "default",
T.layer{
T.row {
T.column {
horizontal_alignment = "center",
grow_factor = 1,
border = "all",
border_size = 5,
T.label {
definition = "title",
text_alignment = "center",
id = "narration_title"
}
}
},
T.row {
--grow_factor = 0, --TODO idk what this does
T.column {
horizontal_alignment = "center",
grow_factor = 1,
border = "all",
border_size = 5,
T.label {
definition = "text",
text_alignment = "center",
id = "narration_message"
}
}
}
}
Code: Select all
maximum_height = "(screen_height - 30)",
maximum_width = "(gamemap_width)",
horizontal_placement = "left",
vertical_placement = "bottom",
Last edited by ZombieKnight on May 16th, 2024, 7:16 am, edited 7 times 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
-
- Posts: 1285
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: Custom dialog text "center" placement
If your only concern is being centered on the screen (not the non-gamemap portion of the screen), try replacing ALL of the above with:ZombieKnight wrote: ↑April 28th, 2024, 8:12 am
This is there so the whole message is only on the game map:Any idea what to do so the message is in the middle of the screen?Code: Select all
maximum_height = "(screen_height - 30)", maximum_width = "(gamemap_width)", horizontal_placement = "left", vertical_placement = "bottom",
Code: Select all
maximum_height = "(screen_height - 30)",
maximum_width = "(2 * gamemap_width - screen_width)",
Speak softly, and carry Doombringer.
- ZombieKnight
- Posts: 250
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Custom dialog text "center" placement
No that should be unchanged, that puts the dialog into the left bottom corner(game map)(defines place for the dialog).white_haired_uncle wrote: ↑April 28th, 2024, 12:05 pm If your only concern is being centered on the screen (not the non-gamemap portion of the screen), try replacing ALL of the above with:Code: Select all
maximum_height = "(screen_height - 30)", maximum_width = "(2 * gamemap_width - screen_width)",
How to put the text into the center of the rectagle defined and placed at the start?
...
So the text is in the center of the space reserved at the start.
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
-
- Posts: 1285
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: Custom dialog text "center" placement
This is probably the idea you want:
But you need to figure out how to set ~SCALE(2000,1000) to the rectangle size. I'm not sure how to access things like gamemap_width in that scope.
Code: Select all
...
T.layer{
T.row {
T.column {
T.image {
id = "empty"
}
}
}
}
}
}
}
}
}
local function preshow(dialog)
dialog.narration_title.marked_up_text = "This is a really, long title. I mean, it's really long. Like it takes up the whole game map. More than the game map. It's that big. When your title lies around the house, it lies <span font='italic'>around</span> the house."
dialog.narration_title.marked_up_text = "This is a short title"
dialog.narration_message.label = wml.tostring(narration)
dialog.narration_stacked_widget.empty.label = "images/misc/blank.png~SCALE(2000,1000)"
dialog.narration_stacked_widget.empty.visible = true
dialog.narration_stacked_widget.narration_title.visible = true
end
Speak softly, and carry Doombringer.
-
- Posts: 1285
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: Custom dialog text "center" placement
Better yet, try this:
(no need for blank.png with this option)
Code: Select all
maximum_height = "(gamemap_height)",
maximum_width = "(gamemap_width)",
height = "(gamemap_height)",
width = "(gamemap_width)",
automatic_placement = false,
x=0,
y="(screen_height - gamemap_height)",
--horizontal_placement = "left",
--vertical_placement = "bottom",
Last edited by white_haired_uncle on April 28th, 2024, 2:46 pm, edited 1 time in total.
Speak softly, and carry Doombringer.
- ZombieKnight
- Posts: 250
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Custom dialog text "center" placement
Nope, this puts the message into the horizantal AND vertical center.white_haired_uncle wrote: ↑April 28th, 2024, 1:33 pm Better yet, try this:(no need for blank.png with this option)Code: Select all
maximum_height = "(screen_height - 30)", maximum_width = "(gamemap_width)", height = "(screen_height - 30)", width = "(gamemap_width)", automatic_placement = false, x=0, y=30, --horizontal_placement = "left", --vertical_placement = "bottom",
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
-
- Posts: 1285
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: Custom dialog text "center" placement
That's what you asked for
BTW, see the updated version above that get's rid of the hardcoded "30".Any idea how to align the text into the middle of the game map?
Speak softly, and carry Doombringer.
-
- Posts: 1285
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: Custom dialog text "center" placement
You might want to add vertical_alignment="bottom" to the column that contains your stacked_widget
Speak softly, and carry Doombringer.
- ZombieKnight
- Posts: 250
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Custom dialog text "center" placement
I'd like to have a defined space (== game map)
And all future positions and alignments position make relative to the game map.
...
Any idea how to achieve that behavior?
So if the dialog has fixed
Or something like that
And all future positions and alignments position make relative to the game map.
...
Any idea how to achieve that behavior?
So if the dialog has fixed
Code: Select all
fixed width, x
and horizontal_alignment="center"
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: 250
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Custom dialog text "center" placement
But that doesn't work either just like so...
So any idea? (Thanks for still helping even I'm so dumb)
So any idea? (Thanks for still helping even I'm so dumb)
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
-
- Posts: 1285
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: Custom dialog text "center" placement
The example above is a dialog that is a fixed size (the size of the gamemap) in a fixed location (the location of the gamemap).
Speak softly, and carry Doombringer.
- ZombieKnight
- Posts: 250
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Custom dialog text "center" placement
Sorry I have somehow missed this message.white_haired_uncle wrote: ↑April 28th, 2024, 2:48 pm That's what you asked for
BTW, see the updated version above that get's rid of the hardcoded "30".Any idea how to align the text into the middle of the game map?
Ok... My bad
New question:
How to put dialog on the bottom of the screen, and horizontal_placement in the "center"?
Thanks, sorry for the inclearance.
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
-
- Posts: 1285
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: Custom dialog text "center" placement
You might want to add vertical_alignment="bottom" to the column that contains your stacked_widget
Speak softly, and carry Doombringer.
- ZombieKnight
- Posts: 250
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Custom dialog text "center" placement
Nope spammed the vertical_placement = "bottom" everywhere, I couldwhite_haired_uncle wrote: ↑April 28th, 2024, 6:26 pm You might want to add vertical_alignment="bottom" to the column that contains your stacked_widget
But it didn't affect the dialog at all.
Code: Select all
local narration = {
T.helptip { id="tooltip_large" }, -- mandatory field
T.tooltip { id="tooltip_large" }, -- mandatory field
maximum_height = "(screen_height - 30)",
maximum_width = "(gamemap_width)",
height = "(screen_height - 30)",
x=0,
y=30,
width = "(gamemap_width)",
automatic_placement = false,
-- horizontal_placement = "left",
-- vertical_placement = "bottom",
vertical_grow = true,
click_dismiss = true,
T.grid {
vertical_placement = "bottom",
horizontal_alignment = "center",
T.row {
T.column {
vertical_placement = "bottom",
horizontal_alignment = "center",
T.stacked_widget{
id = "narration_stacked_widget",
definition = "default",
T.layer{
T.row {
T.column {
vertical_placement = "bottom",
horizontal_alignment = "center",
grow_factor = 1,
border = "all",
border_size = 5,
T.label {
definition = "title",
text_alignment = "center",
id = "narration_title"
}
}
},
Do you know what's not working/ what am I missing/ how to solve it?
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
-
- Posts: 1285
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: Custom dialog text "center" placement
I said vertical_alignment. Like this:
And mine is centered horizontally in the gamemap (as it should be, because that's the center of the dialog too).
Of course, if you end up with a scrollbar you need to move the scrollbar to the center for the text to be in the center.
And I suggest you do this instead of hardcoding the "30". I don't know if 30 depends on the current resolution or not, but this doesn't:
(There's no reason to use stacked_widget in my example, I'm just copying yours)
Code: Select all
T.column {
vertical_alignment="bottom",
T.stacked_widget{
id = "narration_stacked_widget",
Of course, if you end up with a scrollbar you need to move the scrollbar to the center for the text to be in the center.
And I suggest you do this instead of hardcoding the "30". I don't know if 30 depends on the current resolution or not, but this doesn't:
Code: Select all
maximum_height = "(gamemap_height)",
maximum_width = "(gamemap_width)",
height = "(gamemap_height)",
width = "(gamemap_width)",
automatic_placement = false,
x=0,
y="(screen_height - gamemap_height)",
Code: Select all
function wesnoth.wml_actions.my_narration()
local narration = {
T.helptip { id="tooltip_large" }, -- mandatory field
T.tooltip { id="tooltip_large" }, -- mandatory field
maximum_height = "(gamemap_height)",
maximum_width = "(gamemap_width)",
height = "(gamemap_height)",
width = "(gamemap_width)",
automatic_placement = false,
x=0,
y="(screen_height-gamemap_height)",
vertical_grow = true,
click_dismiss = true,
T.grid {
T.row {
T.column {
vertical_alignment="bottom",
T.stacked_widget{
id = "narration_stacked_widget",
definition = "default",
T.layer{
T.row {
T.column {
horizontal_alignment = "center",
grow_factor = 1,
border = "all",
border_size = 5,
T.label {
definition = "title",
text_alignment = "center",
id = "narration_title"
}
}
},
T.row {
--grow_factor = 0, --TODO idk what this does
T.column {
horizontal_alignment = "center",
grow_factor = 1,
border = "all",
border_size = 5,
T.label {
definition = "text",
text_alignment = "center",
id = "narration_message"
}
}
}
},
}
}
}
}
}
local function preshow(dialog)
dialog.narration_title.marked_up_text = "This is a really long title. I mean, it's really, really and truly long. Like it takes up the whole game map. More than the game map. It's that big. When your title lies around the house, it lies <span font='italic'>around</span> the house."
-- dialog.narration_title.marked_up_text = "This is a short title"
-- dialog.narration_message.label = wml.tostring(narration)
dialog.narration_message.label = "this is a short message"
dialog.narration_stacked_widget.narration_title.visible = true
end
gui.show_dialog(narration,preshow)
end
Speak softly, and carry Doombringer.