Arc compatibility update

This commit is contained in:
Anuken
2018-12-27 15:47:17 -05:00
parent 3b42b604e1
commit db546412f1
75 changed files with 255 additions and 285 deletions

2
.gitignore vendored
View File

@@ -14,7 +14,7 @@ logs/
/core/lib/ /core/lib/
/core/assets-raw/sprites/generated/ /core/assets-raw/sprites/generated/
/annotations/build/ /annotations/build/
/kryonet/build/ /net/build/
/tools/build/ /tools/build/
/tests/build/ /tests/build/
/server/build/ /server/build/

View File

@@ -31,13 +31,12 @@ dependencies {
implementation 'org.sufficientlysecure:donations:2.5' implementation 'org.sufficientlysecure:donations:2.5'
implementation 'com.google.android.gms:play-services-auth:16.0.1' implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion" implementation project(":Arc:backends:backend-android")
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"

View File

@@ -8,28 +8,28 @@ import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Core.settings.Secure; import android.provider.Settings.Secure;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.util.Log; import android.util.Log;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.Base64Coder;
import com.google.android.gms.common.GoogleApiAvailability; import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException; import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException; import com.google.android.gms.common.GooglePlayServicesRepairableException;
import com.google.android.gms.security.ProviderInstaller; import com.google.android.gms.security.ProviderInstaller;
import io.anuke.kryonet.KryoClient; import io.anuke.arc.Core;
import io.anuke.kryonet.KryoServer; import io.anuke.arc.backends.android.surfaceview.AndroidApplication;
import io.anuke.arc.backends.android.surfaceview.AndroidApplicationConfiguration;
import io.anuke.arc.files.FileHandle;
import io.anuke.arc.function.Consumer;
import io.anuke.arc.scene.ui.layout.Unit;
import io.anuke.arc.util.Strings;
import io.anuke.arc.util.serialization.Base64Coder;
import io.anuke.net.KryoClient;
import io.anuke.net.KryoServer;
import io.anuke.mindustry.core.Platform; import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.game.Saves.SaveSlot; import io.anuke.mindustry.game.Saves.SaveSlot;
import io.anuke.mindustry.io.SaveIO; import io.anuke.mindustry.io.SaveIO;
import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.ui.dialogs.FileChooser; import io.anuke.mindustry.ui.dialogs.FileChooser;
import io.anuke.arc.function.Consumer;
import io.anuke.arc.scene.ui.layout.Unit;
import io.anuke.arc.util.Bundles;
import io.anuke.arc.util.Strings;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@@ -39,7 +39,7 @@ import java.util.ArrayList;
import static io.anuke.mindustry.Vars.*; import static io.anuke.mindustry.Vars.*;
public class AndroidLauncher extends PatchedAndroidApplication{ public class AndroidLauncher extends AndroidApplication{
public static final int PERMISSION_REQUEST_CODE = 1; public static final int PERMISSION_REQUEST_CODE = 1;
boolean doubleScaleTablets = true; boolean doubleScaleTablets = true;
FileChooser chooser; FileChooser chooser;
@@ -161,10 +161,10 @@ public class AndroidLauncher extends PatchedAndroidApplication{
InputStream inStream; InputStream inStream;
if(myFile != null) inStream = new FileInputStream(myFile); if(myFile != null) inStream = new FileInputStream(myFile);
else inStream = getContentResolver().openInputStream(uri); else inStream = getContentResolver().openInputStream(uri);
Gdx.app.postRunnable(() -> { Core.app.post(() -> {
if(save){ //open save if(save){ //open save
System.out.println("Opening save."); System.out.println("Opening save.");
FileHandle file = Gdx.files.local("temp-save." + saveExtension); FileHandle file = Core.files.local("temp-save." + saveExtension);
file.write(inStream, false); file.write(inStream, false);
if(SaveIO.isSaveValid(file)){ if(SaveIO.isSaveValid(file)){
try{ try{
@@ -177,7 +177,7 @@ public class AndroidLauncher extends PatchedAndroidApplication{
ui.showError("$text.save.import.invalid"); ui.showError("$text.save.import.invalid");
} }
}else if(map){ //open map }else if(map){ //open map
Gdx.app.postRunnable(() -> { Core.app.post(() -> {
System.out.println("Opening map."); System.out.println("Opening map.");
if(!ui.editor.isShown()){ if(!ui.editor.isShown()){
ui.editor.show(); ui.editor.show();

View File

@@ -1,20 +0,0 @@
package io.anuke.mindustry;
import com.badlogic.gdx.backends.android.AndroidApplication;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public abstract class PatchedAndroidApplication extends AndroidApplication {
private final ExecutorService exec = Executors.newSingleThreadExecutor();
@Override
protected void onPause () {
if(useImmersiveMode) {
exec.submit(() -> {
try {Thread.sleep(100);} catch (InterruptedException ignored) {}
graphics.onDrawFrame(null);
});
}
super.onPause();
}
}

View File

@@ -89,6 +89,7 @@ project(":desktop"){
dependencies{ dependencies{
compile project(":core") compile project(":core")
compile project(":net") compile project(":net")
if(new File(projectDir.parent, '../debug').exists() && System.properties["release"] == null) compile project(":debug") if(new File(projectDir.parent, '../debug').exists() && System.properties["release"] == null) compile project(":debug")
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
@@ -145,11 +146,12 @@ project(":ios"){
dependencies{ dependencies{
compile project(":core") compile project(":core")
implementation project(":net") compile project(":net")
compile project(":Arc:backends:backend-robovm")
compile "com.mobidevelop.robovm:robovm-rt:$roboVMVersion" compile "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
compile "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion" compile "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios" compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios" compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
} }
@@ -185,11 +187,9 @@ project(":server"){
apply plugin: "java" apply plugin: "java"
dependencies{ dependencies{
compile project(":core") compile project(":core")
compile project(":net") compile project(":net")
compile "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion" compile project(":Arc:backends:backend-headless")
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
} }
} }
@@ -200,8 +200,7 @@ project(":tests"){
testImplementation project(":core") testImplementation project(":core")
testImplementation('org.junit.jupiter:junit-jupiter-api:5.1.0') testImplementation('org.junit.jupiter:junit-jupiter-api:5.1.0')
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.1.0') testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.1.0')
testImplementation "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion" compile project(":Arc:backends:backend-headless")
testImplementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
} }
test{ test{

View File

@@ -202,14 +202,14 @@ public class Mechs implements ContentList{
public void draw(Player player){ public void draw(Player player){
if(player.shootHeat <= 0.01f) return; if(player.shootHeat <= 0.01f) return;
float alpha = Core.graphics.batch().getColor().a; float alpha = Draw.getColor().a;
Shaders.build.progress = player.shootHeat; Shaders.build.progress = player.shootHeat;
Shaders.build.region = armorRegion; Shaders.build.region = armorRegion;
Shaders.build.time = Time.time() / 10f; Shaders.build.time = Time.time() / 10f;
Shaders.build.color.set(Palette.accent).a = player.shootHeat; Shaders.build.color.set(Palette.accent).a = player.shootHeat;
Draw.shader(Shaders.build); Draw.shader(Shaders.build);
Draw.alpha(1f); Draw.alpha(1f);
Draw.rect(armorRegion, player.snappedX(), player.snappedY()).rot(player.rotation); Draw.rect(armorRegion, player.snappedX(), player.snappedY(), player.rotation);
Draw.shader(Shaders.mix); Draw.shader(Shaders.mix);
Draw.color(1f, 1f, 1f, alpha); Draw.color(1f, 1f, 1f, alpha);
} }
@@ -268,11 +268,13 @@ public class Mechs implements ContentList{
public void draw(Player player){ public void draw(Player player){
float scl = scld(player); float scl = scld(player);
if(scl < 0.01f) return; if(scl < 0.01f) return;
float alpha = Core.graphics.batch().getColor().a; float alpha = Draw.getColor().a;
Draw.shader(); Draw.shader();
Draw.color(Palette.lancerLaser); Draw.color(Palette.lancerLaser);
Draw.alpha(scl/2f); Draw.alpha(scl/2f);
Draw.rect(shield, player.snappedX() + Mathf.range(scl/2f), player.snappedY() + Mathf.range(scl/2f)).rot(player.rotation - 90).blend(Blending.additive); Draw.blend(Blending.additive);
Draw.rect(shield, player.snappedX() + Mathf.range(scl/2f), player.snappedY() + Mathf.range(scl/2f), player.rotation - 90);
Draw.blend();
Draw.shader(Shaders.mix); Draw.shader(Shaders.mix);
Draw.color(); Draw.color();
Draw.alpha(alpha); Draw.alpha(alpha);

View File

@@ -58,7 +58,7 @@ public class TurretBlocks extends BlockList implements ContentList{
ammoUseEffect = ShootFx.shellEjectSmall; ammoUseEffect = ShootFx.shellEjectSmall;
health = 160; health = 160;
drawer = (tile, entity) -> Draw.rect(entity.target != null ? shootRegion : region, tile.drawx() + tr2.x, tile.drawy() + tr2.y).rot(entity.rotation - 90); drawer = (tile, entity) -> Draw.rect(entity.target != null ? shootRegion : region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
} }
}; };
@@ -74,11 +74,11 @@ public class TurretBlocks extends BlockList implements ContentList{
health = 360; health = 360;
drawer = (tile, entity) -> { drawer = (tile, entity) -> {
Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y).rot(entity.rotation - 90); Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
Draw.color(entity.liquids.current().color); Draw.color(entity.liquids.current().color);
Draw.alpha(entity.liquids.total() / liquidCapacity); Draw.alpha(entity.liquids.total() / liquidCapacity);
Draw.rect(name + "-liquid", tile.drawx() + tr2.x, tile.drawy() + tr2.y).rot(entity.rotation - 90).color(entity.liquids.current().color); Draw.rect(name + "-liquid", tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
Draw.color(); Draw.color();
}; };
}}; }};
@@ -157,7 +157,7 @@ public class TurretBlocks extends BlockList implements ContentList{
ammoUseEffect = ShootFx.shellEjectBig; ammoUseEffect = ShootFx.shellEjectBig;
drawer = (tile, entity) -> { drawer = (tile, entity) -> {
Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y).rot(entity.rotation - 90); Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
float offsetx = (int) (abscurve(Mathf.curve(entity.reload / reload, 0.3f, 0.2f)) * 3f); float offsetx = (int) (abscurve(Mathf.curve(entity.reload / reload, 0.3f, 0.2f)) * 3f);
float offsety = -(int) (abscurve(Mathf.curve(entity.reload / reload, 0.3f, 0.2f)) * 2f); float offsety = -(int) (abscurve(Mathf.curve(entity.reload / reload, 0.3f, 0.2f)) * 2f);
@@ -165,7 +165,7 @@ public class TurretBlocks extends BlockList implements ContentList{
float rot = entity.rotation + 90 * i; float rot = entity.rotation + 90 * i;
Draw.rect(panels[i == -1 ? 0 : 1], Draw.rect(panels[i == -1 ? 0 : 1],
tile.drawx() + tr2.x + Angles.trnsx(rot, offsetx, offsety), tile.drawx() + tr2.x + Angles.trnsx(rot, offsetx, offsety),
tile.drawy() + tr2.y + Angles.trnsy(rot, -offsetx, offsety)).rot(entity.rotation - 90); tile.drawy() + tr2.y + Angles.trnsy(rot, -offsetx, offsety), entity.rotation - 90);
} }
}; };

View File

@@ -346,10 +346,10 @@ public class TurretBullets extends BulletList implements ContentList{
float w = 11f, h = 13f; float w = 11f, h = 13f;
Draw.color(Palette.bulletYellowBack); Draw.color(Palette.bulletYellowBack);
Draw.rect("shell-back", b.x, b.y, w, h).rot(b.angle() + 90); Draw.rect("shell-back", b.x, b.y, w, h, b.angle() + 90);
Draw.color(Palette.bulletYellow); Draw.color(Palette.bulletYellow);
Draw.rect("shell", b.x, b.y, w, h).rot(b.angle() + 90); Draw.rect("shell", b.x, b.y, w, h, b.angle() + 90);
Draw.reset(); Draw.reset();
} }

View File

@@ -1,5 +1,6 @@
package io.anuke.mindustry.content.fx; package io.anuke.mindustry.content.fx;
import io.anuke.arc.Core;
import io.anuke.arc.entities.Effects.Effect; import io.anuke.arc.entities.Effects.Effect;
import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.Color;
import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.Draw;
@@ -108,10 +109,9 @@ public class ShootFx extends FxList implements ContentList{
float len = (2f + e.finpow() * 6f) * i; float len = (2f + e.finpow() * 6f) * i;
float lr = rot + e.fin() * 30f * i; float lr = rot + e.fin() * 30f * i;
Draw.rect("white", Fill.rect(e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()),
e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()),
e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()), e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()),
1f, 2f).rot(rot + e.fin() * 50f * i); 1f, 2f, rot + e.fin() * 50f * i);
Draw.color(); Draw.color();
}); });
@@ -122,10 +122,10 @@ public class ShootFx extends FxList implements ContentList{
for(int i : Mathf.signs){ for(int i : Mathf.signs){
float len = (2f + e.finpow() * 10f) * i; float len = (2f + e.finpow() * 10f) * i;
float lr = rot + e.fin() * 20f * i; float lr = rot + e.fin() * 20f * i;
Draw.rect("casing", Draw.rect(Core.atlas.find("casing"),
e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()), e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()),
e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()), e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()),
2f, 3f).rot(rot); 2f, 3f, rot);
} }
Draw.color(Color.LIGHT_GRAY, Color.GRAY, e.fin()); Draw.color(Color.LIGHT_GRAY, Color.GRAY, e.fin());
@@ -145,11 +145,11 @@ public class ShootFx extends FxList implements ContentList{
for(int i : Mathf.signs){ for(int i : Mathf.signs){
float len = (4f + e.finpow() * 8f) * i; float len = (4f + e.finpow() * 8f) * i;
float lr = rot + Mathf.randomSeedRange(e.id + i + 6, 20f * e.fin()) * i; float lr = rot + Mathf.randomSeedRange(e.id + i + 6, 20f * e.fin()) * i;
Draw.rect("casing", Draw.rect(Core.atlas.find("casing"),
e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()), e.x + Angles.trnsx(lr, len) + Mathf.randomSeedRange(e.id + i + 7, 3f * e.fin()),
e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()), e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()),
2.5f, 4f) 2.5f, 4f,
.rot(rot + e.fin() * 30f * i + Mathf.randomSeedRange(e.id + i + 9, 40f * e.fin())); rot + e.fin() * 30f * i + Mathf.randomSeedRange(e.id + i + 9, 40f * e.fin()));
} }
Draw.color(Color.LIGHT_GRAY); Draw.color(Color.LIGHT_GRAY);

View File

@@ -50,7 +50,6 @@ public class Control implements ApplicationListener{
private boolean hiscore = false; private boolean hiscore = false;
private boolean wasPaused = false; private boolean wasPaused = false;
private InputHandler[] inputs = {}; private InputHandler[] inputs = {};
private Throwable error;
public Control(){ public Control(){
saves = new Saves(); saves = new Saves();
@@ -206,10 +205,6 @@ public class Control implements ApplicationListener{
System.arraycopy(oldi, 0, inputs, 0, inputs.length); System.arraycopy(oldi, 0, inputs, 0, inputs.length);
} }
public void setError(Throwable error){
this.error = error;
}
public InputHandler input(int index){ public InputHandler input(int index){
return inputs[index]; return inputs[index];
} }
@@ -308,9 +303,6 @@ public class Control implements ApplicationListener{
@Override @Override
public void update(){ public void update(){
if(error != null){
throw new RuntimeException(error);
}
saves.update(); saves.update();

View File

@@ -14,6 +14,7 @@ import io.anuke.arc.graphics.Camera;
import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.Color;
import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.graphics.g2d.Lines; import io.anuke.arc.graphics.g2d.Lines;
import io.anuke.arc.graphics.g2d.SpriteBatch;
import io.anuke.arc.math.Mathf; import io.anuke.arc.math.Mathf;
import io.anuke.arc.math.geom.Rectangle; import io.anuke.arc.math.geom.Rectangle;
import io.anuke.arc.math.geom.Vector2; import io.anuke.arc.math.geom.Vector2;
@@ -30,7 +31,7 @@ import io.anuke.mindustry.entities.units.BaseUnit;
import io.anuke.mindustry.game.Team; import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.graphics.*; import io.anuke.mindustry.graphics.*;
import static io.anuke.arc.Core.camera; import static io.anuke.arc.Core.*;
import static io.anuke.arc.Core.graphics; import static io.anuke.arc.Core.graphics;
import static io.anuke.mindustry.Vars.*; import static io.anuke.mindustry.Vars.*;
@@ -45,6 +46,7 @@ public class Renderer implements ApplicationListener{
private Vector2 avgPosition = new Vector2(); private Vector2 avgPosition = new Vector2();
public Renderer(){ public Renderer(){
batch = new SpriteBatch(4096);
camera = new Camera(); camera = new Camera();
Lines.setCircleVertices(14); Lines.setCircleVertices(14);
@@ -146,7 +148,7 @@ public class Renderer implements ApplicationListener{
graphics.clear(clearColor); graphics.clear(clearColor);
graphics.batch().setProjection(camera.projection()); Draw.proj(camera.projection());
blocks.drawFloor(); blocks.drawFloor();

View File

@@ -11,6 +11,7 @@ import io.anuke.arc.function.Consumer;
import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.Color;
import io.anuke.arc.graphics.Colors; import io.anuke.arc.graphics.Colors;
import io.anuke.arc.graphics.g2d.BitmapFont; import io.anuke.arc.graphics.g2d.BitmapFont;
import io.anuke.arc.graphics.g2d.Draw;
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.scene.Group; import io.anuke.arc.scene.Group;
@@ -81,6 +82,7 @@ public class UI implements ApplicationListener{
} }
Core.scene = new Scene(skin); Core.scene = new Scene(skin);
Core.input.addProcessor(Core.scene);
Dialog.setShowAction(() -> sequence( Dialog.setShowAction(() -> sequence(
alpha(0f), alpha(0f),
@@ -142,7 +144,7 @@ public class UI implements ApplicationListener{
Core.scene.act(); Core.scene.act();
Core.scene.draw(); Core.scene.draw();
Core.graphics.batch().flush(); Draw.flush();
} }
@Override @Override

View File

@@ -79,7 +79,7 @@ public class MapRenderer implements Disposable{
} }
mesh.getTransformMatrix().setToTranslation(tx, ty).scale(tw / (width * tilesize), th / (height * tilesize)); mesh.getTransformMatrix().setToTranslation(tx, ty).scale(tw / (width * tilesize), th / (height * tilesize));
mesh.setProjectionMatrix(Core.graphics.batch().getProjection()); mesh.setProjectionMatrix(Draw.proj());
mesh.render(Core.atlas.getTextures().first()); mesh.render(Core.atlas.getTextures().first());
} }

View File

@@ -288,7 +288,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
float x = snappedX(), y = snappedY(); float x = snappedX(), y = snappedY();
float scl = mech.flying ? 1f : boostHeat / 2f; float scl = mech.flying ? 1f : boostHeat / 2f;
Draw.rect(mech.iconRegion, x + offsetX * scl, y + offsetY * scl).rot(rotation - 90); Draw.rect(mech.iconRegion, x + offsetX * scl, y + offsetY * scl, rotation - 90);
} }
@Override @Override
@@ -322,10 +322,10 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
Draw.rect(mech.legRegion, Draw.rect(mech.legRegion,
x + Angles.trnsx(baseRotation, ft * i + boostTrnsY, -boostTrnsX * i), x + Angles.trnsx(baseRotation, ft * i + boostTrnsY, -boostTrnsX * i),
y + Angles.trnsy(baseRotation, ft * i + boostTrnsY, -boostTrnsX * i), y + Angles.trnsy(baseRotation, ft * i + boostTrnsY, -boostTrnsX * i),
mech.legRegion.getWidth() * i, mech.legRegion.getHeight() - Mathf.clamp(ft * i, 0, 2)).rot(baseRotation - 90 + boostAng * i); mech.legRegion.getWidth() * i, mech.legRegion.getHeight() - Mathf.clamp(ft * i, 0, 2), baseRotation - 90 + boostAng * i);
} }
Draw.rect(mech.baseRegion, x, y).rot(baseRotation - 90); Draw.rect(mech.baseRegion, x, y, baseRotation - 90);
} }
if(floor.isLiquid){ if(floor.isLiquid){
@@ -334,7 +334,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
Draw.tint(Color.WHITE); Draw.tint(Color.WHITE);
} }
Draw.rect(mech.region, x, y).rot(rotation - 90); Draw.rect(mech.region, x, y, rotation - 90);
mech.draw(this); mech.draw(this);
@@ -343,7 +343,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
float w = i > 0 ? -mech.weapon.equipRegion.getWidth() : mech.weapon.equipRegion.getWidth(); float w = i > 0 ? -mech.weapon.equipRegion.getWidth() : mech.weapon.equipRegion.getWidth();
Draw.rect(mech.weapon.equipRegion, Draw.rect(mech.weapon.equipRegion,
x + Angles.trnsx(tra, (mech.weaponOffsetX + mech.spreadX(this)) * i, trY), x + Angles.trnsx(tra, (mech.weaponOffsetX + mech.spreadX(this)) * i, trY),
y + Angles.trnsy(tra, (mech.weaponOffsetX + mech.spreadX(this)) * i, trY), w, mech.weapon.equipRegion.getHeight()).rot(rotation - 90); y + Angles.trnsy(tra, (mech.weaponOffsetX + mech.spreadX(this)) * i, trY), w, mech.weapon.equipRegion.getHeight(), rotation - 90);
} }
float backTrns = 4f, itemSize = 5f; float backTrns = 4f, itemSize = 5f;
@@ -357,7 +357,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
Draw.rect(stack.item.region, Draw.rect(stack.item.region,
x + Angles.trnsx(rotation + 180f + angT, backTrns + lenT), x + Angles.trnsx(rotation + 180f + angT, backTrns + lenT),
y + Angles.trnsy(rotation + 180f + angT, backTrns + lenT), y + Angles.trnsy(rotation + 180f + angT, backTrns + lenT),
itemSize, itemSize).rot(rotation); itemSize, itemSize, rotation);
} }
} }
@@ -370,7 +370,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
Draw.color(Color.BLACK, team.color, healthf() + Mathf.absin(Time.time(), healthf() * 5f, 1f - healthf())); Draw.color(Color.BLACK, team.color, healthf() + Mathf.absin(Time.time(), healthf() * 5f, 1f - healthf()));
Draw.alpha(hitTime / hitDuration); Draw.alpha(hitTime / hitDuration);
Draw.rect(getPowerCellRegion(), x + Angles.trnsx(rotation, mech.cellTrnsY, 0f), y + Angles.trnsy(rotation, mech.cellTrnsY, 0f)).rot(rotation - 90); Draw.rect(getPowerCellRegion(), x + Angles.trnsx(rotation, mech.cellTrnsY, 0f), y + Angles.trnsy(rotation, mech.cellTrnsY, 0f), rotation - 90);
Draw.color(); Draw.color();
} }
@@ -406,7 +406,9 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
font.setUseIntegerPositions(false); font.setUseIntegerPositions(false);
font.getData().setScale(0.25f / io.anuke.arc.scene.ui.layout.Unit.dp.scl(1f)); font.getData().setScale(0.25f / io.anuke.arc.scene.ui.layout.Unit.dp.scl(1f));
layout.setText(font, name); layout.setText(font, name);
Fill.rect().center(x, y + 8 - layout.height / 2, layout.width + 2, layout.height + 3).color(0f, 0f, 0f, 0.3f); Draw.color(0f, 0f, 0f, 0.3f);
Fill.rect(x, y + 8 - layout.height / 2, layout.width + 2, layout.height + 3);
Draw.color();
font.setColor(color); font.setColor(color);
font.draw(name, x, y + 8, 0, Align.center, false); font.draw(name, x, y + 8, 0, Align.center, false);
@@ -414,9 +416,9 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
if(isAdmin){ if(isAdmin){
float s = 3f; float s = 3f;
Draw.color(color.r * 0.5f, color.g * 0.5f, color.b * 0.5f, 1f); Draw.color(color.r * 0.5f, color.g * 0.5f, color.b * 0.5f, 1f);
Draw.rect("icon-admin-small", x + layout.width / 2f + 2 + 1, y + 6.5f, s, s); Draw.rect(Core.atlas.find("icon-admin-small"), x + layout.width / 2f + 2 + 1, y + 6.5f, s, s);
Draw.color(color); Draw.color(color);
Draw.rect("icon-admin-small", x + layout.width / 2f + 2 + 1, y + 7f, s, s); Draw.rect(Core.atlas.find("icon-admin-small"), x + layout.width / 2f + 2 + 1, y + 7f, s, s);
} }
Draw.reset(); Draw.reset();

