public MyViewController() {
        // Get the view of this view controller.
        UIView view = getView();

        // Setup background.
        view.setBackgroundColor(UIColor.white());

        // Setup label.
        label = new UILabel(new CGRect(20, 250, 280, 44));
        label.setFont(UIFont.getSystemFont(24));
        label.setTextAlignment(NSTextAlignment.Center);
        view.addSubview(label);

        // Setup button.
        button = UIButton.create(UIButtonType.RoundedRect);
        button.setFrame(new CGRect(110, 150, 100, 40));
        button.setTitle("Click me!", UIControlState.Normal);
        button.getTitleLabel().setFont(UIFont.getBoldSystemFont(22));

        button.addOnTouchUpInsideListener(new UIControl.OnTouchUpInsideListener() {
            @Override
            public void onTouchUpInside (UIControl control, UIEvent event) {
                label.setText("Click Nr. " + (++clickCount));
            }
        });
        view.addSubview(button);
    }
Esempio n. 2
0
 void updateText(int state) {
   if (!states.isInState(state)) return;
   if (title != null) {
     title.setText(states.getTitle());
     if (states.getTitlecolor() != null) title.setTextColor(states.getTitlecolor());
     if (states.getShadowColor() != null) title.setShadowColor(states.getShadowColor());
   }
 }
Esempio n. 3
0
  public boolean keyPressed(int key) {
    int ga = UICanvas.getInstance().getGameAction(key);
    boolean keepSelection = false;
    if (ga == Canvas.FIRE && this.selectedIndex >= 0
    //				&& this.chechedIndex != selectedIndex
    ) {
      if (this.chechedIndex >= 0) {
        UILabel ulbOld = (UILabel) this.layoutItems[this.chechedIndex];
        ulbOld.img = UICanvas.getUIImage("/icons/radio_unchecked.png");
        ulbOld.setDirty(true);
      }

      this.chechedIndex = this.selectedIndex;
      UILabel ulb = (UILabel) this.layoutItems[this.chechedIndex];
      ulb.img = UICanvas.getUIImage("/icons/radio_checked.png");
      ulb.setSelected(true);
      this.setDirty(true);
      this.askRepaint();
      keepSelection = true;
    }
    keepSelection |= super.keyPressed(key);
    // we must save the last selectedIndex
    // when loosing focus
    if (keepSelection == false) {
      if (selectedIndex >= 0) {
        UILabel ulbOld = (UILabel) this.layoutItems[this.selectedIndex];
        ulbOld.setSelected(false);
        ulbOld.setDirty(true);
        this.setDirty(true);
        this.askRepaint();
      }
      this.selectedIndex = this.chechedIndex;
    }
    return keepSelection;
  }
Esempio n. 4
0
 private void resetInput() {
   // clear the textbowes
   txtzonename.setText("");
   txtheight.setText("");
   txtwidth.setText("");
   txtdepth.setText("");
   lblzonetype.setText("");
   lblError.setText("");
   newzonefound = false;
   btnSave.setVisible(false);
   btnDelete.setVisible(false);
 }
Esempio n. 5
0
 float getPrefferedWidth() {
   xm_model().measure(0, 0);
   int max = xm_model().getMeasuredWidth();
   if (title != null) {
     title.xm_model().measure(0, 0);
     max = Math.max(max, title.xm_model().getMeasuredWidth() + 16);
   }
   if (fore != null) {
     fore.xm_model().measure(0, 0);
     max = Math.max(max, fore.xm_model().getMeasuredWidth());
   }
   return IOSView.x2IOS(max);
 }
Esempio n. 6
0
 public UIRadioButtons(String[] stringItems) {
   super(stringItems.length, 0);
   int buttonNumber = stringItems.length;
   for (int i = 0; i < buttonNumber; i++) {
     Image img =
         (i == 0
             ? UICanvas.getUIImage("/icons/radio_checked.png")
             : UICanvas.getUIImage("/icons/radio_unchecked.png"));
     UILabel ulb = new UIRadioButton(img, stringItems[i]);
     ulb.setFocusable(true);
     this.insert(ulb, i, 100 / buttonNumber, UILayout.CONSTRAINT_PERCENTUAL);
   }
   this.focusable = true;
 }
Esempio n. 7
0
  private void initText() {
    if (title == null) {
      title = new UILabel();
      title.setBackgroundColor(UIColor.clearColor);
      title.setTextAlignment(UITextAlignment.Center);
      title.setFont(BUTTONFONT);
      CGSize size = getFrame().size;
      title.setFrame(new CGRect(0, 0, size.width, size.height));

      addSubview(title);
      if (fore != null) { // Fix Z-order
        fore.removeFromSuperview();
        addSubview(fore);
      }
    }
  }
