Quest update marker in Quest Log Window

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
marafrass
Posts: 35
Joined: Thu Jan 16, 2020 1:32 pm

Quest update marker in Quest Log Window

Post by marafrass »

Heya Tony,

Going through a big UI update and I've been meaning to add in a marker on the Quest log whenever a quest is updated. (either the main state, when it has an entry state added, or when an entry state changes) For context, I'm trying to do something along these lines;
Image

Is this functionality that already exists in the asset that I've just missed? If not, do you have any suggestion on how to implement it best with whatever functionality does exist? I assume using OnQuestStateChange is my best bet here.

Love the asset, as usual.
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest update marker in Quest Log Window

Post by Tony Li »

Hi,

Quests can have a "Viewed" field. (The Dialogue System adds the field at runtime if it's not already defined in your quest template.) To show a marker, set the quest's Viewed field to false. You can do this in an OnQuestStateChange() method:

Code: Select all

void OnQuestStateChange(string quest)
{
    DialogueLua.SetQuestField(quest, "Viewed", false);
    DialogueManager.SendUpdateTracker(); // Update quest log window immediately if it's open.
}
When "Viewed" is missing or false, the quest log window adds text to the end of the quest title:

newQuestText2.png
newQuestText2.png (291.55 KiB) Viewed 399 times

When the player clicks on the quest title to view the details, the quest log window automatically sets "Viewed" to false.

You can specify the exact string that it adds in the StandardUIQuestLogWindow component:

newQuestText1.png
newQuestText1.png (88.8 KiB) Viewed 399 times

If you want to show an icon in front of the title instead of that text, set the New Quest Text field blank. Then make a subclass of StandardUIQuestTitleButtonTemplate. Override the Assign() method to activate an icon Image if the quest hasn't been viewed yet:

Code: Select all

public class MyQuestTitleButtonTemplate : StandardUIQuestTitleButtonTemplate
{
    public Image newUpdateIcon; //<--Assign in inspector.
        
    public override void Assign (string questName, string displayName, ToggleChangedDelegate trackToggleDelegate)
    {
        base.Assign(questName, displayName, trackToggleDelegate);
        newUpdateIcon.enabbled != QuestLog.WasQuestViewed(title);
    }
}
Use the subclass on your quest log window's Active Quest Heading Template instead of the original class.
marafrass
Posts: 35
Joined: Thu Jan 16, 2020 1:32 pm

Re: Quest update marker in Quest Log Window

Post by marafrass »

Thanks, hadn't realized this was added in an update at some point! This worked immediately when adding new quests, (main entries) but the Viewed field doesn't seem to update when entry states are added/updated - anything I can toggle for that, or is that separate from OnQuestStateChange, or any other suggestions?

Also, appreciate the instructions on turning the [new] into an icon, will be doing that next!
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest update marker in Quest Log Window

Post by Tony Li »

Hi,

Use the OnQuestStateChange() method above in a script on the Dialogue Manager. Whenever a quest state changes, it will set the quest's Viewed field to false.
Post Reply