Ejemplo n.º 1
0
 private void SetScreen(Screen @screen, bool @put)
 {
     lock (this)
     {
         if (screen == null)
         {
             this.isInstance = false;
             throw new RuntimeException(
                     "Cannot create a [Screen] instance !");
         }
         InitDestory();
         if (!LSystem.isLogo)
         {
             if (currentControl != null)
             {
                 SetTransition(screen.OnTransition());
             }
             else
             {
                 LTransition transition = screen.OnTransition();
                 if (transition == null)
                 {
                     switch (MathUtils.Random(0, 3))
                     {
                         case 0:
                             transition = LTransition.NewFadeIn();
                             break;
                         case 1:
                             transition = LTransition.NewArc();
                             break;
                         case 2:
                             transition = LTransition
                                     .NewSplitRandom(LColor.black);
                             break;
                         case 3:
                             transition = LTransition
                                     .NewCrossRandom(LColor.black);
                             break;
                     }
                 }
                 SetTransition(transition);
             }
         }
         screen.SetOnLoadState(false);
         if (currentControl == null)
         {
             currentControl = screen;
         }
         else
         {
             lock (currentControl)
             {
                 currentControl.Destroy();
                 currentControl = screen;
             }
         }
         this.isInstance = true;
         if (screen is EmulatorListener)
         {
             SetEmulatorListener((EmulatorListener)screen);
         }
         else
         {
             SetEmulatorListener(null);
         }
         StartTransition();
         screen.OnCreate(LSystem.screenRect.width, LSystem.screenRect.height);
         if (!running || GLEx.Device == null || loading_Control != null)
         {
             screen.SetClose(false);
             screen.OnLoad();
             screen.SetOnLoadState(true);
             screen.OnLoaded();
             EndTransition();
         }
         else
         {
             Thread load = null;
             try
             {
                 load = new _LoadingScreen(this, screen);
                 load.Start();
             }
             catch (System.Exception ex)
             {
                 throw new RuntimeException(currentControl.GetName()
                         + " onLoad:" + ex.Message);
             }
             finally
             {
                 load = null;
             }
         }
         if (screen != null)
         {
             if (screen is LFlickerListener)
             {
                 if (currentInput != null)
                 {
                     currentInput.Flicker = (LFlickerListener)screen;
                 }
             }
         }
         if (put)
         {
             screens.AddLast(screen);
         }
         loading_Control = null;
         Thread.Yield();
     }
 }
Ejemplo n.º 2
0
        private void SetScreen(Screen @screen, bool @put)
        {
            lock (this)
            {
                if (screen == null)
                {
                    this.isInstance = false;
                    throw new RuntimeException(
                              "Cannot create a [Screen] instance !");
                }
                InitDestory();
                if (!LSystem.isLogo)
                {
                    if (currentControl != null)
                    {
                        SetTransition(screen.OnTransition());
                    }
                    else
                    {
                        LTransition transition = screen.OnTransition();
                        if (transition == null)
                        {
                            switch (MathUtils.Random(0, 3))
                            {
                            case 0:
                                transition = LTransition.NewFadeIn();
                                break;

                            case 1:
                                transition = LTransition.NewArc();
                                break;

                            case 2:
                                transition = LTransition
                                             .NewSplitRandom(LColor.black);
                                break;

                            case 3:
                                transition = LTransition
                                             .NewCrossRandom(LColor.black);
                                break;
                            }
                        }
                        SetTransition(transition);
                    }
                }
                screen.SetOnLoadState(false);
                if (currentControl == null)
                {
                    currentControl = screen;
                }
                else
                {
                    lock (currentControl)
                    {
                        currentControl.Destroy();
                        currentControl = screen;
                    }
                }
                this.isInstance = true;
                if (screen is EmulatorListener)
                {
                    SetEmulatorListener((EmulatorListener)screen);
                }
                else
                {
                    SetEmulatorListener(null);
                }
                StartTransition();
                screen.OnCreate(LSystem.screenRect.width, LSystem.screenRect.height);
                if (!running || GLEx.Device == null || loading_Control != null)
                {
                    screen.SetClose(false);
                    screen.OnLoad();
                    screen.SetOnLoadState(true);
                    screen.OnLoaded();
                    EndTransition();
                }
                else
                {
                    Thread load = null;
                    try
                    {
                        load = new _LoadingScreen(this, screen);
                        load.Start();
                    }
                    catch (System.Exception ex)
                    {
                        throw new RuntimeException(currentControl.GetName()
                                                   + " onLoad:" + ex.Message);
                    }
                    finally
                    {
                        load = null;
                    }
                }
                if (screen != null)
                {
                    if (screen is LFlickerListener)
                    {
                        if (currentInput != null)
                        {
                            currentInput.Flicker = (LFlickerListener)screen;
                        }
                    }
                }
                if (put)
                {
                    screens.AddLast(screen);
                }
                loading_Control = null;
                Thread.Yield();
            }
        }