[editor only] Add manual camera pan control
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
- Sensor component custom width/height
|
||||
- Improve physics bodies bounding boxes (disabled by default)
|
||||
- Enable/disable bounding boxes debug view
|
||||
- Improved layers drag and drop
|
||||
- Add manual camera pan control
|
||||
- Bug fixing and stability improvements
|
||||
|
||||
**Runtime**
|
||||
|
||||
@@ -51,6 +51,7 @@ public class BootstrapViewCommand extends SimpleCommand {
|
||||
facade.registerMediator(new UIGridBoxMediator());
|
||||
facade.registerMediator(new UIResolutionBoxMediator());
|
||||
facade.registerMediator(new UIZoomBoxMediator());
|
||||
facade.registerMediator(new UIPanBoxMediator());
|
||||
facade.registerMediator(new UIToolBoxMediator());
|
||||
facade.registerMediator(new UILivePreviewBoxMediator());
|
||||
|
||||
|
||||
@@ -353,6 +353,10 @@ public class Sandbox {
|
||||
return (int) sceneConfigVO.cameraZoom;
|
||||
}
|
||||
|
||||
public Vector3 getCameraPosition() {
|
||||
return getCamera().position;
|
||||
}
|
||||
|
||||
public void setZoomPercent(float percent, boolean moveCamera) {
|
||||
sceneConfigVO.cameraZoom = percent;
|
||||
|
||||
|
||||
@@ -36,6 +36,11 @@ public class UIBottomMenuBar extends VisTable {
|
||||
UIZoomBox uiZoomBox = uiZoomBoxMediator.getViewComponent();
|
||||
mainGroup.add(uiZoomBox);
|
||||
|
||||
//pan
|
||||
UIPanBoxMediator uiPanBoxMediator = facade.retrieveMediator(UIPanBoxMediator.NAME);
|
||||
UIPanBox uiPanBox = uiPanBoxMediator.getViewComponent();
|
||||
mainGroup.add(uiPanBox);
|
||||
|
||||
//resolution box
|
||||
UIResolutionBoxMediator uiResolutionBoxMediator = facade.retrieveMediator(UIResolutionBoxMediator.NAME);
|
||||
UIResolutionBox uiResolutionBox = uiResolutionBoxMediator.getViewComponent();
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package games.rednblack.editor.view.ui.box.bottom;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.kotcrab.vis.ui.VisUI;
|
||||
import com.kotcrab.vis.ui.widget.VisTextField;
|
||||
import games.rednblack.editor.event.KeyboardListener;
|
||||
import games.rednblack.editor.utils.RoundUtils;
|
||||
import games.rednblack.editor.view.ui.box.UIBaseBox;
|
||||
import games.rednblack.h2d.common.view.ui.StandardWidgetsFactory;
|
||||
|
||||
public class UIPanBox extends UIBaseBox {
|
||||
|
||||
private static final String prefix = "games.rednblack.editor.view.ui.box.bottom.UIPanBox";
|
||||
public static final String PAN_VALUE_CHANGED = prefix + ".PAN_VALUE_CHANGED";
|
||||
|
||||
private final Skin skin;
|
||||
|
||||
private VisTextField xCoordField;
|
||||
private VisTextField yCoordField;
|
||||
|
||||
public UIPanBox() {
|
||||
skin = VisUI.getSkin();
|
||||
init();
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
addSeparator(true).padRight(13).padLeft(13);
|
||||
add("Pan:").padRight(4);
|
||||
|
||||
xCoordField = StandardWidgetsFactory.createTextField("light");
|
||||
xCoordField.addListener(new KeyboardListener(PAN_VALUE_CHANGED));
|
||||
xCoordField.setAlignment(Align.center);
|
||||
add(xCoordField).width(70);
|
||||
|
||||
yCoordField = StandardWidgetsFactory.createTextField("light");
|
||||
yCoordField.addListener(new KeyboardListener(PAN_VALUE_CHANGED));
|
||||
yCoordField.setAlignment(Align.center);
|
||||
add(yCoordField).padLeft(5).width(70);
|
||||
}
|
||||
|
||||
public void setCameraCoordinates(float x, float y) {
|
||||
xCoordField.setText(String.valueOf(RoundUtils.round(x, 1)));
|
||||
yCoordField.setText(String.valueOf(RoundUtils.round(y, 1)));
|
||||
}
|
||||
|
||||
public float getCameraX() {
|
||||
return Float.parseFloat(xCoordField.getText());
|
||||
}
|
||||
|
||||
public float getCameraY() {
|
||||
return Float.parseFloat(yCoordField.getText());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package games.rednblack.editor.view.ui.box.bottom;
|
||||
|
||||
import games.rednblack.editor.proxy.ProjectManager;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.editor.view.stage.tools.PanTool;
|
||||
import games.rednblack.puremvc.Mediator;
|
||||
import games.rednblack.puremvc.interfaces.INotification;
|
||||
import games.rednblack.puremvc.util.Interests;
|
||||
|
||||
public class UIPanBoxMediator extends Mediator<UIPanBox> {
|
||||
private static final String TAG = UIPanBoxMediator.class.getCanonicalName();
|
||||
public static final String NAME = TAG;
|
||||
|
||||
public UIPanBoxMediator() {
|
||||
super(NAME, new UIPanBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listNotificationInterests(Interests interests) {
|
||||
interests.add(ProjectManager.PROJECT_OPENED, PanTool.SCENE_PANNED, UIPanBox.PAN_VALUE_CHANGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleNotification(INotification notification) {
|
||||
super.handleNotification(notification);
|
||||
Sandbox sandbox = Sandbox.getInstance();
|
||||
switch (notification.getName()) {
|
||||
case ProjectManager.PROJECT_OPENED:
|
||||
viewComponent.update();
|
||||
viewComponent.setCameraCoordinates(sandbox.getCameraPosition().x, sandbox.getCameraPosition().y);
|
||||
break;
|
||||
case PanTool.SCENE_PANNED:
|
||||
viewComponent.setCameraCoordinates(sandbox.getCameraPosition().x, sandbox.getCameraPosition().y);
|
||||
break;
|
||||
case UIPanBox.PAN_VALUE_CHANGED:
|
||||
sandbox.panSceneTo(viewComponent.getCameraX(), viewComponent.getCameraY());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,8 +37,8 @@ public class UIZoomBox extends UIBaseBox {
|
||||
|
||||
private static final String prefix = "games.rednblack.editor.view.ui.box.bottom.UIZoomBox";
|
||||
|
||||
public static final String ZOOM_SHIFT_REQUESTED = prefix + "ZOOM_SHIFT_REQUESTED";
|
||||
public static final String ZOOM_VALUE_CHANGED = prefix + "ZOOM_VALUE_CHANGED";
|
||||
public static final String ZOOM_SHIFT_REQUESTED = prefix + ".ZOOM_SHIFT_REQUESTED";
|
||||
public static final String ZOOM_VALUE_CHANGED = prefix + ".ZOOM_VALUE_CHANGED";
|
||||
|
||||
private final Skin skin;
|
||||
private VisTextField percentValueField;
|
||||
|
||||
Reference in New Issue
Block a user