private void backClick() { float nextXPos = Gdx.graphics.getWidth() + CB.scaledSizes.MARGIN; if (listViews.size == 1) { // remove all BackClickListener while (listBackClickListener.size > 0) { StageManager.unRegisterForBackKey(listBackClickListener.pop()); } //Send click to Cancel button cancelClickListener.clicked(StageManager.BACK_KEY_INPUT_EVENT, -1, -1); return; } StageManager.unRegisterForBackKey(listBackClickListener.pop()); listViewsNames.pop(); WidgetGroup actWidgetGroup = listViews.pop(); WidgetGroup showingWidgetGroup = listViews.get(listViews.size - 1); float y = actWidgetGroup.getY(); actWidgetGroup.addAction(Actions.sequence(Actions.moveTo(nextXPos, y, Menu.MORE_MENU_ANIMATION_TIME), Actions.removeActor())); showingWidgetGroup.addAction(Actions.moveTo(CB.scaledSizes.MARGIN, y, Menu.MORE_MENU_ANIMATION_TIME)); }
private void showWidgetGroup() { clearActions(); pack(); mainMenuWidgetGroup = new WidgetGroup(); mainMenuWidgetGroup.setName(this.name.toString()); mainMenuWidgetGroup.setBounds(this.getX(), this.getY(), this.getWidth(), this.getHeight()); mainMenuWidgetGroup.addActor(this); if (this.parentMenu == null) { showingStage = StageManager.showOnNewStage(mainMenuWidgetGroup); } else { showingStage = StageManager.showOnActStage(mainMenuWidgetGroup); } if (this.parentMenu == null) addAction(sequence(Actions.alpha(0), Actions.fadeIn(CB.WINDOW_FADE_TIME, Interpolation.fade))); isShowing = true; }
public Map(GameMap map, GameState gameState, int width, int height, ButtonStyle mapIndicatorStyle) { mapTexture = MinimapGenerator.generate(map, gameState, width, height); this.gameMap = map; this.gameState = gameState; calculateRatios(width, height); Image image = new Image(mapTexture); image.addListener(this); // only add the current camera position indicator in case // the camera does not show the whole map already if (xRatio > 1 || yRatio > 1) { indicator = new MapScreenIndicator(mapIndicatorStyle); } WidgetGroup group = new WidgetGroup(); group.addActor(image); if (indicator != null) { group.addActor(indicator); indicator.addListener(this); } group.setWidth(width); group.setHeight(height); group.invalidate(); add(group).width(width).height(height); }
@Override public void create() { Gdx.app.setLogLevel(Application.LOG_DEBUG); Gdx.gl.glClearColor(0f, 0f, 0f, 0f); stage = new Stage(new ScreenViewport()); WidgetGroup modalContainer = new WidgetGroup(); modalContainer.setFillParent(true); WidgetGroup viewContainer = new WidgetGroup(); viewContainer.setFillParent(true); stage.getRoot().addActor(viewContainer); stage.getRoot().addActor(modalContainer); Gdx.input.setInputProcessor(stage); actor = new LoadingIndicator(); if (actor instanceof WidgetGroup) { ((WidgetGroup) actor).setFillParent(true); } viewContainer.addActor(actor); }
/** * @param controller * the editor controller * @param viewsContainer * the root container where the main view must be added * @param modalsContainer * the container where context menues must appear */ public Views(Controller controller, Group viewsContainer, Group modalsContainer) { this.controller = controller; controller.getModel().addLoadListener(this); this.viewsContainer = viewsContainer; this.modalsContainer = modalsContainer; if (modalsContainer instanceof WidgetGroup) { ((WidgetGroup) modalsContainer).pack(); } modalsContainer.setTouchable(Touchable.childrenOnly); modalsContainer.addListener(closeContextMenu); viewsBuilders = new HashMap<Class, ViewBuilder>(); dialogBuilders = new HashMap<Class, DialogBuilder>(); viewsHistory = new ViewsHistory(); }
public UI() { uiElements = new ArrayList<UIElement>(); stage = new Stage(new ScreenViewport()); skin = new Skin(Gdx.files.internal("data/uiskin.json")); root = new WidgetGroup(); root.setFillParent(true); stage.addActor(root); new MainOptionsWnd(skin); }
private void backClick() { float nextXPos = Gdx.graphics.getWidth() + CB.scaledSizes.MARGIN; if (listViews.size == 1) return; listViewsNames.pop(); WidgetGroup actWidgetGroup = listViews.pop(); WidgetGroup showingWidgetGroup = listViews.get(listViews.size - 1); float y = actWidgetGroup.getY(); actWidgetGroup.addAction(Actions.sequence(Actions.moveTo(nextXPos, y, Menu.MORE_MENU_ANIMATION_TIME), Actions.removeActor())); showingWidgetGroup.addAction(Actions.moveTo(CB.scaledSizes.MARGIN, y, Menu.MORE_MENU_ANIMATION_TIME)); }
private ListViewItem getFloatView(int listIndex, final de.longri.cachebox3.settings.types.SettingFloat setting) { final VisLabel valueLabel = new VisLabel(Float.toString(setting.getValue()), valueStyle); ListViewItem table = getNumericItemTable(listIndex, valueLabel, setting); // add clickListener table.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { if (event.getType() == InputEvent.Type.touchUp) { new NumericInput_Activity<Float>(setting.getValue()) { public void returnValue(Float value) { setting.setValue(value); WidgetGroup group = listViews.peek(); for (Actor actor : group.getChildren()) { if (actor instanceof ListView) { final ListView listView = (ListView) actor; final float scrollPos = listView.getScrollPos(); listView.layout(FORCE); Gdx.app.postRunnable(new Runnable() { @Override public void run() { listView.setScrollPos(scrollPos); } }); } } } }.show(); } } }); return table; }
private ListViewItem getDblView(int listIndex, final de.longri.cachebox3.settings.types.SettingDouble setting) { final VisLabel valueLabel = new VisLabel(Double.toString(setting.getValue()), valueStyle); ListViewItem table = getNumericItemTable(listIndex, valueLabel, setting); // add clickListener table.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { if (event.getType() == InputEvent.Type.touchUp) { new NumericInput_Activity<Double>(setting.getValue()) { public void returnValue(Double value) { setting.setValue(value); WidgetGroup group = listViews.peek(); for (Actor actor : group.getChildren()) { if (actor instanceof ListView) { final ListView listView = (ListView) actor; final float scrollPos = listView.getScrollPos(); listView.layout(FORCE); Gdx.app.postRunnable(new Runnable() { @Override public void run() { listView.setScrollPos(scrollPos); } }); } } } }.show(); } } }); return table; }
private ListViewItem getIntView(int listIndex, final de.longri.cachebox3.settings.types.SettingInt setting) { final VisLabel valueLabel = new VisLabel(Integer.toString(setting.getValue()), valueStyle); final ListViewItem table = getNumericItemTable(listIndex, valueLabel, setting); // add clickListener table.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { if (event.getType() == InputEvent.Type.touchUp) { new NumericInput_Activity<Integer>(setting.getValue()) { public void returnValue(Integer value) { setting.setValue(value); WidgetGroup group = listViews.peek(); for (Actor actor : group.getChildren()) { if (actor instanceof ListView) { final ListView listView = (ListView) actor; final float scrollPos = listView.getScrollPos(); listView.layout(FORCE); Gdx.app.postRunnable(new Runnable() { @Override public void run() { listView.setScrollPos(scrollPos); } }); } } } }.show(); } } }); return table; }
public boolean act(float delta) { if (!added) { added = true; if (target instanceof WidgetGroup) { WidgetGroup group = (WidgetGroup) target; group.addActor(actor); } } return true; }
private static void addAndShow(WidgetGroup actor, WindowPosition position) { stage.addActor(actor); actor.setVisible(true); actor.pack(); position.position(actor); moveToTop(actor); }
@Override public void process(LmlParser parser, LmlTag tag, DragPane actor, String rawAttributeData) { WidgetGroup group = actor.getGroup(); String id = parser.parseString(rawAttributeData, group); LmlUtilities.setActorId(group, id); parser.getActorsMappedByIds().put(id, group); }
/** Toast manager will create own group to host toasts and put it into the stage root. */ public ToastManager (Stage stage) { WidgetGroup widgetGroup = new WidgetGroup(); widgetGroup.setFillParent(true); widgetGroup.setTouchable(Touchable.childrenOnly); stage.addActor(widgetGroup); this.root = widgetGroup; }
/** @param group will replace the internally managed group. All current children will be moved to this group. */ @Override public void setActor (final WidgetGroup group) { if (group == null) { throw new IllegalArgumentException("Group cannot be null."); } final Group previousGroup = getActor(); super.setActor(group); attachListener(); // Attaches draggable to all previous group children. for (final Actor child : previousGroup.getChildren()) { group.addActor(child); // No need to attach draggable, child was already in pane. } }
private void invalidateRecursively (WidgetGroup group) { group.invalidate(); for (Actor actor : group.getChildren()) { if (actor instanceof WidgetGroup) invalidateRecursively((WidgetGroup) actor); else if (actor instanceof Layout) ((Layout) actor).invalidate(); } }
public ItemList(WidgetGroup group) { SharedInjector.get().injectMembers(this); this.group = group; widgets = new HashMap<ItemId, ItemWidget>(); items = new HashMap<Actor, Item>(); comparator = new ItemWidgetComparator(); eventBus.subscribe(this); ItemBag itemBag = api.getOwnedItems(Player.getCurrent().getId()); for (Entry<Item, Integer> entry : itemBag) { addElements(entry.getKey(), entry.getValue()); } }
@Override public void set(Object key, Object value) { if ("HEALTH".equals(key)) { Integer health = (Integer) value; Integer oldHealth = (Integer) properties.get(key); int diff = health - oldHealth; WidgetGroup grp = (WidgetGroup) table.getParent(); grp.layout(); if (diff != 0) { Vector2 pos = new Vector2(table.getWidth() / 2, table.getHeight() / 2); table.localToStageCoordinates(pos); final Label changeLabel = new Label(String.valueOf(diff), context.getSkin()); Gdx.app.log("Anim", "Create health animation at " + pos.x + ", " + pos.y); changeLabel.setPosition(pos.x, pos.y); if (diff > 0) { changeLabel.setColor(Color.GREEN); } else { changeLabel.setColor(Color.RED); } changeLabel.addAction(Actions.sequence(Actions.moveBy(0, this.screenHeight/8, 1.5f), Actions.run(new Runnable() { @Override public void run() { changeLabel.remove(); } }))); context.getStage().addActor(changeLabel); } } properties.put((String) key, value); cost.update(properties); stats.update(properties); }
@Override public void create() { Gdx.app.setLogLevel(Application.LOG_DEBUG); Gdx.gl.glClearColor(1f, 1f, 1f, 1f); stage = new Stage(new ScreenViewport()); WidgetGroup modalContainer = new WidgetGroup(); modalContainer.setFillParent(true); WidgetGroup viewContainer = new WidgetGroup(); viewContainer.setFillParent(true); stage.getRoot().addActor(viewContainer); stage.getRoot().addActor(modalContainer); controller = new MokapController(platform = new MockPlatform(), Gdx.files, viewContainer, modalContainer); controller.getCommands().pushStack(); platform.setBatch(stage.getBatch()); Gdx.input.setInputProcessor(stage); ApplicationAssets assets = controller.getApplicationAssets(); actor = buildUI(assets.getSkin(), assets.getI18N()); if (actor instanceof WidgetGroup) { ((WidgetGroup) actor).setFillParent(true); } viewContainer.addActor(actor); stage.addListener(new ShortcutListener()); }
public void completeRowsIfPossible(WidgetGroup reference) { reference.layout(); IconButton image = (IconButton) colors.getChildren().first(); int rowsToAdd = Math.min( (int) Math.floor((Gdx.graphics.getHeight() - reference .getPrefHeight()) / image.getPrefHeight()), style.rows - colors.getRows()); for (int i = 0; i < rowsToAdd; i++) { addColorRow(); } SnapshotArray<Actor> children = colors.getChildren(); for (int i = 0, n = children.size; i < n; ++i) { Actor actor = children.get(i); int intCol = prefs.getInteger(Preferences.PREF_COLOR + i, -1); if (intCol == -1) { float[] rgb = picker.HSBtoRGB(i / (float) n, 1, 1); actor.setColor(rgb[0], rgb[1], rgb[2], 1f); } else { Color.rgba8888ToColor(actor.getColor(), intCol); actor.setColor(actor.getColor()); } } }
protected Controller buildController() { WidgetGroup modalContainer = new WidgetGroup(); modalContainer.setFillParent(true); WidgetGroup viewContainer = new WidgetGroup(); viewContainer.setFillParent(true); stage.addActor(viewContainer); stage.addActor(modalContainer); return new MokapController(this.platform, Gdx.files, viewContainer, modalContainer); }
/** * Sets the widget with the contents for the tab */ public TabWidget setContent(WidgetGroup content) { if (this.content != null) { this.content.remove(); } this.content = content; this.contentPrefHeight = getPrefHeight(content); addActor(content); return this; }
protected WidgetGroup getLayoutActor() { VerticalWidgetGroup verticalWidgetGroup = new VerticalWidgetGroup( columns); verticalWidgetGroup.setBottomOffset(bottomOffset); verticalWidgetGroup.setPadding(getItemPadding()); return verticalWidgetGroup; }
@Override protected void refresh() { // TODO just generate new item, all others must be reused WidgetGroup scrollActor = getLayoutActor(); Set<T> removeSet = new HashSet<T>(); removeSet.addAll(cacheMap.keySet()); T currentSelectedItem = model.getCurrentSelectedItem(); for (int i = model.getCount() - 1; i >= 0; i--) { T item = model.getItem(i); boolean selected = currentSelectedItem == item; Actor actor = createItem(item, skin, cacheMap.get(item), selected); if (actor != null) { Action inAnimation = inAnimation(); if (inAnimation != null && firstTime) { actor.addAction(inAnimation); } cacheMap.put(item, actor); removeSet.remove(item); scrollActor.addActor(actor); } } for (T removeKey : removeSet) { cacheMap.remove(removeKey); } scrollActor.pack(); scrollPane.setWidget(scrollActor); firstTime = false; }
protected WidgetGroup getLayoutActor() { HorizontalWidgetGroup horizontalWidgetGroup = new HorizontalWidgetGroup( rows); horizontalWidgetGroup.setSideOffset(sideOffset); horizontalWidgetGroup.setPadding(getItemPadding()); return horizontalWidgetGroup; }
@Override public void create () { loadHighScore(); stage = new Stage(); group = new WidgetGroup(); stage.addActor(group); createToolTip(); createResetButton(); createUndoButton(); batch = new SpriteBatch(); polyBatch = new PolygonSpriteBatch(); HexagonalGridBuilder<TileData> builder = new HexagonalGridBuilder<TileData>() .setGridHeight(GRID_WIDTH) .setGridWidth(GRID_HEIGHT) .setGridLayout(HexagonalGridLayout.HEXAGONAL) .setOrientation(HexagonOrientation.FLAT_TOP) .setRadius(Gdx.graphics.getWidth()/16); grid = builder.build(); initHexData(); initInput(); shapeRenderer = new ShapeRenderer(); shapeRenderer.setAutoShapeType(true); AssetLoader.load(); String vertexShader = Gdx.files.internal("defaultvertex.vs").readString(); String redShader = Gdx.files.internal("redtrans.fs").readString(); invalidPlacement = new ShaderProgram(vertexShader, redShader); if (!invalidPlacement.isCompiled()) throw new GdxRuntimeException("Couldn't compile shader: " + invalidPlacement.getLog()); String okShader = Gdx.files.internal("slightlytrans.fs").readString(); okPlacement = new ShaderProgram(vertexShader, okShader); if (!okPlacement.isCompiled()) throw new GdxRuntimeException("Couldn't compile shader: " + okPlacement.getLog()); initGrid(); menuTextures = new ArrayList<>(); menuTextures.add(AssetLoader.assetManager.get("farm.png", Texture.class)); menuTextures.add(AssetLoader.assetManager.get("house.png", Texture.class)); menuTextures.add(AssetLoader.assetManager.get("mine.png", Texture.class)); menuTextures.add(AssetLoader.assetManager.get("wind.png", Texture.class)); menuTextures.add(AssetLoader.assetManager.get("factory.png", Texture.class)); menuTextures.add(AssetLoader.assetManager.get("market.png", Texture.class)); menuTextures.add(AssetLoader.assetManager.get("bank.png", Texture.class)); menuTextures.add(AssetLoader.assetManager.get("rocket.png", Texture.class)); for(int i = 0; i < START_CLOUDS_COUNT; i++) { Coord c = new Coord(); c.x = r.nextInt() % Gdx.graphics.getWidth(); c.y = r.nextInt() % Gdx.graphics.getHeight(); clouds.add(c); } }
public StatusUI(Stage stage) { super("", Utils.UI_SKIN); this.setMovable(false); hpLabel = new Label("10 / 10", Utils.UI_SKIN); hpBar = new Image(Utils.UI_TEXTURE_ATLAS.findRegion("hp_bar")); hpBarBorder = new Image(Utils.UI_TEXTURE_ATLAS.findRegion("bar")); mpLabel = new Label("15 / 15", Utils.UI_SKIN); mpBar = new Image(Utils.UI_TEXTURE_ATLAS.findRegion("mp_bar")); mpBarBorder = new Image(Utils.UI_TEXTURE_ATLAS.findRegion("bar")); xpLabel = new Label("27 / 50", Utils.UI_SKIN); xpBar = new Image(Utils.UI_TEXTURE_ATLAS.findRegion("xp_bar")); xpBarBorder = new Image(Utils.UI_TEXTURE_ATLAS.findRegion("bar")); inventoryButton = new ImageButton(Utils.UI_SKIN, "inventory-button"); lvlLabel = new Label("Level: 1", Utils.UI_SKIN); goldLabel = new Label(GOLD_LABEL, Utils.UI_SKIN); WidgetGroup hpGroup = new WidgetGroup(); WidgetGroup mpGroup = new WidgetGroup(); WidgetGroup xpGroup = new WidgetGroup(); hpLabel.setPosition(43, 7); hpBar.setPosition(33, 10); hpBar.scaleBy(-0.49f); hpBarBorder.scaleBy(-0.5f); hpGroup.addActor(hpBar); hpGroup.addActor(hpBarBorder); hpGroup.addActor(hpLabel); mpLabel.setPosition(43, 7); mpBar.setPosition(33, 10); mpBar.scaleBy(-0.49f); mpBarBorder.scaleBy(-0.5f); mpGroup.addActor(mpBar); mpGroup.addActor(mpBarBorder); mpGroup.addActor(mpLabel); xpLabel.setPosition(43, 7); xpBar.setPosition(33, 10); xpBar.scaleBy(-0.49f); xpBar.scaleBy(-0.25f, 0); xpBarBorder.scaleBy(-0.5f); xpGroup.addActor(xpBar); xpGroup.addActor(xpBarBorder); xpGroup.addActor(xpLabel); inventoryButton.getImageCell().size(32, 32); this.defaults().expand().fill().pad(5); this.add(hpGroup).width(323); this.add(xpGroup).width(323); this.add(inventoryButton); this.row(); this.add(mpGroup).width(323); this.add(lvlLabel).padLeft(50); this.add(goldLabel).padRight(50); pack(); setPosition(stage.getWidth() / 2 - getWidth() / 2, 0); stage.addActor(this); }
private static void addAndShow(WidgetGroup actor) { addAndShow(actor, WindowPosition.CENTER); }
@Override protected WidgetGroup getNewInstanceOfGroup(LmlActorBuilder builder) { return new WidgetGroup(); }
public ToastManager(Stage stage) { WidgetGroup widgetGroup = new WidgetGroup(); widgetGroup.setFillParent(true); stage.addActor(widgetGroup); this.root = widgetGroup; }
@Override public WidgetGroup getGroup() { return new HorizontalGroup(); }
@Override public WidgetGroup getGroup() { return new VerticalGroup(); }
@Override public WidgetGroup getGroup() { return new GridGroup(); }
@Override public WidgetGroup getGroup() { return new FixedSizeGridGroup(16, 32); }
@Override public Draggable getDraggable(final WidgetGroup group) { return FixedSizeGridGroup.getDraggable((FixedSizeGridGroup) group); }
@Override public WidgetGroup getGroup() { return new HorizontalFlowGroup(); }
@Override public WidgetGroup getGroup() { return new VerticalFlowGroup(); }
@Override public WidgetGroup getGroup() { return new FloatingGroup(); }
/** @return a new instance of selected group type. */ public abstract WidgetGroup getGroup();