コード例 #1
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);
 }
コード例 #2
0
ファイル: Lobby.java プロジェクト: Oger-Lord/JPenguin
  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);
        }
      }
    }
  }