Page 1 of 1

2 questions regarding Quest Log Window

Posted: Mon Dec 02, 2019 2:19 pm
by Stalker_EG
Good day!
I have 2 small questions :?: :?: for you:
I was able to independently add an image to the description of the quest. Did this by overriding the method: RepaintSelectedQuest
below code:

Code: Select all

// Image:

            var ImageTransform = questDetailsContentContainer.transform.Find("QuestImage");
            var questImage = (ImageTransform != null) ? ImageTransform.GetComponent<UnityEngine.UI.Image>() : null;

            if (questImage != null)
            {
                var spriteName = DialogueLua.GetQuestField(quest.Title, "Pictures").AsString;
                var isSpriteNameSet = !string.IsNullOrEmpty(spriteName) && !string.Equals(spriteName, "nil");
                var sprite = isSpriteNameSet ? DialogueManager.LoadAsset(spriteName, typeof(Sprite)) as Sprite : null;
                if (isSpriteNameSet && sprite == null)
                {
                    Debug.LogWarning("Dialogue System: " + name + " couldn't load image '" + spriteName + "' for quest '" + quest.Title + "'.", this);
                }
                questImage.gameObject.SetActive(sprite != null);
                questImage.sprite = sprite;
            }
Now I need to add an image to the group button and the buttons of the quest itself. so that it would be attached directly to the group or quest. I define it in the database. How can I do it? already rummaged the entire forum.

and the second question: I really need to list not only active, but also completed and failed quests, how to do this without buttons?

Thanks in advance for your reply.

Re: 2 questions regarding Quest Log Window

Posted: Mon Dec 02, 2019 5:09 pm
by Tony Li
Hi,
Stalker_EG wrote: Mon Dec 02, 2019 2:19 pmNow I need to add an image to the group button and the buttons of the quest itself. so that it would be attached directly to the group or quest. I define it in the database. How can I do it?
You can override the OnQuestListUpdated() method. The base method has a section that adds group foldouts:

Code: Select all

            // Add quests by group:
            foreach (var groupName in groupNames)
            {
                var groupFoldout = selectionPanelContentManager.Instantiate<StandardUIFoldoutTemplate>(questGroupTemplate);
                selectionPanelContentManager.Add(groupFoldout, questSelectionContentContainer);
                groupFoldout.Assign(groupName, IsGroupExpanded(groupName));
In that section, you can set up an image on groupFoldout.

Stalker_EG wrote: Mon Dec 02, 2019 2:19 pmand the second question: I really need to list not only active, but also completed and failed quests, how to do this without buttons?
Override the ShowQuests method:

Code: Select all

protected override void ShowQuests(QuestState questStateMask)
{
    // Always show active, success, and failure.
    base.ShowQuests(QuestState.Active | QuestState.Success | QuestState.Failure);
    currentQuestState = questStateMask; // Maybe you want to also remember the actual state requested to show.
}

Re: 2 questions regarding Quest Log Window

Posted: Tue Dec 03, 2019 1:20 am
by Stalker_EG
Override the ShowQuests method:

Code: Select all

protected override void ShowQuests(QuestState questStateMask)
{
    // Always show active, success, and failure.
    base.ShowQuests(QuestState.Active | QuestState.Success | QuestState.Failure);
    currentQuestState = questStateMask; // Maybe you want to also remember the actual state requested to show.
}
Yes thank you! I did just that. but after that the template ceases to determine the quest state. Highlights everything in gray as if they were all done. In this case, quests have different states. And templates are all defined
01.png
01.png (21.11 KiB) Viewed 606 times

Re: 2 questions regarding Quest Log Window

Posted: Tue Dec 03, 2019 9:15 am
by Tony Li
Hi,

In that case, since you're using different templates for active and completed quests, you'll need to override OnQuestListUpdated(). You can copy the code in StandardUIQuestLogWindow.OnQuestListUpdated and then customize it in your subclass. This method assumes it will use the same template (active or completed) for all of the quests, so it sets questTitleTemplate and selectedQuestTitleTemplate once at the start of the method. You'll need to change your overridden method to set them for each quest based on the quest state.

Re: 2 questions regarding Quest Log Window

Posted: Tue Dec 03, 2019 9:47 am
by Stalker_EG
Thank you so much for your help) I already figured it out. It was not at all difficult. :shock: 8-)