com.badlogic.gdx.scenes.scene2d.utils.ClickListener Java Examples

The following examples show how to use com.badlogic.gdx.scenes.scene2d.utils.ClickListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EffectRosterViewController.java    From gdx-vfx with Apache License 2.0 6 votes vote down vote up
private void addEffectToChain(final EffectEntryModel effectModel) {
    if (effectsChain.containsKey(effectModel)) {
        // If the effect is already in the chain, re-add it to the end of the list.
        removeEffectFromChain(effectModel);
    }

    EffectEntryViewController viewController = new EffectEntryViewController(lmlParser, effectModel);
    Group viewRoot = viewController.getViewRoot();
    vgEffectsChain.addActor(viewRoot);
    effectsChain.put(viewController.getModel(), viewController);
    vfxManager.addEffect(viewController.getModel().getEffect());

    viewRoot.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            removeEffectFromChain(effectModel);
        }
    });
}
 
Example #2
Source File: UIStage.java    From talos with Apache License 2.0 6 votes vote down vote up
public void initExampleList (PopupMenu examples) {
	FileHandle list = Gdx.files.internal("samples/list.xml");
	XmlReader xmlReader = new XmlReader();
	XmlReader.Element root = xmlReader.parse(list);
	Array<XmlReader.Element> samples = root.getChildrenByName("sample");
	for (XmlReader.Element sample : samples) {
		String name = sample.getAttribute("name");
		final String fileName = sample.getAttribute("file");
		MenuItem item = new MenuItem(name);
		examples.addItem(item);

		item.addListener(new ClickListener() {
			@Override
			public void clicked (InputEvent event, float x, float y) {
				super.clicked(event, x, y);
				//openProject(fileName);
				TalosMain.Instance().ProjectController().lastDirTrackingDisable();
				TalosMain.Instance().ProjectController().setProject(ProjectController.TLS);
				TalosMain.Instance().ProjectController().loadProject(Gdx.files.internal("samples/" + fileName));
				TalosMain.Instance().ProjectController().lastDirTrackingEnable();
				TalosMain.Instance().ProjectController().unbindFromFile();
			}
		});
	}
}
 
Example #3
Source File: SettingsDialog.java    From talos with Apache License 2.0 6 votes vote down vote up
public void addPathSetting(String name, final String id) {
    Table inputTable = new Table();

    inputTable.add(new Label(name, getSkin())).width(220);
    final TextField inputPathField = new TextField("", getSkin());
    inputTable.add(inputPathField).padLeft(13).width(270);
    TextButton browseInputBtn = new TextButton("Browse", getSkin());
    inputTable.add(browseInputBtn).padLeft(3);

    add(inputTable).pad(5).left().expandX().padTop(10);
    row();

    textFieldMap.put(id, inputPathField);

    browseInputBtn.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            showFolderSelect(id);
        }
    });
}
 
Example #4
Source File: UsersList.java    From Cardshifter with Apache License 2.0 6 votes vote down vote up
public void handleUserStatus(UserStatusMessage message) {
    switch (message.getStatus()) {
        case OFFLINE:
            UserTable table = userMap.get(message.getUserId());
            if (table != null) {
                table.remove();
            }
            break;
        case ONLINE:
            table = userMap.get(message.getUserId());
            if (table == null) {
                final UserTable userTable = new UserTable(skin, message.getUserId(), message.getName());
                userMap.put(message.getUserId(), userTable);
                userTable.getTable().addListener(new ClickListener() {
                    @Override
                    public void clicked(InputEvent event, float x, float y) {
                    	UsersList.this.selectUser(userTable);

                    }
                });
                this.table.add(userTable.getTable()).align(Align.left).row();
            }
            break;
    }
}
 
Example #5
Source File: BasicColorPicker.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
private VisTable createColorsPreviewTable () {
	VisTable table = new VisTable(false);
	table.add(currentColorImg = new AlphaImage(commons, 5 * sizes.scaleFactor))
			.height(25 * sizes.scaleFactor).width(80 * sizes.scaleFactor).expandX().fillX();
	table.add(new Image(style.iconArrowRight)).pad(0, 2, 0, 2);
	table.add(newColorImg = new AlphaImage(commons, 5 * sizes.scaleFactor))
			.height(25 * sizes.scaleFactor).width(80 * sizes.scaleFactor).expandX().fillX();

	currentColorImg.setColor(color);
	newColorImg.setColor(color);

	currentColorImg.addListener(new ClickListener() {
		@Override
		public void clicked (InputEvent event, float x, float y) {
			restoreLastColor();
		}
	});

	return table;
}
 
