예제 #1
0
파일: CVar.cs 프로젝트: yonder/CryMono
        /// <summary>
        /// Registers a new console variable that will update the user defined float.
        /// </summary>
        /// <param name="name">console variable name</param>
        /// <param name="value">reference to the memory that will be updated</param>
        /// <param name="help">help text that is shown when you use <paramref name="name"/> ? in the console</param>
        /// <param name="flags"></param>
        /// <returns>Newly null if failed, new CVar instance if successful</returns>
        public static CVar RegisterFloat(string name, ref float value, string help = "", CVarFlags flags = CVarFlags.None)
        {
            NativeCVarMethods.RegisterCVarFloat(name, ref value, value, flags, help);

            CVars.Add(new ByRefCVar(name));

            return(CVars.Last());
        }
예제 #2
0
        /// <summary>
        /// Registers a new console variable that references a value.
        /// </summary>
        /// <param name="name">The name of the console variable.</param>
        /// <param name="value">Reference to the memory that will be updated.</param>
        /// <param name="help">
        /// Help text that is shown when you use <paramref name="name" />? in the console.
        /// </param>
        /// <param name="flags">A set of flags to assign to the variable.</param>
        /// <returns>Null if failed, new <see cref="CVar"/> instance if successful.</returns>
        public static CVar RegisterInt(string name, ref int value, string help = "", CVarFlags flags = CVarFlags.None)
        {
            Native.ConsoleInterop.RegisterCVarInt(name, ref value, value, flags, help);

            CVars.Add(new ByRefCVar(name));

            return(CVars.Last());
        }
예제 #3
0
파일: CVar.cs 프로젝트: yonder/CryMono
        /// <summary>
        /// Retrieve a console variable by name - not case sensitive
        /// </summary>
        /// <param name="name">The name of the CVar to retrieve</param>
        /// <returns>null if not found, CVar instance if successful</returns>
        public static CVar Get(string name)
        {
            CVar cvar = CVars.FirstOrDefault(var => var.Name.Equals(name));

            if (cvar != default(CVar))
            {
                return(cvar);
            }

            if (NativeCVarMethods.HasCVar(name))
            {
                CVars.Add(new ExternalCVar(name));

                return(CVars.Last());
            }

            return(null);
        }
예제 #4
0
        internal static CVar Register(CVarAttribute attribute, MemberInfo memberInfo, string value)
        {
            if (attribute.Name == null)
            {
                attribute.Name = memberInfo.Name;
            }

            Native.ConsoleInterop.RegisterCVarString(attribute.Name, value, (string)attribute.DefaultValue ?? string.Empty, attribute.Flags, attribute.Help);

            CVar.CVars.Add
            (
                memberInfo.MemberType == MemberTypes.Field
                                        ? (CVar) new StaticCVarField(attribute, memberInfo as FieldInfo)
                                        : new StaticCVarProperty(attribute, memberInfo as PropertyInfo)
            );

            return(CVars.Last());
        }
예제 #5
0
        internal static CVar Register(CVarAttribute attribute, MemberInfo memberInfo, ref float value)
        {
            if (attribute.Name == null)
            {
                attribute.Name = memberInfo.Name;
            }

            Native.ConsoleInterop.RegisterCVarFloat(attribute.Name, ref value, System.Convert.ToSingle(attribute.DefaultValue), attribute.Flags, attribute.Help);

            CVar.CVars.Add
            (
                memberInfo.MemberType == MemberTypes.Field
                                        ? (CVar) new StaticCVarField(attribute, memberInfo as FieldInfo)
                                        : new StaticCVarProperty(attribute, memberInfo as PropertyInfo)
            );

            return(CVars.Last());
        }
예제 #6
0
파일: CVar.cs 프로젝트: yonder/CryMono
        internal static CVar Register(CVarAttribute attribute, MemberInfo memberInfo, string value)
        {
            if (attribute.Name == null)
            {
                attribute.Name = memberInfo.Name;
            }

            NativeCVarMethods.RegisterCVarString(attribute.Name, value, (string)attribute.DefaultValue ?? string.Empty, attribute.Flags, attribute.Help);

            if (memberInfo.MemberType == MemberTypes.Field)
            {
                CVars.Add(new StaticCVarField(attribute, memberInfo as FieldInfo));
            }
            else
            {
                CVars.Add(new StaticCVarProperty(attribute, memberInfo as PropertyInfo));
            }

            return(CVars.Last());
        }
예제 #7
0
파일: CVar.cs 프로젝트: yonder/CryMono
        internal static CVar Register(CVarAttribute attribute, MemberInfo memberInfo, ref int value)
        {
            if (attribute.Name == null)
            {
                attribute.Name = memberInfo.Name;
            }

            NativeCVarMethods.RegisterCVarInt(attribute.Name, ref value, System.Convert.ToInt32(attribute.DefaultValue), attribute.Flags, attribute.Help);

            if (memberInfo.MemberType == MemberTypes.Field)
            {
                CVars.Add(new StaticCVarField(attribute, memberInfo as FieldInfo));
            }
            else
            {
                CVars.Add(new StaticCVarProperty(attribute, memberInfo as PropertyInfo));
            }

            return(CVars.Last());
        }
예제 #8
0
파일: CVar.cs 프로젝트: yonder/CryMono
        internal static CVar RegisterInternal(string name, object value, string help, CVarFlags flags)
        {
            CVars.Add(new DynamicCVar(name, value, flags, help));

            return(CVars.Last());
        }