public CampPanel(GameState gameState, CampPanelStyle style) { super(Strings.getString(UIManager.STRING_TABLE, "campHeading"), style); this.gameState = gameState; this.style = style; tooltip = new SimpleTooltip(style.tooltipStyle); addListener(this); hunterSelect = new ModalEnabledSelectBox<GameCharacter>(style.hunterSelectStyle); hunterSelect.setName(HUNTER_SELECT); waterSelect = new ModalEnabledSelectBox<GameCharacter>(style.waterSelectStyle); waterSelect.setName(WATER_SELECT); food = new Label("", style.textStyle); food.setAlignment(Align.center); water = new Label("", style.textStyle); water.setAlignment(Align.center); pcSelects = new Container<Table>(); pcSelects.setBackground(style.buttonBackground); }
@Override protected void processForActor(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) { // Parsed if actor is not in a cell: if (actor instanceof Table) { final Value verticalValue = LmlUtilities.parseVerticalValue(parser, tag.getParent(), actor, rawAttributeData); ((Table) actor).padTop(verticalValue); } else if (actor instanceof VerticalGroup) { ((VerticalGroup) actor).padTop(parser.parseFloat(rawAttributeData, actor)); } else if (actor instanceof HorizontalGroup) { ((HorizontalGroup) actor).padTop(parser.parseFloat(rawAttributeData, actor)); } else if (actor instanceof Container<?>) { ((Container<?>) actor) .padTop(LmlUtilities.parseVerticalValue(parser, tag.getParent(), actor, rawAttributeData)); } else { // Exception: super.processForActor(parser, tag, actor, rawAttributeData); } }
@Override protected void processForActor(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) { // Parsed if actor is not in a cell: if (actor instanceof Table) { final Value horizontalValue = LmlUtilities.parseHorizontalValue(parser, tag.getParent(), actor, rawAttributeData); ((Table) actor).padLeft(horizontalValue); } else if (actor instanceof VerticalGroup) { ((VerticalGroup) actor).padLeft(parser.parseFloat(rawAttributeData, actor)); } else if (actor instanceof HorizontalGroup) { ((HorizontalGroup) actor).padLeft(parser.parseFloat(rawAttributeData, actor)); } else if (actor instanceof Container<?>) { ((Container<?>) actor) .padLeft(LmlUtilities.parseHorizontalValue(parser, tag.getParent(), actor, rawAttributeData)); } else { // Exception: super.processForActor(parser, tag, actor, rawAttributeData); } }
@Override protected void processForActor(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) { // Parsed if actor is not in a cell: if (actor instanceof Table) { final Value horizontalValue = LmlUtilities.parseHorizontalValue(parser, tag.getParent(), actor, rawAttributeData); ((Table) actor).padRight(horizontalValue); } else if (actor instanceof VerticalGroup) { ((VerticalGroup) actor).padRight(parser.parseFloat(rawAttributeData, actor)); } else if (actor instanceof HorizontalGroup) { ((HorizontalGroup) actor).padRight(parser.parseFloat(rawAttributeData, actor)); } else if (actor instanceof Container<?>) { ((Container<?>) actor) .padRight(LmlUtilities.parseHorizontalValue(parser, tag.getParent(), actor, rawAttributeData)); } else { // Exception: super.processForActor(parser, tag, actor, rawAttributeData); } }
@Override protected void processForActor(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) { // Parsed if actor is not in a cell: if (actor instanceof Table) { final Value verticalValue = LmlUtilities.parseVerticalValue(parser, tag.getParent(), actor, rawAttributeData); ((Table) actor).padBottom(verticalValue); } else if (actor instanceof VerticalGroup) { ((VerticalGroup) actor).padBottom(parser.parseFloat(rawAttributeData, actor)); } else if (actor instanceof HorizontalGroup) { ((HorizontalGroup) actor).padBottom(parser.parseFloat(rawAttributeData, actor)); } else if (actor instanceof Container<?>) { ((Container<?>) actor) .padBottom(LmlUtilities.parseVerticalValue(parser, tag.getParent(), actor, rawAttributeData)); } else { // Exception: super.processForActor(parser, tag, actor, rawAttributeData); } }
public TabPanel(Skin skin) { super(skin); this.skin = skin; buttonGroup = new ButtonGroup<Button>(); header = new HorizontalGroup(); body = new Container<Actor>(); tabs = new ArrayList<Tab>(); buttonGroup.setMaxCheckCount(1); buttonGroup.setMinCheckCount(1); buttonGroup.setUncheckLast(true); header.wrap(true); header.rowAlign(Align.left); add(header).expandX().fillX().left(); row(); add(body).expand().fill(); body.fill(); }
/** * Registers a new tab with the given icon and the target actor * * @param id * tab id * @param icon * tab icon to show * @param actor * Content actor */ public void addTab(String id, String iconId, Actor content) { if (!id.isEmpty() && !tabs.containsKey(id)) { final Tab tab = new Tab(id, content, generateTabStyle(iconId, false), generateTabStyle(iconId, true)); tabs.put(id, tab); tabGroup.addActor(tab); Container<?> padding = new Container<Actor>(); padding.height(15f); tabGroup.addActor(padding); setTab(id); tab.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); if (activeTabId != tab.getId()) { SoundUtils.play(Assets.SND_TAB, 0.7f, 0.9f); } setTab(tab.getId()); } }); } }
private void addCategoryLabel() { int toFill = columns - gallery.getGrid().getChildren().size % columns; for (int i = 0; i < toFill; i++) { gallery.addSpace(); } CategoryButton aux = categories.get(count); Label cat = new Label(aux.getButtonText(), skin, SkinConstants.STYLE_BIG); gallery.addOriginal(cat); gallery.addSpace(); Container<TextButton> more = new Container<TextButton>(); TextButton button = new TextButton(i18N.m("more").toUpperCase(), skin, SkinConstants.STYLE_CATEGORY); Color color = aux.getColor(); color.a = 1; button.setColor(color); more.setActor(button); for (EventListener listener : aux.getListeners()) { button.addListener(listener); } more.right(); gallery.addOriginal(more); }
public GroupEditor(GroupEditorStyle style) { this.style = style; layersTouched = new Array<Actor>(); layerSelector = new LayerSelector(this, style); selectionGroup = new SelectionGroup(this, style); addActor(sceneContainer = new AbstractWidget()); sceneBackground = new Container(); sceneBackground.setBackground(style.groupBackground); sceneContainer.addActor(sceneBackground); sceneContainer.addActor(selectionGroup); TouchRepresentation touchRepresentation = new TouchRepresentation( style.touch); addActor(touchRepresentation); addListener(touchRepresentation); }
private void initLabel(){ text = new Label(LevelMap.getLevel().getEnergyNumber() + "/" + LevelMap.getLevel().getMaxEnergy(), FontLoader.generateStyle(26, Color.BLACK)); Container l = new Container(text); l.setPosition(energyBar.getX() + energyBar.getWidth()/2, energyBar.getY() + energyBar.getHeight()/2); l.setTransform(true); l.addAction(Actions.rotateTo(90)); addActor(l); }
public void init (ProgressDialogSettings settings, final ProgressDialogCallback callback) { clearChildren(); ProgressDialogStyle style = (ProgressDialogStyle) getStyle(); setTitle(settings.header); current.setText(Float.toString(settings.start)); progressBar.setRange(settings.start, settings.end); progressBar.setValue(settings.start); add(new Label(Float.toString(settings.start), style.textStyle)); add(progressBar).fill().prefWidth(style.barWidth).prefHeight(style.barHeight); add(new Label(Float.toString(settings.end), style.textStyle)); row(); add(current).colspan(3).center(); row(); if (settings.text != null) { textLabel.setText(settings.text); add(textLabel).colspan(3).center(); row(); } if (settings.canCancel) { Container<TextButtonWithSound> buttonsContainer = new Container<TextButtonWithSound>(); TextButtonWithSound button = new TextButtonWithSound(Strings.getString(UIManager.STRING_TABLE, "cancel"), style.cancelButtonStyle); button.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { callback.onCancelled((int)progressBar.getValue()); UIManager.hideProgressDialog(); } }); buttonsContainer.setActor(button); buttonsContainer.fill().width(style.cancelButtonWidth).height(style.cancelButtonHeight); add(buttonsContainer).center().colspan(3); } pack(); }
private Actor buildButtons() { Table buttonTable = new Table(); addButton(buttonTable, Strings.getString(UIManager.STRING_TABLE, "campGatherButton"), style.gatherButtonStyle, GATHER); addButton(buttonTable, Strings.getString(UIManager.STRING_TABLE, "campSleepButton"), style.sleepButtonStyle, SLEEP); addButton(buttonTable, Strings.getString(UIManager.STRING_TABLE, "campPackupButton"), style.packUpButtonStyle, PACKUP); Container<Table> buttonsContainer = new Container<Table>(); buttonsContainer.setBackground(style.buttonBackground); buttonsContainer.setActor(buttonTable); return buttonsContainer; }
@Override public void process(final LmlParser parser, final LmlTag tag, final MenuItem actor, final String rawAttributeData) { Image image = new Image(parser.getData().getDefaultSkin().getDrawable(rawAttributeData)); Container<Image> imageContainer = new Container<>(image); imageContainer.setFillParent(true); imageContainer.align(Align.left); imageContainer.padLeft(25f); actor.addActor(imageContainer); }
public void showLogWindow() { final String log = node.getLog(); if (Strings.isEmpty(log)) return; VisDialog dialog = (VisDialog)App.inst().getInterfaceService().getParser().parseTemplate(Gdx.files.internal("lml/dialogPackingLog.lml")).first(); Container containerLog = dialog.findActor("containerLog"); final VisScrollPane scrLog = dialog.findActor("scrLog"); final Button btnCopyToClipboard = dialog.findActor("btnCopyToClipboard"); VisLabel lblLog = new VisLabel("", "small") { // @Override // protected void sizeChanged() { // super.sizeChanged(); // // Scroll down scroller // scrLog.setScrollPercentY(1f); // } }; lblLog.setAlignment(Align.topLeft); lblLog.setWrap(true); lblLog.setText(log); containerLog.setActor(lblLog); btnCopyToClipboard.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { Gdx.app.getClipboard().setContents(log); } }); dialog.getTitleLabel().setText(App.inst().getI18n().format("dialogTitlePackLog", node.getPack().getName())); dialog.show(getStage()); getStage().setScrollFocus(scrLog); }
@Override public void processList(final List<RemoteScore> scoresList) { Gdx.app.debug("FillTableProcessor", "Begin process"); if (scoresList.size() > 1){ // Sort remote score list Gdx.app.debug("FillTableProcessor", "Sort collection"); // Use comparator to sort with descending order Collections.sort(scoresList, new Comparator<RemoteScore>() { @Override public int compare(RemoteScore o1, RemoteScore o2) { return o2.compareTo(o1); }; }); // Post runnable to synchronize update with rendering Gdx.app.debug("FillTableProcessor", "Send postRunnable"); Gdx.app.postRunnable(new Runnable() { @Override public void run() { int rangIncremeter = 1; for (RemoteScore remoteScore : scoresList) { scoreTable.row(); scoreTable.add(new Container<Label>(new Label("" + rangIncremeter++, skin))); scoreTable.add(new Container<Label>(new Label(remoteScore.getPlayerName(), skin))); scoreTable.add(new Container<Label>(new Label(remoteScore.getFormatedPlayDate(), skin))); scoreTable.add(new Container<Label>(new Label("" + remoteScore.getScore(), skin))); Label seedLabel = new Label("" + remoteScore.getSeed(), skin); if (confirmSeedDialog != null) seedLabel.addListener(new ShowSeedPlayGameDialogListener(confirmSeedDialog, remoteScore.getSeed())); scoreTable.add(new Container<Label>(seedLabel)); } } }); } }
private void createStaticContent() { // Create tables container = new Table(); container.setFillParent(true); container.top(); Table scoreContainer = new Table(uiSkin); // scoreContainer contains a scroll pane that contains the scoreTable scoreTable = new Table(uiSkin); ScrollPane scoreScrollPane = new ScrollPane(scoreTable); Label leaderBoard = new Label("SCORES", uiSkin, "title"); Label returnLabel = new Label("Menu", uiSkin); returnLabel.addListener(new ButtonRedirectListener(game, new MainMenuScreen(game))); Label date = new Label("DATE", uiSkin); Label score = new Label("SCORE", uiSkin); Label seed = new Label("SEED", uiSkin); scoreTable.columnDefaults(0).width(STRING_COLUMN_WIDTH); scoreTable.columnDefaults(1).width(NUMBER_COLUMN_WIDTH); scoreTable.columnDefaults(2).width(NUMBER_COLUMN_WIDTH); container.add(leaderBoard).expandX(); container.row().padTop(15); container.add(scoreContainer).expand().top(); container.row(); container.add(returnLabel).bottom().left().pad(10); scoreContainer.add(new Container<Label>(date)).width(STRING_COLUMN_WIDTH); scoreContainer.add(new Container<Label>(score)).width(NUMBER_COLUMN_WIDTH); scoreContainer.add(new Container<Label>(seed)).width(NUMBER_COLUMN_WIDTH); scoreContainer.row(); scoreContainer.add(scoreScrollPane).colspan(3).expandX().fillX(); }
private void addScoreToLeaderBoard(PersonalScore ps) { scoreTable.row(); scoreTable.add(new Container<Label>(new Label(ps.getDate(), uiSkin))); scoreTable.add(new Container<Label>(new Label(""+ps.getScore(), uiSkin))); Label seedLabel = new Label(""+ps.getSeed(), uiSkin); if (confirmSeedDialog != null) seedLabel.addListener(new ShowSeedPlayGameDialogListener(confirmSeedDialog, ps.getSeed())); scoreTable.add(new Container<Label>(seedLabel)); }
@Override @SuppressWarnings("unchecked") public Class<Container<?>> getHandledType() { // Double cast as there were a problem with generics - SomeClass.class cannot be returned as // <Class<SomeClass<?>>, even though casting never throws ClassCastException in the end. return (Class<Container<?>>) (Object) Container.class; }
@Override public final void process(final LmlParser parser, final LmlTag tag, final Container<?> actor, final String rawAttributeData) { final Value value = LmlUtilities.parseHorizontalValue(parser, tag.getParent(), actor, rawAttributeData); actor.minWidth(value); final Cell<?> cell = LmlUtilities.getCell(actor, tag.getParent()); if (cell != null) { cell.minWidth(value); } }
@Override public final void process(final LmlParser parser, final LmlTag tag, final Container<?> actor, final String rawAttributeData) { final Value xValue = LmlUtilities.parseHorizontalValue(parser, tag.getParent(), actor, rawAttributeData); final Value yValue = LmlUtilities.parseVerticalValue(parser, tag.getParent(), actor, rawAttributeData); actor.minWidth(xValue); actor.minHeight(yValue); final Cell<?> cell = LmlUtilities.getCell(actor, tag.getParent()); if (cell != null) { cell.minWidth(xValue); cell.minHeight(yValue); } }
@Override public final void process(final LmlParser parser, final LmlTag tag, final Container<?> actor, final String rawAttributeData) { applyToContainer(parser, tag, actor, rawAttributeData); final Cell<?> cell = LmlUtilities.getCell(actor, tag.getParent()); if (cell != null) { applyToCell(actor, cell); } }
/** @param child will be set as container's child. */ protected void addChild(final Actor child) { final Container<Actor> container = getContainer(); if (container.getActor() != null) { getParser().throwErrorIfStrict("Container widget can manage only one child."); } container.setActor(child); }
public void addWebglInterface() { webglInterface = new WebGLInterface(skin, GaiaSky.instance.time); wgl = new Container<WebGLInterface>(webglInterface); wgl.setFillParent(true); wgl.left().bottom(); wgl.pad(0, 5, 45, 0); }
@Override protected void onCreateStage(Stage stage) { Container<TabWidget> container = new Container<TabWidget>(tabView); stage.addActor(container); stage.addActor(tabView); stage.addActor(craftingWidget); stage.addActor(playerWidget); stage.addActor(itemBagThumblistView); tabView.addTab(Tabs.ITEMS, Assets.TEX_ICON_ITEMS, generateItemView()); tabView.addTab(Tabs.CRAFTING, Assets.TEX_ICON_HAMMER, recipeView); tabView.setTab(Tabs.ITEMS); tabView.hideTab(Tabs.CRAFTING); }
public void addTransitionPreview(String id) { TransitionDrawable thumbnail = new TransitionDrawable(); thumbnail.setTransition(Transition.fromValue(id), 2f); Image image = new Image(thumbnail); pendingCurrentTextures.add(thumbnail); pendingNextTextures.add(thumbnail); Container<Image> container = new Container<Image>(image); container.setClip(true); container.fill(); container.background(skin.getDrawable(SkinConstants.DRAWABLE_PAGE)); container.setName(id); gallery.add(container); }
public Tile(TileStyle tileStyle) { labelContainer = new Container<Label>(label = new Label("", tileStyle.labelStyle)); label.setEllipsis(true); this.style = tileStyle; labelContainer.setBackground(tileStyle.labelBackground); labelContainer.pad(WidgetBuilder.dpToPixels(8)); labelContainer.left(); addActor(labelContainer); addListener(clickListener); }
private Actor buildToolbar(Skin skin) { MultiWidget toolbar = new MultiWidget(skin, SkinConstants.STYLE_TOOLBAR); LinearLayout project = new LinearLayout(true); project.add(WidgetBuilder.toolbarIcon(SkinConstants.IC_GO, null, CloseProject.class)); project.add( new Container<TextButton>(title = WidgetBuilder.textButton("", SkinConstants.STYLE_TOOLBAR)).width(0).fillX()) .expandX().marginLeft(WidgetBuilder.dpToPixels(8)); title.getLabel().setAlignment(Align.left); Cell cell = title.getLabelCell(); LinearLayout titleCell = new LinearLayout(true); titleCell.add(new Image(skin, SkinConstants.IC_EDIT)).marginRight( WidgetBuilder.dpToPixels(8)); titleCell.add(title.getLabel()); cell.setActor(titleCell); title.padLeft(WidgetBuilder.dpToPixels(8)); WidgetBuilder.actionOnClick(title, Rename.class, Selection.MOKAP); project.add(WidgetBuilder.toolbarIcon(SkinConstants.IC_SHARE, null, ShareProject.class)); project.add(WidgetBuilder.toolbarIcon(SkinConstants.IC_PLAY, null, ChangeView.class, PlayView.class)); toolbar.addWidgets(project); return toolbar; }
protected void addIcon(String id, Drawable drawable) { Image image = new Image(); image.setDrawable(drawable); Container<Image> imageContainer = new Container<Image>() .size(WidgetBuilder.dpToPixels(12)); imageContainer.setActor(image); imageContainer.setName(id); iconsList.add(imageContainer).centerX(); }
@Override public void initialize(Controller controller) { this.controller = controller; Skin skin = controller.getApplicationAssets().getSkin(); Container<Actor> placeHolder = new Container(); Label label = new Label("Interface view", skin); placeHolder.setActor(label); placeHolder.setFillParent(true); view = placeHolder; }
@Override public void initialize(Controller controller) { this.controller = controller; Skin skin = controller.getApplicationAssets().getSkin(); Container<Actor> placeHolder = new Container(); Label label = new Label("No project loaded", skin); placeHolder.setActor(label); placeHolder.setFillParent(true); view = placeHolder; }
public AnimationTimeline(DragAndDrop dragAndDrop, final Controller controller) { align(Align.top); dragNDrop = dragAndDrop; Table tracks = new Table(); scroll = new DraggableScrollPane(tracks, dragNDrop, 20, 50); trackLayouts = new Array<TrackEffectLayout>(); add(scroll).fill().expand().left(); this.controller = controller; addNewTrack = new Container(new IconButton( skin.getDrawable("plus24x24"), skin)); addNewTrack.setBackground(skin.getDrawable("blank")); addNewTrack.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { controller.action(AddTrackEffect.class, animation, new TrackEffect()); } }); animation = new Animation(); controller.getModel().addSelectionListener(this); animationListener = createListListener(); trackListener = createTrackEffectListener(); controller.getModel().addListListener(animation.getEffects(), animationListener); }
@Override protected void builUI(Group root) { Skin skin = controller.getApplicationAssets().getSkin(); Container<Actor> placeHolder = new Container<Actor>(); PerspectiveButtons perspectiveButtons = new PerspectiveButtons( controller); placeHolder.setActor(perspectiveButtons); placeHolder.setFillParent(true); perspectiveButtons.background(skin.getDrawable("blank")); root.addActor(placeHolder); }
@Override protected void builUI(Group root) { Gdx.gl.glClearColor(1f, 1f, 1f, 1f); EditorGameAssets gameAssets = controller.getEditorGameAssets(); // Prepare some images and frames... gameAssets.setLoadingPath("cooldemo", true); controller.getCommands().pushStack(); Frames frames = new Frames(); for (int i = 1; i < 11; ++i) { Frame frame = new Frame(); Image image = new Image(); image.setUri("images/p1_walk" + (i < 10 ? "0" + i : i) + ".png"); frame.setRenderer(image); frame.setTime(.01f * i); frames.getFrames().add(frame); } // Create the widget AnimationEditor animEditor = new AnimationEditor(controller); animEditor.prepare(frames); Container container = new Container(animEditor); container.fill(); container.setFillParent(true); root.addActor(container); }
public void apply(Container<?> container) { container.setBackground(background); container.pad(padTop, padLeft, padBottom, padRight); }