Improve LayerMapComponent performances
This commit is contained in:
Submodule hyperlap2d-runtime-libgdx updated: 1d08837b74...7b7b18f5e4
@@ -1,5 +1,6 @@
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.kotcrab.vis.ui.util.dialog.Dialogs;
|
||||
import games.rednblack.editor.renderer.components.LayerMapComponent;
|
||||
import games.rednblack.editor.renderer.data.LayerItemVO;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
@@ -20,9 +21,20 @@ public class NewLayerCommand extends EntityModifyRevertibleCommand {
|
||||
int index = (int) payload[0];
|
||||
layerName = (String) payload[1];
|
||||
|
||||
if (layerName.isEmpty()) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
int viewingEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
LayerMapComponent layerMapComponent = SandboxComponentRetriever.get(viewingEntity, LayerMapComponent.class);
|
||||
|
||||
if (layerMapComponent.getLayer(layerName) != null) {
|
||||
cancel();
|
||||
Dialogs.showErrorDialog(Sandbox.getInstance().getUIStage(), "Layer name already exists.").padBottom(20).pack();
|
||||
return;
|
||||
}
|
||||
|
||||
LayerItemVO vo = new LayerItemVO(layerName);
|
||||
vo.isVisible = true;
|
||||
layerMapComponent.addLayer(index, vo);
|
||||
|
||||
@@ -37,7 +37,9 @@ public class RenameLayerCommand extends EntityModifyRevertibleCommand {
|
||||
String oldName = payload[0];
|
||||
String newName = payload[1];
|
||||
|
||||
if(oldName.equals(newName)) cancel();
|
||||
if(oldName.equals(newName) || newName.isEmpty()) {
|
||||
cancel();
|
||||
}
|
||||
|
||||
renameLayer(oldName, newName);
|
||||
|
||||
@@ -56,6 +58,8 @@ public class RenameLayerCommand extends EntityModifyRevertibleCommand {
|
||||
}
|
||||
|
||||
private void renameLayer(String fromName, String toName) {
|
||||
if (isCancelled) return;
|
||||
|
||||
int viewEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
NodeComponent nodeComponent = SandboxComponentRetriever.get(viewEntity, NodeComponent.class);
|
||||
LayerMapComponent layerMapComponent = SandboxComponentRetriever.get(viewEntity, LayerMapComponent.class);
|
||||
|
||||
Reference in New Issue
Block a user