Deprecated Draw.color(String), switched to type-safe usage

This commit is contained in:
Anuken 2018-05-21 13:37:16 -04:00
parent 9708d3183f
commit 37afb46957
29 changed files with 168 additions and 136 deletions

View File

@ -1,7 +1,6 @@
package io.anuke.mindustry.content.fx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Colors;
import io.anuke.mindustry.entities.effect.GroundEffectEntity.GroundEffect;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.ucore.core.Effects.Effect;
@ -111,7 +110,7 @@ public class BlockFx {
}),
producesmoke = new Effect(12, e -> {
Angles.randLenVectors(e.id, 8, 4f + e.fin()*18f, (x, y)->{
Draw.color(Color.WHITE, Colors.get("accent"), e.fin());
Draw.color(Color.WHITE, Palette.accent, e.fin());
Fill.poly(e.x + x, e.y + y, 4, 1f+e.fout()*3f, 45);
Draw.reset();
});

View File

@ -1,10 +1,12 @@
package io.anuke.mindustry.content.fx;
import com.badlogic.gdx.graphics.Color;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.ucore.core.Effects.Effect;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Fill;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.util.Angles;
import static io.anuke.mindustry.Vars.tilesize;
@ -16,16 +18,22 @@ public class Fx{
none = new Effect(0, 0f, e->{}),
placeBlock = new Effect(16, e -> {
Draw.color("accent");
Draw.color(Palette.accent);
Lines.stroke(3f - e.fin() * 2f);
Lines.square(e.x, e.y, tilesize / 2f * (float)(e.data) + e.fin() * 3f);
Draw.reset();
}),
breakBlock = new Effect(12, e -> {
Draw.color("break");
float data = (float)(e.data);
Draw.color(Palette.remove);
Lines.stroke(3f - e.fin() * 2f);
Lines.square(e.x, e.y, tilesize / 2f * (float)(e.data) + e.fin() * 3f);
Lines.square(e.x, e.y, tilesize / 2f * data + e.fin() * 3f);
Angles.randLenVectors(e.id, 3 + (int)(data*3), data*2f + (tilesize * data) * e.finpow(), (x, y) -> {
Fill.square(e.x + x, e.y + y, 1f + e.fout()*(3f+data));
});
Draw.reset();
}),
@ -41,27 +49,5 @@ public class Fx{
Draw.color(Color.DARK_GRAY, Color.SCARLET, e.fin());
Lines.circle(e.x, e.y, 7f - e.fin() * 6f);
Draw.reset();
}),
node1 = new Effect(50, e -> {
Lines.stroke(2f);
Draw.color(Color.RED);
Lines.circle(e.x, e.y, 3f);
Draw.reset();
}),
node2 = new Effect(50, e -> {
Draw.color(Color.GREEN);
Fill.circle(e.x, e.y, 3f);
Draw.reset();
}),
node3 = new Effect(50, e -> {
Lines.stroke(1f);
Draw.color(Color.BLUE);
Lines.circle(e.x, e.y, 5f);
Draw.reset();
}),
node4 = new Effect(50, e -> {
Draw.color(Color.YELLOW);
Fill.circle(e.x, e.y, 2f);
Draw.reset();
});
}

View File

@ -33,7 +33,7 @@ import static io.anuke.mindustry.Vars.*;
* This class is not created in the headless server.*/
public class Control extends Module{
/**Minimum period of time between the same sound being played.*/
private static final long minSoundPeriod = 30;
private static final long minSoundPeriod = 100;
private boolean hiscore = false;
private boolean wasPaused = false;

View File

@ -74,6 +74,7 @@ public class Renderer extends RendererModule{
entity.rotation = rotation;
entity.lifetime = effect.lifetime;
entity.data = data;
entity.id ++;
entity.set(x, y).add(effectGroup);
if(data instanceof Entity){
@ -85,6 +86,7 @@ public class Renderer extends RendererModule{
entity.color = color;
entity.rotation = rotation;
entity.lifetime = effect.lifetime;
entity.id ++;
entity.data = data;
entity.set(x, y).add(groundEffectGroup);
}

View File

@ -2,12 +2,12 @@ package io.anuke.mindustry.core;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.utils.Align;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.editor.MapEditorDialog;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.input.InputHandler;
import io.anuke.mindustry.io.Platform;
import io.anuke.mindustry.ui.dialogs.*;
@ -94,24 +94,22 @@ public class UI extends SceneModule{
Dialog.closePadR = -1;
Dialog.closePadT = 5;
Colors.put("description", Color.WHITE);
Colors.put("turretinfo", Color.ORANGE);
Colors.put("iteminfo", Color.LIGHT_GRAY);
Colors.put("powerinfo", Color.YELLOW);
Colors.put("liquidinfo", Color.ROYAL);
Colors.put("craftinfo", Color.LIGHT_GRAY);
Colors.put("missingitems", Color.SCARLET);
Colors.put("health", Color.YELLOW);
Colors.put("healthstats", Color.SCARLET);
Colors.put("interact", Color.ORANGE);
Colors.put("accent", Color.valueOf("f4ba6e"));
Colors.put("place", Color.valueOf("6335f8"));
Colors.put("break", Color.valueOf("e55454"));
Colors.put("placeRotate", Color.ORANGE);
Colors.put("breakStart", Color.YELLOW);
Colors.put("breakInvalid", Color.SCARLET);
Colors.put("range", Colors.get("accent"));
Colors.put("power", Color.valueOf("fbd367"));
Colors.put("description", Palette.description);
Colors.put("turretinfo", Palette.turretinfo);
Colors.put("iteminfo", Palette.iteminfo);
Colors.put("powerinfo", Palette.powerinfo);
Colors.put("liquidinfo", Palette.liquidinfo);
Colors.put("craftinfo", Palette.craftinfo);
Colors.put("missingitems", Palette.missingitems);
Colors.put("health", Palette.health);
Colors.put("healthstats", Palette.healthstats);
Colors.put("interact", Palette.interact);
Colors.put("accent", Palette.accent);
Colors.put("place", Palette.place);
Colors.put("remove", Palette.remove);
Colors.put("placeRotate", Palette.placeRotate);
Colors.put("range", Palette.range);
Colors.put("power", Palette.power);
}
@Override

View File

@ -1,6 +1,5 @@
package io.anuke.mindustry.editor;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.graphics.g2d.Batch;
@ -12,8 +11,8 @@ 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.graphics.Palette;
import io.anuke.mindustry.ui.GridImage;
import io.anuke.mindustry.world.ColorMapper;
import io.anuke.ucore.core.Core;
import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.core.Inputs;
@ -256,7 +255,7 @@ public class MapView extends Element implements GestureListener{
float sx = v1.x, sy = v1.y;
Vector2 v2 = unproject(lastx, lasty).add(x, y);
Draw.color("accent");
Draw.color(Palette.accent);
Lines.stroke(Unit.dp.scl(1f * zoom));
Lines.poly(brushPolygons[index], sx, sy, 3f*zoom);
Lines.poly(brushPolygons[index], v2.x, v2.y, 3f*zoom);
@ -265,7 +264,7 @@ public class MapView extends Element implements GestureListener{
if(tool.edit && (!mobile || drawing)){
GridPoint2 p = project(mousex, mousey);
Vector2 v = unproject(p.x, p.y).add(x, y);
Draw.color("accent");
Draw.color(Palette.accent);
Lines.stroke(Unit.dp.scl(1f * zoom));
Lines.poly(brushPolygons[index], v.x, v.y, 3f*zoom);
}
@ -274,7 +273,7 @@ public class MapView extends Element implements GestureListener{
if(pop) ScissorStack.popScissors();
Draw.color(Colors.get("accent"));
Draw.color(Palette.accent);
Lines.stroke(Unit.dp.scl(3f));
Lines.rect(x, y, width, height);
Draw.reset();

View File

@ -2,6 +2,7 @@ package io.anuke.mindustry.entities;
import com.badlogic.gdx.utils.Queue;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.type.Recipe;
import io.anuke.mindustry.world.Build;
import io.anuke.mindustry.world.Tile;
@ -122,7 +123,7 @@ public interface BlockBuilder {
default void drawBuilding(Unit unit){
Tile tile = world.tile(getCurrentRequest().x, getCurrentRequest().y);
Draw.color(unit.distanceTo(tile) > placeDistance || getCurrentRequest().remove ? "break" : "accent");
Draw.color(unit.distanceTo(tile) > placeDistance || getCurrentRequest().remove ? Palette.remove : Palette.accent);
float focusLen = 3.8f + Mathf.absin(Timers.time(), 1.1f, 0.6f);
float px = unit.x + Angles.trnsx(unit.rotation, focusLen);
float py = unit.y + Angles.trnsy(unit.rotation, focusLen);

View File

@ -4,6 +4,7 @@ import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Pools;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.type.Item;
import io.anuke.ucore.entities.Entity;
import io.anuke.ucore.entities.TimedEntity;
@ -65,7 +66,7 @@ public class ItemTransfer extends TimedEntity{
public void draw() {
float length = fslope()*6f;
float angle = current.set(x, y).sub(from).angle();
Draw.color("accent");
Draw.color(Palette.accent);
Lines.stroke(fslope()*2f);
Lines.circle(x, y, fslope()*2f);

View File

@ -245,7 +245,7 @@ public class Player extends Unit implements BlockBuilder {
public void drawBuildRequests(){
for (BuildRequest request : getPlaceQueue()) {
if(request.remove){
Draw.color("break");
Draw.color(Palette.remove);
Draw.alpha(0.4f);
Lines.stroke(1f);
@ -267,7 +267,7 @@ public class Player extends Unit implements BlockBuilder {
Lines.poly(tile.drawx(), tile.drawy(),
4, tile.block().size * tilesize /2f * (1f-progress) + Mathf.absin(Timers.time(), 3f, 1f));
}else{
Draw.color("accent");
Draw.color(Palette.accent);
Lines.stroke((1f-request.progress));
Lines.poly(request.x * tilesize + request.recipe.result.getPlaceOffset().x,
request.y * tilesize + request.recipe.result.getPlaceOffset().y,

View File

@ -1,7 +1,6 @@
package io.anuke.mindustry.entities.effect;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.content.bullets.TurretBullets;
@ -11,6 +10,7 @@ import io.anuke.mindustry.entities.Bullet;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Effects.Effect;
@ -33,7 +33,7 @@ public class DamageArea{
for(int i = 0; i < Mathf.clamp(power / 20, 0, 6); i ++){
int branches = 5 + Mathf.clamp((int)(power/30), 1, 20);
Timers.run(i*2f + Mathf.random(4f), () -> {
Lightning.create(Team.none, Fx.none, Colors.get("power"), 3, x, y, Mathf.random(360f), branches + Mathf.range(2));
Lightning.create(Team.none, Fx.none, Palette.power, 3, x, y, Mathf.random(360f), branches + Mathf.range(2));
});
}

View File

@ -106,7 +106,7 @@ public class OverlayRenderer {
}
if (Inputs.keyDown("block_info") && target.block().isAccessible()) {
Draw.color(Colors.get("accent"));
Draw.color(Palette.accent);
Lines.crect(target.drawx(), target.drawy(), target.block().size * tilesize, target.block().size * tilesize);
Draw.color();
}
@ -138,14 +138,14 @@ public class OverlayRenderer {
Vector2 v = Graphics.world(input.getMouseX(), input.getMouseY());
float size = 8;
Draw.rect(player.inventory.getItem().item.region, v.x, v.y, size, size);
Draw.color("accent");
Draw.color(Palette.accent);
Lines.circle(v.x, v.y, 6 + Mathf.absin(Timers.time(), 5f, 1f));
Draw.reset();
Tile tile = world.tileWorld(v.x, v.y);
if (tile != null) tile = tile.target();
if (tile != null && tile.block().acceptStack(player.inventory.getItem().item, player.inventory.getItem().amount, tile, player) > 0) {
Draw.color("place");
Draw.color(Palette.place);
Lines.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize / 2f + 1 + Mathf.absin(Timers.time(), 5f, 1f));
Draw.color();
}

View File

@ -24,4 +24,26 @@ public class Palette {
public static final Color portalLight = Color.valueOf("9054ea");
public static final Color portal = Color.valueOf("6344d7");
public static final Color portalDark = Color.valueOf("3f3dac");
public static final Color powerLaserFrom = Color.valueOf("e3e3e3");
public static final Color powerLaserTo = Color.valueOf("ffe7a8");
public static final Color description = Color.WHITE;
public static final Color turretinfo = Color.ORANGE;
public static final Color iteminfo = Color.LIGHT_GRAY;
public static final Color powerinfo = Color.YELLOW;
public static final Color liquidinfo = Color.ROYAL;
public static final Color craftinfo = Color.LIGHT_GRAY;
public static final Color missingitems = Color.SCARLET;
public static final Color health = Color.YELLOW;
public static final Color healthstats = Color.SCARLET;
public static final Color interact = Color.ORANGE;
public static final Color accent = Color.valueOf("f4ba6e");
public static final Color place = Color.valueOf("6335f8");
public static final Color remove = Color.valueOf("e55454");
public static final Color placeRotate = Color.ORANGE;
public static final Color breakInvalid = Color.SCARLET;
public static final Color range = Color.valueOf("f4ba6e");
public static final Color power = Color.valueOf("fbd367");
}

View File

@ -1,10 +1,10 @@
package io.anuke.mindustry.input;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.graphics.Shaders;
import io.anuke.mindustry.ui.fragments.ToolFragment;
import io.anuke.mindustry.world.Block;
@ -39,7 +39,7 @@ public enum PlaceMode{
float si = MathUtils.sin(Timers.time() / 6f) + 1.5f;
Draw.color(valid ? Colors.get("place") : Colors.get("break"));
Draw.color(valid ? Palette.place : Palette.remove);
Lines.stroke(2f);
Lines.crect(x + offset.x, y + offset.y, tilesize * input.recipe.result.size + si,
tilesize * input.recipe.result.size + si);
@ -48,7 +48,7 @@ public enum PlaceMode{
if(input.recipe.result.rotate){
Draw.color(Colors.get("placeRotate"));
Draw.color(Palette.placeRotate);
tr.trns(input.rotation * 90, 7, 0);
Lines.line(x, y, x + tr.x, y + tr.y);
}
@ -93,7 +93,7 @@ public enum PlaceMode{
float fin = input.breaktime / tile.getBreakTime();
if(mobile && input.breaktime > 0){
Draw.color(Colors.get("breakStart"), Colors.get("break"), fin);
Draw.color(Palette.place, Palette.remove, fin);
Lines.poly(tile.drawx(), tile.drawy(), 25, 4 + (1f - fin) * 26);
}
Draw.reset();
@ -145,7 +145,7 @@ public enum PlaceMode{
y2 += t/2;
}
Draw.color(Colors.get("break"));
Draw.color(Palette.remove);
Lines.stroke(1f);
for(int cx = tilex; cx <= endx; cx ++){
for(int cy = tiley; cy <= endy; cy ++){
@ -160,7 +160,7 @@ public enum PlaceMode{
}
Lines.stroke(2f);
Draw.color(input.cursorNear() ? Colors.get("break") : Colors.get("breakInvalid"));
Draw.color(Palette.remove);
Lines.rect(x, y, x2 - x, y2 - y);
Draw.alpha(0.3f);
Draw.crect("blank", x, y, x2 - x, y2 - y);
@ -265,7 +265,7 @@ public enum PlaceMode{
if(tilex == endx && tiley == endy){
cursor.draw(input, tilex, tiley, endx, endy);
}else{
Draw.color("place");
Draw.color(Palette.place);
Lines.stroke(1f);
Lines.rect(x, y, x2 - x, y2 - y);
Draw.alpha(0.3f);
@ -280,9 +280,9 @@ public enum PlaceMode{
int wx = tilex + px * Mathf.sign(endx - tilex),
wy = tiley + py * Mathf.sign(endy - tiley);
if(!Build.validPlace(input.player.team, wx, wy, block, rotation)){
Draw.color("break");
Draw.color(Palette.remove);
}else{
Draw.color("accent");
Draw.color(Palette.accent);
}
drawPreview(block, wx * t + offset.x, wy * t + offset.y);
@ -297,7 +297,7 @@ public enum PlaceMode{
public void drawPreview(Block block, float x, float y){
for(TextureRegion region : block.getBlockIcon()){
Shaders.blockpreview.region = region;
Shaders.blockpreview.color.set(Colors.get("accent"));
Shaders.blockpreview.color.set(Palette.accent);
Shaders.blockpreview.apply();
Draw.rect(region, x, y);
@ -340,17 +340,24 @@ public enum PlaceMode{
if(Math.abs(endy - tiley) > maxlen){
endy = Mathf.sign(endy - tiley) * maxlen + tiley;
}*/
if(endx > tilex)
rotation = 0;
else if(endx < tilex)
rotation = 2;
else if(endy > tiley)
rotation = 1;
else if(endy < tiley)
rotation = 3;
else
int dx = endx - tilex, dy = endy - tiley;
if(Math.abs(dx) > Math.abs(dy)){
if(dx >= 0){
rotation = 0;
}else{
rotation = 2;
}
}else if(Math.abs(dx) < Math.abs(dy)){
if(dy >= 0){
rotation = 1;
}else{
rotation = 3;
}
}else{
rotation = input.rotation;
}
if(endx < tilex){
int t = endx;

View File

@ -1,10 +1,9 @@
package io.anuke.mindustry.ui;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.scene.ui.Image;
@ -36,7 +35,7 @@ public class BorderImage extends Image{
float scaleX = getScaleX();
float scaleY = getScaleY();
Draw.color(Colors.get("accent"));
Draw.color(Palette.accent);
Lines.stroke(Unit.dp.scl(thickness));
Lines.rect(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
Draw.reset();

View File

@ -1,9 +1,8 @@
package io.anuke.mindustry.ui.dialogs;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.utils.Align;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.ucore.scene.ui.Image;
import io.anuke.ucore.scene.ui.KeybindDialog;
@ -16,7 +15,7 @@ public class ControlsDialog extends KeybindDialog{
title().setAlignment(Align.center);
getTitleTable().row();
getTitleTable().add(new Image("white"))
.growX().height(3f).pad(4f).get().setColor(Colors.get("accent"));
.growX().height(3f).pad(4f).get().setColor(Palette.accent);
}
@Override

View File

@ -2,7 +2,7 @@ package io.anuke.mindustry.ui.dialogs;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Colors;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.ucore.scene.ui.Dialog;
import static io.anuke.mindustry.Vars.discordURL;
@ -33,7 +33,7 @@ public class DiscordDialog extends Dialog {
i.addImage("icon-discord").size(14 * 3);
}).size(h).left();
t.add("$text.discord").color(Colors.get("accent")).growX().padLeft(10f);
t.add("$text.discord").color(Palette.accent).growX().padLeft(10f);
}).size(470f, h).pad(10f);
buttons().defaults().size(170f, 50);

View File

@ -1,8 +1,8 @@
package io.anuke.mindustry.ui.dialogs;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.utils.Align;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.ucore.scene.ui.Dialog;
public class FloatingDialog extends Dialog{
@ -12,7 +12,7 @@ public class FloatingDialog extends Dialog{
setFillParent(true);
title().setAlignment(Align.center);
getTitleTable().row();
getTitleTable().addImage("white", Colors.get("accent"))
getTitleTable().addImage("white", Palette.accent)
.growX().height(3f).pad(4f);
}

View File

@ -2,10 +2,10 @@ package io.anuke.mindustry.ui.dialogs;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.utils.Align;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.net.Net;
import io.anuke.ucore.core.Core;
import io.anuke.ucore.core.Settings;
@ -57,7 +57,7 @@ public class SettingsMenuDialog extends SettingsDialog{
title().setAlignment(Align.center);
getTitleTable().row();
getTitleTable().add(new Image("white"))
.growX().height(3f).pad(4f).get().setColor(Colors.get("accent"));
.growX().height(3f).pad(4f).get().setColor(Palette.accent);
content().clearChildren();
content().remove();

View File

@ -1,13 +1,13 @@
package io.anuke.mindustry.ui.fragments;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.IntSet;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.input.InputHandler;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.ItemStack;
@ -298,7 +298,7 @@ public class BlocksFragment implements Fragment{
int current = stack.amount;
String text = Mathf.clamp(current, 0, stack.amount) + "/" + stack.amount;
reqlabel.setColor(current < stack.amount ? Colors.get("missingitems") : Color.WHITE);
reqlabel.setColor(current < stack.amount ? Palette.missingitems : Color.WHITE);
reqlabel.setText(text);
});

View File

@ -1,6 +1,6 @@
package io.anuke.mindustry.ui.fragments;
import com.badlogic.gdx.graphics.Colors;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.ucore.scene.Group;
import io.anuke.ucore.scene.builders.label;
import io.anuke.ucore.scene.builders.table;
@ -17,14 +17,14 @@ public class LoadingFragment implements Fragment {
table = new table("loadDim"){{
touchable(Touchable.enabled);
get().addImage("white").growX()
.height(3f).pad(4f).growX().get().setColor(Colors.get("accent"));
.height(3f).pad(4f).growX().get().setColor(Palette.accent);
row();
new label("$text.loading"){{
get().setName("namelabel");
}}.pad(10);
row();
get().addImage("white").growX()
.height(3f).pad(4f).growX().get().setColor(Colors.get("accent"));
.height(3f).pad(4f).growX().get().setColor(Palette.accent);
}}.end().get();
table.setVisible(false);

View File

@ -30,7 +30,9 @@ import io.anuke.ucore.util.Bundles;
import io.anuke.ucore.util.EnumSet;
import io.anuke.ucore.util.Mathf;
import static io.anuke.mindustry.Vars.*;
import static io.anuke.mindustry.Vars.state;
import static io.anuke.mindustry.Vars.tilesize;
import static io.anuke.mindustry.Vars.world;
public class Block extends BaseBlock {
private static int lastid;
@ -165,8 +167,12 @@ public class Block extends BaseBlock {
return true;
}
public boolean synthetic(){
return update || destructible || solid;
}
public void drawConfigure(Tile tile){
Draw.color("accent");
Draw.color(Palette.accent);
Lines.stroke(1f);
Lines.square(tile.drawx(), tile.drawy(),
tile.block().size * tilesize / 2f + 1f);
@ -215,10 +221,12 @@ public class Block extends BaseBlock {
return (hasItems && itemCapacity > 0);
}
/**Called after the block is destroyed and removed.*/
public void afterDestroyed(Tile tile, TileEntity entity){
}
/**Called when the block is destroyed.*/
public void onDestroyed(Tile tile){
float x = tile.worldx(), y = tile.worldy();
float explosiveness = baseExplosiveness;
@ -301,6 +309,7 @@ public class Block extends BaseBlock {
}
}
/**Returns the icon used for displaying this block in the place menu*/
public TextureRegion[] getIcon(){
if(icon == null) {
if (Draw.hasRegion(name + "-icon")) {
@ -315,10 +324,12 @@ public class Block extends BaseBlock {
return icon;
}
/**Returns a list of regions that represent this block in the world*/
public TextureRegion[] getBlockIcon(){
return getIcon();
}
/**Returns a list of icon regions that have been cropped to 8x8*/
public TextureRegion[] getCompactIcon(){
if(compactIcon == null) {
compactIcon = new TextureRegion[getIcon().length];
@ -329,6 +340,7 @@ public class Block extends BaseBlock {
return compactIcon;
}
/**Crops a regionto 8x8*/
protected TextureRegion iconRegion(TextureRegion src){
TextureRegion region = new TextureRegion(src);
region.setRegionWidth(8);
@ -391,7 +403,7 @@ public class Block extends BaseBlock {
}
public static Block getByID(int id){
if(id < 0){
if(id < 0){ //offset negative values by 256, as they are a product of byte overflow
id += 256;
}
if(id >= blocks.size || id < 0){

View File

@ -1,6 +1,5 @@
package io.anuke.mindustry.world.blocks.types;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import io.anuke.mindustry.content.fx.ExplosionFx;
import io.anuke.mindustry.content.fx.Fx;
@ -10,16 +9,20 @@ import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.effect.Rubble;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.graphics.Layer;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.graphics.Shaders;
import io.anuke.mindustry.type.Recipe;
import io.anuke.mindustry.world.*;
import io.anuke.mindustry.world.BarType;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.BlockBar;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.modules.InventoryModule;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.graphics.Draw;
public class BuildBlock extends Block {
private static final float decaySpeedScl = 4f;
private static final float decaySpeedScl = 6f;
public BuildBlock(String name) {
super(name);
@ -56,7 +59,7 @@ public class BuildBlock extends Block {
public void afterDestroyed(Tile tile, TileEntity e){
BuildEntity entity = (BuildEntity)e;
if(entity.previous.update || entity.previous.solid){
if(entity.previous.synthetic()){
tile.setBlock(entity.previous);
}
}
@ -65,7 +68,7 @@ public class BuildBlock extends Block {
public void draw(Tile tile){
BuildEntity entity = tile.entity();
if(entity.previous.update || entity.previous.solid) {
if(entity.previous.synthetic()) {
for (TextureRegion region : entity.previous.getBlockIcon()) {
Draw.rect(region, tile.drawx(), tile.drawy(), entity.recipe.result.rotate ? tile.getRotation() * 90 : 0);
}
@ -76,7 +79,7 @@ public class BuildBlock extends Block {
public void drawLayer(Tile tile) {
BuildEntity entity = tile.entity();
Shaders.blockbuild.color = Colors.get("accent");
Shaders.blockbuild.color = Palette.accent;
for(TextureRegion region : entity.recipe.result.getBlockIcon()){
Shaders.blockbuild.region = region;

View File

@ -133,7 +133,7 @@ public abstract class Turret extends Block{
@Override
public void drawPlace(int x, int y, int rotation, boolean valid){
Draw.color("place");
Draw.color(Palette.place);
Lines.stroke(1f);
Lines.dashCircle(x * tilesize + getPlaceOffset().x, y * tilesize + getPlaceOffset().y, range);
}

View File

@ -6,6 +6,7 @@ import com.badlogic.gdx.utils.IntSet;
import com.badlogic.gdx.utils.IntSet.IntSetIterator;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.graphics.Layer;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
@ -62,7 +63,7 @@ public class ItemBridge extends Block {
@Override
public void drawPlace(int x, int y, int rotation, boolean valid) {
Lines.stroke(2f);
Draw.color("place");
Draw.color(Palette.place);
for(int i = 0; i < 4; i ++){
Lines.dashLine(
x * tilesize + Geometry.d4[i].x * tilesize/2f,
@ -79,7 +80,7 @@ public class ItemBridge extends Block {
public void drawConfigure(Tile tile){
ItemBridgeEntity entity = tile.entity();
Draw.color("accent");
Draw.color(Palette.accent);
Lines.stroke(1f);
Lines.square(tile.drawx(), tile.drawy(),
tile.block().size * tilesize / 2f + 1f);
@ -89,7 +90,7 @@ public class ItemBridge extends Block {
Tile other = tile.getNearby(Geometry.d4[j].x * i, Geometry.d4[j].y * i);
if(linkValid(tile, other)){
boolean linked = other.packedPosition() == entity.link;
Draw.color(linked ? "place" : "breakInvalid");
Draw.color(linked ? Palette.place : Palette.breakInvalid);
Lines.square(other.drawx(), other.drawy(),
other.block().size * tilesize / 2f + 1f + (linked ? 0f : Mathf.absin(Timers.time(), 4f, 1f)));

View File

@ -1,11 +1,11 @@
package io.anuke.mindustry.world.blocks.types.power;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.IntArray;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.world.Edges;
import io.anuke.mindustry.graphics.Layer;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.world.Edges;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.PowerBlock;
import io.anuke.ucore.core.Settings;
@ -13,21 +13,20 @@ import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.graphics.Shapes;
import io.anuke.ucore.util.*;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Strings;
import io.anuke.ucore.util.Translator;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import static io.anuke.mindustry.Vars.threads;
import static io.anuke.mindustry.Vars.tilesize;
import static io.anuke.mindustry.Vars.world;
import static io.anuke.mindustry.Vars.*;
public class PowerDistributor extends PowerBlock{
public static final float thicknessScl = 0.7f;
public static final float flashScl = 0.12f;
public static final Color laserFrom = Color.valueOf("e3e3e3");
public static final Color laserTo = Color.valueOf("ffe7a8");
//last distribution block placed
private static int lastPlaced = -1;
@ -98,7 +97,7 @@ public class PowerDistributor extends PowerBlock{
public void drawSelect(Tile tile){
super.drawSelect(tile);
Draw.color("power");
Draw.color(Palette.power);
Lines.stroke(1f);
Lines.poly(Edges.getPixelPolygon(laserRange), tile.worldx() - tilesize/2, tile.worldy() - tilesize/2, tilesize);
@ -110,7 +109,7 @@ public class PowerDistributor extends PowerBlock{
public void drawConfigure(Tile tile){
DistributorEntity entity = tile.entity();
Draw.color("accent");
Draw.color(Palette.accent);
Lines.stroke(1f);
Lines.square(tile.drawx(), tile.drawy(),
@ -120,7 +119,7 @@ public class PowerDistributor extends PowerBlock{
Lines.poly(Edges.getPixelPolygon(laserRange), tile.worldx() - tilesize/2, tile.worldy() - tilesize/2, tilesize);
Draw.color("power");
Draw.color(Palette.power);
for(int x = (int)(tile.x - laserRange); x <= tile.x + laserRange; x ++){
for(int y = (int)(tile.y - laserRange); y <= tile.y + laserRange; y ++){
@ -129,7 +128,7 @@ public class PowerDistributor extends PowerBlock{
if(link != tile && linkValid(tile, link)){
boolean linked = linked(tile, link);
Draw.color(linked ? "place" : "breakInvalid");
Draw.color(linked ? Palette.place : Palette.breakInvalid);
Lines.square(link.drawx(), link.drawy(),
link.block().size * tilesize / 2f + 1f + (linked ? 0f : Mathf.absin(Timers.time(), 4f, 1f)));
@ -147,7 +146,7 @@ public class PowerDistributor extends PowerBlock{
@Override
public void drawPlace(int x, int y, int rotation, boolean valid){
Draw.color("place");
Draw.color(Palette.place);
Lines.stroke(1f);
Lines.poly(Edges.getPixelPolygon(laserRange), x * tilesize - tilesize/2, y * tilesize - tilesize/2, tilesize);
@ -163,7 +162,7 @@ public class PowerDistributor extends PowerBlock{
entity.laserColor = Mathf.lerpDelta(entity.laserColor, Mathf.clamp(entity.powerRecieved/(powerSpeed)), 0.08f);
Draw.color(laserFrom, laserTo, entity.laserColor * (1f-flashScl) + Mathf.sin(Timers.time(), 1.7f, flashScl));
Draw.color(Palette.powerLaserFrom, Palette.powerLaserTo, entity.laserColor * (1f-flashScl) + Mathf.sin(Timers.time(), 1.7f, flashScl));
for(int i = 0; i < entity.links.size; i ++){
Tile link = world.tile(entity.links.get(i));

View File

@ -4,10 +4,11 @@ import com.badlogic.gdx.math.Rectangle;
import io.anuke.mindustry.entities.ItemTransfer;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.BlockFlag;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.util.EnumSet;
@ -50,7 +51,7 @@ public class CoreBlock extends StorageBlock {
@Override
public void drawSelect(Tile tile){
Draw.color("accent");
Draw.color(Palette.accent);
Lines.dashCircle(tile.drawx(), tile.drawy(), supplyRadius);
Draw.color();
}

View File

@ -6,9 +6,10 @@ import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.graphics.Layer;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.BlockFlag;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Lines;
@ -40,7 +41,7 @@ public class RepairPoint extends Block{
@Override
public void drawSelect(Tile tile){
Draw.color("accent");
Draw.color(Palette.accent);
Lines.dashCircle(tile.drawx(), tile.drawy(), repairRadius);
Draw.color();
}

View File

@ -6,10 +6,11 @@ import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.graphics.Layer;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.BlockFlag;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Lines;
@ -41,7 +42,7 @@ public class ResupplyPoint extends Block{
@Override
public void drawSelect(Tile tile){
Draw.color("accent");
Draw.color(Palette.accent);
Lines.dashCircle(tile.drawx(), tile.drawy(), supplyRadius);
Draw.color();
}
@ -62,7 +63,7 @@ public class ResupplyPoint extends Block{
Shapes.laser("transfer", "transfer-end",
x1, y1, entity.lastx, entity.lasty, entity.strength);
Draw.color("accent");
Draw.color(Palette.accent);
for(int i = 0; i < dstTo/space-1; i ++){
float fract = (i * space) / dstTo + ((Timers.time()/90f) % (space/dstTo));
Draw.alpha(Mathf.clamp(fract*1.5f));

View File

@ -4,11 +4,12 @@ import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.fx.BlockFx;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.entities.units.BaseUnit;
import io.anuke.mindustry.entities.units.UnitType;
import io.anuke.mindustry.content.fx.BlockFx;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.graphics.Shaders;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.ItemStack;
@ -79,7 +80,7 @@ public class UnitFactory extends Block {
Shaders.build.region = region;
Shaders.build.progress = entity.buildTime/produceTime;
Shaders.build.color.set(Colors.get("accent"));
Shaders.build.color.set(Palette.accent);
Shaders.build.color.a = entity.speedScl;
Shaders.build.time = -entity.time / 10f;
@ -88,7 +89,7 @@ public class UnitFactory extends Block {
Draw.rect(region, tile.drawx(), tile.drawy());
Graphics.shader();
Draw.color("accent");
Draw.color(Palette.accent);
Draw.alpha(entity.speedScl);
Lines.lineAngleCenter(