Пример #1
0
  public void Make(AbstractMTApplication mtApplication, String name) {
    /// Create map provider menu \\\
    IFont font =
        FontManager.getInstance()
            .createFont(mtApplication, "SansSerif.Bold", 15, MTColor.WHITE, MTColor.WHITE);
    MTRoundRectangle mapMenu = new MTRoundRectangle(0, 0, 0, 220, 335, 20, 20, mtApplication);
    mapMenu.setFillColor(new MTColor(35, 35, 35, 180));
    mapMenu.setStrokeColor(new MTColor(35, 35, 35, 180));
    mapMenu.setPositionGlobal(new Vector3D(mtApplication.width / 2f, mtApplication.height / 2f));
    mapMenu.translateGlobal(new Vector3D(-mtApplication.width / 2f - 80, 0));
    MTRectangle drawing = new MTRectangle(0, 0, 200, 200, mtApplication);
    StartTiamat.general.addChild(mapMenu);
    System.out.println("added menu");
    float cellWidth = 155;
    float cellHeight = 40;
    MTColor cellFillColor = new MTColor(new MTColor(0, 0, 0, 210));
    MTColor cellPressedFillColor = new MTColor(new MTColor(20, 20, 20, 220));
    MTList list = new MTList(0, 0, 152, 4 * cellHeight + 4 * 3, mtApplication);
    list.setChildClip(null);
    list.setNoFill(true);
    list.setNoStroke(true);
    list.unregisterAllInputProcessors();
    list.setAnchor(PositionAnchor.CENTER);
    list.setPositionRelativeToParent(mapMenu.getCenterPointLocal());
    mapMenu.addChild(list);

    for (int i = 0; i < StartTiamat.functions.size(); i++) {
      Tiamat.Templates template = StartTiamat.functions.get(i);
      list.addListElement(
          this.createListCell(
              mtApplication,
              template.getName(),
              template.getFunction(),
              font,
              cellWidth,
              cellHeight,
              cellFillColor,
              cellPressedFillColor));
    }
    ;
    MultiPurposeInterpolator in = new MultiPurposeInterpolator(0, 170, 700, 0.1f, 0.7f, 1);
    final Animation slideOut = new Animation("slide out animation", in, mapMenu);
    slideOut.addAnimationListener(
        new IAnimationListener() {
          public void processAnimationEvent(AnimationEvent ae) {
            float delta = ae.getCurrentStepDelta();
            ((IMTComponent3D) ae.getTargetObject()).translateGlobal(new Vector3D(delta, 0, 0));
            switch (ae.getId()) {
              case AnimationEvent.ANIMATION_ENDED:
                doSlideIn = true;
                animationRunning = false;
                break;
            }
          }
        });

    final Animation slideIn = new Animation("slide out animation", in, mapMenu);
    slideIn.addAnimationListener(
        new IAnimationListener() {
          public void processAnimationEvent(AnimationEvent ae) {
            float delta = -ae.getCurrentStepDelta();
            ((IMTComponent3D) ae.getTargetObject()).translateGlobal(new Vector3D(delta, 0, 0));
            switch (ae.getId()) {
              case AnimationEvent.ANIMATION_ENDED:
                doSlideIn = false;
                animationRunning = false;
                break;
            }
          }
        });

    mapMenu.unregisterAllInputProcessors();
    mapMenu.registerInputProcessor(new TapProcessor(mtApplication, 50));
    mapMenu.addGestureListener(
        TapProcessor.class,
        new IGestureEventListener() {
          public boolean processGestureEvent(MTGestureEvent ge) {
            if (((TapEvent) ge).getTapID() == TapEvent.BUTTON_CLICKED) {
              if (!animationRunning) {
                animationRunning = true;
                if (doSlideIn) {
                  slideIn.start();
                } else {
                  slideOut.start();
                }
              }
            }
            return false;
          }
        });
  }