@Override public void drag(InputEvent event, float x, float y, int pointer) { if (pointer == -1) return; Actor actor = event.getListenerActor(); actor.moveBy(x - getTouchDownX(), y - getTouchDownY()); if (getAllActor().contains(SelectGroup.this.getParent(),false)){ return; } for (Actor child : getAllActor()){ if (child instanceof MainWindow){ break; }else { child.moveBy(x-getTouchDownX(),y-getTouchDownY()); } } Actor lastActor = selection.getLastSelected(); if (lastActor!=null){ EditorManager.getInstance().getEventBus().post(new AttrEvent(lastActor)); if (getParent() instanceof MainWindow){ MainWindow mainWindow = (MainWindow) getParent(); if (mainWindow.getEditorLister()!=null) mainWindow.getEditorLister().change(); } } }
@Override public void clicked(InputEvent event, float x, float y) { if (event.getListenerActor() instanceof FileItem) { FileItem item = (FileItem) event.getListenerActor(); if (getTapCount() == 2) { if (item.getFile().isDirectory()) { AssetWindow.this.load(item.getFile().path()); } else if (item.getFile().extension().equals(Config.sceneExtension)) { EditorManager.getInstance().getEventBus().post(new LoadSceneEvent(item.getFile())); } } item.setSelected(); fileNameLabel.setText(item.getFile().path()); } super.clicked(event, x, y); }
public ObjectEditor(Scene scene, String objectName) { this.scene = scene; top = new Table(); top.add(new VisLabel(objectName)).expandX().pad(0, 20, 0, 20); VisTextButton deleteObject = new VisTextButton("Delete"); deleteObject.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { hasDeleteBeenPressed = true; delete(); } }); top.add(deleteObject).pad(0, 20, 0, 20); add(top).padTop(80).colspan(4).row(); bottom = new Table(); }
private Table setupRedDiceOption(int diceNumber) { Table redDiceOption = new Table(); redDiceOption.setBackground(redBackground); redDiceOption.add(new Label("" + diceNumber, CatanGame.skin)); redDiceOption.setTouchable(Touchable.enabled); redDiceOption.addListener(new ClickListener(){ @Override public void clicked(InputEvent event, float x, float y) { if (chosenRedDice == diceNumber) { System.out.println("discard choice of " + diceNumber); chosenRedDice = 0; enableAllTouchablesRed(); } else { System.out.println("choose " + diceNumber); chosenRedDice = diceNumber; disableAllTouchablesRed(); redDiceOption.setTouchable(Touchable.enabled); redDiceOption.setBackground(redBackground); } } }); return redDiceOption; }
private Table setupYellowDiceOption(int diceNumber) { Table yellowDiceOption = new Table(); yellowDiceOption.setBackground(yellowBackground); yellowDiceOption.add(new Label("" + diceNumber, CatanGame.skin)); yellowDiceOption.setTouchable(Touchable.enabled); yellowDiceOption.addListener(new ClickListener(){ @Override public void clicked(InputEvent event, float x, float y) { if (chosenYellowDice == diceNumber) { System.out.println("discard choice of " + diceNumber); chosenYellowDice = 0; enableAllTouchablesYellow(); } else { System.out.println("choose " + diceNumber); chosenYellowDice = diceNumber; disableAllTouchablesYellow(); yellowDiceOption.setTouchable(Touchable.enabled); yellowDiceOption.setBackground(yellowBackground); } } }); return yellowDiceOption; }
/** * Function used to create the Skins' Buttons and Labels and associate them to a given table, organized. * It also adds Listeners to the Skins' Buttons. * * @param table Table where the Skins' Labels and Buttons will be organized. */ private void createSkins(Table table) { for (int i = 0; i < game.getNumSkins(); ++i) { //Adding Buttons and Labels to the Arrays skinButtons.add(new Button(new TextureRegionDrawable(new TextureRegion(game.getAssetManager().get("big_skins/skin" + (i < 10 ? "0" : "") + i + ".png", Texture.class))))); skinLabels.add(new Label("Current", skin1)); final int j = i; //Needed for Listener initialization skinButtons.get(i).addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { setCurrentLabel(j); } }); table.add(skinButtons.get(i)).size(BUTTON_SIZE, BUTTON_SIZE).pad(IMAGE_EDGE); } table.row(); for (int i = 0; i < game.getNumSkins(); ++i) table.add(skinLabels.get(i)); initializeCurrentSkin(); }
/** * Function used to initialize all the elements of the HUD and add the respective Listeners. */ private void initHUD() { Table hudTable = new Table(); hudTable.setFillParent(true); Button pauseButton = new Button(new TextureRegionDrawable( new TextureRegion(game.getAssetManager().get("pause.png", Texture.class)))); scoreText = new Label("0:00", skin); scoreText.setFontScale(FONT_SCALE, FONT_SCALE); pauseButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { model.togglePause(); } }); hudTable.top(); hudTable.add(scoreText).size(HUD_ELEMENTS_SIZE, HUD_ELEMENTS_SIZE).expandX() .left().fill().padLeft(HORIZONTAL_PAD).padTop(VERTICAL_PAD); hudTable.add(pauseButton).size(HUD_ELEMENTS_SIZE, HUD_ELEMENTS_SIZE).fill() .padRight(HORIZONTAL_PAD).padTop(VERTICAL_PAD); this.addActor(hudTable); }
/** * Adds the Achievements Button to the Networking Menu. * * @param table The table to where the Achievements button will be added. */ private void createAchievementButton(Table table) { TextButton achievementsButton = new TextButton("Achievements", skin1); achievementsButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { gameServices.showAchievements(); } }); table.add(achievementsButton).size(BUTTON_WIDTH, DEFAULT_BUTTON_SIZE).pad(BUTTON_EDGE).row(); }
/** * Adds the Sign In / Sign Out Button to the Networking Menu. * * @param table The table to where the button will be added. */ private void createSignInBtn(Table table) { final TextButton signInButton = new TextButton( gameServices.isSignedIn() ? "Sign Out" : "Sign In!", skin1); signInButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (gameServices.isSignedIn()) { gameServices.signOut(); signInButton.setText("Sign In!"); } else { gameServices.signIn(); signInButton.setText("Sign Out"); } } }); table.add(signInButton).size(BUTTON_WIDTH, DEFAULT_BUTTON_SIZE).pad(BUTTON_EDGE).row(); }
/** * {@inheritDoc} */ @Override protected TextButton addBackBtn(boolean style) { TextButton back = new TextButton("Back", (style ? skin2 : skin1)); back.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { game.setScreen(new NetworkingMenuScreen(game)); } }); return back; }
/** * Create a back button to return to the game scene */ private void initBackButton() { TextButtonSceneObject backButton; backButton = new TextButtonSceneObject(sceneData.createTextButton("Back", Assets.DICE_CHEATS_TEXT_BUTTON_DESCRIPTOR), null); backButton.setBounds(1000, 100, 500, 100); backButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (!canRoll) { writeRollResult(); // write roll result only now as we're done when we press back sceneData.sendMessageFromGui(new EvaluateDiceResultGui()); } } }); addSceneObject(backButton); }
@Override public void create () { camera = new OrthographicCamera(); camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); stage = new Stage(); stage.addListener(new InputListener(){ @Override public boolean touchDown (InputEvent event, float x, float y, int pointer, int button){ stage.getActors().get(counter).addAction(Actions.moveTo(x-50,y-50,1)); counter++; if(counter==stage.getActors().size) { counter=0; } return true; } }); Gdx.input.setInputProcessor(stage); }
public void addTouchListener() { this.addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if (isHighlighted()) { setHighlighted(false); } else { setHighlighted(true); } event.stop(); return true; } }); }
private void initImageButtons() { if (!sceneData.isGameHost()) { return; // player is not hosting - don't offer the player to start the game. } imageButtonStartGame = new ImageButtonSceneObject(sceneData.createImageButton(Assets.START_GAME_BUTTON_FILENAME), buttonPressedSound); imageButtonStartGame.setBounds((Gdx.graphics.getWidth() / 2.0f) - 137.5f, Gdx.graphics.getHeight() / 10.0f, 275f, 240f); imageButtonStartGame.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { sceneData.sendMessageFromGui(new StartGameClicked()); } }); addSceneObject(imageButtonStartGame); imageButtonStartGame.setDisabled(); }
private void config_loading_stage() { // TODO Auto-generated method stub loading_stage = new Stage(managment_viewport, batch); loading_stage.addActor(logo_actor); loading_stage.addActor(loading_background_actor); loading_stage.addActor(loading_actor); loading_stage.addListener(new InputListener(){ @Override public boolean keyDown(InputEvent event, int keycode) { // TODO Auto-generated method stub if(keycode == Keys.BACK){ back_button_down(); } return true; } }); }
public ObjectiveDialog(Skin skin, Hexpert hexpert) { super(hexpert, skin); getBackground().setMinWidth(1000); final TextButton textButtonOK = new TextButton(hexpert.i18NBundle.get("ok"), skin); textButtonOK.addListener(new ClickListener(){ @Override public void clicked(InputEvent event, float x, float y) { textButtonOK.setChecked(false); } }); setObject(textButtonOK, null); getButtonTable().add(textButtonOK); getContentTable().defaults().pad(5, 0, 5, 15); getContentTable().top(); }
public TabSelector(final int slotNum, Texture[] icons, final boolean isVertical, int defaultSlot) { if(slotNum != icons.length) throw new IllegalArgumentException("Icon array length needs to equal slot quantity"); setTouchable(Touchable.enabled); slot = defaultSlot; this.slotNum = slotNum; this.isVertical = isVertical; this.icons = icons; selection = new Texture("theme/basic/ui/SelectionBox.png"); addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if(isVertical) slot = (int)(y / (getHeight() / slotNum)); else slot = (int)(x / (getWidth() / slotNum)); return true; } }); }
protected boolean fireEventOnActor(Actor actor, InputEvent.Type type, int pointer, Actor related) { if (actor == null || !isActorFocussable(actor) || !isActorHittable(actor)) return false; InputEvent event = Pools.obtain(InputEvent.class); event.setType(type); event.setStage(this); event.setRelatedActor(related); event.setPointer(pointer); event.setButton(-1); actor.fire(event); boolean handled = event.isHandled(); Pools.free(event); return handled; }
private void addChangeFaction(){ groupChangeFaction = new Group(); Image background = new Image(new TextureRegion(manager.getAssetsSettings().getTexture(NameFiles.extensionImgBackground))); background.setSize(Width - Width * 0.03f, Height * 0.1f); background.setPosition(Width / 2 - background.getWidth() / 2, Height * 0.3f); groupChangeFaction.addActor(background); Label labelFac = new Label("Change Faction",new Label.LabelStyle(Font.getFont((int)(Height*0.025f)),Color.WHITE)); labelFac.setPosition(background.getX()+background.getWidth()*0.05f,background.getY()+background.getHeight()/2-labelFac.getHeight()/2); labelFac.addListener(new ClickListener(){ @Override public void clicked(InputEvent event, float x, float y) { manager.loadAssetsChoiceFaction(); gameManager.setScreen(new ScreenCircleLoading(gameManager,new ScreenChoiceFaction(gameManager),manager.getAssetsChoiceFaction())); } }); groupChangeFaction.addActor(labelFac); }
private void addTestCombat(){ groupTestCombat = new Group(); Image background = new Image(new TextureRegion(manager.getAssetsSettings().getTexture(NameFiles.extensionImgBackground))); background.setSize(Width - Width * 0.03f, Height * 0.1f); background.setPosition(Width / 2 - background.getWidth() / 2, Height * 0.15f); groupChangeFaction.addActor(background); Label labelFac = new Label("Combat Training",new Label.LabelStyle(Font.getFont((int)(Height*0.025f)),Color.WHITE)); labelFac.setPosition(background.getX()+background.getWidth()*0.05f,background.getY()+background.getHeight()/2-labelFac.getHeight()/2); labelFac.addListener(new ClickListener(){ @Override public void clicked(InputEvent event, float x, float y) { manager.loadAssetsEnklaveScreen(); new GetEnklaveDetails().makeRequest(16066, manager); gameManager.screenEnklave.setEnklave3D(new Vector2(0,0)); gameManager.setScreen(new ScreenCircleLoading(gameManager,gameManager.screenEnklave,manager.getAssertEnklaveScreen()));; } }); groupChangeFaction.addActor(labelFac); }
private void drawtopcombat(){ groupTop = new Group(); Texture lookup = managerAssets.getAssetsCombat().getTexture(NameFiles.progressbarcircular); lookup.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); progressBarEnergy = ProgressBarEnergy.getInstance(); Image imageLeftprofile = new Image(new TextureRegion(managerAssets.getAssetsButton().get(NameFiles.buttonBack1))); imageLeftprofile.setSize(Gdx.graphics.getWidth() * 0.15f, Gdx.graphics.getWidth() * 0.15f); imageLeftprofile.setPosition(imageLeftprofile.getWidth() * 0.1f, Gdx.graphics.getHeight() - imageLeftprofile.getHeight() * 1.1f); imageLeftprofile.addListener(new ClickListener(){ @Override public void clicked(InputEvent event, float x, float y) { if(InformationProfile.getInstance().getDateUserGame().getEnklaveCombatId() == -1) gameManager.setScreen(gameManager.screenEnklave); else dialogExit("You can't out from combat!"); } }); groupTop.addActor(imageLeftprofile); }
public void initButtons(int score,TextureAtlas buttonAtlas) { Skin buttonSkin = new Skin(); buttonSkin.addRegions(buttonAtlas); //TODO FIX THIS SHIT INDENTATION //TODO Long-term fix the magic numbers ImageButton playButton = new ImageButton(buttonSkin.getDrawable("playbutton"), buttonSkin.getDrawable("playbutton")); playButton.setSize(256, 64); playButton.setPosition(screenSize.width/2-playButton.getWidth()/2, screenSize.height/2-playButton.getHeight()/2+50); playButton.addListener(new InputListener() { @Override public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { polymorph.setScreen(new GameScreen(polymorph)); DeathScreenMusic.stop(); return true; } }); stage.addActor(playButton); }
private ButtonField<Item> createField(PacketsSender packetsSender, ItemPositionSupplier userInventoryTakeItemPositionSupplier) { ButtonField<Item> field = new ButtonField<Item>(); field.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (field.hasContent()) { Item item = field.getContent(); TakeItemFromContainerPacket packet = PacketsMaker.makeTakeItemFromContainerPacket( ContainerDialog.this.getId(), item.getId(), userInventoryTakeItemPositionSupplier.get(item)); packetsSender.send(packet); } } }); return field; }
@Override protected ButtonField<ItemQuickAccessIcon> createField(int cellPosition) { InventoryTextField<ItemQuickAccessIcon> inventoryField = new InventoryTextField<>( "F" + String.valueOf(cellPosition + 1)); inventoryField.setTextShiftX(-16); inventoryField.setTextShiftY(-4); inventoryField.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { fieldClicked(cellPosition); } }); return inventoryField; }
public AutoCleanupCloseButton(T dialogToClose, ActorManipulator linkedDialogs) { super(dialogToClose); this.dialogToClose = dialogToClose; this.linkedDialogs = linkedDialogs; this.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { cleanUpDialog(); onPress(); } }); }
private void createComponents() { btBackToMainMenu = new TextButton("Back to Main Menu", skin); btBackToMainMenu.center(); btBackToMainMenu.setWidth(600); btBackToMainMenu.setHeight(80); btBackToMainMenu.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { AL.getGame().setScreen(AL.getScreenManager().get(MainMenuScreen.class)); } }); btBackToMainMenu.setPosition(1920 / 2 - 300, 1080 / 2 + 40); stage.addActor(btBackToMainMenu); endgameLabel = new Label(endgameText, skin); endgameLabel.setWidth(600); endgameLabel.setHeight(80); endgameLabel.setAlignment(Align.center); endgameLabel.setPosition(1920 / 2 - 300, 1080 / 1.5f); stage.addActor(endgameLabel); }
private void initTabs() { // Init Tabs: btTabVideo = new TextButton("Video", skin); btTabVideo.setSize(300, 50); tabbedPane.addTab(btTabVideo); btTabAudio = new TextButton("Audio", skin); btTabAudio.setSize(300, 50); tabbedPane.addTab(btTabAudio); btTabInput = new TextButton("Input", skin); btTabInput.setSize(300, 50); btTabInput.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (!AL.getScreenManager().isRegistered(InputSettingsScreen.class)) AL.getScreenManager().register(new InputSettingsScreen(), InputSettingsScreen.class); AL.getGame().setScreen(AL.getScreenManager().get(InputSettingsScreen.class)); } }); tabbedPane.addTab(btTabInput); }
public GameButton(float WIDTH, float HEIGHT, String drawable, boolean isCheckable) { audioManager = AudioManager.getInstance(); skin = new Skin(); skin.addRegions(AssetsManager.getTextureAtlas()); Button.ButtonStyle buttonStyle = new Button.ButtonStyle(); buttonStyle.up = skin.getDrawable(drawable); buttonStyle.down = skin.getDrawable(drawable + "_pressed"); if (isCheckable) { buttonStyle.checked = skin.getDrawable(drawable + "_pressed"); } setStyle(buttonStyle); setSize(WIDTH, HEIGHT); rectangle = new Rectangle(getX(),getY(),getWidth(),getHeight()); addListener(new ClickListener(){ @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); audioManager.playSound(audioManager.getButtonSound()); } }); }
@Override protected void onInitUI() { Skin skin = GdxUISkin.instance().getDeafult(); input = new TextField("", skin); ClickListener mClickListener = new ClickListener() { public boolean keyDown (InputEvent event, int keycode) { if(keycode == Keys.ENTER && !isHide()) { if(!handleCmdString(input.getText())) { //clear input input.setText(null); } } return true; } }; input.addCaptureListener(mClickListener); input.setTextFieldFilter(new TextFieldFilter() { @Override public boolean acceptChar(TextField textField, char c) { if(c == '`' || c == '~') { hide(); return false; } return true; } }); label = new Label("", skin); maxTmp = GdxUIConfig.instance().consoleMaxOutputLine; input.setSize(getUIWidth()/2, 32); input.setPosition(20, getUIHeight() * 0.25f); addUI(input); addUI(label); skin = null; }
public void setListeners(Stage stage) { stage.addListener(new InputListener() { @Override public boolean scrolled(InputEvent event, float x, float y, int amount) { if (editingZone != null) editingZone.zoomBy(amount); return false; } }); }
@Override public void addListeners() { super.addListeners(); submit.addListener(new ClickListener(){ @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { presenter.screenAction(); submit.setDisabled(true); submit.setTouchable(Touchable.disabled); return true; } }); }
private void setupButton(TextButton pTextButton, ScreenKind pScreenkind) { // add listener to button pTextButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { aGame.clickSound.play(0.2F); pTextButton.setChecked(false); aGame.switchScreen(pScreenkind); } }); aMenuTable.add(pTextButton).padLeft(25).padRight(25).left(); }
/** * Adds the Exit Button to the Main Menu. * * @param table The table to where the Exit button will be added. */ private void addExitButton(Table table) { TextButton exitButton = new TextButton("Exit", skin1); exitButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.app.exit(); } }); table.add(exitButton).size(BUTTON_WIDTH, DEFAULT_BUTTON_SIZE).pad(BUTTON_EDGE).row(); }
/** * Adds the Options Button to the Main Menu. * * @param table The table to where the Options button will be added. */ private void addOptionsButton(Table table) { TextButton optionsButton = new TextButton("Options", skin1); optionsButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { game.setScreen(new CustomizeMenuScreen(game)); } }); table.add(optionsButton).size(BUTTON_WIDTH, DEFAULT_BUTTON_SIZE).pad(BUTTON_EDGE).row(); }
/** * Adds the play Button to the Main Menu. * * @param table The table to where the play button will be added. */ private void addPlayButton(Table table) { TextButton playButton = new TextButton("Play", skin1); playButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { game.setScreen(new LevelMenuScreen(game)); } }); table.add(playButton).size(BUTTON_WIDTH, DEFAULT_BUTTON_SIZE).pad(BUTTON_EDGE).row(); }
public FreeridingDialog(final Hexpert hexpert, Skin skin) { super(hexpert, skin.get("gold", WindowStyle.class)); getBackground().setMinWidth(1400); I18NBundle i18N = hexpert.i18NBundle; Label lblRate = new Label(i18N.get("freerider"), skin.get("bigger", Label.LabelStyle.class)); lblRate.setAlignment(Align.center); lblRate.setWrap(true); getContentTable().add(lblRate).width(1200); TextButton.TextButtonStyle goldenStyle = skin.get("gold", TextButton.TextButtonStyle.class); TextButton textButtonRate = new TextButton(i18N.get("rate"), goldenStyle); getButtonTable().add(textButtonRate).width(textButtonRate.getLabelCell().getPrefWidth() + 30); TextButton textButtonNo = new TextButton(i18N.get("no"), goldenStyle); getButtonTable().add(textButtonNo); setObject(textButtonNo, null); textButtonRate.addListener(new ClickListener(){ @Override public void clicked(InputEvent event, float x, float y) { hexpert.playServices.rateGame(); hide(); } }); setObject(textButtonRate, null); }
/** * {@inheritDoc} */ @Override protected void addLevelListener(final int level) { levelButtons.get(level).addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { gameServices.showScores(level); } }); }
/** * Function that adds an Exit Button to the Stage. */ protected void addExitBtn() { TextButton exitBtn = new TextButton("Exit", this.skin); exitBtn.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { game.setScreen(new LevelMenuScreen(game)); } }); table.add(exitBtn).size(BUTTON_WIDTH, BUTTON_HEIGHT); }
/** * Function that adds a Restart Button to the Stage. */ protected void addRestartBtn() { TextButton restartBtn = new TextButton("Restart", skin); restartBtn.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { startLevel(); } }); table.add(restartBtn).size(BUTTON_WIDTH, BUTTON_HEIGHT).padBottom(BUTTON_DISTANCE).row(); }
/** * Function that adds a Button responsible for showing the Leaderboard of the current Level. */ protected void addLeaderboardBtn() { TextButton leaderboardBtn = new TextButton("Leaderboard", skin); leaderboardBtn.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { game.getGameServices().showScores(hud.getCurrentLevel() - 1); } }); table.add(leaderboardBtn).size(BUTTON_WIDTH, BUTTON_HEIGHT).padBottom(BUTTON_DISTANCE).row(); }