Exemplo n.º 1
0
        private static string GetData(params string[] name)
        {
            ConfigLevel <string, string> tmp = mConfig;

            bool found = true;

            for (int i = 0; i < name.Length - 1; ++i)
            {
                if (name[i] == "")
                {
                    break;
                }

                if (tmp.ContainsLevel(name[i]))
                {
                    tmp = tmp.GetLevel(name[i]);
                }
                else
                {
                    found = false;
                    break;
                }
            }

            if (found)
            {
                return(tmp.Get(name[name.Length - 1]));
            }
            else
            {
                return("");
            }
        }
Exemplo n.º 2
0
        public static string[] GetSubLevels(params string[] name)
        {
            ConfigLevel <string, string> tmp = mConfig;

            bool found = true;

            for (int i = 0; i < name.Length; ++i)
            {
                if (name[i] == "")
                {
                    break;
                }

                if (tmp.ContainsLevel(name[i]))
                {
                    tmp = tmp.GetLevel(name[i]);
                }
                else
                {
                    found = false;
                    break;
                }
            }

            if (found)
            {
                return(tmp.GetSubLevelKeys());
            }
            else
            {
                return(new string[0]);
            }
        }
Exemplo n.º 3
0
        public static Color GetColor(params string[] name)
        {
            Color def = Color.White;

            ConfigLevel <string, string> tmp = mConfig;

            bool found = true;

            for (int i = 0; i < name.Length - 1; ++i)
            {
                if (name[i] == "")
                {
                    break;
                }

                if (tmp.ContainsLevel(name[i]))
                {
                    tmp = tmp.GetLevel(name[i]);
                }
                else
                {
                    found = false;
                    break;
                }
            }

            if (found)
            {
                if (tmp.ContainsKey(name[name.Length - 1]))
                {
                    Color    output;
                    string[] parts = tmp.Get(name[name.Length - 1]).Split(space);

                    if (parts.Length == 3)
                    {
                        if (Util.TryParseColor(parts[0], parts[1], parts[2], "255", out output))
                        {
                            return(output);
                        }
                        else if (parts.Length >= 4)
                        {
                            if (Util.TryParseColor(parts[0], parts[1], parts[2], parts[3], out output))
                            {
                                return(output);
                            }
                        }
                    }
                }
            }

            return(def);
        }
Exemplo n.º 4
0
        public static Vector4 GetVector4(params string[] name)
        {
            Vector4 def = Vector4.Zero;

            ConfigLevel <string, string> tmp = mConfig;

            bool found = true;

            for (int i = 0; i < name.Length - 1; ++i)
            {
                if (name[i] == "")
                {
                    break;
                }

                if (tmp.ContainsLevel(name[i]))
                {
                    tmp = tmp.GetLevel(name[i]);
                }
                else
                {
                    found = false;
                    break;
                }
            }

            if (found)
            {
                if (tmp.ContainsKey(name[name.Length - 1]))
                {
                    Vector4  output;
                    string[] parts = tmp.Get(name[name.Length - 1]).Split(space);

                    if (parts.Length >= 4)
                    {
                        if (Util.TryParseVector4(parts[0], parts[1], parts[2], parts[3], out output))
                        {
                            return(output);
                        }
                    }
                }
            }

            return(def);
        }
Exemplo n.º 5
0
        public static float GetFloat(params string[] name)
        {
            float def = 0.0f;

            ConfigLevel <string, string> tmp = mConfig;

            bool found = true;

            for (int i = 0; i < name.Length - 1; ++i)
            {
                if (name[i] == "")
                {
                    break;
                }

                if (tmp.ContainsLevel(name[i]))
                {
                    tmp = tmp.GetLevel(name[i]);
                }
                else
                {
                    found = false;
                    break;
                }
            }

            if (found)
            {
                if (tmp.ContainsKey(name[name.Length - 1]))
                {
                    float  output;
                    string str = tmp.Get(name[name.Length - 1]);

                    if (Util.TryParseFloat(str, out output))
                    {
                        return(output);
                    }
                }
            }

            return(def);
        }
Exemplo n.º 6
0
        public static void ParseLine(string line)
        {
            string[] parts = Util.Split(line, space, 2);

            if (parts.Length < 2)
            {
                return;
            }

            string[] levels = parts[0].Split(slash);

            ConfigLevel <string, string> tmp = mConfig;

            for (int i = 0; i < levels.Length - 1; ++i)
            {
                if (levels[i] == "")
                {
                    break;
                }

                if (!tmp.ContainsLevel(levels[i]))
                {
                    tmp.AddLevel(levels[i]);
                }

                tmp = tmp.GetLevel(levels[i]);
            }

            if (parts[0].Contains(':'))
            {
                tmp.AddToList(levels[levels.Length - 1].Substring(0, levels[levels.Length - 1].Length - 1), parts[1]);
            }
            else
            {
                tmp.Add(levels[levels.Length - 1], parts[1]);
            }
        }
Exemplo n.º 7
0
 public Config()
 {
     mConfig = new ConfigLevel <string, string>();
     LoadContent();
 }