public VisSlider createSlider(String label, float minimum, float maximum, float[] snapValues, float threshold, float initialValue, ChangeListener changeListener) { if(!label.isEmpty()) { add(new VisLabel(label)).left().padRight(10).padTop(20); } add(new VisLabel((int)minimum + "")).padRight(5).padTop(20); VisSlider slider = new VisSlider(minimum, maximum, 1, false); slider.setSnapToValues(snapValues, threshold); slider.setValue(initialValue); slider.addListener(new EventListener() { @Override public boolean handle(Event event) { event.stop(); return false; } }); slider.addListener(changeListener); add(slider).expandX().fill().padRight(5).padTop(20); add(new VisLabel("" + (int)maximum)).padTop(20).row(); return slider; }
public ServerRunningMenu(Save save, int port) { super(Localization.get("menu.general.loading"), Localization.get("menu.server.stop")); this.save = save; this.port = port; addButtonListener(new EventListener() { @Override public boolean handle(Event event) { if (!(event instanceof ChangeListener.ChangeEvent)) return false; try { Adapter.gotoMainMenu(); } catch (StopLoopException ignored) { } return true; } }); }
@Override public Actor getActor(VisualSettingManager visualSettingManager) { final SelectBox<String> selectBox = new SelectBox<String>(visualSettingManager.getSkin()); selectBox.setItems(options); selectBox.setSelected(selected); selectBox.addListener(new EventListener() { @Override public boolean handle(Event event) { if (!(event instanceof SettingsMenu.SaveEvent)) return false; set(selectBox.getSelected()); return true; } }); return selectBox; }
public void create() { stage = new Stage(); Gdx.input.setInputProcessor(stage); //font = new BitmapFont(); //skin = new Skin(); //buttonAtlas = new TextureAtlas(Gdx.files.internal()); //skin.addRegions(buttonAtlas); button = new Button(); button.setStyle(new Button.ButtonStyle()); button.addCaptureListener(new EventListener() { @Override public boolean handle(Event event) { Gdx.app.log("LOG", "event " + event); return false; } }); stage.addActor(button); }
private void init(){ // Vector2 point = localToStageCoordinates(new Vector2(getX(), getY()));//TODO // // if(chooseTransparent != null) chooseTransparent.setBounds(point.x + borderSize, point.y + borderSize, //if() - button not empty // getWidth() - borderSize * 2, getHeight() - borderSize * 2); // if(cdText != null) cdText.setBounds(getX() + borderSize, getY() + borderSize, // getWidth() - borderSize * 2, getHeight() - borderSize * 2); // System.out.println(getX() + " " + getY() + " " + getWidth() + " " + getHeight()); for (EventListener l:getListeners()) { if (l instanceof TooltipListener) { ((SpellTooltip) ((TooltipListener) l).getTooltip()).init(getStage()); } if(l instanceof SpellButton.SpellThrower){ ((SpellButton.SpellThrower) l).init(getStage()); } } }
private void notifyListeners(){ gradeTowerSlot.getSlot().notifyListeners(); for (int i = 0; i < g.length; i++){ for (Actor a:g[i].getChildren()){ for (EventListener t:a.getListeners()){ if(t instanceof TooltipListener){ ((TooltipListener) t).getTooltip().hasChanged(); ((TooltipListener) t).getTooltip().pack(); } } if(a instanceof GemGradeButton){ ((GemGradeButton) a).update(); } } } }
public GestureButton(String styleName, ViewManager viewManager) { style = VisUI.getSkin().get(styleName, GestureButtonStyle.class); style.checked = style.select; filterStyle = new GestureButtonStyle(); filterStyle.down = style.down; filterStyle.checked = style.checked; filterStyle.up = style.up; if (style.downFiltered != null) filterStyle.down = style.downFiltered; if (style.selectFilterd != null) filterStyle.checked = style.selectFilterd; if (style.upFiltered != null) filterStyle.up = style.upFiltered; this.viewManager = viewManager; this.setStyle(style); this.ID = idCounter++; buttonActions = new ArrayList<>(); //remove all Listeners Array<EventListener> listeners = this.getListeners(); for (EventListener listener : listeners) { this.removeListener(listener); } this.addCaptureListener(gestureListener); this.pack(); }
private void place(Creature creature, int x, int y) { WorldObjectView spawnView = dieToIconToSpawn.get(creature.description); placed.add(creature); refreshStartButton(); world.add(x, y, creature); WorldObjectView worldView = world.getController(ViewController.class).getView(creature); EventListener listener = createMoveSpawnedListener(creature, worldView, spawnView); EventListener prev = moveListeners.remove(worldView); if (prev != null) { worldView.removeListener(prev); } moveListeners.put(worldView, listener); worldView.addListener(listener); spawnView.getColor().a = 0f; spawnView.setTouchable(Touchable.disabled); }
public void addTab(Actor header, Actor content) { if (listeners.containsKey(header)) throw new IllegalArgumentException("header already exists"); headers.add(header); contents.add(content); super.addActor(header); if (selectedIndex == -1) setSelectedIndex(0); invalidate(); final int index = headers.size - 1; EventListener listener = new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { setSelectedIndex(index); event.cancel(); } }; header.addListener(listener); listeners.put(header, listener); }
@Override public void start(Callback callback) { Stage stage = resources.get("stage"); EventListener listener = resources.getIfExists("restrictCloseWindowsListener"); if (listener != null) { stage.removeCaptureListener(listener); } if (windowClass == null) { callback.taskEnded(); return; } listener = new WindowListener() { @Override protected void hide(WindowEvent event) { if (!windowClass.isInstance(event.getWindow())) { event.cancel(); } } }; stage.addCaptureListener(listener); resources.put("restrictCloseWindowsListener", listener); callback.taskEnded(); }
@Override public void process(final LmlParser parser, final LmlTag tag, Actor actor, final String rawAttributeData) { // Due to ListView tricky structure we should dig a little to get to the scrollable actor if (actor instanceof ListView.ListViewTable) { actor = ((ListView.ListViewTable) actor).getListView().getScrollPane(); } boolean value = Boolean.parseBoolean(rawAttributeData); if (value) { // Add scroll focus capture listeners actor.addListener(new ScrollFocusCaptureInputListener()); } else { // Remove scroll focus capture listener Iterator<EventListener> iterator = actor.getListeners().iterator(); while (iterator.hasNext()) { EventListener listener = iterator.next(); if (listener instanceof ScrollFocusCaptureInputListener) { iterator.remove(); } } } }
public FlopsyScreen(FlopsyDroidGame game, OnGlobalListener listener) { mStage = new Stage(); mGlobalListener = listener; game.getAssetManager().load("flopsy.sprites", TextureAtlas.class); game.getAssetManager().finishLoading(); mTextureAtlas = game.getAssetManager().get("flopsy.sprites", TextureAtlas.class); mLabelStyle = new Label.LabelStyle(); mLabelStyle.font = new BitmapFont(Gdx.files.internal("flappyfont.fnt"), Gdx.files.internal("flappyfont.png"), false); mStage.addListener(new EventListener() { @Override public boolean handle(Event event) { if(event.getTarget().equals(mAndy)) { mGround.onDroidCollision(); return true; } return false; } }); }
public void showStudio(){ Frame.actorPanel.clear(); Scene.getRoot().clearChildren(); Scene.getCurrentScene().clear(); Camera.clearAllHud(); Camera.followActor(null); Camera.reset(); if(selectedValueExists()){ Scene.getCurrentScene().load(getSelectedValue()); for(Actor child: Scene.getCurrentScene().getChildren()){ Frame.actorPanel.addActor(child.getName()); for(EventListener l: child.getListeners()) child.removeListener(l); } Scene.getRoot().addActor(Scene.getCurrentScene()); } Frame.sceneEffectPanel.update(); }
@Override public Actor[] getActors(Skin skin) { ImageButton musicTooltip = new OwnImageButton(skin, "tooltip"); musicTooltip.addListener(new TextTooltip( I18n.bundle.format("gui.tooltip.music", SysUtilsFactory.getSysUtils().getDefaultMusicDir()), skin)); ImageButton reloadMusic = new OwnImageButton(skin, "reload"); reloadMusic.setName("reload music"); reloadMusic.addListener(new EventListener() { @Override public boolean handle(Event event) { if (event instanceof ChangeEvent) { EventManager.instance.post(Events.MUSIC_RELOAD_CMD); return true; } return false; } }); reloadMusic.addListener(new TextTooltip(I18n.bundle.get("gui.music.reload"), skin)); return new Actor[] { musicTooltip, reloadMusic }; }
private void initialize() { if (cursorLocation == null) { cursor = GlobalResources.linkCursor; } else { cursor = new Pixmap(Gdx.files.internal(cursorLocation)); } listeners = new DelayedRemovalArray<EventListener>(); this.addListener(new EventListener() { @Override public boolean handle(Event event) { if (event instanceof InputEvent) { Type type = ((InputEvent) event).getType(); if (type == Type.enter) { if (!me.isDisabled()) Gdx.graphics.setCursor(Gdx.graphics.newCursor(cursor, 4, 0)); return true; } else if (type == Type.exit) { Gdx.graphics.setSystemCursor(SystemCursor.Arrow); return true; } } return false; } }); }
private void initialize() { this.addListener(new EventListener() { @Override public boolean handle(Event event) { if (event instanceof InputEvent) { Type type = ((InputEvent) event).getType(); if (type == Type.enter) { if (!me.isDisabled()) Gdx.graphics.setCursor(Gdx.graphics.newCursor(cursor != null ? cursor : GlobalResources.linkCursor, 4, 0)); return true; } else if (type == Type.exit) { Gdx.graphics.setSystemCursor(SystemCursor.Arrow); return true; } } return false; } }); }
private void initialize() { this.addListener(new EventListener() { @Override public boolean handle(Event event) { if (event instanceof InputEvent) { Type type = ((InputEvent) event).getType(); // Click if (type == Type.touchUp && ((InputEvent) event).getButton() == Buttons.LEFT) { Gdx.net.openURI(linkURL); } else if (type == Type.enter) { Gdx.graphics.setCursor(Gdx.graphics.newCursor(GlobalResources.linkCursor, 4, 0)); } else if (type == Type.exit) { Gdx.graphics.setSystemCursor(SystemCursor.Arrow); } return true; } return false; } }); }
public GUIJoystick(float x, float y, Texture t, Texture pT, float w, float h, EventListener dl) { table = new Table(); table.setFillParent(false); table.setPosition(x, y); table.setWidth(w); table.setHeight(h); this.texture = t; this.pressTexture = pT; background = new Image(texture); pressElement = new Image(pressTexture); pressElement.setVisible(false); background.setFillParent(true); table.add(background); table.add(pressElement); center = new Vector2(table.getCenterX(), table.getCenterY()); tapListener = dl; table.addListener(dl); }
public TextButton addButton(String name, String value, EventListener listener) { if (buttonsTable == null) { add(buttonsTable = new Table()).colspan(2).expandX().fillX().padBottom(8); } buttonsTable.row(); if (name == null) { buttonsTable.add().expandX(); } else { buttonsTable.add(new Label(name, smallWhite)).expandX().right().padRight(12); } TextButton button = new TextButton(value, skin); if (listener != null) { button.addListener(listener); } buttonsTable.add(button).width(Value.percentWidth(0.5F)).right().padRight(8); buttons.add(button); return button; }
private void addCategoryLabel() { int toFill = columns - gallery.getGrid().getChildren().size % columns; for (int i = 0; i < toFill; i++) { gallery.addSpace(); } CategoryButton aux = categories.get(count); Label cat = new Label(aux.getButtonText(), skin, SkinConstants.STYLE_BIG); gallery.addOriginal(cat); gallery.addSpace(); Container<TextButton> more = new Container<TextButton>(); TextButton button = new TextButton(i18N.m("more").toUpperCase(), skin, SkinConstants.STYLE_CATEGORY); Color color = aux.getColor(); color.a = 1; button.setColor(color); more.setActor(button); for (EventListener listener : aux.getListeners()) { button.addListener(listener); } more.right(); gallery.addOriginal(more); }
public final TextButton a(String paramString1, String paramString2, EventListener paramEventListener) { if (this.jdField_a_of_type_ComBadlogicGdxScenesScene2dUiTable == null) { Table localTable = new Table(); this.jdField_a_of_type_ComBadlogicGdxScenesScene2dUiTable = localTable; add(localTable).b(Integer.valueOf(2)).o().g().h(8.0F); } this.jdField_a_of_type_ComBadlogicGdxScenesScene2dUiTable.row(); if (paramString1 == null) this.jdField_a_of_type_ComBadlogicGdxScenesScene2dUiTable.add().o(); while (true) { TextButton localTextButton = new TextButton(paramString2, this.jdField_a_of_type_ComBadlogicGdxScenesScene2dUiSkin); if (paramEventListener != null) localTextButton.addListener(paramEventListener); this.jdField_a_of_type_ComBadlogicGdxScenesScene2dUiTable.add(localTextButton).a(e.a(0.5F)).m().i(8.0F); this.jdField_a_of_type_JavaUtilList.add(localTextButton); return localTextButton; this.jdField_a_of_type_ComBadlogicGdxScenesScene2dUiTable.add(new Label(paramString1, this.jdField_a_of_type_ComBadlogicGdxScenesScene2dUiLabel$LabelStyle)).o().m().i(12.0F); } }
public static void readAttr(Group parentGroup, XmlReader.Element element, EventListener dragListener){ if (element.getName().equals("Stage")){ XmlUtils.parseGenAttr(parentGroup,element); if (element.getChildCount()>0){ for (int i = 0;i<element.getChildCount();i++){ readAttr(parentGroup,element.getChild(i),dragListener); } } }else if (element.getName().equals("Group")){ Group group = new Group(); XmlUtils.parseGenAttr(group,element); group.addListener(dragListener); parentGroup.addActor(group); if (element.getChildCount()>0){ for (int i = 0;i<element.getChildCount();i++){ readAttr(group,element.getChild(i),dragListener); } } }else { Actor actor = EditorManager.getInstance().getActorByName(element.getName()); parentGroup.addActor(actor); actor.addListener(dragListener); XmlUtils.parseGenAttr(actor,element); XmlUtils.parseUqAttr(actor,element); } }
@Override public void render() { super.render(); if (!firstRender) return; addButtonListener(new EventListener() { @Override public boolean handle(Event event) { if (!(event instanceof ChangeListener.ChangeEvent)) return false; Adapter.setMenu(new MainMenu()); return true; } }); firstRender = false; }
@Override public Actor getActor(VisualSettingManager visualSettingManager) { final TextField textField = new TextField(s, visualSettingManager.getSkin()); textField.addListener(new EventListener() { @Override public boolean handle(Event event) { if (!(event instanceof SettingsMenu.SaveEvent)) return false; set(textField.getText()); return true; } }); return textField; }
public void initialize(Main main, EventListener listener) { this.main = main; instance = this; this.listener = listener; filesDroppedListener = (Array<FileHandle> files) -> { Iterator<FileHandle> iter = files.iterator(); while (iter.hasNext()) { FileHandle file = iter.next(); if (file.isDirectory() || !(file.name().toLowerCase().endsWith(".png") || file.name().toLowerCase().endsWith(".jpg") || file.name().toLowerCase().endsWith(".jpeg") || file.name().toLowerCase().endsWith(".bmp") || file.name().toLowerCase().endsWith(".gif"))) { iter.remove(); } } if (files.size > 0) { drawablesSelected(files); } }; main.getDesktopWorker().addFilesDroppedListener(filesDroppedListener); drawablePairs = new ObjectMap<>(); gatherDrawables(); produceAtlas(); populate(); }
private void resetTargeting(){ for (EventListener l:getListeners()) { if(l instanceof SpellButton.SpellThrower){ // ((SpellButton.SpellThrower) l); } } }
public void notifyListeners(){ for (EventListener e:getListeners()){ if(e instanceof TooltipListener){ ((TooltipListener) e).getTooltip().hasChanged(); } } }
public AdjustableStarListViewItem(int listIndex, final IntProperty property, final CharSequence name, AdjustableStarWidget.Type type) { super(listIndex); this.property = property; this.adjustableWidget = new AdjustableStarWidget(type, name, property); this.add(this.adjustableWidget).expandX().fillX().padTop(CB.scaledSizes.MARGIN).padBottom(CB.scaledSizes.MARGIN); property.setChangeListener(new Property.PropertyChangedListener() { @Override public void propertyChanged() { log.debug("Property {} changed to {}", name, property.get()); //property changed, so set name to "?" filterSettings.filterProperties.setName("?"); } }); // ListViewItem catch the ClickEvent from Button/Label // So we reroute the event to the Button! this.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (event.getTarget() instanceof VisTextButton || event.getTarget().getParent() instanceof VisTextButton) { Array<EventListener> listeners = event.getTarget() instanceof VisTextButton ? event.getTarget().getListeners() : event.getTarget().getParent().getListeners(); int n = listeners.size; while (n-- > 0) { EventListener listener = listeners.get(n); if (listener instanceof ClickListener) { ((ClickListener) listener).clicked(event, x, y); } } } } }); }
public static void triggerButtonClicked(Button button) { log.debug("Perform click event on {}", button); Array<EventListener> listeners = button.getListeners(); for (int i = 0; i < listeners.size; i++) { if (listeners.get(i) instanceof ClickListener) { ((ClickListener) listeners.get(i)).clicked(null, 0, 0); } } }
private EventListener createListener(final Ability ability, final Creature creature, final ClickListener clickListener, final World world, final Future<TurnResponse> future) { return new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { new ProfessionAbilityPlayWindow().show(new ProfessionAbilityPlayWindow.Params(ability, creature, new ProfessionAbilityPlayWindow.Callback() { @Override public void onUseAbility() { UserTurnProcessor.this.cancel(); future.happen(new TurnResponse<Ability>(TurnResponse.TurnAction.PROFESSION_ABILITY, ability)); } })); } }; }
@Override public void start(Callback callback) { for (int keyCode : keyCodes) { EventListener listener = resources.getIfExists("restrictKeyPress" + keyCode); if (listener != null) { Stage stage = resources.get("stage"); stage.removeCaptureListener(listener); resources.remove("restrictKeyPress" + keyCode); } } callback.taskEnded(); }
private EventListener createListener(final Creature creature) { return new ActorGestureListener(20, 0.4f, 0.5f, 0.15f) { @Override public boolean longPress(Actor actor, float x, float y) { creatureInfoWindow.show(new CreatureInfoWindow.Params(creature, array.first().world)); return true; } }; }
private EventListener listener(final GameMapState.ConflictResolution resolution) { return new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { ConflictWindow.this.resolution = resolution; hide(); } }; }
private EventListener createListener(final Creature creature, final TextButton button, final WorldObjectView view, final Image selection) { return new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { view.addActor(selection); selection.toBack(); selected = creature; button.setDisabled(false); } }; }
@Override public void start(Callback callback) { Stage stage = resources.get("stage"); EventListener listener = resources.getIfExists("restrictCloseWindowsListener"); if (listener != null) { stage.removeCaptureListener(listener); } listener = new WindowListener() { @Override protected void hide(WindowEvent event) { event.cancel(); } }; stage.addCaptureListener(listener); resources.put("restrictCloseWindowsListener", listener); callback.taskEnded(); }
public static void showStageEvents(final Stage stage) { EventListener listener = new EventListener() { private final Vector2 tmp = new Vector2(); private Actor actor = new Actor() { @Override public void draw(Batch batch, float parentAlpha) { if (target == null) return; batch.end(); Config.shapeRenderer.begin(ShapeRenderer.ShapeType.Line); Config.shapeRenderer.setProjectionMatrix(stage.getCamera().combined); Gdx.gl.glLineWidth(6); Config.shapeRenderer.setColor(Color.ORANGE); Vector2 pos = target.localToStageCoordinates(tmp.set(0, 0)); float x = pos.x, y = pos.y; Vector2 top = target.localToStageCoordinates(tmp.set(target.getWidth(), target.getHeight())); float maxX = top.x, maxY = top.y; Config.shapeRenderer.rect(x, y, maxX - x, maxY - y); Config.shapeRenderer.end(); batch.begin(); } }; { stage.addActor(actor); } public Actor target; @Override public boolean handle(Event event) { target = event.getTarget(); return false; } }; stage.addListener(listener); }