Exemple #1
0
    public static void ExtractDialogueEntries(LuaNode node, ref DiaEntry_Label entry_Label, bool bClearEntries = true, int iLuaNodeIndex = 0)
    {
        if (bClearEntries)
        {
            lstEntries_IfGoto.Clear();
            dictEntries_Label.Clear();
            lstEntries_Label.Clear();
        }

        if (node.lstTokens.Count > 0)
        {
            string strType = node.lstTokens[0].ToLower();

            if (strType.Equals("if"))
            {
                try
                {
                    if (node.lstTokens.Count == 5)
                    {
                        DiaEntry_IfGoto entry = new DiaEntry_IfGoto();
                        entry.key = node.lstTokens[1];
                        entry.op = node.lstTokens[2];
                        entry.value = node.lstTokens[3];
                        entry.label = node.lstTokens[4];

                        //Debug.LogError(entry.key+"\t"+entry.op+"\t"+entry.value+"\t"+entry.label+"**************");

                        if (entry_Label == null)
                        {
                            // General
                            lstEntries_IfGoto.Add(entry);
                        }
                        else
                        {
                            if (entry_Label.lstBranches.Count > 0)
                            {
                                // Branch
                                DiaBranch_Label branch = entry_Label.lstBranches.Last();
                                branch.lstIfGotos.Add(entry);
                            }
                            else
                            {
                                // Label
                                entry_Label.lstInitialIfGotos.Add(entry);
                            }
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'if' entry does not contain exactly 5 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'if' node - " + e);
                }
            }
            else if (strType.Equals("goto"))
            {
                try
                {
                    if (node.lstTokens.Count == 2)
                    {
                        // Only set the 'label' value because this is a straight goto.
                        DiaEntry_IfGoto entry = new DiaEntry_IfGoto();
                        entry.label = node.lstTokens[1];

                        if (entry_Label == null)
                        {
                            // General
                            lstEntries_IfGoto.Add(entry);
                        }
                        else
                        {
                            if (entry_Label.lstBranches.Count > 0)
                            {
                                // NOTE: Nothing is currently done with branch.lstIfGotos.

                                // Branch
                                DiaBranch_Label branch = entry_Label.lstBranches.Last();
                                branch.lstIfGotos.Add(entry);
                            }
                            else
                            {
                                // Label
                                entry_Label.lstInitialIfGotos.Add(entry);
                            }
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'goto' entry does not contain exactly 2 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'goto' node - " + e);
                }
            }
            else if (strType.Equals("label"))
            {
                try
                {
                    if (node.lstTokens.Count == 2)
                    {
                        entry_Label = new DiaEntry_Label();
                        entry_Label.name = node.lstTokens[1];
                        entry_Label.index = lstEntries_Label.Count;

                        dictEntries_Label.Add(entry_Label.name, entry_Label);
                        lstEntries_Label.Add(entry_Label);
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'label' entry does not contain exactly 2 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'label' node - " + e);
                }
            }
            else if (strType.Equals("n"))
            {
                try
                {
                    if (node.lstTokens.Count == 2)
                    {
                        // print("n - entry_Label is NULL: " + (entry_Label == null).ToString());

                        if (entry_Label != null)
                        {
                            DiaEntry_NpcText entry = new DiaEntry_NpcText();
                            entry.text = Regex.Unescape(node.lstTokens[1]);

                            DiaBranch_Label branch = new DiaBranch_Label();
                            branch.npcText = entry;

                            entry_Label.lstBranches.Add(branch);
                        }
                        else
                        {
                            Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'n' entry found in mode other than Label.");
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'n' entry does not contain exactly 2 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'n' node - " + e);
                }
            }
            else if (strType.Equals("n1"))
            {
                try
                {
                    if (node.lstTokens.Count == 3)
                    {
                        if (entry_Label != null)
                        {
                            DiaEntry_NpcText entry = new DiaEntry_NpcText();
                            entry.text = Regex.Unescape(node.lstTokens[1]);

                            entry.arg1 = node.lstTokens[2];

                            DiaBranch_Label branch = new DiaBranch_Label();
                            branch.npcText = entry;

                            entry_Label.lstBranches.Add(branch);
                        }
                        else
                        {
                            Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'n1' entry found in mode other than Label.");
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'n1' entry does not contain exactly 3 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'n1' node - " + e);
                }
            }
            else if (strType.Equals("n2"))
            {
                try
                {
                    if (node.lstTokens.Count == 4)
                    {
                        if (entry_Label != null)
                        {
                            DiaEntry_NpcText entry = new DiaEntry_NpcText();
                            entry.text = Regex.Unescape(node.lstTokens[1]);

                            entry.arg1 = node.lstTokens[2];
                            entry.arg2 = node.lstTokens[3];

                            DiaBranch_Label branch = new DiaBranch_Label();
                            branch.npcText = entry;

                            entry_Label.lstBranches.Add(branch);
                        }
                        else
                        {
                            Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'n2' entry found in mode other than Label.");
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'n2' entry does not contain exactly 4 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'n2' node - " + e);
                }
            }
            else if (strType.Equals("n3"))
            {
                try
                {
                    if (node.lstTokens.Count == 5)
                    {
                        if (entry_Label != null)
                        {
                            DiaEntry_NpcText entry = new DiaEntry_NpcText();
                            entry.text = Regex.Unescape(node.lstTokens[1]);

                            entry.arg1 = node.lstTokens[2];
                            entry.arg2 = node.lstTokens[3];
                            entry.arg3 = node.lstTokens[4];

                            DiaBranch_Label branch = new DiaBranch_Label();
                            branch.npcText = entry;

                            entry_Label.lstBranches.Add(branch);
                        }
                        else
                        {
                            Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'n3' entry found in mode other than Label.");
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'n3' entry does not contain exactly 5 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'n3' node - " + e);
                }
            }
            else if (strType.Equals("ns"))
            {
                try
                {
                    if (node.lstTokens.Count == 3)
                    {
                        if (entry_Label != null)
                        {
                            DiaEntry_NpcText entry = new DiaEntry_NpcText();
                            entry.text = Regex.Unescape(node.lstTokens[1]);

                            string strAudioName = node.lstTokens[2];
                            entry.sound.Url = strAudioName;

                            DiaBranch_Label branch = new DiaBranch_Label();
                            branch.npcText = entry;

                            entry_Label.lstBranches.Add(branch);
                        }
                        else
                        {
                            Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'ns' entry found in mode other than Label.");
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'ns' entry does not contain exactly 3 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'ns' node - " + e);
                }
            }
            else if (strType.Equals("ns1"))
            {
                try
                {
                    if (node.lstTokens.Count == 4)
                    {
                        if (entry_Label != null)
                        {
                            DiaEntry_NpcText entry = new DiaEntry_NpcText();
                            entry.text = Regex.Unescape(node.lstTokens[1]);

                            string strAudioName = node.lstTokens[2];
                            entry.sound.Url = strAudioName;

                            entry.arg1 = node.lstTokens[3];

                            DiaBranch_Label branch = new DiaBranch_Label();
                            branch.npcText = entry;

                            entry_Label.lstBranches.Add(branch);

                        }
                        else
                        {
                            Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'ns1' entry found in mode other than Label.");
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'ns1' entry does not contain exactly 4 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'ns1' node - " + e);
                }
            }
            else if (strType.Equals("ns2"))
            {
                try
                {
                    if (node.lstTokens.Count == 5)
                    {
                        if (entry_Label != null)
                        {
                            DiaEntry_NpcText entry = new DiaEntry_NpcText();
                            entry.text = Regex.Unescape(node.lstTokens[1]);

                            string strAudioName = node.lstTokens[2];
                            entry.sound.Url = strAudioName;

                            entry.arg1 = node.lstTokens[3];
                            entry.arg2 = node.lstTokens[4];

                            DiaBranch_Label branch = new DiaBranch_Label();
                            branch.npcText = entry;

                            entry_Label.lstBranches.Add(branch);
                        }
                        else
                        {
                            Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'ns2' entry found in mode other than Label.");
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'ns2' entry does not contain exactly 5 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'ns2' node - " + e);
                }
            }
            else if (strType.Equals("ns3"))
            {
                try
                {
                    if (node.lstTokens.Count == 6)
                    {
                        if (entry_Label != null)
                        {
                            DiaEntry_NpcText entry = new DiaEntry_NpcText();
                            entry.text = Regex.Unescape(node.lstTokens[1]);

                            string strAudioName = node.lstTokens[2];
                            entry.sound.Url = strAudioName;

                            entry.arg1 = node.lstTokens[3];
                            entry.arg2 = node.lstTokens[4];
                            entry.arg3 = node.lstTokens[5];

                            DiaBranch_Label branch = new DiaBranch_Label();
                            branch.npcText = entry;

                            entry_Label.lstBranches.Add(branch);
                        }
                        else
                        {
                            Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'ns3' entry found in mode other than Label.");
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'ns3' entry does not contain exactly 6 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'ns3' node - " + e);
                }
            }
            else if (strType.Equals("p"))
            {
                try
                {
                    if (node.lstTokens.Count == 2)
                    {
                        if (entry_Label != null)
                        {
                            if (entry_Label.lstBranches.Count > 0)
                            {
                                DiaEntry_PcText entry = new DiaEntry_PcText();
                                entry.text = Regex.Unescape(node.lstTokens[1]);

                                DiaBranch_Label branch = entry_Label.lstBranches.Last();
                                branch.lstPcTexts.Add(entry);
                            }
                            else
                            {
                                Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'p' entry found before any 'n' or 'ns' entries for label '" + entry_Label.name + "'.");
                            }
                        }
                        else
                        {
                            Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'p' entry found in mode other than Label.");
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'p' entry does not contain exactly 2 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'p' node - " + e);
                }
            }
            else if (strType.Equals("pg"))
            {
                try
                {
                    if (node.lstTokens.Count == 3)
                    {
                        if (entry_Label != null)
                        {
                            if (entry_Label.lstBranches.Count > 0)
                            {
                                DiaEntry_PcText entry = new DiaEntry_PcText();
                                entry.text = Regex.Unescape(node.lstTokens[1]);
                                entry.gotoLabel = node.lstTokens[2];

                                DiaBranch_Label branch = entry_Label.lstBranches.Last();
                                branch.lstPcTexts.Add(entry);
                            }
                            else
                            {
                                Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'pg' entry found before any 'n' or 'ns' entries for label '" + entry_Label.name + "'.");
                            }
                        }
                        else
                        {
                            Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'pg' entry found in mode other than Label.");
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'pg' entry does not contain exactly 3 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'pg' node - " + e);
                }
            }
            else if (strType.Equals("pgs"))
            {
                try
                {
                    if (node.lstTokens.Count == 4)
                    {
                        if (entry_Label != null)
                        {
                            if (entry_Label.lstBranches.Count > 0)
                            {
                                DiaEntry_PcText entry = new DiaEntry_PcText();
                                entry.text = Regex.Unescape(node.lstTokens[1]);
                                entry.gotoLabel = node.lstTokens[2];
                                entry.score = node.lstTokens[3];

                                DiaBranch_Label branch = entry_Label.lstBranches.Last();
                                branch.lstPcTexts.Add(entry);
                            }
                            else
                            {
                                Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'pgs' entry found before any 'n' or 'ns' entries for label '" + entry_Label.name + "'.");
                            }
                        }
                        else
                        {
                            Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'pgs' entry found in mode other than Label.");
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'pgs' entry does not contain exactly 4 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'pgs' node - " + e);
                }
            }
            else if (strType.Equals("pg1"))
            {
                try
                {
                    if (node.lstTokens.Count == 4)
                    {
                        if (entry_Label != null)
                        {
                            if (entry_Label.lstBranches.Count > 0)
                            {
                                DiaEntry_PcText entry = new DiaEntry_PcText();
                                entry.text = Regex.Unescape(node.lstTokens[1]);
                                entry.gotoLabel = node.lstTokens[2];
                                entry.arg1 = node.lstTokens[3];

                                // Format the text based on legacy formatting rules.
                                //entry.text = LegacyFormatSubstitute(entry.text, arg1);

                                DiaBranch_Label branch = entry_Label.lstBranches.Last();
                                branch.lstPcTexts.Add(entry);
                            }
                            else
                            {
                                Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'pg1' entry found before any 'n' or 'ns' entries for label '" + entry_Label.name + "'.");
                            }
                        }
                        else
                        {
                            Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'pg1' entry found in mode other than Label.");
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'pg1' entry does not contain exactly 4 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'pg' node - " + e);
                }
            }
            else if (strType.Equals("pg1s"))
            {
                try
                {
                    if (node.lstTokens.Count == 5)
                    {
                        if (entry_Label != null)
                        {
                            if (entry_Label.lstBranches.Count > 0)
                            {
                                DiaEntry_PcText entry = new DiaEntry_PcText();
                                entry.text = Regex.Unescape(node.lstTokens[1]);
                                entry.gotoLabel = node.lstTokens[2];
                                entry.arg1 = node.lstTokens[3];
                                entry.score = node.lstTokens[4];

                                // Format the text based on legacy formatting rules.
                                //entry.text = LegacyFormatSubstitute(entry.text, arg1);

                                DiaBranch_Label branch = entry_Label.lstBranches.Last();
                                branch.lstPcTexts.Add(entry);
                            }
                            else
                            {
                                Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'pg1s' entry found before any 'n' or 'ns' entries for label '" + entry_Label.name + "'.");
                            }
                        }
                        else
                        {
                            Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'pg1s' entry found in mode other than Label.");
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'pg1s' entry does not contain exactly 5 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'pg' node - " + e);
                }
            }
            else if (strType.Equals("pg2"))
            {
                try
                {
                    if (node.lstTokens.Count == 5)
                    {
                        if (entry_Label != null)
                        {
                            if (entry_Label.lstBranches.Count > 0)
                            {
                                DiaEntry_PcText entry = new DiaEntry_PcText();
                                entry.text = Regex.Unescape(node.lstTokens[1]);
                                entry.gotoLabel = node.lstTokens[2];
                                entry.arg1 = node.lstTokens[3];
                                entry.arg2 = node.lstTokens[4];

                                // Format the text based on legacy formatting rules.
                                //entry.text = LegacyFormatSubstitute(entry.text, arg1);
                                //entry.text = LegacyFormatSubstitute(entry.text, arg2);

                                DiaBranch_Label branch = entry_Label.lstBranches.Last();
                                branch.lstPcTexts.Add(entry);
                            }
                            else
                            {
                                Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'pg2' entry found before any 'n' or 'ns' entries for label '" + entry_Label.name + "'.");
                            }
                        }
                        else
                        {
                            Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'pg2' entry found in mode other than Label.");
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'pg2' entry does not contain exactly 5 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'pg' node - " + e);
                }
            }
            else if (strType.Equals("pg2s"))
            {
                try
                {
                    if (node.lstTokens.Count == 6)
                    {
                        if (entry_Label != null)
                        {
                            if (entry_Label.lstBranches.Count > 0)
                            {
                                DiaEntry_PcText entry = new DiaEntry_PcText();
                                entry.text = Regex.Unescape(node.lstTokens[1]);
                                entry.gotoLabel = node.lstTokens[2];
                                entry.arg1 = node.lstTokens[3];
                                entry.arg2 = node.lstTokens[4];
                                entry.score = node.lstTokens[5];

                                // Format the text based on legacy formatting rules.
                                //entry.text = LegacyFormatSubstitute(entry.text, arg1);
                                //entry.text = LegacyFormatSubstitute(entry.text, arg2);

                                DiaBranch_Label branch = entry_Label.lstBranches.Last();
                                branch.lstPcTexts.Add(entry);
                            }
                            else
                            {
                                Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'pg2s' entry found before any 'n' or 'ns' entries for label '" + entry_Label.name + "'.");
                            }
                        }
                        else
                        {
                            Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'pg2s' entry found in mode other than Label.");
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'pg2s' entry does not contain exactly 6 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'pg' node - " + e);
                }
            }
            else if (strType.Equals("wait"))
            {
                try
                {
                    if (node.lstTokens.Count == 2)
                    {
                        if (entry_Label != null)
                        {
                            if (entry_Label.lstBranches.Count > 0)
                            {
                                DiaEntry_PcText entry = new DiaEntry_PcText();
                                //entry.text = "[Leave] (Wait Placeholder)";
                                entry.text = "Ok.";
                                entry.gotoLabel = node.lstTokens[1];

                                DiaBranch_Label branch = entry_Label.lstBranches.Last();
                                branch.lstPcTexts.Add(entry);
                            }
                            else
                            {
                                Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'wait' entry found before any 'n' or 'ns' entries for label '" + entry_Label.name + "'.");
                            }
                        }
                        else
                        {
                            Debug.LogError("!!! ERROR - Node: " + iLuaNodeIndex + " - 'wait' entry found in mode other than Label.");
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'wait' entry does not contain exactly 2 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'wait' node - " + e);
                }
            }
            else if (strType.Equals("fun"))
            {
                try
                {
                    if (node.lstTokens.Count == 2)
                    {
                        DiaEntry_Function entry = new DiaEntry_Function();
                        entry.name = node.lstTokens[1];

                        if (entry_Label != null)
                        {

                            if (entry_Label.lstBranches.Count > 0)
                            {
                                DiaBranch_Label branch = entry_Label.lstBranches.Last();
                                branch.lstFunctions.Add(entry);
                            }
                            else
                            {
                                entry_Label.lstInitialFunctions.Add(entry);
                            }
                        }
                        else
                        {
                            lstEntries_Function.Add(entry);
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'fun' entry does not contain exactly 2 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'fun' node - " + e);
                }
            }
            else if (strType.Equals("fun2"))
            {
                try
                {
                    if (node.lstTokens.Count == 3)
                    {
                        DiaEntry_Function entry = new DiaEntry_Function();
                        entry.name = node.lstTokens[1];
                        entry.arg1 = node.lstTokens[2];

                        if (entry_Label != null)
                        {
                            if (entry_Label.lstBranches.Count > 0)
                            {
                                DiaBranch_Label branch = entry_Label.lstBranches.Last();
                                branch.lstFunctions.Add(entry);
                            }
                            else
                            {
                                entry_Label.lstInitialFunctions.Add(entry);
                            }
                        }
                        else
                        {
                            lstEntries_Function.Add(entry);
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'fun2' entry does not contain exactly 3 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'fun2' node - " + e);
                }
            }
            else if (strType.Equals("fun3"))
            {
                try
                {
                    if (node.lstTokens.Count == 4)
                    {
                        DiaEntry_Function entry = new DiaEntry_Function();
                        entry.name = node.lstTokens[1];
                        entry.arg1 = node.lstTokens[2];
                        entry.arg2 = node.lstTokens[3];

                        if (entry_Label != null)
                        {
                            if (entry_Label.lstBranches.Count > 0)
                            {
                                DiaBranch_Label branch = entry_Label.lstBranches.Last();
                                branch.lstFunctions.Add(entry);
                            }
                            else
                            {
                                entry_Label.lstInitialFunctions.Add(entry);
                            }
                        }
                        else
                        {
                            lstEntries_Function.Add(entry);
                        }
                    }
                    else
                    {
                        string strError = "!!! ERROR - Node: " + iLuaNodeIndex + " - 'fun3' entry does not contain exactly 4 tokens. Found token count: " + node.lstTokens.Count;
                        strError += "\r\n";
                        foreach (string strToken in node.lstTokens)
                        {
                            strError += "  |  " + strToken;
                        }
                        Debug.LogError(strError);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("!!! ERROR - DialogueOverlay.ExtractDialogueEntries() - 'fun3' node - " + e);
                }
            }

        }

        foreach (LuaNode childNode in node.lstChildren)
        {
            ExtractDialogueEntries(childNode, ref entry_Label, false, ++iLuaNodeIndex);
        }
    }
Exemple #2
0
    public static void Process_DiaEntry_Function(DiaEntry_Function func)
    {
        switch (func.name)
        {
            case "closethegame":
                closethegame();
            break;
            case "setvar":
                setvar(func.arg1.str, func.arg2);

                if (func.arg1.str=="journalprogress")		// peter
                    {
                GLOBAL.Player.Log("Journal Progress SET:"+
                GLOBAL.Player.progress["journalprogress"].ToString()   );

                if (GLOBAL.Player.progress["journalprogress"]==12)
                        {
                            GLOBAL.Player.Log("CONTRACT DONE!  at...$"+
                                GLOBAL.Player.progress["cost"].ToString()+
                            "!!!!!!");
                        }

                    }

            break;
            case "incvars":
                incvars(func.arg1.str);

                if (func.arg1.str=="journalprogress")		// peter
                    {
                GLOBAL.Player.Log("Journal Progress Bumped:"+
                GLOBAL.Player.progress["journalprogress"].ToString()+
                "  week:" + GLOBAL.Player.progress["week"].ToString()+
        //				"  jsize:" + GLOBAL.JSize().ToString()+

                "!"

                  );
                    }

            break;
            case "talkedtostan":
                talkedtostan();
            break;
            case "talkedtomayor":
                talkedtomayor();
            break;
            case "talkedtowill":
                talkedtowill();
            break;
            case "talkedtoexpert":
                talkedtoexpert();
                GLOBAL.Player.Log("Talked to Expert");

            break;
            case "talkedtoevelyn":
                talkedtoevelyn();
            break;
            case "incfailed":
                incfailed();
            break;
            case "startingcostplus10perc":
                startingcostplus10perc();
            break;
            case "startingcostplus30perc":
                startingcostplus30perc();
            break;
            case "clearreneg":
                clearreneg();
            break;
            case "increneg":
                increneg();
            break;
            case "incceo":
                incceo();
            break;
            case "incevelyn":
                incevelyn();
            break;
            case "incstandon":
                incstandon();
            break;
            case "incmayor":
                incmayor();

        // Peter was here again...
                GLOBAL.Player.Log("Mayor Inc:#"+
                GLOBAL.Player.progress["mayorprogress"].ToString()
                );

            break;
            case "incexpert":
                incexpert();
            break;
            case "incvendor1":
                incvendor1();
            break;
            case "incvendor2":
                incvendor2();
            break;
            case "incvendor3":
                incvendor3();
            break;
            case "incvendor4":
                incvendor4();
            break;
            case "talkedtovendor1":
                talkedtovendor1();
            break;
            case "talkedtovendor2":
                talkedtovendor2();
            break;
            case "talkedtovendor3":
                talkedtovendor3();
            break;
            case "talkedtovendor4":
                talkedtovendor4();
            break;
            case "incvendorsvisited":
                incvendorsvisited();
            break;
            case "vendorto1":
                vendorto1();
            break;
            case "vendorto2":
                vendorto2();
            break;
            case "vendorto3":
                vendorto3();
            break;
            case "vendorto4":
                vendorto4();
            break;
            case "pickedvendor1":
                pickedvendor1();
                logvendorchoice();	// Write vendor to log file - below
            break;

            case "pickedvendor2":
                pickedvendor2();
                logvendorchoice();	// Write vendor to log file - below
            break;

            case "pickedvendor3":
                pickedvendor3();
                logvendorchoice();	// Write vendor to log file - below
            break;

            case "pickedvendor4":
                pickedvendor4();
                logvendorchoice();	// Write vendor to log file - below
            break;

            case "incpickedvendor":
                incpickedvendor();
            break;
            case "setpickedvendor":
                setpickedvendor();
            break;
            case "incl1w1":
                incl1w1();
            break;
            case "incl1w2":
                incl1w2();
            break;
            case "incl1r":
                incl1r();
            break;
            case "incl2w1":
                incl2w1();
            break;
            case "incl2w2":
                incl2w2();
            break;
            case "incl2r":
                incl2r();
            break;
            case "incsheriff":
                incsheriff();
            break;
            case "incwp1":
                incwp1();
            break;
            case "incwp2":
                incwp2();
            break;
            case "incwp3":
                incwp3();
            break;
            case "incwp4":
                incwp4();
            break;
            case "gotclueobj":
                gotclueobj(func.arg1.str);
            break;
            case "arrestme":
                arrestme(func.arg1.str);
            break;
            case "foundcrim":
                foundcrim();
            break;
            case "getcheck":
                getcheck();
            break;
            case "checkop":
                checkop();
            break;
            case "setexp":
                setexp();
            break;
            case "setbaseprofit":
                setbaseprofit();
            break;
            case "incprofit":
                incprofit(func.arg1.i);
            break;
            case "decprofit":
                decprofit(func.arg1.i);
            break;
            case "calccost":
                calccost();
            break;
            case "calccostinc":
                calccostinc(func.arg1.i, func.arg2.i);
            break;
            case "calccostdec":
                calccostdec(func.arg1.i, func.arg2.i);
            break;
            case "halfcost":
                halfcost();
            break;
            case "threequartercost":
                threequartercost();
            break;
            case "addexpense":
                addexpense(func.arg1.i);
            break;
            case "subexpense":
                subexpense(func.arg1.i);
            break;
            case "wrongprice":
                wrongprice();
            break;
            case "getvendorcontract":
                getvendorcontract();
            break;
            case "getcontractcost":
                getcontractcost();
            break;
            case "arrestscene":
                arrestscene(func.arg1.str, func.arg2.str);
            break;
            case "setcontractcost":
                setcontractcost(func.arg1.i);
            break;
            case "takemarkup":
                takemarkup();
            break;
            case "storecost":
                storecost();
            break;

            case "incexplored":
                incexplored(func.arg1.i);
            break;
            case "incplayercash":
                incplayercash(func.arg1.i);
            break;
            case "decplayercash":
                decplayercash(func.arg1.i);
            break;
            case "purchase":
                purchase(func.arg1.i);
            break;
            case "dropcash":
                dropcash();
            break;
            case "incinterv":
                incinterv();
            break;
            case "incsq":
                incsq();
            break;
            case "incceostate":
                incceostate();
            break;
            case "decceostate":
                decceostate();
            break;
            case "storescore":
                storescore(func.arg1.str, func.arg2.str);
            break;
            case "storenlcscore":
                storenlcscore(func.arg1.str, func.arg2.str);
            break;
            case "storemsq":
                storemsq(func.arg1.str, func.arg1.str);
            break;
            case "incoldlady":
                incoldlady();
            break;
            case "incol2":
                incol2();
            break;
            case "incol3":
                incol3();
            break;
            case "addboxofhotdogs":
                addboxofhotdogs();
            break;
            case "inchotdog":
                inchotdog();
            break;
            case "bingoto1":
                bingoto1();
            break;
            case "bingoto2":
                bingoto2();
            break;
            case "bingoto3":
                bingoto3();
            break;
            case "organto1":
                organto1();
            break;
            case "organto2":
                organto2();
            break;
            case "organto3":
                organto3();
            break;
            case "incedt":
                incedt();
            break;
            case "incmickey":
                incmickey();
            break;
            case "mickeyto2":
                mickeyto2();
            break;
            case "mickeyto3":
                mickeyto3();
            break;
            case "incmickeycost":
                incmickeycost();
            break;
            case "mickeytext":
                mickeytext();
            break;
            case "mickeydeductcash":
                mickeydeductcash();
            break;
            case "suzieto1":
                suzieto1();
            break;
            case "suzieto2":
                suzieto2();
            break;
            case "suzieto3":
                suzieto3();
            break;
            case "calctourcash":
                calctourcash();
            break;
            case "addtouristscore":
                addtouristscore();
            break;
            case "tourguideto1":
                tourguideto1();
            break;
            case "tourguideto2":
                tourguideto2();
            break;
            case "tourguideto3":
                tourguideto3();
            break;
            case "addwtqscore":
                addwtqscore();
            break;
            case "incwtq":
                incwtq();
            break;
            case "addmqscore":
                addmqscore();
            break;
            case "addmathcash":
                addmathcash();
            break;
            case "incresult":
                incresult();
            break;
            case "incmath":
                incmath();
            break;
            case "keesterto1":
                keesterto1();
            break;
            case "keesterto2":
                keesterto2();
            break;
            case "keesterto3":
                keesterto3();
            break;
            case "adduwayscore":
                adduwayscore();
            break;
            case "incuway":
                incuway();
            break;
            case "incticket":
                incticket();
            break;
            case "decvars":
                decvars(func.arg1.str);
            break;
            case "ettto5":
                ettto5();
            break;
            case "ettfailed":
                ettfailed();
            break;
            case "olett":
                olett();
            break;
            case "francodeduct":
                francodeduct();
            break;
            case "takebook":
                takebook();
            break;
            case "givebook":
                givebook(func.arg1.str);
            break;
            case "buycrier":
                buycrier();
            break;
            case "buyexaminer":
                buyexaminer();
            break;
            case "buytoday":
                buytoday();
            break;
            case "buymickeyclothes":
                buymickeyclothes(func.arg1.i);
            break;
            // BChance: (2016-07-25) - Function 'buyoutfit' not called by NPC lua scripts and
            //                           has too many arguments for current lua parser.
            //case "buyoutfit":
            //	buyoutfit(int arg, string gvar, string mb, int arg2);
            //break;

            case "appendscore":
                appendscore(func.arg1.str);
            break;
            case "flagvendorinfo":
                flagvendorinfo(func.arg1.i);
            break;
            case "vendorinfoscore":
                vendorinfoscore();
            break;
            case "willclothingscore3":
                willclothingscore3(func.arg1.str, func.arg2.str);
            break;
            case "willclothingscore":
                willclothingscore();
            break;
            case "willclothingscore2":
                willclothingscore2();
            break;

            default:
                Debug.LogError("!!! ERROR - LuaFunctions.Process_DiaEntry_Function - Function '" + func.name + "' not recognized.");
            break;
        }

        // Update the UI (particularly the Inventory) based on any state changes.
        GLOBAL.RefreshUIBasedOnProgress();
    }