Exemplo n.º 1
0
 private void executeDelClick(UIDisplayElement element, int id, Zone deletezone) {
   switch (deletezone.zonetype) {
     case Gather:
       {
         MinionSystem.getGatherZoneList().remove(deletezone);
         break;
       }
     case Work:
       {
         MinionSystem.getWorkZoneList().remove(deletezone);
         break;
       }
     case Terraform:
       {
         MinionSystem.getTerraformZoneList().remove(deletezone);
         break;
       }
     case Storage:
       {
         MinionSystem.getStorageZoneList().remove(deletezone);
         break;
       }
     case OreonFarm:
       {
         MinionSystem.getOreonFarmZoneList().remove(deletezone);
         break;
       }
   }
   fillUI();
 }
Exemplo n.º 2
0
 private boolean checkSingleZone() {
   WorldProvider worldprovider = CoreRegistry.get(WorldProvider.class);
   Block block = worldprovider.getBlock(MinionSystem.getNewZone().getStartPosition());
   if (block.getURI().getFamily().matches("minionbench")) {
     MinionSystem.getNewZone().zonetype = ZoneType.Work;
     if (MinionSystem.getWorkZoneList() == null) {
       txtzonename.setText("Workzone0");
     } else {
       txtzonename.setText("Workzone" + MinionSystem.getWorkZoneList().size());
     }
     lblzonetype.setText("ZoneType : Workzone");
     newzonefound = true;
   } else if (block.getURI().getFamily().matches("chest")) {
     MinionSystem.getNewZone().zonetype = ZoneType.Storage;
     if (MinionSystem.getWorkZoneList() == null) {
       txtzonename.setText("Storage0");
     } else {
       txtzonename.setText("Storage" + MinionSystem.getWorkZoneList().size());
     }
     lblzonetype.setText("ZoneType : Storage");
     newzonefound = true;
   }
   return newzonefound;
 }
Exemplo n.º 3
0
        @Override
        public void click(UIDisplayElement element, int button) {
          UIListItem listitem = (UIListItem) element;
          if (listitem.getValue().getClass().equals(ZoneType.class)) {
            switch (((ZoneType) listitem.getValue())) {
              case Gather:
                {
                  uizonelist.removeAll();
                  for (Zone zone : MinionSystem.getGatherZoneList()) {
                    UIListItem newlistitem = new UIListItem(zone.Name, zone);
                    newlistitem.setTextColor(Color.black);
                    newlistitem.addClickListener(zonelistener);
                    uizonelist.addItem(newlistitem);
                  }
                  uizonelistgroup.setVisible(false);
                  uizonelist.setVisible(true);
                  btnBack.setVisible(true);
                  break;
                }
              case Terraform:
                {
                  uizonelist.removeAll();
                  for (Zone zone : MinionSystem.getTerraformZoneList()) {
                    UIListItem newlistitem = new UIListItem(zone.Name, zone);
                    newlistitem.setTextColor(Color.black);
                    newlistitem.addClickListener(zonelistener);
                    uizonelist.addItem(newlistitem);
                  }
                  uizonelistgroup.setVisible(false);
                  uizonelist.setVisible(true);
                  btnBack.setVisible(true);
                  break;
                }
              case Work:
                {
                  uizonelist.removeAll();
                  for (Zone zone : MinionSystem.getWorkZoneList()) {
                    UIListItem newlistitem = new UIListItem(zone.Name, zone);
                    newlistitem.setTextColor(Color.black);
                    newlistitem.addClickListener(zonelistener);
                    uizonelist.addItem(newlistitem);
                  }
                  uizonelistgroup.setVisible(false);
                  uizonelist.setVisible(true);
                  btnBack.setVisible(true);
                  break;
                }
              case Storage:
                {
                  uizonelist.removeAll();
                  for (Zone zone : MinionSystem.getStorageZoneList()) {
                    UIListItem newlistitem = new UIListItem(zone.Name, zone);
                    newlistitem.setTextColor(Color.black);
                    newlistitem.addClickListener(zonelistener);
                    uizonelist.addItem(newlistitem);
                  }
                  uizonelistgroup.setVisible(false);
                  uizonelist.setVisible(true);
                  btnBack.setVisible(true);
                  break;
                }
              case OreonFarm:
                {
                  uizonelist.removeAll();
                  for (Zone zone : MinionSystem.getOreonFarmZoneList()) {
                    UIListItem newlistitem = new UIListItem(zone.Name, zone);
                    newlistitem.setTextColor(Color.black);
                    newlistitem.addClickListener(zonelistener);
                    uizonelist.addItem(newlistitem);
                  }
                  uizonelistgroup.setVisible(false);
                  uizonelist.setVisible(true);
                  btnBack.setVisible(true);
                  break;
                }
              default:
                {
                  break;
                }
            }
          } else {
            if (cmbType.isVisible()) {
              cmbType.setVisible(false);
            }
            lblError.setText("");
            Zone zone = (Zone) listitem.getValue();
            txtzonename.setText(zone.Name);
            txtheight.setText("" + zone.zoneheight);
            txtwidth.setText("" + zone.zonewidth);
            txtdepth.setText("" + zone.zonedepth);
            switch (zone.zonetype) {
              case Gather:
                {
                  lblzonetype.setText("Zonetype : Gather");
                  break;
                }
              case Terraform:
                {
                  lblzonetype.setText("Zonetype : Terraform");
                  break;
                }
              case Work:
                {
                  lblzonetype.setText("Zonetype : Work");
                  break;
                }
              default:
                {
                  lblzonetype.setText("label wasn't set");
                  break;
                }
            }

            btnSave.setVisible(false);
            btnDelete.setVisible(true);
          }
        }
