public void quit(){ nifty.gotoScreen("end"); }
/** * Invoked when the event is stopped. */ @Override public void onStop() { if (nifty.getCurrentScreen() != null) { nifty.getCurrentScreen().endScreen(null); } }
public void simpleInitApp() { NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort); nifty = niftyDisplay.getNifty(); nifty.fromXml("all/intro.xml", "start"); // attach the nifty display to the gui view port as a processor guiViewPort.addProcessor(niftyDisplay); // disable the fly cam flyCam.setEnabled(false); }
/** * Create a standard NiftyJmeDisplay. This uses the old Nifty renderer. It's probably slower then the batched * renderer and is mainly here for backwards compatibility. * * @param assetManager jME AssetManager * @param inputManager jME InputManager * @param audioRenderer jME AudioRenderer * @param vp Viewport to use */ public NiftyJmeDisplay(AssetManager assetManager, InputManager inputManager, AudioRenderer audioRenderer, ViewPort vp){ initialize(assetManager, inputManager, audioRenderer, vp); this.renderDev = new RenderDeviceJme(this); this.batchRendererBackend = null; nifty = new Nifty(renderDev, soundDev, inputSys, new AccurateTimeProvider()); inputSys.setNifty(nifty); resourceLocation = new ResourceLocationJme(); nifty.getResourceLoader().removeAllResourceLocations(); nifty.getResourceLoader().addResourceLocation(resourceLocation); }
public ModelViewerScreenController(ModelViewer app) { this.app = app; nifty = app.getNifty(); screen = nifty.getCurrentScreen(); // Set default font RenderFont font = nifty.createFont("Interface/Fonts/Frontend14.fnt"); nifty.getRenderEngine().setFont(font); nifty.registerMouseCursor("pointer", "Interface/Cursors/Idle.png", 4, 4); // Set some Nifty stuff nifty.addResourceBundle("menu", Main.getResourceBundle("Interface/Texts/Text")); nifty.addResourceBundle("speech", Main.getResourceBundle("Interface/Texts/Speech")); }
/** * Initialize this Nifty instance from the given xml file. * * @param filename filename to nifty xml * @param startScreen screen to start exec * @param controllers controllers to use */ public void fromXml( @Nonnull final String filename, @Nonnull final String startScreen, final ScreenController... controllers) { registerScreenController(controllers); prepareScreens(filename); loadFromFile(filename); gotoScreen(startScreen); }
/** * fromXml with ScreenControllers. * * @param fileId fileId * @param input inputStream * @param startScreen screen to start * @param controllers controllers to use */ public void fromXml( @Nonnull final String fileId, @Nonnull final InputStream input, @Nonnull final String startScreen, @Nonnull final ScreenController... controllers) { registerScreenController(controllers); prepareScreens(fileId); loadFromStream(input); gotoScreen(startScreen); }
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 initNifty() { /** Create a new NiftyGUI object */ niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort); nifty = niftyDisplay.getNifty(); nifty.setIgnoreKeyboardEvents(true); /** Read your XML and initialize your custom ScreenController */ nifty.fromXml("jadex3d/interface/BaseHud.xml", "hud", new DefaultGuiController(this)); nifty.fromXml("jadex3d/interface/BaseHud.xml", "default", new DefaultGuiController(this)); nifty.gotoScreen("hud"); guiViewPort.addProcessor(niftyDisplay); }
if (vertical == null) { if (bottomRight != null) { nifty.removeElement(screen, bottomRight, new EndNotify() { @Override public void perform() { "List box is expected to look crappy."); } else { nifty.createElementFromType(screen, horizontal, bottomRightTemplate); initializeHorizontalScrollbar(); element.getParent().layoutElements();
nifty = new Nifty(batchRenderDevice, new GdxSoundDevice(assetManager), gdxInputSystem, new AccurateTimeProvider()); nifty.fromXml(niftyExample.getMainXML(), niftyExample.getStartScreen()); } else { nifty.gotoScreen(niftyExample.getStartScreen());
protected void showError(String title, String message) { closePopup(); // Open message popupElement = nifty.createPopup("errorMessage"); nifty.showPopup(nifty.getCurrentScreen(), popupElement.getId(), null); // Set message text Label titleLabel = popupElement.findNiftyControl("title", Label.class); titleLabel.setText(title); Label messageLabel = popupElement.findNiftyControl("message", Label.class); messageLabel.setText(message); }
/** * Initialize this Nifty instance from the given xml file. * * @param filename filename to nifty xml * @param startScreen screen to start exec */ public void fromXml(@Nonnull final String filename, @Nonnull final String startScreen) { prepareScreens(filename); loadFromFile(filename); gotoScreen(startScreen); }
@Override public void publish(@Nonnull final CheckBoxStateChangedEvent event) { if (nifty != null) { String id = getId(); if (id != null) { nifty.publishEvent(id, event); } } }
/** * fromXml. * * @param fileId fileId * @param input inputStream * @param startScreen screen to start */ public void fromXml( @Nonnull final String fileId, @Nonnull final InputStream input, @Nonnull final String startScreen) { prepareScreens(fileId); loadFromStream(input); gotoScreen(startScreen); }
nifty.fromXml(nscreen.getPath(), nscreen.getName(), customCreator.getScreenController()); stateManager.attach((AppState)customCreator.getScreenController()); if(nscreen.isStartScreen() || startScreen == null) nifty.gotoScreen(startScreen.getName());
Screen hud = nifty.getScreen(HUD_SCREEN_ID); Element panel = nifty.getCurrentScreen().findElementById("bottomBackgroundPanel"); BufferedImage newImage = new BufferedImage(panel.getHeight() * img.getWidth() / img.getHeight(), panel.getHeight(), img.getType()); Graphics2D g = newImage.createGraphics(); NiftyImage niftyImage = nifty.createImage("HUDBackground", true); String resizeString = "repeat:0,0," + newImage.getWidth() + "," + newImage.getHeight(); String areaProviderProperty = ImageModeHelper.getAreaProviderProperty(resizeString);
@Nonnull public String getFontname(@Nonnull final RenderFont font) { return getRenderEngine().getFontname(font); }
private void initTab(@Nonnull final Tab tab) { final int tabIndex = indexOf(tab); Element button = getButton(tabIndex); if (button == null) { if (buttonTemplate == null || nifty == null || screen == null || tabButtonPanel == null) { log.severe("Tab can't be initialized. Binding not done yet or binding failed."); return; } final ElementType newButtonTemplate = buttonTemplate.copy(); newButtonTemplate.getAttributes().set("id", buildTabButtonName(tabIndex)); button = nifty.createElementFromType(screen, tabButtonPanel, newButtonTemplate); } String buttonId = button.getId(); if (buttonId != null) { nifty.subscribe(screen, buttonId, ButtonClickedEvent.class, buttonClickedSubscriber); } if (!button.isVisible()) { button.show(); } final Button btnControl = button.getNiftyControl(Button.class); if (btnControl == null) { log.warning("Can't set label of tab selection element that is not a button."); } else { btnControl.setText(tab.getCaption()); } if (tab instanceof TabGroupMember) { ((TabGroupMember) tab).setParentTabGroup(this); } }
public void show() { nifty.showPopup(nifty.getCurrentScreen(), messageboxPopup.getId(), null); }