Added sensor data that can be used to add to a physical body. They can be added to the bottom, left, right and top to check which side has contact with another box2d object.
This commit is contained in:
@@ -18,21 +18,83 @@
|
||||
|
||||
package games.rednblack.editor.controller;
|
||||
|
||||
import games.rednblack.editor.controller.commands.component.*;
|
||||
import games.rednblack.editor.splash.SplashScreenAdapter;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.*;
|
||||
import games.rednblack.editor.controller.commands.resource.*;
|
||||
import org.puremvc.java.interfaces.INotification;
|
||||
import org.puremvc.java.patterns.command.SimpleCommand;
|
||||
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.AddComponentToItemCommand;
|
||||
import games.rednblack.editor.controller.commands.AddSelectionCommand;
|
||||
import games.rednblack.editor.controller.commands.AddToLibraryAction;
|
||||
import games.rednblack.editor.controller.commands.AddToLibraryCommand;
|
||||
import games.rednblack.editor.controller.commands.ChangeOriginPointPosition;
|
||||
import games.rednblack.editor.controller.commands.ChangePolygonVertexPositionCommand;
|
||||
import games.rednblack.editor.controller.commands.ChangeRulerPositionCommand;
|
||||
import games.rednblack.editor.controller.commands.CompositeCameraChangeCommand;
|
||||
import games.rednblack.editor.controller.commands.ConvertToButtonCommand;
|
||||
import games.rednblack.editor.controller.commands.ConvertToCompositeCommand;
|
||||
import games.rednblack.editor.controller.commands.CopyItemsCommand;
|
||||
import games.rednblack.editor.controller.commands.CreateItemCommand;
|
||||
import games.rednblack.editor.controller.commands.CreatePrimitiveCommand;
|
||||
import games.rednblack.editor.controller.commands.CreateStickyNoteCommand;
|
||||
import games.rednblack.editor.controller.commands.CustomVariableModifyCommand;
|
||||
import games.rednblack.editor.controller.commands.CutItemsCommand;
|
||||
import games.rednblack.editor.controller.commands.DeleteItemsCommand;
|
||||
import games.rednblack.editor.controller.commands.DeleteLayerCommand;
|
||||
import games.rednblack.editor.controller.commands.DeletePolygonVertexCommand;
|
||||
import games.rednblack.editor.controller.commands.ExportProjectCommand;
|
||||
import games.rednblack.editor.controller.commands.ItemChildrenTransformCommand;
|
||||
import games.rednblack.editor.controller.commands.ItemTransformCommand;
|
||||
import games.rednblack.editor.controller.commands.ItemsMoveCommand;
|
||||
import games.rednblack.editor.controller.commands.LayerSwapCommand;
|
||||
import games.rednblack.editor.controller.commands.ModifyStickyNoteCommand;
|
||||
import games.rednblack.editor.controller.commands.NewLayerCommand;
|
||||
import games.rednblack.editor.controller.commands.PasteItemsCommand;
|
||||
import games.rednblack.editor.controller.commands.PluginItemCommand;
|
||||
import games.rednblack.editor.controller.commands.ReleaseSelectionCommand;
|
||||
import games.rednblack.editor.controller.commands.RemoveComponentFromItemCommand;
|
||||
import games.rednblack.editor.controller.commands.RemoveStickyNoteCommand;
|
||||
import games.rednblack.editor.controller.commands.RenameLayerCommand;
|
||||
import games.rednblack.editor.controller.commands.SaveExportPathCommand;
|
||||
import games.rednblack.editor.controller.commands.SetSelectionCommand;
|
||||
import games.rednblack.editor.controller.commands.ShowNotificationCommand;
|
||||
import games.rednblack.editor.controller.commands.UpdateEntityComponentsCommand;
|
||||
import games.rednblack.editor.controller.commands.UpdateSceneDataCommand;
|
||||
import games.rednblack.editor.controller.commands.component.ReplaceRegionCommand;
|
||||
import games.rednblack.editor.controller.commands.component.ReplaceSpineCommand;
|
||||
import games.rednblack.editor.controller.commands.component.ReplaceSpriteAnimationCommand;
|
||||
import games.rednblack.editor.controller.commands.component.UpdateCompositeDataCommand;
|
||||
import games.rednblack.editor.controller.commands.component.UpdateImageItemDataCommand;
|
||||
import games.rednblack.editor.controller.commands.component.UpdateLabelDataCommand;
|
||||
import games.rednblack.editor.controller.commands.component.UpdateLightBodyDataCommand;
|
||||
import games.rednblack.editor.controller.commands.component.UpdateLightDataCommand;
|
||||
import games.rednblack.editor.controller.commands.component.UpdateParticleDataCommand;
|
||||
import games.rednblack.editor.controller.commands.component.UpdatePhysicsDataCommand;
|
||||
import games.rednblack.editor.controller.commands.component.UpdatePolygonDataCommand;
|
||||
import games.rednblack.editor.controller.commands.component.UpdateSensorDataCommand;
|
||||
import games.rednblack.editor.controller.commands.component.UpdateShaderDataCommand;
|
||||
import games.rednblack.editor.controller.commands.component.UpdateSpineDataCommand;
|
||||
import games.rednblack.editor.controller.commands.component.UpdateSpriteAnimationDataCommand;
|
||||
import games.rednblack.editor.controller.commands.component.UpdateTalosDataCommand;
|
||||
import games.rednblack.editor.controller.commands.resource.DeleteImageResource;
|
||||
import games.rednblack.editor.controller.commands.resource.DeleteLibraryAction;
|
||||
import games.rednblack.editor.controller.commands.resource.DeleteLibraryItem;
|
||||
import games.rednblack.editor.controller.commands.resource.DeleteParticleEffect;
|
||||
import games.rednblack.editor.controller.commands.resource.DeleteSpineAnimation;
|
||||
import games.rednblack.editor.controller.commands.resource.DeleteSpriteAnimation;
|
||||
import games.rednblack.editor.controller.commands.resource.DeleteTalosVFX;
|
||||
import games.rednblack.editor.controller.commands.resource.DuplicateLibraryAction;
|
||||
import games.rednblack.editor.controller.commands.resource.ExportActionCommand;
|
||||
import games.rednblack.editor.controller.commands.resource.ExportLibraryItemCommand;
|
||||
import games.rednblack.editor.splash.SplashScreenAdapter;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
|
||||
/**
|
||||
* Created by azakhary on 4/28/2015.
|
||||
*/
|
||||
public class BootstrapCommand extends SimpleCommand {
|
||||
|
||||
public void execute(INotification notification) {
|
||||
@Override
|
||||
public void execute(INotification notification) {
|
||||
super.execute(notification);
|
||||
facade = HyperLap2DFacade.getInstance();
|
||||
facade.sendNotification(SplashScreenAdapter.UPDATE_SPLASH, "Loading Commands...");
|
||||
@@ -90,6 +152,7 @@ public class BootstrapCommand extends SimpleCommand {
|
||||
facade.registerCommand(MsgAPI.ACTION_UPDATE_TALOS_DATA, UpdateTalosDataCommand::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_UPDATE_BODY_LIGHT_DATA, UpdateLightBodyDataCommand::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_UPDATE_PHYSICS_BODY_DATA, UpdatePhysicsDataCommand::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_UPDATE_SENSOR_DATA, UpdateSensorDataCommand::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_UPDATE_SHADER_DATA, UpdateShaderDataCommand::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_UPDATE_IMAGE_ITEM_DATA, UpdateImageItemDataCommand::new);
|
||||
facade.registerCommand(MsgAPI.ACTION_UPDATE_SPRITE_ANIMATION_DATA, UpdateSpriteAnimationDataCommand::new);
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package games.rednblack.editor.controller.commands.component;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand;
|
||||
import games.rednblack.editor.renderer.components.physics.SensorComponent;
|
||||
import games.rednblack.editor.renderer.data.SensorDataVO;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
|
||||
/**
|
||||
* Update command for the sensor data.
|
||||
*
|
||||
* @author Jan-Thierry Wegener
|
||||
*/
|
||||
public class UpdateSensorDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
private Integer entityId;
|
||||
private SensorDataVO backup;
|
||||
|
||||
public UpdateSensorDataCommand() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
Entity entity = (Entity) payload[0];
|
||||
SensorDataVO vo = (SensorDataVO) payload[1];
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
SensorComponent sensorComponent = ComponentRetriever.get(entity, SensorComponent.class);
|
||||
|
||||
backup = new SensorDataVO();
|
||||
backup.loadFromComponent(sensorComponent);
|
||||
|
||||
sensorComponent.bottom = vo.bottom;
|
||||
sensorComponent.left = vo.left;
|
||||
sensorComponent.right = vo.right;
|
||||
sensorComponent.top = vo.top;
|
||||
|
||||
sensorComponent.scheduleRefresh();
|
||||
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
SensorComponent sensorComponent = ComponentRetriever.get(entity, SensorComponent.class);
|
||||
|
||||
sensorComponent.bottom = backup.bottom;
|
||||
sensorComponent.left = backup.left;
|
||||
sensorComponent.right = backup.right;
|
||||
sensorComponent.top = backup.top;
|
||||
|
||||
sensorComponent.scheduleRefresh();
|
||||
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
}
|
||||
|
||||
public static Object payload(Entity entity, SensorDataVO vo) {
|
||||
Object[] payload = new Object[2];
|
||||
payload[0] = entity;
|
||||
payload[1] = vo;
|
||||
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
@@ -18,18 +18,27 @@
|
||||
|
||||
package games.rednblack.editor.view.ui.box;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.puremvc.java.interfaces.IMediator;
|
||||
import org.puremvc.java.interfaces.INotification;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
import com.badlogic.gdx.utils.reflect.ReflectionException;
|
||||
import games.rednblack.editor.renderer.components.label.TypingLabelComponent;
|
||||
import games.rednblack.editor.renderer.components.light.LightBodyComponent;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.AddComponentToItemCommand;
|
||||
import games.rednblack.editor.controller.commands.RemoveComponentFromItemCommand;
|
||||
import games.rednblack.editor.renderer.components.PolygonComponent;
|
||||
import games.rednblack.editor.renderer.components.ShaderComponent;
|
||||
import games.rednblack.editor.renderer.components.label.TypingLabelComponent;
|
||||
import games.rednblack.editor.renderer.components.light.LightBodyComponent;
|
||||
import games.rednblack.editor.renderer.components.physics.PhysicsBodyComponent;
|
||||
import games.rednblack.editor.renderer.components.physics.SensorComponent;
|
||||
import games.rednblack.editor.renderer.data.SceneVO;
|
||||
import games.rednblack.editor.renderer.factory.EntityFactory;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
@@ -39,14 +48,25 @@ import games.rednblack.editor.view.stage.SandboxMediator;
|
||||
import games.rednblack.editor.view.stage.tools.TextTool;
|
||||
import games.rednblack.editor.view.ui.properties.UIAbstractProperties;
|
||||
import games.rednblack.editor.view.ui.properties.UIAbstractPropertiesMediator;
|
||||
import games.rednblack.editor.view.ui.properties.panels.*;
|
||||
import org.puremvc.java.interfaces.IMediator;
|
||||
import org.puremvc.java.interfaces.INotification;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
import games.rednblack.editor.view.ui.properties.panels.UIBasicItemPropertiesMediator;
|
||||
import games.rednblack.editor.view.ui.properties.panels.UICompositeItemPropertiesMediator;
|
||||
import games.rednblack.editor.view.ui.properties.panels.UIImageItemPropertiesMediator;
|
||||
import games.rednblack.editor.view.ui.properties.panels.UILabelItemPropertiesMediator;
|
||||
import games.rednblack.editor.view.ui.properties.panels.UILightBodyPropertiesMediator;
|
||||
import games.rednblack.editor.view.ui.properties.panels.UILightItemPropertiesMediator;
|
||||
import games.rednblack.editor.view.ui.properties.panels.UIMultipleSelectPropertiesMediator;
|
||||
import games.rednblack.editor.view.ui.properties.panels.UIParticlePropertiesMediator;
|
||||
import games.rednblack.editor.view.ui.properties.panels.UIPhysicsPropertiesMediator;
|
||||
import games.rednblack.editor.view.ui.properties.panels.UIPolygonComponentPropertiesMediator;
|
||||
import games.rednblack.editor.view.ui.properties.panels.UIScenePropertiesMediator;
|
||||
import games.rednblack.editor.view.ui.properties.panels.UISensorPropertiesMediator;
|
||||
import games.rednblack.editor.view.ui.properties.panels.UIShaderPropertiesMediator;
|
||||
import games.rednblack.editor.view.ui.properties.panels.UISpineAnimationItemPropertiesMediator;
|
||||
import games.rednblack.editor.view.ui.properties.panels.UISpriteAnimationItemPropertiesMediator;
|
||||
import games.rednblack.editor.view.ui.properties.panels.UITalosPropertiesMediator;
|
||||
import games.rednblack.editor.view.ui.properties.panels.UITextToolPropertiesMediator;
|
||||
import games.rednblack.editor.view.ui.properties.panels.UITypingLabelPropertiesMediator;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
|
||||
/**
|
||||
* Created by azakhary on 4/15/2015.
|
||||
@@ -189,6 +209,7 @@ public class UIMultiPropertyBoxMediator extends PanelMediator<UIMultiPropertyBox
|
||||
// optional panels based on components
|
||||
PolygonComponent polygonComponent = ComponentRetriever.get(entity, PolygonComponent.class);
|
||||
PhysicsBodyComponent physicsComponent = ComponentRetriever.get(entity, PhysicsBodyComponent.class);
|
||||
SensorComponent sensorComponent = ComponentRetriever.get(entity, SensorComponent.class);
|
||||
ShaderComponent shaderComponent = ComponentRetriever.get(entity, ShaderComponent.class);
|
||||
LightBodyComponent lightComponent = ComponentRetriever.get(entity, LightBodyComponent.class);
|
||||
TypingLabelComponent typingLabelComponent = ComponentRetriever.get(entity, TypingLabelComponent.class);
|
||||
@@ -199,6 +220,9 @@ public class UIMultiPropertyBoxMediator extends PanelMediator<UIMultiPropertyBox
|
||||
if (physicsComponent != null) {
|
||||
mediatorNames.add(UIPhysicsPropertiesMediator.NAME);
|
||||
}
|
||||
if (sensorComponent != null) {
|
||||
mediatorNames.add(UISensorPropertiesMediator.NAME);
|
||||
}
|
||||
if (shaderComponent != null) {
|
||||
mediatorNames.add(UIShaderPropertiesMediator.NAME);
|
||||
}
|
||||
|
||||
+22
-12
@@ -18,36 +18,44 @@
|
||||
|
||||
package games.rednblack.editor.view.ui.properties.panels;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.puremvc.java.interfaces.INotification;
|
||||
|
||||
import com.badlogic.ashley.core.Component;
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
import com.badlogic.gdx.utils.reflect.ReflectionException;
|
||||
import games.rednblack.editor.renderer.components.label.TypingLabelComponent;
|
||||
import games.rednblack.editor.renderer.components.light.LightBodyComponent;
|
||||
import games.rednblack.h2d.common.view.ui.widget.HyperLapColorPicker;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import com.kotcrab.vis.ui.widget.color.ColorPicker;
|
||||
import com.kotcrab.vis.ui.widget.color.ColorPickerAdapter;
|
||||
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.AddComponentToItemCommand;
|
||||
import games.rednblack.editor.controller.commands.AddToLibraryCommand;
|
||||
import games.rednblack.editor.renderer.components.*;
|
||||
import games.rednblack.editor.renderer.components.DimensionsComponent;
|
||||
import games.rednblack.editor.renderer.components.MainItemComponent;
|
||||
import games.rednblack.editor.renderer.components.PolygonComponent;
|
||||
import games.rednblack.editor.renderer.components.ShaderComponent;
|
||||
import games.rednblack.editor.renderer.components.TintComponent;
|
||||
import games.rednblack.editor.renderer.components.TransformComponent;
|
||||
import games.rednblack.editor.renderer.components.label.TypingLabelComponent;
|
||||
import games.rednblack.editor.renderer.components.light.LightBodyComponent;
|
||||
import games.rednblack.editor.renderer.components.physics.PhysicsBodyComponent;
|
||||
import games.rednblack.editor.renderer.components.physics.SensorComponent;
|
||||
import games.rednblack.editor.renderer.factory.EntityFactory;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.ComponentCloner;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.editor.view.ui.properties.UIItemPropertiesMediator;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.puremvc.java.interfaces.INotification;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.h2d.common.view.ui.widget.HyperLapColorPicker;
|
||||
|
||||
/**
|
||||
* Created by azakhary on 4/15/2015.
|
||||
@@ -63,6 +71,7 @@ public class UIBasicItemPropertiesMediator extends UIItemPropertiesMediator<Enti
|
||||
|
||||
public static final String POLYGON_COMPONENT_KEY = "Polygon";
|
||||
public static final String PHYSICS_COMPONENT_KEY = "Physics";
|
||||
public static final String SENSOR_COMPONENT_KEY = "Sensors";
|
||||
public static final String SHADER_COMPONENT_KEY = "Shader";
|
||||
public static final String LIGHT_COMPONENT_KEY = "Light";
|
||||
public static final String TYPING_LABEL_COMPONENT_KEY = "Typing Label";
|
||||
@@ -77,6 +86,7 @@ public class UIBasicItemPropertiesMediator extends UIItemPropertiesMediator<Enti
|
||||
public void onRegister() {
|
||||
componentClassMap.put(POLYGON_COMPONENT_KEY, PolygonComponent.class);
|
||||
componentClassMap.put(PHYSICS_COMPONENT_KEY, PhysicsBodyComponent.class);
|
||||
componentClassMap.put(SENSOR_COMPONENT_KEY, SensorComponent.class);
|
||||
componentClassMap.put(SHADER_COMPONENT_KEY, ShaderComponent.class);
|
||||
componentClassMap.put(LIGHT_COMPONENT_KEY, LightBodyComponent.class);
|
||||
componentClassMap.put(TYPING_LABEL_COMPONENT_KEY, TypingLabelComponent.class);
|
||||
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
package games.rednblack.editor.view.ui.properties.panels;
|
||||
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.kotcrab.vis.ui.widget.VisCheckBox;
|
||||
import com.kotcrab.vis.ui.widget.VisLabel;
|
||||
import com.kotcrab.vis.ui.widget.VisTable;
|
||||
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.event.CheckBoxChangeListener;
|
||||
import games.rednblack.editor.view.ui.properties.UIRemovableProperties;
|
||||
import games.rednblack.h2d.common.view.ui.StandardWidgetsFactory;
|
||||
|
||||
/**
|
||||
* The properties view for the sensors.
|
||||
*
|
||||
* @author Jan-Thierry Wegener
|
||||
*/
|
||||
public class UISensorProperties extends UIRemovableProperties {
|
||||
|
||||
public static final String prefix = "games.rednblack.editor.view.ui.properties.panels.UISensorProperties";
|
||||
public static final String CLOSE_CLICKED = prefix + ".CLOSE_CLICKED";
|
||||
|
||||
private VisCheckBox sensorBottom;
|
||||
private VisCheckBox sensorLeft;
|
||||
private VisCheckBox sensorRight;
|
||||
private VisCheckBox sensorTop;
|
||||
|
||||
public UISensorProperties() {
|
||||
super("Sensors");
|
||||
|
||||
initView();
|
||||
initListeners();
|
||||
}
|
||||
|
||||
public void initView() {
|
||||
// sensors
|
||||
sensorBottom = StandardWidgetsFactory.createCheckBox("Bottom");
|
||||
sensorLeft = StandardWidgetsFactory.createCheckBox("Left");
|
||||
sensorRight = StandardWidgetsFactory.createCheckBox("Right");
|
||||
sensorTop = StandardWidgetsFactory.createCheckBox("Top");
|
||||
|
||||
mainTable.add(new VisLabel("Add sensors to body:", Align.right)).padRight(5).colspan(3).fillX();
|
||||
mainTable.row().padTop(5);
|
||||
|
||||
// table
|
||||
VisTable sensorTable = new VisTable();
|
||||
sensorTable.add(sensorTop).padRight(5).colspan(3).fillX();
|
||||
sensorTable.row();
|
||||
sensorTable.add(sensorLeft).padRight(5);
|
||||
sensorTable.add(new VisLabel(""));
|
||||
sensorTable.add(sensorRight).padRight(5);
|
||||
sensorTable.row();
|
||||
sensorTable.add(sensorBottom).padRight(5).colspan(3).fillX();
|
||||
|
||||
mainTable.add(sensorTable).padBottom(5).colspan(4);
|
||||
mainTable.row().padTop(5);
|
||||
}
|
||||
|
||||
private void initListeners() {
|
||||
sensorBottom.addListener(new CheckBoxChangeListener(getUpdateEventName()));
|
||||
sensorLeft.addListener(new CheckBoxChangeListener(getUpdateEventName()));
|
||||
sensorRight.addListener(new CheckBoxChangeListener(getUpdateEventName()));
|
||||
sensorTop.addListener(new CheckBoxChangeListener(getUpdateEventName()));
|
||||
}
|
||||
|
||||
public VisCheckBox getSensorBottomBox() {
|
||||
return sensorBottom;
|
||||
}
|
||||
|
||||
public VisCheckBox getSensorLeftBox() {
|
||||
return sensorLeft;
|
||||
}
|
||||
|
||||
public VisCheckBox getSensorRightBox() {
|
||||
return sensorRight;
|
||||
}
|
||||
|
||||
public VisCheckBox getSensorTopBox() {
|
||||
return sensorTop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove() {
|
||||
HyperLap2DFacade.getInstance().sendNotification(CLOSE_CLICKED);
|
||||
}
|
||||
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
package games.rednblack.editor.view.ui.properties.panels;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.puremvc.java.interfaces.INotification;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.RemoveComponentFromItemCommand;
|
||||
import games.rednblack.editor.controller.commands.component.UpdateSensorDataCommand;
|
||||
import games.rednblack.editor.renderer.components.physics.SensorComponent;
|
||||
import games.rednblack.editor.renderer.data.SensorDataVO;
|
||||
import games.rednblack.editor.view.ui.properties.UIItemPropertiesMediator;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
|
||||
/**
|
||||
* The properties mediator for the sensors.
|
||||
*
|
||||
* @author Jan-Thierry Wegener
|
||||
*/
|
||||
public class UISensorPropertiesMediator extends UIItemPropertiesMediator<Entity, UISensorProperties> {
|
||||
|
||||
private static final String TAG = UISensorPropertiesMediator.class.getCanonicalName();
|
||||
public static final String NAME = TAG;
|
||||
|
||||
private SensorComponent sensorComponent;
|
||||
|
||||
public UISensorPropertiesMediator() {
|
||||
super(NAME, new UISensorProperties());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] listNotificationInterests() {
|
||||
String[] defaultNotifications = super.listNotificationInterests();
|
||||
String[] notificationInterests = new String[]{
|
||||
UISensorProperties.CLOSE_CLICKED
|
||||
};
|
||||
|
||||
return ArrayUtils.addAll(defaultNotifications, notificationInterests);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleNotification(INotification notification) {
|
||||
super.handleNotification(notification);
|
||||
|
||||
switch (notification.getName()) {
|
||||
case UISensorProperties.CLOSE_CLICKED:
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_REMOVE_COMPONENT, RemoveComponentFromItemCommand.payload(observableReference, SensorComponent.class));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void translateObservableDataToView(Entity item) {
|
||||
sensorComponent = item.getComponent(SensorComponent.class);
|
||||
|
||||
viewComponent.getSensorBottomBox().setChecked(sensorComponent.bottom);
|
||||
viewComponent.getSensorLeftBox().setChecked(sensorComponent.left);
|
||||
viewComponent.getSensorRightBox().setChecked(sensorComponent.right);
|
||||
viewComponent.getSensorTopBox().setChecked(sensorComponent.top);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void translateViewToItemData() {
|
||||
sensorComponent = observableReference.getComponent(SensorComponent.class);
|
||||
|
||||
SensorDataVO oldPayloadVo = new SensorDataVO();
|
||||
oldPayloadVo.loadFromComponent(sensorComponent);
|
||||
|
||||
SensorDataVO payloadVo = new SensorDataVO();
|
||||
|
||||
payloadVo.bottom = viewComponent.getSensorBottomBox().isChecked();
|
||||
payloadVo.left = viewComponent.getSensorLeftBox().isChecked();
|
||||
payloadVo.right = viewComponent.getSensorRightBox().isChecked();
|
||||
payloadVo.top = viewComponent.getSensorTopBox().isChecked();
|
||||
|
||||
if (!oldPayloadVo.equals(payloadVo)) {
|
||||
Object payload = UpdateSensorDataCommand.payload(observableReference, payloadVo);
|
||||
facade.sendNotification(MsgAPI.ACTION_UPDATE_SENSOR_DATA, payload);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user