Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Peegee on Tue 13/05/2025 19:04:44

Title: Move GUI in front of text
Post by: Peegee on Tue 13/05/2025 19:04:44
Hello, I would like to attenuate a text, I thought to put a GUI representing a halo, which would be displayed over the text. But even by changing the Z, the halo remains behind. I also tried to use another font but I can not do it, how to change the font that uses a character? All the information I found did not work.
Title: Re: Move GUI in front of text
Post by: Rik_Vargard on Tue 13/05/2025 19:07:41
I might be wrong but couldn't you use an object image instead and change the Baseline?
Title: Re: Move GUI in front of text
Post by: Crimson Wizard on Tue 13/05/2025 19:25:01
Quote from: Peegee on Tue 13/05/2025 19:04:44Hello, I would like to attenuate a text, I thought to put a GUI representing a halo, which would be displayed over the text. But even by changing the Z, the halo remains behind. I also tried to use another font but I can not do it, how to change the font that uses a character? All the information I found did not work.

I will assume that by "text" you mean character speech.

Please clarify what kind of "halo" effect do you have in mind, can you post an example that presents your idea? That might let us to suggest better solution.

In regards to the questions.
By default the speech text is drawn on a overlay that has the maximal possible ZOrder, you cannot set anything above it. So either:
1. Reduce this overlay's z-order to a lower value instead. You can get speech overlay using Speech.TextOverlay (https://adventuregamestudio.github.io/ags-manual/Speech.html#speechtextoverlay), but you have to do so in (late_)repeatedly_execute_always, because that's the only two functions that run during blocking speech.
2. Write a custom speech function that displays character speech on a GUI label. Then you can add any more additional effects as you like.

Character speech font is changed using Game.SpeechFont property.

Quote from: Rik_Vargard on Tue 13/05/2025 19:07:41I might be wrong but couldn't you use an object image instead and change the Baseline?

Room objects are within the room and not sorted with speech overlays.
Title: Re: Move GUI in front of text
Post by: Peegee on Tue 13/05/2025 20:38:06
(For Adventure Game Studio 3.6.0)

It is a simple text, cCharacter.Say ("Hello");
I'm trying to display a sprite (png), small semi-transparent gradient to soften the text. (In response to Rick, the text is always displayed above)
That's why I made a GUI, but it does not want to get on top and in addition, when I position the GUI, the text moves.

Thank you for your answers.
1: What code exactly do I need to put in the repeatedly_execute_always?

2: I do not understand much, can be because I do not use CharacterSpeech?

Yesterday I did a lot of testing, the software didn't want to take Game.SpeechFont.
At worst, I would like to be able to manage my fonts and assign them to the characters.

Title: Re: Move GUI in front of text
Post by: Khris on Tue 13/05/2025 22:01:31
Using cCharacter.Say() means you are using character speech (as opposed to displaying text boxes for instance).

Please always post the exact code you tried to use.

This will definitely work:

  // in game_start
  Game.SpeechFont = eFontTheName;

Using a standard GUI to change the appearance of LucasArts style spoken text won't work because AGS moves the text away from any GUIs currently appearing on-screen.

Can you provide a quick illustration that demonstrates how you want this to appear in-game? It's most likely going to require a custom speech function, as in a function you write that is then called by AGS whenever your code uses .Say().
This function will use a graphical overlay or GUI(s) to display the custom speech you want.
Title: Re: Move GUI in front of text
Post by: Crimson Wizard on Wed 14/05/2025 03:38:32
@Peegee
Could you please post the screenshot of you current text and elaborate on which problem you are trying to solve, because there's a chance that your problem has an easier solution. Earlier you said that you want to "soften" the text. Could it be that what you need a is a font outline?

Quote from: Khris on Tue 13/05/2025 22:01:31Using a standard GUI to change the appearance of LucasArts style spoken text won't work because AGS moves the text away from any GUIs currently appearing on-screen.

I must clarify: AGS only moves speech down if GUI is vertically above the text. If GUI is right over the text, then the text will not be moved down.

