Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: The_Creep on Fri 21/04/2006 02:35:54

Title: notebook GUI (SOLVED)
Post by: The_Creep on Fri 21/04/2006 02:35:54
Hi there,

I want to make a GUI that represents the character's Note book, being an investiagtive reporter, he writes down clues, leads and other useful bots of information, and i want to the player to have access to this at any time during the game so he can review and keep in mind what his objectives are.

As the player unlocks a clue, say...a suicide note, I want the note to appear as an option in his gui that he can click on, and the contents of the note will be displayed, as the player unlocks further clues, they will be added to his notenook.

I have tried several things, but cant seem to get a working idea going, any ideas, help or pointing out it already exists somewhere would be great!
Title: Re: notebook GUI
Post by: Dr. Scary on Fri 21/04/2006 02:43:31
Depends on what you want to want the player to be able to do with the notebook GUI, really...
I have thought of a similar thing recently. My situation was that I wanted the writing to be sprites rather than ingame text.
My idea then was to make the sprites inventory items and make the notebook GUI an inventory GUI. Then you can handle all the clicks as inventory clicks and even use them on each other to juxtapose information in order to make conclusions and thereby gain new information.
PM me if you want. I have thought a lot about this so it would be fun to discuss this with somebody else.
Title: Re: notebook GUI
Post by: Scummbuddy on Fri 21/04/2006 04:23:59
Did you not see this thread on the first page of the Beginners thread?
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=26145.0
Title: Re: notebook GUI
Post by: The_Creep on Fri 21/04/2006 07:09:11
I did indeed, and copied the code and played with it, but the concept seems far too overly complex for what I want. I dont want the player to add his own text, nor do I want any other games to be able to access it,

what I'm looking for is far closer to the principle that the AGS dialog system works on, where an event, such as reading a newspaper, note or book, would "unlock" a text entry in the GUI making it viisble to the player so he may consult it at a later date.

The game I'm working on is based on the world of Call of Cthulhu, and thus lends itself to a fair amount of books, news paper clippings journals, Using thse as clues, I dont want the player to have a ridiculously stocked inventory consisting of books he may or may not need to refer back too, nor do I want him trecking back and forth between the libary and the puzzle to solve it.

I've been trying to get it to work with text overlays but again, this seems incredibly complex. I was just wondering if anyone had any ideas on an easier soloution.
Title: Re: notebook GUI
Post by: Scorpiorus on Fri 21/04/2006 13:51:45
But what if you then do make a use of the AGS dialog system?

You can have dialog options to represent entries, so that when the player chooses one it displays the details.
Title: Re: notebook GUI
Post by: The_Creep on Sat 22/04/2006 11:28:30
thats what I had initialy intended, but I ran into a couple of problems, first off, how do I display the dialog in a gui, without a character? do I need to create a blank character, if so how do I do that, and how would I tell AGS where to display the various texts, (like the dialog options in a listbox, and the text displayed next to it ) without messing up my default dialog options in the process?
Title: Re: notebook GUI
Post by: Ashen on Sat 22/04/2006 11:43:23
Well ... You can change which GUI is used by dialogues with the OPT_DIALOGOPTIONSGUI parameter of SetGameOption, so it'd just be a case of setting it to whatever GUI you want the 'Notepad' to use when you access it, and that back to 0 (for no GUI, or whatever other GUI you use) when you exit, so as not to affect standard dialogues.
Unchecking the 'Say' box for the dialogue options will stop the player character from speaking the title (e.g. "Suicide Note", before the note displays) and you can tell the dialog script to have it 'read' by any character, or use run-script to have it displayed however you like.

I think this thread probably belongs in Beginners Tech, since The_Creep only wants/needs something simple, while that other one should probably have been posted here.
Title: Re: notebook GUI
Post by: The_Creep on Sat 22/04/2006 15:19:24
I think you're right Ashen, maybe one of the moderaters should swap the threads around :)

