Package com.drakulo.games.ais.ui.component.button

Examples of com.drakulo.games.ais.ui.component.button.ImageButton


    this.selectedBuildingPB.setFilledColor(Color.magenta);

    int x = Settings.WIDTH / 2 - ImageButton.IB_DEFAULT_SIZE / 2;
    int y = Settings.HEIGHT - 116 - PADDING - ImageButton.IB_DEFAULT_SIZE
        - PADDING;
    this.developButton = new ImageButton("cog", x, y);
    developButton.setTitle(I18n.get("ui.build_panel"));
    this.developButton.setActionHandler(new ActionHandler() {

      @Override
      public void run() {
        showBuildWindow(!SectorState.this.showActionWindow);
      }
    });
    add(developButton);

    x -= PADDING + ImageButton.IB_DEFAULT_SIZE;
    this.researchVisionButton = new ImageButton("lightbulb", x, y);
    researchVisionButton.setTitle(I18n.get("vision.research"));
    this.researchVisionButton.disable();
    this.researchVisionButton.setActionHandler(new ActionHandler() {

      @Override
      public void run() {
        GameData.getGame().enterState(AloneInSpace.RESEARCH_STATE);
      }
    });
    add(researchVisionButton);

    x -= PADDING + ImageButton.IB_DEFAULT_SIZE;
    this.planetVisionButton = new ImageButton("globe_3", x, y);
    planetVisionButton.setTitle(I18n.get("vision.planet"));
    this.planetVisionButton.disable();
    this.planetVisionButton.setActionHandler(new ActionHandler() {

      @Override
      public void run() {
        SectorState.this.selectedAction = null;
        SectorState.this.selectedBuilding = null;
        GameData.getGame().enterState(AloneInSpace.PLANET_STATE);
      }
    });
    add(planetVisionButton);

    // Cancel button

    final int startX = Settings.WIDTH - Minimap.WIDTH.intValue() - PADDING
        + 10;
    final int startY = Settings.HEIGHT - Minimap.HEIGHT.intValue()
        - PADDING + 9;
    this.buildingButtons = new ImageButton[3][3];
    for (int col = 0; col < 3; col++) {
      for (int row = 0; row < 3; row++) {
        this.buildingButtons[col][row] = new ImageButton(null, startX
            + col * 46, startY + row * 46);
        this.buildingButtons[col][row].disable();
        this.buildingButtons[col][row].hide();

      }
 
View Full Code Here


        int col = 0;
        int row = 0;
        for (String name : data.getSpecialActions()) {
          final ColonyAction sa = SpecialActionManager.get(
              GameData.getSelectedColony(), name);
          ImageButton btn = this.buildingButtons[col][row];
          btn.setImageRef(sa.getGfxKey());
          btn.setActionHandler(new ActionHandler() {

            @Override
            public void run() {
              if (ResourceHelper.enoughResourcesFor(sa
                  .getCostMap())) {
                sa.setLinkedBuilding(SectorState.this.selectedBuilding);
                final Colony cc = GameData.getSelectedColony();
                for (Resource r : Resource.values()) {
                  BigDecimal d = sa.getCostMap().get(r);
                  if (d == null) {
                    continue;
                  }
                  cc.updateResource(r, d.negate());
                }
                GameData.getSelectedColony().addSpecialAction(
                    sa);
              } else {
                // TODO Play error sound
              }
            }
          });
          btn.show();
          if (getSelectedBuildingAction() == null) {
            btn.enable();
          } else {
            btn.disable();
          }
          if (btn.isHovered()) {
            showUpgradeCost(sa.getCostMap(), g, btn);
          }
          col++;
          if (col == 3) {
            col = 0;
View Full Code Here

    int y = initialY;

    // Robots actions
    // Terrabot (terrain preparation)

    Button terrabotButton = new ImageButton("TERRABOT", x, y);
    terrabotButton.disable();
    // TODO why the terrabutton size is fucked?
    terrabotButton.setSize(ImageButton.IB_DEFAULT_SIZE,
        ImageButton.IB_DEFAULT_SIZE);
    terrabotButton.setActionHandler(new ActionHandler() {

      @Override
      public void run() {
        PreparationAction pa = BuildingHelper.create(GameData.getSelectedColony());
        BuildWindowOld.this.parent.setSelectedAction(pa);
        hide();
      }
    });
    terrabotButton.setHoverHandler(new ActionHandler() {

      @Override
      public void run() {
        initMaps();
        BuildWindowOld.this.name = "terrabot";
View Full Code Here

    }

  }

  private Button createBuildingButton(String text, final BuildingType type) {
    ImageButton button = new ImageButton(type.toString());
    button.setActionHandler(new ActionHandler() {

      @Override
      public void run() {
        BuildingAction ba = BuildingHelper.createAction(GameData.getSelectedColony(), type,
            BuildWindowOld.this.cost);
        BuildWindowOld.this.parent.setSelectedAction(ba);
        hide();
      }
    });
    button.setHoverHandler(new ActionHandler() {

      @Override
      public void run() {
        displayBuildingData(type);
      }
    });
    button.disable();
    return button;
  }
View Full Code Here

      i++;
    }

    this.background = ImageManager.getGfx("space_background");

    this.exploreButton = new ImageButton("exploration");
    this.exploreButton.setTitle(I18n.get("planet.explore_sector"));
    this.exploreButton.setActionHandler(new ActionHandler() {

      @Override
      public void run() {
        if (PlanetState.this.selectedColony == null) {
          // TODO play error sound
        } else {
          startZoneSelectionForExploration();
        }
      }
    });
    exploreButton.setHoverHandler(new ActionHandler() {

      @Override
      public void run() {
        // Exploration = 2500 Gas
        Map<Resource, BigDecimal> costMap = new HashMap<Resource, BigDecimal>();
        costMap.put(Resource.GAS, BigDecimal.valueOf(2500));
        resources.setMap(costMap);
        resources.show();
      }
    });
    add(this.exploreButton);

    this.viewButton = new ImageButton("home");
    this.viewButton.setTitle(I18n.get("planet.go_to_colony"));
    this.viewButton.setActionHandler(new ActionHandler() {

      @Override
      public void run() {
        if (PlanetState.this.selectedColony == null) {
          // TODO play error sound

        } else {
          GameData.setSelectedColony(PlanetState.this.selectedColony);
          GameData.getGame().enterState(AloneInSpace.SECTOR_STATE);
        }
      }
    });
    add(this.viewButton);

    this.colonizeButton = new ImageButton("top_right_expand");
    this.colonizeButton.setTitle(I18n.get("planet.colonize"));
    this.colonizeButton.setActionHandler(new ActionHandler() {

      @Override
      public void run() {
        if (PlanetState.this.selectedColony == null) {
          // TODO play error sound

        } else {
          // TODO Externalize
          Map<Resource, BigDecimal> costMap = new HashMap<Resource, BigDecimal>();
          for (Resource r : Resource.values()) {
            costMap.put(r, BigDecimal.valueOf(10000));
          }
          if (ResourceHelper.enoughResourcesFor(costMap)) {
            startZoneSelectionForColonization();
          } else {
            // TODO Play error sound
          }
        }
      }
    });
    this.colonizeButton.setHoverHandler(new ActionHandler() {

      @Override
      public void run() {
        // Colonization = 10.000 each
        Map<Resource, BigDecimal> costMap = new HashMap<Resource, BigDecimal>();
        for (Resource r : Resource.values()) {
          costMap.put(r, BigDecimal.valueOf(10000));
        }
        resources.setMap(costMap);
        resources.show();
      }
    });
    add(this.colonizeButton);


    transferButton = new ImageButton("transfer");
    transferButton.setTitle(I18n.get("planet.transfer"));
    transferButton.setActionHandler(new ActionHandler() {
     
      @Override
      public void run() {
View Full Code Here

      buttons.add(button);
      x += pitch;
    }

    // Terrabot
    ImageButton terrabotButton = new ImageButton("terrabot", x, y);
    terrabotButton.setTitle(I18n.get("terrabot"));
    terrabotButton.disable();
    terrabotButton.setActionHandler(new ActionHandler() {

      @Override
      public void run() {
        PreparationAction pa = BuildingHelper.create(GameData
            .getSelectedColony());
        BuildWindow.this.parent.setSelectedAction(pa);
        hide();
      }
    });
    terrabotButton.setHoverHandler(new ActionHandler() {

      @Override
      public void run() {
        String desc = I18n.get("terrabot.desc");
        Map<Resource, BigDecimal> costMap = new HashMap<Resource, BigDecimal>();
View Full Code Here

    BuildingLevelData data = BuildingIO.getBuildingData(type).getLevelData(
        0);
    final Map<Resource, BigDecimal> costMap = data.getUpgradeCost();

    // Create the button
    ImageButton button = new ImageButton(type.toString());
    button.setTitle(I18n.get(type.getI18n()));
    // Set the build action
    button.setActionHandler(new ActionHandler() {

      @Override
      public void run() {
        BuildingAction ba = BuildingHelper.createAction(
            GameData.getSelectedColony(), type, costMap);
        parent.setSelectedAction(ba);
        hide();
      }
    });
    // Set the hover action
    button.setHoverHandler(new ActionHandler() {

      @Override
      public void run() {
        final String desc = I18n.get(type.getDescI18n());
        displayBuildingData(desc, costMap);
        hoverFlag = true;

        BuildingLevelData data = BuildingIO.getBuildingData(type)
            .getLevelData(0);
        BuildWindow.this.costMap = data.getUpgradeCost();
        earnMap = data.getProduction();
      }
    });
    button.disable();
    button.hide();
    parent.add(button);
    return button;
  }
View Full Code Here

        GameData.getSelectedColony().setResearch(action);
      }
    });
    add(startResearchButton);
    x += ImageButton.IB_DEFAULT_SIZE + padding;
    this.cancelResearchButton = new ImageButton("delete"); // TODO I18N
    this.cancelResearchButton.setPosition(x, y);
    this.cancelResearchButton.disable();
    this.cancelResearchButton.setActionHandler(new ActionHandler() {

      @Override
View Full Code Here

TOP

Related Classes of com.drakulo.games.ais.ui.component.button.ImageButton

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.