Example #6
Source File: MainMenu.java    From talos with Apache License 2.0 6 votes vote down vote up
public void updateRecentsList(Array<String> list) {
    openRecentPopup.clear();

    for(String path: list) {
        final FileHandle handle = Gdx.files.absolute(path);
        if(!handle.exists()) continue;;
        String name = handle.name();
        MenuItem item = new MenuItem(name);
        item.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                super.clicked(event, x, y);
                if(handle.extension().equals("tls")) {
                    TalosMain.Instance().ProjectController().setProject(ProjectController.TLS);
                    TalosMain.Instance().ProjectController().loadProject(handle);
                } else {
                    TalosMain.Instance().Addons().projectFileDrop(handle);
                }
            }
        });
        openRecentPopup.addItem(item);
    }
}
 
Example #7
Source File: FileChooserField.java    From Mundus with Apache License 2.0 6 votes vote down vote up
private void setupListeners() {

        fcBtn.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                super.clicked(event, x, y);
                FileChooser fileChooser = UI.INSTANCE.getFileChooser();
                fileChooser.setSelectionMode(mode);
                fileChooser.setListener(new SingleFileChooserListener() {
                    @Override
                    protected void selected(FileHandle file) {
                        fileHandle = file;
                        path = file.path();

                        textField.setText(file.path());
                        if (fileSelected != null) {
                            fileSelected.selected(file);
                        }
                    }
                });
                UI.INSTANCE.addActor(fileChooser.fadeIn());
            }
        });

    }
 
Example #8
Source File: ImageChooserField.java    From Mundus with Apache License 2.0 6 votes vote down vote up
private void setupListeners() {
    fcBtn.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            FileChooser fileChooser = UI.INSTANCE.getFileChooser();
            fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);
            fileChooser.setListener(new SingleFileChooserListener() {
                public void selected(FileHandle file) {
                    if (FileFormatUtils.isImage(file)) {
                        setImage(file);
                    } else {
                        Dialogs.showErrorDialog(UI.INSTANCE, "This is no image");
                    }
                }
            });
            UI.INSTANCE.addActor(fileChooser.fadeIn());
        }
    });
}
 
Example #9
Source File: TreeTools.java    From libgdx-snippets with MIT License 6 votes vote down vote up
public static ClickListener createNodeClickListener(Tree tree, Runnable clicked) {

		return new ClickListener() {

			@Override
			public void clicked(InputEvent event, float x, float y) {
				super.clicked(event, x, y);

				Tree.Node node = tree.getNodeAt(y);

				if (node != null && node.getChildren().size > 0) {
					node.setExpanded(!node.isExpanded());
					tree.getClickListener().clicked(event, x, y);
				}

				clicked.run();
			}
		};
	}
 
Example #10
Source File: ModuleBoardWidget.java    From talos with Apache License 2.0 6 votes vote down vote up
public ModuleBoardWidget(NodeStage mainStage) {
    super();
    this.mainStage = mainStage;

    curvePoints[0] = new Vector2();
    curvePoints[1] = new Vector2();
    curvePoints[2] = new Vector2();
    curvePoints[3] = new Vector2();

    addActor(groupContainer);
    addActor(moduleContainer);

    shapeRenderer = new ShapeRenderer();

    addListener(new ClickListener() {

        @Override
        public boolean keyUp(InputEvent event, int keycode) {
            if(event.isHandled()) return super.keyUp(event, keycode);
            if(keycode == Input.Keys.DEL || keycode == Input.Keys.FORWARD_DEL) {
                deleteSelectedWrappers();
            }
            return super.keyUp(event, keycode);
        }
    });
}
 
