Ejemplo n.º 1
0
        public void TestConvarEnum()
        {
            ConVar.Set("convar_enum", "Pizza");
            Assert.AreEqual(Food.Pizza, ConVar.Get <Food>("convar_enum"));

            ConVar.Set("convar_enum", Food.Spaghetti);
            Assert.AreEqual(Food.Spaghetti, ConVar.Get <Food>("convar_enum"));
        }
Ejemplo n.º 2
0
        public void TestConvarBool()
        {
            ConVar.Set("convar_bool", "true");
            Assert.AreEqual(true, ConVar.Get("convar_bool"));

            ConVar.Set("convar_bool", false);
            Assert.AreEqual(false, ConVar.Get("convar_bool"));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Reads the config file by path into convars
        /// </summary>
        /// <param name="file">Path to the config file</param>
        private static void ReadConfig(string file)
        {
            // todo protection
            var path  = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, file);
            var lines = File.ReadAllLines(path);

            foreach (var line in lines)
            {
                var split = line.Split(' ');

                var name  = split[0];
                var value = string.Join(" ", split.Skip(1));

                ConVar.Set(name, value);
            }
        }
Ejemplo n.º 4
0
        public async Task Convar(CommandContext ctx, string name, string value = null)
        {
            // set or get?
            if (value == null)
            {
                var val = ConVar.Get <string>(name);

                var type   = ConVar.Convars[name].Value;
                var convar = ConVar.Convars[name].Key;

                await ctx.RespondAsync($"\"{name}\" is set to \"{val}\"\n" +
                                       $"type is \"{type.PropertyType}\"\n" +
                                       $"defined in \"{type.DeclaringType.FullName}\"\n" +
                                       $"description is \"{convar.HelpText}\"");

                return;
            }

            ConVar.Set(name, value);
            return;
        }
Ejemplo n.º 5
0
 public void TestConvarString()
 {
     ConVar.Set("convar_string", "test");
     Assert.AreEqual("test", ConVar.Get("convar_string"));
 }