Java Code Examples for com.badlogic.gdx.scenes.scene2d.InputEvent#getListenerActor()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.InputEvent#getListenerActor() . 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: 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 2
Source File: ScrollFocusCaptureInputListener.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
    Actor actor = event.getListenerActor();
    Stage stage = actor.getStage();
    if (stage == null) return;

    if (stage.getScrollFocus() != actor) {
        stage.setScrollFocus(actor);
    }
}
 
Example 3
Source File: ScrollFocusCaptureInputListener.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
    Actor actor = event.getListenerActor();
    Stage stage = actor.getStage();
    if (stage == null) return;

    // Stage fires "exit" event upon touchUp() even if pointer is still over the actor.
    // This is simple workaround.
    if (x > 0 && y > 0 && x < actor.getWidth() && y < actor.getHeight()) return;

    if (stage.getScrollFocus() == actor) {
        stage.setScrollFocus(null);
    }
}
 
Example 4
Source File: TabbedPane.java    From riiablo with Apache License 2.0 5 votes vote down vote up
public TabbedPane() {
  clickListener = new ClickListener() {
    @Override
    public void clicked(InputEvent event, float x, float y) {
      Button button = (Button) event.getListenerActor();
      contentPanel.setActor(map.get(button.getName()));
      notifyTabSwitched(buttons.getChecked().getName(), button.getName());
    }
  };

  add(tabs = new VisTable()).growX().row();
  add(new Image(VisUI.getSkin().getDrawable("list-selection"))).growX().row();
  add(contentPanel = new Container<>()).align(Align.top).row();
}
 
Example 5
Source File: IbeamListener.java    From skin-composer with MIT License 4 votes vote down vote up
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
    if (!(event.getListenerActor() instanceof Disableable) || !((Disableable) event.getListenerActor()).isDisabled())
        Gdx.graphics.setSystemCursor(SystemCursor.Ibeam);
}
 
Example 6
Source File: HandListener.java    From skin-composer with MIT License 4 votes vote down vote up
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
    if (!(event.getListenerActor() instanceof Disableable) || !((Disableable) event.getListenerActor()).isDisabled())
        Gdx.graphics.setSystemCursor(Cursor.SystemCursor.Hand);
}
 
Example 7
Source File: MultiplayerScreen.java    From riiablo with Apache License 2.0 4 votes vote down vote up
public MultiplayerScreen(Animation D2logoLeft, Animation D2logoRight) {
  this.D2logoLeft = D2logoLeft;
  this.D2logoRight = D2logoRight;
  load();

  stage = new Stage(Riiablo.defaultViewport, Riiablo.batch);

  Riiablo.assets.finishLoadingAsset(TitleScreenDescriptor);
  TitleScreen = Riiablo.assets.get(TitleScreenDescriptor).getTexture();

  if (D2logoLeft == null || D2logoRight == null) {
    Riiablo.music.enqueue("data/global/music/Act1/tristram.wav");
  }

  if (D2logoLeft == null) {
    Riiablo.assets.finishLoadingAsset(D2logoBlackLeftDescriptor);
    Riiablo.assets.finishLoadingAsset(D2logoFireLeftDescriptor);
    this.D2logoLeft = D2logoLeft = Animation.builder()
        .layer(Riiablo.assets.get(D2logoBlackLeftDescriptor))
        .layer(Riiablo.assets.get(D2logoFireLeftDescriptor), BlendMode.LUMINOSITY)
        .build();
  }

  if (D2logoRight == null) {
    Riiablo.assets.finishLoadingAsset(D2logoBlackRightDescriptor);
    Riiablo.assets.finishLoadingAsset(D2logoFireRightDescriptor);
    this.D2logoRight = D2logoRight = Animation.builder()
        .layer(Riiablo.assets.get(D2logoBlackRightDescriptor))
        .layer(Riiablo.assets.get(D2logoFireRightDescriptor), BlendMode.LUMINOSITY)
        .build();
  }
  D2logo = new AnimationWrapper(D2logoLeft, D2logoRight);
  D2logo.setPosition(stage.getWidth() * 0.50f, stage.getHeight() * 0.75f);
  stage.addActor(D2logo);

  TextButton.TextButtonStyle style = new TextButton.TextButtonStyle() {{
      Riiablo.assets.finishLoadingAsset(WideButtonBlankDescriptor);
      DC6 WideButtonBlank = Riiablo.assets.get(WideButtonBlankDescriptor);
      up   = new TextureRegionDrawable(WideButtonBlank.getTexture(0));
      down = new TextureRegionDrawable(WideButtonBlank.getTexture(1));
      font = Riiablo.fonts.fontexocet10;
  }};
  ClickListener clickListener = new ClickListener() {
    @Override
    public void clicked(InputEvent event, float x, float y) {
      Actor actor = event.getListenerActor();
      if (actor == btnOpenBattlenet) {
        Riiablo.client.pushScreen(new LoginScreen(MultiplayerScreen.this.D2logoLeft, MultiplayerScreen.this.D2logoRight));
      } else if (actor == btnTCPIP) {
        Riiablo.client.pushScreen(new TCPIPScreen(MultiplayerScreen.this.D2logoLeft, MultiplayerScreen.this.D2logoRight));
      } else if (actor == btnCancel) {
        Riiablo.client.popScreen();
      }
    }
  };
  btnOpenBattlenet = new TextButton(5115, style);
  btnOpenBattlenet.addListener(clickListener);
  btnTCPIP = new TextButton(5116, style);
  btnTCPIP.addListener(clickListener);
  btnCancel = new TextButton(5134, style);
  btnCancel.addListener(clickListener);

  final Table panel = new Table() {{
    final float SPACING = 8;
    add(btnOpenBattlenet).space(SPACING).row();
    add(btnTCPIP).space(SPACING).row();
    add(btnCancel).space(SPACING).row();
    pack();
  }};
  panel.setPosition(stage.getWidth() / 2, D2logo.getY() / 2, Align.center);
  stage.addActor(panel);
}
 
Example 8
Source File: LoadSaveScreen.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void clicked(InputEvent event, float x, float y) {
	final Actor listenerActor = event.getListenerActor();

	Dialog d = new Dialog("", ui.getSkin()) {
		@Override
		protected void result(Object object) {
			if (((Boolean) object).booleanValue()) {
				final World world = ui.getWorld();
				final String filename = listenerActor.getName() + WorldSerialization.GAMESTATE_EXT;

				try {
					world.removeGameState(filename);

					listenerActor.getParent().getParent().getParent()
							.removeActor(listenerActor.getParent().getParent());

				} catch (IOException e) {
					EngineLogger.error(e.getMessage());
				}
			}
		}
	};

	d.pad(DPIUtils.getMarginSize());
	d.getButtonTable().padTop(DPIUtils.getMarginSize());
	d.getButtonTable().defaults().padLeft(DPIUtils.getMarginSize()).padRight(DPIUtils.getMarginSize());

	Label l = new Label(ui.getWorld().getI18N().getString("ui.remove"), ui.getSkin(), "ui-dialog");
	l.setWrap(true);
	l.setAlignment(Align.center);

	d.getContentTable().add(l).prefWidth(Gdx.graphics.getWidth() * .7f);

	d.button(ui.getWorld().getI18N().getString("ui.yes"), true,
			ui.getSkin().get("ui-dialog", TextButtonStyle.class));
	d.button(ui.getWorld().getI18N().getString("ui.no"), false,
			ui.getSkin().get("ui-dialog", TextButtonStyle.class));
	d.key(Keys.ENTER, true).key(Keys.ESCAPE, false);

	d.show(stage);
}