View File

@@ -320,7 +320,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
public void drawStats(){ public void drawStats(){
Draw.color(Color.BLACK, team.color, healthf() + Mathf.absin(Time.time(), healthf()*5f, 1f - healthf())); Draw.color(Color.BLACK, team.color, healthf() + Mathf.absin(Time.time(), healthf()*5f, 1f - healthf()));
Draw.alpha(hitTime); Draw.alpha(hitTime);
Draw.rect(getPowerCellRegion(), x, y).rot(rotation - 90); Draw.rect(getPowerCellRegion(), x, y, rotation - 90);
Draw.color(); Draw.color();
} }
@@ -336,7 +336,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
} }
public void drawShadow(float offsetX, float offsetY){ public void drawShadow(float offsetX, float offsetY){
Draw.rect(getIconRegion(), x + offsetX, y + offsetY).rot(rotation - 90); Draw.rect(getIconRegion(), x + offsetX, y + offsetY, rotation - 90);
} }
public void drawView(){ public void drawView(){

View File

@@ -34,9 +34,9 @@ public class ArtilleryBulletType extends BasicBulletType{
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout()); float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
Draw.color(backColor); Draw.color(backColor);
Draw.rect(backRegion, b.x, b.y, bulletWidth * scale, height * scale).rot(b.angle() - 90); Draw.rect(backRegion, b.x, b.y, bulletWidth * scale, height * scale, b.angle() - 90);
Draw.color(frontColor); Draw.color(frontColor);
Draw.rect(frontRegion, b.x, b.y, bulletWidth * scale, height * scale).rot(b.angle() - 90); Draw.rect(frontRegion, b.x, b.y, bulletWidth * scale, height * scale, b.angle() - 90);
Draw.color(); Draw.color();
} }
} }

