* Avoid tons of garbage in Items Tree
* Update libGDX to 1.10.1-SNAPSHOT * Update LWJGL to 3.3.0-SNAPSHOT
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
[0.0.8]
|
||||
- Update libGDX to 1.10.1-SNAPSHOT
|
||||
- [BREAK CHANGE] Rework runtime code, replaced Ashley ECS with Artemis-odb
|
||||
|
||||
= Editor =
|
||||
- Update LWJGL to 3.3.0-SNAPSHOT
|
||||
|
||||
[0.0.7]
|
||||
- [BREAK CHANGE] Spine and Sprite animations are now packed into same main atlas pack
|
||||
- [BREAK CHANGE] Update Project version to `0.2.0`
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
gdxVersion = 1.10.0
|
||||
lwjgl3Version = 3.2.3
|
||||
gdxVersion = 1.10.1-SNAPSHOT
|
||||
lwjgl3Version = 3.3.0-SNAPSHOT
|
||||
artemisVersion = 2.3.0
|
||||
spineVersion = 3.8.55.1
|
||||
visuiVersion = 1.5.0
|
||||
|
||||
@@ -37,6 +37,8 @@ public class CustomExceptionHandler implements UncaughtExceptionHandler {
|
||||
stacktrace = stacktrace.replace("<", "");
|
||||
stacktrace = stacktrace.replace(">", "");
|
||||
stacktrace = stacktrace.replace("$", "");
|
||||
stacktrace = stacktrace.replace("'", "");
|
||||
stacktrace = stacktrace.replace("\"", "");
|
||||
|
||||
TinyFileDialogs.tinyfd_messageBox("Oops! Something went wrong",
|
||||
"HyperLap2D just crashed, stacktrace saved in: " + localPath.getAbsolutePath()
|
||||
|
||||
+2
@@ -143,5 +143,7 @@ public class ConvertToCompositeCommand extends EntityModifyRevertibleCommand {
|
||||
HyperLap2DFacade.getInstance().sendNotification(DONE);
|
||||
|
||||
sandbox.getSelector().setSelections(children, true);
|
||||
|
||||
facade.sendNotification(MsgAPI.DELETE_ITEMS_COMMAND_DONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.renderer.components.TransformComponent;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -35,6 +34,8 @@ import java.util.Map;
|
||||
*/
|
||||
public class ItemsMoveCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
public static final String TAG = ItemsMoveCommand.class.getCanonicalName();
|
||||
|
||||
private HashMap<Integer, Vector2> prevLocations = new HashMap<>();
|
||||
|
||||
@Override
|
||||
@@ -59,7 +60,7 @@ public class ItemsMoveCommand extends EntityModifyRevertibleCommand {
|
||||
transformComponent.y = newLocation.y;
|
||||
|
||||
// pining UI to update current item properties tools
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity, TAG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@ public class ItemsMoveCommand extends EntityModifyRevertibleCommand {
|
||||
transformComponent.y = prevLocation.y;
|
||||
|
||||
// pining UI to update current item properties tools
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity, TAG);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,9 +92,8 @@ public class EntityUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static Drawable getItemIcon(int entity) {
|
||||
int type = EntityUtils.getType(entity);
|
||||
String icon = itemTypeIconMap.get(type);
|
||||
public static Drawable getItemIcon(int entityType) {
|
||||
String icon = itemTypeIconMap.get(entityType);
|
||||
return VisUI.getSkin().getDrawable(icon);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,15 @@ package games.rednblack.editor.view.ui.box;
|
||||
import java.util.Comparator;
|
||||
import java.util.Set;
|
||||
|
||||
import com.artemis.ComponentMapper;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Cell;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Tree;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.Selection;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Pools;
|
||||
import com.kotcrab.vis.ui.widget.*;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.renderer.components.MainItemComponent;
|
||||
@@ -34,25 +37,33 @@ import games.rednblack.editor.renderer.components.NodeComponent;
|
||||
import games.rednblack.editor.renderer.components.ParentNodeComponent;
|
||||
import games.rednblack.editor.renderer.components.ZIndexComponent;
|
||||
import games.rednblack.editor.renderer.factory.EntityFactory;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.h2d.common.view.ui.StandardWidgetsFactory;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
|
||||
public class UIItemsTreeBox extends UICollapsibleBox {
|
||||
protected ComponentMapper<NodeComponent> nodeComponentMapper;
|
||||
protected ComponentMapper<ParentNodeComponent> parentNodeComponentMapper;
|
||||
protected ComponentMapper<MainItemComponent> mainItemComponentMapper;
|
||||
protected ComponentMapper<ZIndexComponent> zIndexComponentMapper;
|
||||
|
||||
public static final String ITEMS_SELECTED = "games.rednblack.editor.view.ui.box.UIItemsTreeBox." + ".ITEMS_SELECTED";
|
||||
private final HyperLap2DFacade facade;
|
||||
private final VisTable treeTable;
|
||||
private Tree<UIItemsTreeNode, UIItemsTreeValue> tree;
|
||||
private VisScrollPane scroller;
|
||||
private UIItemsTreeNode rootTreeNode;
|
||||
|
||||
private final Array<UIItemsTreeNode> tmpNodes = new Array<>();
|
||||
private UIItemsTreeNode rootNode;
|
||||
private Set<Integer> lastSelection;
|
||||
|
||||
private final VisImageButton zUp, zDown;
|
||||
|
||||
Sandbox sandbox;
|
||||
private Sandbox sandbox;
|
||||
|
||||
private final ZIndexComparator zIndexComparator = new ZIndexComparator();
|
||||
|
||||
public UIItemsTreeBox() {
|
||||
super("Items Tree", 180);
|
||||
@@ -87,14 +98,13 @@ public class UIItemsTreeBox extends UICollapsibleBox {
|
||||
});
|
||||
}
|
||||
|
||||
UIItemsTreeNode rootTreeNode;
|
||||
|
||||
public void init(int rootScene) {
|
||||
sandbox = Sandbox.getInstance();
|
||||
sandbox.getEngine().inject(this);
|
||||
|
||||
treeTable.clear();
|
||||
tree = new VisTree<>();
|
||||
VisScrollPane scroller = StandardWidgetsFactory.createScrollPane(tree);
|
||||
scroller = StandardWidgetsFactory.createScrollPane(tree);
|
||||
scroller.setFlickScroll(false);
|
||||
treeTable.add(scroller).width(177).maxHeight(570).colspan(2);
|
||||
//
|
||||
@@ -115,20 +125,39 @@ public class UIItemsTreeBox extends UICollapsibleBox {
|
||||
}
|
||||
|
||||
public void sortTree() {
|
||||
rootTreeNode.getChildren().sort(new ZIndexComparator());
|
||||
rootTreeNode.getChildren().sort(zIndexComparator);
|
||||
rootTreeNode.updateChildren();
|
||||
tree.updateRootNodes();
|
||||
}
|
||||
|
||||
public void update(int rootScene) {
|
||||
Pools.freeAll(tmpNodes);
|
||||
tmpNodes.clear();
|
||||
|
||||
tree.clearChildren();
|
||||
tree.setOverNode(null);
|
||||
tree.getRootNodes().clear();
|
||||
tree.getSelection().clear();
|
||||
|
||||
rootTreeNode = addTreeRoot(rootScene, null);
|
||||
rootTreeNode.setExpanded(true);
|
||||
|
||||
sortTree();
|
||||
|
||||
if (lastSelection != null)
|
||||
setSelection(lastSelection);
|
||||
}
|
||||
|
||||
private UIItemsTreeNode addTreeRoot(int entity, UIItemsTreeNode parentNode) { // was like this addTreeRoot(CompositeItem compoiteItem, Node parentNode)
|
||||
UIItemsTreeNode node = addTreeNode(entity, parentNode);
|
||||
if (parentNode == null) rootNode = node;
|
||||
|
||||
NodeComponent nodeComponent = SandboxComponentRetriever.get(entity, NodeComponent.class);
|
||||
NodeComponent nodeComponent = nodeComponentMapper.get(entity);
|
||||
MainItemComponent mainItemComponent = mainItemComponentMapper.get(entity);
|
||||
|
||||
if(nodeComponent != null) {
|
||||
for (int item : nodeComponent.children) {
|
||||
if (EntityUtils.getType(entity) == EntityFactory.COMPOSITE_TYPE) {
|
||||
if (mainItemComponent.entityType == EntityFactory.COMPOSITE_TYPE) {
|
||||
addTreeRoot(item, node);
|
||||
} else {
|
||||
addTreeNode(item, node);
|
||||
@@ -139,38 +168,36 @@ public class UIItemsTreeBox extends UICollapsibleBox {
|
||||
}
|
||||
|
||||
private UIItemsTreeNode addTreeNode(int item, UIItemsTreeNode parentNode) {
|
||||
String name, style;
|
||||
ParentNodeComponent parentNodeComponent = SandboxComponentRetriever.get(item, ParentNodeComponent.class);
|
||||
MainItemComponent mainItemComponent = SandboxComponentRetriever.get(item, MainItemComponent.class);
|
||||
String name;
|
||||
ParentNodeComponent parentNodeComponent = parentNodeComponentMapper.get(item);
|
||||
MainItemComponent mainItemComponent = mainItemComponentMapper.get(item);
|
||||
|
||||
UIItemsTreeNode node = Pools.get(UIItemsTreeNode.class, 20000).obtain();
|
||||
tmpNodes.add(node);
|
||||
|
||||
if (parentNodeComponent == null) {
|
||||
node.setColor(Color.WHITE);
|
||||
name = Sandbox.getInstance().sceneControl.getCurrentSceneVO().sceneName;
|
||||
style = "default";
|
||||
} else if (mainItemComponent.itemIdentifier != null && !mainItemComponent.itemIdentifier.isEmpty()) {
|
||||
node.setColor(Color.WHITE);
|
||||
name = mainItemComponent.itemIdentifier;
|
||||
style = "default";
|
||||
} else {
|
||||
style = "greyed";
|
||||
int type = EntityUtils.getType(item);
|
||||
name = EntityUtils.itemTypeNameMap.get(type);
|
||||
node.setColor(0.65f, 0.65f, 0.65f, 1f);
|
||||
name = EntityUtils.itemTypeNameMap.get(mainItemComponent.entityType);
|
||||
if (name == null)
|
||||
name = EntityUtils.itemTypeNameMap.get(EntityFactory.UNKNOWN_TYPE);
|
||||
}
|
||||
|
||||
VisTable label = new VisTable();
|
||||
Cell<VisLabel> lblCell = label.add(new VisLabel(name, style));
|
||||
UIItemsTreeNode node = new UIItemsTreeNode(label);
|
||||
ZIndexComponent zIndexComponent = SandboxComponentRetriever.get(item, ZIndexComponent.class);
|
||||
node.setName(name);
|
||||
ZIndexComponent zIndexComponent = zIndexComponentMapper.get(item);
|
||||
|
||||
node.setValue(new UIItemsTreeValue(mainItemComponent.uniqueId, zIndexComponent.getGlobalZIndex()));
|
||||
node.setNodeValue(mainItemComponent.uniqueId, zIndexComponent.getGlobalZIndex());
|
||||
if (mainItemComponent.entityType != EntityFactory.COMPOSITE_TYPE)
|
||||
lblCell.padBottom(4);
|
||||
else {
|
||||
lblCell.padTop(4);
|
||||
lblCell.padLeft(3);
|
||||
lblCell.padBottom(4);
|
||||
}
|
||||
node.setIcon(EntityUtils.getItemIcon(item));
|
||||
node.setPad(0, 0, 4, 0);
|
||||
else
|
||||
node.setPad(4, 3, 4, 0);
|
||||
|
||||
node.setIcon(EntityUtils.getItemIcon(mainItemComponent.entityType));
|
||||
if (parentNode != null) {
|
||||
parentNode.add(node);
|
||||
} else {
|
||||
@@ -193,7 +220,7 @@ public class UIItemsTreeBox extends UICollapsibleBox {
|
||||
lastSelection.addAll(selection);
|
||||
|
||||
if (tree == null || selection == null) return;
|
||||
Array<UIItemsTreeNode> allSceneRootNodes = tree.getNodes().get(0).getChildren();
|
||||
Array<UIItemsTreeNode> allSceneRootNodes = tree.getRootNodes().get(0).getChildren();
|
||||
|
||||
for (int entityId : EntityUtils.getEntityId(selection)) {
|
||||
for (UIItemsTreeNode n : allSceneRootNodes) {
|
||||
@@ -203,6 +230,11 @@ public class UIItemsTreeBox extends UICollapsibleBox {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tree.getSelection().size() > 0) {
|
||||
Actor firstSelected = tree.getSelection().first().getActor();
|
||||
scroller.scrollTo(0, firstSelected.getY(), firstSelected.getWidth(), firstSelected.getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFromSelection(Set<Integer> selection) {
|
||||
@@ -210,7 +242,7 @@ public class UIItemsTreeBox extends UICollapsibleBox {
|
||||
lastSelection.removeAll(selection);
|
||||
|
||||
if (tree == null || selection == null) return;
|
||||
Array<UIItemsTreeNode> allSceneRootNodes = tree.getNodes().get(0).getChildren();
|
||||
Array<UIItemsTreeNode> allSceneRootNodes = tree.getRootNodes().get(0).getChildren();
|
||||
|
||||
for (int entityId : EntityUtils.getEntityId(selection)) {
|
||||
for (UIItemsTreeNode n : allSceneRootNodes) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package games.rednblack.editor.view.ui.box;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.Selection;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import games.rednblack.editor.controller.commands.ItemsMoveCommand;
|
||||
import games.rednblack.editor.controller.commands.resource.DeleteResourceCommand;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
@@ -65,7 +66,8 @@ public class UIItemsTreeBoxMediator extends PanelMediator<UIItemsTreeBox> {
|
||||
case MsgAPI.DELETE_ITEMS_COMMAND_DONE:
|
||||
case DeleteResourceCommand.DONE:
|
||||
rootEntity = sandbox.getCurrentViewingEntity();
|
||||
viewComponent.init(rootEntity);
|
||||
if (notification.getType() == null || !notification.getType().equals(ItemsMoveCommand.TAG))
|
||||
viewComponent.update(rootEntity);
|
||||
break;
|
||||
case UIItemsTreeBox.ITEMS_SELECTED:
|
||||
Selection<UIItemsTreeNode> selection = notification.getBody();
|
||||
|
||||
@@ -1,11 +1,54 @@
|
||||
package games.rednblack.editor.view.ui.box;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Cell;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Tree;
|
||||
import com.badlogic.gdx.utils.Pool;
|
||||
import com.kotcrab.vis.ui.widget.VisLabel;
|
||||
import com.kotcrab.vis.ui.widget.VisTable;
|
||||
|
||||
public class UIItemsTreeNode extends Tree.Node<UIItemsTreeNode, UIItemsTreeValue, VisTable> {
|
||||
public class UIItemsTreeNode extends Tree.Node<UIItemsTreeNode, UIItemsTreeValue, VisTable> implements Pool.Poolable {
|
||||
VisLabel label;
|
||||
Cell<VisLabel> lblCell;
|
||||
|
||||
public UIItemsTreeNode(VisTable actor) {
|
||||
super(actor);
|
||||
public UIItemsTreeNode() {
|
||||
super(new VisTable());
|
||||
|
||||
label = new VisLabel("", "default");
|
||||
setColor(Color.WHITE);
|
||||
lblCell = getActor().add(label);
|
||||
|
||||
setValue(new UIItemsTreeValue());
|
||||
}
|
||||
|
||||
public void setNodeValue(int entityId, int zIndex) {
|
||||
getValue().setEntityId(entityId);
|
||||
getValue().setzIndex(zIndex);
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
label.setColor(color);
|
||||
}
|
||||
|
||||
public void setColor(float r, float g, float b, float a) {
|
||||
label.setColor(r, g, b, a);
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
label.setText(name);
|
||||
}
|
||||
|
||||
public void setPad(float top, float left, float bottom, float right) {
|
||||
lblCell.pad(top, left, bottom, right);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
getValue().reset();
|
||||
|
||||
setExpanded(false);
|
||||
setIcon(null);
|
||||
clearChildren();
|
||||
remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
package games.rednblack.editor.view.ui.box;
|
||||
|
||||
public class UIItemsTreeValue {
|
||||
public int entityId;
|
||||
public int zIndex;
|
||||
public int entityId = -1;
|
||||
public int zIndex = -1;
|
||||
|
||||
public UIItemsTreeValue(int id, int index) {
|
||||
entityId = id;
|
||||
zIndex = index;
|
||||
public void setEntityId(int entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
public void setzIndex(int zIndex) {
|
||||
this.zIndex = zIndex;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
entityId = -1;
|
||||
zIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user