Esempio n. 8
0
 @Override
 public void setFrame(CGRect frame) {
   super.setFrame(frame);
   frame.origin.x = 0;
   frame.origin.y = 0;
   if (title != null) title.setFrame(frame);
   if (fore != null) fore.setFrame(frame);
 }
Esempio n. 9
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);
    }
  }
Esempio n. 10
0
  public UIScreenBookOreo() {
    setId("oreobook");
    setHorizontalAlign(EHorizontalAlign.LEFT);
    setVerticalAlign(EVerticalAlign.CENTER);
    setModal(true);
    // setCloseBinds(new String[]{"engine:useHeldItem"});
    setCloseKeys(new int[] {Keyboard.KEY_ESCAPE});
    setSize(new Vector2f(800, 400));

    background = new UIImage();
    background.setTexture(Assets.getTexture("miniion:openbook"));
    background.setPosition(new Vector2f(0, 0));
    background.setSize(new Vector2f(600, 400));
    background.setVisible(true);
    addDisplayElement(background);

    pagetitle = new UILabel("Summoned minions");
    pagetitle.setPosition(new Vector2f(50, 20));
    pagetitle.setColor(org.newdawn.slick.Color.black);
    pagetitle.setVisible(true);
    addDisplayElement(pagetitle);

    pagetitle2 = new UILabel("Active minion");
    pagetitle2.setPosition(new Vector2f(340, 20));
    pagetitle2.setColor(org.newdawn.slick.Color.black);
    pagetitle2.setVisible(true);
    addDisplayElement(pagetitle2);

    uiminionlist = new UIList();
    uiminionlist.setSize(new Vector2f(250, 350));
    uiminionlist.setPosition(new Vector2f(45, 40));
    uiminionlist.setVisible(true);
    addDisplayElement(uiminionlist);

    selected = new UISelectedMinion(this);
    selected.setPosition(new Vector2f(310, 40));
    selected.setSize(new Vector2f(250, 170));
    selected.setVisible(true);
    addDisplayElement(selected);

    btnshowminion = new UIModButton(new Vector2f(100, 20), ButtonType.NORMAL);
    btnshowminion.setLabel("Show minion window");
    btnshowminion.setColorOffset(120);
    btnshowminion.setVisible(true);
    btnshowminion.setPosition(new Vector2f(375, 260));
    btnshowminion.addClickListener(
        new ClickListener() {
          @Override
          public void click(UIDisplayElement element, int button) {
            if (btnshowminion.getLabel().getText() == "Show minion window") {
              btnshowminion.setLabel("Hide minion minion");
            } else {
              btnshowminion.setLabel("Show minion window");
            }
          }
        });
    this.addDisplayElement(btnshowminion);
  }
Esempio n. 11
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;
 }
Esempio n. 12
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();
  }