View File

@@ -57,9 +57,9 @@ public class BasicBulletType extends BulletType{
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout()); float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
Draw.color(backColor); Draw.color(backColor);
Draw.rect(backRegion, b.x, b.y, bulletWidth, height).rot(b.angle() - 90); Draw.rect(backRegion, b.x, b.y, bulletWidth, height, b.angle() - 90);
Draw.color(frontColor); Draw.color(frontColor);
Draw.rect(frontRegion, b.x, b.y, bulletWidth, height).rot(b.angle() - 90); Draw.rect(frontRegion, b.x, b.y, bulletWidth, height, b.angle() - 90);
Draw.color(); Draw.color();
} }

View File

@@ -26,6 +26,6 @@ public class RubbleDecal extends Decal{
return; return;
} }
Draw.rect(region, x, y).rot(Mathf.randomSeed(id, 0, 4) * 90); Draw.rect(region, x, y, Mathf.randomSeed(id, 0, 4) * 90);
} }
} }

View File

@@ -36,8 +36,7 @@ public class ScorchDecal extends Decal{
TextureRegion region = regions[Mathf.randomSeed(id - i, 0, scorches - 1)]; TextureRegion region = regions[Mathf.randomSeed(id - i, 0, scorches - 1)];
float rotation = Mathf.randomSeed(id + i, 0, 360); float rotation = Mathf.randomSeed(id + i, 0, 360);
float space = 1.5f + Mathf.randomSeed(id + i + 1, 0, 20) / 10f; float space = 1.5f + Mathf.randomSeed(id + i + 1, 0, 20) / 10f;
Draw.rect(region, x + Angles.trnsx(rotation, space), y + Angles.trnsy(rotation, space) + region.getHeight()/2f) Draw.rect(region, x + Angles.trnsx(rotation, space), y + Angles.trnsy(rotation, space) + region.getHeight()/2f, region.getWidth()/2f, 0, rotation - 90);
.origin(region.getWidth()/2f, 0).rot(rotation - 90);
} }
} }
} }

View File

@@ -216,7 +216,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
Draw.rect(stack.item.region, Draw.rect(stack.item.region,
x + Angles.trnsx(rotation + 180f + angT, backTrns + lenT), x + Angles.trnsx(rotation + 180f + angT, backTrns + lenT),
y + Angles.trnsy(rotation + 180f + angT, backTrns + lenT), y + Angles.trnsy(rotation + 180f + angT, backTrns + lenT),
itemSize, itemSize).rot(rotation); itemSize, itemSize, rotation);
} }
} }
} }

View File

