(SOLVED) Centre TEXT - Gui TexBox

Started by Nixxon, Fri 20/11/2020 00:24:32

Previous topic - Next topic

Nixxon

Hi Gang,

Is there a way to align-center TextBox text?

It's the last hurdle after getting some intro text to finally work.

I see in the manual there are options for -

TextBox.Font
TextBox.ShowBorder
TextBox.TextColor

The GUI labels have an option for alignment, however there is a character limit on those.


Crimson Wizard

#1
Just to clarify: you need this to display text, or let user type text?

I don't think there remains any character limit in GUI labels (unless I misunderstood what do you mean), which version of AGS are you using, what kind of text are you putting there, do you set text in editor or script? Is label large enough?

Asnwering your question directly: no there's no auto alignment for TextBox, but you may reposition it around GUI yourself to center it.

EDIT: note that as a last resort you may just draw text on gui background in any way you like, using DynamicSprite, but I'd suggest to find out what was wrong with label first.

Nixxon

Thanks Crim,

Essentially, I have 5 messages that fade in / out during an intro scene.

Currently, I am using GUI background graphics.

The background graphic number changes each time there's a new fade it. This works ok.

Code: ags
gIntro.BackgroundGraphic = 215;
Wait(120);
gIntro.Transparency = 100;
while (trans > 0)
{
        trans--;
        gIntro.Transparency = trans;
        Wait(1);
}
Wait(160);
while (trans < 100) {
  trans++;
  gIntro.Transparency = trans;
  Wait(1);
}



I just thought, it would be better to use GUI Text Box or GUI Label instead as I can change the text on the fly if required, without having to re-save and import sprites if I choose to update some of the story text.

It also looks cleaner and more consistent with the AGS fonts within the game.

I tried two methods, and both worked with caveats.

1. (using GU Text Box)
Replacing  - gIntro.BackgroundGraphic = 215;
With - TextBox1.Text = "Story Message 1"; //etc.

= The text is not centered.


2. (using GUI Label)
Replacing  - gIntro.BackgroundGraphic = 215;
With - StoryLabel1.Visible = true;

= Limit on how many characters you can use in the Text input field on labels.





Nixxon

#3
And guess what??

Now it lets me add as much text as I like into the GUI Label.

Unbelievable.

I'm all sorted now. Sorry.

EDIT - I am guessing I didn't have the GUI Label window large enough, so that it was appearing to cut off text. I assumed this was a limit on the text field, instead of just dragging the Label window larger. That's what we're dealing with here :S :S

SMF spam blocked by CleanTalk