Added Graphics.begin/endClip()
This commit is contained in:
@@ -9,7 +9,6 @@ import com.badlogic.gdx.math.Bresenham2;
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ScissorStack;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.editor.DrawOperation.TileOperation;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
@@ -270,8 +269,7 @@ public class MapView extends Element implements GestureListener{
|
||||
|
||||
image.setImageSize(editor.getMap().width(), editor.getMap().height());
|
||||
|
||||
batch.flush();
|
||||
boolean pop = ScissorStack.pushScissors(rect.set(x, y, width, height));
|
||||
Graphics.beginClip(x, y, width, height);
|
||||
|
||||
Draw.color(Color.LIGHT_GRAY);
|
||||
Lines.stroke(-2f);
|
||||
@@ -327,9 +325,7 @@ public class MapView extends Element implements GestureListener{
|
||||
}
|
||||
}
|
||||
|
||||
batch.flush();
|
||||
|
||||
if(pop) ScissorStack.popScissors();
|
||||
Graphics.endClip();
|
||||
|
||||
Draw.color(Palette.accent);
|
||||
Lines.stroke(Unit.dp.scl(3f));
|
||||
|
||||
@@ -20,7 +20,6 @@ import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.entities.EntityDraw;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Fill;
|
||||
import io.anuke.ucore.scene.utils.ScissorStack;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@@ -140,9 +139,7 @@ public class FogRenderer implements Disposable{
|
||||
|
||||
buffer.begin();
|
||||
|
||||
boolean pop = ScissorStack.pushScissors(rect.set((padding-shadowPadding), (padding-shadowPadding),
|
||||
(world.width() + shadowPadding*2) ,
|
||||
(world.height() + shadowPadding*2)));
|
||||
Graphics.beginClip((padding-shadowPadding), (padding-shadowPadding), (world.width() + shadowPadding*2), (world.height() + shadowPadding*2));
|
||||
|
||||
Graphics.begin();
|
||||
EntityDraw.setClip(false);
|
||||
@@ -172,7 +169,7 @@ public class FogRenderer implements Disposable{
|
||||
Graphics.end();
|
||||
buffer.end();
|
||||
|
||||
if(pop) ScissorStack.popScissors();
|
||||
Graphics.endClip();
|
||||
|
||||
region.setTexture(buffer.getColorBufferTexture());
|
||||
region.setRegion(u, v2, u2, v);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.anuke.mindustry.graphics;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
@@ -20,7 +19,6 @@ import io.anuke.ucore.core.Events;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Pixmaps;
|
||||
import io.anuke.ucore.scene.utils.ScissorStack;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.ThreadArray;
|
||||
|
||||
@@ -34,8 +32,6 @@ public class MinimapRenderer implements Disposable{
|
||||
private Texture texture;
|
||||
private TextureRegion region;
|
||||
private Rectangle rect = new Rectangle();
|
||||
private Rectangle clipRect = new Rectangle();
|
||||
private Color tmpColor = new Color();
|
||||
private int zoom = 4;
|
||||
|
||||
public MinimapRenderer(){
|
||||
@@ -80,9 +76,7 @@ public class MinimapRenderer implements Disposable{
|
||||
|
||||
synchronized(units){
|
||||
rect.set((dx - sz) * tilesize, (dy - sz) * tilesize, sz * 2 * tilesize, sz * 2 * tilesize);
|
||||
Graphics.flush();
|
||||
|
||||
boolean clip = ScissorStack.pushScissors(clipRect.set(x, y, w, h));
|
||||
Graphics.beginClip(x, y, w, h);
|
||||
|
||||
for(Unit unit : units){
|
||||
float rx = (unit.x - rect.x) / rect.width * w, ry = (unit.y - rect.y) / rect.width * h;
|
||||
@@ -92,8 +86,7 @@ public class MinimapRenderer implements Disposable{
|
||||
|
||||
Draw.color();
|
||||
|
||||
Graphics.flush();
|
||||
if(clip) ScissorStack.popScissors();
|
||||
Graphics.endClip();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,22 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Fill;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.event.InputEvent;
|
||||
import io.anuke.ucore.scene.event.InputListener;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
import io.anuke.ucore.scene.utils.Cursors;
|
||||
import io.anuke.ucore.scene.utils.ScissorStack;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class SectorsDialog extends FloatingDialog{
|
||||
private Rectangle clip = new Rectangle();
|
||||
private Sector selected;
|
||||
|
||||
public SectorsDialog(){
|
||||
@@ -121,9 +117,6 @@ public class SectorsDialog extends FloatingDialog{
|
||||
|
||||
int shownSectorsX = (int)(width/padSectorSize);
|
||||
int shownSectorsY = (int)(height/padSectorSize);
|
||||
clip.setSize(width, height).setCenter(x + width/2f, y + height/2f);
|
||||
Graphics.flush();
|
||||
boolean clipped = ScissorStack.pushScissors(clip);
|
||||
|
||||
int offsetX = (int)(panX / padSectorSize);
|
||||
int offsetY = (int)(panY / padSectorSize);
|
||||
@@ -169,14 +162,7 @@ public class SectorsDialog extends FloatingDialog{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Draw.color(Color.GRAY);
|
||||
Lines.stroke(Unit.dp.scl(4f));
|
||||
//Lines.crect(x + width/2f, y + height/2f, width, height);
|
||||
|
||||
Draw.reset();
|
||||
Graphics.flush();
|
||||
if(clipped) ScissorStack.popScissors();
|
||||
|
||||
clicked = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user