@@ -164,7 +164,7 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
public void draw(){ public void draw(){
Draw.alpha(hitTime / hitDuration); Draw.alpha(hitTime / hitDuration);
Draw.rect(type.name, x, y).rot(rotation - 90); Draw.rect(type.name, x, y, rotation - 90);
drawItems(); drawItems();

View File

@@ -154,7 +154,7 @@ public abstract class GroundUnit extends BaseUnit{
Draw.rect(type.legRegion, Draw.rect(type.legRegion,
x + Angles.trnsx(baseRotation, ft * i), x + Angles.trnsx(baseRotation, ft * i),
y + Angles.trnsy(baseRotation, ft * i), y + Angles.trnsy(baseRotation, ft * i),
12f * i, 12f - Mathf.clamp(ft * i, 0, 2)).rot(baseRotation - 90); 12f * i, 12f - Mathf.clamp(ft * i, 0, 2), baseRotation - 90);
} }
if(floor.isLiquid){ if(floor.isLiquid){
@@ -163,16 +163,16 @@ public abstract class GroundUnit extends BaseUnit{
Draw.tint(Color.WHITE); Draw.tint(Color.WHITE);
} }
Draw.rect(type.baseRegion, x, y).rot(baseRotation - 90); Draw.rect(type.baseRegion, x, y, baseRotation - 90);
Draw.rect(type.region, x, y).rot(rotation - 90); Draw.rect(type.region, x, y, rotation - 90);
for(int i : Mathf.signs){ for(int i : Mathf.signs){
float tra = rotation - 90, trY = -weapon.getRecoil(this, i > 0) + type.weaponOffsetY; float tra = rotation - 90, trY = -weapon.getRecoil(this, i > 0) + type.weaponOffsetY;
float w = i > 0 ? -12 : 12; float w = i > 0 ? -12 : 12;
Draw.rect(weapon.equipRegion, Draw.rect(weapon.equipRegion,
x + Angles.trnsx(tra, type.weaponOffsetX * i, trY), x + Angles.trnsx(tra, type.weaponOffsetX * i, trY),
y + Angles.trnsy(tra, type.weaponOffsetX * i, trY), w, 12).rot(rotation - 90); y + Angles.trnsy(tra, type.weaponOffsetX * i, trY), w, 12, rotation - 90);
} }
drawItems(); drawItems();

View File

@@ -142,7 +142,7 @@ public class Saves{
IntArray result = new IntArray(saves.size); IntArray result = new IntArray(saves.size);
for(int i = 0; i < saves.size; i++) result.add(saves.get(i).index); for(int i = 0; i < saves.size; i++) result.add(saves.get(i).index);
Core.settings.put("save-slots", result); Core.settings.putObject("save-slots", result);
Core.settings.save(); Core.settings.save();
} }

View File

@@ -1,6 +1,5 @@
package io.anuke.mindustry.graphics; package io.anuke.mindustry.graphics;
import io.anuke.arc.Core;
import io.anuke.arc.Events; import io.anuke.arc.Events;
import io.anuke.arc.collection.Array; import io.anuke.arc.collection.Array;
import io.anuke.arc.collection.IntSet; import io.anuke.arc.collection.IntSet;
@@ -58,7 +57,7 @@ public class BlockRenderer{
public void drawShadows(){ public void drawShadows(){
Draw.color(0, 0, 0, 0.15f); Draw.color(0, 0, 0, 0.15f);
Draw.rect().tex(shadows.getTexture()).center( Draw.rect(Draw.wrap(shadows.getTexture()),
camera.position.x - camera.position.x % tilesize, camera.position.x - camera.position.x % tilesize,
camera.position.y - camera.position.y % tilesize, camera.position.y - camera.position.y % tilesize,
shadows.getWidth(), -shadows.getHeight()); shadows.getWidth(), -shadows.getHeight());
@@ -90,7 +89,7 @@ public class BlockRenderer{
requestidx = 0; requestidx = 0;
Draw.flush(); Draw.flush();
Core.graphics.batch().getProjection() Draw.proj()
.setOrtho(Mathf.round(camera.position.x, tilesize)-shadowW/2f, Mathf.round(camera.position.y, tilesize)-shadowH/2f, .setOrtho(Mathf.round(camera.position.x, tilesize)-shadowW/2f, Mathf.round(camera.position.y, tilesize)-shadowH/2f,
shadowW, shadowH); shadowW, shadowH);
@@ -141,7 +140,7 @@ public class BlockRenderer{
shadows.end(); shadows.end();
Draw.flush(); Draw.flush();
Draw.projection(camera.projection()); Draw.proj(camera.projection());
Sort.instance().sort(requests.items, 0, requestidx); Sort.instance().sort(requests.items, 0, requestidx);

View File

@@ -7,11 +7,9 @@ import io.anuke.arc.collection.IntSet;
import io.anuke.arc.collection.IntSet.IntSetIterator; import io.anuke.arc.collection.IntSet.IntSetIterator;
import io.anuke.arc.collection.ObjectSet; import io.anuke.arc.collection.ObjectSet;
import io.anuke.arc.graphics.Camera; import io.anuke.arc.graphics.Camera;
import io.anuke.arc.graphics.Color;
import io.anuke.arc.graphics.GL20; import io.anuke.arc.graphics.GL20;
import io.anuke.arc.graphics.g2d.CacheBatch; import io.anuke.arc.graphics.g2d.CacheBatch;
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.SpriteBatch; import io.anuke.arc.graphics.g2d.SpriteBatch;
import io.anuke.arc.math.Mathf; import io.anuke.arc.math.Mathf;
import io.anuke.arc.util.Log; import io.anuke.arc.util.Log;
@@ -145,12 +143,6 @@ public class FloorRenderer{
layer.end(); layer.end();
} }
private void fillChunk(float x, float y){
Draw.color(Color.BLACK);
Fill.rect().set(x, y, chunksize * tilesize, chunksize * tilesize);
Draw.color();
}
private void cacheChunk(int cx, int cy){ private void cacheChunk(int cx, int cy){
Chunk chunk = cache[cx][cy]; Chunk chunk = cache[cx][cy];
@@ -174,8 +166,10 @@ public class FloorRenderer{
} }
private void cacheChunkLayer(int cx, int cy, Chunk chunk, CacheLayer layer){ private void cacheChunkLayer(int cx, int cy, Chunk chunk, CacheLayer layer){
SpriteBatch current = Core.graphics.batch(); SpriteBatch current = Core.batch;
Core.graphics.useBatch(cbatch); Core.batch = cbatch;
cbatch.beginCache();
for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize; tilex++){ for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize; tilex++){
for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize; tiley++){ for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize; tiley++){
@@ -195,8 +189,8 @@ public class FloorRenderer{
} }
} }
} }
Core.graphics.useBatch(current); Core.batch = current;
chunk.caches[layer.ordinal()] = cbatch.flushCache(); chunk.caches[layer.ordinal()] = cbatch.endCache();
} }
public void clearTiles(){ public void clearTiles(){

View File

@@ -8,6 +8,7 @@ import io.anuke.arc.graphics.Pixmap.Format;
import io.anuke.arc.graphics.Pixmaps; import io.anuke.arc.graphics.Pixmaps;
import io.anuke.arc.graphics.Texture; import io.anuke.arc.graphics.Texture;
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.ScissorStack; import io.anuke.arc.graphics.g2d.ScissorStack;
import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.arc.math.Mathf; import io.anuke.arc.math.Mathf;
@@ -81,7 +82,7 @@ public class MinimapRenderer implements Disposable{
for(Unit unit : units){ for(Unit unit : units){
float rx = (unit.x - rect.x) / rect.width * w, ry = (unit.y - rect.y) / rect.width * h; float rx = (unit.x - rect.x) / rect.width * w, ry = (unit.y - rect.y) / rect.width * h;
Draw.color(unit.getTeam().color); Draw.color(unit.getTeam().color);
Draw.rect().tex(Core.atlas.white()).set(x + rx, y + ry, w / (sz * 2), h / (sz * 2)); Fill.crect(x + rx, y + ry, w / (sz * 2), h / (sz * 2));
} }
Draw.color(); Draw.color();

View File

@@ -26,14 +26,13 @@ public class Shapes{
TextureRegion region = Core.atlas.find(edge); TextureRegion region = Core.atlas.find(edge);
Draw.rect(edge, x, y, region.getWidth() * Draw.scl, region.getHeight() * scale * Draw.scl).rot(rotation + 180); Draw.rect(Core.atlas.find(edge), x, y, region.getWidth() * Draw.scl, region.getHeight() * scale * Draw.scl, rotation + 180);
Draw.rect(edge, x2, y2, region.getWidth() * Draw.scl, region.getHeight() * scale * Draw.scl).rot(rotation); Draw.rect(Core.atlas.find(edge), x2, y2, region.getWidth() * Draw.scl, region.getHeight() * scale * Draw.scl, rotation);
} }
public static void tri(float x, float y, float width, float length, float rotation){ public static void tri(float x, float y, float width, float length, float rotation){
float oy = 17f / 63f * length; float oy = 17f / 63f * length;
Core.graphics.batch().draw().tex(Core.atlas.find("shape-3")).pos(x - width / 2f, y - oy) Draw.rect(Core.atlas.find("shape-3"), x, y - oy + length/2f, width, length, width / 2f, oy, rotation - 90);
.origin(width / 2f, oy).size(width, length).rot(rotation - 90);
} }
} }

View File

@@ -49,7 +49,7 @@ public class DesktopInput extends InputHandler{
for(TextureRegion region : regions){ for(TextureRegion region : regions){
Draw.rect(region, x * tilesize + block.offset(), y * tilesize + block.offset(), Draw.rect(region, x * tilesize + block.offset(), y * tilesize + block.offset(),
region.getWidth() * selectScale, region.getHeight() * selectScale).rot(block.rotate ? rotation * 90 : 0); region.getWidth() * selectScale, region.getHeight() * selectScale, block.rotate ? rotation * 90 : 0);
} }
}else{ }else{
Draw.color(Palette.removeBack); Draw.color(Palette.removeBack);
@@ -79,8 +79,10 @@ public class DesktopInput extends InputHandler{
if(i + recipe.result.size > result.getLength() && recipe.result.rotate){ if(i + recipe.result.size > result.getLength() && recipe.result.rotate){
Draw.color(!validPlace(x, y, recipe.result, result.rotation) ? Palette.remove : Palette.placeRotate); Draw.color(!validPlace(x, y, recipe.result, result.rotation) ? Palette.remove : Palette.placeRotate);
Draw.rect("place-arrow", x * tilesize + recipe.result.offset(), Draw.rect(Core.atlas.find("place-arrow"), x * tilesize + recipe.result.offset(),
y * tilesize + recipe.result.offset()).origin(x * tilesize + recipe.result.offset()/2f, 0f).rot(result.rotation * 90 - 90); y * tilesize + recipe.result.offset(),
Core.atlas.find("place-arrow").getWidth() * Draw.scl, Core.atlas.find("place-arrow").getHeight() * Draw.scl,
x * tilesize + recipe.result.offset()/2f, 0f, result.rotation * 90 - 90);
} }
drawPlace(x, y, recipe.result, result.rotation); drawPlace(x, y, recipe.result, result.rotation);
@@ -111,8 +113,11 @@ public class DesktopInput extends InputHandler{
}else if(isPlacing()){ }else if(isPlacing()){
if(recipe.result.rotate){ if(recipe.result.rotate){
Draw.color(!validPlace(cursorX, cursorY, recipe.result, rotation) ? Palette.remove : Palette.placeRotate); Draw.color(!validPlace(cursorX, cursorY, recipe.result, rotation) ? Palette.remove : Palette.placeRotate);
Draw.rect("place-arrow", cursorX * tilesize + recipe.result.offset(), Draw.rect(Core.atlas.find("place-arrow"), cursorX * tilesize + recipe.result.offset(),
cursorY * tilesize + recipe.result.offset()).origin(cursorX * tilesize + recipe.result.offset()/2f, 0).rot(rotation * 90 - 90); cursorY * tilesize + recipe.result.offset(),
Core.atlas.find("place-arrow").getWidth() * Draw.scl,
Core.atlas.find("place-arrow").getHeight() * Draw.scl,
cursorX * tilesize + recipe.result.offset()/2f, 0, rotation * 90 - 90);
} }
drawPlace(cursorX, cursorY, recipe.result, rotation); drawPlace(cursorX, cursorY, recipe.result, rotation);
recipe.result.drawPlace(cursorX, cursorY, rotation, validPlace(cursorX, cursorY, recipe.result, rotation)); recipe.result.drawPlace(cursorX, cursorY, rotation, validPlace(cursorX, cursorY, recipe.result, rotation));

View File

@@ -178,8 +178,8 @@ public class MobileInput extends InputHandler implements GestureListener{
for(TextureRegion region : regions){ for(TextureRegion region : regions){
Draw.rect(region, tile.worldx() + offset, tile.worldy() + offset, Draw.rect(region, tile.worldx() + offset, tile.worldy() + offset,
region.getWidth() * request.scale, region.getHeight() * request.scale) region.getWidth() * request.scale, region.getHeight() * request.scale,
.rot(request.recipe.result.rotate ? request.rotation * 90 : 0); request.recipe.result.rotate ? request.rotation * 90 : 0);
} }
}else{ }else{
float rad = (tile.block().size * tilesize / 2f - 1) * request.scale; float rad = (tile.block().size * tilesize / 2f - 1) * request.scale;
@@ -346,8 +346,7 @@ public class MobileInput extends InputHandler implements GestureListener{
for(TextureRegion region : regions){ for(TextureRegion region : regions){
Draw.rect(region, x * tilesize + recipe.result.offset(), y * tilesize + recipe.result.offset(), Draw.rect(region, x * tilesize + recipe.result.offset(), y * tilesize + recipe.result.offset(),
region.getWidth() * lineScale, region.getHeight() * lineScale) region.getWidth() * lineScale, region.getHeight() * lineScale, recipe.result.rotate ? result.rotation * 90 : 0);
.rot(recipe.result.rotate ? result.rotation * 90 : 0);
} }
}else{ }else{
Draw.color(Palette.removeBack); Draw.color(Palette.removeBack);

View File

@@ -42,18 +42,18 @@ public class BlockLocMission extends Mission{
if(block.rotate){ if(block.rotate){
Draw.colorl(0.4f); Draw.colorl(0.4f);
Draw.rect("icon-arrow", x * tilesize + block.offset(), y * tilesize + block.offset() - 1f).rot(rotation*90); Draw.rect(Core.atlas.find("icon-arrow"), x * tilesize + block.offset(), y * tilesize + block.offset() - 1f, rotation*90);
Draw.colorl(0.6f); Draw.colorl(0.6f);
Draw.rect("icon-arrow", x * tilesize + block.offset(), y * tilesize + block.offset()).rot(rotation*90); Draw.rect(Core.atlas.find("icon-arrow"), x * tilesize + block.offset(), y * tilesize + block.offset(), rotation*90);
} }
float rot = players[0].angleTo(x * tilesize + block.offset(), y * tilesize + block.offset()); float rot = players[0].angleTo(x * tilesize + block.offset(), y * tilesize + block.offset());
float len = 12f; float len = 12f;
Draw.color(Palette.accentBack); Draw.color(Palette.accentBack);
Draw.rect("icon-arrow", players[0].x + Angles.trnsx(rot, len), players[0].y + Angles.trnsy(rot, len)).rot(rot); Draw.rect(Core.atlas.find("icon-arrow"), players[0].x + Angles.trnsx(rot, len), players[0].y + Angles.trnsy(rot, len), rot);
Draw.color(Palette.accent); Draw.color(Palette.accent);
Draw.rect("icon-arrow", players[0].x + Angles.trnsx(rot, len), players[0].y + Angles.trnsy(rot, len) + 1f).rot(rot); Draw.rect(Core.atlas.find("icon-arrow"), players[0].x + Angles.trnsx(rot, len), players[0].y + Angles.trnsy(rot, len) + 1f, rot);
Draw.reset(); Draw.reset();
} }

View File

@@ -23,11 +23,11 @@ public class GridImage extends Element{
int jumpy = (int) (Math.max(minspace, yspace) / yspace); int jumpy = (int) (Math.max(minspace, yspace) / yspace);
for(int x = 0; x <= imageWidth; x += jumpx){ for(int x = 0; x <= imageWidth; x += jumpx){
Fill.rect().set((int) (getX() + xspace * x - s), getY() - s, 2, getHeight() + (x == imageWidth ? 1 : 0)); Fill.crect((int) (getX() + xspace * x - s), getY() - s, 2, getHeight() + (x == imageWidth ? 1 : 0));
} }
for(int y = 0; y <= imageHeight; y += jumpy){ for(int y = 0; y <= imageHeight; y += jumpy){
Fill.rect().set(getX() - s, (int) (getY() + y * yspace - s), getWidth(), 2); Fill.crect(getX() - s, (int) (getY() + y * yspace - s), getWidth(), 2);
} }
} }

View File

@@ -18,7 +18,7 @@ public class Minimap extends Container<Element>{
public void draw(){ public void draw(){
if(renderer.minimap.getRegion() == null) return; if(renderer.minimap.getRegion() == null) return;
Draw.rect().tex(renderer.minimap.getRegion()).set(x, y, width, height); Draw.rect(renderer.minimap.getRegion(), x + width/2f, y + height/2f, width, height);
if(renderer.minimap.getTexture() != null){ if(renderer.minimap.getTexture() != null){
renderer.minimap.drawEntities(x, y, width, height); renderer.minimap.drawEntities(x, y, width, height);

View File

@@ -99,7 +99,7 @@ public class GenViewDialog extends FloatingDialog{
float drawX = x + width/2f+ wx * padSectorSize - tx * padSectorSize - panX % padSectorSize; float drawX = x + width/2f+ wx * padSectorSize - tx * padSectorSize - panX % padSectorSize;
float drawY = y + height/2f + wy * padSectorSize - ty * padSectorSize - panY % padSectorSize; float drawY = y + height/2f + wy * padSectorSize - ty * padSectorSize - panY % padSectorSize;
Draw.rect().tex(map.get(wx, wy)).set(drawX, drawY, padSectorSize, padSectorSize); Draw.rect(Draw.wrap(map.get(wx, wy)), drawX + padSectorSize/2f, drawY + padSectorSize/2f, padSectorSize, padSectorSize);
} }
} }
} }

View File

@@ -202,13 +202,13 @@ public class SectorsDialog extends FloatingDialog{
if(sector == null || sector.texture == null){ if(sector == null || sector.texture == null){
Draw.reset(); Draw.reset();
Draw.rect("empty-sector", drawX, drawY, sectorSize, sectorSize); Draw.rect(("empty-sector"), drawX, drawY, sectorSize, sectorSize);
int i = 0; int i = 0;
for(Point2 point : Geometry.d4){ for(Point2 point : Geometry.d4){
Sector other = world.sectors.get(sectorX + point.x, sectorY + point.y); Sector other = world.sectors.get(sectorX + point.x, sectorY + point.y);
if(other != null){ if(other != null){
Draw.rect("sector-edge", drawX, drawY, sectorSize, sectorSize).rot(i*90); Draw.rect(("sector-edge"), drawX, drawY, sectorSize, sectorSize, i*90);
} }
i ++; i ++;
@@ -217,7 +217,7 @@ public class SectorsDialog extends FloatingDialog{
} }
Draw.colorl(!sector.complete ? 0.3f : 1f); Draw.colorl(!sector.complete ? 0.3f : 1f);
Draw.rect().tex(sector.texture).center(drawX, drawY, sectorSize, sectorSize); Draw.rect(Draw.wrap(sector.texture), drawX, drawY, sectorSize, sectorSize);
if(sector.missions.size == 0) continue; if(sector.missions.size == 0) continue;
@@ -250,16 +250,16 @@ public class SectorsDialog extends FloatingDialog{
} }
Draw.color(selectColor); Draw.color(selectColor);
Draw.rect("sector-select", drawX, drawY, sectorSize, sectorSize); Draw.rect(("sector-select"), drawX, drawY, sectorSize, sectorSize);
Draw.color(backColor); Draw.color(backColor);
Draw.alpha(0.75f * backColor.a); Draw.alpha(0.75f * backColor.a);
Draw.rect("icon-mission-background", drawX, drawY, Unit.dp.scl(18f * 5), Unit.dp.scl(18f * 5)); Draw.rect(("icon-mission-background"), drawX, drawY, Unit.dp.scl(18f * 5), Unit.dp.scl(18f * 5));
float size = Unit.dp.scl(10f * 5); float size = Unit.dp.scl(10f * 5);
Draw.color(iconColor); Draw.color(iconColor);
Draw.rect(region, drawX, drawY, size, size); Draw.rect((region), drawX, drawY, size, size);
} }
} }

View File

@@ -7,7 +7,6 @@ import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.arc.scene.Group; import io.anuke.arc.scene.Group;
import io.anuke.arc.scene.ui.layout.Unit; import io.anuke.arc.scene.ui.layout.Unit;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.graphics.Shaders; import io.anuke.mindustry.graphics.Shaders;
import static io.anuke.mindustry.Vars.state; import static io.anuke.mindustry.Vars.state;
@@ -18,12 +17,10 @@ public class BackgroundFragment extends Fragment{
public void build(Group parent){ public void build(Group parent){
Core.scene.table().addRect((a, b, w, h) -> { Core.scene.table().addRect((a, b, w, h) -> {
Draw.colorl(0.1f); Draw.colorl(0.1f);
Fill.rect().set(0, 0, w, h); Fill.rect(0, 0, w, h);
Draw.color(Palette.accent);
Draw.shader(Shaders.menu); Draw.shader(Shaders.menu);
Fill.rect().set(0, 0, w, h); Fill.rect(0, 0, w, h);
Draw.shader(); Draw.shader();
Draw.color();
boolean portrait = Core.graphics.getWidth() < Core.graphics.getHeight(); boolean portrait = Core.graphics.getWidth() < Core.graphics.getHeight();
float logoscl = (int) Unit.dp.scl(7) * (portrait ? 5f / 7f : 1f); float logoscl = (int) Unit.dp.scl(7) * (portrait ? 5f / 7f : 1f);
@@ -32,7 +29,7 @@ public class BackgroundFragment extends Fragment{
float logoh = logo.getHeight() * logoscl; float logoh = logo.getHeight() * logoscl;
Draw.color(); Draw.color();
Draw.rect().tex(logo).set((int) (w / 2 - logow / 2), (int) (h - logoh + 15 - Unit.dp.scl(portrait ? 30f : 0)), logow, logoh); Draw.rect(logo, (int) (w / 2 - logow / 2), (int) (h - logoh + 15 - Unit.dp.scl(portrait ? 30f : 0)), logow, logoh);
}).visible(() -> state.is(State.menu)).grow(); }).visible(() -> state.is(State.menu)).grow();
} }
} }

View File

@@ -158,7 +158,7 @@ public class ChatFragment extends Table{
Draw.color(shadowColor); Draw.color(shadowColor);
if(chatOpen){ if(chatOpen){
Fill.rect().set(offsetx, chatfield.getY(), chatfield.getWidth() + 15f, chatfield.getHeight() - 1); Fill.crect(offsetx, chatfield.getY(), chatfield.getWidth() + 15f, chatfield.getHeight() - 1);
} }
super.draw(); super.draw();
@@ -185,7 +185,7 @@ public class ChatFragment extends Table{
Draw.color(0, 0, 0, shadowColor.a * (fadetime - i)); Draw.color(0, 0, 0, shadowColor.a * (fadetime - i));
} }
Fill.rect().set(offsetx, theight - layout.height - 2, textWidth + Unit.dp.scl(4f), layout.height + textspacing); Fill.crect(offsetx, theight - layout.height - 2, textWidth + Unit.dp.scl(4f), layout.height + textspacing);
Draw.color(shadowColor); Draw.color(shadowColor);
font.getCache().draw(); font.getCache().draw();

View File

@@ -509,7 +509,7 @@ public class Block extends BaseBlock {
} }
public void draw(Tile tile){ public void draw(Tile tile){
Draw.rect(region, tile.drawx(), tile.drawy()).rot(rotate ? tile.getRotation() * 90 : 0); Draw.rect(region, tile.drawx(), tile.drawy(), rotate ? tile.getRotation() * 90 : 0);
} }
public void drawNonLayer(Tile tile){ public void drawNonLayer(Tile tile){

View File

@@ -129,7 +129,7 @@ public class BuildBlock extends Block{
if(entity.previous == null) return; if(entity.previous == null) return;
for(TextureRegion region : entity.previous.getBlockIcon()){ for(TextureRegion region : entity.previous.getBlockIcon()){
Draw.rect(region, tile.drawx(), tile.drawy()).rot(entity.previous.rotate ? tile.getRotation() * 90 : 0); Draw.rect(region, tile.drawx(), tile.drawy(), entity.previous.rotate ? tile.getRotation() * 90 : 0);
} }
} }
@@ -149,7 +149,7 @@ public class BuildBlock extends Block{
Shaders.blockbuild.progress = entity.progress; Shaders.blockbuild.progress = entity.progress;
Shaders.blockbuild.apply(); Shaders.blockbuild.apply();
Draw.rect(region, tile.drawx(), tile.drawy()).rot(target.rotate ? tile.getRotation() * 90 : 0); Draw.rect(region, tile.drawx(), tile.drawy(), target.rotate ? tile.getRotation() * 90 : 0);
Draw.flush(); Draw.flush();
} }
} }