Example #11
Source File: AttachmentTypeToggle.java    From talos with Apache License 2.0 6 votes vote down vote up
public AttachmentTypeToggle(Skin skin) {
    setSkin(skin);
    setBackground(getSkin().getDrawable("panel_button_bg"));

    drawableMap.put(AttachmentPoint.AttachmentType.POSITION, getSkin().getDrawable("icon-target"));
    drawableMap.put(AttachmentPoint.AttachmentType.ROTATION, getSkin().getDrawable("icon-angle"));
    drawableMap.put(AttachmentPoint.AttachmentType.TRANSPARENCY, getSkin().getDrawable("icon-transparency"));
    drawableMap.put(AttachmentPoint.AttachmentType.COLOR, getSkin().getDrawable("icon-color"));

    button = new ImageButton(drawableMap.get(AttachmentPoint.AttachmentType.POSITION));

    addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            currentType = currentType.next();
            setButtonDrawable();
        }
    });

    setButtonDrawable();
}
 
Example #12
Source File: Button.java    From riiablo with Apache License 2.0 6 votes vote down vote up
public Button(ButtonStyle style) {
  super(style);
  addListener(new ClickListener() {
    Sound button = null;

    {
      Riiablo.assets.load(buttonDescriptor);
    }

    @Override
    public boolean touchDown(InputEvent event, float x, float y, int pointer, int b) {
      if (event.getButton() != Input.Buttons.LEFT || isDisabled()) {
        return super.touchDown(event, x, y, pointer, b);
      } else if (button == null) {
        Riiablo.assets.finishLoadingAsset(buttonDescriptor);
        button = Riiablo.assets.get(buttonDescriptor);
      }

      button.play();
      Riiablo.input.vibrate(10);
      return super.touchDown(event, x, y, pointer, b);
    }
  });
}
 
Example #13
Source File: LobbyScreen.java    From riiablo with Apache License 2.0 6 votes vote down vote up
TabbedPane(TextureRegion defaultBackground) {
  background.setRegion(this.defaultBackground = defaultBackground);
  setBackground(background);
  buttons.setMinCheckCount(0);
  clickListener = new ClickListener() {
    @Override
    public void clicked(InputEvent event, float x, float y) {
      Button button = (Button) event.getListenerActor();
      TabGroup previous = getActor();
      TabGroup content = map.get(button.getName());
      setActor(content);
      setBackground(content.background);
      content.exited();
      content.entered();
    }
  };
}
 
Example #14
Source File: SystemProfilerGUI.java    From riiablo with Apache License 2.0 6 votes vote down vote up
public SystemProfilerGUI(Skin skin, String style) {
  super("Profiler", skin, style);
  this.skin = skin;

  setVisible(false);
  setResizable(true);
  setResizeBorder(12);
  TextButton closeButton = new TextButton("X", skin);
  getTitleTable().add(closeButton).padRight(3);
  closeButton.addListener(new ClickListener() {
    @Override
    public void clicked(InputEvent event, float x, float y) {
      hide();
    }
  });
}
 
Example #15
Source File: SelectScreen.java    From Unlucky with MIT License 6 votes vote down vote up
/**
 * Handles the position and events of the exit button
 */
protected void handleExitButton(final Screen screen) {
    // init exit button
    ImageButton.ImageButtonStyle style = new ImageButton.ImageButtonStyle();
    style.imageUp = new TextureRegionDrawable(rm.menuExitButton[0][0]);
    style.imageDown = new TextureRegionDrawable(rm.menuExitButton[1][0]);
    exitButton = new ImageButton(style);
    exitButton.setSize(18, 18);
    exitButton.setPosition(177, 99);
    stage.addActor(exitButton);

    // fade back to previous screen
    exitButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (!game.player.settings.muteSfx) rm.buttonclick0.play(game.player.settings.sfxVolume);
            game.menuScreen.transitionIn = 0;
            setFadeScreen(screen);
        }
    });
}
 
