Beispiel #1
0
        public Context(IGL gl, IContextInfra infra)
        {
            GL    = gl;
            Infra = infra;
            Caps  = new ContextCaps(gl);

            Create   = new ContextObjectFactory(this);
            Bindings = new ContextBindings(this, Caps);
            States   = new ContextStates(this, Caps);
            Actions  = new ContextActions(this);
        }
Beispiel #2
0
        public Context(IGL gl, IContextInfra infra)
        {
            GL = gl;
            Infra = infra;
            Caps = new ContextCaps(gl);

            Create = new ContextObjectFactory(this);
            Bindings = new ContextBindings(this, Caps);
            States = new ContextStates(this, Caps);
            Actions = new ContextActions(this);
        }
        public void AddContextStateMult <T>(bool global, int numerator, int denominator) where T : ContextMultState
        {
            ContextMultState multState = global ? GlobalContextStates.GetWithDefault <T>() : ContextStates.GetWithDefault <T>();

            if (multState == null)
            {
                T newMult = (T)Activator.CreateInstance(typeof(T));
                newMult.Mult = new Multiplier(numerator, denominator);
                if (global)
                {
                    GlobalContextStates.Set(newMult);
                }
                else
                {
                    ContextStates.Set(newMult);
                }
            }
            else
            {
                multState.Mult.AddMultiplier(numerator, denominator);
            }
        }
        public void AddContextStateInt <T>(bool global, int addedVal) where T : ContextIntState
        {
            ContextIntState countState = global ? GlobalContextStates.GetWithDefault <T>() : ContextStates.GetWithDefault <T>();

            if (countState == null)
            {
                T newCount = (T)Activator.CreateInstance(typeof(T));
                newCount.Count = addedVal;
                if (global)
                {
                    GlobalContextStates.Set(newCount);
                }
                else
                {
                    ContextStates.Set(newCount);
                }
            }
            else
            {
                countState.Count += addedVal;
            }
        }
        public Multiplier GetContextStateMult <T>(bool global, Multiplier defaultVal) where T : ContextMultState
        {
            ContextMultState countState = global ? GlobalContextStates.GetWithDefault <T>() : ContextStates.GetWithDefault <T>();

            if (countState == null)
            {
                return(defaultVal);
            }
            else
            {
                return(countState.Mult);
            }
        }
        public int GetContextStateInt <T>(bool global, int defaultVal) where T : ContextIntState
        {
            ContextIntState countState = global ? GlobalContextStates.GetWithDefault <T>() : ContextStates.GetWithDefault <T>();

            if (countState == null)
            {
                return(defaultVal);
            }
            else
            {
                return(countState.Count);
            }
        }