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(shieldSurface);
Graphics.surface(); Graphics.surface();
boolean optimize = false;
drawFloor(); drawFloor();
drawBlocks(false, optimize); drawBlocks(false);
Graphics.shader(Shaders.outline, false); Graphics.shader(Shaders.outline, false);
Entities.draw(control.enemyGroup); Entities.draw(control.enemyGroup);
@@ -221,8 +219,6 @@ public class Renderer extends RendererModule{
Entities.draw(Entities.defaultGroup()); Entities.draw(Entities.defaultGroup());
if(!optimize) drawBlocks(true, false);
Entities.draw(control.bulletGroup); Entities.draw(control.bulletGroup);
drawShield(); 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 crangex = (int) (camera.viewportWidth / (chunksize * tilesize)) + 1;
int crangey = (int) (camera.viewportHeight / (chunksize * tilesize)) + 1; int crangey = (int) (camera.viewportHeight / (chunksize * tilesize)) + 1;
@@ -384,8 +380,8 @@ public class Renderer extends RendererModule{
Layer[] layers = Layer.values(); Layer[] layers = Layer.values();
int start = optimize ? (noshadows ? 1 : 0) : (top ? 4 : (noshadows ? 1 : 0)); int start = (top ? 4 : (noshadows ? 1 : 0));
int end = optimize ? 4 : (top ? 4 + layers.length-1 : 4); int end = (top ? 4 + layers.length-1 : 4);
//0 = shadows //0 = shadows
//1 = cache blocks //1 = cache blocks
@@ -422,15 +418,12 @@ public class Renderer extends RendererModule{
(!expanded || tile.block().expanded)){ (!expanded || tile.block().expanded)){
if(l == 2){ if(l == 2){
tile.block().draw(tile); tile.block().draw(tile);
}else if(!optimize){ }else{
if(tile.block().layer == layer) if(tile.block().layer == layer)
tile.block().drawLayer(tile); tile.block().drawLayer(tile);
if(tile.block().layer2 == layer) if(tile.block().layer2 == layer)
tile.block().drawLayer2(tile); 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.Core;
import io.anuke.ucore.core.Settings; import io.anuke.ucore.core.Settings;
import io.anuke.ucore.core.Timers; 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.*;
import io.anuke.ucore.scene.ui.layout.Stack; import io.anuke.ucore.scene.ui.layout.Stack;
import io.anuke.ucore.scene.ui.layout.Table; 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.scene.utils.Elements;
import io.anuke.ucore.util.Tmp;
public class LevelDialog extends FloatingDialog{ public class LevelDialog extends FloatingDialog{
private Map selectedMap = Vars.world.maps().getMap(0); private Map selectedMap = Vars.world.maps().getMap(0);
@@ -83,20 +86,29 @@ public class LevelDialog extends FloatingDialog{
if(map.custom){ if(map.custom){
image.row(); image.row();
delete[0] = image.addButton("Delete", () -> { delete[0] = image.addButton("Delete", () -> {
Vars.ui.showConfirm("Confirm Delete", "Are you sure you want to delete\nthe map \"[orange]" + map.name + "[]\"?", () -> { Timers.run(1f, () -> {
Vars.world.maps().removeMap(map); Vars.ui.showConfirm("Confirm Delete", "Are you sure you want to delete\nthe map \"[orange]" + map.name + "[]\"?", () -> {
reload(); Vars.world.maps().removeMap(map);
Core.scene.setScrollFocus(pane); reload();
Core.scene.setScrollFocus(pane);
});
}); });
}).width(images+16).padBottom(-10f).grow().get(); }).width(images+16).padBottom(-10f).grow().get();
} }
image.clicked(()->{
if(delete[0] != null && delete[0].getClickListener().isOver()){ image.addListener(new ClickListener(){
return; 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); 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.resource.Liquid;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.BlockPart; import io.anuke.mindustry.world.blocks.types.*;
import io.anuke.mindustry.world.blocks.types.Floor;
import io.anuke.mindustry.world.blocks.types.StaticBlock;
import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Mathf;
@@ -79,25 +77,26 @@ public class Blocks{
stone = new Floor("stone"){{ stone = new Floor("stone"){{
drops = new ItemStack(Item.stone, 1); drops = new ItemStack(Item.stone, 1);
blends = block -> block != this && !(block instanceof Ore);
}}, }},
blackstone = new Floor("blackstone"){{ blackstone = new Floor("blackstone"){{
drops = new ItemStack(Item.stone, 1); drops = new ItemStack(Item.stone, 1);
}}, }},
iron = new Floor("iron"){{ iron = new Ore("iron"){{
drops = new ItemStack(Item.iron, 1); drops = new ItemStack(Item.iron, 1);
}}, }},
coal = new Floor("coal"){{ coal = new Ore("coal"){{
drops = new ItemStack(Item.coal, 1); drops = new ItemStack(Item.coal, 1);
}}, }},
titanium = new Floor("titanium"){{ titanium = new Ore("titanium"){{
drops = new ItemStack(Item.titanium, 1); drops = new ItemStack(Item.titanium, 1);
}}, }},
uranium = new Floor("uranium"){{ uranium = new Ore("uranium"){{
drops = new ItemStack(Item.uranium, 1); 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.Block;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Draw;
import io.anuke.ucore.function.Predicate;
import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Mathf;
public class Floor extends Block{ public class Floor extends Block{
protected Predicate<Block> blends = block -> block != this;
public Floor(String name) { public Floor(String name) {
super(name); super(name);
variants = 3; variants = 3;
@@ -33,7 +35,7 @@ public class Floor extends Block{
Block floor = other.floor(); 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") : TextureRegion region = Draw.hasRegion(floor.name() + "edge") ? Draw.region(floor.name() + "edge") :
Draw.region(floor.edge + "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;
}
}