MODULE: ScrollingDialog v3.0 - Updated 27 January 2016

Started by monkey0506, Mon 31/07/2006 06:33:57

Previous topic - Next topic

monkey0506

Don't call it a rewrite! :-D

For the first time in years, the ScrollingDialog module is back! And what's more, it actually works this time!!! := This is a major overhaul, written entirely from scratch and is in no way comparable or compatible with the older versions of the module.

You will need AGS 3.4.0.6 or higher to use this module. You will also need the MathsPlus module, which is included in the download.

DOWNLOAD

Why do you need another dialog module? Well, because this one's pretty cool, and if you want to be a cool guy, you'll use it. Just look at this actual, functioning code sample:

Code: ags
function game_start()
{
  ScrollingDialog.Width = 320;
  ScrollingDialog.Height = 75;
  ScrollingDialog.Padding.Top = 5;
  ScrollingDialog.Padding.Left = 5;
  ScrollingDialog.Padding.Bottom = 5;
  ScrollingDialog.Padding.Right = 5;
  ScrollingDialog.X = 0;
  ScrollingDialog.Y = 125;
  ScrollingDialog.TextColorNormal = player.SpeechColor;
  ScrollingDialog.TextColorActive = 14;
  ScrollingDialog.TextColorChosen = player.SpeechColor;
  ScrollingDialog.LineSpacing = 3;
  ScrollingDialog.Bullet.ActiveGraphic = 6;
  ScrollingDialog.Bullet.Padding.Top = 2;
  ScrollingDialog.Bullet.Padding.Right = 3;
  ScrollingDialog.Bullet.Float = eFloatLeft;
  ScrollingDialog.ScrollArrows.Float = eFloatLeft;
  ScrollingDialog.ScrollArrows.Up.NormalGraphic = 10;
  ScrollingDialog.ScrollArrows.Up.MouseOverGraphic = 9;
  ScrollingDialog.ScrollArrows.Up.PushedGraphic = 13;
  ScrollingDialog.ScrollArrows.Up.Padding.Top = 4;
  ScrollingDialog.ScrollArrows.Up.Padding.Bottom = 2;
  ScrollingDialog.ScrollArrows.Up.Padding.Right = 5;
  ScrollingDialog.ScrollArrows.Down.NormalGraphic = 8;
  ScrollingDialog.ScrollArrows.Down.MouseOverGraphic = 7;
  ScrollingDialog.ScrollArrows.Down.PushedGraphic = 12;
  ScrollingDialog.ScrollArrows.Down.Padding.Top = 2;
  ScrollingDialog.ScrollArrows.Down.Padding.Right = 5;
  ScrollingDialog.NumberStyle = eDialogOptionNumbersDrawn;
  ScrollingDialog.TextAlignment = eAlignRight;
  ScrollingDialog.AutosizeHeight = true;
  ScrollingDialog.AnchorPoint = eAnchorBottomLeft;
  ScrollingDialog.Background.Color = 1632;
  ScrollingDialog.Background.Transparency = 75;
  ScrollingDialog.Background.Graphic = 11;
  ScrollingDialog.Background.AnchorPoint = eAnchorCenter;
  ScrollingDialog.MinWidth = 107;
  ScrollingDialog.SetTag("%LOCATION%", "SPARTA");
  ScrollingDialog.Background.BorderDecoration.Top = 6;
  ScrollingDialog.Background.BorderDecoration.Bottom = 6;
  ScrollingDialog.Background.BorderDecoration.TopLeftCorner = 6;
  ScrollingDialog.Background.BorderDecoration.TopRightCorner = 6;
  ScrollingDialog.Background.BorderDecoration.BottomLeftCorner = 6;
  ScrollingDialog.Background.BorderDecoration.BottomRightCorner = 6;
  ScrollingDialog.Background.BorderDecoration.Left = 6;
  ScrollingDialog.Background.BorderDecoration.Right = 6;
  ScrollingDialog.Font = eFontBlackAdder;
}


There isn't a demo game for this (yet), but one may be made (I'm going to ask Secret Fawful to make graphics for it, so if it never happens, blame him).

For the most part, the properties should all speak for themselves as to what they do, and there's some limited documentation in the module. One really cool feature that the module includes is dialog option tagging. What that means is that you can create a custom tag that you will later replace with some other text, such as a character's name. You tell the module what you want to replace the tag with (using ScrollingDialog.SetTag), and then when the dialog options are drawn, the module will handle it for you!

Code: ags
  cPet.Name = "Spike";
  ScrollingDialog.SetTag("%PETNAME%", cPet.Name);


Then if you have a dialog option set to "My dog's name is %PETNAME%." (for example), then the text would be displayed as "My dog's name is Spike.".

There is also a built-in tag for the player name (ScrollingDialog.PlayerNameTag), which is always replaced with the current player name. This will save you from having to change the tag if you change the player, as it will always stay up-to-date with the current player character.

