@Override public void onPlay() { super.onPlay(); nifty.getScreen(screen).findElementById("text") .getRenderer(TextRenderer.class).setText(text); }
public Label getTooltip() { if (tooltip == null) { tooltip = nifty.getScreen(HUD_SCREEN_ID).findNiftyControl("tooltip", Label.class); } return tooltip; }
@Override public void bind(Nifty nifty, Screen screen, Element element, Parameters parameter) { this.nifty = nifty; this.hud = nifty.getScreen(HUD_SCREEN_ID); this.element = element; this.buttonPanel = element.findElementById("#buttonPanel"); }
public Element getGuiConstraint() { Element middle = nifty.getScreen(HUD_SCREEN_ID).findElementById("middle"); return middle; }
public Element getMessages() { return nifty.getScreen(HUD_SCREEN_ID).findElementById("systemMessages"); }
public Console getConsole() { return nifty.getScreen(HUD_SCREEN_ID).findNiftyControl("console", Console.class); }
private void setCinematicText(String text) { Label label = nifty.getScreen(CINEMATIC_SCREEN_ID).findNiftyControl("speechText", Label.class); cinematicText = text; label.setText(cinematicText); }
@Override public void bind(Nifty nifty, Screen screen, Element element, Parameters parameter) { this.text = parameter.get("text"); this.element = element; this.nifty = nifty; this.hud = this.nifty.getScreen(HUD_SCREEN_ID); // sync effects on adding messages syncActiveEffects(); }
public void setPause(boolean paused) { nifty.getScreen(HUD_SCREEN_ID).findElementById("optionsMenu").setVisible(paused); }
/** * FIXME not applied when enter possession twice Focus active Action element * on GUI * * @param action */ protected void updatePossessionSelectedItem(PossessionInteractionState.Action action) { possessionAction = action; Element element = nifty.getScreen(POSSESSION_SCREEN_ID).findElementById("creature-" + possessionAction.toString().toLowerCase()); if (element != null) { element.setFocus(); } }
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(); }
public SystemMessageState(Element systemMessages, boolean enabled) { this.systemMessagesQueue = systemMessages; this.hud = systemMessagesQueue.getNifty().getScreen(HUD_SCREEN_ID); // can be removed if system messages are correctly detached after quiting the game (like going back to main menu) this.removeAllMessages(); super.setEnabled(enabled); }
/** * Populates the player spells tab */ public void populateSpellTab() { Screen hud = nifty.getScreen(HUD_SCREEN_ID); FlowLayoutControl contentPanel = hud.findElementById("tab-spell-content").getControl(FlowLayoutControl.class); contentPanel.removeAll(); for (final Entry<KeeperSpell, PlayerSpell> entry : state.getSpellControl().getTypes().entrySet()) { contentPanel.addElement(createSpellIcon(entry.getValue())); } }
protected void updateSelectedItem(PlayerInteractionState.InteractionState state) { if (selectedButton != null) { selectedButton.stopEffect(EffectEventId.onCustom); } String itemId = state.getType().toString().toLowerCase() + "_" + state.getItemId(); selectedButton = nifty.getScreen(HUD_SCREEN_ID).findElementById(itemId); if (selectedButton != null) { selectedButton.startEffect(EffectEventId.onCustom, null, "select"); } }
@Override public void pauseMenu() { boolean paused = !state.isPaused(); // Pause state state.setPaused(paused); // Set the menuButton Element menuButton = nifty.getScreen(HUD_SCREEN_ID).findElementById("menuButton"); if (paused) { menuButton.startEffect(EffectEventId.onCustom, null, "select"); } else { menuButton.stopEffect(EffectEventId.onCustom); } nifty.getScreen(HUD_SCREEN_ID).findElementById("optionsMenu").setVisible(paused); if (paused) { pauseMenuNavigate(PauseMenuState.MAIN.name(), null, null, null); } }
/** * Populates the player rooms tab */ public void populateRoomTab() { Screen hud = nifty.getScreen(HUD_SCREEN_ID); FlowLayoutControl contentPanel = hud.findElementById("tab-room-content").getControl(FlowLayoutControl.class); contentPanel.removeAll(); for (final Room room : state.getAvailableRoomsToBuild()) { contentPanel.addElement(createRoomIcon(room)); } }
@Override public void workersAmount(String uiState) { WorkerAmountControl.State controlState = WorkerAmountControl.State.valueOf(uiState.toUpperCase()); if (controlState != null) { Screen s = nifty.getScreen(HUD_SCREEN_ID); WorkerAmountControl cAmount = s.findNiftyControl("tab-workers", WorkerAmountControl.class); cAmount.setState(controlState); WorkerEqualControl cEqual = s.findNiftyControl("tab-workers-equal", WorkerEqualControl.class); cEqual.setState(controlState); Element e = s.findElementById("tab-creature-content"); for (Element element : e.getChildren()) { element.getControl(CreatureCardControl.class).setState(controlState); } } }
@Override public void togglePanel() { // FIXME work but not properly. Map should not move with other things. Need HUD redesign Element element = nifty.getScreen(HUD_SCREEN_ID).findElementById("bottomPanel"); if (!element.getUserDataKeys().contains("toggle")) { element.setUserData("toggle", false); } boolean toggled = element.getUserData("toggle"); if (toggled) { element.setMarginTop(new SizeValue(0, SizeValueType.Pixel)); } else { element.setMarginTop(new SizeValue(156, SizeValueType.Pixel)); } element.setUserData("toggle", !toggled); element.getParent().layoutElements(); }
/** * Unlocks my pet dungeon levels if the preceding level was won */ private void unlockMPDMaps() { Screen mpdScreen = nifty.getScreen("myPetDungeon"); Element mpdList = mpdScreen.findElementById("mpdList"); int childCount = mpdList.getChildrenCount(); for (int i = 2; i < childCount; i++) { Element button = mpdList.findElementById("mpd" + i); if (button.getStyle().equals("menuTextDisabled")) { // the level before it must be completed Level mpdLevel = new Level(LevelType.MPD, i - 1); if (Settings.getInstance().getLevelStatus(mpdLevel).equals(LevelStatus.COMPLETED)) { TextBuilder unlockedLevel = new TextBuilder(); unlockedLevel.style("menuText"); unlockedLevel.id("mpd" + i); unlockedLevel.interactOnClick(String.format("selectMPDLevel(%s)", i)); unlockedLevel.text(button.getRenderer(TextRenderer.class).getOriginalText()); unlockedLevel.align(Align.Center); unlockedLevel.build(nifty, mpdScreen, mpdList, button); // remove the button button.markForRemoval(); } } } }
@Override public void toggleObjective() { Element element = nifty.getScreen(HUD_SCREEN_ID).findElementById("objective"); if (element.isVisible()) { element.hide(); } else { GameLevel gameLevel = state.stateManager.getState(GameState.class).getLevelData().getGameLevel(); Label mainObjective = element.findNiftyControl("mainObjective", Label.class); mainObjective.setText(gameLevel.getMainObjective()); Label subObjective1 = element.findNiftyControl("subObjective1", Label.class); subObjective1.setText(gameLevel.getSubObjective1()); Label subObjective2 = element.findNiftyControl("subObjective2", Label.class); subObjective2.setText(gameLevel.getSubObjective2()); Label subObjective3 = element.findNiftyControl("subObjective3", Label.class); subObjective3.setText(gameLevel.getSubObjective3()); element.layoutElements(); element.show(); } }