public boolean isVisible() { return console.getElement().isVisible(); }
private void debugOutputLayerElements( @Nonnull final String regexpElement, @Nonnull final String regexpAttribute, @Nonnull StringBuffer result, @Nonnull List<Element> layers) { for (int i = 0; i < layers.size(); i++) { Element layer = layers.get(i); String layerType = " +"; if (!layer.isVisible()) { layerType = " -"; } result.append("\n").append(layerType).append(getIdText(layer)).append("\n").append(StringHelper.whitespace (layerType.length())).append(layer.getElementStateString(StringHelper.whitespace(layerType.length()), regexpAttribute)); result.append(outputElement(layer, " ", regexpElement, regexpAttribute)); } }
public void hideWithoutEffect() { // don't hide if not visible if (!isVisible()) { return; } resetEffects(); internalHide(); }
@Override public void deactivate() { if (hintPanel != null) { if (hintPanel.isVisible()) { hintPanel.startEffect(EffectEventId.onCustom, new EndNotify() { @Override public void perform() { removePanel(); } }); } else { removePanel(); } } }
private boolean isCursorOnGUI() { int height = app.getContext().getSettings().getHeight(); if (view.isVisible() && view.isMouseInsideElement((int) mousePosition.x, height - (int) mousePosition.y)) { for (Element e : view.getChildren()) { if (e.isVisible() && e.isMouseInsideElement((int) mousePosition.x, height - (int) mousePosition.y)) { return true; } } return false; } return true; }
@Nonnull T item = visibleItems.get(i); if (labelElements[i] != null) { labelElements[i].setVisible(element != null && element.isVisible()); displayElement(i, item); setListBoxItemIndex(i);
@Nonnull T item = visibleItems.get(i); if (labelElements[i] != null) { labelElements[i].setVisible(element != null && element.isVisible()); displayElement(i, item); setListBoxItemIndex(i);
public void hide(@Nullable final EndNotify perform) { // don't hide if not visible if (!isVisible()) { return; } // don't hide if hide is still in progress if (isEffectActive(EffectEventId.onHide)) { return; } // stop any onShow effects when a new onHide effect is about to be started if (isEffectActive(EffectEventId.onShow)) { resetSingleEffect(EffectEventId.onShow); } // start effect and shizzle startEffect(EffectEventId.onHide, new EndNotify() { @Override public void perform() { resetForHide(); internalHide(); if (perform != null) { perform.perform(); } } }); }
@Override public void setHandle(final int pos, final int size) { Element scrollbarElement = scrollbar.getElement(); if (scrollbarElement == null) { return; } if (getAreaSize() < minHandleSize) { if (elementPosition.isVisible()) { elementPosition.hide(); } } else { if (!elementPosition.isVisible()) { elementPosition.show(); } elementPosition.setConstraintY(SizeValue.px(pos)); elementPosition.setConstraintHeight(SizeValue.px(size)); elementBackground.layoutElements(); } }
@Override public void setHandle(final int pos, final int size) { Element scrollbarElement = scrollbar.getElement(); if (scrollbarElement == null) { return; } if (getAreaSize() < minHandleSize) { if (elementPosition.isVisible()) { elementPosition.hide(); } } else { if (!elementPosition.isVisible()) { elementPosition.show(); } elementPosition.setConstraintY(SizeValue.px(pos)); elementPosition.setConstraintHeight(SizeValue.px(size)); elementBackground.layoutElements(); } }
@Override public void setHandle(final int pos, final int size) { Element scrollbarElement = scrollbar.getElement(); if (scrollbarElement == null) { return; } if (elementBackground.getWidth() < minHandleSize) { if (scrollbarElement.isVisible()) { elementPosition.hide(); } } else { if (scrollbarElement.isVisible()) { elementPosition.show(); } elementPosition.setConstraintX(SizeValue.px(pos)); elementPosition.setConstraintWidth(SizeValue.px(size)); elementBackground.layoutElements(); } }
@Override public void setHandle(final int pos, final int size) { Element scrollbarElement = scrollbar.getElement(); if (scrollbarElement == null) { return; } if (elementBackground.getWidth() < minHandleSize) { if (scrollbarElement.isVisible()) { elementPosition.hide(); } } else { if (scrollbarElement.isVisible()) { elementPosition.show(); } elementPosition.setConstraintX(SizeValue.px(pos)); elementPosition.setConstraintWidth(SizeValue.px(size)); elementBackground.layoutElements(); } }
@Override public void execute( @Nonnull final Element element, final float normalizedTime, @Nullable final Falloff falloff, @Nonnull final NiftyRenderEngine r) { if (nifty == null || screen == null || hintLayer == null || hintPanel == null) { log.severe("Can't execute effect. Activation not done or failed."); return; } if (normalizedTime > 0.0) { if (!hintLayer.isVisible()) { // decide if we can already show the hint if (nifty.getNiftyMouse().getNoMouseMovementTime() > hintDelay) { hintPanel.setConstraintX(SizeValue.px(getPosX(element, hintPanel, r.getWidth()))); hintPanel.setConstraintY(SizeValue.px(getPosY(element, hintPanel, r.getHeight()))); // hard remove all old hints, else they only mess with the new ones List<Element> hints = hintLayer.getChildren(); for (int i = 0; i < hints.size() - 1; i++) { nifty.removeElement(screen, hints.get(i)); } hintLayer.layoutElements(); hintLayer.show(); } } } }
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); } }
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); } }
@Override public void onKeyEvent(KeyInputEvent evt) { if (evt.isPressed()) { if (evt.getKeyCode() == KeyInput.KEY_F12) { // FIXME use CTRL + ALT + C to activate cheats! // TODO Disable in multi player! CheatState cheat = stateManager.getState(CheatState.class); if (!cheat.isEnabled()) { cheat.setEnabled(true); } } else if (evt.getKeyCode() == ConsoleState.KEY && Main.isDebug()) { stateManager.getState(ConsoleState.class).setEnabled(true); } else if (evt.getKeyCode() == (Integer) Settings.Setting.TOGGLE_PLAYER_INFORMATION.getDefaultValue()) { Element stats = view.findElementById("statistics"); if (stats != null) { if (stats.isVisible()) { stats.hide(); } else { stats.show(); } } } } }
private void initTab(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)); newButtonTemplate.getAttributes().set("image", ((CustomTabControl) tab).getImage()); newButtonTemplate.getAttributes().set("active", ((CustomTabControl) tab).getImageActive()); newButtonTemplate.getAttributes().set("hintText", ((CustomTabControl) tab).getHint()); newButtonTemplate.getAttributes().set("tooltip", ((CustomTabControl) tab).getTooltip()); 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(); } if (tab instanceof TabGroupMember) { ((TabGroupMember) tab).setParentTabGroup(this); } }
@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(); } }