Exemplo n.º 4
0
  private void fillUI() {
    initList();
    resetInput();

    if (MinionSystem.getNewZone() != null && MinionSystem.getNewZone().getEndPosition() == null) {
      if (checkSingleZone()) {
        Vector3i minbounds = MinionSystem.getNewZone().getMinBounds();
        Vector3i maxbounds = MinionSystem.getNewZone().getMaxBounds();
        txtwidth.setText("1");
        txtdepth.setText("1");
        txtheight.setText("1");
      }
    } else if (MinionSystem.getNewZone() != null
        && MinionSystem.getNewZone().getEndPosition() != null) {
      newzonefound = true;
      MinionSystem.getNewZone().zonetype = ZoneType.Gather;

      Vector3i minbounds = MinionSystem.getNewZone().getMinBounds();
      Vector3i maxbounds = MinionSystem.getNewZone().getMaxBounds();
      if (MinionSystem.getGatherZoneList() == null) {
        txtzonename.setText("Zone0");
      } else {
        txtzonename.setText(
            "Zone"
                + (MinionSystem.getGatherZoneList().size()
                    + MinionSystem.getTerraformZoneList().size()));
      }
      lblzonetype.setText("ZoneType :");
      cmbType.setVisible(true);
      txtwidth.setText("" + (getAbsoluteDiff(maxbounds.x, minbounds.x)));
      txtdepth.setText("" + (getAbsoluteDiff(maxbounds.z, minbounds.z)));
      txtheight.setText("" + (getAbsoluteDiff(maxbounds.y, minbounds.y)));
    }
    if (newzonefound) {
      if (MinionSystem.getNewZone().outofboundselection()) {
        btnSave.setVisible(true);
        lblError.setText(
            "The zone is to big to be saved, depth, width, height should not exceed 50");
      } else {
        btnSave.setVisible(true);
      }
      btnDelete.setVisible(false);
    }
  }
Exemplo n.º 5
0
  private void executeClick(UIDisplayElement element, int id) {
    lblError.setText("");
    if (MinionSystem.getNewZone() == null) {
      newzonefound = false;
      MinionSystem.resetNewSelection();
      lblError.setText("Something went wrong. Please close the book and recreate the selection.");
    }
    if (MinionSystem.getNewZone().zonetype == ZoneType.OreonFarm) {
      if (MinionSystem.getNewZone().getEndPosition() == null) {
        newzonefound = false;
        MinionSystem.resetNewSelection();
        lblError.setText("Something went wrong. Please close the book and recreate the selection.");
      } else {

      }
    }
    if ((!cmbType.isVisible()) && MinionSystem.getNewZone() == null) {
      newzonefound = false;
      this.close();
    }
    if (cmbType.isVisible() && cmbType.getSelection() == null) {
      lblError.setText("Please select a zone type");
      return;
    }
    if (cmbType.isVisible() && cmbType.getSelection() != null) {
      if (ZoneType.valueOf(cmbType.getSelection().getText()) == ZoneType.OreonFarm) {
        if (MinionSystem.getNewZone().getMinBounds().y
            != MinionSystem.getNewZone().getMaxBounds().y) {
          newzonefound = false;
          lblError.setText(
              "A farm zone needs to be level. Please select a flat zone and try again");
          return;
        }
      }
    }
    if (txtzonename.getText().length() < 3) {
      lblError.setText("Zone name needs to be longer then 2 characters!");
      return;
    }
    for (Zone zone : MinionSystem.getGatherZoneList()) {
      if (zone.Name.matches(txtzonename.getText())) {
        lblError.setText("Zone name already exists!");
        return;
      }
    }
    for (Zone zone : MinionSystem.getTerraformZoneList()) {
      if (zone.Name.matches(txtzonename.getText())) {
        lblError.setText("Zone name already exists!");
        return;
      }
    }
    for (Zone zone : MinionSystem.getWorkZoneList()) {
      if (zone.Name.matches(txtzonename.getText())) {
        lblError.setText("Zone name already exists!");
        return;
      }
    }
    int tmp;
    try {
      tmp = Integer.parseInt(txtheight.getText());
      tmp = Integer.parseInt(txtwidth.getText());
      tmp = Integer.parseInt(txtdepth.getText());
      lblError.setText("value needs to be an number, check for trailing spaces!");
    } catch (NumberFormatException e) {
      return;
    }
    Zone newzone =
        new Zone(
            MinionSystem.getNewZone().getStartPosition(),
            MinionSystem.getNewZone().getEndPosition());
    newzone.Name = txtzonename.getText();
    newzone.zoneheight = Integer.parseInt(txtheight.getText());
    newzone.zonewidth = Integer.parseInt(txtwidth.getText());
    newzone.zonedepth = Integer.parseInt(txtdepth.getText());
    if (cmbType.isVisible()) {
      newzone.zonetype = ZoneType.valueOf(cmbType.getSelection().getText());
    } else {
      newzone.zonetype = MinionSystem.getNewZone().zonetype;
    }
    MinionSystem.addZone(newzone);
    newzonefound = false;
    lblzonetype.setText("");
    MinionSystem.resetNewSelection();
    this.close();
  }