NOTE: If you are using a tagged dialog option, you should always leave the Say check-box unchecked. The module can't overwrite the actual dialog option text, so if the player reads that option, they would end up saying the original text, as set up in the editor. If you want the player to read that option, then instead include a line such as this in your dialog script:

Code: ags
// dialog script
@S
return;
@1 // My dog's name is %PETNAME%.
  player.Say(ScrollingDialog.SelectedOption.Text); // say "My dog's name is Spike."
return;


This will ensure that the dialog tags are replaced appropriately.

Shade

wow! :o great job monkey_05_06 and thanks for sharing! first of all the mosule is easy to use and i like the way how you can customise almost everything!

monkey0506

I'm glad that you like it then.

Right now I'm just trying to decide if I should use an array or a vector for storing the dialog tree...it would actually be easier on my part to use a vector, but it would mean you would have to include another module, so I'm still undecided.

GarageGothic

But monkey, you also made the vector module, right? So can't you just copy the code from that into the dialogue module and add a note in the readme to make sure that people don't use both?

SSH

You could detect, using #ifdef, if the user has already got the vector module included, and if they have: use it, if not use an array...
12

monkey0506

I could do that. But then I'd have to program it both ways...that's no fun. :D

I'll work on this today...see if I can't come up with something.

[EDIT:]

I didn't feel like using an array because it really would have been much more complicated for me to have to deal with...so I just wrote a customized version of the int vector class into the module! :D

It works better that way. And so the new version's up now. For those that won't read the edit in the first post, you can now have multiple dialog topics run at the same time (nested dialogs for complex dialog trees). You just use ScrollingDialog.Run as you normally would. To go back one step you call ScrollingDialog.Return. If you call ScrollingDialog.Return when only one topic is running it calls ScrollingDialog.End.

It's worthy noting though that you can't call ScrollingDialog.Run from the ScrollingDialog_Setup module. So for nested dialogs you will have to put interactions in the ScrollingDialog module itself.

Code: ags
// example of how to put interactions in the ScrollingDialog module
static void ScrollingDialog::RunInteraction(int topic, int option) {
  if ((topic < 0) || (topic >= eScrollingDialog_MaxTopics))
    AbortGame("Invalid parameter 'topic' to function 'ScrollingDialog::RunInteraction'. Range 0..%d, value %d.", eScrollingDialog_MaxTopics - 1, topic);
  if ((option < 0) || (option == eScrollingDialog_MaxOptions))
    AbortGame("Invalid parameter 'option' to function 'ScrollingDialog::RunInteraction'. Range 0..%d, value %d.", eScrollingDialog_MaxOptions - 1, option);
  if (ScrollingDialog_Topics[topic].Say[option]) player.Say(ScrollingDialog.GetText(topic, option));
  ScrollingDialog_Setup.RunInteraction(topic, option);
  if (topic == 0) {
    if (option == 0) ScrollingDialog.Run(15);
    else if (option == 1) {
      cMan.Say("That's hard to believe.");
      player.Say("I saw it with me own two eyes.");
      }
    }
  /* ... */
  else if (topic == 15) {
    if (option == 0) ScrollingDialog.Return();
    }
  }


Of course if you don't call any of the ScrollingDialog functions from your interaction script you can put it in the ScrollingDialog_Setup module. You can even have interactions defined in both places, however anything in the ScrollingDialog module before the line "ScrollingDialog_Setup.RunInteraction(topic, option);" will be run before the interactions defined in ScrollingDialog_Setup, and anything after it will be run after those interactions.

Rui 'Trovatore' Pires

Small suggestion - how hard would it be to allow your dialogs to recognize numbers for topics (pressing 1 equal clicking on first dialogue, and so on)? It would be a very handy feature.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

monkey0506

#7
Question: Is that implemented into AGS's system?

Because it would be fairly easy to implement (either for the module or individually):

Code: ags
function on_key_press(int keycode) {
  if ((keycode >= '0') && (keycode <= '9') && (ScrollingDialog.GetRunning() != -1)) {
    if ((keycode == '0') && (9 < eScrollingDialog_LabelCount)) keycode = 40;
    if ((keycode == '0') || (keycode - 31) >= eScrollingDialog_LabelCount) || (ScrollingDialog.GetOptionOnLabel(keycode - 31) == -1)) return;
    ScrollingDialog.RunInteraction(ScrollingDialog.GetRunning(), ScrollingDialog.GetOptionOnLabel(keycode - 31));
    }
  }


Okay, there's a few more checks than I initially anticipated...but...that would allow you to press 1 - 0 to run options 0 - [9/eScrollingDialog_LabelCount - 1] (because the options are indexed from 0 to eScrollingDialog_MaxOptions).

