public void setProgress(final float progress, String loadingText) {
   final int MIN_WIDTH = 32;
   int pixelWidth =
       (int) (MIN_WIDTH + (progressBarElement.getParent().getWidth() - MIN_WIDTH) * progress);
   progressBarElement.setConstraintWidth(new SizeValue(pixelWidth + "px"));
   progressBarElement.getParent().layoutElements();
 }
  private void setMessageHUD(String text) {
    Element el = nifty.getCurrentScreen().findElementByName("messages");

    if (text != null && el != null) {
      el.getRenderer(TextRenderer.class).setText(text);
    }
  }
Ejemplo n.º 3
0
  // refresh/build method:
  public void refresh(Nifty panel) {
    if (!visible) {
      return;
    }

    // disable other existing layers
    for (Element l : panel.getScreen("start").getLayerElements()) {
      l.disable();
    }

    Element layer =
        new LayerBuilder("journal layer") {
          {
            childLayoutAbsolute();
            width("100%");
            height("100%");
          }
        }.build(panel, panel.getScreen("start"), panel.getScreen("start").getRootElement());

    // make overall panel
    Element back =
        new PanelBuilder("back") {
          {
            childLayoutHorizontal();
            x(Integer.toString(screen_x) + "px");
            y(Integer.toString(screen_y) + "px");
            width("50%");
            height("60%");
            style("nifty-panel");
          }
        }.build(panel, panel.getScreen("start"), layer);

    // arc selection panel
    // make frame
    Element arcpanel =
        new PanelBuilder() {
          {
            childLayoutVertical();
            width("40%");
            height("100%");
            style("nifty-panel");
          }
        }.build(panel, panel.getScreen("start"), back);
    // fill with arc select panel
    panel_arc_select.refresh(panel, arcpanel, true);

    // make arc/segment edit panel
    Element arceditpanel =
        new PanelBuilder() {
          {
            childLayoutVertical();
            width("60%");
            height("100%");
          }
        }.build(panel, panel.getScreen("start"), back);

    // fill panel
    panel_arc_edit.refresh(panel, arceditpanel);
  }
  @Override
  public void bind(final Nifty nifty, @Nonnull final Screen screen) {
    this.nifty = nifty;

    displayParent = screen.findElementByName("nameDisplay");
    titleLabel = displayParent.findNiftyControl("title", Label.class);
    nameLabel = displayParent.findNiftyControl("name", Label.class);
  }
Ejemplo n.º 5
0
 public void bind(Nifty nifty, Screen screen) {
   stageManager = (RTSStageManager) this.gameGUIManager.getApp().getStageManager();
   this.screen = screen;
   createUI(nifty, screen);
   this.energyText = screen.findElementByName("country_energy");
   this.gasText = screen.findElementByName("country_gas");
   energyText.getRenderer(TextRenderer.class).setText("100");
   gasText.getRenderer(TextRenderer.class).setText("200");
   this.mapElement = screen.findElementByName("mapImage");
   entityActionUI = screen.findElementByName("entityAction");
 }
 @Override
 public boolean keyEvent(final NiftyInputEvent inputEvent) {
   if (inputEvent == NiftyInputEvent.ConsoleToggle) {
     if (screen.isActivePopup(consolePopup)) {
       nifty.closePopup(consolePopup.getId());
     } else {
       nifty.showPopup(screen, consolePopup.getId(), null);
     }
     return true;
   }
   return false;
 }
  @Override
  public void bind(final Nifty nifty, final Screen screen) {
    System.out.println("bind()");
    this.nifty = nifty;

    for (int i = 0; i < 5; i++) {
      for (int j = 0; j < 5; j++) {
        Element e = screen.findElementByName("item" + i + "_" + j);
        DroppableControl drroppableControl = e.getControl(DroppableControl.class);
        drroppableControl.addFilter(this);
      }
    }
  }
  private void showNextEntry(@Nonnull final Iterator<CreditsList> iterator) {
    if (!iterator.hasNext()) {
      gotoNextScreen();
      return;
    }

    final CreditsList list = iterator.next();
    if (Lang.getInstance().isGerman()) {
      titleLabel.setText(list.getNameGerman());
    } else {
      titleLabel.setText(list.getNameEnglish());
    }

    final List<String> names = new ArrayList<String>();
    for (final CreditsPerson person : list) {
      names.add(person.getName());
    }
    final StringBuilder builder = new StringBuilder();
    final int nameCount = names.size();
    for (int i = 0; i < nameCount; i++) {
      builder.append(names.get(i));
      if (i < (nameCount - 2)) {
        builder.append(", ");
      } else if (i < (nameCount - 1)) {
        if (Lang.getInstance().isGerman()) {
          builder.append(" und ");
        } else {
          builder.append(" and ");
        }
      }
    }
    nameLabel.setText(builder.toString());
    displayParent.layoutElements();

    displayParent.show(
        new EndNotify() {
          @Override
          public void perform() {
            displayParent.hide(
                new EndNotify() {
                  @Override
                  public void perform() {
                    showNextEntry(iterator);
                  }
                });
          }
        });
  }