Following example script under spoiler works for me in AGS 3.6.0:

Spoiler
Code (ags) Select
function repeatedly_execute_always()
{
    // test if there's a blocking speech overlay on screen
    if (Speech.TextOverlay != null)
    {
        // if there is one, then set its z-order to 20, and halo gui z-order to 21, so above it
        // make halo gui visible, and align over the text
        Speech.TextOverlay.ZOrder = 20;
        gHalo.Visible = true;
        gHalo.ZOrder = 21;
        gHalo.X = Speech.TextOverlay.X - 10;
        gHalo.Y = Speech.TextOverlay.Y - 10;
    }
    else
    {
        gHalo.Visible = false;
    }
}

Note that you must set GUI Clickable = false and Visible = false in the editor.
[close]

I cannot predict if that will do what you want though.
Title: Re: Move GUI in front of text
Post by: Peegee on Wed 14/05/2025 09:54:09

KHRIS:
I don't want to change the font of the whole game, only for one character.

Crimson Wizard:
It does not take this code:


gGui4Halo102 = Speech.TextOverlay.X - 10;


It seems difficult to mix a GUI with a text... Just for one page.
Can we at least assign a specific font to a character?
Title: Re: Move GUI in front of text
Post by: Khris on Wed 14/05/2025 11:01:25
You're trying to assign a number to a GUI.

You need to use
  gGui4Halo102.X = Speech.TextOverlay.X - 10;
As for using a different speech font for a character, the only way I know of is to change Game.SpeechFont before calling .Say() whenever that character speaks. This can also be solved best with a custom Say function.
Title: Re: Move GUI in front of text
Post by: Snarky on Wed 14/05/2025 15:27:37
Quote from: Peegee on Wed 14/05/2025 09:54:09Can we at least assign a specific font to a character?

I've linked to this post a number of times. It has a step-by-step explanation of how to write a custom function to set different fonts for different characters' speech: https://www.adventuregamestudio.co.uk/forums/index.php?msg=636510794
Title: Re: Move GUI in front of text
Post by: Peegee on Thu 15/05/2025 18:34:57
Thanks to Snarky for the link, it sounds complex, I'll explore that when I have some time.

Khris and Crimson, sorry, I had forgotten the .X-Code. The code works. It's not bad, the GUI is displayed well above, but the GUI must always be displayed. There, it is displayed only when the text arrives and its position is according to the size of the text pad. How to make it always be displayed, and does not move?
Title: Re: Move GUI in front of text
Post by: Crimson Wizard on Thu 15/05/2025 23:20:56
Quote from: Peegee on Thu 15/05/2025 18:34:57Khris and Crimson, sorry, I had forgotten the .X-Code. The code works. It's not bad, the GUI is displayed well above, but the GUI must always be displayed. There, it is displayed only when the text arrives and its position is according to the size of the text pad. How to make it always be displayed, and does not move?

What do you mean by "always displayed"? like, display it for the whole game? or display it under certain conditions (for certain character, or in certain room)?

You can set Gui.Visible anytime you need. If you need a gui which is always visible, then you can set Visible property right in the Editor. But I suspect that is not exactly what you need.

Then, you said that you do not want it to move. Which speech style are you using in your game, is it Lucas Arts style where the text appears above the character's head, or Sierra style where it appears on top of the screen?
If it's Lucas-Arts style, then the speech may appear in different positions, and have different size.

