Various fixes
This commit is contained in:
@@ -318,20 +318,25 @@ public class Vars implements Loadable{
|
||||
|
||||
settings.setAppName(appName);
|
||||
|
||||
Writer writer = settings.getDataDirectory().child("last_log.txt").writer(false);
|
||||
LogHandler log = Log.logger;
|
||||
//ignore it
|
||||
Log.logger = (level, text) -> {
|
||||
log.log(level, text);
|
||||
try{
|
||||
Writer writer = settings.getDataDirectory().child("last_log.txt").writer(false);
|
||||
LogHandler log = Log.logger;
|
||||
//ignore it
|
||||
Log.logger = (level, text) -> {
|
||||
log.log(level, text);
|
||||
|
||||
try{
|
||||
writer.write("[" + Character.toUpperCase(level.name().charAt(0)) +"] " + Log.removeColors(text) + "\n");
|
||||
writer.flush();
|
||||
}catch(IOException e){
|
||||
e.printStackTrace();
|
||||
//ignore it
|
||||
}
|
||||
};
|
||||
try{
|
||||
writer.write("[" + Character.toUpperCase(level.name().charAt(0)) +"] " + Log.removeColors(text) + "\n");
|
||||
writer.flush();
|
||||
}catch(IOException e){
|
||||
e.printStackTrace();
|
||||
//ignore it
|
||||
}
|
||||
};
|
||||
}catch(Exception e){
|
||||
//handle log file not being found
|
||||
Log.err(e);
|
||||
}
|
||||
|
||||
loadedFileLogger = true;
|
||||
}
|
||||
|
||||
@@ -429,8 +429,8 @@ public class UnitTypes implements ContentList{
|
||||
continuous = true;
|
||||
cooldownTime = 200f;
|
||||
|
||||
bullet = new ContinuousLaserBulletType(20){{
|
||||
length = 150f;
|
||||
bullet = new ContinuousLaserBulletType(22){{
|
||||
length = 160f;
|
||||
hitEffect = Fx.hitMeltHeal;
|
||||
drawSize = 420f;
|
||||
lifetime = 160f;
|
||||
@@ -445,7 +445,7 @@ public class UnitTypes implements ContentList{
|
||||
incendAmount = 1;
|
||||
|
||||
//constant healing
|
||||
healPercent = 0.5f;
|
||||
healPercent = 1f;
|
||||
collidesTeam = true;
|
||||
|
||||
colors = new Color[]{Pal.heal.cpy().a(.2f), Pal.heal.cpy().a(.5f), Pal.heal.cpy().mul(1.2f), Color.white};
|
||||
@@ -909,7 +909,7 @@ public class UnitTypes implements ContentList{
|
||||
|
||||
horizon = new UnitType("horizon"){{
|
||||
health = 350;
|
||||
speed = 2f;
|
||||
speed = 1.8f;
|
||||
accel = 0.08f;
|
||||
drag = 0.016f;
|
||||
flying = true;
|
||||
@@ -931,7 +931,7 @@ public class UnitTypes implements ContentList{
|
||||
inaccuracy = 15f;
|
||||
ignoreRotation = true;
|
||||
shootSound = Sounds.none;
|
||||
bullet = new BombBulletType(28f, 25f){{
|
||||
bullet = new BombBulletType(27f, 25f){{
|
||||
width = 10f;
|
||||
height = 14f;
|
||||
hitEffect = Fx.flakExplosion;
|
||||
|
||||
@@ -18,6 +18,7 @@ public class Weathers implements ContentList{
|
||||
@Override
|
||||
public void load(){
|
||||
snow = new ParticleWeather("snow"){{
|
||||
particleRegion = "particle";
|
||||
sizeMax = 13f;
|
||||
sizeMin = 2.6f;
|
||||
density = 1200f;
|
||||
@@ -32,6 +33,7 @@ public class Weathers implements ContentList{
|
||||
|
||||
sandstorm = new ParticleWeather("sandstorm"){{
|
||||
color = noiseColor = Color.valueOf("f7cba4");
|
||||
particleRegion = "particle";
|
||||
drawNoise = true;
|
||||
useWindVector = true;
|
||||
sizeMax = 140f;
|
||||
@@ -48,7 +50,7 @@ public class Weathers implements ContentList{
|
||||
|
||||
sporestorm = new ParticleWeather("sporestorm"){{
|
||||
color = noiseColor = Color.valueOf("7457ce");
|
||||
particleRegion = "circle";
|
||||
particleRegion = "circle-small";
|
||||
drawNoise = true;
|
||||
statusGround = false;
|
||||
useWindVector = true;
|
||||
|
||||
@@ -390,7 +390,7 @@ public class UI implements ApplicationListener, Loadable{
|
||||
public void showException(String text, Throwable exc){
|
||||
loadfrag.hide();
|
||||
new Dialog(""){{
|
||||
String message = Strings.getFinalMesage(exc);
|
||||
String message = Strings.getFinalMessage(exc);
|
||||
|
||||
setFillParent(true);
|
||||
cont.margin(15);
|
||||
|
||||
@@ -20,8 +20,8 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
public Stats stats = new Stats();
|
||||
/** Localized, formal name. Never null. Set to internal name if not found in bundle. */
|
||||
public String localizedName;
|
||||
/** Localized description. May be null. */
|
||||
public @Nullable String description;
|
||||
/** Localized description & details. May be null. */
|
||||
public @Nullable String description, details;
|
||||
/** Whether this content is always unlocked in the tech tree. */
|
||||
public boolean alwaysUnlocked = false;
|
||||
/** Special logic icon ID. */
|
||||
@@ -36,6 +36,7 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
|
||||
this.localizedName = Core.bundle.get(getContentType() + "." + this.name + ".name", this.name);
|
||||
this.description = Core.bundle.getOrNull(getContentType() + "." + this.name + ".description");
|
||||
this.details = Core.bundle.getOrNull(getContentType() + "." + this.name + ".details");
|
||||
this.unlocked = Core.settings != null && Core.settings.getBool(this.name + "-unlocked", false);
|
||||
}
|
||||
|
||||
@@ -51,7 +52,7 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
}
|
||||
}
|
||||
|
||||
/** Intializes stats on demand. Should only be called once. Only called before something is displayed. */
|
||||
/** Initializes stats on demand. Should only be called once. Only called before something is displayed. */
|
||||
public void setStats(){
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ public class OverlayRenderer{
|
||||
|
||||
input.drawOverSelect();
|
||||
|
||||
if(ui.hudfrag.blockfrag.hover() instanceof Unit unit && unit.controller() instanceof LogicAI ai && ai.controller instanceof Building build){
|
||||
if(ui.hudfrag.blockfrag.hover() instanceof Unit unit && unit.controller() instanceof LogicAI ai && ai.controller instanceof Building build && build.isValid()){
|
||||
Drawf.square(build.x, build.y, build.block.size * tilesize/2f + 2f);
|
||||
if(!unit.within(build, unit.hitSize * 2f)){
|
||||
Drawf.arrow(unit.x, unit.y, build.x, build.y, unit.hitSize *2f, 4f);
|
||||
|
||||
@@ -333,7 +333,7 @@ public class TypeIO{
|
||||
//1: prev controller was not a player, carry on
|
||||
//2: prev controller was a player, so replace this controller with *anything else*
|
||||
//...since AI doesn't update clientside it doesn't matter
|
||||
return (!(prev instanceof AIController) || (prev instanceof FormationAI)) ? new GroundAI() : prev;
|
||||
return (!(prev instanceof AIController) || (prev instanceof FormationAI) || (prev instanceof LogicAI)) ? new GroundAI() : prev;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
public class LCanvas extends Table{
|
||||
public static final int maxJumpsDrawn = 100;
|
||||
//ew static variables
|
||||
static LCanvas canvas;
|
||||
|
||||
@@ -25,7 +26,9 @@ public class LCanvas extends Table{
|
||||
StatementElem dragging;
|
||||
ScrollPane pane;
|
||||
Group jumps;
|
||||
StatementElem hovered;
|
||||
float targetWidth;
|
||||
int jumpCount = 0;
|
||||
|
||||
public LCanvas(){
|
||||
canvas = this;
|
||||
@@ -69,6 +72,12 @@ public class LCanvas extends Table{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
jumpCount = 0;
|
||||
super.draw();
|
||||
}
|
||||
|
||||
void add(LStatement statement){
|
||||
statements.addChild(new StatementElem(statement));
|
||||
}
|
||||
@@ -97,10 +106,23 @@ public class LCanvas extends Table{
|
||||
this.statements.layout();
|
||||
}
|
||||
|
||||
StatementElem checkHovered(){
|
||||
Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true);
|
||||
if(e != null){
|
||||
while(e != null && !(e instanceof StatementElem)){
|
||||
e = e.parent;
|
||||
}
|
||||
}
|
||||
if(e == null || isDescendantOf(e)) return null;
|
||||
return (StatementElem)e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta){
|
||||
super.act(delta);
|
||||
|
||||
hovered = checkHovered();
|
||||
|
||||
if(Core.input.isTouched()){
|
||||
float y = Core.input.mouseY();
|
||||
float dst = Math.min(y - this.y, Core.graphics.getHeight() - y);
|
||||
@@ -351,7 +373,6 @@ public class LCanvas extends Table{
|
||||
boolean selecting;
|
||||
float mx, my;
|
||||
ClickListener listener;
|
||||
StatementElem hovered;
|
||||
|
||||
JumpCurve curve;
|
||||
|
||||
@@ -380,7 +401,7 @@ public class LCanvas extends Table{
|
||||
@Override
|
||||
public void touchUp(InputEvent event, float x, float y, int pointer, KeyCode code){
|
||||
localToStageCoordinates(Tmp.v1.set(x, y));
|
||||
StatementElem elem = hovered();
|
||||
StatementElem elem = canvas.hovered;
|
||||
|
||||
if(elem != null && !isDescendantOf(elem)){
|
||||
setter.get(elem);
|
||||
@@ -403,13 +424,6 @@ public class LCanvas extends Table{
|
||||
curve = new JumpCurve(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta){
|
||||
super.act(delta);
|
||||
|
||||
hovered = hovered();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setScene(Scene stage){
|
||||
super.setScene(stage);
|
||||
@@ -420,17 +434,6 @@ public class LCanvas extends Table{
|
||||
canvas.jumps.addChild(curve);
|
||||
}
|
||||
}
|
||||
|
||||
StatementElem hovered(){
|
||||
Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true);
|
||||
if(e != null){
|
||||
while(e != null && !(e instanceof StatementElem)){
|
||||
e = e.parent;
|
||||
}
|
||||
}
|
||||
if(e == null || isDescendantOf(e)) return null;
|
||||
return (StatementElem)e;
|
||||
}
|
||||
}
|
||||
|
||||
public static class JumpCurve extends Element{
|
||||
@@ -451,7 +454,13 @@ public class LCanvas extends Table{
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Element hover = button.to.get() == null && button.selecting ? button.hovered : button.to.get();
|
||||
canvas.jumpCount ++;
|
||||
|
||||
if(canvas.jumpCount > maxJumpsDrawn && !button.selecting && !button.listener.isOver()){
|
||||
return;
|
||||
}
|
||||
|
||||
Element hover = button.to.get() == null && button.selecting ? canvas.hovered : button.to.get();
|
||||
boolean draw = false;
|
||||
Vec2 t = Tmp.v1, r = Tmp.v2;
|
||||
|
||||
@@ -489,12 +498,27 @@ public class LCanvas extends Table{
|
||||
|
||||
float dist = 100f;
|
||||
|
||||
//square jumps
|
||||
if(false){
|
||||
float len = Scl.scl(Mathf.randomSeed(hashCode(), 10, 50));
|
||||
|
||||
float maxX = Math.max(x, x2) + len;
|
||||
|
||||
Lines.beginLine();
|
||||
Lines.linePoint(x, y);
|
||||
Lines.linePoint(maxX, y);
|
||||
Lines.linePoint(maxX, y2);
|
||||
Lines.linePoint(x2, y2);
|
||||
Lines.endLine();
|
||||
return;
|
||||
}
|
||||
|
||||
Lines.curve(
|
||||
x, y,
|
||||
x + dist, y,
|
||||
x2 + dist, y2,
|
||||
x2, y2,
|
||||
Math.max(20, (int)(Mathf.dst(x, y, x2, y2) / 6))
|
||||
Math.max(18, (int)(Mathf.dst(x, y, x2, y2) / 6))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class Net{
|
||||
t = t.getCause();
|
||||
}
|
||||
|
||||
String baseError = Strings.getFinalMesage(e);
|
||||
String baseError = Strings.getFinalMessage(e);
|
||||
|
||||
String error = baseError == null ? "" : baseError.toLowerCase();
|
||||
String type = t.getClass().toString().toLowerCase();
|
||||
|
||||
@@ -62,7 +62,13 @@ public class Bar extends Element{
|
||||
public void draw(){
|
||||
if(fraction == null) return;
|
||||
|
||||
float computed = Mathf.clamp(fraction.get());
|
||||
float computed;
|
||||
try{
|
||||
computed = Mathf.clamp(fraction.get());
|
||||
}catch(Exception e){ //getting the fraction may involve referring to invalid data
|
||||
computed = 0f;
|
||||
}
|
||||
|
||||
if(lastValue > computed){
|
||||
blink = 1f;
|
||||
lastValue = computed;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package mindustry.ui.dialogs;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
@@ -36,16 +35,16 @@ public class ContentInfoDialog extends BaseDialog{
|
||||
|
||||
table.row();
|
||||
|
||||
table.image().height(3).color(Color.lightGray).pad(8).padLeft(0).padRight(0).fillX();
|
||||
|
||||
table.row();
|
||||
|
||||
if(content.description != null){
|
||||
table.add(content.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
|
||||
table.add("@category.purpose").color(Pal.accent).fillX().padTop(10);
|
||||
table.row();
|
||||
table.add("[lightgray]" + content.displayDescription()).wrap().fillX().padLeft(10).width(500f).left();
|
||||
table.row();
|
||||
|
||||
table.image().height(3).color(Color.lightGray).pad(8).padLeft(0).padRight(0).fillX();
|
||||
table.row();
|
||||
if(!content.stats.useCategories){
|
||||
table.add("@category.general").fillX().color(Pal.accent);
|
||||
table.row();
|
||||
}
|
||||
}
|
||||
|
||||
Stats stats = content.stats;
|
||||
@@ -76,6 +75,12 @@ public class ContentInfoDialog extends BaseDialog{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(content.details != null){
|
||||
table.add("[gray]" + content.details).pad(6).padTop(20).width(400f).wrap().fillX();
|
||||
table.row();
|
||||
}
|
||||
|
||||
ScrollPane pane = new ScrollPane(table);
|
||||
cont.add(pane);
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
if(to.near().contains(launchSector)) return launchSector;
|
||||
|
||||
Sector launchFrom = launchSector;
|
||||
if(launchFrom == null || (to.preset == null && !to.near().contains(launchSector))){
|
||||
if(launchFrom == null){
|
||||
//TODO pick one with the most resources
|
||||
launchFrom = to.near().find(Sector::hasBase);
|
||||
if(launchFrom == null && to.preset != null){
|
||||
|
||||
@@ -305,7 +305,7 @@ public class Block extends UnlockableContent{
|
||||
return hasItems;
|
||||
}
|
||||
|
||||
/** Returns whether ot not this block can be place on the specified */
|
||||
/** Returns whether or not this block can be place on the specified */
|
||||
public boolean canPlaceOn(Tile tile, Team team){
|
||||
return true;
|
||||
}
|
||||
@@ -365,7 +365,7 @@ public class Block extends UnlockableContent{
|
||||
float capacity = cons.capacity;
|
||||
|
||||
bars.add("power", entity -> new Bar(() -> buffered ? Core.bundle.format("bar.poweramount", Float.isNaN(entity.power.status * capacity) ? "<ERROR>" : (int)(entity.power.status * capacity)) :
|
||||
Core.bundle.get("bar.power"), () -> Pal.powerBar, () -> Mathf.zero(cons.requestedPower(entity)) && entity.power.graph.getPowerProduced() + entity.power.graph.getBatteryStored() > 0f ? 1f : entity.power.status));
|
||||
Core.bundle.get("bar.power"), () -> Pal.powerBar, () -> Mathf.zero(cons.requestedPower(entity)) && entity.power.graph.getPowerProduced() + entity.power.graph.getBatteryStored() > 0f ? 1f : entity.power.status));
|
||||
}
|
||||
|
||||
if(hasItems && configurable){
|
||||
|
||||
@@ -27,23 +27,27 @@ public class PayloadAcceptor extends Block{
|
||||
sync = true;
|
||||
}
|
||||
|
||||
public static boolean blends(Building tile, int direction){
|
||||
int size = tile.block.size;
|
||||
Building accept = tile.nearby(Geometry.d4(direction).x * size, Geometry.d4(direction).y * size);
|
||||
public static boolean blends(Building build, int direction){
|
||||
int size = build.block.size;
|
||||
int trns = build.block.size/2 + 1;
|
||||
Building accept = build.nearby(Geometry.d4(direction).x * trns, Geometry.d4(direction).y * trns);
|
||||
return accept != null &&
|
||||
accept.block.outputsPayload &&
|
||||
|
||||
//if size is the same, block must either be facing this one, or not be rotating
|
||||
((accept.block.size == size &&
|
||||
((accept.tileX() + Geometry.d4(accept.rotation).x * size == tile.tileX() && accept.tileY() + Geometry.d4(accept.rotation).y * size == tile.tileY())
|
||||
|| !accept.block.rotate || (accept.block.rotate && !accept.block.outputFacing))) ||
|
||||
((accept.block.size == size
|
||||
&& Math.abs(accept.tileX() - build.tileX()) % size == 0 //check alignment
|
||||
&& Math.abs(accept.tileY() - build.tileY()) % size == 0
|
||||
&& ((accept.block.rotate && accept.tileX() + Geometry.d4(accept.rotation).x * size == build.tileX() && accept.tileY() + Geometry.d4(accept.rotation).y * size == build.tileY())
|
||||
|| !accept.block.rotate
|
||||
|| !accept.block.outputFacing)) ||
|
||||
|
||||
//if the other block is smaller, check alignment
|
||||
(accept.block.size < size &&
|
||||
(accept.rotation % 2 == 0 ? //check orientation; make sure it's aligned properly with this block.
|
||||
Math.abs(accept.y - tile.y) <= (size * tilesize - accept.block.size * tilesize)/2f : //check Y alignment
|
||||
Math.abs(accept.x - tile.x) <= (size * tilesize - accept.block.size * tilesize)/2f //check X alignment
|
||||
)) && (!accept.block.rotate || accept.front() == tile || !accept.block.outputFacing) //make sure it's facing this block
|
||||
Math.abs(accept.y - build.y) <= (size * tilesize - accept.block.size * tilesize)/2f : //check Y alignment
|
||||
Math.abs(accept.x - build.x) <= (size * tilesize - accept.block.size * tilesize)/2f //check X alignment
|
||||
)) && (!accept.block.rotate || accept.front() == build || !accept.block.outputFacing) //make sure it's facing this block
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user