@Test @NeedGL public void shouldParseSpriteView() throws Exception { CocoStudioUIEditor editor = new CocoStudioUIEditor( Gdx.files.internal("animation/MainScene.json"), null, null, null, null); Group group = editor.createGroup(); Image image = group.findActor("st_2"); Array<Action> actions = image.getActions(); assertThat(actions.size, is(1)); RepeatAction repeatAction = (RepeatAction) actions.get(0); ParallelAction parallelAction = (ParallelAction) repeatAction.getAction(); assertThat(parallelAction.getActions().size, is(3)); assertThat(parallelAction.getActions(), (Matcher) everyItem(instanceOf(SequenceAction.class))); SequenceAction moveAction = (SequenceAction) parallelAction.getActions().get(0); SequenceAction scaleAction = (SequenceAction) parallelAction.getActions().get(1); assertThat(moveAction.getActions().size, is(4)); assertThat(moveAction.getActions(), (Matcher) everyItem(instanceOf(MoveToAction.class))); assertThat(scaleAction.getActions().size, is(4)); assertThat(scaleAction.getActions(), (Matcher) everyItem(instanceOf(ScaleToAction.class))); }
private static void readAttr(Group parentGroup, XmlReader.Element element){ if (element.getName().equals("Stage")){ XmlUtils.parseGenAttr(parentGroup,element); if (element.getChildCount()>0){ for (int i = 0;i<element.getChildCount();i++){ readAttr(parentGroup,element.getChild(i)); } } }else if (element.getName().equals("Group")){ Group group = new Group(); XmlUtils.parseGenAttr(group,element); parentGroup.addActor(group); if (element.getChildCount()>0){ for (int i = 0;i<element.getChildCount();i++){ readAttr(group,element.getChild(i)); } } }else { Actor actor = getActorByName(element.getName()); parentGroup.addActor(actor); XmlUtils.parseGenAttr(actor,element); XmlUtils.parseUqAttr(actor,element); } }
private static Actor getActorByName(String name){ switch (name){ case "Group": return new Group(); case "Label": return new NativeLabel("",new NativeFont(new NativeFontPaint(14))); case "CheckBox": // return new CheckBox(""); case "Image": return new Image(); case "Button": return new Button(); case "TextField": default: return new Actor(); } }
private static Class getActorType(Actor actor){ if (actor instanceof Label){ return Label.class; }else if (actor instanceof CheckBox){ return CheckBox.class; }else if (actor instanceof Image){ return Image.class; }else if (actor instanceof TextField){ return TextField.class; }else if (actor instanceof Button){ return Button.class; }else if (actor instanceof Group){ return Group.class; }else { return Actor.class; } }
private void isInsideCub(Group group){ for (Actor child:group.getChildren()){ if (EditorManager.getInstance().getActorType(child).equals(Group.class)){ isInsideCub((Group) child); } if (child instanceof SelectGroup) continue; Vector2 childVect2 = child.getParent().localToStageCoordinates(new Vector2(child.getX(),child.getY())); childRect.set(childVect2.x,childVect2.y,child.getWidth(),child.getHeight()); if (getCullingArea().overlaps(childRect)){ if (!selection.contains(child)){ child.debug(); selection.add(child); } }else if (selection.contains(child)){ selection.remove(child); child.setDebug(false); } } }
public Class getActorType(Actor actor){ if (actor instanceof Label){ return Label.class; }else if (actor instanceof CheckBox){ return CheckBox.class; }else if (actor instanceof Image){ return Image.class; }else if (actor instanceof TextField){ return TextField.class; }else if (actor instanceof Button){ return Button.class; }else if (actor instanceof Group){ return Group.class; }else { return Actor.class; } }
public Actor getActorByName(String name){ switch (name){ case "Group": return new Group(); case "Label": return new NativeLabel("",getMainFont()); case "CheckBox": return new VisCheckBox(""); case "Image": return new Image(assetManager.get("badlogic.jpg",Texture.class)); case "Button": return new VisImageButton(VisUI.getSkin().get(VisImageButton.VisImageButtonStyle.class)); case "TextField": return new TextField("",VisUI.getSkin()); default: return new Actor(); } }
public VRope(GdxRopeJoint aJoint, Group group, AtlasRegion region, //(CCSpriteBatchNode*)spriteSheetArg List<VPoint> points, List<VStick> sticks, List<Image> sprites) { joint = aJoint; // spriteSheet = spriteSheetArg; this.group = group; this.region = region; vPoints = points; vSticks = sticks; ropeSprites = sprites; numPoints = vPoints.size(); }
public void _init(Drawable[] textures, int depth, Vector2[] bias) { if (bias != null && bias.length != textures.length) throw new IllegalArgumentException(); group = new Group(); images = new Image[textures.length]; for (int i=0; i<textures.length; i++) { Drawable texture = textures[i]; Image image = new Image(texture); images[i] = image; image.setBounds(0, 0, texture.getMinWidth(), texture.getMinHeight()); if (bias != null) image.setPosition(bias[i].x, bias[i].y, Align.center); else image.setPosition(0, 0, Align.center); group.addActor(image); } mDepth = depth; biases = bias; }
private void createCarouselExtension() { lookup = manager.getAssetsExtension().getTexture(NameFiles.progressbarcircular); lookup.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); groupCarousel = new Group(); arrayGroup = new Group[4]; arrayGroup[2] = addoneExtension("GAMMA SHIELD", NameFiles.imageExtensionGammaShield,9,8,5,7,23); arrayGroup[2].setScale(0.8f); arrayGroup[2].setPosition(Gdx.graphics.getWidth() * 0.1f, 0); groupCarousel.addActor(arrayGroup[2]); arrayGroup[3] = addoneExtension("SHIELD",NameFiles.imageExtensionRegularShield,7.5,8,4,6,23); arrayGroup[3].setScale(0.8f); arrayGroup[3].setPosition(Gdx.graphics.getWidth() * 0.1f, Gdx.graphics.getHeight() * 0.28f); groupCarousel.addActor(arrayGroup[3]); arrayGroup[1] = addoneExtension("AUTO TURRET", NameFiles.imageExtensionAutoTurret,9,5,7,3,8); arrayGroup[1].setScale(0.8f); arrayGroup[1].setPosition(Gdx.graphics.getWidth() * 0.1f, -Gdx.graphics.getHeight() * 0.1f); groupCarousel.addActor(arrayGroup[1]); arrayGroup[0] = addoneExtension("REMOTE TURRET", NameFiles.imageExtensionRemoteTurret, 5, 2, 8.5, 7,45); groupCarousel.addActor(arrayGroup[0]); groupCarousel.setVisible(false); }
private void addBackgroundExtension() { Image stobottom = new Image(new TextureRegion(manager.getAssetsExtension().getTexture(NameFiles.imageArrowBottom))); stobottom.setSize(Gdx.graphics.getWidth() * 0.1f, Gdx.graphics.getWidth() * 0.22f); stobottom.setPosition(Gdx.graphics.getWidth() / 2 - stobottom.getWidth() / 2, Gdx.graphics.getHeight() * 0.74f); Image selectroomtext = new Image(new TextureRegion(manager.getAssetsExtension().getTexture(NameFiles.txtSelectExtension))); selectroomtext.setSize(Gdx.graphics.getWidth() * 0.44f, Gdx.graphics.getHeight() * 0.12f); selectroomtext.setPosition(Gdx.graphics.getWidth() / 2 - selectroomtext.getWidth() / 2, Gdx.graphics.getHeight() * 0.815f); RepeatAction repeatActioan = new RepeatAction(); MoveToAction fadedown = new MoveToAction(); fadedown.setPosition(Gdx.graphics.getWidth() / 2 - stobottom.getWidth() / 2, Gdx.graphics.getHeight() * 0.71f); fadedown.setDuration(0.5f); MoveToAction fadeup = new MoveToAction(); fadeup.setPosition(Gdx.graphics.getWidth() / 2 - stobottom.getWidth() / 2, Gdx.graphics.getHeight() * 0.74f); fadeup.setDuration(1f); repeatActioan.setAction(new SequenceAction(fadedown, fadeup)); repeatActioan.setCount(RepeatAction.FOREVER); stobottom.addAction(repeatActioan); groupBtn = new Group(); groupBtn.addActor(stobottom); groupBtn.addActor(selectroomtext); }
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); }
private void drawdefenders(){ defenders = new DrawDefenders(); groupBtnDefender = new Group(); Button btn1 = new Button(new ImageButton.ImageButtonStyle()); btn1.setName("btn1"); btn1.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f); btn1.setPosition(Gdx.graphics.getWidth() * 0.025f, Gdx.graphics.getHeight() / 2.3f - Gdx.graphics.getHeight() * 0.14f); groupBtnDefender.addActor(btn1); Button btn2 = new Button(new ImageButton.ImageButtonStyle()); btn2.setName("btn2"); btn2.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f); btn2.setPosition(Gdx.graphics.getWidth() * 0.025f, Gdx.graphics.getHeight() / 2.3f); groupBtnDefender.addActor(btn2); Button btn3 = new Button(new ImageButton.ImageButtonStyle()); btn3.setName("btn3"); btn3.setSize(Gdx.graphics.getWidth() * 0.18f, Gdx.graphics.getWidth() * 0.2f); btn3.setPosition(Gdx.graphics.getWidth() * 0.025f, Gdx.graphics.getHeight() / 2.3f + Gdx.graphics.getHeight() * 0.14f); groupBtnDefender.addActor(btn3); }
private void makeRequest() { countBricks = Integer.parseInt(((Label)(((Group)(gr.findActor(MaterialsCraft.BRICKS.name()))).findActor(MaterialsCraft.BRICKS.name()))).getText().toString()); countcell = Integer.parseInt(((Label)(((Group)(gr.findActor("CELLS"))).findActor("CELLS"))).getText().toString()); if (countBricks > 0 || countcell > 0) { if(!queue.deployOn) { setisOn(); createAddQueue(); }else{ queueDisplay.createexitdialog(this); } } ((Label) (((Group) (gr.findActor("BRICKS"))).findActor("BRICKS"))).setText("0"); ((Label) (((Group) (gr.findActor("CELLS"))).findActor("CELLS"))).setText("0"); updateDisplay(); progressbar.update(); queue.showqueue(); }
private void modifyview(Group[] array) { if (centerPlayer[0] != -1) array[centerPlayer[0]].toFront(); if (centerPlayer[6] != -1) array[centerPlayer[6]].toFront(); if (centerPlayer[1] != -1) array[centerPlayer[1]].toFront(); if (centerPlayer[5] != -1) array[centerPlayer[5]].toFront(); if (centerPlayer[2] != -1) array[centerPlayer[2]].toFront(); if (centerPlayer[4] != -1) array[centerPlayer[4]].toFront(); if (centerPlayer[3] != -1) array[centerPlayer[3]].toFront(); }
private void reorderArray(Group[] array, float procent) { if (procent > 0.5) { System.arraycopy(centerPlayer, 1, centerPlayer, 0, 6); if (centerPlayer[6] < array.length - 1 && centerPlayer[6] != -1) { centerPlayer[6] = centerPlayer[5] + 1; } else { centerPlayer[6] = -1; } } else if(procent < -0.5){ System.arraycopy(centerPlayer, 0, centerPlayer, 1, 6); if (centerPlayer[1] > 0) { centerPlayer[0] = centerPlayer[1] - 1; } else { centerPlayer[0] = -1; } } }
private void move3(Group gr, float procent, float time) { MoveToAction move = new MoveToAction(); move.setDuration(time); if(time==0) { move.setPosition(0, -procent * distanceReference); }else { if(Math.abs(procent)<=0.5) { move.setPosition(0, 0); }else if(procent>0.5){ move.setPosition(p2.x,p2.y); }else{ move.setPosition(p4.x,p4.y); } } gr.addAction(move); }
private void modifyview(Group[] array){ if(centerPlayer[0] != -1) array[centerPlayer[0]].toFront(); if(centerPlayer[6]!= -1) array[centerPlayer[6]].toFront(); if(centerPlayer[1] != -1) array[centerPlayer[1]].toFront(); if(centerPlayer[5] != -1) array[centerPlayer[5]].toFront(); if(centerPlayer[2] != -1) array[centerPlayer[2]].toFront(); if(centerPlayer[4] != -1) array[centerPlayer[4]].toFront(); if(centerPlayer[3] != -1) array[centerPlayer[3]].toFront(); }
@Override public void build(Group group) { pauseButtonTexture = new TextureRegionDrawable(new TextureRegion(new Texture("pause.png"))); backButtonTexture = new TextureRegionDrawable(new TextureRegion(new Texture("back.png"))); pauseButton = new VisImageButton(pauseButtonTexture); pauseButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { ((WorldSimulator)getController()).toggleOverlayMenu(); } }); pauseButton.setWidth(widthVal.get(pauseButton)); pauseButton.setHeight(heightVal.get(pauseButton)); group.addActor(pauseButton); }
@Override public IFuture<Void> visualize(DroppedItem drop) { final Future<Void> future = new Future<Void>(); Group group = new Group(); Tile image = new Tile("item/" + drop.item.name); Label counter = new Label(String.valueOf(drop.count), Config.skin); counter.setSize(image.getWidth(), image.getHeight()); counter.setAlignment(Align.right | Align.bottom); group.addActor(image); group.addActor(counter); group.setTransform(false); visualizer.viewController.notificationLayer.addActor(group); group.setPosition(drop.target.getX() * ViewController.CELL_SIZE, drop.target.getY() * ViewController.CELL_SIZE); group.addAction(Actions.parallel( Actions.moveBy(0, 30, 1f, Interpolation.fade), Actions.alpha(0, 1f, Interpolation.fade), Actions.delay(0.4f, Actions.run(new Runnable() { @Override public void run() { future.happen(); } })) )); return future; }
@Override public void cancel() { if (world == null) return; ViewController viewController = world.getController(ViewController.class); Group root = viewController.root; viewController.removeSelection(this); root.removeCaptureListener(clickListener); if (confirmTargetListener != null) root.removeCaptureListener(confirmTargetListener); if (confirm != null) confirm.remove(); if (back != null) back.remove(); message.hide(); world = null; clickListener = null; confirmTargetListener = null; confirm = null; back = null; message = null; }
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()) ); } } }; }
public DiePane(Die die, UserData userData, Group diceWindowGroup) { this.die = die; this.userData = userData; this.diceWindowGroup = diceWindowGroup; shopComparator = Ability.shopComparator(die); setTransform(false); addActor(splitPane); splitPane.clearListeners(); initInfoPanel(); initParamsPanel(); splitPane.setSplitAmount(1f); splitPane.setHeight(info.getPrefHeight()); splitPane.layout(); setSize(getPrefWidth(), splitPane.getHeight()); params.setTouchable(Touchable.disabled); }
void add(GameWindow window) { if (windows.contains(window, true)) return; Group parent; if (window.getTargetParent() != null) { if (window.getTargetParent().getStage() == null) throw new IllegalStateException("no stage in target parent to show window!"); parent = window.getTargetParent(); } else { if (activeStage == null) throw new IllegalStateException("no active stage to show window!"); parent = activeStage.getRoot(); } windows.add(window); parent.addActor(window); }
@Override public void act(float delta) { super.act(delta); if (loader.update(am)) { if (!dependenciesLoaded) { loader.loadDependencies(am); dependenciesLoaded = true; return; } Group parent = getParent(); remove(); setVisible(false); parent.addActor(windowToLoad); loader.onLoaded(am, windowToLoad); windowToLoad.setVisible(true); } }
/*** * 解析节点,创建控件 * * @param parent * @param widget * @return */ public Actor parseWidget(Group parent, ObjectData widget) { String className = widget.getCtype(); BaseWidgetParser parser = parsers.get(className); if (parser == null) { debug(widget, "not support Widget:" + className); return null; } Actor actor = parser.parse(this, widget); actor = parser.commonParse(this, widget, parent, actor); return actor; }
@Override public Group groupChildrenParse(CocoStudioUIEditor editor, ObjectData widget, Group parent, Actor actor) { ScrollPane scrollPane = (ScrollPane) actor; Table table = new Table(); for (ObjectData childrenWidget : widget.getChildren()) { Actor childrenActor = editor.parseWidget(table, childrenWidget); if (childrenActor == null) { continue; } table.setSize(Math.max(table.getWidth(), childrenActor.getRight()), Math.max(table.getHeight(), childrenActor.getTop())); table.addActor(childrenActor); } sort(widget, table); // scrollPane.setWidget(table); return scrollPane; }
@Test @NeedGL public void shouldParseSingleButtonWithImages() throws Exception { FileHandle defaultFont = Gdx.files.internal("share/MLFZS.ttf"); CocoStudioUIEditor editor = new CocoStudioUIEditor( Gdx.files.internal("single-button/MainScene.json"), null, null, defaultFont, null); Group group = editor.createGroup(); Actor actor = group.findActor("Button_1"); assertThat(actor, not(nullValue())); assertThat(actor, instanceOf(ImageButton.class)); ImageButton imageButton = (ImageButton) actor; assertThat(imageButton.getScaleX(), is(1.7958f)); assertThat(imageButton.getScaleY(), is(1.8041f)); ImageButton.ImageButtonStyle style = imageButton.getStyle(); assertThat(style.imageDisabled, instanceOf(NinePatchDrawable.class)); assertThat(style.up, instanceOf(NinePatchDrawable.class)); assertThat(style.down, instanceOf(NinePatchDrawable.class)); }
@Test @NeedGL public void shouldParsePageView() throws Exception { FileHandle defaultFont = Gdx.files.internal("share/MLFZS.ttf"); CocoStudioUIEditor editor = new CocoStudioUIEditor( Gdx.files.internal("levelSelection/MainScene.json"), null, null, defaultFont, null); Group group = editor.createGroup(); PageView pageView = group.findActor("PageView_SelectPage"); assertThat(pageView.getChildren().get(0).getX(), is(0f)); pageView.nextView(); pageView.act(1000f); assertThat(pageView.getChildren().get(0).getX(), is(-492f)); assertThat(pageView.getChildren().get(1).getX(), is(0f)); pageView.previousView(); pageView.act(1000f); assertThat(pageView.getChildren().get(0).getX(), is(0f)); assertThat(pageView.getChildren().get(1).getX(), is(492f)); }
@Test @NeedGL public void shouldParseParticle() throws Exception { CocoStudioUIEditor editor = new CocoStudioUIEditor( Gdx.files.internal("particle/MainScene.json"), null, null, null, null); Group group = editor.createGroup(); CCParticleActor particleActor = group.findActor("Particle_1"); Object modeA = Whitebox.getInternalState(particleActor, "modeA"); Float speedVar = (Float) Whitebox.getInternalState(modeA, "speedVar"); Float tangentialAccel = (Float) Whitebox.getInternalState(modeA, "tangentialAccel"); Float tangentialAccelVar = (Float) Whitebox.getInternalState(modeA, "tangentialAccelVar"); assertThat(speedVar, is(190.79f)); assertThat(tangentialAccel, is(-92.11f)); assertThat(tangentialAccelVar, is(65.79f)); Object modeB = Whitebox.getInternalState(particleActor, "modeB"); Float startRadius = (Float) Whitebox.getInternalState(modeB, "startRadius"); Float endRadius = (Float) Whitebox.getInternalState(modeB, "endRadius"); Float rotatePerSecond = (Float) Whitebox.getInternalState(modeB, "rotatePerSecond"); assertThat(startRadius, is(0f)); assertThat(endRadius, is(0f)); assertThat(rotatePerSecond, is(0f)); }
@Test @NeedGL public void shouldParseSliderBar() throws Exception { CocoStudioUIEditor editor = new CocoStudioUIEditor( Gdx.files.internal("slideBar/MainScene.json"), null, null, null, null); Group group = editor.createGroup(); Slider slider = group.findActor("Slider_1"); assertThat(slider.getWidth(), is(200f)); assertThat(slider.getHeight(), is(14f)); assertThat(slider.getValue(), is(50f)); Slider.SliderStyle style = slider.getStyle(); assertThat(style.knob, instanceOf(TextureRegionDrawable.class)); assertThat(style.background, instanceOf(TextureRegionDrawable.class)); assertThat(style.knobBefore, instanceOf(TextureRegionDrawable.class)); //assertThat(style.disabledKnob, instanceOf(TextureRegionDrawable.class)); // assertThat(style.knobDown, instanceOf(TextureRegionDrawable.class)); }
@Test @NeedGL public void shouldParseTextField() throws Exception { FileHandle defaultFont = Gdx.files.internal("share/MLFZS.ttf"); CocoStudioUIEditor editor = new CocoStudioUIEditor( Gdx.files.internal("textField/MainScene.json"), null, null, defaultFont, null); Group group = editor.createGroup(); TextField textField = group.findActor("TextField_1"); assertThat(textField.getText(), is("Here is text")); assertThat(textField.getMessageText(), is("Place Holder")); assertThat(textField.getText(), is("Here is text")); assertThat(textField.getColor().toString(), is("008000ff")); assertThat(textField.getListeners().size, is(1)); textField = group.findActor("TextField_2"); assertThat(textField.getText(), is("")); assertThat(textField.getMessageText(), is("Place Holder")); assertThat(textField.getColor().toString(), is("ff0000ff")); assertThat(textField.getListeners().size, is(1)); }
public InfoPanel(LmlParser parser) { align(Align.top); fillX(); // Workaround of parser's only single parsing operation limitation LmlParser localParser = new DefaultLmlParser(parser.getData()); localParser.setSyntax(parser.getSyntax()); Group root = (Group) (localParser.parseTemplate(Gdx.files.internal("lml/canvasInfoPanel.lml")).first()); setActor(root); lblPages = root.findActor("lblPages"); lblZoom = root.findActor("lblZoom"); lblPageDimens = root.findActor("lblPageDimens"); lblFileSize = root.findActor("lblFileSize"); updatePagesText(); setZoomLevel(100f); }
public <E extends Enum<?>> AbstractMenuScreen(Class<E> menuEnumClass, BitmapFont pFont, Class<?> selectorClass) { stage = new Stage(); Gdx.input.setInputProcessor(stage); font = pFont != null ? pFont : new BitmapFont(); font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear); font.setColor(0, 0, 0, 1); selectorHeight = font.getCapHeight(); initItemsPositions(menuEnumClass); generateSelector(selectorClass); foregroundGroup= new Group(); backgroundGroup = new Group(); addBackgroundElements(); foregroundGroup.addActor(selector); stage.addActor(backgroundGroup); stage.addActor(foregroundGroup); }
/** * Holds board information * * @param width * Column number of the board * @param height * Row number of the board * @param fg * Reference to foreground * @param camera * Camera of the stage */ public Board(int width, int height, Group fg, Camera camera) { this.boardCols = width; this.boardRows = height; setOrigin(1, 1); /* Add range group to fg first */ rangeGroup = new Group(); fg.addActor(rangeGroup); /* Add block group to fg */ blockGroup = new Group(); fg.addActor(blockGroup); loadMap(camera, "t1.tmx"); createBoard(); blockPools = new BlockPools(this); neighbours = new Array<Tile>(); turn = Turn.FIRE; }
/** @param child will be added to the actor casted to a Group or a Table. */ protected void addChild(final Actor child) { final Actor actor = getActor(); if (actor instanceof Tree) { final Tree.Node node = LmlUtilities.getTreeNode(child); if (node != null) { ((Tree) actor).add(node); } else { ((Tree) actor).add(new Tree.Node(child)); } } else if (actor instanceof Table) { LmlUtilities.getCell(child, (Table) actor); } else { ((Group) actor).addActor(child); } }