Bugfixes / Unit test fix
This commit is contained in:
Binary file not shown.
@@ -147,7 +147,7 @@ public class Zones implements ContentList{
|
|||||||
}};
|
}};
|
||||||
}};
|
}};
|
||||||
|
|
||||||
tarFields = new Zone("tarFields", new MapGenerator("tarFields", 1)
|
tarFields = new Zone("tarFields", new MapGenerator("tarFields")
|
||||||
.dist(0f, false)
|
.dist(0f, false)
|
||||||
.decor(new Decoration(Blocks.shale, Blocks.shaleBoulder, 0.02))){{
|
.decor(new Decoration(Blocks.shale, Blocks.shaleBoulder, 0.02))){{
|
||||||
loadout = Loadouts.basicFoundation;
|
loadout = Loadouts.basicFoundation;
|
||||||
|
|||||||
@@ -126,6 +126,13 @@ public class Renderer implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose(){
|
||||||
|
minimap.dispose();
|
||||||
|
shieldBuffer.dispose();
|
||||||
|
blocks.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
void updateShake(float scale){
|
void updateShake(float scale){
|
||||||
if(shaketime > 0){
|
if(shaketime > 0){
|
||||||
float intensity = shakeIntensity * (settings.getInt("screenshake", 4) / 4f) * scale;
|
float intensity = shakeIntensity * (settings.getInt("screenshake", 4) / 4f) * scale;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class GlobalData{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes this piece of content 'unlocked', if possible.
|
* Makes this piece of content 'unlocked', if possible.
|
||||||
* If this piece of content is already unlocked or cannot be unlocked due to dependencies, nothing changes.
|
* If this piece of content is already unlocked, nothing changes.
|
||||||
* Results are not saved until you call {@link #save()}.
|
* Results are not saved until you call {@link #save()}.
|
||||||
*/
|
*/
|
||||||
public void unlockContent(UnlockableContent content){
|
public void unlockContent(UnlockableContent content){
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import io.anuke.arc.graphics.Texture.TextureFilter;
|
|||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.graphics.g2d.Fill;
|
import io.anuke.arc.graphics.g2d.Fill;
|
||||||
import io.anuke.arc.graphics.glutils.FrameBuffer;
|
import io.anuke.arc.graphics.glutils.FrameBuffer;
|
||||||
|
import io.anuke.arc.util.Disposable;
|
||||||
import io.anuke.arc.util.Tmp;
|
import io.anuke.arc.util.Tmp;
|
||||||
import io.anuke.mindustry.content.Blocks;
|
import io.anuke.mindustry.content.Blocks;
|
||||||
import io.anuke.mindustry.game.EventType.TileChangeEvent;
|
import io.anuke.mindustry.game.EventType.TileChangeEvent;
|
||||||
@@ -20,7 +21,7 @@ import io.anuke.mindustry.world.Tile;
|
|||||||
import static io.anuke.arc.Core.camera;
|
import static io.anuke.arc.Core.camera;
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class BlockRenderer{
|
public class BlockRenderer implements Disposable{
|
||||||
private final static int initialRequests = 32 * 32;
|
private final static int initialRequests = 32 * 32;
|
||||||
private final static int expandr = 9;
|
private final static int expandr = 9;
|
||||||
private final static Color shadowColor = new Color(0, 0, 0, 0.71f);
|
private final static Color shadowColor = new Color(0, 0, 0, 0.71f);
|
||||||
@@ -294,6 +295,14 @@ public class BlockRenderer{
|
|||||||
requestidx++;
|
requestidx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose(){
|
||||||
|
shadows.dispose();
|
||||||
|
fog.dispose();
|
||||||
|
shadows = fog = null;
|
||||||
|
floor.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
private class BlockRequest implements Comparable<BlockRequest>{
|
private class BlockRequest implements Comparable<BlockRequest>{
|
||||||
Tile tile;
|
Tile tile;
|
||||||
Layer layer;
|
Layer layer;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import java.util.Arrays;
|
|||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Vars.world;
|
||||||
|
|
||||||
public class FloorRenderer{
|
public class FloorRenderer implements Disposable{
|
||||||
private final static int chunksize = 64;
|
private final static int chunksize = 64;
|
||||||
|
|
||||||
private Chunk[][] cache;
|
private Chunk[][] cache;
|
||||||
@@ -221,6 +221,14 @@ public class FloorRenderer{
|
|||||||
Log.info("Time to cache: {0}", Time.elapsed());
|
Log.info("Time to cache: {0}", Time.elapsed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose(){
|
||||||
|
if(cbatch != null){
|
||||||
|
cbatch.dispose();
|
||||||
|
cbatch = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class Chunk{
|
private class Chunk{
|
||||||
int[] caches = new int[CacheLayer.values().length];
|
int[] caches = new int[CacheLayer.values().length];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ public class MapGenerator extends Generator{
|
|||||||
|
|
||||||
if(enemySpawns != -1){
|
if(enemySpawns != -1){
|
||||||
if(enemySpawns > enemies.size){
|
if(enemySpawns > enemies.size){
|
||||||
throw new IllegalArgumentException("Enemy spawn pool greater than map spawn number.");
|
throw new IllegalArgumentException("Enemy spawn pool greater than map spawn number for map: " + mapName);
|
||||||
}
|
}
|
||||||
|
|
||||||
enemies.shuffle();
|
enemies.shuffle();
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package io.anuke.mindustry.ui;
|
package io.anuke.mindustry.ui;
|
||||||
|
|
||||||
import io.anuke.arc.function.Supplier;
|
|
||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
import io.anuke.arc.scene.ui.Image;
|
import io.anuke.arc.scene.ui.Image;
|
||||||
import io.anuke.arc.scene.ui.layout.Stack;
|
import io.anuke.arc.scene.ui.layout.Stack;
|
||||||
@@ -18,14 +17,6 @@ public class ItemImage extends Stack{
|
|||||||
add(t);
|
add(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemImage(TextureRegion region, Supplier<CharSequence> text){
|
|
||||||
Table t = new Table().left().bottom();
|
|
||||||
t.label(text).name("item-label");
|
|
||||||
|
|
||||||
add(new Image(region));
|
|
||||||
add(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemImage(ItemStack stack){
|
public ItemImage(ItemStack stack){
|
||||||
add(new Image(stack.item.icon(Icon.large)));
|
add(new Image(stack.item.icon(Icon.large)));
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import io.anuke.arc.scene.ui.layout.Table;
|
|||||||
import io.anuke.arc.util.Align;
|
import io.anuke.arc.util.Align;
|
||||||
import io.anuke.mindustry.content.Blocks;
|
import io.anuke.mindustry.content.Blocks;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.input.InputHandler;
|
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
@@ -18,14 +17,9 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
|
|
||||||
public class BlockConfigFragment extends Fragment{
|
public class BlockConfigFragment extends Fragment{
|
||||||
private Table table = new Table();
|
private Table table = new Table();
|
||||||
private InputHandler input;
|
|
||||||
private Tile configTile;
|
private Tile configTile;
|
||||||
private Block configBlock;
|
private Block configBlock;
|
||||||
|
|
||||||
public BlockConfigFragment(InputHandler input){
|
|
||||||
this.input = input;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
table.visible(false);
|
table.visible(false);
|
||||||
|
|||||||
@@ -5,22 +5,25 @@ import io.anuke.annotations.Annotations.Remote;
|
|||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.arc.collection.IntSet;
|
import io.anuke.arc.collection.IntSet;
|
||||||
import io.anuke.arc.function.BooleanProvider;
|
import io.anuke.arc.function.BooleanProvider;
|
||||||
|
import io.anuke.arc.function.Supplier;
|
||||||
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
import io.anuke.arc.input.KeyCode;
|
import io.anuke.arc.input.KeyCode;
|
||||||
import io.anuke.arc.math.Interpolation;
|
import io.anuke.arc.math.Interpolation;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.math.geom.Vector2;
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
|
import io.anuke.arc.scene.Element;
|
||||||
import io.anuke.arc.scene.Group;
|
import io.anuke.arc.scene.Group;
|
||||||
import io.anuke.arc.scene.actions.Actions;
|
import io.anuke.arc.scene.actions.Actions;
|
||||||
import io.anuke.arc.scene.event.*;
|
import io.anuke.arc.scene.event.*;
|
||||||
|
import io.anuke.arc.scene.ui.Image;
|
||||||
|
import io.anuke.arc.scene.ui.layout.Stack;
|
||||||
import io.anuke.arc.scene.ui.layout.Table;
|
import io.anuke.arc.scene.ui.layout.Table;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.entities.type.Player;
|
import io.anuke.mindustry.entities.type.Player;
|
||||||
import io.anuke.mindustry.gen.Call;
|
import io.anuke.mindustry.gen.Call;
|
||||||
import io.anuke.mindustry.input.InputHandler;
|
|
||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.mindustry.type.Item.Icon;
|
import io.anuke.mindustry.type.Item.Icon;
|
||||||
import io.anuke.mindustry.ui.ItemImage;
|
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
@@ -30,15 +33,10 @@ public class BlockInventoryFragment extends Fragment{
|
|||||||
|
|
||||||
private Table table;
|
private Table table;
|
||||||
private Tile tile;
|
private Tile tile;
|
||||||
private InputHandler input;
|
|
||||||
private float holdTime = 0f;
|
private float holdTime = 0f;
|
||||||
private boolean holding;
|
private boolean holding;
|
||||||
private Item lastItem;
|
private Item lastItem;
|
||||||
|
|
||||||
public BlockInventoryFragment(InputHandler input){
|
|
||||||
this.input = input;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Remote(called = Loc.server, targets = Loc.both, forward = true)
|
@Remote(called = Loc.server, targets = Loc.both, forward = true)
|
||||||
public static void requestItem(Player player, Tile tile, Item item, int amount){
|
public static void requestItem(Player player, Tile tile, Item item, int amount){
|
||||||
if(player == null || tile == null) return;
|
if(player == null || tile == null) return;
|
||||||
@@ -133,7 +131,7 @@ public class BlockInventoryFragment extends Fragment{
|
|||||||
HandCursorListener l = new HandCursorListener();
|
HandCursorListener l = new HandCursorListener();
|
||||||
l.setEnabled(canPick);
|
l.setEnabled(canPick);
|
||||||
|
|
||||||
ItemImage image = new ItemImage(item.icon(Icon.xlarge), () -> {
|
Element image = itemImage(item.icon(Icon.xlarge), () -> {
|
||||||
if(tile == null || tile.entity == null){
|
if(tile == null || tile.entity == null){
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -182,9 +180,9 @@ public class BlockInventoryFragment extends Fragment{
|
|||||||
private String round(float f){
|
private String round(float f){
|
||||||
f = (int)f;
|
f = (int)f;
|
||||||
if(f >= 1000000){
|
if(f >= 1000000){
|
||||||
return Strings.fixed(f / 1000000f, 1) + "[gray]mil[]";
|
return (int)(f / 1000000f) + "[gray]mil[]";
|
||||||
}else if(f >= 1000){
|
}else if(f >= 1000){
|
||||||
return Strings.fixed(f / 1000, 1) + "k";
|
return (int)(f / 1000) + "k";
|
||||||
}else{
|
}else{
|
||||||
return (int)f + "";
|
return (int)f + "";
|
||||||
}
|
}
|
||||||
@@ -195,4 +193,15 @@ public class BlockInventoryFragment extends Fragment{
|
|||||||
table.pack();
|
table.pack();
|
||||||
table.setPosition(v.x, v.y, Align.topLeft);
|
table.setPosition(v.x, v.y, Align.topLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Element itemImage(TextureRegion region, Supplier<CharSequence> text){
|
||||||
|
Stack stack = new Stack();
|
||||||
|
|
||||||
|
Table t = new Table().left().bottom();
|
||||||
|
t.label(text);
|
||||||
|
|
||||||
|
stack.add(new Image(region));
|
||||||
|
stack.add(t);
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ public class ChatFragment extends Table{
|
|||||||
private BitmapFont font;
|
private BitmapFont font;
|
||||||
private GlyphLayout layout = new GlyphLayout();
|
private GlyphLayout layout = new GlyphLayout();
|
||||||
private float offsetx = Unit.dp.scl(4), offsety = Unit.dp.scl(4), fontoffsetx = Unit.dp.scl(2), chatspace = Unit.dp.scl(50);
|
private float offsetx = Unit.dp.scl(4), offsety = Unit.dp.scl(4), fontoffsetx = Unit.dp.scl(2), chatspace = Unit.dp.scl(50);
|
||||||
private float textWidth = Unit.dp.scl(600);
|
|
||||||
private Color shadowColor = new Color(0, 0, 0, 0.4f);
|
private Color shadowColor = new Color(0, 0, 0, 0.4f);
|
||||||
private float textspacing = Unit.dp.scl(10);
|
private float textspacing = Unit.dp.scl(10);
|
||||||
private Array<String> history = new Array<>();
|
private Array<String> history = new Array<>();
|
||||||
@@ -124,6 +123,7 @@ public class ChatFragment extends Table{
|
|||||||
@Override
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
float opacity = Core.settings.getInt("chatopacity") / 100f;
|
float opacity = Core.settings.getInt("chatopacity") / 100f;
|
||||||
|
float textWidth = Math.min(Core.graphics.getWidth()/1.5f, Unit.dp.scl(700f));
|
||||||
|
|
||||||
Draw.color(shadowColor);
|
Draw.color(shadowColor);
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package io.anuke.mindustry.ui.fragments;
|
|||||||
import io.anuke.arc.scene.Group;
|
import io.anuke.arc.scene.Group;
|
||||||
import io.anuke.mindustry.input.InputHandler;
|
import io.anuke.mindustry.input.InputHandler;
|
||||||
|
|
||||||
/** Fragment for displaying overlays such as block inventories. One is created for each input handler. */
|
/** Fragment for displaying overlays such as block inventories. */
|
||||||
public class OverlayFragment extends Fragment{
|
public class OverlayFragment extends Fragment{
|
||||||
public final BlockInventoryFragment inv;
|
public final BlockInventoryFragment inv;
|
||||||
public final BlockConfigFragment config;
|
public final BlockConfigFragment config;
|
||||||
@@ -11,8 +11,8 @@ public class OverlayFragment extends Fragment{
|
|||||||
private Group group = new Group();
|
private Group group = new Group();
|
||||||
|
|
||||||
public OverlayFragment(InputHandler input){
|
public OverlayFragment(InputHandler input){
|
||||||
inv = new BlockInventoryFragment(input);
|
inv = new BlockInventoryFragment();
|
||||||
config = new BlockConfigFragment(input);
|
config = new BlockConfigFragment();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -284,7 +284,8 @@ public class Block extends BlockStorage{
|
|||||||
|
|
||||||
/** Call when some content is produced. This unlocks the content if it is applicable. */
|
/** Call when some content is produced. This unlocks the content if it is applicable. */
|
||||||
public void useContent(Tile tile, UnlockableContent content){
|
public void useContent(Tile tile, UnlockableContent content){
|
||||||
if(!headless && tile.getTeam() == player.getTeam()){
|
//only unlocks content in zones
|
||||||
|
if(!headless && tile.getTeam() == player.getTeam() && world.isZone()){
|
||||||
logic.handleContent(content);
|
logic.handleContent(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user