diff --git a/hyperlap2d-runtime-libgdx b/hyperlap2d-runtime-libgdx index e2ac88b4..b481ffdc 160000 --- a/hyperlap2d-runtime-libgdx +++ b/hyperlap2d-runtime-libgdx @@ -1 +1 @@ -Subproject commit e2ac88b47c0703df6e1ee1b44043ee28ef963c52 +Subproject commit b481ffdcd28da6d98fea712f6a3eb40057acbfdb diff --git a/src/main/java/games/rednblack/editor/view/HyperLap2DScreenMediator.java b/src/main/java/games/rednblack/editor/view/HyperLap2DScreenMediator.java index 162f2c30..e20eccc9 100644 --- a/src/main/java/games/rednblack/editor/view/HyperLap2DScreenMediator.java +++ b/src/main/java/games/rednblack/editor/view/HyperLap2DScreenMediator.java @@ -80,7 +80,7 @@ public class HyperLap2DScreenMediator extends Mediator { facade = HyperLap2DFacade.getInstance(); sandboxMediator = facade.retrieveMediator(SandboxMediator.NAME); engine = sandboxMediator.getViewComponent().getEngine(); - SandboxBackUI sandboxBackUI = new SandboxBackUI(engine.getSystem(HyperLap2dRenderer.class).batch); + SandboxBackUI sandboxBackUI = new SandboxBackUI(engine.getSystem(HyperLap2dRenderer.class).getBatch()); getViewComponent().setBackUI(sandboxBackUI); getViewComponent().disableDrawingBgLogo(); break; diff --git a/src/main/java/games/rednblack/editor/view/ui/RulersUI.java b/src/main/java/games/rednblack/editor/view/ui/RulersUI.java index cde4681b..9fb5bc11 100644 --- a/src/main/java/games/rednblack/editor/view/ui/RulersUI.java +++ b/src/main/java/games/rednblack/editor/view/ui/RulersUI.java @@ -1,12 +1,8 @@ package games.rednblack.editor.view.ui; -import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.graphics.Color; -import com.badlogic.gdx.graphics.GL20; -import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.g2d.Batch; -import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.math.Circle; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; @@ -19,6 +15,8 @@ import com.kotcrab.vis.ui.widget.VisLabel; import games.rednblack.editor.HyperLap2DFacade; import games.rednblack.editor.utils.Guide; import games.rednblack.editor.view.stage.Sandbox; +import games.rednblack.editor.view.ui.widget.actors.basic.WhitePixel; +import space.earlygrey.shapedrawer.ShapeDrawer; import java.util.HashMap; @@ -47,7 +45,7 @@ public class RulersUI extends Actor { //Allows the ChangeRulerXPositionCommand to change the guide's position from the function UpdateGuideManully private static Guide editableDraggingGuide = null; - private final ShapeRenderer shapeRenderer; + private ShapeDrawer shapeDrawer; private final Rectangle horizontalRect, verticalRect; @@ -78,8 +76,6 @@ public class RulersUI extends Actor { private final HashMap labelTextCache = new HashMap<>(); public RulersUI() { - shapeRenderer = new ShapeRenderer(); - horizontalRect = new Rectangle(); verticalRect = new Rectangle(); @@ -102,7 +98,7 @@ public class RulersUI extends Actor { Circle touchCircle = tmpCircle; touchCircle.radius = 5; - touchCircle.setPosition(x - getStage().getWidth() / 2f, y - getStage().getHeight() / 2f); + touchCircle.setPosition(x, y); isTouchingDownRuler = false; if (verticalRect.contains(touchCircle.x, touchCircle.y)) { @@ -137,7 +133,7 @@ public class RulersUI extends Actor { //Changes the dragging guide's position to the world position if (draggingGuide != null) { - Vector2 worldCoords = hereToWorld(tmp.set(x - getStage().getWidth() / 2f, y - getStage().getHeight() / 2f)); + Vector2 worldCoords = hereToWorld(tmp.set(x, y)); if (draggingGuide.isVertical) { draggingGuide.pos = worldCoords.x; if (!isShowingPixels) @@ -161,8 +157,8 @@ public class RulersUI extends Actor { } if (draggingGuide != null) { - if ((draggingGuide.isVertical && x - getStage().getWidth() / 2f < verticalRect.x + verticalRect.getWidth()) || - (!draggingGuide.isVertical && y - getStage().getHeight() / 2f > horizontalRect.y)) { + if ((draggingGuide.isVertical && x < verticalRect.x + verticalRect.getWidth()) || + (!draggingGuide.isVertical && y > horizontalRect.y)) { guides.removeValue(draggingGuide, true); } else { if (button == Input.Buttons.RIGHT) { @@ -190,8 +186,8 @@ public class RulersUI extends Actor { super.act(delta); - horizontalRect.set(-getStage().getWidth() / 2f + leftOffset, getStage().getHeight() / 2f - rulerBoxSize - topOffset, getStage().getWidth() - leftOffset, rulerBoxSize); - verticalRect.set(-getStage().getWidth() / 2f + leftOffset, -getStage().getHeight() / 2f, rulerBoxSize, getStage().getHeight() - topOffset); + horizontalRect.set(leftOffset, getStage().getHeight() - rulerBoxSize - topOffset, getStage().getWidth() - leftOffset, rulerBoxSize); + verticalRect.set(leftOffset, 0, rulerBoxSize, getStage().getHeight() - topOffset); //calculating sizes viewMeasurableWidth = Sandbox.getInstance().getViewport().getWorldWidth() * Sandbox.getInstance().getCamera().zoom; @@ -223,15 +219,11 @@ public class RulersUI extends Actor { private Vector2 worldToHere(Vector2 tmp) { tmp = Sandbox.getInstance().worldToScreen(tmp); - tmp.x -= getStage().getWidth() / 2f; - tmp.y -= getStage().getHeight() / 2f; return tmp; } private Vector2 hereToWorld(Vector2 tmp) { - tmp.x += getStage().getWidth() / 2f; - tmp.y += getStage().getHeight() / 2f; tmp = Sandbox.getInstance().screenToWorld(tmp); return tmp; @@ -239,15 +231,15 @@ public class RulersUI extends Actor { @Override public void draw(Batch batch, float parentAlpha) { - batch.end(); - - OrthographicCamera uiCamera = (OrthographicCamera) getStage().getCamera(); - - Gdx.gl.glLineWidth(1.0f); - Gdx.gl.glEnable(GL20.GL_BLEND); - Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); - - shapeRenderer.setProjectionMatrix(uiCamera.projection); + if (shapeDrawer == null) { + shapeDrawer = new ShapeDrawer(batch, WhitePixel.sharedInstance.textureRegion){ + /* OPTIONAL: Ensuring a certain smoothness. */ + @Override + protected int estimateSidesRequired(float radiusX, float radiusY) { + return 200; + } + }; + } try { drawShapes(parentAlpha); @@ -255,10 +247,6 @@ public class RulersUI extends Actor { e.printStackTrace(); } - Gdx.gl.glDisable(GL20.GL_BLEND); - batch.begin(); - batch.setColor(Color.WHITE); - try { drawBatch(batch, parentAlpha); } catch (Exception e) { @@ -272,29 +260,23 @@ public class RulersUI extends Actor { } public void drawBg(float parentAlpha) { - shapeRenderer.begin(ShapeRenderer.ShapeType.Filled); - tmpColor.set(BG_COLOR); tmpColor.a *= parentAlpha; - shapeRenderer.setColor(tmpColor); - shapeRenderer.rect(horizontalRect.x, horizontalRect.y, horizontalRect.width, horizontalRect.height); - shapeRenderer.rect(verticalRect.x, verticalRect.y, verticalRect.width, verticalRect.height); - - shapeRenderer.end(); + shapeDrawer.setColor(tmpColor); + shapeDrawer.filledRectangle(horizontalRect.x, horizontalRect.y, horizontalRect.width, horizontalRect.height); + shapeDrawer.filledRectangle(verticalRect.x, verticalRect.y, verticalRect.width, verticalRect.height); } public void drawLines(float parentAlpha) { - shapeRenderer.begin(ShapeRenderer.ShapeType.Line); - tmpColor.set(LINE_COLOR); tmpColor.a *= parentAlpha; - shapeRenderer.setColor(tmpColor); + shapeDrawer.setColor(tmpColor); // Static Lines for Aesthetics - shapeRenderer.line(horizontalRect.x + rulerBoxSize, horizontalRect.y, horizontalRect.x + horizontalRect.width, horizontalRect.y); - shapeRenderer.line(verticalRect.x + verticalRect.width + 1, verticalRect.y, verticalRect.x + verticalRect.width + 1, verticalRect.y + verticalRect.height - rulerBoxSize); + shapeDrawer.line(horizontalRect.x + rulerBoxSize, horizontalRect.y, horizontalRect.x + horizontalRect.width, horizontalRect.y, 1f); + shapeDrawer.line(verticalRect.x + verticalRect.width + 1, verticalRect.y, verticalRect.x + verticalRect.width + 1, verticalRect.y + verticalRect.height - rulerBoxSize, 1f); //Functional lines to show grid Vector2 startPoint = tmp1.set(horizontalRect.x + rulerBoxSize, verticalRect.y); @@ -304,8 +286,6 @@ public class RulersUI extends Actor { Vector2 worldStartPointCpy = tmp2.set(worldStartPoint); Vector2 gridCurrPoint = worldToHere(worldStartPoint); - labels.clear(); - String postFix = ""; if (isShowingPixels) { postFix = "px"; @@ -316,13 +296,14 @@ public class RulersUI extends Actor { float gridSize = gridMeasuringSize * gridMeasureToDisplayScale; int iterator = 0; while (gridCurrPoint.x < horizontalRect.x + horizontalRect.getWidth()) { - shapeRenderer.line(gridCurrPoint.x, horizontalRect.y, gridCurrPoint.x, horizontalRect.y + rulerBoxSize); - shapeRenderer.line(gridCurrPoint.x + gridSize / 2, horizontalRect.y, gridCurrPoint.x + gridSize / 2, horizontalRect.y + rulerBoxSize / 2f); + shapeDrawer.line(gridCurrPoint.x, horizontalRect.y, gridCurrPoint.x, horizontalRect.y + rulerBoxSize, 1f); + shapeDrawer.line(gridCurrPoint.x + gridSize / 2, horizontalRect.y, gridCurrPoint.x + gridSize / 2, horizontalRect.y + rulerBoxSize / 2f, 1f); VisLabel label = Pools.obtain(VisLabel.class); - label.setPosition(getStage().getWidth() / 2f + gridCurrPoint.x + 2, getStage().getHeight() / 2f + horizontalRect.y + 7); + label.setPosition(gridCurrPoint.x + 2, horizontalRect.y + 7); label.setColor(TEXT_COLOR); label.setText((int) Math.abs(worldStartPointCpy.x + iterator * gridMeasuringSize) + postFix); + label.setWrap(false); labels.add(label); gridCurrPoint.x += gridSize; @@ -330,8 +311,8 @@ public class RulersUI extends Actor { } iterator = 0; while (gridCurrPoint.y < verticalRect.y + verticalRect.getHeight()) { - shapeRenderer.line(verticalRect.x + verticalRect.getWidth(), gridCurrPoint.y, verticalRect.x + verticalRect.getWidth() - rulerBoxSize, gridCurrPoint.y); - shapeRenderer.line(verticalRect.x + verticalRect.getWidth(), gridCurrPoint.y + gridSize / 2, verticalRect.x + verticalRect.getWidth() - rulerBoxSize / 2f, gridCurrPoint.y + gridSize / 2); + shapeDrawer.line(verticalRect.x + verticalRect.getWidth(), gridCurrPoint.y, verticalRect.x + verticalRect.getWidth() - rulerBoxSize, gridCurrPoint.y, 1f); + shapeDrawer.line(verticalRect.x + verticalRect.getWidth(), gridCurrPoint.y + gridSize / 2, verticalRect.x + verticalRect.getWidth() - rulerBoxSize / 2f, gridCurrPoint.y + gridSize / 2, 1f); VisLabel label = Pools.obtain(VisLabel.class); label.setColor(TEXT_COLOR); @@ -345,37 +326,38 @@ public class RulersUI extends Actor { label.setText(lblText); label.setWrap(true); - label.setPosition(getStage().getWidth() / 2f + verticalRect.x + 3, getStage().getHeight() / 2f + gridCurrPoint.y - label.getPrefHeight() / 2); + label.setPosition(verticalRect.x + 3, gridCurrPoint.y - label.getPrefHeight() / 2); labels.add(label); gridCurrPoint.y += gridSize; iterator++; } - drawGuides(); - - shapeRenderer.end(); + drawGuides(parentAlpha); } - public void drawGuides() { + public void drawGuides(float parentAlpha) { for (int i = 0; i < guides.size; i++) { Guide guide = guides.get(i); if (mouseOverGuide == guide) { - shapeRenderer.setColor(OVER_GUIDE_COLOR); + tmpColor.set(OVER_GUIDE_COLOR); } else { - shapeRenderer.setColor(GUIDE_COLOR); + tmpColor.set(GUIDE_COLOR); } + tmpColor.a *= parentAlpha; + shapeDrawer.setColor(tmpColor); + if (guide.isVertical) { Vector2 localCoords = worldToHere(tmp1.set(guide.pos, 0)); if (localCoords.x > verticalRect.x + verticalRect.width) { - shapeRenderer.line(localCoords.x, -getStage().getHeight() / 2f, localCoords.x, horizontalRect.y); + shapeDrawer.line(localCoords.x, 0, localCoords.x, horizontalRect.y, 1f); } } else { Vector2 localCoords = worldToHere(tmp1.set(0, guide.pos)); if (localCoords.y < horizontalRect.y) { - shapeRenderer.line(verticalRect.x + verticalRect.getWidth(), localCoords.y, getStage().getWidth(), localCoords.y); + shapeDrawer.line(verticalRect.x + verticalRect.getWidth(), localCoords.y, getStage().getWidth(), localCoords.y, 1f); } } } @@ -386,6 +368,7 @@ public class RulersUI extends Actor { labels.get(i).draw(batch, parentAlpha); Pools.free(labels.get(i)); } + labels.clear(); if (draggingGuide != null) { float pos = draggingGuide.pos; @@ -427,7 +410,7 @@ public class RulersUI extends Actor { @Override public Actor hit(float x, float y, boolean touchable) { - if (verticalRect.contains(x - getStage().getWidth() / 2f, y - getStage().getHeight() / 2f) || horizontalRect.contains(x - getStage().getWidth() / 2f, y - getStage().getHeight() / 2f)) { + if (verticalRect.contains(x, y) || horizontalRect.contains(x, y)) { return this; } @@ -440,7 +423,7 @@ public class RulersUI extends Actor { } public Guide guideCollision(float x, float y) { - Vector2 point = tmp1.set(x - getStage().getWidth() / 2f, y - getStage().getHeight() / 2f); + Vector2 point = tmp1.set(x, y); point = hereToWorld(point); Circle touchCircle = tmpCircle; diff --git a/src/main/java/games/rednblack/editor/view/ui/dialog/AtlasesPackDialog.java b/src/main/java/games/rednblack/editor/view/ui/dialog/AtlasesPackDialog.java index da59ee8b..aff2c5af 100644 --- a/src/main/java/games/rednblack/editor/view/ui/dialog/AtlasesPackDialog.java +++ b/src/main/java/games/rednblack/editor/view/ui/dialog/AtlasesPackDialog.java @@ -154,8 +154,7 @@ public class AtlasesPackDialog extends H2DDialog { opTable.add().width(80); currentSelectedPackLabel = new VisLabel("Select Pack", Align.center); opTable.add(currentSelectedPackLabel).uniformX().growX().row(); - NinePatchDrawable bg = new NinePatchDrawable((NinePatchDrawable) VisUI.getSkin().getDrawable("sticky-note")); - bg.getPatch().setColor(Color.DARK_GRAY); + NinePatchDrawable bg = ((NinePatchDrawable) VisUI.getSkin().getDrawable("sticky-note")).tint(Color.DARK_GRAY); mainPackList.getMainTable().background(bg); opTable.add(mainPackList.getMainTable()).uniformX().grow(); opTable.add(opButtonsContainer).growY(); diff --git a/src/main/java/games/rednblack/editor/view/ui/widget/actors/GridView.java b/src/main/java/games/rednblack/editor/view/ui/widget/actors/GridView.java index 050d84c3..ea431c13 100644 --- a/src/main/java/games/rednblack/editor/view/ui/widget/actors/GridView.java +++ b/src/main/java/games/rednblack/editor/view/ui/widget/actors/GridView.java @@ -18,138 +18,128 @@ package games.rednblack.editor.view.ui.widget.actors; -import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; -import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.g2d.Batch; -import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.utils.Array; import com.kotcrab.vis.ui.widget.VisLabel; import games.rednblack.editor.view.stage.Sandbox; +import space.earlygrey.shapedrawer.ShapeDrawer; public class GridView extends Actor { - private Array lines = new Array<>(); - private ShapeRenderer shapeRenderer; + private final Array lines = new Array<>(); + private final ShapeDrawer shapeDrawer; - private Label zeroLabel; + private final Label zeroLabel; - private int pixelsPerWU = 1; + private int pixelsPerWU = 1; - private int gridSize; - int gridLinesCount; + private int gridSize; + int gridLinesCount; - private final Color tmpColor = new Color(); + private final Color tmpColor = new Color(); - public GridView() { - gridSize = 50; - gridLinesCount = 40; + public GridView(ShapeDrawer shapeDrawer) { + this.shapeDrawer = shapeDrawer; + gridSize = 50; + gridLinesCount = 40; - pixelsPerWU = Sandbox.getInstance().getPixelPerWU(); - shapeRenderer = new ShapeRenderer(); + pixelsPerWU = Sandbox.getInstance().getPixelPerWU(); - for(int i = 0; i = gridLinesCount) { + i -= gridLinesCount; + offsetTmp = ((runtimeCamera.position.y * pixelsPerWU) / runtimeCamera.zoom) / gridSize; + } - OrthographicCamera runtimeCamera = Sandbox.getInstance().getCamera(); - float offsetX = (runtimeCamera.position.x*pixelsPerWU)/runtimeCamera.zoom % gridSize; - float offsetY = (runtimeCamera.position.y*pixelsPerWU)/runtimeCamera.zoom % gridSize; + // offset + int offset = 0; + if (offsetTmp > 0) offset = (int) Math.floor(offsetTmp); + if (offsetTmp < 0) offset = (int) -Math.floor(-offsetTmp); + i += offset; - for(int i = 0; i < lines.size; i++) { - shapeRenderer.setColor(getLineColor(i)); - shapeRenderer.line(lines.get(i).start.x - offsetX, lines.get(i).start.y-offsetY, lines.get(i).end.x-offsetX, lines.get(i).end.y-offsetY); - } + Color color = tmpColor.set(Color.WHITE); - shapeRenderer.end(); - } - - private Color getLineColor(int i) { - OrthographicCamera runtimeCamera = Sandbox.getInstance().getCamera(); + if ((gridLinesCount / 2 - i - 1) % 4 == 0) { + color.a = 0.1f; + } else if ((gridLinesCount / 2 - i - 1) % 2 == 0) { + color.a = 0.05f; + } else { + color.a = 0.02f; + } - float offsetTmp = ((runtimeCamera.position.x*pixelsPerWU)/runtimeCamera.zoom) / gridSize; - if(i >= gridLinesCount) { - i-= gridLinesCount; - offsetTmp = ((runtimeCamera.position.y*pixelsPerWU)/runtimeCamera.zoom) / gridSize; - } + return color; + } - // offset - int offset = 0; - if(offsetTmp > 0) offset = (int) Math.floor(offsetTmp); - if(offsetTmp < 0) offset = (int) -Math.floor(-offsetTmp); - i += offset; + public static class Segment { + public Vector2 start; + public Vector2 end; - Color color = tmpColor.set(Color.WHITE); + public Segment(float startX, float startY, float endX, float endY) { + start = new Vector2(startX, startY); + end = new Vector2(endX, endY); + } - if((gridLinesCount/2 - i - 1) % 4 == 0) { - color.a = 0.1f; - } else if((gridLinesCount/2 - i - 1) % 2 == 0) { - color.a = 0.05f; - } else { - color.a = 0.02f; - } - - return color; - } - - public class Segment { - public Vector2 start; - public Vector2 end; - - public Segment(float startX, float startY, float endX, float endY) { - start = new Vector2(startX, startY); - end = new Vector2(endX, endY); - } - - public Segment(Vector2 start, Vector2 end) { - this.start = start; - this.end = end; - } - } + public Segment(Vector2 start, Vector2 end) { + this.start = start; + this.end = end; + } + } } diff --git a/src/main/java/games/rednblack/editor/view/ui/widget/actors/StaticGrid.java b/src/main/java/games/rednblack/editor/view/ui/widget/actors/StaticGrid.java index d555dae2..56d23319 100644 --- a/src/main/java/games/rednblack/editor/view/ui/widget/actors/StaticGrid.java +++ b/src/main/java/games/rednblack/editor/view/ui/widget/actors/StaticGrid.java @@ -1,12 +1,11 @@ package games.rednblack.editor.view.ui.widget.actors; -import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.g2d.Batch; -import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.ui.Window; +import games.rednblack.editor.view.ui.widget.actors.basic.WhitePixel; +import space.earlygrey.shapedrawer.ShapeDrawer; public class StaticGrid extends Actor { @@ -14,44 +13,40 @@ public class StaticGrid extends Actor { private final Vector2 tmp = new Vector2(); - private ShapeRenderer shapeRenderer; + private ShapeDrawer shapeDrawer; public StaticGrid(Window window) { this.window = window; - shapeRenderer = new ShapeRenderer(); } @Override public void draw (Batch batch, float parentAlpha) { - super.draw(batch, parentAlpha); - batch.end(); + if (shapeDrawer == null) { + shapeDrawer = new ShapeDrawer(batch, WhitePixel.sharedInstance.textureRegion){ + /* OPTIONAL: Ensuring a certain smoothness. */ + @Override + protected int estimateSidesRequired(float radiusX, float radiusY) { + return 200; + } + }; + } - Gdx.gl.glEnable(GL20.GL_BLEND); - Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); - - shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix()); - - shapeRenderer.begin(ShapeRenderer.ShapeType.Filled); drawGrid(window.getX(), window.getY(), window.getWidth(), window.getHeight(), parentAlpha); - shapeRenderer.end(); - - Gdx.gl.glDisable(GL20.GL_BLEND); - batch.begin(); } private void drawGrid (float x, float y, float windowWidth, float windowHeight, float parentAlpha) { - tmp.set(x + windowWidth / 2, y + windowHeight / 2); + tmp.set(windowWidth / 2, windowHeight / 2); int lineCount = (int)(windowWidth / 28f); for (int i = -lineCount / 2 - 1; i < lineCount / 2 + 1; i++) { float spacing = windowWidth / lineCount; - shapeRenderer.setColor(0.2f, 0.2f, 0.2f, parentAlpha); + shapeDrawer.setColor(0.2f, 0.2f, 0.2f, parentAlpha); float posX = tmp.x - i * spacing - tmp.x % spacing; float posY = tmp.y + i * spacing - tmp.y % spacing; - shapeRenderer.rectLine(posX, tmp.y - windowHeight/2f, posX, tmp.y + windowHeight/2f, 2f); // vertical - shapeRenderer.rectLine(tmp.x - windowWidth/2f, posY, tmp.x + windowWidth/2f, posY, 2f); // horizontal + shapeDrawer.line(posX, tmp.y - windowHeight/2f, posX, tmp.y + windowHeight/2f, 2f); // vertical + shapeDrawer.line(tmp.x - windowWidth/2f, posY, tmp.x + windowWidth/2f, posY, 2f); // horizontal } } } diff --git a/src/main/java/games/rednblack/editor/view/ui/widget/actors/basic/SandboxBackUI.java b/src/main/java/games/rednblack/editor/view/ui/widget/actors/basic/SandboxBackUI.java index fb96afe7..f8b13f90 100644 --- a/src/main/java/games/rednblack/editor/view/ui/widget/actors/basic/SandboxBackUI.java +++ b/src/main/java/games/rednblack/editor/view/ui/widget/actors/basic/SandboxBackUI.java @@ -25,20 +25,21 @@ import com.badlogic.gdx.utils.Array; import games.rednblack.editor.HyperLap2DFacade; import games.rednblack.editor.proxy.ResourceManager; import games.rednblack.editor.view.ui.widget.actors.GridView; +import space.earlygrey.shapedrawer.ShapeDrawer; /** * Created by azakhary on 6/10/2015. */ public class SandboxBackUI { - private Array actors = new Array<>(); - - private Batch batch; + private final Array actors = new Array<>(); + private final Batch batch; public SandboxBackUI(Batch batch) { this.batch = batch; + ShapeDrawer shapeDrawer = new ShapeDrawer(batch, WhitePixel.sharedInstance.textureRegion); - GridView gridView = new GridView(); + GridView gridView = new GridView(shapeDrawer); addActor(gridView); } @@ -50,7 +51,7 @@ public class SandboxBackUI { ResourceManager resourceManager = HyperLap2DFacade.getInstance().retrieveProxy(ResourceManager.NAME); batch.begin(); for (Actor actor : actors) { - actor.setScale(1f/resourceManager.getProjectVO().pixelToWorld); + actor.setScale(1f / resourceManager.getProjectVO().pixelToWorld); actor.act(delta); actor.draw(batch, 1); }