Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: monkey0506 on Thu 30/12/2004 21:17:11

Title: Scrolling Dialog Template -- DEPRECATED
Post by: monkey0506 on Thu 30/12/2004 21:17:11
This template is officially deprecated.  I would suggest using the ScrollingDialog script module, which is its replacement, found here (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=27930).  Thank you.

ATTENTION:

This template was designed within and for AGS Version 2.62.  It is now outdated, although it's replacement is still under construction.  It was never fully implemented, but the missing features are getting worked on in the Script Module that will replace this template.  You are still free to use this as you see fit, but as I now use AGS 2.7 support may (and probably will) be limited!

--

I've been waiting a long time for scrolling dialogs to get off of the AGS tracker, but it's still there. So, I got bored and did it myself (a.k.a. I promised authenticity, and I'm pretty anal about it). I want to thank those who helped me with label-clicks and multidimensional arrays.

Things to note:
If you download the template, make sure you do not change these settings
1. This is entirely script-based and does not use AGS's built in dialog interface.
2. This script is customized for a 7 label GUI "DIALOG" that display the text for the dialog.
3. Customized for a 2 button GUI "DLGARROWS" with arrows that turn off if you can not scroll in that respective direction.
4. With the current script you can not have text that spans longer than 1 line.
5. DIALOG and DLGARROW GUIs MUST be normal GUIs not pop-up modal.
6. The "dlg" struct is contained in the header file.  I'm not sure if it can be moved, but that is where it's at.
7. I wrote this script, so if it's not too much to ask, I'd like some credit.

Now that that's said and done, the script:

[EDIT: See latest script here (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=18466.msg232302#msg232302).]

;D Michael Rittenhouse

Last edit:  13 March 2005
Local time (at edit):  5:20 P.M.

(Edited by strazer to add first note)
Title: Re: Scrolling dialogs.
Post by: Rui 'Trovatore' Pires on Thu 30/12/2004 21:44:41
Any chance of templatizing it? I could upload it then. And I could see this going into the archive...

(But by all means, CJ, don't let this workaround postpone the much awaited feature. ::) )
Title: Re: Scrolling dialogs.
Post by: Ponch on Thu 30/12/2004 22:19:48
 :o

Wow! That is amazing!

I'll have to give that a try in a game.

Thank you for sharing that code.
Title: Re: Scrolling dialogs.
Post by: monkey0506 on Fri 31/12/2004 01:04:37
 ;D I'm glad you guys like it. But please test it, as I customized the scripts for my game and copied/pasted/edited it for the post. I may have missed something, and be sure to test it for bugs. I still can't believe that I coded all that. I did have some help with label clicks and strazer showed me how to set up the struct (thanks guys ;D) but I still can't get over the feeling that I did this. Well, like I said, have fun. I figure that this is fairly customizable as it's entirely script based. If you need any help, just ask and I'll try to figure out why this thing works...

EDIT:

Quote(But by all means, CJ, don't let this workaround postpone the much awaited feature.Ã,  ::) )

By the way, I would like to hear CJ's comments on this "workaround". ;D

EDIT: I don't know about a template. I guess I could make one... ::) I'll get to it eventually. That will give me an excuse to not be working on my game (all I need now to release the first demo is to finish the graphics :P).
Title: Re: Scrolling dialogs.
Post by: Rui 'Trovatore' Pires on Fri 31/12/2004 09:15:12
Ok. Just be sure to tell me if you DON'T templatize it, because in that case I will. ;)
Title: Re: Scrolling dialogs.
Post by: monkey0506 on Fri 31/12/2004 19:04:14
I have found a problem with my script. It only allows for the text to be one line long. I'm looking into fixing this at the moment. I'll let you know if I get it figured out.


EDIT:

I've tried using something like:

if ((StrLen(text) * MAXFONTWIDTH) > DIALOGGUIWIDTH) {
Ã,  SetLabelText(DIALOG, (line + 1 + shift), "");
Ã,  line++
Ã,  }


There's more to what I actually tried, but that's the basic idea of what I tried. It didn't work.

1. I changed the label that certain text would appear on, so that would produce errors with RunCustomDialog.
2. Some lines which didn't overflow the first line graphically did mathematically.
3. The second line of an option is shifted down from where it should appear.

So, I tried using an average of the smallest width and the largest width used by the font. It produced the same errors. I don't want to use the smallest width (which for my font is 1 pixel) because that would definitely produce errors (You could have 200 "i"s at 200 pixels (one line), but 200 "M"s would be 1600 pixels (over 4 lines) with the font I'm using.) So, unless I manually store and test the width of every character in the string, I don't see how multi-line text is going to be possible here. And I don't know about your fonts, but mine has 89 characters, so (manually, as in, USER DEFINED) storing that many variables isn't logical for this matter. Perhaps this "work around" will inspire Chris to finish the AGS implemented version so we can have multi-line text, but untill then, I suggest keeping it to one line (unless one of you have an idea(?)).

EDIT:

You know, this also serves as a work-around for some other problems with the dialogs:

Custom-defining the highlight color.
Animating objects/characters/backgrounds/etc. while choosing a dialog option.

But I guess you have a choice. You can get these three things, or you can get multi-line dialog options. I'd probably have to choose the scrollability over the multi-line(ity)...
Title: Re: Scrolling dialogs.
Post by: Pumaman on Sun 02/01/2005 15:55:01
Very clever, your own dialog system, pretty much :)

Anyway yes, the dialog options changes are still on my to-do list, but I've got other things to concentrate on for 2.7 so this workaround is good for a while at least :)
Title: Re: Scrolling dialogs.
Post by: monkey0506 on Mon 03/01/2005 21:18:21
Sweet! Two "smiley" smileys! Thanks for the compliments Chris! ;D I was at a friend's house most of the weekend, and I have to start going back to school tomorrow (4 Jan) so I'll work on templatizing this, but it could take me a while...
Title: Re: Scrolling dialogs.
Post by: Mr Flibble on Mon 03/01/2005 21:54:40
Wow Michael, I underestimated you. Bravo!
Title: Re: Custom scrolling dialog options GUI
Post by: monkey0506 on Tue 04/01/2005 01:09:23
I got Tech Archived! :o I can now die happy! ;D Thanks for all the positive feedback. BTW, I'm still looking for a way to provide multi-line text, so feel free to offer ideas. ;D

EDIT: By the way, the list of "things to note" in the first post has been updated, so if you haven't read it lately, go back and look over it again.
Title: Re: Custom scrolling dialog options GUI
Post by: strazer on Tue 04/01/2005 01:14:42
Yeah, although I haven't actually tested your code...
So hurry up with that template! ;)
Title: Re: Custom scrolling dialog options GUI
Post by: monkey0506 on Fri 07/01/2005 23:03:10
Just wondering, has anyone yet tested the code? I've still been contemplating perfection (multi-line text support), so I haven't actually started on the template yet. I don't suppose it would take me very long to make one, I just haven't done it yet. Ok... I think I'll do it now. I'm bored enough. ::)

YAY! I've made a template! Be warned though: I didn't take the time to make proper cursors, so they're really crappy. I used the empty template, and ripped the cursors from the Default template, and did a crappy job for it. The cursors are all large black squares with the pictures inside them. If it's really that important, I could re-install Photoshop (I didn't intentionally format the hard drive!) and fix the cursors to have a black outline, instead of a black square. (Hey, version 2.0? XD)

Have fun, and feel free to link the crap out of it. I don't even use this brinkster account any more:

http://www32.brinkster.com/monkey0506/csdlg.zip
Title: Re: Custom scrolling dialog options GUI
Post by: Candle on Sat 08/01/2005 08:04:02
The game crashed when I tried to talk to ego and gave this error .
---------------------------
Adventure Game Studio
---------------------------
An internal error has occured. Please note down the following information.
If the problem persists, contact Chris Jones.
(ACI version 2.63.780)

Error: run_text_script1: error -6 running function 'character2_b':
Error (line 23): Array index out of bounds (index: -1, bounds: 0..8999)


Title: Re: Custom scrolling dialog options GUI
Post by: Rui 'Trovatore' Pires on Sat 08/01/2005 11:11:22
I'll upload the template in my resource site as soon as it's bug proof, yes? (reference to Candle's post) ::)
Title: Re: Custom scrolling dialog options GUI
Post by: strazer on Sat 08/01/2005 12:49:50
Which version of AGS was the template made with?
It doesn't show up for me in either AGS 2.62 or 2.7 Beta 10. Please try giving the file a shorter name when creating it.
Title: Re: Custom scrolling dialog options GUI
Post by: monkey0506 on Sat 08/01/2005 20:34:12
I used AGS 2.63 when I made it... I didn't realize making the name long would cause problems, but I'm having problems getting it to show up too. I did get it to show up once last night (after quite a few tries), so I figured maybe it was just my computer... Ok, I got it now, I'm not sure exactly how, I just kept trying. I'll try making the new template with a shorter name (after I try to figure out Candle's apparent bug). BTW, the script in the template will actually be better than that which I posted, because I did find some run-time errors there, and thought I had fixed all of them. I made the script in my game, so it was tricky picking it all out. I'll take a look at that now, and update you on any news.

Ok... I lied, it was made with 2.62... I could've sworn I had 2.63 installed... BTW, I don't know why it would say that there was an array out of bounds. For one, 'character2_b' isn't on line 23, and I checked, and line 23 contains no array element... I'm going to re-upload the template... Let me know if you still have problems. BTW, renaming it appears to have fixed the problem with "it [not] show[ing] up" (strazer), as it appears on the new game list every time I try it now...
Title: Re: Custom scrolling dialog options GUI
Post by: Candle on Sat 08/01/2005 21:58:54
I'm getting a bad zip now .
Title: Re: Custom scrolling dialog options GUI
Post by: monkey0506 on Sun 09/01/2005 02:02:08
I don't know what the problem is. ??? This is beginning to get frustrating. If someone can give me their email, I'll try sending them an unzipped copy of the template, and see if they can get it to work that way. Otherwise, the only thing I can think to suggest would be to dowload PicoZip (http://www.picozip.com/) and try using that to open the zip file. That's what I used to compress it, and when I opened the file (off of the link) just now, it worked fine. ???
Title: Re: Custom scrolling dialog options GUI
Post by: Candle on Sun 09/01/2005 04:49:15
Here is the file that monkey sent to me so if someone gets a bad zip on the one linked here you can try this one .
http://12.22.230.41/MicroTech/Host/Games/CustomScrollingDialog.zip
will be up for 60 days .
Title: Re: Custom scrolling dialog options GUI
Post by: monkey0506 on Sun 09/01/2005 12:56:45
Candle, you didn't comment on the template itself. Did you still get that error when talking to Roger?

EDIT: Candle emailed me:

QuoteWell ran it at 640 and it did the crash so loaded it again at 320 and
it didn't crash when I used the talk icon on ego . but it gives me the
a two line dialogue ?
Click on it with any ofÃ,  the other icons and it gives the scrolling dialogue .
but clicking on the top when and it quits the dialogue .
clicking any other oneÃ,  locks the mouse so can't change iconÃ,  to walk etc ..
It maybe my system ? but I will upload it and give link in your post
so someone else can try it .

I guess that for some reason you have to run the template at 320 resolution? As for the dialogs, there are two set up.

Dialog 0:
1. My name's Guybrush Threepwood. Prepare to die! (this one turns off after it is said)
2. So... How did you get up there? (use this to exit the dialog)
3. I'll just be running along now. (use this to exit the dialog)

Dialog 1: (8 messages just for testing -- This one should be scrollable. Use option 1 to exit the dialog.)

I also set it up so that the game does not respond to mouse-clicks or key-presses if you are running a dialog. That is why you can't change the cursor mode while running a dialog. You can change this in the global script, it's not a bug... It's just to emulate the paused interface of AGS's default handling. You can allow anything you want, I just disallowed anything for the template. And I just tested it on my computer in 640 X 400, and it didn't produce any errors. Perhaps it's Candle's computer? Can someone else verify either way. In any case I made a template from the 640 X 400 version (if that makes a difference).

http://www32.brinkster.com/monkey0506/dlg640.zip

Let me know if you get another bad zip so I can send the full file to someone via email (I can only upload 1 MB to the website). Oh... And something that (doesn't need to) but should be changed:

// interface_click
// if (button == 0)
else if (button == 1) { // scroll down
Ã,  optstate[DialogVariable(1)] = 1; // topopt = off;
Ã,  optstate[DialogVariable(2) + 1] = 0; // bottomopt + 1 = on;
Ã,  }
// SetupDialog


In interface click, the line that reads "optstate[DialogVariable(1)]" of the "else if" statement should appear before the line that reads "optstate[DialogVariable(2) + 1]". This is just to ensure that scrolling down does not produce errors (turning the bottom option + 1 on first could cause options which are not on to have their optstate[] set to 0 (on), which could cause problems later). Please notify me of any other bugs/(possible) errors that you find. :)

EDIT: In the two most recent versions of the template there is no function character2_b. I used the interaction editor, deleted all interaction, then put all the scripts (2) in the "any click" option. So is it now producing the error in function character2_a (which exists) or is it producing an error in a non-existant area of the script???
Title: Re: Custom scrolling dialog options GUI
Post by: Candle on Sun 09/01/2005 13:14:50
I sent you an email .
Title: Re: Custom scrolling dialog options GUI
Post by: monkey0506 on Sun 09/01/2005 13:33:55
I edited my post. ;)
Title: Re: Custom scrolling dialog options GUI
Post by: Rui 'Trovatore' Pires on Thu 13/01/2005 19:18:13
Well, no further problems have come up, right? Then I'll add your template to my archive. :)
Title: Re: Custom scrolling dialog options GUI
Post by: monkey0506 on Sat 29/01/2005 02:58:26
Well, after a long break trying to figure out what was wrong with my scripts, I realized virtually nothing was wrong with them. Either that or it was an issue with something changed when I just made this update:

[EDIT: See latest script here (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=18466.msg232302#msg232302).]

I don't have time (and I can't get a good link anyway) to rebuild/reupload the template files, but that script should fix a few minor things, as well as making the global script a tiny bit shorter (notice the way I rescripted on_event, it's much nicer that way). And I never did get a definitive reply as to whether or not Candle ever got this working in 640 resolution...

EDIT: I've just discovered the "GetTextWidth" function... Hmm... Perhaps I could figure out aÃ,  way to allow multi-line text... This would be very extremely useful in doing so. Why hasn't anyone mentioned this???
Title: Re: Custom scrolling dialog options GUI
Post by: monkey0506 on Sun 06/02/2005 01:43:06
Update again!Ã,  Sorry about all these long posts, but this one is a major update to the global script:

// main global script file

int RunningDialog; // stores currently running dialog
dlg dlgnum[300]; // max 300 dialogs
int optstate[9000]; // Max. 30 topics per dialog, Max. 300 dialogs

function DialogVariable(int var){
Ã,  if (var == 0) {
Ã,  Ã,  int firstopt = (RunningDialog * 30);
Ã,  Ã,  return firstopt;
Ã,  Ã,  }
Ã,  else if (var == 1) {
Ã,  Ã,  int topopt = (RunningDialog * 30);
Ã,  Ã,  while (optstate[topopt] != 0) topopt++;
Ã,  Ã,  return topopt;
Ã,  Ã,  }
Ã,  else if (var == 2) {
Ã,  Ã,  int bottomopt = (RunningDialog * 30);
Ã,  Ã,  while (optstate[bottomopt] != 0) bottomopt++;
Ã,  Ã,  bottomopt += 6;
Ã,  Ã,  return bottomopt;
Ã,  Ã,  }
Ã,  else if (var == 3) {
Ã,  Ã,  int lastopt = (RunningDialog * 30);
Ã,  Ã,  lastopt += 29;
Ã,  Ã,  }
}

function OptStateEstablishment() {
Ã,  // set objects not contained in the first 7 lines of a dialog
Ã,  // to "off by scrolling"
Ã,  int i = 0;
Ã,  while (i <= 8999) {
Ã,  Ã,  optstate[i] = 1;
Ã,  Ã,  i++;
Ã,  Ã,  }
Ã,  RunningDialog = 0;
Ã,  while (RunningDialog <= 299) {
Ã,  Ã,  int j = DialogVariable(0);
Ã,  Ã,  while (j < (DialogVariable(0) + 7)) {
Ã,  Ã,  Ã,  optstate[j] = 0;
Ã,  Ã,  Ã,  j++;
Ã,  Ã,  Ã,  }
Ã,  Ã,  RunningDialog++;
Ã,  Ã,  }
Ã,  RunningDialog = -1;
Ã,  }

#sectionstart game_startÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() // called when the game starts, before the first room is loaded
Ã,  {
Ã,  // Turn off DIALOG and DLGARROW GUIs
Ã,  GUIOff(DIALOG);
Ã,  GUIOff(DLGARROWS);
Ã,  OptStateEstablishment();
Ã,  }
#sectionend game_startÃ,  // DO NOT EDIT OR REMOVE THIS LINE

function GetOptionText(int option) {
Ã,  // use this function to get the text of a variable option of the running dialog, i.e., as in a while loop
Ã,  if (option > 29) option -= DialogVariable(0); // set up for appropriate dialog
Ã,  if (option == 0) return dlgnum[RunningDialog].text0;
Ã,  else if (option == 1) return dlgnum[RunningDialog].text1;
Ã,  else if (option == 2) return dlgnum[RunningDialog].text2;
Ã,  else if (option == 3) return dlgnum[RunningDialog].text3;
Ã,  else if (option == 4) return dlgnum[RunningDialog].text4;
Ã,  else if (option == 5) return dlgnum[RunningDialog].text5;
Ã,  else if (option == 6) return dlgnum[RunningDialog].text6;
Ã,  else if (option == 7) return dlgnum[RunningDialog].text7;
Ã,  else if (option == 8) return dlgnum[RunningDialog].text8;
Ã,  else if (option == 9) return dlgnum[RunningDialog].text9;
Ã,  else if (option == 10) return dlgnum[RunningDialog].text10;
Ã,  else if (option == 11) return dlgnum[RunningDialog].text11;
Ã,  else if (option == 12) return dlgnum[RunningDialog].text12;
Ã,  else if (option == 13) return dlgnum[RunningDialog].text13;
Ã,  else if (option == 14) return dlgnum[RunningDialog].text14;
Ã,  else if (option == 15) return dlgnum[RunningDialog].text15;
Ã,  else if (option == 16) return dlgnum[RunningDialog].text16;
Ã,  else if (option == 17) return dlgnum[RunningDialog].text17;
Ã,  else if (option == 18) return dlgnum[RunningDialog].text18;
Ã,  else if (option == 19) return dlgnum[RunningDialog].text19;
Ã,  else if (option == 20) return dlgnum[RunningDialog].text20;
Ã,  else if (option == 21) return dlgnum[RunningDialog].text21;
Ã,  else if (option == 22) return dlgnum[RunningDialog].text22;
Ã,  else if (option == 23) return dlgnum[RunningDialog].text23;
Ã,  else if (option == 24) return dlgnum[RunningDialog].text24;
Ã,  else if (option == 25) return dlgnum[RunningDialog].text25;
Ã,  else if (option == 26) return dlgnum[RunningDialog].text26;
Ã,  else if (option == 27) return dlgnum[RunningDialog].text27;
Ã,  else if (option == 28) return dlgnum[RunningDialog].text28;
Ã,  else if (option == 29) return dlgnum[RunningDialog].text29;
Ã,  }

function HighlightDialog() { //highlight the dialog option under the mouse
Ã,  if ((IsGUIOn(DIALOG)) && (GetGUIAt(mouse.x, mouse.y) == DIALOG)) {
Ã,  Ã,  if (GetGUIObjectAt(mouse.x, mouse.y) == 0) SetLabelColor(DIALOG, 0, 13);
Ã,  Ã,  else SetLabelColor(DIALOG, 0, 31055);
Ã,  Ã,  if (GetGUIObjectAt(mouse.x, mouse.y) == 1) SetLabelColor(DIALOG, 1, 13);
Ã,  Ã,  else SetLabelColor(DIALOG, 1, 31055);
Ã,  Ã,  if (GetGUIObjectAt(mouse.x, mouse.y) == 2) SetLabelColor(DIALOG, 2, 13);
Ã,  Ã,  else SetLabelColor(DIALOG, 2, 31055);
Ã,  Ã,  if (GetGUIObjectAt(mouse.x, mouse.y) == 3) SetLabelColor(DIALOG, 3, 13);
Ã,  Ã,  else SetLabelColor(DIALOG, 3, 31055);
Ã,  Ã,  if (GetGUIObjectAt(mouse.x, mouse.y) == 4) SetLabelColor(DIALOG, 4, 13);
Ã,  Ã,  else SetLabelColor(DIALOG, 4, 31055);
Ã,  Ã,  if (GetGUIObjectAt(mouse.x, mouse.y) == 5) SetLabelColor(DIALOG, 5, 13);
Ã,  Ã,  else SetLabelColor(DIALOG, 5, 31055);
Ã,  Ã,  if (GetGUIObjectAt(mouse.x, mouse.y) == 6) SetLabelColor(DIALOG, 6, 13);
Ã,  Ã,  else SetLabelColor(DIALOG, 6, 31055);
Ã,  Ã,  }
Ã,  else { // mouse not over GUI option
Ã,  Ã,  SetLabelColor(DIALOG, 0, 31055);
Ã,  Ã,  SetLabelColor(DIALOG, 1, 31055);
Ã,  Ã,  SetLabelColor(DIALOG, 2, 31055);
Ã,  Ã,  SetLabelColor(DIALOG, 3, 31055);
Ã,  Ã,  SetLabelColor(DIALOG, 4, 31055);
Ã,  Ã,  SetLabelColor(DIALOG, 5, 31055);
Ã,  Ã,  SetLabelColor(DIALOG, 6, 31055);
Ã,  Ã,  }
Ã,  }

function OptStateNullEstablishment() {
Ã,  // turn empty strings off
Ã,  int i = DialogVariable(0);
Ã,  while (i <= DialogVariable(3)) {
Ã,  Ã,  string j;
Ã,  Ã,  StrFormat(j, "%s", GetOptionText(i));
Ã,  Ã,  if (StrComp(j, "") == 0) optstate[i] = -1;
Ã,  Ã,  i++;
Ã,  Ã,  }
Ã,  }

function SetupDialog(int dialog) {
Ã,  //this function is used to replace the dialog tab in the game editor
Ã,  RunningDialog = dialog; // store the currently running dialog globally
Ã,  // set up dialog text in arrays
Ã,  /****///DIALOG 1///****/
Ã,  StrCopy(dlgnum[0].text0, "My name's Guybrush Threepwood. Prepare to die!");
Ã,  StrCopy(dlgnum[0].text1, "So... How did you get up there?");
Ã,  StrCopy(dlgnum[0].text2, "I'll just be running along now.");
Ã,  /****///DIALOG 2///****/
Ã,  StrCopy(dlgnum[1].text0, "This is the first option of dialog two.");
Ã,  StrCopy(dlgnum[1].text1, "It's not that fantastic, but it's just for testing.");
Ã,  StrCopy(dlgnum[1].text2, "I need to make six more after this.");
Ã,  StrCopy(dlgnum[1].text3, "One down, five more to go for this dialog.");
Ã,  StrCopy(dlgnum[1].text4, "Funny the way I gave up on trying to build a dialog tree.");
Ã,  StrCopy(dlgnum[1].text5, "A few more to go now...");
Ã,  StrCopy(dlgnum[1].text6, "I'm getting bored.");
Ã,  StrCopy(dlgnum[1].text7, "This is making me tired.");
Ã,  StrCopy(dlgnum[1].text8, "This is the last one, thank goodness.");
Ã,  OptStateNullEstablishment(); // turn off empty options
Ã,  // set appropriate dialog text on GUI
Ã,  int line = 0; // stores current line (0 - 6) of DIALOG GUI
Ã,  int shift = 0; // shifts text in appropriate direction
Ã,  int option = DialogVariable(0); // begin while loop at firstopt
Ã,  string text; // stores text to be set on label
Ã,  while ((line + shift) <= 6) { // sets text on label
Ã,  Ã,  StrFormat(text, "%s", GetOptionText(option)); // format text
Ã,  Ã,  if (optstate[option] == 0) // if option is ON
Ã,  Ã,  Ã,  SetLabelText(DIALOG, (line + shift), text); // set text on label
Ã,  Ã,  else shift--; // shift text up
Ã,  Ã,  line++; // go to next line
Ã,  Ã,  option++; // and next option
Ã,  Ã,  }
Ã,  // check ability to scroll
Ã,  string strbotopt, strbotopt1;
Ã,  StrFormat(strbotopt, "%s", (GetOptionText(DialogVariable(2)))); // check bottom option
Ã,  StrFormat(strbotopt1, "%s", (GetOptionText(DialogVariable(2) + 1))); // check option below bottom option
Ã,  int i = DialogVariable(1);
Ã,  int j = (DialogVariable(2) + 1);
Ã,  while ((i >= DialogVariable(0)) && (optstate[i] != 1)) i--;
Ã,  while ((j <= DialogVariable(4)) && (optstate[j] != 1)) j++;
Ã,  if (((DialogVariable(1) != DialogVariable(0)) && (optstate[i] == 1)) ||
Ã,  Ã,  ((StrComp(strbotopt, "") != 0) && (StrComp(strbotopt1, "") != 0) &&
Ã,  Ã,  (optstate[j] == 1))) { // can scroll
Ã,  Ã,  Ã,  if ((DialogVariable(1) != DialogVariable(0)) && (optstate[i] == 1)) { // can scroll up
Ã,  Ã,  Ã,  Ã,  SetGUIObjectEnabled(DLGARROWS, 0, 1);
Ã,  Ã,  Ã,  Ã,  SetButtonPic(DLGARROWS, 0, 1, 79);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  else { // can not scroll up
Ã,  Ã,  Ã,  Ã,  SetGUIObjectEnabled(DLGARROWS, 0, 0);
Ã,  Ã,  Ã,  Ã,  SetButtonPic(DLGARROWS, 0, 1, 0);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  if ((StrComp(strbotopt, "") != 0) && (StrComp(strbotopt1, "") != 0) &&
Ã,  Ã,  Ã,  Ã,  (optstate[j] == 1)) { // can scroll down
Ã,  Ã,  Ã,  Ã,  SetGUIObjectEnabled(DLGARROWS, 1, 1);
Ã,  Ã,  Ã,  Ã,  SetButtonPic(DLGARROWS, 1, 1, 81);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  else { // can not scroll down
Ã,  Ã,  Ã,  Ã,  SetGUIObjectEnabled(DLGARROWS, 1, 0);
Ã,  Ã,  Ã,  Ã,  SetButtonPic(DLGARROWS, 1, 1, 0);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  SetGUIPosition(DIALOG, 16, 143);
Ã,  Ã,  Ã,  SetGUISize(DIALOG, 304, 57);
Ã,  Ã,  Ã,  GUIOn(DLGARROWS);
Ã,  Ã,  Ã,  }
Ã,  else { // can not scroll
Ã,  Ã,  SetGUIPosition(DIALOG, 0, 143);
Ã,  Ã,  SetGUISize(DIALOG, 320, 57);
Ã,  Ã,  GUIOff(DLGARROWS);
Ã,  Ã,  }
Ã,  GUIOn(DIALOG); // turn on the dialog GUI
Ã,  }

function EndDialog() {
Ã,  RunningDialog = -1; // no dialog running
Ã,  GUIOff(DLGARROWS); // turn off dialog arrows
Ã,  GUIOff(DIALOG); // turn off dialog
Ã,  SetCursorMode(0);
Ã,  // TURN ON NORMAL GUIS HERE
Ã,  }

function RunCustomDialog(int dialog, int option){
Ã,  //this function is used to replace the dialog editor
Ã,  GUIOff(DLGARROWS); // turn off dialog arrows during speech
Ã,  GUIOff(DIALOG); // turn off dialog GUI during speech
Ã,  while (optstate[option] != 0) option++;
Ã,  if (option > 29) option -= DialogVariable(0);
Ã,  if (dialog==0){
Ã,  Ã,  if ((option > 2) && (option < 7)) SetupDialog(0);
Ã,  Ã,  if (option==0){
Ã,  Ã,  Ã,  DisplaySpeech(GBRUSH, dlgnum[0].text0);
Ã,  Ã,  Ã,  DisplaySpeech(CHAR, "No... That can't be right. I'm Guybrush!");
Ã,  Ã,  Ã,  DisplaySpeech(GBRUSH, "Woah... You're right!");
Ã,  Ã,  Ã,  DisplaySpeech(CHAR, "Of course I'm right.");
Ã,  Ã,  Ã,  optstate[0] = -1;// turn of dlgnum[0].text0
Ã,  Ã,  Ã,  SetupDialog(0);
Ã,  Ã,  Ã,  }
Ã,  Ã,  else if (option==1){
Ã,  Ã,  Ã,  DisplaySpeech(GBRUSH, dlgnum[0].text1);
Ã,  Ã,  Ã,  DisplaySpeech(CHAR, "I was born this way.");
Ã,  Ã,  Ã,  DisplaySpeech(GBRUSH, "You were?");
Ã,  Ã,  Ã,  DisplaySpeech(GBRUSH, "That's amazing!");
Ã,  Ã,  Ã,  DisplaySpeech(CHAR, "Yes, but--");
Ã,  Ã,  Ã,  DisplaySpeech(CHAR, "OH MY!");
Ã,  Ã,  Ã,  DisplaySpeech(CHAR, "Look, a distraction!");
Ã,  Ã,  Ã,  DisplaySpeech(GBRUSH, "Where?");
Ã,  Ã,  Ã,  EndDialog();
Ã,  Ã,  Ã,  }
Ã,  Ã,  else if (option==2){
Ã,  Ã,  Ã,  DisplaySpeech(GBRUSH, dlgnum[0].text2);
Ã,  Ã,  Ã,  DisplaySpeech(CHAR, "You do that, son...");
Ã,  Ã,  Ã,  EndDialog();
Ã,  Ã,  Ã,  }
Ã,  Ã,  }
Ã,  else if (dialog == 1) {
Ã,  Ã,  if (option == 8) {
Ã,  Ã,  Ã,  DisplaySpeech(GBRUSH, dlgnum[1].text8);
Ã,  Ã,  Ã,  optstate[DialogVariable(0) + 8] = -1;
Ã,  Ã,  Ã,  SetupDialog(1);
Ã,  Ã,  Ã,  }
Ã,  Ã,  else EndDialog();
Ã,  Ã,  }
Ã,  }

function AutoScrollDialog() {
Ã,  // automatically correct the scrolling of the dialogues
Ã,  if (optstate[DialogVariable(2)] == -1) {
Ã,  Ã,  int i = DialogVariable(2);
Ã,  Ã,  while ((optstate[i] != 1) && (i <= DialogVariable(3))) i++;
Ã,  Ã,  if (optstate[i] == 1) optstate[i] = 0;
Ã,  Ã,  else {
Ã,  Ã,  Ã,  int j = DialogVariable(1);
Ã,  Ã,  Ã,  while ((optstate[j] != 1) && (j >= DialogVariable(0))) j--;
Ã,  Ã,  Ã,  if (optstate[j] == 1) optstate[j] = 0;
Ã,  Ã,  Ã,  }
Ã,  Ã,  SetupDialog(RunningDialog);
Ã,  Ã,  }
Ã,  }

#sectionstart on_eventÃ,  //DO NOT EDIT OR REMOVE THIS LINE
function on_event(int event, int data) {
Ã,  if (event == GUI_MDOWN) { // if clicked on A GUI (any mouse button, combine with IsButtonDown to allow/disallow buttons)
Ã,  Ã,  if (data == DIALOG) { // if clicked on THIS gui
Ã,  Ã,  Ã,  RunCustomDialog(RunningDialog, DialogVariable(1) + GetGUIObjectAt(mouse.x, mouse.y));
Ã,  Ã,  Ã,  }
Ã,  Ã,  }
Ã,  }
#sectionend on_eventÃ,  //DO NOT EDIT OR REMOVE THIS LINE

#sectionstart repeatedly_executeÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute()
Ã,  {
Ã,  // put anything you want to happen every game cycle here
Ã,  HighlightDialog();
Ã,  AutoScrollDialog();
Ã,  }
#sectionend repeatedly_executeÃ,  // DO NOT EDIT OR REMOVE THIS LINE

function show_inventory_window()Ã,  Ã, 
// This demonstrates both types of inventory window - the first part is how to
// show the built-in inventory window, the second part uses the custom one.
// Un-comment one section or the other below.
Ã,  {
Ã,  // ** DEFAULT INVENTORY WINDOW
Ã,  InventoryScreen();
Ã,  /*Ã, 
Ã,  // ** CUSTOM INVENTORY WINDOW
Ã,  GUIOn (INVENTORY);Ã, 
Ã,  // switch to the Use cursor (to select items with)
Ã,  SetCursorMode (MODE_USE);
Ã,  // But, override the appearance to look like the arrow
Ã,  SetMouseCursor (6);
Ã,  */
Ã,  }

#sectionstart on_key_pressÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function on_key_press(int keycode) // called when a key is pressed. keycode holds the key's ASCII code
Ã,  {
Ã,  if (/*(*/IsGUIOn(DIALOG)) /*&& (keycode !=Ã,  NEGATE YOUR DIALOG KEYCODES HERE ))*/ keycode = 0;
Ã,  // You may want some popup modal GUIs to be able to come on while the DIALOG
Ã,  // GUI is on. Negate these (i.e., keycode != 32) here so that other keypresses
Ã,  // will be ignored.
Ã,  // PLACE YOUR on_key_press SCRIPTS HERE
Ã,  if (IsGamePaused()==1) keycode=0; // game paused, so don't react to keypresses
Ã,  if (keycode==17) QuitGame(1); // Ctrl-Q
Ã,  if (keycode==363) SaveGameDialog(); // F5
Ã,  if (keycode==365) RestoreGameDialog(); // F7
Ã,  if (keycode==367) RestartGame(); // F9
Ã,  if (keycode==434) SaveScreenShot("scrnshot.pcx");Ã,  // F12
Ã,  if (keycode==9) show_inventory_window(); // Tab, show inventory
Ã,  }
#sectionend on_key_pressÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart on_mouse_clickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(int button) // called when a mouse button is clicked. button is either LEFT or RIGHT
Ã,  {
Ã,  if (IsGUIOn(DIALOG)) button = 0; // prevent non-GUI mouse-clicks during dialogÃ,  Ã, 
Ã,  if (IsGamePaused()==1) // Game is paused, so do nothing (ie. don't allow mouse click)
Ã,  Ã,  {
Ã,  Ã,  }
Ã,  // PLACE YOUR on_mouse_click SCRIPTS HERE
Ã,  else if (button==LEFT)
Ã,  Ã,  {
Ã,  Ã,  ProcessClick(mouse.x,mouse.y,GetCursorMode());
Ã,  Ã,  }
Ã,  else // right-click, so cycle cursor
Ã,  Ã,  {Ã,  Ã, 
Ã,  Ã,  SetNextCursorMode();
Ã,  Ã,  }
Ã,  }
#sectionend on_mouse_clickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart interface_clickÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(int interface, int button) {
Ã,  if (interface == DIALOG) on_event(GUI_MDOWN, DIALOG);
Ã,  else if (interface == DLGARROWS) {
Ã,  Ã,  if (button == 0) { // scroll up
Ã,  Ã,  Ã,  int i = DialogVariable(1);
Ã,  Ã,  Ã,  while ((i >= DialogVariable(0)) && (optstate[i] != 1)) i--;
Ã,  Ã,  Ã,  if (optstate[i] == 1) {
Ã,  Ã,  Ã,  Ã,  // if any option above the top has been turned off by scrolling
Ã,  Ã,  Ã,  Ã,  optstate[DialogVariable(2)] = 1;
Ã,  Ã,  Ã,  Ã,  optstate[i] = 0;
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  }
Ã,  Ã,  else if (button == 1) { // scroll down
Ã,  Ã,  Ã,  int i = DialogVariable(2) + 1;
Ã,  Ã,  Ã,  while ((optstate[i] != 1) && (i <= DialogVariable(3))) i++;
Ã,  Ã,  Ã,  if (optstate[i] == 1) {
Ã,  Ã,  Ã,  Ã,  // if any option below the bottom has been turned off by scrolling
Ã,  Ã,  Ã,  Ã,  optstate[DialogVariable(1)] = 1;
Ã,  Ã,  Ã,  Ã,  optstate[i] = 0;
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  }
Ã,  Ã,  SetupDialog(RunningDialog);
Ã,  Ã,  }
Ã,  // PLACE YOUR interface_click SCRIPTS HERE
Ã,  }
#sectionend interface_clickÃ,  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart character2_aÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function character2_a() {
Ã,  // script for character2: Any click on character
if (GetCursorMode() == MODE_TALK) {
Ã,  SetCursorMode(6);
Ã,  SetupDialog(0);
Ã,  }
else {
Ã,  SetCursorMode(6);
Ã,  SetupDialog(1);
Ã,  }Ã, 
}
#sectionend character2_aÃ,  // DO NOT EDIT OR REMOVE THIS LINE


I'll rebuild the template file tomorrow if I get a chance.Ã,  As for what this update does, it allows you to turn off options in scrolling dialogs.Ã,  With earlier versions this wasn't possible.Ã,  It also establishes the optstate of everything but the first 7 options of every dialog (the first shown, 0 - 6) as '1', which aids in proper scrolling capabilities.Ã,  And I now test whether the option you are scrolling to is actually off by scrolling.Ã,  If it's not off by scrolling, it will go to the first option that is, or if none are available, it will not allow scrolling.

EDIT:  I edited all the posts that contained lengthy bits of code and linked them to this post.

EDIT:  I reuploaded it to my site, but I'm not sure if it will work.  I had to use WinXP's compression service to zip it because my copy of Picozip self-corrupted.

http://www32.brinkster.com/monkey0506/dlg320.zip
http://www32.brinkster.com/monkey0506/dlg640.zip
Title: Re: Custom scrolling dialog options GUI
Post by: monkey0506 on Thu 24/02/2005 12:28:26
I know this may sound a bit big-headed of myself, but I was just reading in the BFAQ (Re: Dialog Speech Color (http://bfaq.xylot.com/#editor08)) and it reads:

QuoteThe dialog options are drawn in the player character's talking color. The highlighted option color uses the GUI foreground color if you are using a GUI TextWindow. Otherwise, it is hardcoded to yellow. Maybe in the future there will be a way to change this, but for now, deal with it!

I was just wondering if this template could be added as a workaround to the highlighted option color (if that sort of thing is even done in the BFAQ).  If it isn't, then you can probably just ignore this post (or "deal with it!").
Title: Re: Custom scrolling dialog options GUI
Post by: GarageGothic on Fri 04/03/2005 14:11:09
Ok, this is the error message I get when using both 640 and 320 versions of the template on the AGS 2.7 RC1. I haven't been able to use it on any versions of 2.7:

An internal error has occured. Please note down the following information.
If the problem persists, contact Chris Jones.
(ACI version 2.70.849)

Error: run_text_script1: error -6 running function 'repeatedly_execute':
Error: Array index out of bounds (index: -30, bounds: 0..8999)
in Global script (line 19)
from Global script (line 258)
from Global script (line 286)
Title: Re: Custom scrolling dialog options GUI
Post by: monkey0506 on Fri 04/03/2005 16:39:03
Thank you for reporting this problem.  I will look into it immediately (actually, I'm at school right now, and then I'll be gone all weekend, so I'll get to it first thing Monday).  It's probably just a problem with the AutoScrollDialog function, so if you temporarily comment out that line:

#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute()
  {
  // put anything you want to happen every game cycle here
  HighlightDialog();
[b]//  AutoScrollDialog();[/b]
  }
#sectionend repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE


HighlightDialog() doesn't reference any array elements, so it's likely a problem with the while loop.  Please note that with this line commented out, you can not turn off options in a scrolling dialog.  It causes errors in the way the dialog options are displayed.  Once again, thank you for reporting this error, and like I said, I'm gone all weekend, but I'll look at it Monday. :)
Title: Re: Scrolling Dialog Template v. 1.2.0
Post by: Dr Lecter on Tue 09/08/2005 21:34:26
Erm... I tried using the script with version 2.7 and this happened:
---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occured in ACWIN.EXE at EIP = 0x0043072C ; program pointer is +379, ACI version 2.70.864, gtags (1,1)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and notify CJ on the Tech forum.



Most versions of Windows allow you to press Ctrl+C now to copy this entire message to the clipboard for easy reporting.
---------------------------
OK   
---------------------------

Something tells me that isn't very good...

I don't know how I plan to do this, but I'm going to try and make a much simpler custom version of is, minimised down so that it only covers what I want it to.
Title: Re: Scrolling Dialog Template v. 1.2.0
Post by: monkey0506 on Tue 09/08/2005 23:15:36
Well the code is optimised for 2.62.  So it may have something to do with that.  Else it may have something to do with the Autoscroll functions I was trying to implement which will be obsolete in the new SM I am coming out with.

OFFICIAL UPDATE FOR NEW USERS (and those who haven't heard about the ScrollingDialog Script Module):

This template was designed within and for AGS Version 2.62.  It is now outdated, although it's replacement is still under construction.  It was never fully implemented, but the missing features are getting worked on in the Script Module that will replace this template.  You are still free to use this as you see fit, but as I now use AGS 2.7, support may (and probably will) be limited!  Thank you,

monkey_05_06
Title: Scrolling Dialog Template -- Replacement Coming Soon!
Post by: monkey0506 on Sat 03/09/2005 04:35:50
Well...it's been a long while since I started this venture, and it would seem that I'm nearly there.  As I have previously mentioned, this template is being replaced by a script module.

The replacement SM is nearing completion, so I figured I would give an official update on the new syntax that will be used.

Previously, this was something of a hassle to work with...to say the least.  I hope to simplify these matters a lot with this module.  For example, previously the user had access to an array, dlgnum[300], which has been changed and removed from the user's general use.

The user will now have access to the struct ScrollingDialog, which contains static functions to set and obtain the values needed by the script.  For example, where the user previously had to type something like string temp; StrFormat(temp, "%s", GetOptionText(3)); to get the text from an option, the user can now do this String Text = ScrollingDialog.GetOptionText(0, 3); (AGS 2.71 beta 3+).

Furthermore, the following will be available with the release of the replacement SM:

ScrollingDialog SM Features (pre-release list)
Ability to run a dialog from any script (following the SM in the SM list).
Ability to scroll dialogs containing more options than can be shown on the GUI at once (as defined by the number of labels on the GUI).
User definition of default, highlighted, and used dialog option colors.
Ability to run interaction for a dialog option from any script (following the SM in the SM list).
Multi-line dialog text support (dialog options can span up to two lines per option).
Support of up to 200 characters per option (as opposed to the 150 character built-in limit).
Support of 500 dialog topics each containing 30 options (based on built-in limits.  the user can increase/decrease these limits).

So...it's come a good ways.  Well...I increased some of the limits, added multi-line support, and added user color-definition support.  I'm still working out some bugs, but keep an eye out for this...it should be finished soon.

[EDIT:]

I've now implemented dynamic string reconstruction.  Basically, all this means is that the text will appear correctly on your GUI if the dialog is scrollable or not.  The reason it is important is this.  Suppose you have a long string of text:

"Hello, my name is Toboggan Shoeslider.  I'm new to this town."

It's possible that this text would span more than one line, perhaps displaying:

"Hello, my name is Toboggan Shoeslider.  I'm new"

on the first line, and:

" to this town."

On the second.  Now suppose that you later turn on a dialog option, which makes the dialog topic in question scrollable.  Since the GUI is moved and resized to make room for the new text, less of the first line would fit on the new first line.  But, because of the dynamic text reconstruction, the user doesn't have to worry about this at all.  It is all taken care of.

[EDIT:]

ScrollingDialog v. 0.5 BETA Script Module posted as Monday 5 September 2005 3:46 P.M. Central time.
Title: Re: Scrolling Dialog Template -- DEPRECATED (Use ScrollingDialog SM)
Post by: monkey0506 on Fri 30/09/2005 15:39:44
Final bump.

Version 0.60 of the ScrollingDialog Script Module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=22526) has now been released.  Although it requires v. 2.71 RC1 or later (which ATM is not the official version), this template is officially deprecated.  If anyone really wants to use it, be warned that support will be very limited.  Perhaps you can contact Geoffkan because he has created a new system based on this one which is AGS 2.7 compliant.  In any case, this thread, which has been dead for some time, is officially ended.