I may decide to implement it if it's implemented in the built-in system, but for right now...I'm off to find something to entertain myself...lol...(I'm very bored and the A/C is broken...)

Rui 'Trovatore' Pires

Oh ayuh, very possible to do. I've just played 3 or 4 AGS games recently in which it was not only possible - it was a very welcome shortcut. Very, very welcome.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Pendorcho

#9
When i try to import the module i get an error.

Something like "You need a newer version of AGS..."

monkey0506

What version of AGS are you using? It was built with the latest version, AGS v2.72. So make sure you're using the latest version of AGS. If it still doesn't work, you can try redownloading the file.

Pendorcho

I'm using the latest version.

=S

Until yesterday, the link was broken, so i downloaded a mirror from http://www.americangirlscouts.org/agsresources/.

I'll try the one you've just uploaded (http://monkey0506.madpage.com/ScrollingDialog_1_21.rar) and see what happens.

Edit:

It works perfectly.

Thank you very much.

monkey0506

I'm glad to hear you've gotten it working. However I see that you posted twice, and within only a few minutes of each other. You're really supposed to use the "Modify" button to edit your posts if no one else has posted since your last post, or unless it's been several days. (I'm not a mod, just trying to watch out for my consumers ;D)

monkey0506

Quote from: The friendly forum reminderWarning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

*bump*

Yes forum, I'm sure I want to post. This may just be a beta version, but it's at least mostly stable. :) Right now I'm looking into the unstable bits...more later.

Mazoliin

Hi! I'm makeing a game whit a FOA look-a-like dialog gui.
I've tried to use monkey_05_06's ScrollingDialog module to change the color and font, but when I then try to test my game, I get this error saying the gui isn't initialized.

What does that mean?!

I've looked for an answer everywhere I can think of.
Maybe someone else had a similar problem?
I don't know too much about code.
Many excuses for my bad english.

Mazoliin

Exact error:

QuoteA fatal error has been generated by the script using the AbortGame function. Please contact the game author for support.

in ScrollingDialog (line293)
from ScrollingDialog_Setup (line36)

Error: ScrollingDialog error: Dialog GUI not initialized. Check manual for mor info.

Haven't been able to find anything in the manual.

monkey0506

You may have read this in the manual:

Quotebool ScrollingDialog_Setup.SetDialogGUI(GUI* dialogGUI, optional int seed_control,
optional int x_offset)

  Sets the GUI to use for displaying the dialog options. Requires
  eScrollingDialog_LabelCount labels starting from SEED_CONTROL (default 0).
  X_OFFSET sets the offset for this GUI if the arrows GUI is activated (similar to the
  way the GUI is moved in The Secret of Monkey Island(TM)).

As denoted by the manual entry the dialog GUI requires eScrollingDialog_LabelCount GUI label controls. The default value for eScrollingDialog_LabelCount is 7. If you need to change this, you will need to look in the ScrollingDialog module header where you will see this:

Code: ags
enum ScrollingDialog_Variables {
  eScrollingDialog_LabelCount = 7,
  eScrollingDialog_MaxTopics = 500
  };


You can change 7 to whatever value you need (however many rows of options you need to show on the dialog GUI at once) however you must have as many labels on the dialog GUI as this value defines or your game will crash.

It's been a while since I worked on this module, however I may find time to take back up my work on it again shortly.

If this doesn't solve your problem, feel free to describe exactly what you've done, as well as any errors you receive (Ctrl+C to copy the errors, Ctrl+V to paste them in your messages).

Mazoliin

#17
Fixed it. Must read the manual more carefully. But when I'm going to talk, this happend:
Quote
---------------------------
Adventure Game Studio
---------------------------
An internal error has occured. Please note down the following information.
If the problem persists, contact Chris Jones.
(ACI version 2.72.920)

Error: run_text_script1: error -6 running function 'character1_a':
Error: call stack overflow, recursive call problem?
in ScrollingDialog (line 102)
from ScrollingDialog (line 107)
from ScrollingDialog (line 114)
from ScrollingDialog (line 459)
from ScrollingDialog (line 514)
from ScrollingDialog (line 554)
(and more...)


---------------------------
OK   
---------------------------

Can't wait until I can get the demo and see what I'm doing wrong! >:(
This is just silly! I'm really need a tutorial for this or something...

monkey0506

Can you post the exact code you used? Because unless you've modified the script for the ScrollingDialog module...there's no way that error message is correct. The line numbers it's giving don't match up at all.

If all else fails would it be too much to ask for you to zip/rar up your game files and PM them to me?

Mazoliin

On "Talk to character" I have...
Code: ags
gGui2.Visible = false;
ScrollingDialog.Start("new topic");


And this is how it look in the ScrollingDialog Script.
Code: ags

static void ScrollingDialog_SetupType::InitializeText() {
  // set up your dialog text here!
  ScrollingDialog.SetOption("new topic", 0, "this is some text");
  ScrollingDialog.SetOption("new topic", 1, "More text");
  }

void ScrollingDialogType::RunInteraction(String topic, int option) {
  if (this.GetSay(topic, option)) player.Say(this.GetText(topic, option));
  // set up your dialog interactions here!
  if (topic == "new topic") {
    if (option == 0){
      cGoog.Say("Eat fish!");
      cEgo.Say("Oh...");
    }
    if (option == 1){
      cGoog.Say("Fish, FISH!");
    }
    }
  }


I hope the demo will be available soon. I really think it would help me a lot.

SMF spam blocked by CleanTalk