Could you please post a screenshot or a mockup drawing of what you are trying to achieve? Right now I do not understand the purpose of these actions, and do not know what to suggest exactly.
Title: Re: Move GUI in front of text
Post by: Peegee on Fri 16/05/2025 08:46:44
Hello, this is a narrative page where some texts are displayed on a colored rectangle. Indeed, it is LucasArt, so the clutter of the texts changes. What I'm looking for is to have a GUI, semi-transparent png that is permanently displayed on the colored rectangle (and will not move), and that the text is displayed behind it.
Title: Re: Move GUI in front of text
Post by: Snarky on Fri 16/05/2025 09:45:30
Please post an image of what you want.
Title: Re: Move GUI in front of text
Post by: Peegee on Mon 19/05/2025 07:55:11
(https://images.app.goo.gl/9Ezo6NWSQhm24WzS7)

Here is a semi-transparent piece of parchment, which will be displayed on my background, without moving, so that the text appears behind. The borders of the scroll correspond to the rectangle on which it is displayed.

Title: Re: Move GUI in front of text
Post by: Peegee on Mon 19/05/2025 07:57:50

https://images.app.goo.gl/zrxXxuyy2nZf7Zzn9
Title: Re: Move GUI in front of text
Post by: Peegee on Mon 19/05/2025 08:06:20
By the way, Game.SpeechFont does work to change the font momentarily, that would be fine with me, thank you. Unfortunately, to have a smaller font or another color, I must reload my base file of letters (TGA I think), which I can not find.
Title: Re: Move GUI in front of text
Post by: Peegee on Mon 19/05/2025 08:43:52
At worst, I could change the font, remove the outline of the letters and play on the color of the letters to reduce the display of the text... But when I remove the outline of the letters, the clutter of the text changes, it becomes larger! I do not understand why. Too bad, if I stay on this solution, I would change the background so that the text does not protrude.
Title: Re: Move GUI in front of text
Post by: Khris on Mon 19/05/2025 09:17:08
I'm still confused by the idea of putting this *on top of* the text to *soften* it. Don't you mean behind it? Like with a very standard dialog box games have had for decades?
Please post an example screenshot from another game. Anything. Because now we're apparently talking about parchment or something, as opposed to something that "softens" text, whatever that means.
Title: Re: Move GUI in front of text
Post by: Peegee on Mon 19/05/2025 20:21:31
It must be the translation that complicates the understanding. Sorry, it's very simple. My font is a bit rough and contrasting. I imagined to use a sprite (png) a little transparent, above the text, to soften the display of the text. I have a parchment in the background, I would display another parchment on top as GUI, so that it is above the text. But I think I will abdicate, the use of GUIs is not practical.
Title: Re: Move GUI in front of text
Post by: Crimson Wizard on Tue 20/05/2025 04:27:40
We've been asking for a game screenshot, because that will let us to clearly see the problem with your text. "Rough and contrasting" may have a number of reasons. Some reasons may be solved by easier means.

For example, have you tried turning "Anti-alias TTF fonts" on? This option is located in General Settings -> Text output. (Or do you have it turned on already?)
What is your game resolution? This option works better in high resolutions than in low resolutions.

Another option that you may try is making speech text's overlay slightly transparent (using Transparency property of a Speech.TextOverlay).

Spoiler
Example:
Code (ags) Select
function repeatedly_execute_always()
{
    // test if there's a blocking speech overlay on screen
    if (Speech.TextOverlay != null)
    {
        Speech.TextOverlay.Transparency = 10; // this value may be experimented with
    }
}
[close]

I'd try the "GUI above the text" as a last option. It's not difficult to do, but seems like an unusual solution.
Title: Re: Move GUI in front of text
Post by: Peegee on Tue 20/05/2025 08:19:09
Yes !! Perfect solution (make the text transparent), simple and effective.
 
It's strange, when I removed the outline of the font, the text took more space in width...

Sorry, I didn't want to send my picture so as not to reveal my game (GOBLiiNS6), and it was just a parchment (with an illustration). Thank you ! :-D
Title: Re: Move GUI in front of text
Post by: Crimson Wizard on Tue 20/05/2025 09:15:49
Quote from: Peegee on Tue 20/05/2025 08:19:09It's strange, when I removed the outline of the font, the text took more space in width...

That is unexpected. Could you tell which version of AGS are you using, which font, and how the outline was made (was it using another font, or automatic outline, etc)?

Quote from: Peegee on Tue 20/05/2025 08:19:09Sorry, I didn't want to send my picture so as not to reveal my game (GOBLiiNS6), and it was just a parchment (with an illustration).

Well, I understand, but you could make a screenshot in some mockup scene in such situation, with just the text shown.