View File

@@ -141,13 +141,13 @@ public class Floor extends Block{
boolean above = (tile.getCliffs() & (1 << ((i + 1) % 4) * 2)) != 0, below = (tile.getCliffs() & (1 << (Mathf.mod(i - 1, 4)) * 2)) != 0; boolean above = (tile.getCliffs() & (1 << ((i + 1) % 4) * 2)) != 0, below = (tile.getCliffs() & (1 << (Mathf.mod(i - 1, 4)) * 2)) != 0;
if(above && below){ if(above && below){
Draw.rect(cliffRegions[0], tile.worldx(), tile.worldy()).rot(i * 90); Draw.rect(cliffRegions[0], tile.worldx(), tile.worldy(), i * 90);
}else if(above){ }else if(above){
Draw.rect(cliffRegions[1], tile.worldx(), tile.worldy()).rot(i * 90); Draw.rect(cliffRegions[1], tile.worldx(), tile.worldy(), i * 90);
}else if(below){ }else if(below){
Draw.rect(cliffRegions[2], tile.worldx(), tile.worldy()).rot(i * 90); Draw.rect(cliffRegions[2], tile.worldx(), tile.worldy(), i * 90);
}else{ }else{
Draw.rect(cliffRegions[3], tile.worldx(), tile.worldy()).rot(i * 90); Draw.rect(cliffRegions[3], tile.worldx(), tile.worldy(), i * 90);
} }
} }
} }
@@ -178,7 +178,7 @@ public class Floor extends Block{
TextureRegion region = floor.edgeRegions[i]; TextureRegion region = floor.edgeRegions[i];
Draw.rect().tex(region).set(tile.worldx() + floor.offsets[i].x, tile.worldy() + floor.offsets[i].y, region.getWidth(), region.getHeight()); Draw.rect(region, tile.worldx() + floor.offsets[i].x, tile.worldy() + floor.offsets[i].y, region.getWidth(), region.getHeight());
} }
} }

View File

@@ -40,15 +40,15 @@ public class LiquidBlock extends Block{
int rotation = rotate ? tile.getRotation() * 90 : 0; int rotation = rotate ? tile.getRotation() * 90 : 0;
Draw.rect(bottomRegion, tile.drawx(), tile.drawy()).rot(rotation); Draw.rect(bottomRegion, tile.drawx(), tile.drawy(), rotation);
if(mod.total() > 0.001f){ if(mod.total() > 0.001f){
Draw.color(mod.current().color); Draw.color(mod.current().color);
Draw.alpha(mod.total() / liquidCapacity); Draw.alpha(mod.total() / liquidCapacity);
Draw.rect(liquidRegion, tile.drawx(), tile.drawy()).rot(rotation); Draw.rect(liquidRegion, tile.drawx(), tile.drawy(), rotation);
Draw.color(); Draw.color();
} }
Draw.rect(topRegion, tile.drawx(), tile.drawy()).rot(rotation); Draw.rect(topRegion, tile.drawx(), tile.drawy(), rotation);
} }
} }

View File

@@ -36,7 +36,9 @@ public class DeflectorWall extends Wall{
Draw.color(Color.WHITE); Draw.color(Color.WHITE);
Draw.alpha(entity.hit * 0.5f); Draw.alpha(entity.hit * 0.5f);
Draw.rect("blank", tile.drawx(), tile.drawy(), tilesize * size, tilesize * size).blend(Blending.additive); Draw.blend(Blending.additive);
Draw.rect("blank", tile.drawx(), tile.drawy(), tilesize * size, tilesize * size);
Draw.blend();
Draw.reset(); Draw.reset();
entity.hit = Mathf.clamp(entity.hit - Time.delta() / hitTime); entity.hit = Mathf.clamp(entity.hit - Time.delta() / hitTime);

View File

@@ -175,7 +175,9 @@ public class ForceProjector extends Block {
if(entity.buildup <= 0f) return; if(entity.buildup <= 0f) return;
Draw.alpha(entity.buildup / breakage * 0.75f); Draw.alpha(entity.buildup / breakage * 0.75f);
Draw.rect(topRegion, tile.drawx(), tile.drawy()).blend(Blending.additive); Draw.blend(Blending.additive);
Draw.rect(topRegion, tile.drawx(), tile.drawy());
Draw.blend();
Draw.reset(); Draw.reset();
} }

View File

