Example #1
0
        //this is for testing purposes
        void Start()
        {
            //Make sure you have 'using TextBoxSystem;'
            //for this to work in other classes

            AddNextDialog("Dialog/test dialog.dia");

            TextBoxData tmp = new TextBoxData();

            tmp.textBoxType = TextBoxType.Narration;
            tmp.addDialogSection("Well, I’m back here again.");
            tmp.addDialogSection("Everything’s just how I left it…");
            tmp.addDialogSection("..after I had to rush out last time.");
            tmp.addDialogSection("Yikes.");
            tmp.addDialogSection("Sorry for leaving my room like this all these months, Mom.");
            tmp.addDialogSection("Guess I should take the time to clean up now. Before dinner.");
            tmp.addDialogSection("Alright, let’s see…");
            tmp.addDialogSection("I’ll start with you, desk.");
            CreateDialog.AddNextDialog(tmp);

            //tmp = new TextBoxData();
            //tmp.textBoxType = TextBoxType.Dialog;
            //tmp.name = "Protag";
            //tmp.addDialogSection("OK here is a new one");
            //tmp.addDialogSection("I moved it so it looks cooler");
            //tmp.setMovement(0, MovementType.Breath);
            //tmp.setMovement(1, MovementType.None);
            //tmp.position = new float2(250, 150);
            //CreateDialog.AddNextDialog(tmp);
            //
            //tmp = new TextBoxData();
            //tmp.textBoxType = TextBoxType.Internal;
            //tmp.setMovement(0, MovementType.Breath);
            //tmp.addDialogSection("Who am I?");
            //CreateDialog.AddNextDialog(tmp);
        }
Example #2
0
        public static void AddNextDialog(string dialogFile)
        {
            try
            {
                using (StreamReader stream = new StreamReader(Application.dataPath + "/" + dialogFile))
                {
                    TextBoxData data     = null;
                    string      textBody = "";

                    for (string line;
                         (line = stream.ReadLine()) != null;)
                    {
                        bool newBox = false;

                        //This is for line comments found in file
                        while (line.Contains("#"))
                        {
                            if ((line[line.LastIndexOf('#')].ToString() ?? "") != "\\")
                            {
                                line = line.Substring(0, line.LastIndexOf('#'));
                            }
                        }

                        //Find Name
                        if (line.Trim().Length > 0)
                        {
                            if (line.Trim()[0] == '[')
                            {
                                if (data != null)
                                {
                                    AddNextDialog(data);
                                }
                                textBody  = "";
                                data      = new TextBoxData();
                                data.name = line.Trim().Substring(1, line.Trim().IndexOf(']') - 1);
                                if (data.name.Length < 1)
                                {
                                    data.name = null;
                                }
                                continue;
                            }
                        }


                        if (line.Replace(" ", "").ToLower().Contains("textboxtype="))
                        {
                            string tmp = line.Replace(" ", "").ToLower();
                            switch (tmp.Substring(tmp.IndexOf('=') + 1))
                            {
                            case "narration":
                                data.textBoxType = TextBoxType.Narration;
                                break;

                            case "dialog":
                                data.textBoxType = TextBoxType.Dialog;
                                break;

                            case "internal":
                                data.textBoxType = TextBoxType.Internal;
                                break;
                            }
                            continue;
                        }

                        //separate the dialog into sections
                        if (line.Trim() == "" || line.Trim() == @"\endsection")
                        {
                            newBox = true;
                        }
                        else
                        {
                            textBody += line;
                        }

                        if (newBox)
                        {
                            if (data != null)
                            {
                                if (textBody != "")
                                {
                                    data.addDialogSection(textBody);
                                }
                            }

                            textBody = "";
                            newBox   = false;
                        }
                    }
                    if (data != null)
                    {
                        if (data != null)
                        {
                            if (textBody != "")
                            {
                                data.addDialogSection(textBody);
                            }
                        }

                        AddNextDialog(data);
                    }
                }
            }
            catch (Exception e) { print("Could not parse dialog:\n" + e); }
        }
Example #3
0
 public static void AddNextDialog(TextBoxData msg) => dialogData.Add(msg);
Example #4
0
 /// <summary>
 /// MUST be called for any function to work
 /// </summary>
 public void initData(TextBoxData data)
 {
     this.data = data;
 }