Ejemplo n.º 9
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);
 }
Ejemplo n.º 10
0
 public void ClosePopulationPopup() {
   if (PopulationPopup != null) {
     nifty.closePopup(PopulationPopup.getId());
     PopulationPopup = null;
   }
   enableMouseWheel();
 }
 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);
   }
 }
Ejemplo n.º 12
0
  public void doMapClick(int mx, int my) {

    // go to XY
    mx = mx - mapElement.getX();
    my = my - mapElement.getY();
    int mh = mapElement.getHeight();
    int mw = mapElement.getWidth();
    float sx = 1024 / mw;
    float sy = stageManager.getStartPos().y;
    float sz = 1024 / mh;

    float cx = 512;
    float cz = 512;
    Vector3f newMapPos = new Vector3f(mx * sx - cx, sy, my * sz - cz);
    System.out.println(" Mouse Map : " + mx + " " + my);
    stageManager.getRtsCam().setCenter(newMapPos);
  }
Ejemplo n.º 13
0
  public void OpenMenuPopup() {
    CloseMenuPopup();
    Game game = Main.app.getStateManager().getState(Game.class);
    game.Pause(true);

    MenuPopup = nifty.createPopup("MenuPopup");
    nifty.showPopup(screen, MenuPopup.getId(), null);
  }
 public void bind(
     Nifty nifty,
     Screen screen,
     Element element,
     Properties parameter,
     Attributes controlDefinitionAttributes) {
   progressBarElement = element.findElementByName("progressbar");
   binded = true;
 }
Ejemplo n.º 15
0
 public void onEndScreen() {
   MenuPopup = null;
   PopulationPopup = null;
   // close any open windows
   for (Element tempElement : windows.getElements()) {
     nifty.removeElement(screen, tempElement);
   }
   updatables.clear();
   System.out.println("onEndScreen");
 }
 @Override
 public void bind(Nifty nifty, Screen screen) {
   this.nifty = nifty;
   this.screen = screen;
   textArea = this.screen.findElementByName("textareat");
   textArea
       .getRenderer(TextRenderer.class)
       .setText(
           "Create By: Lightnet \n\n Credits to: \n\n-jmonkeyengine.org #to the forums and the wiki for helpful information. \n\n-nifty GUI ");
 }
  private void changeDialogTo(final String id) {
    if (!id.equals(currentMenuButtonId)) {
      int currentIndex = buttonIdList.indexOf(currentMenuButtonId);
      int nextIndex = buttonIdList.indexOf(id);

      Element nextElement = screen.findElementByName(buttonToDialogMap.get(id));
      modifyMoveEffect(
          EffectEventId.onShow, nextElement, currentIndex < nextIndex ? "right" : "left");
      nextElement.show();

      Element currentElement = screen.findElementByName(buttonToDialogMap.get(currentMenuButtonId));
      modifyMoveEffect(
          EffectEventId.onHide, currentElement, currentIndex < nextIndex ? "left" : "right");
      currentElement.hide();

      screen.findElementByName(currentMenuButtonId).stopEffect(EffectEventId.onCustom);
      screen.findElementByName(id).startEffect(EffectEventId.onCustom, null, "selected");
      currentMenuButtonId = id;
    }
  }
Ejemplo n.º 18
0
  public void OpenPopulationPopup() {
    ClosePopulationPopup();
    Game game = Main.app.getStateManager().getState(Game.class);
    game.Pause(true);
    // prevent mouse wheel interfering with scrolling a menu
    // TODO there may be a better way of doing this, e.g. nifty not passing the mousewheel event to
    // the game.
    disableMouseWheel();

    PopulationPopup = nifty.createPopup("PopulationPopup");
    nifty.showPopup(screen, PopulationPopup.getId(), null);
  }
Ejemplo n.º 19
0
 public RadioButtonGroup create(final Nifty nifty, final Screen screen, final Element parent) {
   nifty.addControl(screen, parent, getStandardControl());
   nifty.addControlsWithoutStartScreen();
   return parent.findNiftyControl(attributes.get("id"), RadioButtonGroup.class);
 }
 public void showPopup() {
   nifty.showPopup(nifty.getCurrentScreen(), popup.getId(), null);
 }
 public void closePopup() {
   nifty.closePopup(popup.getId());
 }
Ejemplo n.º 22
0
 public void CloseMenuPopup() {
   if (MenuPopup != null) {
     nifty.closePopup(MenuPopup.getId());
     MenuPopup = null;
   }
 }
  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()));
  }
  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("");
    }
  }
 private void showCredits() {
   nifty.showPopup(screen, creditsPopup.getId(), null);
 }
 @NiftyEventSubscriber(id = "creditsBack")
 public void onCreditsBackClick(final String id, final ButtonClickedEvent event) {
   nifty.closePopup(creditsPopup.getId());
 }
Ejemplo n.º 27
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);
        }
      }
    }
  }