Esempio n. 13
0
  public UIZoneBook() {

    setId("zonebook");
    setModal(true);
    maximize();
    setCloseKeys(new int[] {Keyboard.KEY_ESCAPE});

    background = new UIImage();
    background.setTexture(Assets.getTexture("miniion:openbook"));
    background.setHorizontalAlign(EHorizontalAlign.CENTER);
    background.setVerticalAlign(EVerticalAlign.CENTER);
    background.setSize(new Vector2f(500, 300));
    background.setVisible(true);
    addDisplayElement(background);

    uizonelist = new UIList();
    uizonelist.setSize(new Vector2f(200, 220));
    uizonelist.setPosition(new Vector2f(40, 20));
    uizonelist.setVisible(true);
    background.addDisplayElement(uizonelist);

    uizonelistgroup = new UIList();
    uizonelistgroup.setSize(new Vector2f(200, 250));
    uizonelistgroup.setPosition(new Vector2f(40, 20));
    uizonelistgroup.setVisible(true);
    background.addDisplayElement(uizonelistgroup);

    lblzonename = new UILabel("Zone name :");
    lblzonename.setPosition(new Vector2f(260, 20));
    lblzonename.setColor(Color.black);
    lblzonename.setVisible(true);
    background.addDisplayElement(lblzonename);

    txtzonename = new UIText();
    txtzonename.setPosition(new Vector2f(350, 20));
    txtzonename.setColor(Color.black);
    txtzonename.setSize(new Vector2f(80, 20));
    txtzonename.setVisible(true);
    background.addDisplayElement(txtzonename);

    lblheight = new UILabel("Height :");
    lblheight.setPosition(new Vector2f(260, 40));
    lblheight.setColor(Color.black);
    lblheight.setVisible(true);
    background.addDisplayElement(lblheight);

    txtheight = new UIText();
    txtheight.setPosition(new Vector2f(350, 40));
    txtheight.setColor(Color.black);
    txtheight.setSize(new Vector2f(80, 20));
    txtheight.setVisible(true);
    background.addDisplayElement(txtheight);

    lblwidth = new UILabel("Width :");
    lblwidth.setPosition(new Vector2f(260, 60));
    lblwidth.setColor(Color.black);
    lblwidth.setVisible(true);
    background.addDisplayElement(lblwidth);

    txtwidth = new UIText();
    txtwidth.setPosition(new Vector2f(350, 60));
    txtwidth.setColor(Color.black);
    txtwidth.setSize(new Vector2f(80, 20));
    txtwidth.setVisible(true);
    background.addDisplayElement(txtwidth);

    lbldepth = new UILabel("Depth :");
    lbldepth.setPosition(new Vector2f(260, 80));
    lbldepth.setColor(Color.black);
    lbldepth.setVisible(true);
    background.addDisplayElement(lbldepth);

    txtdepth = new UIText();
    txtdepth.setPosition(new Vector2f(350, 80));
    txtdepth.setColor(Color.black);
    txtdepth.setSize(new Vector2f(80, 20));
    txtdepth.setVisible(true);
    background.addDisplayElement(txtdepth);

    lblzonetype = new UILabel("");
    lblzonetype.setPosition(new Vector2f(260, 100));
    lblzonetype.setColor(Color.black);
    lblzonetype.setVisible(true);
    background.addDisplayElement(lblzonetype);

    cmbType = new UIComboBox(new Vector2f(80, 20), new Vector2f(80, 200));
    cmbType.setPosition(new Vector2f(350, 100));
    cmbType.setVisible(false);
    background.addDisplayElement(cmbType);
    initTypes();

    lblError = new UILabel("");
    lblError.setWrap(true);
    lblError.setSize(new Vector2f(200, 80));
    lblError.setPosition(new Vector2f(260, 130));
    lblError.setColor(Color.red);
    lblError.setVisible(true);
    background.addDisplayElement(lblError);

    btnSave = new UIModButton(new Vector2f(50, 20), ButtonType.NORMAL);
    btnSave.setPosition(new Vector2f(260, 230));
    btnSave.setLabel("Save");
    btnSave.setId("btnSave");
    btnSave.setVisible(true);
    btnSave.addClickListener(
        new ClickListener() {
          @Override
          public void click(UIDisplayElement element, int button) {
            executeClick(element, button);
          }
        });
    background.addDisplayElement(btnSave);

    btnDelete = new UIModButton(new Vector2f(50, 20), ButtonType.NORMAL);
    btnDelete.setPosition(new Vector2f(260, 230));
    btnDelete.setLabel("Delete");
    btnDelete.setId("btnDelZone");
    btnDelete.setVisible(false);
    btnDelete.addClickListener(
        new ClickListener() {
          @Override
          public void click(UIDisplayElement element, int button) {
            executeDelClick(element, button, (Zone) uizonelist.getSelection().getValue());
          }
        });
    background.addDisplayElement(btnDelete);

    btnBack = new UIModButton(new Vector2f(50, 20), ButtonType.NORMAL);
    btnBack.setPosition(new Vector2f(40, 240));
    btnBack.setLabel("Back");
    btnBack.setId("btnBack");
    btnBack.setVisible(false);
    btnBack.addClickListener(
        new ClickListener() {
          @Override
          public void click(UIDisplayElement element, int button) {
            initList();
            btnBack.setVisible(false);
          }
        });
    background.addDisplayElement(btnBack);
  }
Esempio n. 14
0
 public void setFont(UIFont font) {
   initText();
   title.setFont(font);
 }
Esempio n. 15
0
 public CGSize getTitleShadowOffset() {
   initText();
   return title.getShadowOffset();
 }
Esempio n. 16
0
 public void setTitleShadowOffset(CGSize titleShadowOffset) {
   initText();
   title.setShadowOffset(titleShadowOffset);
 }
Esempio n. 17
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);
          }
        }
Esempio n. 18
0
 public UIFont getFont() {
   initText();
   return title.getFont();
 }