Break rendering, fix level dialog bug

This commit is contained in:
Anuken
2017-12-20 13:49:35 -05:00
parent 2000a4b6f6
commit 8cff097d1a
5 changed files with 49 additions and 31 deletions

View File

@@ -210,10 +210,8 @@ public class Renderer extends RendererModule{
Graphics.surface(shieldSurface);
Graphics.surface();
boolean optimize = false;
drawFloor();
drawBlocks(false, optimize);
drawBlocks(false);
Graphics.shader(Shaders.outline, false);
Entities.draw(control.enemyGroup);
@@ -221,8 +219,6 @@ public class Renderer extends RendererModule{
Entities.draw(Entities.defaultGroup());
if(!optimize) drawBlocks(true, false);
Entities.draw(control.bulletGroup);
drawShield();
@@ -369,7 +365,7 @@ public class Renderer extends RendererModule{
}
}
void drawBlocks(boolean top, boolean optimize){
void drawBlocks(boolean top){
int crangex = (int) (camera.viewportWidth / (chunksize * tilesize)) + 1;
int crangey = (int) (camera.viewportHeight / (chunksize * tilesize)) + 1;
@@ -384,8 +380,8 @@ public class Renderer extends RendererModule{
Layer[] layers = Layer.values();
int start = optimize ? (noshadows ? 1 : 0) : (top ? 4 : (noshadows ? 1 : 0));
int end = optimize ? 4 : (top ? 4 + layers.length-1 : 4);
int start = (top ? 4 : (noshadows ? 1 : 0));
int end = (top ? 4 + layers.length-1 : 4);
//0 = shadows
//1 = cache blocks
@@ -422,15 +418,12 @@ public class Renderer extends RendererModule{
(!expanded || tile.block().expanded)){
if(l == 2){
tile.block().draw(tile);
}else if(!optimize){
}else{
if(tile.block().layer == layer)
tile.block().drawLayer(tile);
if(tile.block().layer2 == layer)
tile.block().drawLayer2(tile);
}else if(l == 3){
tile.block().drawLayer(tile);
tile.block().drawLayer2(tile);
}
}
}

View File

@@ -8,10 +8,13 @@ import io.anuke.mindustry.world.Map;
import io.anuke.ucore.core.Core;
import io.anuke.ucore.core.Settings;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.scene.event.InputEvent;
import io.anuke.ucore.scene.ui.*;
import io.anuke.ucore.scene.ui.layout.Stack;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.utils.ClickListener;
import io.anuke.ucore.scene.utils.Elements;
import io.anuke.ucore.util.Tmp;
public class LevelDialog extends FloatingDialog{
private Map selectedMap = Vars.world.maps().getMap(0);
@@ -83,20 +86,29 @@ public class LevelDialog extends FloatingDialog{
if(map.custom){
image.row();
delete[0] = image.addButton("Delete", () -> {
Vars.ui.showConfirm("Confirm Delete", "Are you sure you want to delete\nthe map \"[orange]" + map.name + "[]\"?", () -> {
Vars.world.maps().removeMap(map);
reload();
Core.scene.setScrollFocus(pane);
Timers.run(1f, () -> {
Vars.ui.showConfirm("Confirm Delete", "Are you sure you want to delete\nthe map \"[orange]" + map.name + "[]\"?", () -> {
Vars.world.maps().removeMap(map);
reload();
Core.scene.setScrollFocus(pane);
});
});
}).width(images+16).padBottom(-10f).grow().get();
}
image.clicked(()->{
if(delete[0] != null && delete[0].getClickListener().isOver()){
return;
image.addListener(new ClickListener(){
public void clicked(InputEvent event, float x, float y){
image.localToStageCoordinates(Tmp.v1.set(x, y));
if(delete[0] != null && (delete[0].getClickListener().isOver() || delete[0].getClickListener().isPressed()
|| (Core.scene.hit(Tmp.v1.x, Tmp.v1.y, true) != null &&
Core.scene.hit(Tmp.v1.x, Tmp.v1.y, true).isDescendantOf(delete[0])))){
return;
}
selectedMap = map;
hide();
Vars.control.playMap(selectedMap);
}
selectedMap = map;
hide();
Vars.control.playMap(selectedMap);
});
image.getImageCell().size(images);

View File

@@ -8,9 +8,7 @@ import io.anuke.mindustry.resource.ItemStack;
import io.anuke.mindustry.resource.Liquid;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.BlockPart;
import io.anuke.mindustry.world.blocks.types.Floor;
import io.anuke.mindustry.world.blocks.types.StaticBlock;
import io.anuke.mindustry.world.blocks.types.*;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Mathf;
@@ -79,25 +77,26 @@ public class Blocks{
stone = new Floor("stone"){{
drops = new ItemStack(Item.stone, 1);
blends = block -> block != this && !(block instanceof Ore);
}},
blackstone = new Floor("blackstone"){{
drops = new ItemStack(Item.stone, 1);
}},
iron = new Floor("iron"){{
iron = new Ore("iron"){{
drops = new ItemStack(Item.iron, 1);
}},
coal = new Floor("coal"){{
coal = new Ore("coal"){{
drops = new ItemStack(Item.coal, 1);
}},
titanium = new Floor("titanium"){{
titanium = new Ore("titanium"){{
drops = new ItemStack(Item.titanium, 1);
}},
uranium = new Floor("uranium"){{
uranium = new Ore("uranium"){{
drops = new ItemStack(Item.uranium, 1);
}},

View File

@@ -7,10 +7,12 @@ import io.anuke.mindustry.Vars;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.function.Predicate;
import io.anuke.ucore.util.Mathf;
public class Floor extends Block{
protected Predicate<Block> blends = block -> block != this;
public Floor(String name) {
super(name);
variants = 3;
@@ -33,7 +35,7 @@ public class Floor extends Block{
Block floor = other.floor();
if(floor.id <= this.id) continue;
if(floor.id <= this.id || !blends.test(floor)) continue;
TextureRegion region = Draw.hasRegion(floor.name() + "edge") ? Draw.region(floor.name() + "edge") :
Draw.region(floor.edge + "edge");

View File

@@ -0,0 +1,12 @@
package io.anuke.mindustry.world.blocks.types;
import io.anuke.mindustry.world.blocks.Blocks;
public class Ore extends Floor{
public Ore(String name) {
super(name);
blends = block -> block != this && block != Blocks.stone;
}
}