Exemplo n.º 1
0
 public void setCurrentScreen(final Screen screen) {
   if (screen != null) {
     this.isInstance = false;
     if (currentControl != null) {
       currentControl.destroy();
     }
     this.currentControl = screen;
     currentControl.setLock(false);
     currentControl.setLocation(0, 0);
     currentControl.setClose(false);
     currentControl.setOnLoadState(true);
     if (screen.getBackground() != null) {
       currentControl.setRepaintMode(Screen.SCREEN_BITMAP_REPAINT);
     }
     this.isInstance = true;
     if (screen instanceof EmulatorListener) {
       setEmulatorListener((EmulatorListener) screen);
     } else {
       setEmulatorListener(null);
     }
     this.screens.add(screen);
   }
 }
Exemplo n.º 2
0
  private void setScreen(final Screen screen, boolean put) {
    if (currentControl != null && currentControl.isOnLoadComplete()) {
      return;
    }
    synchronized (this) {
      if (screen == null) {
        this.isInstance = false;
        throw new RuntimeException("Cannot create a [Screen] instance !");
      }
      GLLoader.destory();
      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 {
        synchronized (currentControl) {
          currentControl.destroy();
          currentControl = screen;
        }
      }
      this.isInstance = true;
      if (screen instanceof EmulatorListener) {
        setEmulatorListener((EmulatorListener) screen);
      } else {
        setEmulatorListener(null);
      }

      screen.onCreate(LSystem.screenRect.width, LSystem.screenRect.height);

      Runnable runnable =
          new Runnable() {

            @Override
            public void run() {
              for (; LSystem.isLogo; ) {
                try {
                  Thread.sleep(60);
                } catch (InterruptedException e) {
                }
              }
              startTransition();
              screen.setClose(false);
              screen.onLoad();
              screen.onLoaded();
              screen.setOnLoadState(true);
              endTransition();
            }
          };

      //	LSystem.callScreenRunnable(new Thread(runnable, "ProcessThread"));

      if (put) {
        screens.add(screen);
      }
      loading_Control = null;
    }
  }