Problem with ingame Journal.

Started by Woten, Thu 21/03/2013 16:32:25

Previous topic - Next topic

Woten

I have a problem. I've been tinkering with the GUI's and am making a Journal for my character.
What I want is for my Listboxes (Quest and Journal respectively) to be scrollable using my own sprites, on account of spacial concerns. I also have no idea how to link the Listbox items to the corresponding text entry on the textbox on the left.

Also, the Journal is a tad small, so being able to scroll the corresponding text up and down is essential. Is this possible, and if so, can I do this using my own scroll buttons?

Any pointers on how to accomplish this?

Here's a sample of the journal: http://imgur.com/MPiAXDz


PS. I also need a smaller font for the journal, I've been scouring the forums but all it returns is people with font scaling problems and stuff like that. Is there a smaller font available anywhere around here?

Ghost

#1
What size font do you need (in pixels); I have a couple of relatively small (but still readable) fonts I could share. Radiant also made a font editor once, so you can even create your own ones!
You can find it on the AGS home page, Download section, and then right at the bottom of the page.

As for the journal, you can get any selected item in a list-box with the SelectedIndex property. I'd either use a couple of if statements to refresh the text box, or, alternatively, create an array of texts, where each entry is already matched to the proper entry in the list box.

AGS doesn't support scrolling text windows as far as I know, but there may be a workaround.

If this is too complicated or not exactly that you want, maybe a module is also helpful?
http://www.adventuregamestudio.co.uk/forums/index.php?topic=27158.msg345442#msg345442

[edit]
And that plant is pretty awesome!

Woten

Thank you so much for the help, I'm going to tinker with the font editor and Journal module for a bit, to see they fit my purposes :)

Woten


Alright, so the Font Editor worked just fine(but only if you make your font a SCI file named "FONT") , but the link for the Journal Module is broken.

I do fancy the idea of linking the quest description label to the listboxes by making, as you said, an array of texts (and in some cases, images) that are already linked up to the corresponding entries, but I'm kind of a scrub and have really no idea how to code that. So further instruction on how to accomplish this would be infinitely helpful.

-Woten

MurrayL

Quote from: Woten on Thu 21/03/2013 19:11:40
I do fancy the idea of linking the quest description label to the listboxes by making, as you said, an array of texts (and in some cases, images) that are already linked up to the corresponding entries, but I'm kind of a scrub and have really no idea how to code that. So further instruction on how to accomplish this would be infinitely helpful.

Assuming a listbox of journal entry titles called gcJournalList, and a description label called gcJournalText:
Code: AGS

String journalTextArray[5];
journalTextArray[0] = "Journal entry 1";
journalTextArray[1] = "Journal entry 2";
journalTextArray[2] = "Journal entry 3";
journalTextArray[3] = "Journal entry 4";
journalTextArray[4] = "Journal entry 5";

function gcJournalList_OnSelectionChanged(){ // Make sure this function is linked to the OnSelectionChanged event on gcJournalList!
    if(gcJournalList.SelectedIndex>=0){
        gcJournalText.Text = journalTextArray[gcJournalList.SelectedIndex];
    }else{
        gcJournalText.Text = "";
    }
}

Woten

#5
When I try to implement this, I get a parse error message for the line below "String journalTextArray[5];" or "String EntryTextArray[5];" as it is in this case.

Edit:

The full error message reads: GlobalScript.asc(1587): Error (line 1587): Parse error: unexpected 'EntryTextArray'

And it is reffering to this line: EntryTextArray[0] = "Journal entry 1";

MurrayL

Ah, yes - I think AGS doesn't allow you to populate an array outside of a function.

Keep the definition ( String EntryTextArray[5]; ) where it is, but put the list of entries into the game_start function.

Woten

#7
Thanks for answering again.

I did that and I get: GlobalScript.asc(53): Error (line 53): Undefined token 'EntryTextArray'

Edit: Also since there is a number of listboxes that I need to work with (some even have images that need to be called when the corresponding entry is selected) then maybe is it to make a custom function for each listbox?

MurrayL

I'm not sure what line 53 is in your script, but you must have something in the wrong place. That error implies you're trying to access EntryTextArray before it's been properly created.

Here's an example of what something similar should look like (globalscript.asc):

Code: AGS

// main global script file
String ACTitles[3];

// called when the game starts, before the first room is loaded
function game_start(){
    ACTitles[0] = "New Game";
    ACTitles[1] = "Tech-Whizz";
    ACTitles[2] = "Don't Get Cocky";
}


I know this code works, since it's a truncated version of how I initialise the array of achievements in Astroloco!

Woten

Alright I no longer get the error message, but it doesn't seem to work.

Let me elaborate:
On the particular page that I'm working with there are three buttons, Quests, Completed Quests and Journal Entries specifically.

The code for the button is such

Code: AGS
function btnEntries_OnClick(GUIControl *control, MouseButton button)
{
  LBQuests.Visible = false;
  LBComplete.Visible = false;
  LBEntries.Visible = true;
}



What I want of course is for the Entries to pop up when you click the LBEntries button, and again, a label that corresponds with the entry.

The code you so graciously provided looks like it should work, I'm just having problems with where to place it.

Khris

In your GlobalScript.asc is a function called game_start().

In there, initialize the Strings like MurrayL showed. For this to work, the array of Strings has to be declared above the function.
To keep things tidy, you can put all that stuff in a separate script. Just add a new one to the script node in the editor, give it a name and open its asC file.
The paste MurrayL's code in there.
In line 3, put
Code: ags
export ACTitles;

Then open the asH file and put this line in there:
Code: ags
import String ACTitles[3];


You now have a global array of Strings at your disposal.

For each Listbox, create its OnSelectionChanged() function.
Move the button functions below those.

Now fake selecting the first item when you show the Journal list box:
Code: ags
function btnEntries_OnClick(GUIControl *control, MouseButton button)
{
  LBQuests.Visible = false;
  LBComplete.Visible = false;
  LBEntries.Visible = true;
  // fake click on first entry
  LBEntries.SelectedIndex = 0;
  LBEntries_OnSelectionChanged();
}


In the OnSelectionChanged() function of each listbox, you need to figure out a way to link the list item to the global string containing the text for the label.

I'm actually thinking that a struct would come in handy:
Code: ags
// new script header
struct ListEntry {
  String name;
  String text;
};


name gets to be the listbox item, and when one is selected, AGS searches through the available ListEntry objects to find the matching name, then puts the text on the label.

This takes some additional work though.

A dirty workaround is to put the index of the global string into the listbox entry, but move it to the right with whitespace until it's no longer visible. Upon selecting an item, extract the index from the item and set the label to show the string.

SMF spam blocked by CleanTalk