text alignment in [message]

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

text alignment in [message]

Post by ZombieKnight »

Hi
How to align text in center in [message]?
It can be done in [story][part] text_alignment=center...
. . .
Or how to display [story] text on top of map and units?
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: text alignment in [message]

Post by beetlenaut »

Neither of these is possible as far as I know.

However, you can make dialog boxes or put text in the center of the screen with Lua functions. There is gui.show_dialog, and gui.show_prompt. SotA uses both in zombie_recruit_dialog.lua, which is called from zombie-utils.cfg, so you have at least one mainline example of those.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: text alignment in [message]

Post by ZombieKnight »

beetlenaut wrote: April 1st, 2024, 1:57 amput text in the center of the screen with Lua functions.
(Sry for delay)
Oh, that's good to hear... which lua functions?
Can I make [message] text wighter?
Thanks.
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: text alignment in [message]

Post by beetlenaut »

ZombieKnight wrote: April 2nd, 2024, 5:46 pm which lua functions?
I already answered this: gui.show_dialog and gui.show_prompt.
ZombieKnight wrote: April 2nd, 2024, 5:46 pm Can I make [message] text wighter?
You can use Pango markup to change the style of the text in a [message]. That includes the color.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: text alignment in [message]

Post by ZombieKnight »

How to make two quotes?...
I'll try gui.show_dialog, but I'm not sure if that usn't that middle screen box...
By widther I meant the text to be more in width(standard message reserves too much space on the screen for speaker images)
...
So can it be done?
(Sry idk how to type width)
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: text alignment in [message]

Post by beetlenaut »

I thought you meant "whiter", but you meant "wider". No, I can't see how there could be a way to do that.

Obviously, I don't know for sure which Lua function you should use for the effect you want. Maybe you could read the wiki pages. This is the page on the gui commands for example: https://wiki.wesnoth.org/LuaAPI/gui
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
white_haired_uncle
Posts: 1226
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: text alignment in [message]

Post by white_haired_uncle »

ZombieKnight wrote: April 3rd, 2024, 6:54 am I'll try gui.show_dialog, but I'm not sure if that usn't that middle screen box...
If you don't want it in the middle of the screen, try the placement options. Example here:

https://wiki.wesnoth.org/LuaAPI/gui/example
Speak softly, and carry Doombringer.
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: text alignment in [message]

Post by ZombieKnight »

white_haired_uncle wrote: April 3rd, 2024, 1:47 pm If you don't want it in the middle of the screen, try the placement options. Example here:

https://wiki.wesnoth.org/LuaAPI/gui/example
Thanks... How to Implement that example? ...
I've created a character_select.cfg file and included it in _main.cfg I'm calling it with:

Code: Select all

[lua]code=<<--That long code with characters and some functions>>[/lua]
...reports nothing and nothing happens...
What am I doing wrong/missing?
(Even if it's a really dumb mistake, I'm capable of it...)
I had saurian in profile before, but I've merged my discord profile with forum one...
white_haired_uncle
Posts: 1226
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: text alignment in [message]

Post by white_haired_uncle »

The example is just an example, you need to understand gui.show_dialog as beetlenaut recommended. From the looks of it, you would put the "The implementation" section in your lua code section (actually, it should go in a file, probably in a lua directory in your addon and then you use dofile to load it). Then in your wml code you would use [select_character]. The example is not something you can just cut and paste, you need to read through it to understand how to use it. I really just posted it to point out the vertical_placement = "center" and horizontal_placement = "center". If you learn to use gui.show_dialog, they are what you can use to move the gui from the center of the screen if that is what you want.

I'm working on a tutorial. It's still very much in progress and hasn't been reviewed yet, but it MIGHT help you get started. It also pretty much assumes you want to do everything in lua, because wml and I are not on friendly terms. I should probably add some more detail for people who want to write the definition in wml like in that example.

https://wiki.wesnoth.org/Sandbox/GUI/Getting_Started
Speak softly, and carry Doombringer.
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: text alignment in [message]

Post by ZombieKnight »

Jup I see...
I'm gonna stick with it for now to see how it works.
How to make it that narration([message])-like background?
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: text alignment in [message]

Post by ZombieKnight »

...(Like in Victory/Defeat messages)...?
I had saurian in profile before, but I've merged my discord profile with forum one...
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: text alignment in [message]

Post by beetlenaut »

I don't know how to change the background of a dialog box at the moment either.

Are you asking this because you have a dialog that works the way you want, and the background is the last part you need to fix? Or, are you asking about step eight when you haven't completed step one yet? I think the second one might be the case, so I am not going to research this right now.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
white_haired_uncle
Posts: 1226
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: text alignment in [message]

Post by white_haired_uncle »

Set the window transparent:

Code: Select all

        local function preshow(dialog)
                dialog:set_canvas(1, { } )
        end
 
and use a panel with

Code: Select all

definition = "box_display"
Gives the same look as the victory/defeat window
Speak softly, and carry Doombringer.
User avatar
ZombieKnight
Posts: 180
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: text alignment in [message]

Post by ZombieKnight »

Thanks!
Is there a documentation for new dialog/[resolution] creation?
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: text alignment in [message]

Post by ZombieKnight »

This is only thing, I've found so far...
https://devdocs.wesnoth.org/GUIToolkitWML.html
And it describes few things, but doesn't say how to really work with them.
...
Jup I really need to really understand how it's working first.
Is there something better?
Last edited by ZombieKnight on April 5th, 2024, 4:31 pm, edited 1 time in total.
I had saurian in profile before, but I've merged my discord profile with forum one...
Post Reply