public void addTab(String tabTitle, final ITabContent tabContent, Skin skin) { TextButton button = new TextButton(tabTitle, skin); button.align(Align.left); //button.setFillParent(true); button.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { tabContent.setContent(content); content.pack(); setWidth(preferedContentWidth); setHeight(preferedContentHeight); } }); tabHeaders.add(button); contents.add(tabContent); preferedContentWidth = Math.max(preferedContentWidth, tabContent.getWidth()); preferedContentHeight = Math.max(preferedContentHeight, tabContent.getHeight() + tabHeaders.get(0).getHeight()); }
public GameDialog(Skin skin) { super("", skin); waveLevel = new Label("", skin); monsHP = new Label("", skin); monsBonus = new Label("", skin); monsSpeed = new Label("", skin); monsNumber = new Label("", skin); btnOK = new TextButton("Okay, Let them come!", skin); btnOK.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { // TODO Auto-generated method stub setVisible(false); } }); setTitle(" There are more monsters are coming to you... "); }
@Override public boolean handle(Event event) { if (event instanceof ChangeEvent) { Actor target = event.getTarget(); boolean isDecrease = target.equals(decreaseButton); int skillIncreases = stats.getSkillIncreasesThisLevel(skill); if (isDecrease && increases > 0) { --increases; stats.decrementSkillIncreasesThisLevel(skill); stats.setSkillPoints(stats.getSkillPoints()+1); stats.skills().decreaseSkillRank(skill); return true; } else if (!isDecrease && skillIncreases < Configuration.getSkillIncreasesPerLevel()) { ++increases; stats.incrementSkillIncreasesThisLevel(skill); stats.setSkillPoints(stats.getSkillPoints()-1); stats.skills().increaseSkillRank(skill); return true; } } return false; }
public boolean changed (ChangeEvent event, Actor actor) { if (endTurnButton.equals(actor) && GameState.isPlayersTurn()) { UIManager.hideToolTip(); gameState.unpauseGame(); gameState.switchToNextSide(); endTurnButton.setDisabled(true); ignoreEvent = true; endTurnButton.setChecked(true); ignoreEvent = false; return true; } else if (endCombatButton.equals(actor)) { if (GameState.canPlayerEndCombat()) { gameState.endCombat(); } } return false; }
@Override public boolean handle(Event event) { if (event instanceof ChangeEvent) { if ("EXIT".equals(event.getTarget().getName())) { dispose(); Gdx.app.exit(); } else if ("OK".equals(event.getTarget().getName())) { SelectOption<String> selected = moduleSelectBox.getSelected(); if (selected != null) { FileHandle currentModuleFile = Gdx.files.local(Configuration.FILE_LAST_MODULE); currentModuleFile.writeString(selected.value, false); dispose(); game.reloadGame(); } } return true; } return false; }
/** * Sets the progress bar position, rounded to the nearest step size and clamped to the minumum and maximim values. * {@link #clamp(float)} can be overidden to allow values outside of the progress bars min/max range. * * @return false if the value was not changed because the progress bar already had the value or it was canceled by a listener. */ public boolean setValue(float value) { value = snap(clamp(Math.round(value / stepSize) * stepSize)); float oldValue = this.value; if (value == oldValue) { return false; } float oldVisualValue = getVisualValue(); this.value = value; ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); boolean cancelled = fire(changeEvent); if (cancelled) { this.value = oldValue; } else if (animateDuration > 0) { animateFromValue = oldVisualValue; animateTime = animateDuration; } Pools.free(changeEvent); return !cancelled; }
/** Sets the progress bar position, rounded to the nearest step size and clamped to the minimum and maximum values. * {@link #clamp(float)} can be overridden to allow values outside of the progress bar's min/max range. * @return false if the value was not changed because the progress bar already had the value or it was canceled by a listener. */ public boolean setValue (float value) { value = clamp(Math.round(value / stepSize) * stepSize); if (!shiftIgnoresSnap || (!Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) && !Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT))) value = snap(value); float oldValue = this.value; if (value == oldValue) return false; float oldVisualValue = getVisualValue(); this.value = value; ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); boolean cancelled = fire(changeEvent); if (cancelled) this.value = oldValue; else if (animateDuration > 0) { animateFromValue = oldVisualValue; animateTime = animateDuration; } Pools.free(changeEvent); return !cancelled; }
@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 }; }
/** * Override to append all animations if selected. */ @Override protected void ok() { @SuppressWarnings("unchecked") SelectBox<String> cb = (SelectBox<String>) id.getField(); if (e == null && cb.getSelectedIndex() == 0) { for (int i = 1; i < cb.getItems().size; i++) { cb.setSelectedIndex(i); inputsToModel(true); // doc.setId(e, cb.getItems().get(i)); if (listener != null) listener.changed(new ChangeEvent(), this); } } else { super.ok(); } }
@Override protected void ok() { Message.showMsg(getStage(), "Creating resolution...", true); Timer.schedule(new Task() { @Override public void run() { createResolution(); String msg = scaleImages(); if(listener != null) listener.changed(new ChangeEvent(), CreateResolutionDialog.this); Message.hideMsg(); if(msg != null) Message.showMsgDialog(getStage(), "Error creating resolution", msg); } },1); }
@Override public boolean handle(Event event) { if (event instanceof ChangeEvent) { currentState = State.PLAYBACK; final InputPlayer player = new InputPlayer(writer.getReader()); player.addPlaybackListener(new PlaybackAdapter() { @Override public void onSyncPropertiesFinish() { player.stopPlayback(); currentState = State.BEFORE_RECORD; layout(); } }); layout(); player.startPlayback(); } return true; }
public boolean setValue(float value) { value = clamp(Math.round(value / stepSize) * stepSize); if (!shiftIgnoresSnap || (!Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) && !Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT))) value = snap(value); float oldValue = this.value; if (value == oldValue) return false; float oldVisualValue = getVisualValue(); this.value = value; ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); boolean cancelled = fire(changeEvent); if (cancelled) this.value = oldValue; else if (animateDuration > 0) { animateFromValue = oldVisualValue; animateTime = animateDuration; } Pools.free(changeEvent); return !cancelled; }
public void setChecked(boolean paramBoolean) { if (this.isChecked == paramBoolean); do { do return; while ((this.buttonGroup != null) && (!this.buttonGroup.canCheck(this, paramBoolean))); this.isChecked = paramBoolean; } while (this.isDisabled); ChangeListener.ChangeEvent localChangeEvent = (ChangeListener.ChangeEvent)Pools.obtain(ChangeListener.ChangeEvent.class); if (fire(localChangeEvent)) if (paramBoolean) break label73; label73: for (boolean bool = true; ; bool = false) { this.isChecked = bool; Pools.free(localChangeEvent); return; } }
public boolean touchDown(InputEvent paramInputEvent, float paramFloat1, float paramFloat2, int paramInt1, int paramInt2) { if ((paramInt1 == 0) && (paramInt2 != 0)) return false; this.this$1.stageToLocalCoordinates(Vector2.tmp); float f1 = Vector2.tmp.x; float f2 = Vector2.tmp.y; if ((f1 > 0.0F) && (f1 < this.this$1.getWidth()) && (f2 > 0.0F) && (f2 < this.this$1.getHeight())) { this.this$1.listSelectedIndex = ((int)((this.this$1.getHeight() - f2) / this.this$1.itemHeight)); this.this$1.listSelectedIndex = Math.max(0, this.this$1.listSelectedIndex); this.this$1.listSelectedIndex = Math.min(-1 + this.this$1.this$0.items.length, this.this$1.listSelectedIndex); this.this$1.this$0.selectedIndex = this.this$1.listSelectedIndex; if (this.this$1.this$0.items.length > 0) { ChangeListener.ChangeEvent localChangeEvent = (ChangeListener.ChangeEvent)Pools.obtain(ChangeListener.ChangeEvent.class); this.this$1.this$0.fire(localChangeEvent); Pools.free(localChangeEvent); } } return true; }
/**------------------------RENDER------------------------**/ @Override public void render(float f) { //Debug //stage.setDebugAll(true); //Clear Screen Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1); Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT); //Set background image rootTable.background(new TextureRegionDrawable(new TextureRegion(TextureManager.menuBackground))); //Render stage stage.act(Constants.DELTATIME); stage.draw(); /*------------------SWITCH TO FULLSCREEN AND BACK------------------*/ super.changeToFullScreenOnF12(); /*------------------QUIT GAME------------------*/ if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) { game.setScreen(new MenuScreen(game, client, server)); } /*------------------JOIN GAME WITH ENTER------------------*/ if(Gdx.input.isKeyJustPressed(Input.Keys.ENTER)) { ChangeEvent event1 = new ChangeEvent(); joinButton.fire(event1); } }
public boolean changed (ChangeEvent event, Actor actor) { if (actor instanceof StatBar) { return false; } if (UIManager.getDisplayedCharacter() != null) { if (!pc.equals(UIManager.getDisplayedCharacter())) { if (levelUpIndicator.equals(actor) && !UIManager.isPerksScreenOpen()) { UIManager.togglePerks(pc); } else { UIManager.switchDisplayedCharacter(pc); } } else if (levelUpIndicator.equals(actor)) { UIManager.togglePerks(pc); } } else { PlayerCharacterController controller = gameState.getPlayerCharacterController(); if (controller.isTargetSelectionInProgress()) { Vector2 tempVector = MathUtil.getVector2(); boolean returnValue = controller.handleTargetSelection(Buttons.LEFT, pc.position().setVector2(tempVector)); MathUtil.freeVector2(tempVector); return returnValue; } if (levelUpIndicator.equals(actor)) { UIManager.togglePerks(pc); return true; } if (!controller.isMultiSelectActive()) { boolean wasSelected = pc.isSelected(); GameState.getPlayerCharacterGroup().selectOnlyMember(pc); if (!wasSelected) { pc.getAudioProfile().playCharacterBark(pc); } } else { GameState.getPlayerCharacterGroup().toggleMemberSelection(pc); } } return true; }
@Override public boolean handle(Event event) { if (!(event instanceof ChangeEvent)) { return false; } changed((ChangeEvent)event, event.getTarget()); return false; }
public boolean changed (ChangeEvent event, String actorName) { UIManager.hideToolTip(); if (GATHER.equals(actorName)) { performGather(); } else if (SLEEP.equals(actorName)) { final int sleepDuration = Configuration.getSleepDuration(); if (sleepDuration <= 0) { return true; } GameState.getPlayerCharacterGroup().sleep(sleepDuration, new BasicCallback() { @Override public void callback() { recalculateChangedItems(); } }); } else if (PACKUP.equals(actorName)) { UIManager.displayConfirmation( Strings.getString(SurvivalManager.STRING_TABLE, "packCampQuestion"), Strings.getString(SurvivalManager.STRING_TABLE, "packCampConfirmation",Configuration.getPackingCampDuration()), new OkCancelCallback<Void>() { @Override public void onOk(Void nada) { ProgressDialogSettings settings = new ProgressDialogSettings(Strings.getString(SurvivalManager.STRING_TABLE, "PackingUp"), Configuration.getPackingCampDuration(), false); gameState.fastForwardTimeBy(settings, new SurvivalFastForwardCallback() { @Override public void onFinished() { UIManager.hideCampPanel(); } }, false); } }); } return true; }
public boolean changed (ChangeEvent event, Actor actor) { if (inventoryButton == actor) { UIManager.toggleInventory(group.getGroupLeader()); } else if (characterSheetButton == actor) { UIManager.togglePerks(group.getGroupLeader()); } else if (usePerkButton == actor) { UIManager.toggleUsePerks(group.getGroupLeader()); } else if (journalButton == actor) { UIManager.toggleJournal(); } else if (spellbookButton == actor) { UIManager.toggleSpellbook(group.getGroupLeader()); } else if (activeEffectsButton == actor) { UIManager.toggleActiveEffects(group.getGroupLeader()); } else if (campButton == actor && !UIManager.isCampOpen()) { group.sleepOrCamp(); } else if (stealthButton == actor) { gameState.toggleStealth(); } else if (lockpickButton == actor) { gameState.getPlayerCharacterController().toggleTool(Tool.LOCKPICK); } else if (detectTrapsButton == actor) { group.toggleDetectTraps(); } else if (disarmTrapsButton == actor) { gameState.getPlayerCharacterController().toggleTool(Tool.DISARM); } else if (formationEditorButton == actor) { UIManager.toggleFormationEditor(); } else if (attackButton == actor) { gameState.getPlayerCharacterController().toggleTool(Tool.ATTACK); }else if (talkToButton == actor) { gameState.getPlayerCharacterController().toggleTool(Tool.TALKTO); } return true; }
@Override public boolean handle(Event event) { if (!(event instanceof ChangeEvent)) { return false; } if (ignoreEvent) { return false; } return changed((ChangeEvent)event, event.getTarget()); }
public ErrorScreen(String errorMessage, String optionalButtonText) { this.skin = new SkinWithTrueTypeFonts(Gdx.files.internal(ModuleSelectionScreen.SKIN_PATH)); TextButton exitButton = new TextButton("Exit", skin); exitButton.addListener(new EventListener() { @Override public boolean handle(Event event) { if (event instanceof ChangeEvent) { dispose(); Gdx.app.exit(); } return false; } }); Window window = new Window("Error", skin); window.pad(30, 10, 10, 10); window.setModal(true); window.setMovable(false); window.add(new Label(errorMessage, skin)).padBottom(20).padTop(10); window.row(); Table buttonsTable = new Table(); if (optionalButtonText != null) { optionalButton = new TextButton(optionalButtonText, skin); buttonsTable.add(optionalButton).fill().minWidth(100).height(40).padRight(30); } buttonsTable.add(exitButton).fill().minWidth(100).height(40); window.add(buttonsTable).center(); window.pack(); stage.addActor(window); WindowPosition.CENTER.position(window); }
/** Sends a ChangeEvent, with this TabbedPane as the target, to each registered listener. This method is called each time there * is a change to the selected index. */ protected void fireStateChanged () { ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); changeEvent.setBubbles(false); fire(changeEvent); Pools.free(changeEvent); }
private void update() { content.clear(); content.add(new Table() { { add(WidgetUtils.tooltip("The skill's range, relative to a centered target.")); add(new VisLabel("Targets")); } }).row(); content.add(new Table() { { for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { final int x = i - CENTER_OFFSET; final int y = j - CENTER_OFFSET; add(new VisCheckBox("", isChecked(x, y)) { { addListener(new EventListener() { @Override public boolean handle(Event event) { if (event instanceof ChangeEvent) { setTarget(x, y, isChecked()); return true; } return false; } }); if (x == 0 && y == 0) { setDebug(true); setColor(Color.YELLOW); setBackground(Drawables.get("blue")); } } }); } row(); } } }); }
/** Fires a change event on the selection's actor, if any. Called internally when the selection changes, depending on * {@link #setProgrammaticChangeEvents(boolean)}. * @return true if the change should be undone. */ public boolean fireChangeEvent () { if (actor == null) return false; ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); try { return actor.fire(changeEvent); } finally { Pools.free(changeEvent); } }
public void setChecked (boolean isChecked) { if (this.isChecked == isChecked) return; if (buttonGroup != null && !buttonGroup.canCheck(this, isChecked)) return; this.isChecked = isChecked; ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); if (fire(changeEvent)) this.isChecked = !isChecked; Pools.free(changeEvent); }
void calculatePositionAndValue (float x, float y, boolean isTouchUp) { float oldPositionX = knobPosition.x; float oldPositionY = knobPosition.y; float oldPercentX = knobPercent.x; float oldPercentY = knobPercent.y; float centerX = knobBounds.x; float centerY = knobBounds.y; knobPosition.set(centerX, centerY); knobPercent.set(0f, 0f); if (!isTouchUp) { if (!deadzoneBounds.contains(x, y)) { knobPercent.set((x - centerX) / knobBounds.radius, (y - centerY) / knobBounds.radius); float length = knobPercent.len(); if (length > 1) knobPercent.scl(1 / length); if (knobBounds.contains(x, y)) { knobPosition.set(x, y); } else { knobPosition.set(knobPercent).nor().scl(knobBounds.radius).add(knobBounds.x, knobBounds.y); } } } if (oldPercentX != knobPercent.x || oldPercentY != knobPercent.y) { ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); if (fire(changeEvent)) { knobPercent.set(oldPercentX, oldPercentY); knobPosition.set(oldPositionX, oldPositionY); } Pools.free(changeEvent); } }
/** @param oldText May be null. * @return True if the text was changed. */ boolean changeText(String oldText, String newText) { if (newText.equals(oldText)) return false; text = newText; ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); boolean cancelled = fire(changeEvent); text = cancelled ? oldText : newText; Pools.free(changeEvent); return !cancelled; }
@Override public boolean handle(Event event) { if (event instanceof ChangeEvent) { GaiaCatalogWindow gaiaWindow = new GaiaCatalogWindow(GaiaSky.instance.mainGui.getGuiStage(), skin); gaiaWindow.initialize(focus); gaiaWindow.display(); return true; } return false; }
@Override protected void ok() { if (previousId == null) { create(); } else { newId = inputId.getText(); renameChapter(); } if(listener != null) listener.changed(new ChangeEvent(), this); }
@Override protected void ok() { try{ inputsToModel(e==null); } catch (Exception e1) { Message.showMsg(getStage(), "Error getting fields " + e1.getMessage(), 4); EditorLogger.printStackTrace(e1); } if (listener != null) listener.changed(new ChangeEvent(), this); }
@Override public boolean handle(Event event) { if (event instanceof ChangeEvent) { currentState = State.RECORDING; layout(); try { recorder.startRecording(); } catch (IOException e) { e.printStackTrace(); } } return true; }
@Override public boolean handle(Event event) { if (event instanceof ChangeEvent) { currentState = State.AFTER_RECORD; try { recorder.stopRecording(); } catch (IOException e) { e.printStackTrace(); } layout(); } return true; }
/** * @param oldText May be null. * @return True if the text was changed. */ boolean changeText (String oldText, String newText) { if (ignoreEqualsTextChange && newText.equals(oldText)) return false; text = newText; beforeChangeEventFired(); ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); boolean cancelled = fire(changeEvent); text = cancelled ? oldText : newText; Pools.free(changeEvent); return !cancelled; }
private void updateValueFromTouch (float y) { int newValue = (int) (y / BasicColorPicker.PALETTE_SIZE * maxValue / sizes.scaleFactor); setValue(newValue); ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); fire(changeEvent); Pools.free(changeEvent); }
private void updateValueFromTouch (float touchX, float touchY) { int newV = (int) (touchX / BasicColorPicker.PALETTE_SIZE * maxValue / sizes.scaleFactor); int newS = (int) (touchY / BasicColorPicker.PALETTE_SIZE * maxValue / sizes.scaleFactor); setValue(newS, newV); ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); fire(changeEvent); Pools.free(changeEvent); }
private void updateValueFromTouch (float x) { int newValue = (int) (x / BasicColorPicker.BAR_WIDTH * maxValue / sizes.scaleFactor); setValue(newValue); ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class); fire(changeEvent); Pools.free(changeEvent); }
private void changeFieldValue (float value) { try { float fieldValue = Float.parseFloat(getText()); fieldValue += value; int lastPos = getCursorPosition(); setText(floatToString(fieldValue)); NumberInputField.this.setCursorPosition(lastPos); fire(new ChangeEvent()); } catch (NumberFormatException ex) { } }
private void addParticle() { Particle p = new Particle(protoParticle); particles.add(p); addedParticle = true; fire(new ChangeEvent()); }
public void clearParticles() { particles.clear(); clearTrails(); followedParticle = null; fire(new ChangeEvent()); }