Example #16
Source File: MainController.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@OnEvent(ShowToastEvent.class) void onEvent(final ShowToastEvent event) {
    if (viewShown) {
        final Toast toast;
        if (event.getContent() != null) {
            toast = toastManager.show(event.getContent(), event.getDuration());
        } else {
            toast = toastManager.show(event.getMessage(), event.getDuration());
        }
        // Setup click listener (if provided).
        if (event.getClickAction() != null) {
            Table mainTable = toast.getMainTable();
            mainTable.setTouchable(Touchable.enabled);
            mainTable.addListener(new ClickListener() {
                @Override
                public void clicked(InputEvent e, float x, float y) {
                    if (e.getTarget() == e.getListenerActor()) {
                        event.getClickAction().run();
                        toastManager.remove(toast);
                    }
                }
            });
        }
    }
}
 
Example #17
Source File: BehaviorTreeTests.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
private List<String> createTestList () {
	// Create behavior names
	int numTests = tests.length;
	String[] testNames = new String[numTests];
	for (int i = 0; i < numTests; i++) {
		testNames[i] = tests[i].getName();
	}

	final List<String> testList = new List<String>(skin);
	testList.setItems(testNames);
	testList.addListener(new ClickListener() {
		@Override
		public void clicked (InputEvent event, float x, float y) {
			changeTest(testList.getSelectedIndex());
		}
	});
	return testList;
}
 
Example #18
Source File: ListViewOnClickLmlAttribute.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@Override
public void process(LmlParser parser, LmlTag tag, final ListView.ListViewTable listTable, String rawAttributeData) {
    final ActorConsumer<?, ListView.ListViewTable> action = parser.parseAction(rawAttributeData, listTable);
    if (action == null) {
        parser.throwError("Could not find action for: " + rawAttributeData + " with actor: " + listTable);
        return;
    }

    listTable.getListView().getScrollPane().addListener(new ClickListener(0) {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (event.getTarget() == event.getListenerActor()) {
                action.consume(listTable);
            }
        }
    });
}
 
Example #19
Source File: OnRightClickLmlAttribute.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@Override
public void process(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) {
    final ActorConsumer<?, Params> action = parser.parseAction(rawAttributeData, tmpParams);
    if (action == null) {
        parser.throwError("Could not find action for: " + rawAttributeData + " with actor: " + actor);
    }
    actor.addListener(new ClickListener(1) {
        @Override
        public void clicked(final InputEvent event, final float x, final float y) {
            tmpParams.actor = actor;
            tmpParams.x = x;
            tmpParams.y = y;
            tmpParams.stageX = event.getStageX();
            tmpParams.stageY = event.getStageY();
            action.consume(tmpParams);
            tmpParams.reset();
        }
    });
}
 
Example #20
Source File: PlayerView.java    From Cardshifter with Apache License 2.0 6 votes vote down vote up
public PlayerView(CardshifterClientContext context, PlayerMessage message) {
    this.context = context;
    this.table = new Table(context.getSkin());
    this.id = message.getId();
    this.index = message.getIndex();
    ResViewFactory rvf = new ResViewFactory(context.getSkin());
    this.resources = rvf.forFormat(rvf.res("SCRAP"), rvf.str(" "), rvf.res("MANA"), rvf.str(" "), rvf.coloredRes("HEALTH", "MAX_HEALTH"));
    this.properties = new HashMap<String, Integer>(message.getProperties());
    this.table.add(message.getName()).row();
    this.table.add(this.resources.getActor()).row();
    this.table.add(actions);
    table.setTouchable(Touchable.enabled);
    table.addListener(new ClickListener(){
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (callback != null) {
                callback.addEntity(PlayerView.this);
            }
        }
    });
    resources.update(properties);
}
 
Example #21
Source File: EditWidget.java    From skin-composer with MIT License 6 votes vote down vote up
private void addSimListener() {
    addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (simActor != null) {
                dialog.simActor = simActor;
                dialog.populateProperties();
                dialog.model.updatePreview();
                dialog.populatePath();
                
                var label = new FadeLabel(simActor.toString(), main.getSkin(), "scene-edit-tip");
                main.getStage().addActor(label);
                label.setPosition(Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY());
            }
        }
    });
    addListener(main.getHandListener());
}
 
