Exemplo n.º 1
0
 public void ManipulateElements(object value, Player_Modes pm, string button = "", int index = 0)
 {
     if (elements.ContainsKey(pm))
     {
         if (elements[pm][index].GetType() == typeof(Strip))
         {
             ((Strip)elements[pm][index]).Manipulate <Button>(button, (string)value);
         }
         if (elements[pm][index].GetType() == typeof(TextBox))
         {
             ((TextBox)elements[pm][index]).AddLine((Text)value);
         }
     }
 }
Exemplo n.º 2
0
        public static Dictionary <Player_Modes, List <IElement> > Parse_Ui_Master(string filepath, ContentManager cm)
        {
            if (!File.Exists(filepath))
            {
                return(null);
            }

            StreamReader sr   = new StreamReader(filepath);
            string       line = "";

            Dictionary <Player_Modes, List <IElement> > ndic = new Dictionary <Player_Modes, List <IElement> >();
            Player_Modes mode  = Player_Modes.Building;
            Align        align = Align.Horizontal;
            string       sm    = "";

            Vector2 loc  = new Vector2();
            Point   size = new Point();

            while ((line = sr.ReadLine()) != null)
            {
                if (line.StartsWith("Mode"))
                {
                    string[] split = line.Split('\t');
                    mode = (Player_Modes)Enum.Parse(typeof(Player_Modes), split[1]);

                    if (!ndic.ContainsKey(mode))
                    {
                        ndic.Add(mode, new List <IElement>());
                    }
                }

                if (line.StartsWith("ParseType"))
                {
                    string[] split = line.Split('\t');
                    sm = split[1];
                }

                if (sm == "single")
                {
                    if (line.StartsWith("File"))
                    {
                        string[] split = line.Split('\t');
                        var      data  = Parse_UiElements(split[1], cm);

                        foreach (IElement ie in data.Values)
                        {
                            ndic[mode].Add(ie);
                        }
                    }
                }

                else if (sm == "multi")
                {
                    if (line.StartsWith("Location"))
                    {
                        string[] split = line.Split('\t', ',');
                        loc = new Vector2(Convert.ToInt32(split[1]), Convert.ToInt32(split[2]));
                    }

                    if (line.StartsWith("Size"))
                    {
                        string[] split = line.Split('\t', ',');
                        size = new Point(Convert.ToInt32(split[1]), Convert.ToInt32(split[2]));
                    }

                    if (line.StartsWith("Align"))
                    {
                        string[] split = line.Split('\t');
                        align = (Align)Enum.Parse(typeof(Align), split[1]);
                    }

                    if (line.StartsWith("File"))
                    {
                        string[] split = line.Split('\t');
                        var      data  = Parse_UiElements(split[1], cm);
                        ndic[mode].Add(new Strip(loc, true, size, align, data));
                    }
                }
            }

            return(ndic);
        }