Пример #1
0
  public void bind(Nifty nifty, Screen screen) {
    this.nifty = nifty;

    //  CustomControlCreator createMultiplayerPanel = new CustomControlCreator("myPlayerPanel",
    // "playerPanel");
    //   createMultiplayerPanel.create(nifty, screen, screen.findElementByName("slot0"));
    playerLoader(MenuApp.getInstance(), screen, "Map1");
  }
Пример #2
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);
        }
      }
    }
  }
Пример #3
0
 public void host() {
   nifty.gotoScreen("mapselection");
   MenuApp.getInstance().getNifty().resolutionChanged();
 }