@Override
 public void onStartScreen() {
   screen.findElementByName(buttonToDialogMap.get(currentMenuButtonId)).show();
   screen
       .findElementByName(currentMenuButtonId)
       .startEffect(EffectEventId.onCustom, null, "selected");
 }
Ejemplo n.º 2
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");
 }
  @NiftyEventSubscriber(id = "resolutions")
  public void onResolution(
      final String id, final DropDownSelectionChangedEvent<DisplayMode> event) {
    screen
        .findElementByName("whiteOverlay")
        .startEffect(
            EffectEventId.onCustom,
            new EndNotify() {
              @Override
              public void perform() {
                DisplayMode displayMode = event.getSelection();
                try {
                  Display.setDisplayMode(displayMode);

                  GL11.glMatrixMode(GL11.GL_PROJECTION);
                  GL11.glLoadIdentity();
                  GL11.glOrtho(0, displayMode.getWidth(), displayMode.getHeight(), 0, -9999, 9999);

                  GL11.glMatrixMode(GL11.GL_MODELVIEW);

                  nifty.resolutionChanged();
                } catch (LWJGLException e) {
                  e.printStackTrace();
                }
              }
            },
            "onResolutionStart");
  }
  @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);
  }
  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.º 6
0
 public UserCommandControl(Screen screen, InputManager inputManager) {
   this(inputManager);
   this.screen = screen;
   for (int i = 0; i < 10; i++) {
     selectionTexts[i] =
         screen
             .findElementByName("layer")
             .findElementByName("panel_bottom")
             .findElementByName("bottom_panel_right")
             .findElementByName("status_text_0" + i)
             .getRenderer(TextRenderer.class);
     commandTexts[i] =
         screen
             .findElementByName("layer")
             .findElementByName("panel_top")
             .findElementByName("top_panel_left")
             .findElementByName("status_text_0" + i)
             .getRenderer(TextRenderer.class);
   }
   setSelectionMenu(SelectionMenu.Main);
   updateCommandMenu();
 }
  @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);
      }
    }
  }
 @NiftyEventSubscriber(id = "quitGameButton")
 public void onTestButton2Click(final String id, final ButtonClickedEvent clickedEvent) {
   screen
       .findElementByName(buttonToDialogMap.get(currentMenuButtonId))
       .hide(
           new EndNotify() {
             @Override
             public void perform() {
               exit = true;
               nifty.exit();
             }
           });
 }
Ejemplo n.º 9
0
  @NiftyEventSubscriber(id = "html-select")
  public void onHtmlSelectChanged(
      final String id, final DropDownSelectionChangedEvent<String> event) {
    try {
      generator.generate(
          readHTMLFile(event.getSelection()), screen, screen.findElementByName("parent"));

      // for debugging purpose we could output the screen as a text structure
      //      System.out.println(screen.debugOutput());
    } catch (IOException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 10
0
 public void bind(Nifty nifty, Screen screen) {
   this.nifty = nifty;
   this.screen = screen;
   System.out.println("bind( " + screen.getScreenId() + ")");
   screen.addKeyboardInputHandler(new KeyBoardMapping(), this);
   windows = screen.findElementByName("windows");
   // screen.addPreKeyboardInputHandler(new KeyBoardMapping(), this);
   pathingCheckBox = screen.findNiftyControl("pathingCheckBox", CheckBox.class);
   litSurfacesCheckBox = screen.findNiftyControl("litSurfacesCheckBox", CheckBox.class);
   terrainCheckBox = screen.findNiftyControl("terrainCheckBox", CheckBox.class);
   timeLabel = screen.findNiftyControl("timeLabel", Label.class);
   expandedNodesLabel = screen.findNiftyControl("expandedNodesLabel", Label.class);
   graphReadsLabel = screen.findNiftyControl("graphReadsLabel", Label.class);
   registerWithInput(Main.app.getInputManager());
 }
Ejemplo n.º 11
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);
        }
      }
    }
  }