private void modifyMoveEffect(
     final EffectEventId effectEventId, final Element element, final String direction) {
   List<Effect> moveEffects =
       element.findElementByName("#effectPanel").getEffects(effectEventId, Move.class);
   if (!moveEffects.isEmpty()) {
     moveEffects.get(0).getParameters().put("direction", direction);
   }
 }
 public void bind(
     Nifty nifty,
     Screen screen,
     Element element,
     Properties parameter,
     Attributes controlDefinitionAttributes) {
   progressBarElement = element.findElementByName("progressbar");
   binded = true;
 }
  public void display(Element listBoxItem, ListBoxMessages_Bucket item) {
    final Element index = listBoxItem.findElementByName(CHAT_LINE_INDEX);
    if (index == null) return;
    final TextRenderer indexRenderer = index.getRenderer(TextRenderer.class);

    final Element unit = listBoxItem.findElementByName(CHAT_LINE_UNIT);
    if (unit == null) return;
    final TextRenderer unitRenderer = unit.getRenderer(TextRenderer.class);

    final Element sizeCapacity = listBoxItem.findElementByName(CHAT_LINE_SIZECAPACITY);
    if (sizeCapacity == null) return;
    final TextRenderer sizeCapacityRenderer = sizeCapacity.getRenderer(TextRenderer.class);

    final Element partAssigned = listBoxItem.findElementByName(CHAT_LINE_PARTASSIGNED);
    if (partAssigned == null) return;
    final TextRenderer partAssignedRenderer = partAssigned.getRenderer(TextRenderer.class);

    final Element unitsToArriveRemove =
        listBoxItem.findElementByName(CHAT_LINE_UNITSTOARRIVEREMOVE);
    if (unitsToArriveRemove == null) return;
    final TextRenderer unitsToArriveRemoveRenderer =
        unitsToArriveRemove.getRenderer(TextRenderer.class);

    if (item != null) {
      indexRenderer.setText(item.getIndex());
      unitRenderer.setText(item.getUnit());
      sizeCapacityRenderer.setText(item.getSizeCapacity());
      partAssignedRenderer.setText(item.getPartAssigned());
      unitsToArriveRemoveRenderer.setText(item.getUnitsToArriveRemove());
    } else {
      indexRenderer.setText("");
      unitRenderer.setText("");
      sizeCapacityRenderer.setText("");
      partAssignedRenderer.setText("");
      unitsToArriveRemoveRenderer.setText("");
    }
  }
  public int getWidth(Element listBoxItem, ListBoxMessages_Bucket item) {
    final Element index = listBoxItem.findElementByName(CHAT_LINE_INDEX);
    if (index == null) return 0;
    final TextRenderer indexRenderer = index.getRenderer(TextRenderer.class);

    final Element unit = listBoxItem.findElementByName(CHAT_LINE_UNIT);
    if (unit == null) return 0;
    final TextRenderer unitRenderer = unit.getRenderer(TextRenderer.class);

    final Element sizeCapacity = listBoxItem.findElementByName(CHAT_LINE_SIZECAPACITY);
    if (sizeCapacity == null) return 0;
    final TextRenderer sizeCapacityRenderer = sizeCapacity.getRenderer(TextRenderer.class);

    final Element partAssigned = listBoxItem.findElementByName(CHAT_LINE_PARTASSIGNED);
    if (partAssigned == null) return 0;
    final TextRenderer partAssignedRenderer = partAssigned.getRenderer(TextRenderer.class);

    final Element unitsToArriveRemove =
        listBoxItem.findElementByName(CHAT_LINE_UNITSTOARRIVEREMOVE);
    if (unitsToArriveRemove == null) return 0;
    final TextRenderer unitsToArriveRemoveRenderer =
        unitsToArriveRemove.getRenderer(TextRenderer.class);
    return ((indexRenderer.getFont() == null)
            ? 0
            : indexRenderer.getFont().getWidth(item.getIndex()))
        + ((unitRenderer.getFont() == null) ? 0 : unitRenderer.getFont().getWidth(item.getUnit()))
        + ((sizeCapacityRenderer.getFont() == null)
            ? 0
            : sizeCapacityRenderer.getFont().getWidth(item.getSizeCapacity()))
        + ((partAssignedRenderer.getFont() == null)
            ? 0
            : partAssignedRenderer.getFont().getWidth(item.getPartAssigned()))
        + ((unitsToArriveRemoveRenderer.getFont() == null)
            ? 0
            : unitsToArriveRemoveRenderer.getFont().getWidth(item.getUnitsToArriveRemove()));
  }
Пример #5
0
 public void spawnCitizenWindow(Citizen citizen) {
   String windowId = "updatable-" + NiftyIdCreator.generate();
   CustomControlCreator citizenWindowCreator = new CustomControlCreator(windowId, "CitizenWindow");
   Element citizenWindow = citizenWindowCreator.create(nifty, screen, windows);
   // the controller needs to be set on the panel rather than the control, maybe due to the hidden
   // window-content panel
   // there is something bugged about these ID's
   Element citizenWindowPanel =
       citizenWindow.findElementByName(
           windowId
               + "#CitizenWindow#window-content#CitizenWindow#window-content#CitizenWindowPanel");
   CitizenWindowController controller =
       citizenWindowPanel.getControl(CitizenWindowController.class);
   controller.setCitizen(citizen);
   updatables.put(windowId, controller);
 }
Пример #6
0
  public void playerLoader(MenuApp menuApp, Screen screen, String map) {

    AssetManager as = menuApp.getAssetManager();

    PlayerDataManager pdm = PlayerDataManager.load(as);
    PlayerDataMapManager pdmm = PlayerDataMapManager.load(as, map);

    ArrayList<PlayerData> list = pdm.getPlayer();

    int id = 0;

    int countTeams = 0;
    for (int i = 0; i < list.size(); i++) {
      PlayerData playerData = list.get(i);

      PlayerDataMap playerDataMap = pdmm.getPlayer().get(playerData.getId());

      if (playerDataMap != null) {
        if (playerDataMap.getController() != PlayerDataMap.none) {
          countTeams++;
        }
      }
    }

    for (int i = 0; i < list.size(); i++) {
      PlayerData playerData = list.get(i);
      PlayerDataMap playerDataMap = pdmm.getPlayer().get(playerData.getId());

      if (playerDataMap != null) {
        if (playerDataMap.getController() != PlayerDataMap.none) {
          id++;

          CustomControlCreator createMultiplayerPanel =
              new CustomControlCreator("myPlayerPanel", "playerPanel");
          de.lessvoid.nifty.elements.Element e =
              createMultiplayerPanel.create(nifty, screen, screen.findElementByName("slot" + i));

          TextField tf = e.findNiftyControl("id", TextField.class);
          tf.setText(id + "");
          tf.setEnabled(false);

          tf = e.findNiftyControl("playername", TextField.class);
          tf.setText(playerData.getName());
          tf.setEnabled(false);

          DropDown dd = e.findNiftyControl("team", DropDown.class);
          for (int b = 0; b < countTeams; b++) {
            dd.addItem("Team " + (b + 1));
          }
          // dd.setEnabled(false);

          PanelRenderer colorPanel = e.findElementByName("color").getRenderer(PanelRenderer.class);
          Color color =
              new Color(
                  playerData.getColor().r,
                  playerData.getColor().g,
                  playerData.getColor().b,
                  playerData.getColor().a);
          colorPanel.setBackgroundColor(color);
        }
      }
    }
  }