* ImageTabbedPane can support both text and icons
* Expose more assets creation in plugin api * Improve Tiled panel UI
This commit is contained in:
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
@@ -882,6 +882,7 @@
|
||||
vertical: false,
|
||||
tabPadding: 20,
|
||||
singleLine: true,
|
||||
font: default-font,
|
||||
buttonStyle: {
|
||||
down: tab-active,
|
||||
up: tab-inactive,
|
||||
|
||||
+1
-1
Submodule hyperlap2d-common-api updated: bf2f0b0996...8f428569cd
@@ -19,21 +19,20 @@
|
||||
package games.rednblack.editor.plugin.tiled;
|
||||
|
||||
import com.badlogic.ashley.core.Engine;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.kotcrab.vis.ui.VisUI;
|
||||
import com.kotcrab.vis.ui.widget.VisLabel;
|
||||
import com.kotcrab.vis.ui.widget.VisTable;
|
||||
import com.kotcrab.vis.ui.widget.VisTextButton;
|
||||
import com.kotcrab.vis.ui.widget.tabbedpane.Tab;
|
||||
import com.kotcrab.vis.ui.widget.tabbedpane.TabbedPane;
|
||||
import com.kotcrab.vis.ui.widget.tabbedpane.TabbedPaneListener;
|
||||
import games.rednblack.editor.plugin.tiled.data.TileVO;
|
||||
import games.rednblack.editor.plugin.tiled.manager.ResourcesManager;
|
||||
import games.rednblack.editor.plugin.tiled.view.tabs.GridTilesTab;
|
||||
import games.rednblack.editor.plugin.tiled.view.tabs.SettingsTab;
|
||||
import games.rednblack.h2d.common.UIDraggablePanel;
|
||||
import games.rednblack.h2d.common.view.ui.widget.imagetabbedpane.ImageTab;
|
||||
import games.rednblack.h2d.common.view.ui.widget.imagetabbedpane.ImageTabbedPane;
|
||||
import games.rednblack.h2d.common.view.ui.widget.imagetabbedpane.ImageTabbedPaneListener;
|
||||
import org.puremvc.java.interfaces.IFacade;
|
||||
|
||||
/**
|
||||
@@ -47,19 +46,16 @@ public class TiledPanel extends UIDraggablePanel {
|
||||
public static final float DROP_HEIGHT = 140f;
|
||||
public static final float SETTINGS_WIDTH = 200f;
|
||||
public static final float SETTINGS_HEIGHT = 150f;
|
||||
public static final float BOTTOM_BAR_X = 177f;
|
||||
public static final float BOTTOM_BAR_DELTA_Y = 6f;
|
||||
|
||||
public TiledPlugin tiledPlugin;
|
||||
private IFacade facade;
|
||||
|
||||
protected TabbedPane tabbedPane;
|
||||
protected ImageTabbedPane tabbedPane;
|
||||
protected VisTable tabTable; //table inside of each tab
|
||||
protected Table paneTable; //table for 'tabs' row
|
||||
|
||||
private GridTilesTab tilesTab;
|
||||
private SettingsTab settingsTab;
|
||||
private Image bottomBar;
|
||||
private VisTable mainTable;
|
||||
private Engine engine;
|
||||
private ResourcesManager resourcesManager;
|
||||
@@ -79,30 +75,20 @@ public class TiledPanel extends UIDraggablePanel {
|
||||
}
|
||||
|
||||
public void initView() {
|
||||
if (bottomBar == null) {
|
||||
if (resourcesManager == null)
|
||||
this.resourcesManager = tiledPlugin.pluginRM;
|
||||
bottomBar = new Image(resourcesManager.getTextureRegion("tab-back-line"));
|
||||
bottomBar.setWidth(80);
|
||||
addActorBefore(mainTable, bottomBar);
|
||||
}
|
||||
|
||||
mainTable.clear();
|
||||
|
||||
TabbedPane.TabbedPaneStyle style = new TabbedPane.TabbedPaneStyle();
|
||||
VisTextButton.VisTextButtonStyle btnStyle = new VisTextButton.VisTextButtonStyle();
|
||||
btnStyle.up = new TextureRegionDrawable(resourcesManager.getTextureRegion("plugin-tab-inactive"));
|
||||
btnStyle.checked = new TextureRegionDrawable(resourcesManager.getTextureRegion("plugin-tab-active"));
|
||||
btnStyle.font = VisUI.getSkin().getFont("default-font");
|
||||
btnStyle.fontColor = VisUI.getSkin().getColor("white");
|
||||
style.buttonStyle = btnStyle;
|
||||
tabbedPane = new TabbedPane(style);
|
||||
tabbedPane = new ImageTabbedPane();
|
||||
paneTable = tabbedPane.getTable();
|
||||
|
||||
mainTable.add(paneTable)
|
||||
.left()
|
||||
.top()
|
||||
.expandX()
|
||||
.row();
|
||||
mainTable.add(paneTable).growX();
|
||||
mainTable.row();
|
||||
|
||||
tabTable.clear();
|
||||
paneTable.row();
|
||||
@@ -111,10 +97,10 @@ public class TiledPanel extends UIDraggablePanel {
|
||||
.top()
|
||||
.row();
|
||||
|
||||
tabbedPane.addListener(new TabbedPaneListener() {
|
||||
tabbedPane.addListener(new ImageTabbedPaneListener() {
|
||||
|
||||
@Override
|
||||
public void switchedTab (Tab tab) {
|
||||
public void switchedTab (ImageTab tab) {
|
||||
if (tab == null) {
|
||||
return;
|
||||
}
|
||||
@@ -143,12 +129,11 @@ public class TiledPanel extends UIDraggablePanel {
|
||||
.row();
|
||||
pack();
|
||||
|
||||
setBottomBarPosition(HEIGHT);
|
||||
setFixedPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removedTab(Tab tab) {
|
||||
public void removedTab(ImageTab tab) {
|
||||
|
||||
}
|
||||
|
||||
@@ -164,11 +149,6 @@ public class TiledPanel extends UIDraggablePanel {
|
||||
pack();
|
||||
}
|
||||
|
||||
public void setBottomBarPosition(float panelHeight) {
|
||||
bottomBar.setX(BOTTOM_BAR_X);
|
||||
bottomBar.setY(panelHeight + BOTTOM_BAR_DELTA_Y);
|
||||
}
|
||||
|
||||
public void setFixedPosition() {
|
||||
setPosition(56f, 765f - getPrefHeight());
|
||||
}
|
||||
@@ -216,7 +196,6 @@ public class TiledPanel extends UIDraggablePanel {
|
||||
.width(width)
|
||||
.height(height);
|
||||
tabTable.pack();
|
||||
setBottomBarPosition(height);
|
||||
pack();
|
||||
}
|
||||
|
||||
|
||||
+9
-5
@@ -12,6 +12,7 @@ import games.rednblack.editor.renderer.components.TransformComponent;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.h2d.common.command.TransformCommandBuilder;
|
||||
import games.rednblack.h2d.common.command.UpdateRegionCommandBuilder;
|
||||
import games.rednblack.h2d.common.factory.IFactory;
|
||||
import games.rednblack.h2d.common.view.tools.Tool;
|
||||
import org.puremvc.java.interfaces.INotification;
|
||||
|
||||
@@ -156,12 +157,15 @@ public class DrawTileTool implements Tool {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity imageEntity = tiledPlugin.getAPI().drawImage(tiledPlugin.getSelectedTileName(), new Vector2(newX, newY));
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(imageEntity, MainItemComponent.class);
|
||||
mainItemComponent.tags.add(TiledPlugin.TILE_TAG);
|
||||
IFactory itemFactory = tiledPlugin.getAPI().getItemFactory();
|
||||
if (itemFactory.createSimpleImage(tiledPlugin.getSelectedTileName(), new Vector2(newX, newY))) {
|
||||
Entity imageEntity = itemFactory.getCreatedEntity();
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(imageEntity, MainItemComponent.class);
|
||||
mainItemComponent.tags.add(TiledPlugin.TILE_TAG);
|
||||
|
||||
mainItemComponent.setCustomVars(TiledPlugin.ROW, Integer.toString(row));
|
||||
mainItemComponent.setCustomVars(TiledPlugin.COLUMN, Integer.toString(column));
|
||||
mainItemComponent.setCustomVars(TiledPlugin.ROW, Integer.toString(row));
|
||||
mainItemComponent.setCustomVars(TiledPlugin.COLUMN, Integer.toString(column));
|
||||
}
|
||||
}
|
||||
|
||||
private void drawOnEntity(Entity entity, float x, float y) {
|
||||
|
||||
+7
-2
@@ -2,13 +2,13 @@ package games.rednblack.editor.plugin.tiled.view.tabs;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.kotcrab.vis.ui.widget.VisLabel;
|
||||
import com.kotcrab.vis.ui.widget.tabbedpane.Tab;
|
||||
import games.rednblack.editor.plugin.tiled.TiledPanel;
|
||||
import games.rednblack.h2d.common.view.ui.widget.imagetabbedpane.ImageTab;
|
||||
|
||||
/**
|
||||
* Created by mariam on 10/30/15.
|
||||
*/
|
||||
public class DefaultTab extends Tab {
|
||||
public class DefaultTab extends ImageTab {
|
||||
|
||||
protected TiledPanel panel;
|
||||
protected int tabIndex;
|
||||
@@ -31,6 +31,11 @@ public class DefaultTab extends Tab {
|
||||
return tabTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabIconStyle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Table getContentTable () {
|
||||
return content;
|
||||
|
||||
+4
-2
@@ -16,6 +16,7 @@ import games.rednblack.editor.plugin.tiled.TiledPanel;
|
||||
import games.rednblack.editor.plugin.tiled.TiledPlugin;
|
||||
import games.rednblack.editor.plugin.tiled.data.TileVO;
|
||||
import games.rednblack.editor.plugin.tiled.manager.ResourcesManager;
|
||||
import games.rednblack.h2d.common.view.ui.StandardWidgetsFactory;
|
||||
|
||||
/**
|
||||
* Created by mariam on 2/11/16.
|
||||
@@ -118,7 +119,8 @@ public class GridTilesTab extends DefaultTab {
|
||||
tiles.clear();
|
||||
|
||||
VisTable listTable = new VisTable();
|
||||
pane = new VisScrollPane(listTable);
|
||||
pane = StandardWidgetsFactory.createScrollPane(listTable);
|
||||
pane.setScrollingDisabled(true, false);
|
||||
content.add(pane)
|
||||
.padTop(10);
|
||||
listTable.top();
|
||||
@@ -127,7 +129,7 @@ public class GridTilesTab extends DefaultTab {
|
||||
tilesCount = tileIndex + 1;
|
||||
}
|
||||
|
||||
for (int i=0; i<tilesCount; i++) {
|
||||
for (int i = 0; i < tilesCount + 1; i++) {
|
||||
VisImageButton ct;
|
||||
VisImageButton.VisImageButtonStyle imageBoxStyle = new VisImageButton.VisImageButtonStyle();
|
||||
NinePatchDrawable inactive = new NinePatchDrawable(new NinePatch(resourcesManager.getPluginNinePatch("image-Box-inactive")));
|
||||
|
||||
@@ -21,7 +21,6 @@ package games.rednblack.editor.factory;
|
||||
import com.badlogic.ashley.core.Engine;
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
@@ -29,7 +28,6 @@ import games.rednblack.editor.controller.commands.PasteItemsCommand;
|
||||
import games.rednblack.editor.proxy.ProjectManager;
|
||||
import games.rednblack.editor.proxy.ResourceManager;
|
||||
import games.rednblack.editor.renderer.SceneLoader;
|
||||
import games.rednblack.editor.renderer.components.DimensionsComponent;
|
||||
import games.rednblack.editor.renderer.components.MainItemComponent;
|
||||
import games.rednblack.editor.renderer.data.*;
|
||||
import games.rednblack.editor.renderer.factory.EntityFactory;
|
||||
@@ -37,6 +35,7 @@ import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.editor.view.stage.tools.TextTool;
|
||||
import games.rednblack.editor.view.ui.box.UILayerBoxMediator;
|
||||
import games.rednblack.h2d.common.factory.IFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -44,12 +43,12 @@ import java.util.HashMap;
|
||||
* Created by azakhary on 6/5/2015.
|
||||
*
|
||||
*/
|
||||
public class ItemFactory {
|
||||
public class ItemFactory implements IFactory {
|
||||
|
||||
private EntityFactory entityFactory;
|
||||
private SceneLoader sceneLoader;
|
||||
private Sandbox sandbox;
|
||||
private Entity imageEntity;
|
||||
private final EntityFactory entityFactory;
|
||||
private final SceneLoader sceneLoader;
|
||||
private final Sandbox sandbox;
|
||||
private Entity createdEntity;
|
||||
|
||||
private static ItemFactory instance;
|
||||
|
||||
@@ -85,19 +84,21 @@ public class ItemFactory {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createSimpleImage(String regionName, Vector2 position) {
|
||||
SimpleImageVO vo = new SimpleImageVO();
|
||||
vo.imageName = regionName;
|
||||
|
||||
if(!setEssentialData(vo, position)) return false;
|
||||
imageEntity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_CREATE_ITEM, imageEntity);
|
||||
createdEntity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_CREATE_ITEM, createdEntity);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Entity getImageEntity() {
|
||||
return imageEntity;
|
||||
@Override
|
||||
public Entity getCreatedEntity() {
|
||||
return createdEntity;
|
||||
}
|
||||
|
||||
public boolean create9Patch(String regionName, Vector2 position) {
|
||||
@@ -105,31 +106,33 @@ public class ItemFactory {
|
||||
vo.imageName = regionName;
|
||||
|
||||
if(!setEssentialData(vo, position)) return false;
|
||||
Entity entity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_CREATE_ITEM, entity);
|
||||
createdEntity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_CREATE_ITEM, createdEntity);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createSpriteAnimation(String animationName, Vector2 position) {
|
||||
SpriteAnimationVO vo = new SpriteAnimationVO();
|
||||
vo.animationName = animationName;
|
||||
vo.playMode = 2;
|
||||
|
||||
if(!setEssentialData(vo, position)) return false;
|
||||
Entity entity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_CREATE_ITEM, entity);
|
||||
createdEntity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_CREATE_ITEM, createdEntity);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createSpineAnimation(String animationName, Vector2 position) {
|
||||
SpineVO vo = new SpineVO();
|
||||
vo.animationName = animationName;
|
||||
|
||||
if(!setEssentialData(vo, position)) return false;
|
||||
Entity entity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_CREATE_ITEM, entity);
|
||||
createdEntity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_CREATE_ITEM, createdEntity);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -148,6 +151,7 @@ public class ItemFactory {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createItemFromLibrary(String libraryName, Vector2 position) {
|
||||
ProjectManager projectManager = HyperLap2DFacade.getInstance().retrieveProxy(ProjectManager.NAME);
|
||||
HashMap<String, CompositeItemVO> libraryItems = projectManager.currentProjectInfoVO.libraryItems;
|
||||
@@ -155,15 +159,15 @@ public class ItemFactory {
|
||||
CompositeItemVO itemVO = libraryItems.get(libraryName);
|
||||
itemVO.uniqueId = -1;
|
||||
PasteItemsCommand.forceIdChange(itemVO.composite);
|
||||
Entity entity = createCompositeItem(itemVO, position);
|
||||
createdEntity = createCompositeItem(itemVO, position);
|
||||
|
||||
if (entity == null) return false;
|
||||
if (createdEntity == null) return false;
|
||||
|
||||
//adding library name
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(createdEntity, MainItemComponent.class);
|
||||
mainItemComponent.libraryLink = libraryName;
|
||||
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_CREATE_ITEM, entity);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_CREATE_ITEM, createdEntity);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import games.rednblack.editor.renderer.data.ProjectInfoVO;
|
||||
import games.rednblack.editor.view.stage.UIStage;
|
||||
import games.rednblack.h2d.common.IItemCommand;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.h2d.common.factory.IFactory;
|
||||
import games.rednblack.h2d.common.plugins.H2DPlugin;
|
||||
import games.rednblack.h2d.common.plugins.PluginAPI;
|
||||
import games.rednblack.h2d.common.proxy.CursorManager;
|
||||
@@ -224,10 +225,8 @@ public class PluginManager extends Proxy implements PluginAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity drawImage(String regionName, Vector2 position) {
|
||||
ItemFactory itemFactory = ItemFactory.get();
|
||||
itemFactory.createSimpleImage(regionName, position);
|
||||
return itemFactory.getImageEntity();
|
||||
public IFactory getItemFactory() {
|
||||
return ItemFactory.get();
|
||||
}
|
||||
|
||||
public boolean isEntityVisible(Entity e) {
|
||||
|
||||
Reference in New Issue
Block a user