Custom Quest Log Window

Announcements, support questions, and discussion for the Dialogue System.
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Custom Quest Log Window

Post by eeeli »

Hi Tony,

I'm looking to tweak the UI functionality of the Quest Log Window. I'm looking to create the following functionality:

1. Break apart the Quest List and Quest Description windows, so instead of being side by side, selecting a quest closes the Quest List and opens the Quest Description of that selected quest.

2. List out completed and incomplete quests in the Quest List, with the complete quests at the top, and incomplete at the bottom for later reference.

I'd like to be able to manage opening and closing the Quest List and Quest Description from a script that I write (because I'm not using the typical UI input for this project), so I think the biggest helpful thing would be knowing how to do that.

Thank you so much!
User avatar
Tony Li
Posts: 22154
Joined: Thu Jul 18, 2013 1:27 pm

Re: Custom Quest Log Window

Post by Tony Li »

Hi,

There are a few ways you can approach this:

1. Make a subclass of StandardUIQuestLogWindow. Override methods such as OnQuestListUpdated() (called to refresh the window) and SelectQuest() (called when the player clicks on a quest name).

2. Or make a subclass of the abstract QuestLogWindow class. This class implements all the nonvisual data stuff. You can implement the visual part.

3. Or bypass QuestLogWindow entirely and write your own script. Call QuestLog.GetAllQuests() to a list of quests. You can call it twice, once as QuestLog.GetAllQuests(QuestState.Active) and a second as QuestLog.GetAllQuests(QuestState.Success).
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: Custom Quest Log Window

Post by eeeli »

Hi Tony,

Thank you so much for the help! I took option 3, and am putting together my own simple quest scene by calling QuestLog.GetAllQuests(). It's going well, and I think I have it mostly implemented, however there's one small issue I'm running into.

Some of the quests use markup tags in their entries, however my script is clearly not parsing it properly. For example, one entry is:

"[var=Donuts]/6 Donuts Eaten"

Here Donuts is a number variable in the database which changes as the donuts are eaten. However, when I read the entry from the database and feed it to my TextMeshProUI I see the markup, instead of the filled in variable number.

This is the code I'm using:

TextMeshProUGUI questName;
TextMeshProUGUI questDescription;
TextMeshProUGUI questEntry;

public void SetUpDescription(string currentQuest){
questName.text = currentQuest;
questDescription.text = QuestLog.GetQuestDescription(currentQuest);
questEntry.text = QuestLog.GetQuestEntry(currentQuest, QuestLog.GetQuestEntryCount(currentQuest));
}

Thank so much in advance!
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: Custom Quest Log Window

Post by eeeli »

Hi Tony, sorry to stack up posts in here.

I just realized I had one more small bit of functionality I wanted to ask your help with. I'm looking to create a small pop-up when a quest is added, so I guess that would mean when a quest is switched to 'active'.

I was wondering if you had a recommendation of a way to detect when the state of a quest has changed. I could envision creating a listener script that is constantly checking the QuestLog against a reference to see if the state of anything has changed, however, that seems like it might be a taxing/clunky way to implementing it.
User avatar
Tony Li
Posts: 22154
Joined: Thu Jul 18, 2013 1:27 pm

Re: Custom Quest Log Window

Post by Tony Li »

Hi,

To process markup tags in text, use FormattedText.ParseCode():

Code: Select all

questEntry.text = FormattedText.ParseCode(QuestLog.GetQuestEntry(currentQuest, QuestLog.GetQuestEntryCount(currentQuest)));
To detect when a quest state has changed, add a script with an OnQuestStateChange() method to the Dialogue Manager.
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: Custom Quest Log Window

Post by eeeli »

Brilliant! That solved both of those, thanks so much :)
User avatar
Tony Li
Posts: 22154
Joined: Thu Jul 18, 2013 1:27 pm

Re: Custom Quest Log Window

Post by Tony Li »

Happy to help! :-)
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: Custom Quest Log Window

Post by eeeli »

Hi Tony,

Sorry to resurrect this thread. For the most part everything is working wonderfully, but I'm running into one issue with my OnQuestStateChange() call.

For a little context, whenever a player gets a new quest I want a little popup to show to them to indicate the new quest. I have that all set up and it's working almost perfectly. One of the ways the player can get is a quest is through a dialogue choice. The game is currently set up to allow players to return through old dialogue choices. Each time they return through an old dialogue choice the quest is set to an active state. The issue though, is even if the quest is already in an active state, OnQuestStateChange() is called, and the player gets a notification for a quest they already have.

Assuming I want the player to be able to repeat the same dialogue, one way I can see to fix this setting up a branch at every point of dialogue that the player receives a quest with a conditional. One branch sets the quest active if it's not already, the other does nothing, but they both give the same dialogue. This isn't the worst option if there's not easier way to set this up, but I did want to ask because it's a little clunky to have to do for every point of dialogue where they might get a quest. Is there way to perhaps set up a conditional for running just the Script part of a dialogue node, where you see the same text every time, but the script is only run if a certain condition is met. If there's no easy way to do this, no worries :)
User avatar
Tony Li
Posts: 22154
Joined: Thu Jul 18, 2013 1:27 pm

Re: Custom Quest Log Window

Post by Tony Li »

Hi,

You can override the method that sets quest states. For example:

Code: Select all

// In some initialization script somewhere:
QuestLog.SetQuestStateOverride = CustomSetQuestState;

void CustomSetQuestState(string quest, string state)
{
    // Only set state if it's a different state:
    if (QuestLog.CurrentQuestState(quest) != state)
    {
        QuestLog.DefaultSetQuestState(quest, state);
    }
}
This way you'll only receive the OnQuestStateChange() call when the state actually changes to something different.
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: Custom Quest Log Window

Post by eeeli »

Thanks!! This is super helpful :D
Post Reply