@@ -112,7 +112,9 @@ public class MendProjector extends Block{
Draw.color(color, phase, entity.phaseHeat); Draw.color(color, phase, entity.phaseHeat);
Draw.alpha(entity.heat * Mathf.absin(Time.time(), 10f, 1f) * 0.5f); Draw.alpha(entity.heat * Mathf.absin(Time.time(), 10f, 1f) * 0.5f);
Draw.rect(topRegion, tile.drawx(), tile.drawy()).blend(Blending.additive); Draw.blend(Blending.additive);
Draw.rect(topRegion, tile.drawx(), tile.drawy());
Draw.blend();
Draw.alpha(1f); Draw.alpha(1f);
Lines.stroke((2f * f + 0.2f)* entity.heat); Lines.stroke((2f * f + 0.2f)* entity.heat);

View File

@@ -115,7 +115,9 @@ public class OverdriveProjector extends Block{
Draw.color(color, phase, entity.phaseHeat); Draw.color(color, phase, entity.phaseHeat);
Draw.alpha(entity.heat * Mathf.absin(Time.time(), 10f, 1f) * 0.5f); Draw.alpha(entity.heat * Mathf.absin(Time.time(), 10f, 1f) * 0.5f);
Draw.rect(topRegion, tile.drawx(), tile.drawy()).blend(Blending.additive); Draw.blend(Blending.additive);
Draw.rect(topRegion, tile.drawx(), tile.drawy());
Draw.blend();
Draw.alpha(1f); Draw.alpha(1f);
Lines.stroke((2f * f + 0.2f)* entity.heat); Lines.stroke((2f * f + 0.2f)* entity.heat);
Lines.circle(tile.drawx(), tile.drawy(), (1f-f) * 9f); Lines.circle(tile.drawx(), tile.drawy(), (1f-f) * 9f);

View File

@@ -34,7 +34,7 @@ public class ShockMine extends Block{
super.draw(tile); super.draw(tile);
Draw.color(tile.getTeam().color); Draw.color(tile.getTeam().color);
Draw.alpha(0.22f); Draw.alpha(0.22f);
Fill.rect().center(tile.drawx(), tile.drawy(), 2f, 2f); Fill.rect(tile.drawx(), tile.drawy(), 2f, 2f);
Draw.color(); Draw.color();
} }

View File

@@ -75,10 +75,14 @@ public abstract class Turret extends Block{
protected TextureRegion baseTopRegion; protected TextureRegion baseTopRegion;
protected BiConsumer<Tile, TurretEntity> drawer = (tile, entity) -> protected BiConsumer<Tile, TurretEntity> drawer = (tile, entity) ->
Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y).rot(entity.rotation - 90); Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
protected BiConsumer<Tile, TurretEntity> heatDrawer = (tile, entity) -> { protected BiConsumer<Tile, TurretEntity> heatDrawer = (tile, entity) -> {
if(entity.heat <= 0.00001f) return; if(entity.heat <= 0.00001f) return;
Draw.rect(heatRegion, tile.drawx() + tr2.x, tile.drawy() + tr2.y).rot(entity.rotation - 90).color(heatColor, entity.heat).blend(Blending.additive); Draw.color(heatColor, entity.heat);
Draw.blend(Blending.additive);
Draw.rect(heatRegion, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
Draw.blend();
Draw.color();
}; };
public Turret(String name){ public Turret(String name){
@@ -129,7 +133,8 @@ public abstract class Turret extends Block{
@Override @Override
public void draw(Tile tile){ public void draw(Tile tile){
Draw.rect(baseRegion, tile.drawx(), tile.drawy()); Draw.rect(baseRegion, tile.drawx(), tile.drawy());
Draw.rect(baseTopRegion, tile.drawx(), tile.drawy()).color(tile.getTeam().color, Color.WHITE, 0.45f); Draw.color(tile.getTeam().color, Color.WHITE, 0.45f);
Draw.rect(baseTopRegion, tile.drawx(), tile.drawy());
} }
@Override @Override

View File

@@ -45,7 +45,7 @@ public class Conduit extends LiquidBlock{
if(entity.blendshadowrot == -1){ if(entity.blendshadowrot == -1){
super.drawShadow(tile); super.drawShadow(tile);
}else{ }else{
Draw.rect("shadow-corner", tile.drawx(), tile.drawy()).rot((tile.getRotation() + 3 + entity.blendshadowrot) * 90); Draw.rect(Core.atlas.find("shadow-corner"), tile.drawx(), tile.drawy(), (tile.getRotation() + 3 + entity.blendshadowrot) * 90);
} }
} }
@@ -88,14 +88,14 @@ public class Conduit extends LiquidBlock{
int rotation = tile.getRotation() * 90; int rotation = tile.getRotation() * 90;
Draw.colorl(0.34f); Draw.colorl(0.34f);
Draw.rect(botRegions[entity.blendbits], tile.drawx(), tile.drawy()).rot(rotation); Draw.rect(botRegions[entity.blendbits], tile.drawx(), tile.drawy(), rotation);
Draw.color(mod.current().color); Draw.color(mod.current().color);
Draw.alpha(entity.smoothLiquid); Draw.alpha(entity.smoothLiquid);
Draw.rect(botRegions[entity.blendbits], tile.drawx(), tile.drawy()).rot(rotation); Draw.rect(botRegions[entity.blendbits], tile.drawx(), tile.drawy(), rotation);
Draw.color(); Draw.color();
Draw.rect(topRegions[entity.blendbits], tile.drawx(), tile.drawy()).rot(rotation); Draw.rect(topRegions[entity.blendbits], tile.drawx(), tile.drawy(), rotation);
} }
@Override @Override

View File

@@ -91,7 +91,7 @@ public class Conveyor extends Block{
if(entity.blendshadowrot == -1){ if(entity.blendshadowrot == -1){
super.drawShadow(tile); super.drawShadow(tile);
}else{ }else{
Draw.rect("shadow-corner", tile.drawx(), tile.drawy()).rot((tile.getRotation() + 3 + entity.blendshadowrot) * 90); Draw.rect(Core.atlas.find("shadow-corner"), tile.drawx(), tile.drawy(), (tile.getRotation() + 3 + entity.blendshadowrot) * 90);
} }
} }
@@ -102,7 +102,7 @@ public class Conveyor extends Block{
int frame = entity.clogHeat <= 0.5f ? (int) (((Time.time() * speed * 8f * entity.timeScale)) % 4) : 0; int frame = entity.clogHeat <= 0.5f ? (int) (((Time.time() * speed * 8f * entity.timeScale)) % 4) : 0;
Draw.rect(regions[Mathf.clamp(entity.blendbits, 0, regions.length - 1)][Mathf.clamp(frame, 0, regions[0].length - 1)], tile.drawx(), tile.drawy(), Draw.rect(regions[Mathf.clamp(entity.blendbits, 0, regions.length - 1)][Mathf.clamp(frame, 0, regions[0].length - 1)], tile.drawx(), tile.drawy(),
tilesize * entity.blendsclx, tilesize * entity.blendscly).rot( rotation*90); tilesize * entity.blendsclx, tilesize * entity.blendscly, rotation*90);
} }
@Override @Override

View File

@@ -39,10 +39,10 @@ public class ExtendingItemBridge extends ItemBridge{
tile.worldx() + ex, tile.worldx() + ex,
tile.worldy() + ey, CapStyle.none, 0f); tile.worldy() + ey, CapStyle.none, 0f);
Draw.rect(endRegion, tile.drawx(), tile.drawy()).rot(i * 90 + 90); Draw.rect(endRegion, tile.drawx(), tile.drawy(), i * 90 + 90);
Draw.rect(endRegion, Draw.rect(endRegion,
tile.worldx() + ex + Geometry.d4[i].x * tilesize / 2f, tile.worldx() + ex + Geometry.d4[i].x * tilesize / 2f,
tile.worldy() + ey + Geometry.d4[i].y * tilesize / 2f).rot(i * 90 + 270); tile.worldy() + ey + Geometry.d4[i].y * tilesize / 2f, i * 90 + 270);
int dist = Math.max(Math.abs(other.x - tile.x), Math.abs(other.y - tile.y)); int dist = Math.max(Math.abs(other.x - tile.x), Math.abs(other.y - tile.y));
@@ -54,8 +54,7 @@ public class ExtendingItemBridge extends ItemBridge{
Draw.alpha(Mathf.absin(a / (float) arrows - entity.time / 100f, 0.1f, 1f) * entity.uptime); Draw.alpha(Mathf.absin(a / (float) arrows - entity.time / 100f, 0.1f, 1f) * entity.uptime);
Draw.rect(arrowRegion, Draw.rect(arrowRegion,
tile.worldx() + Geometry.d4[i].x * (tilesize / 2f + a * 6f + 2) * entity.uptime, tile.worldx() + Geometry.d4[i].x * (tilesize / 2f + a * 6f + 2) * entity.uptime,
tile.worldy() + Geometry.d4[i].y * (tilesize / 2f + a * 6f + 2) * entity.uptime) tile.worldy() + Geometry.d4[i].y * (tilesize / 2f + a * 6f + 2) * entity.uptime, i * 90f);
.rot(i * 90f);
} }
Draw.reset(); Draw.reset();
} }

View File

@@ -216,8 +216,8 @@ public class ItemBridge extends Block{
Draw.color(Color.WHITE, Color.BLACK, Mathf.absin(Time.time(), 6f, 0.07f)); Draw.color(Color.WHITE, Color.BLACK, Mathf.absin(Time.time(), 6f, 0.07f));
Draw.alpha(Math.max(entity.uptime, 0.25f)); Draw.alpha(Math.max(entity.uptime, 0.25f));
Draw.rect(endRegion, tile.drawx(), tile.drawy()).rot(i * 90 + 90); Draw.rect(endRegion, tile.drawx(), tile.drawy(), i * 90 + 90);
Draw.rect(endRegion, other.drawx(), other.drawy()).rot(i * 90 + 270); Draw.rect(endRegion, other.drawx(), other.drawy(), i * 90 + 270);
Lines.stroke(8f); Lines.stroke(8f);
Lines.line(bridgeRegion, Lines.line(bridgeRegion,
@@ -237,7 +237,7 @@ public class ItemBridge extends Block{
Draw.alpha(Mathf.absin(a / (float) arrows - entity.time / 100f, 0.1f, 1f) * entity.uptime); Draw.alpha(Mathf.absin(a / (float) arrows - entity.time / 100f, 0.1f, 1f) * entity.uptime);
Draw.rect(arrowRegion, Draw.rect(arrowRegion,
tile.worldx() + Geometry.d4[i].x * (tilesize / 2f + a * 4f + time % 4f), tile.worldx() + Geometry.d4[i].x * (tilesize / 2f + a * 4f + time % 4f),
tile.worldy() + Geometry.d4[i].y * (tilesize / 2f + a * 4f + time % 4f)).rot(i * 90f); tile.worldy() + Geometry.d4[i].y * (tilesize / 2f + a * 4f + time % 4f), i * 90f);
} }
Draw.reset(); Draw.reset();
} }

View File

@@ -191,8 +191,7 @@ public class MassDriver extends Block{
Draw.rect(turretRegion, Draw.rect(turretRegion,
tile.drawx() + Angles.trnsx(entity.rotation + 180f, entity.reload * knockback), tile.drawx() + Angles.trnsx(entity.rotation + 180f, entity.reload * knockback),
tile.drawy() + Angles.trnsy(entity.rotation + 180f, entity.reload * knockback)) tile.drawy() + Angles.trnsy(entity.rotation + 180f, entity.reload * knockback), entity.rotation - 90);
.rot(entity.rotation - 90);
} }
@Override @Override

View File

@@ -1,7 +1,6 @@
package io.anuke.mindustry.world.blocks.power; package io.anuke.mindustry.world.blocks.power;
import io.anuke.arc.Core; import io.anuke.arc.Core;
import io.anuke.arc.Graphics;
import io.anuke.arc.graphics.Blending; import io.anuke.arc.graphics.Blending;
import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.Color;
import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.Draw;
@@ -85,7 +84,9 @@ public class FusionReactor extends PowerGenerator{
Draw.color(plasma1, plasma2, (float) i / plasmas); Draw.color(plasma1, plasma2, (float) i / plasmas);
Draw.alpha((0.3f + Mathf.absin(Time.time(), 2f + i * 2f, 0.3f + i * 0.05f)) * entity.warmup); Draw.alpha((0.3f + Mathf.absin(Time.time(), 2f + i * 2f, 0.3f + i * 0.05f)) * entity.warmup);
Draw.rect(name + "-plasma-" + i, tile.drawx(), tile.drawy(), r, r).rot(Time.time() * (12 + i * 6f) * entity.warmup).blend(Blending.additive); Draw.blend(Blending.additive);
Draw.rect(name + "-plasma-" + i, tile.drawx(), tile.drawy(), r, r, Time.time() * (12 + i * 6f) * entity.warmup);
Draw.blend();
} }
Draw.color(); Draw.color();

View File

@@ -97,11 +97,13 @@ public class Drill extends Block{
if(drawRim){ if(drawRim){
Draw.color(heatColor); Draw.color(heatColor);
Draw.alpha(entity.warmup * ts * (1f - s + Mathf.absin(Time.time(), 3f, s))); Draw.alpha(entity.warmup * ts * (1f - s + Mathf.absin(Time.time(), 3f, s)));
Draw.rect(rimRegion, tile.drawx(), tile.drawy()).blend(Blending.additive); Draw.blend(Blending.additive);
Draw.rect(rimRegion, tile.drawx(), tile.drawy());
Draw.blend();
Draw.color(); Draw.color();
} }
Draw.rect(rotatorRegion, tile.drawx(), tile.drawy()).rot(entity.drillTime * rotateSpeed); Draw.rect(rotatorRegion, tile.drawx(), tile.drawy(), entity.drillTime * rotateSpeed);
Draw.rect(topRegion, tile.drawx(), tile.drawy()); Draw.rect(topRegion, tile.drawx(), tile.drawy());

View File

@@ -44,7 +44,7 @@ public class Fracker extends SolidPump{
Draw.rect(liquidRegion, tile.drawx(), tile.drawy()); Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
Draw.color(); Draw.color();
Draw.rect(rotatorRegion, tile.drawx(), tile.drawy()).rot(entity.pumpTime); Draw.rect(rotatorRegion, tile.drawx(), tile.drawy(), entity.pumpTime);
Draw.rect(topRegion, tile.drawx(), tile.drawy()); Draw.rect(topRegion, tile.drawx(), tile.drawy());
} }

View File

@@ -78,16 +78,16 @@ public class LiquidMixer extends LiquidBlock{
int rotation = rotate ? tile.getRotation() * 90 : 0; int rotation = rotate ? tile.getRotation() * 90 : 0;
Draw.rect(bottomRegion, tile.drawx(), tile.drawy()).rot(rotation); Draw.rect(bottomRegion, tile.drawx(), tile.drawy(), rotation);
if(mod.total() > 0.001f){ if(mod.total() > 0.001f){
Draw.color(outputLiquid.color); Draw.color(outputLiquid.color);
Draw.alpha(mod.get(outputLiquid) / liquidCapacity); Draw.alpha(mod.get(outputLiquid) / liquidCapacity);
Draw.rect(liquidRegion, tile.drawx(), tile.drawy()).rot(rotation); Draw.rect(liquidRegion, tile.drawx(), tile.drawy(), rotation);
Draw.color(); Draw.color();
} }
Draw.rect(topRegion, tile.drawx(), tile.drawy()).rot(rotation); Draw.rect(topRegion, tile.drawx(), tile.drawy(), rotation);
} }
@Override @Override

