Well, the tracker is staying open now but unfortunately it's not showing the entry. It also makes the quest title go away.
Here is what I have done, just so you can see and perhaps so I don't forget. I've got custom code all over now and it's getting harder to keep track of. Anyway.
So here is my CustomQuestState:
Code: Select all
public class CustomQuestStateCode : MonoBehaviour
{
public const string QuestStatePreempted = "preempted";
public const string QuestStateReady = "ready";
public const string QuestStateComplete = "complete";
[ObfuscateLiterals]
private void OnEnable()
{
Lua.RegisterFunction("UpdateTracker", null, SymbolExtensions.GetMethodInfo(() => DialogueManager.SendUpdateTracker()));
}
[ObfuscateLiterals]
private void Start()
{
QuestLog.StringToState = CustomStringToState;
QuestLog.StringToState = MakeReadyState;
QuestLog.StringToState = CustomActiveState;
}
[SkipRename]
[ObfuscateLiterals]
public static QuestState CustomStringToState(string s)
{
if (s == "preempted") return QuestState.Unassigned;
else return QuestLog.DefaultStringToState(s);
}
[SkipRename]
[ObfuscateLiterals]
public static QuestState CustomActiveState(string s)
{
if (s == "complete") return QuestState.Active;
else return QuestLog.DefaultStringToState(s);
}
[SkipRename]
[ObfuscateLiterals]
public static QuestState MakeReadyState(string s)
{
if (s == "ready") return QuestState.Unassigned;
else return QuestLog.DefaultStringToState(s);
}
[SkipRename]
public void OnQuestTrackingEnabled(string questName)
{
ManagerSupp.instance.SaveLua();
}
[SkipRename]
public void OnQuestTrackingDisabled(string questName)
{
ManagerSupp.instance.SaveLua();
}
}
complete and ready are only used for the quest indicators.
Next is my custom quest tracker:
Code: Select all
public class CustomQuestTracker : StandardUIQuestTracker
{
protected override string GetQuestEntryText(string quest, int entryNum, QuestState entryState)
{
var questStateString = QuestLog.CurrentQuestState(quest);
var isPreempted = questStateString == "preempted";
var isReallyUnassigned = questStateString == "unassigned";
if (isReallyUnassigned || entryState == QuestState.Abandoned)
{
return string.Empty;
}
else if ((entryState == QuestState.Success || entryState == QuestState.Failure) && !showCompletedEntryText)
{
return string.Empty;
}
else if (entryState == QuestState.Success)
{
return string.Empty;
}
else if (entryState == QuestState.Failure)
{
return string.Empty;
}
else if (entryState == QuestState.Active)
{
var text = DialogueLua.GetQuestField(quest, QuestLog.GetQuestEntry(quest, 1)).asString;
}
else if (isPreempted) //entryState == QuestState.Active || isPreempted)
{
var text = DialogueLua.GetQuestField(quest, QuestLog.GetQuestEntry(quest, 2)).asString;
if (!string.IsNullOrEmpty(text)) return text;
}
return QuestLog.GetQuestEntry(quest, entryNum);
}
}
and I did this is the StandardUIQuestTracker as you showed me.
Code: Select all
protected virtual IEnumerator RefreshAtEndOfFrame()
{
yield return new WaitForEndOfFrame();
// Move instances to the unused list:
unusedInstances.AddRange(instantiatedItems);
instantiatedItems.Clear();
siblingIndexCounter = 0;
// Add quests, drawing from unused list when possible:
int numTracked = 0;
QuestState flags = (showActiveQuests ? QuestState.Active : 0) |
(showCompletedQuests ? QuestState.Success | QuestState.Failure : 0) | QuestState.Unassigned;
foreach (string quest in QuestLog.GetAllQuests(flags))
{
if (QuestLog.IsQuestTrackingEnabled(quest) && QuestLog.CurrentQuestState(quest) != "unassigned")
{
AddQuestTrack(quest);
numTracked++;
}
}
if (container != null)
{
container.gameObject.SetActive(showContainerIfEmpty || numTracked > 0);
}
// Destroy remaining unused instances:
for (int i = 0; i < unusedInstances.Count; i++)
{
Destroy(unusedInstances[i].gameObject);
}
unusedInstances.Clear();
refreshCoroutine = null;
}
I'm changing the quest state and the entry state when I pick up the item and it triggers UpdateTracker().
Also, I have to set an entry when I start the conversation or I get no tracking at all. It doesn't show whatsoever if I have 1 entry that doesn't get started right away. If I have no entries it works as normal.
SO basically, if I keep it how it is now, what happens is I get the quest and the tracker opens and shows entry 1. The quest is "active" at this time (Hard Active). When I pick up the item UpdateTracker() is called by Lua as it should and the tracker stays but the title disappears and only shows entry1, not entry2 which should say "return to jerkface", etc. the quest is now "preempted" (Soft Unassigned). My quest entries are set to active and unassigned respectively.
Oh, and I also set the QuestEntryState to preempted in my UpdateTracker function.
Thanks for your previous and any future help.