/** * Visually indicate that a player has been marked as ready. * * @param username username of the ready player */ private void markPlayerAsReady(String username) { // Find the table row containing the player that has been marked as ready final SnapshotArray<Actor> children = playersTable.getChildren(); // Ignore the first child since it's just the table header for (int i = 1; i < children.size; i++) { Actor actor = children.get(i); if (actor instanceof Table) { final Actor label = ((Table) actor).getCells().get(0).getActor(); if (label instanceof Label) { if (((Label) label).getText().toString().equals(username)) { ((Table) actor).setBackground("readyBackground"); break; } } } } }
/** * Remove a player from the list of players as a result of him/her leaving * the game. * * @param username username of the player */ private void removePlayer(String username) { Table playerTable = null; // Find the table row containing the player that left the game final SnapshotArray<Actor> children = playersTable.getChildren(); // Ignore the first child since it's just the table header for (int i = 1; i < children.size; i++) { Actor actor = children.get(i); if (actor instanceof Table) { final Actor label = ((Table) actor).getCells().get(0).getActor(); if (label instanceof Label) { if (((Label) label).getText().toString().equals(username)) { playerTable = ((Table) actor); break; } } } } if (playerTable != null) playersTable.removeActor(playerTable); }
@Override public Actor hit(float x, float y, boolean touchable) { //Still include menu button tempVector.set(x, y); localToStageCoordinates(tempVector); closeButton.stageToLocalCoordinates(tempVector); if (closeButton.hit(tempVector.x, tempVector.y, touchable) != null) return closeButton.hit(tempVector.x, tempVector.y, touchable); //Find deepest child at position SnapshotArray<Actor> childrenSnapshot = getChildren(); Actor[] children = childrenSnapshot.items; for(int i = childrenSnapshot.size - 1; i >= 0; i--) { Actor child = children[i]; child.parentToLocalCoordinates(tempVector.set(x, y)); if (child.hit(tempVector.x, tempVector.y, touchable) != null) return child; } return this; }
protected void resizeElements() { Vector2 screenSize = new Vector2(getWidth(), getHeight()); if(menuBar != null) { screenSize.y -= menuBar.getTable().getHeight(); menuBar.getTable().pack(); menuBar.getTable().setPosition(0, screenSize.y); menuBar.getTable().setWidth(screenSize.x); } Table table = tabControl.getTable(); table.setSize(screenSize.x, 24); table.setPosition(0, screenSize.y-table.getHeight()); activePane.setBounds(0, 0, screenSize.x, screenSize.y-table.getHeight()); SnapshotArray<Actor> paneChildren = activePane.getChildren(); if(paneChildren.size >= 1) { paneChildren.first().setBounds(0, 0, activePane.getWidth(), activePane.getHeight()); } }
@Override protected void resizeElements() { if(scroller != null) { scroller.setBounds(0, 0, getWidth()*0.15f, getHeight()); scroller.setScrollBarPositions(true, true); } if(objList != null) { objList.pack(); objList.setPosition(0, 0); objList.setWidth(scroller.getWidth()-30); } Table table = tabControl.getTable(); table.setSize(getWidth()*0.85f, 24); table.setPosition(getWidth()*0.15f, getHeight()-table.getHeight()); activePane.setBounds(getWidth()*0.15f, 0, getWidth()*0.85f, getHeight()-table.getHeight()); SnapshotArray<Actor> paneChildren = activePane.getChildren(); if(paneChildren.size >= 1) { paneChildren.first().setBounds(0, 0, activePane.getWidth(), activePane.getHeight()); } }
Coordinate getValue() { StringBuilder sb = new StringBuilder(); SnapshotArray<Actor> childs = this.getChildren(); for (Actor actor : childs) { if (actor == null) { sb.append(" "); } else { if (actor instanceof VisTextButton) { sb.append(((VisTextButton) actor).getText()); } else if (actor instanceof VisLabel) { sb.append(((VisLabel) actor).getText()); } } } return new Coordinate(sb.toString()); }
@Override Coordinate getValue() { StringBuilder sb = new StringBuilder(); SnapshotArray<Actor> childs = this.getChildren(); for (Actor actor : childs) { if (actor == null) { sb.append(" "); } else { if (actor instanceof VisTextButton) { sb.append(((VisTextButton) actor).getText()); } else if (actor instanceof VisLabel) { sb.append(((VisLabel) actor).getText()); } } } sb = sb.replace("OstW", "").replace("NordW", " ").replace("Zone", " "); //switch Zone to first block String s[] = sb.toString().split(" "); String utmStr = s[2] + " " + s[0] + " " + s[1]; return new Coordinate(utmStr); }
public void onShow() { SnapshotArray<Actor> childs = this.getChildren(); if (childs != null && childs.size > 0) { try { for (int i = 0, n = childs.size; i < n; i++) { // alle renderChilds() der in dieser CB_View_Base // enthaltenen Childs auf rufen. if (childs.get(i) instanceof CB_View_Base) { CB_View_Base view = (CB_View_Base) childs.get(i); if (view != null) view.onShow(); } } } catch (Exception e) { e.printStackTrace(); } } }
public void onHide() { SnapshotArray<Actor> childs = this.getChildren(); if (childs != null && childs.size > 0) { try { for (int i = 0, n = childs.size; i < n; i++) { // alle renderChilds() der in dieser GL_View_Base // enthaltenen Childs auf rufen. if (childs.get(i) instanceof CB_View_Base) { CB_View_Base view = (CB_View_Base) childs.get(i); if (view != null) view.onHide(); } } } catch (Exception e) { e.printStackTrace(); } } }
public void nextView() { Gdx.app.debug("PageView", "Change to next view"); SnapshotArray<Actor> children = this.getChildren(); if (children.get(children.size - 1).getX() <= 0) { Gdx.app.debug("PageView", "Already last one, can't move to next."); return; } Actor[] actors = children.begin(); float width = this.getWidth(); for (Actor actor : actors) { if (actor != null) { actor.addAction(Actions.moveTo(actor.getX() - width, 0, 0.5f)); } } children.end(); }
public void previousView() { Gdx.app.debug("PageView", "Change to previous view"); SnapshotArray<Actor> children = this.getChildren(); if (children.get(0).getX() >= 0) { Gdx.app.debug("PageView", "Already first one, can't move to previous."); return; } float width = this.getWidth(); Actor[] actors = children.begin(); for (Actor actor : actors) { if (actor != null) { actor.addAction(Actions.moveTo(actor.getX() + width, 0, 0.5f)); } } children.end(); }
private void computeSize() { sizeInvalid = false; maxWidth = minWidth = prefWidth = getStage().getWidth() - 5; maxHeight = minHeight = prefHeight = 0; SnapshotArray<Actor> children = getChildren(); for (int i = 0, n = children.size; i < n; i++) { Actor child = children.get(i); if (!child.isVisible()) { continue; } if (child instanceof Layout) { Layout layout = (Layout) child; prefHeight += layout.getPrefHeight(); minHeight += layout.getMinHeight(); } else { prefHeight += child.getHeight(); minHeight += child.getHeight(); } } }
private void computeSize () { sizeInvalid = false; SnapshotArray<Actor> children = getChildren(); int n = children.size; prefWidth = 0; prefHeight = padTop + padBottom + spacing * (n - 1); for (int i = 0; i < n; i++) { Actor child = children.get(i); if (child instanceof Layout) { Layout layout = (Layout)child; prefWidth = Math.max(prefWidth, layout.getPrefWidth()); prefHeight += layout.getPrefHeight(); } else { prefWidth = Math.max(prefWidth, child.getWidth()); prefHeight += child.getHeight(); } } prefWidth += padLeft + padRight; if (round) { prefWidth = Math.round(prefWidth); prefHeight = Math.round(prefHeight); } }
private void computeSize () { sizeInvalid = false; SnapshotArray<Actor> children = getChildren(); int n = children.size; prefWidth = padLeft + padRight + spacing * (n - 1); prefHeight = 0; for (int i = 0; i < n; i++) { Actor child = children.get(i); if (child instanceof Layout) { Layout layout = (Layout)child; prefWidth += layout.getPrefWidth(); prefHeight = Math.max(prefHeight, layout.getPrefHeight()); } else { prefWidth += child.getWidth(); prefHeight = Math.max(prefHeight, child.getHeight()); } } prefHeight += padTop + padBottom; if (round) { prefWidth = Math.round(prefWidth); prefHeight = Math.round(prefHeight); } }
@SuppressWarnings("unchecked") public void setProperty(String name, String value) { SnapshotArray<Actor> actors = table.getChildren(); for (Actor a : actors) { if (name.equals(a.getName())) { if (a instanceof SelectBox<?>) { ((SelectBox<String>) a).setSelected(value == null ? "" : value); } else { ((TextField) a).setText(value == null ? "" : value); } return; } } }
@Override public void doProcessEntity(Entity entity, float delta) { TimersComponent timers = entity.getComponent(TimersComponent.class); SnapshotArray<RuntimeTimer> timerList = timers.getBehaviors(); Object[] timerArray = timerList.begin(); for (int j = 0, n = timerList.size; j < n; j++) { RuntimeTimer timer = (RuntimeTimer) timerArray[j]; if (!evaluateCondition(timer.getCondition())) continue; int count = timer.update(delta); for (int i = 0; i < count; i++) { addEffects(entity, timer.getEffects()); } if (timer.isDone()) { timerList.removeValue(timer, true); } } timerList.end(); // If no timers remaining, remove the component if (timers.getBehaviors().size == 0) { entity.remove(TimersComponent.class); } }
public Actor hit(float paramFloat1, float paramFloat2) { Actor localActor2; if (getTouchable() == Touchable.disabled) { localActor2 = null; return localActor2; } SnapshotArray localSnapshotArray = this.children; for (int i = -1 + localSnapshotArray.size; ; i--) { if (i < 0) break label99; Actor localActor1 = (Actor)localSnapshotArray.get(i); if (localActor1.isVisible()) { localActor1.parentToLocalCoordinates(this.point.set(paramFloat1, paramFloat2)); localActor2 = localActor1.hit(this.point.x, this.point.y); if (localActor2 != null) break; } } label99: return super.hit(paramFloat1, paramFloat2); }
public float getMinHeight() { SnapshotArray localSnapshotArray = getChildren(); int i = localSnapshotArray.size; float f1 = 0.0F; int j = 0; if (j < i) { Actor localActor = (Actor)localSnapshotArray.get(j); if ((localActor instanceof Layout)); for (float f2 = ((Layout)localActor).getMinHeight(); ; f2 = localActor.getHeight()) { f1 = Math.max(f1, f2); j++; break; } } return f1 * getScaleY(); }
public float getMinWidth() { SnapshotArray localSnapshotArray = getChildren(); int i = localSnapshotArray.size; float f1 = 0.0F; int j = 0; if (j < i) { Actor localActor = (Actor)localSnapshotArray.get(j); if ((localActor instanceof Layout)); for (float f2 = ((Layout)localActor).getMinWidth(); ; f2 = localActor.getWidth()) { f1 = Math.max(f1, f2); j++; break; } } return f1 * getScaleX(); }
public float getPrefHeight() { SnapshotArray localSnapshotArray = getChildren(); int i = localSnapshotArray.size; float f1 = 0.0F; int j = 0; if (j < i) { Actor localActor = (Actor)localSnapshotArray.get(j); if ((localActor instanceof Layout)); for (float f2 = ((Layout)localActor).getPrefHeight(); ; f2 = localActor.getHeight()) { f1 = Math.max(f1, f2); j++; break; } } return f1 * getScaleY(); }
public float getPrefWidth() { SnapshotArray localSnapshotArray = getChildren(); int i = localSnapshotArray.size; float f1 = 0.0F; int j = 0; if (j < i) { Actor localActor = (Actor)localSnapshotArray.get(j); if ((localActor instanceof Layout)); for (float f2 = ((Layout)localActor).getPrefWidth(); ; f2 = localActor.getWidth()) { f1 = Math.max(f1, f2); j++; break; } } return f1 * getScaleX(); }
public void layout() { SnapshotArray localSnapshotArray = getChildren(); int i = localSnapshotArray.size; for (int j = 0; j < i; j++) { Actor localActor = (Actor)localSnapshotArray.get(j); localActor.setBounds(0.0F, 0.0F, getWidth(), getHeight()); if ((localActor instanceof Layout)) { Layout localLayout = (Layout)localActor; localLayout.invalidate(); localLayout.validate(); } } }
private void setLayoutEnabled(Group paramGroup, boolean paramBoolean) { SnapshotArray localSnapshotArray = getChildren(); int i = localSnapshotArray.size; int j = 0; if (j < i) { Actor localActor = (Actor)localSnapshotArray.get(j); if ((localActor instanceof Layout)) ((Layout)localActor).setLayoutEnabled(paramBoolean); while (true) { j++; break; if ((localActor instanceof Group)) setLayoutEnabled((Group)localActor, paramBoolean); } } }
public void setZIndex(int paramInt) { if (paramInt < 0) throw new IllegalArgumentException("ZIndex cannot be < 0."); Group localGroup = getParent(); if (localGroup == null); SnapshotArray localSnapshotArray; do { return; localSnapshotArray = localGroup.getChildren(); } while ((localSnapshotArray.size == 1) || (!localSnapshotArray.removeValue(this, true))); if (paramInt >= localSnapshotArray.size) { localSnapshotArray.add(this); return; } localSnapshotArray.insert(paramInt, this); }
public void cancelTouchFocus(EventListener paramEventListener, Actor paramActor) { InputEvent localInputEvent = (InputEvent)Pools.obtain(InputEvent.class); localInputEvent.setStage(this); localInputEvent.setType(InputEvent.Type.touchUp); localInputEvent.setStageX(-2.147484E+09F); localInputEvent.setStageY(-2.147484E+09F); SnapshotArray localSnapshotArray = this.touchFocuses; for (int i = -1 + localSnapshotArray.size; i >= 0; i--) { Stage.TouchFocus localTouchFocus = (Stage.TouchFocus)localSnapshotArray.get(i); if ((localTouchFocus.listener != paramEventListener) || (localTouchFocus.listenerActor != paramActor)) { localInputEvent.setTarget(localTouchFocus.target); localInputEvent.setListenerActor(localTouchFocus.listenerActor); localInputEvent.setPointer(localTouchFocus.pointer); localInputEvent.setButton(localTouchFocus.button); localSnapshotArray.removeIndex(i); localTouchFocus.listener.handle(localInputEvent); } } Pools.free(localInputEvent); }
@Override public void render(float delta) { Klooni.theme.glClearBackground(); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(Math.min(Gdx.graphics.getDeltaTime(), MIN_DELTA)); stage.draw(); // After everything is drawn, showcase the current shop item SnapshotArray<Actor> children = shopGroup.getChildren(); if (children.size > 0) { final ShopCard card = (ShopCard)children.get(showcaseIndex); final Batch batch = stage.getBatch(); batch.begin(); // For some really strange reason, we need to displace the particle effect // by "buyBand.height", or it will render exactly that height below where // it should. // TODO Fix this - maybe use the same project matrix as stage.draw()? // batch.setProjectionMatrix(stage.getViewport().getCamera().combined) if (!card.showcase(batch, buyBand.getHeight())) { showcaseIndex = (showcaseIndex + 1) % children.size; } batch.end(); } if (Gdx.input.isKeyJustPressed(Input.Keys.BACK)) { goBack(); } }
@Override public void dispose() { EventHandler.remove(this); targetdirectionLabel = null; ownPositionLabel = null; SnapshotArray<Actor> childs = this.getChildren(); for (int i = 0, n = childs.size - 1; i < n; i++) { this.removeChild(childs.get(i)); } childs.clear(); }
private void setChangedFlagToAllItems() { if (listView == null || ON_LAYOUT_WORK.get()) return; SnapshotArray<ListViewItem> allItems = listView.items(); Object[] actors = allItems.begin(); for (int i = 0, n = allItems.size; i < n; i++) { CacheListItem item = (CacheListItem) actors[i]; item.posOrBearingChanged(); } allItems.end(); CB.requestRendering(); }
@Override public void layout() { if (!needLayout) { super.layout(); return; } SnapshotArray<Actor> actors = this.getChildren(); for (Actor actor : actors) this.removeActor(actor); this.setFillParent(true); this.defaults().pad(CB.scaledSizes.MARGIN); this.add(lblTitle).colspan(3).center(); this.add(gsLogo).colspan(2).center(); this.row().padTop(new Value.Fixed(CB.scaledSizes.MARGINx2 * 2)); this.add(workAnimation).colspan(5).center(); this.row(); this.add(); this.add(progressBar).colspan(3).center().expandX().fillX(); this.row(); Table nestedTable2 = new Table(); nestedTable2.defaults().pad(CB.scaledSizes.MARGIN).bottom(); nestedTable2.add(bCancel).bottom(); this.add(nestedTable2).colspan(5); super.layout(); needLayout = false; }
public HintDialog() { super("Hint", createContentBox(), Translation.get("hint"), MessageBoxButtons.RetryCancel, null); hintFromDB = EventHandler.getSelectedCache() == null ? "" : UnitFormatter.rot13(EventHandler.getSelectedCache().getHint(Database.Data)); hintLabel.setWrap(true); SnapshotArray<Actor> childs = this.buttonTable.getChildren(); encodeButton = ((CharSequenceButton) childs.get(0)); encodeButton.setText(Translation.get("decode")); ((CharSequenceButton) childs.get(1)).setText(Translation.get("close")); result(BUTTON_POSITIVE); }
public <T> void dispatch(EventType<T> type, T t) { SnapshotArray<EventListener<T>> list = getList(type, false); if (list == null) return; EventListener<T>[] items = list.begin(); for (int i = 0, n = list.size; i < n; i++) { items[i].handle(type, t); } list.end(); }
@SuppressWarnings("unchecked") private <T> SnapshotArray<EventListener<T>> getList(EventType<T> type, boolean createIfNotExist) { Object list = data.get(type); if (list == null) { if (!createIfNotExist) return null; SnapshotArray<EventListener<T>> result = new SnapshotArray<EventListener<T>>(EventListener.class); data.put(type, result); return result; } return (SnapshotArray<EventListener<T>>) list; }
public Array<Actor> getAllInventoryItems() { Array<Actor> items = new Array<Actor>(); if( hasItem() ){ SnapshotArray<Actor> arrayChildren = this.getChildren(); int numInventoryItems = arrayChildren.size - 2; for(int i = 0; i < numInventoryItems; i++) { decrementItemCount(true); items.add(arrayChildren.pop()); } } return items; }
public void updateAllInventoryItemNames(String name){ if( hasItem() ){ SnapshotArray<Actor> arrayChildren = this.getChildren(); //skip first two elements for(int i = arrayChildren.size - 1; i > 1 ; i--) { arrayChildren.get(i).setName(name); } } }
public void removeAllInventoryItemsWithName(String name){ if( hasItem() ){ SnapshotArray<Actor> arrayChildren = this.getChildren(); //skip first two elements for(int i = arrayChildren.size - 1; i > 1 ; i--) { String itemName = arrayChildren.get(i).getName(); if( itemName.equalsIgnoreCase(name)){ decrementItemCount(true); arrayChildren.removeIndex(i); } } } }
public void clearAllInventoryItems(boolean sendRemoveNotifications) { if( hasItem() ){ SnapshotArray<Actor> arrayChildren = this.getChildren(); int numInventoryItems = getNumItems(); for(int i = 0; i < numInventoryItems; i++) { decrementItemCount(sendRemoveNotifications); arrayChildren.pop(); } } }
public boolean hasItem(){ if( hasChildren() ){ SnapshotArray<Actor> items = this.getChildren(); if( items.size > 2 ){ return true; } } return false; }
public int getNumItems(){ if( hasChildren() ){ SnapshotArray<Actor> items = this.getChildren(); return items.size - 2; } return 0; }
public int getNumItems(String name){ if( hasChildren() ){ SnapshotArray<Actor> items = this.getChildren(); int totalFilteredSize = 0; for( Actor actor: items ){ if( actor.getName().equalsIgnoreCase(name)){ totalFilteredSize++; } } return totalFilteredSize; } return 0; }