View File

@@ -50,7 +50,7 @@ public class PhaseWeaver extends PowerSmelter{
Draw.shader(Shaders.build, false); Draw.shader(Shaders.build, false);
Shaders.build.apply(); Shaders.build.apply();
Draw.rect(weaveRegion, tile.drawx(), tile.drawy()).rot(entity.time); Draw.rect(weaveRegion, tile.drawx(), tile.drawy(), entity.time);
Draw.shader(); Draw.shader();
Draw.color(Palette.accent); Draw.color(Palette.accent);

View File

@@ -25,7 +25,7 @@ public class Pulverizer extends GenericCrafter{
GenericCrafterEntity entity = tile.entity(); GenericCrafterEntity entity = tile.entity();
Draw.rect(region, tile.drawx(), tile.drawy()); Draw.rect(region, tile.drawx(), tile.drawy());
Draw.rect(rotatorRegion, tile.drawx(), tile.drawy()).rot(entity.totalProgress * 2f); Draw.rect(rotatorRegion, tile.drawx(), tile.drawy(), entity.totalProgress * 2f);
} }
@Override @Override

View File

@@ -51,7 +51,7 @@ public class SolidPump extends Pump{
Draw.alpha(tile.entity.liquids.total() / liquidCapacity); Draw.alpha(tile.entity.liquids.total() / liquidCapacity);
Draw.rect(liquidRegion, tile.drawx(), tile.drawy()); Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
Draw.color(); Draw.color();
Draw.rect(name + "-rotator", tile.drawx(), tile.drawy()).rot(entity.pumpTime * rotateSpeed); Draw.rect(name + "-rotator", tile.drawx(), tile.drawy(), entity.pumpTime * rotateSpeed);
Draw.rect(name + "-top", tile.drawx(), tile.drawy()); Draw.rect(name + "-top", tile.drawx(), tile.drawy());
} }

View File

