private void closeMessageBox() { clearButtons(); // messageboxPopup.findElementById("#messagebox").findElementById("#buttons"); nifty.getCurrentScreen().layoutLayers(); }
private void closeMessageBox() { clearButtons(); // messageboxPopup.findElementById("#messagebox").findElementById("#buttons"); nifty.getCurrentScreen().layoutLayers(); }
/** * Build an element in a specified position in parent element list * * @return the Element created */ @Nonnull public Element build(@Nonnull final Element parent, final int index) { Screen screen = parent.getScreen(); ElementType type = buildElementType(); Element result = parent.getNifty().createElementFromType(screen, parent, type, index); screen.layoutLayers(); return result; }
protected void initHud(String resource) { Screen hud = nifty.getScreen(HUD_SCREEN_ID); // Load the level dictionary if (resource != null) { String levelResource = "Interface/Texts/".concat(resource); try { nifty.addResourceBundle("level", Main.getResourceBundle(levelResource)); } catch (Exception ex) { logger.log(Level.WARNING, "Failed to load the level dictionary!", ex); } } // Load the HUD initHud = true; nifty.gotoScreen(PlayerScreenController.HUD_SCREEN_ID); hud.layoutLayers(); }
private void displayResolutionChanged() { getRenderEngine().displayResolutionChanged(); resetMouseInputEvents(); int newWidth = getRenderEngine().getWidth(); int newHeight = getRenderEngine().getHeight(); for (Screen screen : screens.values()) { updateLayoutPart(screen.getRootElement().getLayoutPart(), newWidth, newHeight); for (Element e : screen.getLayerElements()) { updateLayoutPart(e.getLayoutPart(), newWidth, newHeight); } screen.resetLayout(); } for (Element e : popups.values()) { updateLayoutPart(e.getLayoutPart(), newWidth, newHeight); } if (currentScreen != null) { currentScreen.layoutLayers(); } }
private void setupMessageBox() { final Element imgIcon = messageboxPopup.findElementById("#messagebox").findElementById("#message-icon"); final ImageRenderer iconRenderer = imgIcon.getRenderer(ImageRenderer.class); iconRenderer.setImage(icon); final Element text = messageboxPopup.findElementById("#messagebox").findElementById("#message-text"); final TextRenderer textRenderer = text.getRenderer(TextRenderer.class); textRenderer.setText(message); int i = 0; for (String buttonCaption : buttonCaptions) { i++; createButton(buttonCaption, buttonCaption, "button_" + i); } messageboxPopup.findElementById("#messagebox").layoutElements(); nifty.getCurrentScreen().layoutLayers(); }
private void setupMessageBox() { final Element imgIcon = messageboxPopup.findElementById("#messagebox").findElementById("#message-icon"); final ImageRenderer iconRenderer = imgIcon.getRenderer(ImageRenderer.class); iconRenderer.setImage(icon); final Element text = messageboxPopup.findElementById("#messagebox").findElementById("#message-text"); final TextRenderer textRenderer = text.getRenderer(TextRenderer.class); textRenderer.setText(message); int i = 0; for (String buttonCaption : buttonCaptions) { i++; createButton(buttonCaption, buttonCaption, "button_" + i); } messageboxPopup.findElementById("#messagebox").layoutElements(); nifty.getCurrentScreen().layoutLayers(); }
public void startScreen(final EndNotify startScreenEndNotify) { NiftyStopwatch.start(); running = false; nifty.getRenderEngine().screenStarted(this); focusHandler.resetFocusElements(); resetLayers(); layoutLayers(); bindControls(); // bind happens right BEFORE the onStartScreen if (!screenControllerBound) { screenController.bind(nifty, this); screenControllerBound = true; } // activate the onActive event right now activeEffectStart(); // onStartScreen final StartScreenEndNotify endNotify = createScreenStartEndNotify(startScreenEndNotify); startLayers(EffectEventId.onStartScreen, endNotify); // default focus attribute has been set in onStartScreen // event of the elements. so we have to set the default focus // here after the onStartScreen is started. setDefaultFocus(); NiftyStopwatch.stop("Screen.startScreen(" + layoutLayersCallCount + ")"); }
private void populateSelectedMap(KwdFile map) { // The map title Label label = screen.findNiftyControl("mapNameTitle", Label.class); label.setText(map == null ? "No maps found from " + PathUtils.DKII_MAPS_FOLDER : map.getGameLevel().getName()); NiftyUtils.resetContraints(label); if (map != null) { // Player count label = screen.findNiftyControl("playerCount", Label.class); label.setText(": " + map.getGameLevel().getPlayerCount()); NiftyUtils.resetContraints(label); // Map image Element mapImage = screen.findElementById("mapImage"); NiftyImage img = nifty.createImage(state.getMapThumbnail(map), true); mapImage.getRenderer(ImageRenderer.class).setImage(img); mapImage.setConstraintWidth(new SizeValue(img.getWidth() + "px")); mapImage.setConstraintHeight(new SizeValue(img.getHeight() + "px")); } // Re-populate screen.layoutLayers(); }
ip.setWidth(new SizeValue(renderer.getTextWidth() + "px")); screen.layoutLayers();