Custom dialog rendering - line break & flipping pages?

Started by kaputtnik, Tue 02/12/2008 17:42:34

Previous topic - Next topic

kaputtnik

Hello there, adept AGS scripters of the world,

I am having troubles with a temporary custom dialogs GUI. I simply copied the examples and modified them to suit the game, and it works like it should and renders nicely, but there are two things I don't really know how to.

Basically, I'd like to be able to make the GUI look like a book page where you can click certain things, others not, and where you can flip pages to bring up the next pair of, let's say, 7 clickable dialog lines.

The first thing I fail at is a line break for long sentences within the dialog_options_render-function. I just don't know where to put it and how to use the GetTextWidth command appropriately.

The second thing is the flipping of the pages - how can I determine that after a certain amount of displayed responses, others should be displayed on the next page?


I realize this could be some trouble to explain, but I'd really, really appreciate it.
I, object.

Pumaman

Well, decide on the width of the area that you want to render the text into. Then, use GetTextHeight to find out how tall the text will be, and use DrawStringWrapped to draw it there.

kaputtnik

#2
Thanks, Chris! I think the first part of it works now (I had overlooked the DrawStringWrapped command in the manual), but since I have changed the script, all the dialog options are cluttered on top of each other and I can't seem to fix it. I am pretty confused by what "width" and "height" actually mean...especially since in the example, it says:

ypos += GetTextHeight(info.DialogToRender.GetOptionText(i), eFontFont0, 10000);


I don't get where that 10000 is coming from, could somebody explain it to me? Thanks!
I, object.

Pumaman

The example in the manual is overly-simplistic, and just supplies a width of 10000 such that the text will never wrap. Rather than 10000 you should supply the width of the area that you're drawing the options into.

I can't remember why the example uses 10000 actually, it should probably be "info.Width - 10" or something like that.

kaputtnik

#4
Alright, the first part works like a charm now!

The next step would be to determine when one book page is full and the player has to switch over to the next page.

I suppose I should try to first render only, let's say, seven options in the dialog_options_render-function and then display the next seven using the dialog_options_mouse_click. I'll try my luck and maybe come back and whine if I fail.

edit: Alright, I am back to whine, already. I have managed to display a certain amount of dialog options, but switching (by right clicking on the GUI without clicking a dialog option) over to the next page will trigger one of the options on the next page immediately.
I, object.

Pumaman

If your dialog_options_get_active function returns an option number, AGS will process that when the player clicks the mouse. The example in the manual just checks the Y co-ordinate and returns the option at that vertical position, so you probably need to exclude the location of your scroll arrows from returning an option number.


This custom dialog stuff is quite complicated, but the idea is that it provides AGS with the power for advanced scripters to be able to create script modules with custom dialogue systems -- it's certainly not something I'd recommend playing around with if you're not completely comfortable with scripting :)

kaputtnik

I totally agree that this kind of advanced scripting is way over my head  - which puts me in kind of an awkward situation, as it seems like this is the only way I can implement a custom dialogs GUI for a certain room, or is there another possibility to do this?

I have been searching the manual and the forums high and low for a clue if and how it is possible to change the dialogs GUI at runtime, but to no avail.
I, object.

Trent R

game.speech_text_gui        The textwindow GUI number used for sierra-style speech.

From the game variables page in the manual.

~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Pumaman

If you mean the Dialog Options GUI, you can change it temporarily using the SetGameOption function.

kaputtnik

Quote from: Pumaman on Wed 03/12/2008 21:54:21
If you mean the Dialog Options GUI, you can change it temporarily using the SetGameOption function.

Zounds, I have never even seen this page! Thanks² and hooray for my completely worthless scripting efforts! I could have simply asked for it right away, I guess...

Trent R, thanks, I knew of the existence of that command - after all, it is not as well hidden as the other one.
I, object.

Trent R

Dang, meant to post the one CJ did but wasn't thinking... I think I should probably take a break from the forums.....


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

abstauber

#11
Hey!

I've just finished a module for the custom dialogs, don't worry - the code is in english ;)



It supports optional bullets, up/down scrolling borders and background graphics.

Get it while it's hot - so far I haven't found any bugs, but there could be still some in.
Oh, and I've only tested it in 320x200...


By the way, is it good enough for the module section?

kaputtnik

I, object.

Ghost

Woo-hoo! Great job, I was pulling my hair over here...

abstauber


Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk