Beispiel #1
0
  @SuppressWarnings("rawtypes")
  public GuiAtlas() {
    setSize(WIDTH, HEIGHT);
    setMapScale(0.5);
    followPlayer = true;
    setInterceptKeyboard(false);

    btnUp = GuiArrowButton.up();
    addChild(btnUp).offsetGuiCoords(148, 10);
    btnDown = GuiArrowButton.down();
    addChild(btnDown).offsetGuiCoords(148, 194);
    btnLeft = GuiArrowButton.left();
    addChild(btnLeft).offsetGuiCoords(15, 100);
    btnRight = GuiArrowButton.right();
    addChild(btnRight).offsetGuiCoords(283, 100);
    btnPosition = new GuiPositionButton();
    btnPosition.setEnabled(!followPlayer);
    addChild(btnPosition).offsetGuiCoords(283, 194);
    IButtonListener positionListener =
        new IButtonListener() {
          @Override
          public void onClick(GuiComponentButton button) {
            selectedButton = button;
            if (button.equals(btnPosition)) {
              followPlayer = true;
              btnPosition.setEnabled(false);
            } else {
              // Navigate once, before enabling pause:
              navigateByButton(selectedButton);
              timeButtonPressed = player.worldObj.getTotalWorldTime();
            }
          }
        };
    btnUp.addListener(positionListener);
    btnDown.addListener(positionListener);
    btnLeft.addListener(positionListener);
    btnRight.addListener(positionListener);
    btnPosition.addListener(positionListener);

    btnExportPng =
        new GuiBookmarkButton(1, Textures.ICON_EXPORT, I18n.format("gui.antiqueatlas.exportImage"));
    addChild(btnExportPng).offsetGuiCoords(300, 75);
    btnExportPng.addListener(
        new IButtonListener<GuiBookmarkButton>() {
          @Override
          public void onClick(GuiBookmarkButton button) {
            progressBar.reset();
            if (stack != null) {
              new Thread(
                      new Runnable() {
                        @Override
                        public void run() {
                          exportImage(stack.copy());
                        }
                      })
                  .start();
            }
          }
        });

    btnMarker =
        new GuiBookmarkButton(
            0, Textures.ICON_ADD_MARKER, I18n.format("gui.antiqueatlas.addMarker"));
    addChild(btnMarker).offsetGuiCoords(300, 14);
    btnMarker.addListener(
        new IButtonListener() {
          @Override
          public void onClick(GuiComponentButton button) {
            if (stack != null) {
              if (state.is(PLACING_MARKER)) {
                selectedButton = null;
                state.switchTo(NORMAL);
              } else {
                selectedButton = button;
                state.switchTo(PLACING_MARKER);
              }
            }
          }
        });
    btnDelMarker =
        new GuiBookmarkButton(
            2, Textures.ICON_DELETE_MARKER, I18n.format("gui.antiqueatlas.delMarker"));
    addChild(btnDelMarker).offsetGuiCoords(300, 33);
    btnDelMarker.addListener(
        new IButtonListener() {
          @Override
          public void onClick(GuiComponentButton button) {
            if (stack != null) {
              if (state.is(DELETING_MARKER)) {
                selectedButton = null;
                state.switchTo(NORMAL);
              } else {
                selectedButton = button;
                state.switchTo(DELETING_MARKER);
              }
            }
          }
        });
    btnShowMarkers =
        new GuiBookmarkButton(
            3, Textures.ICON_HIDE_MARKERS, I18n.format("gui.antiqueatlas.hideMarkers"));
    addChild(btnShowMarkers).offsetGuiCoords(300, 52);
    btnShowMarkers.addListener(
        new IButtonListener() {
          @Override
          public void onClick(GuiComponentButton button) {
            if (stack != null) {
              selectedButton = null;
              state.switchTo(state.is(HIDING_MARKERS) ? NORMAL : HIDING_MARKERS);
            }
          }
        });

    addChild(scaleBar).offsetGuiCoords(20, 198);
    scaleBar.setMapScale(1);

    markerFinalizer.addListener(blinkingIcon);

    eraser.setTexture(Textures.ERASER, 12, 14, 2, 11);
  }