a revelation
This commit is contained in:
@@ -33,6 +33,7 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
|
||||
@Override
|
||||
public void setup(){
|
||||
Vars.loadLogger();
|
||||
Vars.loadFileLogger();
|
||||
Vars.platform = this;
|
||||
beginTime = Time.millis();
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package mindustry;
|
||||
|
||||
import arc.*;
|
||||
import arc.Application.*;
|
||||
import arc.*;
|
||||
import arc.assets.*;
|
||||
import arc.struct.*;
|
||||
import arc.files.*;
|
||||
import arc.graphics.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.Log.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.ai.*;
|
||||
import mindustry.core.*;
|
||||
@@ -21,11 +22,12 @@ import mindustry.gen.*;
|
||||
import mindustry.input.*;
|
||||
import mindustry.maps.*;
|
||||
import mindustry.mod.*;
|
||||
import mindustry.net.*;
|
||||
import mindustry.net.Net;
|
||||
import mindustry.net.*;
|
||||
import mindustry.type.Weather.*;
|
||||
import mindustry.world.blocks.defense.ForceProjector.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.*;
|
||||
import java.util.*;
|
||||
|
||||
@@ -36,7 +38,7 @@ public class Vars implements Loadable{
|
||||
/** Whether to load locales.*/
|
||||
public static boolean loadLocales = true;
|
||||
/** Whether the logger is loaded. */
|
||||
public static boolean loadedLogger = false;
|
||||
public static boolean loadedLogger = false, loadedFileLogger = false;
|
||||
/** Maximum schematic size.*/
|
||||
public static final int maxSchematicSize = 32;
|
||||
/** All schematic base64 starts with this string.*/
|
||||
@@ -285,9 +287,10 @@ public class Vars implements Loadable{
|
||||
String[] stags = {"&lc&fb[D]", "&lg&fb[I]", "&ly&fb[W]", "&lr&fb[E]", ""};
|
||||
|
||||
Array<String> logBuffer = new Array<>();
|
||||
Log.setLogger((level, text, args) -> {
|
||||
String result = Log.format(text, args);
|
||||
System.out.println(Log.format(stags[level.ordinal()] + "&fr " + text, args));
|
||||
Log.setLogger((level, text) -> {
|
||||
String result = text;
|
||||
String rawText = Log.format(stags[level.ordinal()] + "&fr " + text);
|
||||
System.out.println(rawText);
|
||||
|
||||
result = tags[level.ordinal()] + " " + result;
|
||||
|
||||
@@ -303,6 +306,28 @@ public class Vars implements Loadable{
|
||||
loadedLogger = true;
|
||||
}
|
||||
|
||||
public static void loadFileLogger(){
|
||||
if(loadedFileLogger) return;
|
||||
|
||||
Core.settings.setAppName(appName);
|
||||
|
||||
Writer writer = settings.getDataDirectory().child("last_log.txt").writer(false);
|
||||
LogHandler log = Log.getLogger();
|
||||
Log.setLogger(((level, text) -> {
|
||||
log.log(level, text);
|
||||
|
||||
try{
|
||||
writer.write("[" + Character.toUpperCase(level.name().charAt(0)) +"] " + Log.removeCodes(text) + "\n");
|
||||
writer.flush();
|
||||
}catch(IOException e){
|
||||
e.printStackTrace();
|
||||
//ignore it
|
||||
}
|
||||
}));
|
||||
|
||||
loadedFileLogger = true;
|
||||
}
|
||||
|
||||
public static void loadSettings(){
|
||||
Core.settings.setAppName(appName);
|
||||
|
||||
|
||||
@@ -894,18 +894,21 @@ public class Blocks implements ContentList{
|
||||
requirements(Category.distribution, ItemStack.with(Items.copper, 1), true);
|
||||
health = 45;
|
||||
speed = 0.03f;
|
||||
displayedSpeed = 4.2f;
|
||||
}};
|
||||
|
||||
titaniumConveyor = new Conveyor("titanium-conveyor"){{
|
||||
requirements(Category.distribution, ItemStack.with(Items.copper, 1, Items.lead, 1, Items.titanium, 1));
|
||||
health = 65;
|
||||
speed = 0.08f;
|
||||
displayedSpeed = 10f;
|
||||
}};
|
||||
|
||||
armoredConveyor = new ArmoredConveyor("armored-conveyor"){{
|
||||
requirements(Category.distribution, ItemStack.with(Items.plastanium, 1, Items.thorium, 1, Items.metaglass, 1));
|
||||
health = 180;
|
||||
speed = 0.08f;
|
||||
displayedSpeed = 10f;
|
||||
}};
|
||||
|
||||
junction = new Junction("junction"){{
|
||||
|
||||
@@ -133,9 +133,9 @@ public class NetClient implements ApplicationListener{
|
||||
}
|
||||
|
||||
//called on all clients
|
||||
@Remote(called = Loc.server, targets = Loc.server, variants = Variant.both)
|
||||
@Remote(targets = Loc.server, variants = Variant.both)
|
||||
public static void sendMessage(String message, String sender, Player playersender){
|
||||
if(Vars.ui != null && !(playersender != null && net.server() && sender.startsWith("[#" + player.getTeam().color.toString() + "]<T>"))){
|
||||
if(Vars.ui != null){
|
||||
Vars.ui.chatfrag.addMessage(message, sender);
|
||||
}
|
||||
|
||||
|
||||
@@ -762,7 +762,6 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
||||
public void sendMessage(String text){
|
||||
if(isLocal){
|
||||
if(Vars.ui != null){
|
||||
Log.info("add " + text);
|
||||
Vars.ui.chatfrag.addMessage(text, null);
|
||||
}
|
||||
}else{
|
||||
|
||||
@@ -54,7 +54,7 @@ public class PlanetRenderer{
|
||||
|
||||
shader.begin();
|
||||
shader.setUniformMatrix4("u_projModelView", cam.combined().val);
|
||||
mesh.render(shader, Gl.triangleStrip);
|
||||
mesh.render(shader, Gl.triangles);
|
||||
shader.end();
|
||||
|
||||
Gl.disable(Gl.depthTest);
|
||||
@@ -76,7 +76,7 @@ public class PlanetRenderer{
|
||||
|
||||
void planet(){
|
||||
PlanetGrid p = new PlanetGrid();
|
||||
Grid grid = p.newGrid(4);
|
||||
Grid grid = p.newGrid(2);
|
||||
|
||||
for(Tile tile : grid.tiles){
|
||||
|
||||
|
||||
@@ -20,15 +20,8 @@ public class ModsDialog extends FloatingDialog{
|
||||
super("$mods");
|
||||
addCloseButton();
|
||||
|
||||
buttons.addImageTextButton(mobile ? "$mods.report" : "$mods.openfolder", Icon.link,
|
||||
() -> {
|
||||
if(mobile){
|
||||
Core.net.openURI(reportIssueURL);
|
||||
}else{
|
||||
Core.net.openFolder(modDirectory.absolutePath());
|
||||
}
|
||||
})
|
||||
.size(250f, 64f);
|
||||
buttons.addImageTextButton("$mods.openfolder", Icon.link,
|
||||
() -> Core.app.openFolder(modDirectory.absolutePath())).size(250f, 64f);
|
||||
|
||||
buttons.row();
|
||||
|
||||
|
||||
@@ -81,10 +81,10 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
dataDialog.addCloseButton();
|
||||
|
||||
dataDialog.cont.table(Tex.button, t -> {
|
||||
t.defaults().size(240f, 60f).left();
|
||||
t.defaults().size(270f, 60f).left();
|
||||
TextButtonStyle style = Styles.cleart;
|
||||
|
||||
t.addButton("$settings.cleardata", style, () -> ui.showConfirm("$confirm", "$settings.clearall.confirm", () -> {
|
||||
t.addImageTextButton("$settings.cleardata", Icon.trash16Small, style, () -> ui.showConfirm("$confirm", "$settings.clearall.confirm", () -> {
|
||||
ObjectMap<String, Object> map = new ObjectMap<>();
|
||||
for(String value : Core.settings.keys()){
|
||||
if(value.contains("usid") || value.contains("uuid")){
|
||||
@@ -104,7 +104,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
|
||||
t.row();
|
||||
|
||||
t.addButton("$data.export", style, () -> {
|
||||
t.addImageTextButton("$data.export", Icon.loadMapSmall, style, () -> {
|
||||
if(ios){
|
||||
Fi file = Core.files.local("mindustry-data-export.zip");
|
||||
try{
|
||||
@@ -128,7 +128,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
|
||||
t.row();
|
||||
|
||||
t.addButton("$data.import", style, () -> ui.showConfirm("$confirm", "$data.import.confirm", () -> platform.showFileChooser(true, "zip", file -> {
|
||||
t.addImageTextButton("$data.import", Icon.saveMapSmall, style, () -> ui.showConfirm("$confirm", "$data.import.confirm", () -> platform.showFileChooser(true, "zip", file -> {
|
||||
try{
|
||||
data.importData(file);
|
||||
Core.app.exit();
|
||||
@@ -143,6 +143,11 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
}
|
||||
}
|
||||
})));
|
||||
|
||||
if(!ios){
|
||||
t.row();
|
||||
t.addImageTextButton("$data.openfolder", Icon.folderSmall, style, () -> Core.app.openFolder(Core.settings.getDataDirectory().absolutePath()));
|
||||
}
|
||||
});
|
||||
|
||||
ScrollPane pane = new ScrollPane(prefs);
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package mindustry.world;
|
||||
|
||||
import arc.struct.*;
|
||||
import arc.func.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
@@ -215,6 +216,16 @@ public class Tile implements Position, TargetTrait{
|
||||
}
|
||||
}
|
||||
|
||||
/** remove()-s this tile, except it's synced across the network */
|
||||
public void removeNet(){
|
||||
Call.removeTile(this);
|
||||
}
|
||||
|
||||
/** set()-s this tile, except it's synced across the network */
|
||||
public void setNet(Block block, Team team, int rotation){
|
||||
Call.setTile(this, block, team, rotation);
|
||||
}
|
||||
|
||||
public byte rotation(){
|
||||
return rotation;
|
||||
}
|
||||
@@ -506,4 +517,16 @@ public class Tile implements Position, TargetTrait{
|
||||
public String toString(){
|
||||
return floor.name + ":" + block.name + ":" + overlay + "[" + x + "," + y + "] " + "entity=" + (entity == null ? "null" : (entity.getClass())) + ":" + getTeam();
|
||||
}
|
||||
|
||||
//remote utility methods
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
public static void removeTile(Tile tile){
|
||||
tile.remove();
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
public static void setTile(Tile tile, Block block, Team team, int rotation){
|
||||
tile.set(block, team, rotation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
private TextureRegion[][] regions = new TextureRegion[7][4];
|
||||
|
||||
public float speed = 0f;
|
||||
public float displayedSpeed = 0f;
|
||||
|
||||
protected Conveyor(String name){
|
||||
super(name);
|
||||
@@ -59,7 +60,8 @@ public class Conveyor extends Block implements Autotiler{
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
stats.add(BlockStat.itemsMoved, speed * 60 / itemSpace, StatUnit.itemsSecond);
|
||||
//have to add a custom calculated speed, since the actual movement speed is apparently not linear
|
||||
stats.add(BlockStat.itemsMoved, displayedSpeed, StatUnit.itemsSecond);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package mindustry.world.blocks.liquid;
|
||||
|
||||
import arc.*;
|
||||
import arc.struct.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.traits.BuilderTrait.*;
|
||||
@@ -13,7 +13,6 @@ import mindustry.entities.type.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.modules.*;
|
||||
|
||||
public class Conduit extends LiquidBlock implements Autotiler{
|
||||
public final int timerFlow = timers++;
|
||||
@@ -92,13 +91,12 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
ConduitEntity entity = tile.ent();
|
||||
LiquidModule mod = tile.entity.liquids;
|
||||
int rotation = tile.rotation() * 90;
|
||||
|
||||
Draw.colorl(0.34f);
|
||||
Draw.rect(botRegions[entity.blendbits], tile.drawx(), tile.drawy(), rotation);
|
||||
|
||||
Draw.color(mod.current().color);
|
||||
Draw.color(tile.entity.liquids.current().color);
|
||||
Draw.alpha(entity.smoothLiquid);
|
||||
Draw.rect(botRegions[entity.blendbits], tile.drawx(), tile.drawy(), rotation);
|
||||
Draw.color();
|
||||
@@ -109,7 +107,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
ConduitEntity entity = tile.ent();
|
||||
entity.smoothLiquid = Mathf.lerpDelta(entity.smoothLiquid, entity.liquids.total() / liquidCapacity, 0.05f);
|
||||
entity.smoothLiquid = Mathf.lerpDelta(entity.smoothLiquid, entity.liquids.currentAmount() / liquidCapacity, 0.05f);
|
||||
|
||||
if(tile.entity.liquids.total() > 0.001f && tile.entity.timer.get(timerFlow, 1)){
|
||||
tryMoveLiquid(tile, tile.getNearby(tile.rotation()), leakResistance, tile.entity.liquids.current());
|
||||
|
||||
Reference in New Issue
Block a user