Text Window GUI

Started by AdamM, Sat 31/07/2010 03:10:36

Previous topic - Next topic

AdamM

This is what my dialogue currently renders as (Lucasarts):

http://img97.imageshack.us/img97/4023/sierral.png

I'm in the process of designing a new conversation GUI with embedded portraits (yes I know you adventure design buffs will probably take issue with the options but please reserve comment for now):

http://img836.imageshack.us/img836/6509/talkgui.png

It all works perfectly, except for the dialogue which appears as the above default Lucasarts. This is what I want my dialogue to render as, i.e. on a GUI (Sierra with Background):

http://img801.imageshack.us/img801/9284/sierrabackground.png

Unfortunately there seems to be no way of achieving the latter effect without using a blocking function like Display(), or using SierraWithBackground, which displays an extra portrait in the top left of the screen in addition to the one I've drawn in my GUI (I'm using SSH's GuiPortrait module to achieve that). My current workaround is SierraWithBackground and a blank SpeechView, but even with this the text is limited to rendering in two fixed positions of the screen i.e. top left or top right, whereas I want to move it wherever I want so that it doesn't necessarily cover up the conversation GUI or anything else.

If I make a new GUI to handle it, it isn't able to dynamically (and magically) resize itself depending on the amount of text it is displaying like the mysterious Text Window GUI.

So that's the problem. Solutions go.

PS: And why is SierraWithBackground destroying all my SpeechColor variables anyway?

PPS: No responses in 20 hours? A more complicated problem than I thought then?

Charity

This should be entirely doable, but you'll have to make your own text GUI.  How complicated of an image (backdrop and borders) are you wanting for your text GUI?  If it will look exactly like the one in your example, I would use the border color for two edges and use a couple super thin list boxes (they have their own borders and can be resized and moved with the script) to make that "3D" effect around the edges.  Also make a label that uses the appropriate font.

You'll have to make your own "Say" function, or I guess edit the one in SSH's module.  Basically what you need to do is turn on your custom GUI, set the label to the string in your function, and then resize and position of the GUI and its elements.

Look up the GetTextHeight and GetTextWidth functions in the manual.  Also the GUI and GUI control functions and properties.

Getting it to look just right might be a little complicated, and I haven't figured it out in my head, just yet.  Also with custom talking functions you will need to figure out how you will implement pausing and resuming play when the text GUI is up.

It CAN be done, though.  Just takes some persistence and a little scripting know-how.  How are you with scripting?

AdamM

Completely forgot about this; my frustration with the problem resulted in me losing interest in designing the game for a while.

QuoteGetTextHeight and GetTextWidth

Aha. I wasn't aware of these functions, thanks.

However it still isn't quite clear how the GUI itself will resize its borders to fit the text. Your List Box thing seems like a workaround. The standard Text Window GUI asks you to provide images for the borders and then through some kind of mystic art translates them into a perfectly-sized text box. If I only knew how this was manifested in scripting I would just be able to use that.

Khris

Depending on how complex the border graphics are, this can be achieved (easily) using buttons. A button usually clips the image to its own dimensions, so you'd just need to reposition/resize the buttons for the borders and three corners.
Afaik AGS simply puts the border images next to each other to get the borders. That's a simple loop involving DynamicSprites. Alternatively, the image (DynamicSprite) is stretched to fit the button dimensions.
If the border image is just a thick line or something similar, make it 320 wide and all that's left to do is resize the button.

AdamM

Okay, well as my design is so simple I've taken your suggestion about using buttons, Khris; one at each corner and side. I've written this bit of code that seems to emulate the Sierra view using a GUI, called gNewText, and I've inserted it before Say() is called in SSH's module. As it doesn't draw borders automatically I've taken two labels each using the component fonts and put them on top of each other, resizing them identically.

I came up with 215 as the number of 320 resolution pixels that AGS seems to wrap to in the Sierra view by measuring the screenshot I took in the first post of this thread; if the GetTextWidth is shorter than 215 the GUI resizes itself around it as normal, but if it is longer then it freezes the GUI at a static width. It didn't seem to work entirely well so I adjusted the rest of the numbers through trial and error.

It seems to work moderately well now but I've been looking at how the generated text on the GUI compares to the SierraWithBackground style that still appears, and it's not always identically wrapped. Here is a comparison screenshot: the dialogue above is my emulated code and the dialogue below is how AGS handles it. Can someone tell me where my maths is going wrong?

http://img141.imageshack.us/img141/2601/sierrabackgroundwithnew.png

Code: ags

    //This bit is for the New Text GUI

if (GetTextWidth(what, 1)>215) {
      gNewText.Width=235;
      gNewText.Height=(GetTextHeight(what,1, 215)+10);
      NewTextLabel.Width=225;
      NewTextLabel.Height=GetTextHeight(what, 1, 215);
      NewTextBorder.Width=225;
      NewTextBorder.Height=GetTextHeight(what, 1, 215);
    }

    else {
      gNewText.Width=(GetTextWidth(what, 1)+10);
      gNewText.Height=(GetTextHeight(what, 1, GetTextWidth(what, 1)));
      NewTextLabel.Width=GetTextWidth(what, 1)*2;
      NewTextLabel.Height=GetTextHeight(what, 1, GetTextWidth(what, 1));
      NewTextBorder.Width=GetTextWidth(what, 1)*2;
      NewTextBorder.Height=GetTextHeight(what, 1, GetTextWidth(what, 1));
    }
    
    BottomLeft.Y=gNewText.Height-2;
    BottomRight.SetPosition(gNewText.Width-2, gNewText.Height-2);
    TopRight.X=gNewText.Width-2;
    TopRight.Y=0;
    RightBorder.SetPosition(gNewText.Width-2, 0);
    BottomBorder.SetPosition(0, gNewText.Height-2);
    
    NewTextLabel.SetText(what);
    NewTextBorder.SetText(what);
    gNewText.Visible=true;
    gNewText.SetPosition(5, 5);
    
    //End New Text GUI bit
    
    this.Say(what);

Khris

If you use an outlined font, put the outer font into GetTextWidth/Height.
This should be font 2 here.

AdamM

No, I've changed all the 1s to 2s and that doesn't seem to have changed anything.

AdamM


AdamM

I'm a patient man.

Unfortunately I'm also a perfectionist, so my game isn't getting developed until I can resolve this.

Crimson Wizard

#9
There's a certain mistake in AGS I reported back in 2009:
Perhaps it may have influence in your case too, please check the discussion:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=36567.0

EDIT: Or maybe not.... hard to tell. The last sample from the picture you posted has more specific mistake... but, I don't have time to analyse your code right now, sorry.

AdamM

I think I've already compensated for that, but thanks for pointing it out.

I've been analysing how AGS treats different strings of text, and rather than the Text Window wrapping at a static width as I had assumed, it varies slightly. AGS seems to magically know what width to set the window at so the text wraps without any big gaps or space. But surely that's impossible to determine with the script? I wish CJ could reveal how it's done.

SMF spam blocked by CleanTalk