That said, thanks for the input, that really helps a lot, I'm a little  unclear as to what you mean by using run script to have it displayed however I like, could you elaborate?
Title: Re: notebook GUI
Post by: Ashen on Sat 22/04/2006 17:30:25
Elaborate on which part? The run-script X function is how you run most AGS script (i.e. anything that's not the basic dialog script commands) from inside a dialogue. See the BFAQ (http://americangirlscouts.org/agswiki/index.php/Scripting%2C_Code_%26_Interaction#Running_regular_code_inside_dialog) or a forum search if you're not sure what I'm talking about (it happens a lot).

The 'having it displayed however you like' bit: To keep the suicide note example - just using dialog script pretty much all you could do would be have a character read out the note. Using run-script lets you display a GUI with the text on, or display the note as an on-screen graphic, or go to a room with the note as a background, or, well, any other way you could possibly want.

However, it might be that the Dialog system isn't the best way to do this. Dr. Scary's idea of using the inventory is quite nice, especially the way you can 'cross-reference' facts you already know. Or, on a simpler note, your own suggestion of using a ListBox would work - just add an item everytime a 'clue' is unlocked.
Title: Re: notebook GUI
Post by: The_Creep on Sun 23/04/2006 00:43:41
Aaah I see, I had it backwards, I've been trying to retrieve dialog options in a function within the global script,  and display them in the GUI code, I have read the Bfaq, it just never occured to me to use run-script-x in this manner

as for the Listbox Idea, I have been fiddling with the damned Listbox, Textbox and GUIlabel functions all night and tearing my hair out in an effort to understand them and their relation to each other, what I've been trying to do is within the listbox add an item that retreives a dialog option,which you then click on and it displays the dialog in the adjacent text box but no luck.

I'm begining to think this whole idea is a bit beyond my coding skills
Is there a basic listbox tutorial and their relations to other gui options anywhere, this is driving me nuts! in the mean while I will give the run-script-x idea a try, thanks!
Title: Re: notebook GUI
Post by: Scorpiorus on Sun 23/04/2006 16:01:42
Note that with the dialog system you could probably use "narrator" (http://www.adventuregamestudio.co.uk/manual/Conversations.htm) to display the text from the dialog script:

// dialog script file
@1Ã,  // option 1
narrator: your text here
return

etc...

This will use standart text window or a text window GUI you specified ("Always display text as speech" option from the general settings pane maybe cancels it though).

Using a custom GUI or built-in inventory system functionality are also good options of course, so see what works best for you.
Title: Re: notebook GUI
Post by: The_Creep on Sun 23/04/2006 22:33:00
Thanks for the tip, I did'nt know about the narrator option. At the moment, I've had limited success with a custom GUI containing a textbox and listbox and utilising GlobalStrings (limits me to 50 entries but so far its the closest I've got to what I need).  but it won't quite do what I want, this is the code I have:

NBList is the ListBox
NBDisplay is the textbox



String NBE1 = "John's journal entry";  //This entry is placed on an event to add the entry into the journal
NBlist.AddItem(NBE1);
Game.GlobalStrings[0] = "According to John's journal, there is a safe in the study, the combination is the date of his wedding";


String NBE2 = "Kitchen Note";        //This entry is placed on an event to add the entry into the joutnal
NBlist.AddItem(NBE2);
Game.GlobalStrings[1] = "John for some strange reason wrote the word GRENDEL on the fridge to remind himself of something"; 


int entry;                           //This is entry is in the listbox script to trigger the displaying of the relevent entry
      if (entry == (0)) {
         String output0 = (Game.GlobalStrings[0]);
         NBDisplay.Text = output0;
         }
      else if (entry == (1)) {
    String output1 = (Game.GlobalStrings[1]);
    NBDisplay.Text = output1;
   }

Now when I click on the Journal entry, everything comes up roses, it displays the relevant text, but when I activate the second entry (The Ktichen note) the entry appears in the listbox, but it won't display the text, nothing happens at all, this happens no matter which order I activate the events.  Now I'm almost postive I've made a stupid coding mistake, but I'm damned if I can figure out what it is. any suggestions?
Title: Re: notebook GUI
Post by: Ashen on Sun 23/04/2006 22:57:02
What's the full code for the entry selection? At the moment I can't see how/where the variable entry is being set.

I can't really help with the problem you posted, but I noticed a few things:
Have you actually got a TextBox on the GUI, or are you just using that word? A TextBox is for the player to input text - to display the text (as you want) you'd generally want to use a Label. (Although you can set the text in a TextBox so it'd look like it works - but if the player types anything it'll be entered into the display.)

Strings (unlike strings) can be exported from the Global Script, if you need them to be changable from Room scripts. This means you can create your own array of Strings of whatever size you want, so you're not limited to using the GlobalStrings. E.g.:

//Global Script
String Clues[200];
export Clues;


//Script Header
import String Clues[200];

However, if this is all in the Global Script (as it looks like mostly GUI scripts) do wouldn't even need to export it.

Finally, that code looks a little over-written to me. For example NBList.AddItem("John's journal entry"); should work well enough, without the redundant String NBE1 = ..... Similarly NBDisplay.Text = (Game.GlobalStrings[1]); should be enough.
   
Title: Re: notebook GUI
Post by: The_Creep on Mon 24/04/2006 16:27:26
Thanks Ashen, I've just got it working and came to post my soloution, I will optimize my code as per your suggestions as they make a lot of sense, if its my weakest failing in coding anything, its that I wrap myself up in knots, and end up with complex soloutions to simple problems, here is the code I have that is currently working 100%

the code for notebook entries are placed in the script of any event you want to trigger an entry, eg using a computer or examining a fridge.

NBList is the ListBox
NBDisplay is the textbox
Global Message 982 states "Your Notebook has been Updated."

//This is the Entry placed in the code for an event, adds it to the Notebookl
NBlist.AddItem("John's Journal Entry");
Game.GlobalStrings[0] = "According to John's journal, there is a safe in the study,";
DisplayMessage(982);


//This is the Entry placed in the code for an even to it adds it to the Notebook
NBlist.AddItem("Kitchen Note");
Game.GlobalStrings[1] = "John for some strange reason wrote the word Password on the fridge";
DisplayMessage(982);

// This  is the script for the the listbox
function NBlist_SelectionChanged(GUIControl *control) {
   String seltex = NBlist.Items[NBlist.SelectedIndex];
      if (seltex.CompareTo("John's Journal Entry") == 0){
         NBDisplay.Text = (Game.GlobalStrings[0]);
         }
      if (seltex.CompareTo("Kitchen Note") == 0){
         NBDisplay.Text = (Game.GlobalStrings[1]);
         }
// and so on and so forth
}

EDIT right this is the final code, interestingly, you cannot export/import strings, so I had to stick with Globalstrings, but it should be fine. thanks again!