@Override public void onStartScreen() { screen.findElementByName(buttonToDialogMap.get(currentMenuButtonId)).show(); screen .findElementByName(currentMenuButtonId) .startEffect(EffectEventId.onCustom, null, "selected"); }
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"); }
@SuppressWarnings("unchecked") @Override public void onEvent(final String topic, final ListBoxSelectionChangedEvent data) { final Object selectedItem = getSelectedItem(data.getSelection()); ListBoxControl listBoxControl = (ListBoxControl) listBox; listBoxControl .getViewConverter() .display(dropDown.getElement().findElementByName("#text"), selectedItem); final int selectedItemIndex = getSelectedIndex(data); if (screen.isActivePopup(popupInstance)) { dropDown .getElement() .getControl(DropDownControl.class) .close( new EndNotify() { @Override public void perform() { nifty.publishEvent( dropDown.getId(), new DropDownSelectionChangedEvent(dropDown, selectedItem, selectedItemIndex)); } }); } else { nifty.publishEvent( dropDown.getId(), new DropDownSelectionChangedEvent(dropDown, selectedItem, selectedItemIndex)); } }
@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); }
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()); }
@Override public void onStartScreen() { List<String> items = new ArrayList<String>(); for (int i = 1; i < 51; i++) { items.add("src/test/resources/html/test-" + String.format("%02d", i) + ".html"); } DropDown<String> htmlSelectDropDown = screen.findNiftyControl("html-select", DropDown.class); htmlSelectDropDown.addAllItems(items); }
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; } }
@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); } } }
@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(); } }); }
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(); }
@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(); } }
/** * Get all LWJGL DisplayModes into the DropDown * * @param screen */ private void fillResolutionDropDown(final Screen screen) { try { DisplayMode currentMode = Display.getDisplayMode(); List<DisplayMode> sorted = new ArrayList<DisplayMode>(); DisplayMode[] modes = Display.getAvailableDisplayModes(); for (int i = 0; i < modes.length; i++) { DisplayMode mode = modes[i]; if (mode.getBitsPerPixel() == 32 && mode.getFrequency() == currentMode.getFrequency()) { // since Nifty does not yet support automatically rescaling of the GUI and since this // example/demo was designed for 1024x768 pixel we can't allow resolutions below this // size. if (mode.getWidth() >= 1024 && mode.getHeight() >= 768) { sorted.add(mode); } } } Collections.sort( sorted, new Comparator<DisplayMode>() { @Override public int compare(DisplayMode o1, DisplayMode o2) { int widthCompare = Integer.valueOf(o1.getWidth()).compareTo(Integer.valueOf(o2.getWidth())); if (widthCompare != 0) { return widthCompare; } int heightCompare = Integer.valueOf(o1.getHeight()).compareTo(Integer.valueOf(o2.getHeight())); if (heightCompare != 0) { return heightCompare; } return o1.toString().compareTo(o2.toString()); } }); DropDown dropDown = screen.findNiftyControl("resolutions", DropDown.class); for (DisplayMode mode : sorted) { dropDown.addItem(mode); } } catch (Exception e) { } }
@Override public final void bind(final Nifty newNifty, final Screen screen) { this.nifty = newNifty; console = screen.findNiftyControl("console", Console.class); }
@Override public void bind(@Nonnull Nifty nifty, @Nonnull Screen screen) { hitPointBar = screen.findNiftyControl("healthBar", Progress.class); manaPointBar = screen.findNiftyControl("manaBar", Progress.class); foodPointBar = screen.findNiftyControl("foodBar", Progress.class); }
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); } } } }