ScrollingDialog script module BETA thread

Started by monkey0506, Mon 05/09/2005 21:44:10

Previous topic - Next topic

monkey0506

Welcome to the ScrollingDialog script module. With this module you can create a scrollable dialog system, something not currently available with AGS's built-in dialog system. This module was started as a template and over the course of the last year has been developed into the module which you can now download here.



Version 1.0 released! Go to its separate thread.



There is also now a demo which you can download which isn't much in the way of a great demo, but it displays a dialog which you can scroll through. Also if you look through the script you can understand how to properly set up your dialogs (as they must be set up in the ScrollingDialog_Setup module through the script, not AGS's dialog topic editor).

Download here
Download the demo
Read the ScrollingDialog Manual

Currently with the module you cannot have dialog options which span more than one line. You can store as much text into each option as you want, however when it is displayed on the GUI you will only see as much as will fit across your Dialog GUI (with an ellipses appended to the end). When you run the interaction for the option or retrieve the text with ScrollingDialog.GetText the full String will be returned.

Currently you can only run one dialog at a time (this means no nested dialog trees). I am working on this and will update the post when I get it worked out.

Implemented as of version 1.2

Requires AGS 2.72 or higher! (Why? Because that's the version I'm using and I don't want to here any complaining if it doesn't work with lower versions. You can try it if you want, and let me know if it works, but I'm off to bed.)

[EDIT:]

31 July 2006 1:48 P.M. - Uploaded v1.1 which adds support for used option colors, setting whether the dialog options go upward on the GUI, and whether the dialog options are numbered. Also included documentation and licensing information, and uploaded a simple demo.

1 August 2006 3:37 P.M. - Uploaded v1.2 which adds support for nested dialogs. You can build up a dialog tree by calling ScrollingDialog.Run several times, however if the topic is already stored in the tree you cannot run it again (i.e., if you run topic 0, then topic 1, then topic 5, you can't run topic 0 after topic 5, you would have to call ScrollingDialog.Return() to work your way backward through the tree). As denoted in the previous example, to return to a previous dialog topic you call ScrollingDialog.Return. If the tree is empty (there is only one topic running) this function will call ScrollingDialog.End. The demo hasn't been updated to reflect the changes, but I might make a small sample game that does more than just shows one dialog scrolling.

1 August 2006 11:59 P.M. - Pushing this in at the last minute...literally...I've uploaded a new version of the demo (same link). It works more like a game, there's actually two characters, and I set it up with the same dialog as the tutorial covers (with the "merchant" selling fine leather jackets :=). I did some of the sprite work myself so some of it's crap although if I had looked I probably could have found the sprites I needed...Anyway, the new demo also includes (imported, not exported) a slightly modified version of the module which doesn't stop you from adding the same dialog to the tree multiple times (i.e., if you run dialog 4, then 5, then 4 (running 4 then 4 would just update 4 (which most of the time should mean absolutely nothing to the user :D))). The modified version also has been fixed to turn the dialog GUIs off while the characters are speaking...I should probably export it as a new version...but I've been updating this a lot lately...it can wait a while. It's worth mentioning again that although the majority of the interaction scripts for the dialog are in ScrollingDialog_Setup, there are some commands in the ScrollingDialog module (which is necessary to link dialog topics together). The dialog is initiated when you talk to the merchant. The new demo doesn't actually demonstrate scrolling...you can add more options to the existing dialogs if you'd like...

15 August 2006 - I'm changing my host, so you may need to right-click and choose "Save as..." (in my experience trying to link directly to the files opens it as if it were a text file). If that doesn't work, feel free to PM me and let me know. I'll try and have this issue resolved as quickly as possible. Thanks. Also, I've finally gotten around to changing the link to 1.21 which basically just allows you to add whatever dialogs you want in whatever order you want instead of preventing you from running a dialog already stored in the tree.

Rui 'Trovatore' Pires

\o/

I'll keep an eye on the thread, but could you please PM me when it leaves beta stage, so I can up it to my sitey? And will this replace the template, i.e., can I safely stop hosting the template?
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

monkey0506

#2
This is built to replace the template (because the template was never fully completed and was built with an old version of AGS) so you can remove the template if you would like.

And you always have permission to share my work with others*. :=


Oh...and BTW, I'm working on v. 0.51 which will include proper licensing and stuff...then v. 0.52 should contain documentation - yay!


*Unless of course it is in some feeble attempt to defame me.  You try to defame me...and...I'll...do something about it. :P

[EDIT:]

I never edited this post to say that version 0.51 is up.  I haven't been able to work on this (physically) for the past 3 days, but I've had a lot of time to work some things out in my head...and I think I have good news.  I'm almost certain that I know how to fix the highlight bug, and I have some ideas to fix the scrolling (multi-line text) and used option bugs.  I'll be able to work on this later...erm...today (it's currently 1 a.m. here, so after school I should be able to work on it (around 4 p.m. is when I get home)).  But first, I must get some sleep...actually I've been asleep for just about 8 hours already...  I can't sleep...which is why I'm on here...I'll be back later today (hopefully) with a version 0.52 which probably won't contain the documentation, but rather some bug fixes...

[EDIT:]

Oh...I did edit the first post to say that v. 0.51 is up... :=

Pumaman


monkey0506

#4
Thanks Chris...

I've been looking at it, and I don't know why scrolling is bugged (where multiline options are present as well as restoring the Used option color).  I have narrowed it down to the fact that the used option's color is restored when I call ScrollingDialog.Run from within ScrollingDialog.ScrollUp/Down (to display the change)...even though I don't change it from that function...  In fact it's something actually accessing a struct local to the module script.  The value is a boolean value that is being stored as false whenever the Run function is called, but like I said, I don't change it...I'll look into it more (checking the called functions and whatnot) but I didn't see anything last night.

And when scrolling dialogs with multiline options, it appears to be a bug with one or more of the dialog options having it's text value stored as null (it's a String)...  So I'll let you guys know if I get it figured out...but first...I have to go finish the dishes*. ::)

*I swear my sisters and their friend that spent the night used every cup in our house...and about 75% of all the other dishes. :-\ :-X :=


[EDIT:]  I forgot to mention...I should be able to upload a version 0.52 BETA tonight just to get the highlight bug worked out, and I'll include a simple readme.

[EDIT:]  I'll also put a version of the readme online and link to it from the first post to shorten it up a bit...I can't possibly be the only one annoyed by it's length. :=

[EDIT:]  The used option color restoration when scrolling a dialog has been resolved.  I use the SetDialogText function to initialize most of the variables, so I had been setting the boolean value to false (because the option is initially not used), but I use the SetDialogText function to resize the text on the GUI for scrolling dialogs.

Yay for 2/3 of the bugs being fixed (even if they were silly things like old code being (mis-)used and initializing values improperly and hence completely my fault :D)!

monkey0506

I'm tired of edits.

I was hoping that someone would have tested this by now.  I mean, I would hope that Chris had tested it before telling me that it was good work, but I'd still like some verification that my script is working...

Now I'm thinking crazy thoughts.

Also, kinda off topic, I've been wondering why this hasn't been moved to the tech archive.  It seems that's where they put these things.  I'm sure there's probably a good reason.  Just curious what it might be.

strazer

Quote from: monkey_05_06 on Mon 12/09/2005 00:31:41Also, kinda off topic, I've been wondering why this hasn't been moved to the tech archive.  It seems that's where they put these things.  I'm sure there's probably a good reason.  Just curious what it might be.

Don't worry, I'm watching this thread (bookmarked it, actually).

Thing is, you have been updating it so often it made me think maybe it's not quite ready for general consumption?
I'm waiting for responses from actual users as well...

monkey0506

Okay.  That's good enough for me. :=

I think I'm just about finished with the near constant updating.  Now that I've got it down to one bug (that I'm not entirely sure how to fix) and I want to get it out of the way before I add anything.

And as for the user responses...I suppose "if you build it, they will come." But I don't know when... ::)

Rui 'Trovatore' Pires

Do it like Strazer it. His script modules were made "publicly available". It went untested for quite a while, but recently one of his scripts underwent about 3 bug-fixes.

Finish the documentation, kill the bug, release it, hope for the best. Sooner or later you'll have your testers. :)
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

monkey0506

Well I have school, so this isn't exactly at the top of my priority list...but I'm still looking to fix that bug.  I mean, since this says you can scroll your dialogs it would be nice if you could scroll dialogs that had options spanning two lines without it crashing the game...

As for the documentation, I may make some better documentation, but it may take me a while.

And the module is "publicly available".  I'm just calling it a BETA version because there is a rather large bug in the system that I know about, but I'm not really sure how to fix.

I just wish someone would say, "Hey I tested it and it works except for that one bug." or something... :-\

Rui 'Trovatore' Pires

Well, then I'll up it to my sitey. :)
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Scorpiorus

#11
Nice work with the module! :)

Module dependency mechanism implemented through #defines and #errors works well as I can see.

By the way, I noticed you do a "ScrollingDialog.Run(1);" call from within the module's game_start function. I'd suggest moving it to the main global script game_start one. This way game script that uses the module would be isolated fromÃ,  the module itself and thus you could release new versions of it without having the game developer to copy scripts from old version of your module to a newer one.

Ultimately, it would be excellent to have those...
Code: ags

Ã,  SetDialogText(0, 0, "My name's Guybrush Threepwood!Ã,  Prepare to die!");
Ã,  SetDialogText(0, 1, "So...How did you get up there?");
Ã,  SetDialogText(0, 2, "I'll just be running along now.");


...lines in a separate script module (just like StrAdditions) for the very same reason -- you release a new version but these lines stay intact.
I appreciate though it can bring some complexities to how modules should then be arranged in the list. Just a thought.

monkey0506

So I take it you've tested it! :=

I understand the concern with all the demo-specific code, and I've thought about that...but I'm pretty sure that the user should be able to figure it out if they actually want to before I can get around to fixing it.

The easiest way would probably just to be copying the code to notepad, removing the demo-specific code, re-exporting the module, then replacing the demo's code with what it already was.  That way the demo has the code in place, while the actual module doesn't.

I'll get around to it eventually :D.

However, eventually I'll actually set up a much better game.  With more than one character XD...seeing as talking to yourself is a sign of insanity ;D.  So that's a pretty vague statement when I say "eventually". :=

I'm too happy tonight.  I don't really know why.  I just am.

Also, as for the demo-specificity of the code at the moment, there are some things that would be a bit more difficult to arrange properly.  For example, in the demo, the DLGARROWS GUI covers part of the original space allotted for the DIALOG GUI, so all of the text shown on the GUI has to be reprocessed for length, and then the whole GUI resized and moved.  If the user allotted a separate space, then it would be pointless to do this.  I'll have to probably implement a flag as to whether or not the DIALOG GUI is moved...

And just to keep on babbling, I'm currently revising the StrAdditions module to try and make it more consistent (making the Str* functions work with old-style strings, and adding a StrAdditions struct containing static functions to work with the new String type (although you will have to specify the String to use instead of calling the function on it (obviously))).

So a new version of the module might be released within the next few days...maybe.  Just because of the above mentioned reasons.  Oh, and I should also have a flag as to whether or not the user wants the arrows to disappear when you can't scroll in that direction.

Blast!  There is so much more to be done!  So much customization to make way for!  And there's still a bug to fix o_0!  One day I may torture you all with the tale of the function I once created that went something like:

function SetupDialog(string text0, string text1, string text2, string text3, string text4, string text5, string text6)

But that's for a later date.  I'm off (to post a mile long speech elsewhere)! :P

[EDIT:]  Oh, I forgot...  Thanks for your comments Scorporious.

monkey0506

Okay, so I've been doing some debugging...and I've found some very interesting results.  Okay, dialog three is set up as:

Code: ags
  SetDialogText(3, 0, "Here we go again with another really long string of text to span two lines.");
  SetDialogText(3, 1, "But this one will be short.");
  SetDialogText(3, 2, "And this one will be longer than the second, but not as long as the first.");
  SetDialogText(3, 3, "Since this one has the most options I will add to it.");
  SetDialogText(3, 4, "This should be the last shown so I will make it long just to do some more testing.");
  SetDialogText(3, 5, "And one more should make it scrollable.");


Okay, so what is actually shown on the GUI at runtime is:
Here we go again with another really long string of text
to span two lines.
But this one will be short.
And this one will be longer than the second, but not as
long as the first.
Since this one has the most options I will add to it.
This should be the last shown so I will make it long just to
Along with the arrow (down) for scrolling.

So I click the down arrow, and then this is displayed:
to span two lines.

And this one will be longer than the second, but not as
long as the first.
Since this one has the most options I will add to it.
This should be the last shown so I will make it long just to
do some more testing.
As you can see, an option has disappeared.  What you can't see here is that the down arrow is still on, but the up arrow isn't (don't ask me why...).  So I click on the missing text, and when it tries to run the interaction (more specifically when it tries to display the text), I get an error saying:

Quote---------------------------
Adventure Game Studio
---------------------------
An error has occured. Please contact the game author for support, as this
is likely to be a scripting error and not a bug in AGS.
(ACI version 2.71.880)

in ScrollingDialog (line 361)
from ScrollingDialog (line 389)
from ScrollingDialog (line 494)

Error: Cannot display message with extended characters in SCI font

(Accented characters, for example the special French and German e/a/u/i letters cannot be used by default. You need to import a TTF font to do so).

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

Okay, so I set up a little debug here...I display the text one character at a time (integer value (if it's within the displayable range, the character as well)).  And here's the interesting part.
-84 at 0
-122 at 1
O (79) at 2
So I have two negative characters, and the letter O.  While working with AGS, I know that if a char is set to a value less than 0, it is looped back around, i.e. -1 = 255.  So by this, I came to the conclusion that -84 = 172 and -122 = 134.  But then these aren't in the displayable range... :-\

The call stack, in order should run as follows when the down arrow is clicked:
ScrollingDialog.ScrollDown
|-> ScrollingDialog.Run
|---> SetDialogText /* to resize the text to fit on the gui */
|-----> StringAdditions.CutByWidth /* new function */
|-------> StrCutByWidth
So hopefully I'll be able to find the guilty culprit amongst this mess.  But first, my dad wants me to format the hard drive because he likes to screw up computers, and can't comprehend the fact that no matter how many times he makes me format it, he still won't know what he's doing. :=

So it will be a few days (at least) before I can get any work done on this. :-\

Later,
monkey_05_06

monkey0506

Okay the problem seems to be coming from running a dialog more than once per game (and ScrollingDialog.Run is called when scrolling).  So...I'm working on it.  But then there's that hurricane coming.  I hope I don't lose power.

monkey0506

#15
Let's bump this thread again. ;D

Version 0.60 is now up, and, what's that?Ã,  It's not a BETA version.Ã,  That's because, as far as I can tell, unless you pass an invalid parameter to one of these functions, it won't crash your game any more.Ã,  You still can't scroll topics with multi-line text properly (it will only scroll down once), but there are a couple that don't have any multi-line text which scroll fine.

I also split the module and demo game apart, and updated the readme file.Ã,  So will somebody* PLEASE test this?


* I realize that Scorporious has tested it, and like I said, I hope Chris tested it before congratulating me on it.Ã,  Perhaps I'll PM those who previously tested the template and ask them personally to test it for me.Ã,  I just want a few people to verify that it is indeed working.Ã,  Well, perhaps a few more, rather.

[EDIT: (1 October 2005)]

I noticed today that all of the error messages are screwed up.  When I was copying/pasting them yesterday, I ended up testing the topic parameter against _MaxTopics and _MaxOptions.  The error messages that say "Invalid parameter 'option'..." should be beneath the check "if ((option < 0) || (option >= eScrollingDialog_MaxOptions))", not "if ((topic < 0) || (topic >= eScrollingDialog_MaxTopics))" as it reads.  I'll fix it, possibly Monday, but I don't have internet at my house, and I'm on my cousin's laptop right now (at his brother's apartment for a little while), so...

Also, I've been working on trying to implement the options to allow numbering of dialog options and making the options go upwards on the gui...it's not exactly coming along quite right at the moment...I'll see if I can get it fixed Monday, but if I can't I'll remove it and upload the version with the error message fix.

monkey0506

Quote from: Scorpiorus on Tue 13/09/2005 00:51:43Ultimately, it would be excellent to have those...
Code: ags

  SetDialogText(0, 0, "My name's Guybrush Threepwood!  Prepare to die!");
  SetDialogText(0, 1, "So...How did you get up there?");
  SetDialogText(0, 2, "I'll just be running along now.");


...lines in a separate script module (just like StrAdditions) for the very same reason -- you release a new version but these lines stay intact.

The main concern I had in doing this was that the user would have the ability to dynamically change the dialog text, which could screw things up pretty bad if they don't do it properly.  However, I found that by using the clever comment:

Code: ags
// $AUTOCOMPLETEIGNORE$


After the new global struct definitions, they won't autocomplete, so unless the user really digs around and knows what they are doing, they won't have access to it.  I'm still working on updating the documentation, but the new version of the module*, version 0.61, will implement the following:

- Ability to number dialog options.
- Ability to make dialog options go
  bottom-to-top instead of top-to-bottom.
- Ability to define dialog text separately
  to make updating the module easier.
- Ability to define whether or not the
  DIALOG GUI is moved/resized for
  scrolling.
- Ability to define whether or not the
  dialog arrows should be turned off
  if scrolling is not available in their
  respective directions.
- Fix of improper parameter check
  (broken by 0.60)


So, there is still the bug with scrolling topics with multi-line options...but I'm still not sure why that's messed up.  So, once I get the documentation completed I can upload this, but school started back yesterday**, so I may have to wait until the weekend to get it uploaded.

*This will now be released as the following three modules:

- StrAdditions
- ScrollingDialog_Setup
- ScrollingDialog

StrAdditions will be the same v. 2.0 as the last release.

ScrollingDialog_Setup is now where the user sets up all of their specific information (the ScrollingDialog_Variables enumerated values (in the header), and the dialog text and interactions (in the script)).

ScrollingDialog will now be where all the calculations and label text editing and things are done; as it was before, but now without the user specific information spread throughout it.

**They say we should have power back today (5 October) or tomorrow, which will be nice, but it sucks that I have to go back to school.

monkey0506

#17
After...well...a few months...:-\...I've finally managed to get around to uploading a new version that won't crash the game.  I should be able to implement most of the features that were lost from 0.61 (just hopefully not the crashing feature) within the next few days.  Until then this is a pretty pointless module, but I just wanted to get rid of that nasty bug.

[EDIT:]

I just noticed that before I thought that dynamic changing of the dialog text would be a bad thing...Fortunately though I got it worked out.

[EDIT (21 January 2006):]

For anyone who's reading this, the system has been broken for some time.  I've been trying to get it fixed, but time after time I've been focusing on all the wrong things.  I'm currently working on the next official (non-BETA) version, and it seems promising.  I've been taking my time, programming it slowly, one bit at a time and testing each step along the way.  The next version will allow for a virtually infinite number of lines per option, though the user must define a limit (default is 3).  Also the user will be able to have the scrolling arrows on the same GUI as the options will be displayed on.  As in v. 0.80 BETA, you will be able to dynamically alter the text.  So, good things to come.  I should hopefully have this finished in under a month (I know that's a long time, but I'm in high school, I have other priorities).

Rui 'Trovatore' Pires

Bump for encouragement after reading recent edit:

That's great news! Keep up the good work, monkey_05_06 - I've had a go at your module some time ago, and I was very, very impressed. The degree of customization, and the overal feel of the thing, is nothing short of amazing. Thank you very much for giving us your module!
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

monkey0506

#19
It's interesting that allowing a virtually infinite number of lines is easier than only allowing two...but...it's just the way that I've gone about it.  Taking a different approach has allowed me to work things much differently (for the better).  I won't promise when the next version can be expected, but hopefully soon.

[EDIT:]

The only difficult thing I've seemed to encounter is making sure that the state of each individual line of options is valid in a system where lines are numbered.  Because if you put the number at the front of the text, it could push the text into a new line.  But when initializing the states,

I think I might have just fixed that (mentally).  I haven't had a chance to get on the main computer (the one that I have my files stored on) today, so I can't check it right now.  Although I'm pretty sure all my problems (in regards to this anyway) have just flown out the window.  Now it's just a matter of actual time on the computer for programming it.  And testing.  Lots and lots of testing.  I'm tired of releasing half-broken modules.

[EDIT:]

Also, the StrAdditions module won't be necessary any more.  A long time ago you used to need several functions that would be implemented, but it's all come down to one function in the end...kind of pointless to need a new module just for that.

Furthermore, regarding the number of lines you can have, since Strings have no limit to size, you can store as much information as you want in any option, but only the first eScrollingDialog_MaxLinesPerOption (new enumerated value to define maximum number of lines allowed per option (defaults to 3)) lines will be displayed at run-time of the dialog (the actual text won't be truncated).

Rui 'Trovatore' Pires

Quotesince Strings have no limit to size, you can store as much information as you want in any option

RIght-o. Though we still have the 300-char-per-line limit in the script editor. Just pointing it out for completion's sake.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

monkey0506

#21
Are you serious?  I never knew that...but you can spread strings across several lines if you know what you're doing. :D

Edit:

Quote from: Removed from the first postWell...that was crazy. No...in retrospect it was just stupid.

I've released several half-baked versions of this module that don't really do anything. And I feel like an idiot for doing it too. It makes me look like a very mediocre programmer.

This is now up to version 1.0 as of 31 July 12:14 A.M. And it actually works now. However, there have been some major revisions and simplifications, so I'll cover here what the module does and doesn't (since there's not any documentation in the package right now and I'm about to go to sleep).

There are actually two modules: the ScrollingDialog_Setup module, and the ScrollingDialog module. This was suggested by someone somewhere along the way to separate where the user actually sets up the dialog text and interaction events from the module scripts, however I've noticed a problem with it.

Because ScrollingDialog_Setup (where the user defines dialog text and interactions) has to come before ScrollingDialog (which currently isn't enforced by any type of macros or anything and will just generate compiler errors) you can't call any of the functions defined in ScrollingDialog. I am now considering putting it back so that the user can call these functions. Actually, all that would need to be moved was the setting up of the interactions.

Anyway, the user has access to the following functions:

Code: ags
static ScrollingDialog_OptionState ScrollingDialog.GetState(int topic, int option);
static bool ScrollingDialog.SetState(int topic, int option, ScrollingDialog_OptionState state);
static String ScrollingDialog.GetText(int topic, int option);
static void ScrollingDialog.Run(int topic);
static void ScrollingDialog.End();
static void ScrollingDialog.RunInteraction(int topic, int option);
static int ScrollingDialog.GetRunning();
static int ScrollingDialog.GetOptionOnLabel(int label);
static bool ScrollingDialog.GetSay(int topic, int option);
static void ScrollingDialog.ScrollUp();
static void ScrollingDialog.ScrollDown();


Hopefully those are all self-explanatory enough.

There's already some stuff leftover in the ScrollingDialog_Setup module that should help with getting your first dialog set up.

And I should cover some things that have been removed.

- There is no option to number dialog options.
- There is no option to make dialog options go upward on the GUI.
- There is no used option color.

Also it's worth noting that you can't have any multi-line options any more. You can store as much text into the dialog options as you want, however, when they are displayed on the labels they are automatically truncated to fit onto the label with an ellipsis appended at the end. When retrieving the text the full text will be restored.

Once again I'll bump this thread. However I have a legitimate reason this time seeing as I actually wrote a version of the module that works:

Version 1.0 released!

It pretty much emulates the original workings of the template. So that's good. I'll be working on implementing things like multi-line options, numbering options, used option color, etc. But the core system for scrolling dialogs is there now. Finally. And it's time for some much needed rest.

Btw, I came up with a solution to the interaction problem. If the user needs to call module functions from within the interaction for the dialog option, they can place their interactions directly into the ScrollingDialog module's script. Otherwise they can put their interactions in the ScrollingDialog_Setup module. (For more info on how to do this, just ask...)

SMF spam blocked by CleanTalk