Inheritance: idWindowVariable
Esempio n. 1
0
        private static void Script_Transition(idWindow window, List <idWinGuiScript> source)
        {
            // transitions always affect rect or vec4 vars
            if (source.Count >= 4)
            {
                idWinRectangle rect = null;
                idWinVector4   vec4 = source[0].Variable as idWinVector4;

                //
                //  added float variable
                idWinFloat val = null;
                //
                if (vec4 == null)
                {
                    rect = source[0].Variable as idWinRectangle;
                    //
                    //  added float variable
                    if (rect == null)
                    {
                        val = source[0].Variable as idWinFloat;
                    }
                    //
                }

                idWinVector4 from    = source[1].Variable as idWinVector4;
                idWinVector4 to      = source[2].Variable as idWinVector4;
                idWinString  timeStr = source[3].Variable as idWinString;
                //
                //  added float variable
                if (((vec4 == null) && (rect == null) && (val == null)) && (from != null) && (to != null) && (timeStr != null))
                {
                    idConsole.Warning("Bad transition in gui {0} in window {1}", window.UserInterface.SourceFile, window.Name);
                }
                else
                {
                    int time;
                    int.TryParse(timeStr.ToString(), out time);

                    float accel = 0.0f;
                    float decel = 0.0f;

                    if (source.Count > 4)
                    {
                        idWinString accelStr = source[4].Variable as idWinString;
                        idWinString decelStr = source[5].Variable as idWinString;

                        float.TryParse(accelStr.ToString(), out accel);
                        float.TryParse(decelStr.ToString(), out decel);
                    }

                    if (vec4 != null)
                    {
                        vec4.Evaluate = false;
                        window.AddTransition(vec4, from, to, time, accel, decel);
                    }
                    else if (val != null)
                    {
                        val.Evaluate = false;
                        window.AddTransition(val, from, to, time, accel, decel);
                    }
                    else
                    {
                        rect.Evaluate = false;
                        window.AddTransition(rect, from, to, time, accel, decel);
                    }

                    window.StartTransition();
                }
            }
        }