Esempio n. 1
0
        public static string Item(int index, string[] content)
        {
            string result = "[" + index.ToString() + "] = { ";

            for (int i = 0; i < content.Length; i++)
            {
                result += (i > 0 ? ", " : "") + "\"" + LuaTableWriter.EscapeContent(content[i]) + "\"";
            }
            return(result + " },");
        }
Esempio n. 2
0
        public static string[] List(string index, string[] content)
        {
            string[] result = new string[content.Length + 2];
            LuaTableWriter.IndentLines(ref content);

            result[0] = "[\"" + index + "\"] = {";
            content.CopyTo(result, 1);
            result[content.Length + 1] = "},";

            return(result);
        }
Esempio n. 3
0
        public static string[] Table(string container, string title, string[] content)
        {
            string[] result = new string[content.Length + 2 + LuaTableWriter.EmptyLinesBetweenTables];
            LuaTableWriter.IndentLines(ref content);

            result[0] = container + "[\"" + title + "\"] = {";
            content.CopyTo(result, 1);
            result[content.Length + 1] = "}";

            return(result);
        }
Esempio n. 4
0
        public bool Export(bool appendLanguage)
        {
            try
            {
                LuaTableWriter writer = new LuaTableWriter(this.ExportFile.FullName);

                foreach (EmoteConfiguration configuration in this.EmoteConfigurations)
                {
                    if (configuration.DefaultEmotes.Count > 0)
                    {
                        string[] table = LuaTableWriter.Table(
                            "PetEmote_DefaultEmotes",
                            configuration.Name + (appendLanguage ? "-" + configuration.PetFamily.Language : string.Empty),
                            this.ExportNodeSetContent(configuration.DefaultEmotes)
                            );
                        writer.Write(table);
                    }

                    if (configuration.CombatEmotes.Count > 0)
                    {
                        string[] table = LuaTableWriter.Table(
                            "PetEmote_CombatEmotes",
                            configuration.Name + (appendLanguage ? "-" + configuration.PetFamily.Language : string.Empty),
                            this.ExportNodeSetContent(configuration.CombatEmotes)
                            );
                        writer.Write(table);
                    }

                    if (configuration.FeedingEmotes.Count > 0)
                    {
                        string[] table = LuaTableWriter.Table(
                            "PetEmote_FeedingEmotes",
                            configuration.Name + (appendLanguage ? "-" + configuration.PetFamily.Language : string.Empty),
                            this.ExportNodeSetContent(configuration.FeedingEmotes)
                            );
                        writer.Write(table);
                    }
                }

                writer.Close();
            }
            catch (IOException) {
                return(false);
            }
            catch (Exception e) {
                throw e;
            }

            return(true);
        }
Esempio n. 5
0
        private string[] ExportNodeSetContent(List <EmoteNode> nodeSet)
        {
            List <string> emotes = new List <string>();

            for (int i = 0; i < nodeSet.Count; i++)
            {
                EmoteNode node = nodeSet[i];

                List <string> contents = new List <string>();

                contents.Add(LuaTableWriter.Item("text", node.Text));

                if (node.Properties.Chance != 100)
                {
                    contents.Add(LuaTableWriter.Item("chance", node.Properties.Chance));
                }

                if (node.Properties.Condition != EmoteCondition.None)
                {
                    contents.Add(LuaTableWriter.Item("condition", node.Properties.Condition));
                }

                if (node.Properties.Keywords.Length > 0)
                {
                    contents.Add(LuaTableWriter.Item("keywords", node.Properties.Keywords));
                }

                if (node.ChildNodes.Count > 0)
                {
                    string[] childContents = LuaTableWriter.List(node.Properties.MustContinue ? "continues" : "optional", this.ExportNodeSetContent(node.ChildNodes));
                    foreach (string line in childContents)
                    {
                        contents.Add(line);
                    }
                }

                string[] list = LuaTableWriter.List(i + 1, contents.ToArray());
                foreach (string line in list)
                {
                    emotes.Add(line);
                }
            }

            return(emotes.ToArray());
        }
Esempio n. 6
0
 public static string Item(int index, string content)
 {
     return(String.Format("[{0}] = \"{1}\",", index, LuaTableWriter.EscapeContent(content)));
 }