Quests order in UI Quest Log Window

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
walczak
Posts: 20
Joined: Tue Oct 11, 2022 9:42 pm

Quests order in UI Quest Log Window

Post by walczak »

Hello,

How can I make Quests to appear in "UI Quest Log Window" in order they are in "Quests/Items" table?
At the moment they are displayed alphabetically. I will prefer to make a script rather than changing the names of the quest as I already have the names used in many Triggers/Conditions etc.

Thanks.
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quests order in UI Quest Log Window

Post by Tony Li »

Hi,

The easiest way is to set the Name fields in the order you want, and set the Display Names to what you want to appear in the quest log window. Example:

Code: Select all

Name                 Display Name
------------   --------------------
01 Kill Rats          Kill 5 Rats
02 Bake Cake    Bake a Birthday Cake
03 Find Sword   Find the Magic Sword
walczak
Posts: 20
Joined: Tue Oct 11, 2022 9:42 pm

Re: Quests order in UI Quest Log Window

Post by walczak »

Thanks for the answer. Is there any other way? I am already using the names in Conditions and it will take ages to change it.
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quests order in UI Quest Log Window

Post by Tony Li »

Hi,

You can make a subclass of your quest log window class (e.g., StandardUIQuestLogWindow) and override the OnQuestListUpdated() method to sort it however you want. Example:

Code: Select all

public class MyQuestLogWindow : StandardUIQuestLogWindow
{
    public override void OnQuestListUpdated()
    {
        SortQuests();
        base.OnQuestListUpdated();
    }
    
    private void SortQuests() // Sort by order in dialogue database.
    {
        var list = new List<QuestInfo>(quests);
        list.Sort((x, y) => IndexInDatabase(x.Title).CompareTo(IndexInDatabase(y.Title)));
        quests = list.ToArray();
    }
    
    private int IndexInDatabase(string questName)
    {
        return DialogueManager.masterDatabase.items.FindIndex(x => x.Name == questName);
    }
}
walczak
Posts: 20
Joined: Tue Oct 11, 2022 9:42 pm

Re: Quests order in UI Quest Log Window

Post by walczak »

Thanks.
I got en error in line:

Code: Select all

list.Sort((x, y) => IndexInDatabase(x.Title) < IndexInDatabase(y.Title));
* Cannot implicity convert type "bool" to "int" *
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quests order in UI Quest Log Window

Post by Tony Li »

Sorry, I should have mentioned that I just typed that example into the reply. It's just an example idea. Try this:

Code: Select all

list.Sort((x, y) => IndexInDatabase(x.Title).CompareTo(IndexInDatabase(y.Title)));
walczak
Posts: 20
Joined: Tue Oct 11, 2022 9:42 pm

Re: Quests order in UI Quest Log Window

Post by walczak »

I am sorry, you said it was example my bad.
Anyway it works! Thanks again for a help.
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quests order in UI Quest Log Window

Post by Tony Li »

Glad to help! Sorry about the earlier typo.
Post Reply