@@ -111,7 +111,7 @@ public class MechPad extends Block{
Draw.color(Palette.accent); Draw.color(Palette.accent);
for(int i = 0; i < 4; i ++){ for(int i = 0; i < 4; i ++){
float length = tilesize * size/2f + 3 + Mathf.absin(Time.time(), 5f, 2f); float length = tilesize * size/2f + 3 + Mathf.absin(Time.time(), 5f, 2f);
Draw.rect("transfer-arrow", tile.drawx() + Geometry.d4[i].x * length, tile.drawy() + Geometry.d4[i].y * length).rot((i+2) * 90); Draw.rect("transfer-arrow", tile.drawx() + Geometry.d4[i].x * length, tile.drawy() + Geometry.d4[i].y * length, (i+2) * 90);
} }
Draw.color(); Draw.color();
} }
@@ -142,7 +142,7 @@ public class MechPad extends Block{
public void draw(Tile tile){ public void draw(Tile tile){
MechFactoryEntity entity = tile.entity(); MechFactoryEntity entity = tile.entity();
Draw.rect(Core.atlas.find(name), tile.drawx(), tile.drawy()).rot(entity.open ? 180f : 0f); Draw.rect(Core.atlas.find(name), tile.drawx(), tile.drawy(), entity.open ? 180f : 0f);
if(entity.player != null){ if(entity.player != null){
TextureRegion region = mech.iconRegion; TextureRegion region = mech.iconRegion;

View File

@@ -60,7 +60,7 @@ public class RepairPoint extends Block{
public void drawLayer(Tile tile){ public void drawLayer(Tile tile){
RepairPointEntity entity = tile.entity(); RepairPointEntity entity = tile.entity();
Draw.rect(topRegion, tile.drawx(), tile.drawy()).rot(entity.rotation - 90); Draw.rect(topRegion, tile.drawx(), tile.drawy(), entity.rotation - 90);
} }
@Override @Override

View File

@@ -3,8 +3,8 @@ package io.anuke.mindustry.desktop;
import io.anuke.arc.ApplicationListener; import io.anuke.arc.ApplicationListener;
import io.anuke.arc.backends.lwjgl3.Lwjgl3Application; import io.anuke.arc.backends.lwjgl3.Lwjgl3Application;
import io.anuke.arc.backends.lwjgl3.Lwjgl3ApplicationConfiguration; import io.anuke.arc.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import io.anuke.kryonet.KryoClient; import io.anuke.net.KryoClient;
import io.anuke.kryonet.KryoServer; import io.anuke.net.KryoServer;
import io.anuke.mindustry.Mindustry; import io.anuke.mindustry.Mindustry;
import io.anuke.mindustry.core.Platform; import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net;

View File

@@ -1,18 +1,17 @@
package io.anuke.mindustry; package io.anuke.mindustry;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.iosrobovm.IOSApplication; import com.badlogic.gdx.backends.iosrobovm.IOSApplication;
import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration; import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration;
import com.badlogic.gdx.files.FileHandle; import io.anuke.arc.Core;
import io.anuke.kryonet.KryoClient; import io.anuke.arc.files.FileHandle;
import io.anuke.kryonet.KryoServer; import io.anuke.arc.scene.ui.layout.Unit;
import io.anuke.arc.util.Strings;
import io.anuke.net.KryoClient;
import io.anuke.net.KryoServer;
import io.anuke.mindustry.core.Platform; import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.game.Saves.SaveSlot; import io.anuke.mindustry.game.Saves.SaveSlot;
import io.anuke.mindustry.io.SaveIO; import io.anuke.mindustry.io.SaveIO;
import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net;
import io.anuke.arc.scene.ui.layout.Unit;
import io.anuke.arc.util.Bundles;
import io.anuke.arc.util.Strings;
import org.robovm.apple.foundation.NSAutoreleasePool; import org.robovm.apple.foundation.NSAutoreleasePool;
import org.robovm.apple.foundation.NSURL; import org.robovm.apple.foundation.NSURL;
import org.robovm.apple.uikit.*; import org.robovm.apple.uikit.*;
@@ -39,7 +38,7 @@ public class IOSLauncher extends IOSApplication.Delegate {
@Override @Override
public void shareFile(FileHandle file){ public void shareFile(FileHandle file){
FileHandle to = Gdx.files.absolute(getDocumentsDirectory()).child(file.name()); FileHandle to = Core.files.absolute(getDocumentsDirectory()).child(file.name());
file.copyTo(to); file.copyTo(to);
NSURL url = new NSURL(to.file()); NSURL url = new NSURL(to.file());
@@ -91,9 +90,9 @@ public class IOSLauncher extends IOSApplication.Delegate {
void openURL(NSURL url){ void openURL(NSURL url){
Gdx.app.postRunnable(() -> { Core.app.post(() -> {
FileHandle file = Gdx.files.absolute(getDocumentsDirectory()).child(url.getLastPathComponent()); FileHandle file = Core.files.absolute(getDocumentsDirectory()).child(url.getLastPathComponent());
Gdx.files.absolute(url.getPath()).copyTo(file); Core.files.absolute(url.getPath()).copyTo(file);
if(file.extension().equalsIgnoreCase(saveExtension)){ //open save if(file.extension().equalsIgnoreCase(saveExtension)){ //open save
@@ -109,7 +108,7 @@ public class IOSLauncher extends IOSApplication.Delegate {
} }
}else if(file.extension().equalsIgnoreCase(mapExtension)){ //open map }else if(file.extension().equalsIgnoreCase(mapExtension)){ //open map
Gdx.app.postRunnable(() -> { Core.app.post(() -> {
if (!ui.editor.isShown()) { if (!ui.editor.isShown()) {
ui.editor.show(); ui.editor.show();
} }

Binary file not shown.

Binary file not shown.

View File

@@ -1,4 +1,4 @@
package io.anuke.kryonet; package io.anuke.net;
import com.esotericsoftware.kryonet.FrameworkMessage; import com.esotericsoftware.kryonet.FrameworkMessage;
import com.esotericsoftware.kryonet.serialization.Serialization; import com.esotericsoftware.kryonet.serialization.Serialization;

View File

@@ -1,4 +1,4 @@
package io.anuke.kryonet; package io.anuke.net;
import com.esotericsoftware.kryonet.FrameworkMessage; import com.esotericsoftware.kryonet.FrameworkMessage;
import com.esotericsoftware.kryonet.FrameworkMessage.*; import com.esotericsoftware.kryonet.FrameworkMessage.*;

View File

@@ -1,4 +1,4 @@
package io.anuke.kryonet; package io.anuke.net;
import com.esotericsoftware.kryonet.*; import com.esotericsoftware.kryonet.*;
import io.anuke.arc.Core; import io.anuke.arc.Core;

View File

@@ -1,4 +1,4 @@
package io.anuke.kryonet; package io.anuke.net;
import com.esotericsoftware.kryonet.util.Log; import com.esotericsoftware.kryonet.util.Log;
import com.esotericsoftware.kryonet.util.Log.Logger; import com.esotericsoftware.kryonet.util.Log.Logger;

View File

@@ -1,4 +1,4 @@
package io.anuke.kryonet; package io.anuke.net;
import com.dosse.upnp.UPnP; import com.dosse.upnp.UPnP;
import com.esotericsoftware.kryonet.Connection; import com.esotericsoftware.kryonet.Connection;

View File

@@ -1,11 +1,11 @@
package io.anuke.mindustry.server; package io.anuke.mindustry.server;
import com.badlogic.gdx.utils.JsonValue;
import com.badlogic.gdx.utils.JsonValue.ValueType;
import com.badlogic.gdx.utils.JsonWriter.OutputType;
import io.anuke.arc.Core; import io.anuke.arc.Core;
import io.anuke.arc.util.Log; import io.anuke.arc.util.Log;
import io.anuke.arc.util.OS; import io.anuke.arc.util.OS;
import io.anuke.arc.util.serialization.JsonValue;
import io.anuke.arc.util.serialization.JsonValue.ValueType;
import io.anuke.arc.util.serialization.JsonWriter.OutputType;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.Vars;
import io.anuke.mindustry.game.Version; import io.anuke.mindustry.game.Version;
import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net;

View File

@@ -1,22 +1,17 @@
package io.anuke.mindustry.server; package io.anuke.mindustry.server;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectSet;
import com.badlogic.gdx.utils.Timer;
import com.badlogic.gdx.utils.Timer.Task;
import io.anuke.arc.ApplicationListener; import io.anuke.arc.ApplicationListener;
import io.anuke.arc.Core; import io.anuke.arc.Core;
import io.anuke.arc.Events; import io.anuke.arc.Events;
import io.anuke.arc.collection.Array;
import io.anuke.arc.collection.ObjectSet;
import io.anuke.arc.entities.Effects; import io.anuke.arc.entities.Effects;
import io.anuke.arc.util.CommandHandler; import io.anuke.arc.files.FileHandle;
import io.anuke.arc.util.*;
import io.anuke.arc.util.CommandHandler.Command; import io.anuke.arc.util.CommandHandler.Command;
import io.anuke.arc.util.CommandHandler.Response; import io.anuke.arc.util.CommandHandler.Response;
import io.anuke.arc.util.CommandHandler.ResponseType; import io.anuke.arc.util.CommandHandler.ResponseType;
import io.anuke.arc.util.Log; import io.anuke.arc.util.Timer.Task;
import io.anuke.arc.util.Strings;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.game.Difficulty; import io.anuke.mindustry.game.Difficulty;
@@ -36,6 +31,7 @@ import io.anuke.mindustry.type.ItemType;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import java.io.IOException; import java.io.IOException;
import java.lang.StringBuilder;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Scanner; import java.util.Scanner;
@@ -49,7 +45,7 @@ public class ServerControl implements ApplicationListener{
private static final int maxLogLength = 1024 * 512; private static final int maxLogLength = 1024 * 512;
private final CommandHandler handler = new CommandHandler(""); private final CommandHandler handler = new CommandHandler("");
private final FileHandle logFolder = Gdx.files.local("logs/"); private final FileHandle logFolder = Core.files.local("logs/");
private FileHandle currentLogFile; private FileHandle currentLogFile;
private int gameOvers; private int gameOvers;
@@ -99,13 +95,13 @@ public class ServerControl implements ApplicationListener{
} }
}); });
Time.setDeltaProvider(() -> Gdx.graphics.getDeltaTime() * 60f); Time.setDeltaProvider(() -> Core.graphics.getDeltaTime() * 60f);
Effects.setScreenShakeProvider((a, b) -> {}); Effects.setScreenShakeProvider((a, b) -> {});
Effects.setEffectProvider((a, b, c, d, e, f) -> {}); Effects.setEffectProvider((a, b, c, d, e, f) -> {});
registerCommands(); registerCommands();
Gdx.app.postRunnable(() -> { Core.app.post(() -> {
String[] commands = {}; String[] commands = {};
if(args.length > 0){ if(args.length > 0){
@@ -176,7 +172,7 @@ public class ServerControl implements ApplicationListener{
}else{ }else{
Call.onInfoMessage("[SCARLET]Sector has been lost.[]\nRe-deploying in " + roundExtraTime + " seconds."); Call.onInfoMessage("[SCARLET]Sector has been lost.[]\nRe-deploying in " + roundExtraTime + " seconds.");
if(gameOvers >= 2){ if(gameOvers >= 2){
Core.settings.putInt("sector_y", Core.settings.getInt("sector_y") < 0 ? Core.settings.getInt("sector_y") + 1 : Core.settings.getInt("sector_y") - 1); Core.settings.put("sector_y", Core.settings.getInt("sector_y") < 0 ? Core.settings.getInt("sector_y") + 1 : Core.settings.getInt("sector_y") - 1);
Core.settings.save(); Core.settings.save();
gameOvers = 0; gameOvers = 0;
} }
@@ -211,7 +207,7 @@ public class ServerControl implements ApplicationListener{
handler.register("exit", "Exit the server application.", arg -> { handler.register("exit", "Exit the server application.", arg -> {
info("Shutting down server."); info("Shutting down server.");
Net.dispose(); Net.dispose();
Gdx.app.exit(); Core.app.exit();
}); });
handler.register("stop", "Stop hosting the server.", arg -> { handler.register("stop", "Stop hosting the server.", arg -> {
@@ -282,7 +278,7 @@ public class ServerControl implements ApplicationListener{
return; return;
} }
info("&lyPort set to {0}.", port); info("&lyPort set to {0}.", port);
Core.settings.putInt("port", port); Core.settings.put("port", port);
Core.settings.save(); Core.settings.save();
} }
}); });
@@ -308,7 +304,7 @@ public class ServerControl implements ApplicationListener{
} }
info(" &ly{0} FPS.", (int) (60f / Time.delta())); info(" &ly{0} FPS.", (int) (60f / Time.delta()));
info(" &ly{0} MB used.", Gdx.app.getJavaHeap() / 1024 / 1024); info(" &ly{0} MB used.", Core.app.getJavaHeap() / 1024 / 1024);
if(playerGroup.size() > 0){ if(playerGroup.size() > 0){
info(" &lyPlayers: {0}", playerGroup.size()); info(" &lyPlayers: {0}", playerGroup.size());
@@ -343,8 +339,8 @@ public class ServerControl implements ApplicationListener{
handler.register("setsector", "<x> <y>", "Sets the next sector to be played. Does not affect current game.", arg -> { handler.register("setsector", "<x> <y>", "Sets the next sector to be played. Does not affect current game.", arg -> {
try{ try{
Core.settings.putInt("sector_x", Integer.parseInt(arg[0])); Core.settings.put("sector_x", Integer.parseInt(arg[0]));
Core.settings.putInt("sector_y", Integer.parseInt(arg[1])); Core.settings.put("sector_y", Integer.parseInt(arg[1]));
Core.settings.save(); Core.settings.save();
info("Sector position set."); info("Sector position set.");
}catch(NumberFormatException e){ }catch(NumberFormatException e){
@@ -380,14 +376,14 @@ public class ServerControl implements ApplicationListener{
handler.register("crashreport", "<on/off>", "Disables or enables automatic crash reporting", arg -> { handler.register("crashreport", "<on/off>", "Disables or enables automatic crash reporting", arg -> {
boolean value = arg[0].equalsIgnoreCase("on"); boolean value = arg[0].equalsIgnoreCase("on");
Core.settings.putBool("crashreport", value); Core.settings.put("crashreport", value);
Core.settings.save(); Core.settings.save();
info("Crash reporting is now {0}.", value ? "on" : "off"); info("Crash reporting is now {0}.", value ? "on" : "off");
}); });
handler.register("logging", "<on/off>", "Disables or enables server logs", arg -> { handler.register("logging", "<on/off>", "Disables or enables server logs", arg -> {
boolean value = arg[0].equalsIgnoreCase("on"); boolean value = arg[0].equalsIgnoreCase("on");
Core.settings.putBool("logging", value); Core.settings.put("logging", value);
Core.settings.save(); Core.settings.save();
info("Logging is now {0}.", value ? "on" : "off"); info("Logging is now {0}.", value ? "on" : "off");
}); });
@@ -421,7 +417,7 @@ public class ServerControl implements ApplicationListener{
err("Invalid shuffle mode."); err("Invalid shuffle mode.");
return; return;
} }
Core.settings.putBool("shuffle", arg[0].equals("on")); Core.settings.put("shuffle", arg[0].equals("on"));
Core.settings.save(); Core.settings.save();
info("Shuffle mode set to '{0}'.", arg[0]); info("Shuffle mode set to '{0}'.", arg[0]);
}); });
@@ -587,7 +583,7 @@ public class ServerControl implements ApplicationListener{
return; return;
} }
threads.run(() -> { Core.app.post(() -> {
SaveIO.loadFromSlot(slot); SaveIO.loadFromSlot(slot);
info("Save loaded."); info("Save loaded.");
host(); host();
@@ -604,7 +600,7 @@ public class ServerControl implements ApplicationListener{
return; return;
} }
threads.run(() -> { Core.app.post(() -> {
int slot = Strings.parseInt(arg[0]); int slot = Strings.parseInt(arg[0]);
SaveIO.saveToSlot(slot); SaveIO.saveToSlot(slot);
info("Saved to slot {0}.", slot); info("Saved to slot {0}.", slot);
@@ -677,7 +673,7 @@ public class ServerControl implements ApplicationListener{
while(scan.hasNext()){ while(scan.hasNext()){
String line = scan.nextLine(); String line = scan.nextLine();
Gdx.app.postRunnable(() -> { Core.app.post(() -> {
Response response = handler.handleMessage(line); Response response = handler.handleMessage(line);
if(response.type == ResponseType.unknownCommand){ if(response.type == ResponseType.unknownCommand){

View File

@@ -1,22 +1,18 @@
package io.anuke.mindustry.server; package io.anuke.mindustry.server;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx; import io.anuke.arc.ApplicationListener;
import com.badlogic.gdx.backends.headless.HeadlessApplication;
import com.badlogic.gdx.backends.headless.HeadlessApplicationConfiguration;
import io.anuke.arc.Core; import io.anuke.arc.Core;
import io.anuke.arc.util.EmptyLogger; import io.anuke.arc.backends.headless.HeadlessApplication;
import io.anuke.kryonet.KryoClient; import io.anuke.arc.backends.headless.HeadlessApplicationConfiguration;
import io.anuke.kryonet.KryoServer; import io.anuke.net.KryoClient;
import io.anuke.net.KryoServer;
import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net;
public class ServerLauncher extends HeadlessApplication{ public class ServerLauncher extends HeadlessApplication{
public ServerLauncher(ApplicationListener listener, HeadlessApplicationConfiguration config){ public ServerLauncher(ApplicationListener listener, HeadlessApplicationConfiguration config){
super(listener, config); super(listener, config);
//don't do anything at all for GDX logging: don't want controller info and such
Gdx.app.setApplicationLogger(new EmptyLogger());
} }
public static void main(String[] args){ public static void main(String[] args){
@@ -26,7 +22,7 @@ public class ServerLauncher extends HeadlessApplication{
Net.setServerProvider(new KryoServer()); Net.setServerProvider(new KryoServer());
HeadlessApplicationConfiguration config = new HeadlessApplicationConfiguration(); HeadlessApplicationConfiguration config = new HeadlessApplicationConfiguration();
Core.settings.setPrefHandler((appName) -> Gdx.files.local("config")); Core.settings.setDataDirectory(Core.files.local("config"));
new ServerLauncher(new MindustryServer(args), config); new ServerLauncher(new MindustryServer(args), config);
}catch(Throwable t){ }catch(Throwable t){

View File

@@ -27,6 +27,9 @@ if(System.properties["release"] == null || System.properties["release"] == "fals
use(':Arc:extensions:freetype', '../Arc/extensions/freetype') use(':Arc:extensions:freetype', '../Arc/extensions/freetype')
use(':Arc:backends', '../Arc/backends') use(':Arc:backends', '../Arc/backends')
use(':Arc:backends:backend-lwjgl3', '../Arc/backends/backend-lwjgl3') use(':Arc:backends:backend-lwjgl3', '../Arc/backends/backend-lwjgl3')
use(':Arc:backends:backend-android', '../Arc/backends/backend-android')
use(':Arc:backends:backend-robovm', '../Arc/backends/backend-robovm')
use(':Arc:backends:backend-headless', '../Arc/backends/backend-headless')
} }
if (new File(settingsDir, '../debug').exists()) { if (new File(settingsDir, '../debug').exists()) {
use(':debug', '../debug') use(':debug', '../debug')

View File

@@ -1,7 +1,9 @@
import com.badlogic.gdx.Gdx; import io.anuke.arc.ApplicationCore;
import com.badlogic.gdx.backends.headless.HeadlessApplication; import io.anuke.arc.backends.headless.HeadlessApplication;
import com.badlogic.gdx.backends.headless.HeadlessApplicationConfiguration; import io.anuke.arc.backends.headless.HeadlessApplicationConfiguration;
import com.badlogic.gdx.math.Point2; import io.anuke.arc.math.geom.Point2;
import io.anuke.arc.util.Log;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.Items; import io.anuke.mindustry.content.Items;
import io.anuke.mindustry.content.UnitTypes; import io.anuke.mindustry.content.UnitTypes;
@@ -24,16 +26,10 @@ import io.anuke.mindustry.type.Recipe;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Edges; import io.anuke.mindustry.world.Edges;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import io.anuke.arc.core.Timers;
import io.anuke.arc.modules.ModuleCore;
import io.anuke.arc.util.EmptyLogger;
import io.anuke.arc.util.Log;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.io.File;
import static io.anuke.mindustry.Vars.*; import static io.anuke.mindustry.Vars.*;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@@ -46,9 +42,9 @@ public class ApplicationTests{
Throwable[] exceptionThrown = {null}; Throwable[] exceptionThrown = {null};
Log.setUseColors(false); Log.setUseColors(false);
ModuleCore core = new ModuleCore(){ ApplicationCore core = new ApplicationCore(){
@Override @Override
public void init(){ public void setup(){
Vars.init(); Vars.init();
headless = true; headless = true;
@@ -57,26 +53,21 @@ public class ApplicationTests{
content.load(); content.load();
content.initialize(Content::init); content.initialize(Content::init);
module(logic = new Logic()); add(logic = new Logic());
module(world = new World()); add(world = new World());
module(netServer = new NetServer()); add(netServer = new NetServer());
} }
@Override @Override
public void postInit(){ public void init(){
super.postInit(); super.init();
begins[0] = true; begins[0] = true;
} }
}; };
HeadlessApplicationConfiguration config = new HeadlessApplicationConfiguration(); HeadlessApplicationConfiguration config = new HeadlessApplicationConfiguration();
config.preferencesDirectory = "test_files/";
new File("tests_files/").delete(); new HeadlessApplication(core, config);
new HeadlessApplication(core, config){{
Gdx.app.setApplicationLogger(new EmptyLogger());
}};
for(Thread thread : Thread.getAllStackTraces().keySet()){ for(Thread thread : Thread.getAllStackTraces().keySet()){
if(thread.getName().equals("HeadlessApplication")){ if(thread.getName().equals("HeadlessApplication")){

View File

@@ -1,4 +1,4 @@
import com.badlogic.gdx.utils.Array; import io.anuke.arc.collection.Array;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.Vars;
import io.anuke.mindustry.core.ContentLoader; import io.anuke.mindustry.core.ContentLoader;
import io.anuke.mindustry.maps.SectorPresets; import io.anuke.mindustry.maps.SectorPresets;
@@ -8,7 +8,7 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.assertTrue;
/** This class is responsible for testing predefined sectors. */ /** This class is responsible for testing predefined sectors. */
public class SectorTests{ public class SectorTests{