Example #22
Source File: TImage.java    From cocos-ui-libgdx with Apache License 2.0 6 votes vote down vote up
public TImage isButton() {
    clearListeners();
    origonCenter();
    addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            addAction(Actions.sequence(Actions.scaleTo(0.9f, 0.9f, 0.1f), Actions.scaleTo(1, 1, 0.1f), Actions.run(new Runnable() {
                @Override
                public void run() {
                    if (clickListener != null) {
                        clickListener.onClicked(TImage.this);
                    }
                }
            })));
        }
    });
    return this;
}
 
Example #23
Source File: T.java    From cocos-ui-libgdx with Apache License 2.0 6 votes vote down vote up
public T isButton(final TClickListener clickListener) {
    actor.setTouchable(Touchable.enabled);
    actor.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            actor.addAction(Actions.sequence(Actions.scaleTo(0.9f, 0.9f, 0.1f), Actions.scaleTo(1, 1, 0.1f), Actions.run(new Runnable() {
                @Override
                public void run() {
                    if (clickListener != null) {
                        clickListener.onClick(actor);
                    }
                }
            })));
        }
    });

    return this;
}
 
Example #24
Source File: TabPane.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #25
Source File: CreatureInfoWindow.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
private ClickListener createListener(final Group group, final Image selection, final LocLabel label, final CreatureEffect effect, final Creature creature) {
    return new ClickListener() {
        @Override public void clicked(InputEvent event, float x, float y) {
            group.addActor(selection);
            final int turnCount = effect.getTurnCount();
            if (turnCount > 1000) {
                //forever effect
                label.setKey("ui-creature-info-window-forever-effect-description");
                label.setParams(Thesaurus.params()
                        .with("desc", effect.locDescKey())
                        .with("die", creature.description.nameLocKey())
                );
            } else {
                label.setKey("ui-creature-info-window-effect-description");
                label.setParams(Thesaurus.params()
                        .with("desc", effect.locDescKey())
                        .with("turn-count", String.valueOf(turnCount))
                        .with("die", creature.description.nameLocKey())
                );
            }
        }
    };
}
 
Example #26
Source File: DeckCardView.java    From Cardshifter with Apache License 2.0 6 votes vote down vote up
public DeckCardView(Skin skin, int id, String name, DeckBuilderScreen screen) {
    super(skin);
    this.count = new Label("", skin);
    this.add(count).left().expand().fill();
    this.add(new Label(name, skin)).right();
    this.name = name;
    this.id = id;
    this.screen = screen;
    setName(name);
    
    this.setTouchable(Touchable.enabled);
    this.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            DeckCardView.this.screen.removeCardFromDeck(DeckCardView.this.id);
        }
    });
}
 
Example #27
Source File: FilteredSelectBox.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
public FilteredSelectBox(FilteredSelectBoxStyle style) {
	setStyle(style);
	setSize(getPrefWidth(), getPrefHeight());

	selection.setActor(this);
	selection.setRequired(true);

	selectBoxList = new SelectBoxList<>(this);

	addListener(clickListener = new ClickListener() {
		@Override
		public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
			if (pointer == 0 && button != 0)
				return false;
			if (disabled)
				return false;
			if (selectBoxList.hasParent())
				hideList();
			else
				showList();
			return true;
		}
	});

}
 
Example #28
Source File: TImage.java    From cocos-ui-libgdx with Apache License 2.0 5 votes vote down vote up
public TImage isNoButton() {
    clearListeners();
    origonCenter();
    addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            if (clickListener != null) {
                clickListener.onClicked(TImage.this);
            }
        }
    });
    return this;
}
 
Example #29
Source File: SelectCreatureToResurrectWindow.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
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);
        }
    };
}
 
Example #30
Source File: DemoScreen.java    From cocos-ui-libgdx with Apache License 2.0 5 votes vote down vote up
private void initDemoChange(InputMultiplexer multiplexer) {
    Stage demoChangeStage = new Stage(new StretchViewport(DemoGame.GAME_WIDTH, DemoGame.GAME_HEIGHT));
    Actor actor = new Actor();
    actor.setWidth(stage.getWidth());
    actor.setHeight(stage.getHeight());
    actor.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            updateCurrentIndex();
            changeDemo();
        }
    });
    demoChangeStage.addActor(actor);
    multiplexer.addProcessor(demoChangeStage);
}