diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index a8ebbbfc53..b5b0255c03 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -20,7 +20,7 @@ gameover = Game Over gameover.pvp = The[accent] {0}[] team is victorious! highscore = [accent]New highscore! copied = Copied. -indevpopup = [accent]v6[] is currently in [accent]pre-alpha[].\n[lightgray]This means:[]\n- Content is missing\n - Most [scarlet]Unit AI[] does not work\n- Many units are unfinished\n- The campaign is completely unfinished\n- Everything you see is subject to change or removal.\n\nReport bugs or crashes on [accent]Github[]. +indevpopup = [accent]v6[] is currently in [accent]alpha[].\n[lightgray]This means:[]\n- Content is missing\n - Most [scarlet]Unit AI[] does not work properly\n- Many units are unfinished\n- The campaign is completely unfinished\n- Everything you see is subject to change or removal.\n\nReport bugs or crashes on [accent]Github[]. load.sound = Sounds load.map = Maps @@ -509,6 +509,11 @@ error.io = Network I/O error. error.any = Unknown network error. error.bloom = Failed to initialize bloom.\nYour device may not support it. +weather.rain.name = Rain +weather.snow.name = Snow +weather.sandstorm.name = Sandstorm +weather.sporestorm.name = Sporestorm + sectors.unexplored = [lightgray]Unexplored sectors.resources = Resources: sectors.production = Production: @@ -652,6 +657,7 @@ unit.liquidunits = liquid units unit.powerunits = power units unit.degrees = degrees unit.seconds = seconds +unit.minutes = mins unit.persecond = /sec unit.perminute = /min unit.timesspeed = x speed @@ -842,7 +848,9 @@ rules.lighting = Lighting rules.fire = Fire rules.explosions = Block/Unit Explosion Damage rules.ambientlight = Ambient Light -rules.solarpowermultiplier = Solar Power Multiplier +rules.weather = Weather +rules.weather.frequency = Frequency: +rules.weather.duration = Duration: content.item.name = Items content.liquid.name = Liquids diff --git a/core/assets/bundles/bundle_ru.properties b/core/assets/bundles/bundle_ru.properties index a375e4ebb7..dd6b76b2ea 100644 --- a/core/assets/bundles/bundle_ru.properties +++ b/core/assets/bundles/bundle_ru.properties @@ -638,6 +638,7 @@ unit.liquidunits = жидкостных единиц unit.powerunits = энерг. единиц unit.degrees = град. unit.seconds = сек. +unit.minutes = мин. unit.persecond = /сек unit.timesspeed = x скорость unit.percent = % @@ -823,6 +824,7 @@ rules.title.environment = Окружение rules.lighting = Освещение rules.ambientlight = Окружающий свет rules.solarpowermultiplier = Множитель солнечной энергии +rules.weather = Погода content.item.name = Предметы content.liquid.name = Жидкости diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index f91d2f1217..3a175a6819 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -329,6 +329,7 @@ public class Control implements ApplicationListener, Loadable{ } public void playTutorial(){ + ui.showInfo("There is no tutorial yet."); //TODO implement //ui.showInfo("death"); /* diff --git a/core/src/mindustry/editor/MapGenerateDialog.java b/core/src/mindustry/editor/MapGenerateDialog.java index 7f540750d9..a8ceb58d79 100644 --- a/core/src/mindustry/editor/MapGenerateDialog.java +++ b/core/src/mindustry/editor/MapGenerateDialog.java @@ -275,6 +275,8 @@ public class MapGenerateDialog extends BaseDialog{ } }).grow().left().pad(6).top(); }).width(280f).pad(3).top().left().fillY(); + + if(++i % cols == 0){ filterTable.row(); } diff --git a/core/src/mindustry/type/Weather.java b/core/src/mindustry/type/Weather.java index 163fa7f211..6d414ef18c 100644 --- a/core/src/mindustry/type/Weather.java +++ b/core/src/mindustry/type/Weather.java @@ -4,6 +4,7 @@ import arc.func.*; import arc.graphics.g2d.*; import arc.math.*; import arc.math.geom.*; +import arc.scene.ui.layout.*; import arc.util.*; import mindustry.annotations.Annotations.*; import mindustry.content.*; @@ -14,7 +15,7 @@ import mindustry.world.blocks.*; import static mindustry.Vars.*; -public abstract class Weather extends MappableContent{ +public abstract class Weather extends UnlockableContent{ /** Default duration of this weather event in ticks. */ public float duration = 9f * Time.toMinutes; public Attributes attrs = new Attributes(); @@ -89,6 +90,16 @@ public abstract class Weather extends MappableContent{ } + @Override + public void displayInfo(Table table){ + //do not + } + + @Override + public boolean isHidden(){ + return true; + } + @Override public ContentType getContentType(){ return ContentType.weather; @@ -104,7 +115,7 @@ public abstract class Weather extends MappableContent{ public Weather weather; /** Minimum and maximum spacing between weather events. Does not include the time of the event itself. */ public float minFrequency, maxFrequency, minDuration, maxDuration; - /** Cooldown time before the next weather event takes place. */ + /** Cooldown time before the next weather event takes place This is *state*, not configuration. */ public float cooldown; /** Intensity of the weather produced. */ public float intensity = 1f; @@ -146,7 +157,7 @@ public abstract class Weather extends MappableContent{ @Override public void update(){ if(life < fadeTime){ - opacity = life / fadeTime; + opacity = Math.min(life / fadeTime, opacity); }else{ opacity = Mathf.lerpDelta(opacity, 1f, 0.004f); } diff --git a/core/src/mindustry/ui/dialogs/CustomRulesDialog.java b/core/src/mindustry/ui/dialogs/CustomRulesDialog.java index 8bf500205b..868875e2cf 100644 --- a/core/src/mindustry/ui/dialogs/CustomRulesDialog.java +++ b/core/src/mindustry/ui/dialogs/CustomRulesDialog.java @@ -3,19 +3,24 @@ package mindustry.ui.dialogs; import arc.*; import arc.func.*; import arc.graphics.*; +import arc.math.*; import arc.scene.style.*; import arc.scene.ui.*; +import arc.scene.ui.ImageButton.*; import arc.scene.ui.layout.*; import arc.struct.*; import arc.util.*; import mindustry.content.*; +import mindustry.ctype.*; import mindustry.game.*; import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; +import mindustry.type.Weather.*; import mindustry.ui.*; import mindustry.world.*; +import static arc.util.Time.*; import static mindustry.Vars.*; public class CustomRulesDialog extends BaseDialog{ @@ -176,8 +181,9 @@ public class CustomRulesDialog extends BaseDialog{ }}).grow(); }).margin(4).size(50f).padRight(10); b.add("@rules.ambientlight"); - }, () -> ui.picker.show(rules.ambientLight, rules.ambientLight::set)).left().width(250f); - main.row(); + }, () -> ui.picker.show(rules.ambientLight, rules.ambientLight::set)).left().width(250f).row(); + + main.button("@rules.weather", this::weatherDialog).width(250f).left().row(); //TODO add weather patterns } @@ -214,4 +220,110 @@ public class CustomRulesDialog extends BaseDialog{ main.image().color(Pal.accent).height(3f).padRight(100f).padBottom(20); main.row(); } + + Cell field(Table table, float value, Floatc setter){ + return table.field(Strings.autoFixed(value, 2), v -> setter.get(Strings.parseFloat(v))) + .valid(Strings::canParsePositiveFloat) + .size(90f, 40f).pad(2f).addInputDialog(); + } + + void weatherDialog(){ + BaseDialog dialog = new BaseDialog("@rules.weather"); + Runnable[] rebuild = {null}; + + dialog.cont.pane(base -> { + + rebuild[0] = () -> { + base.clearChildren(); + int cols = Math.max(1, Core.graphics.getWidth() / 460); + int idx = 0; + + for(WeatherEntry entry : rules.weather){ + base.top(); + //main container + base.table(Tex.pane, c -> { + c.margin(0); + + //icons to perform actions + c.table(Tex.whiteui, t -> { + t.setColor(Pal.gray); + + t.top().left(); + t.add(entry.weather.localizedName).left().padLeft(6); + + t.add().growX(); + + ImageButtonStyle style = Styles.geni; + t.defaults().size(42f); + + t.button(Icon.cancel, style, () -> { + rules.weather.remove(entry); + rebuild[0].run(); + }); + }).growX(); + + c.row(); + + //all the options + c.table(f -> { + f.marginLeft(4); + f.left().top(); + + f.defaults().padRight(4).left(); + + f.add("@rules.weather.duration"); + field(f, entry.minDuration / toMinutes, v -> entry.minDuration = v * toMinutes); + f.add("@waves.to"); + field(f, entry.maxDuration / toMinutes, v -> entry.maxDuration = v * toMinutes); + f.add("@unit.minutes"); + + f.row(); + + f.add("@rules.weather.frequency"); + field(f, entry.minFrequency / toMinutes, v -> entry.minFrequency = v * toMinutes); + f.add("@waves.to"); + field(f, entry.maxFrequency / toMinutes, v -> entry.maxFrequency = v * toMinutes); + f.add("@unit.minutes"); + + //intensity can't currently be customized + + }).grow().left().pad(6).top(); + }).width(410f).pad(3).top().left().fillY(); + + if(++idx % cols == 0){ + base.row(); + } + } + }; + + rebuild[0].run(); + }).grow(); + + dialog.addCloseButton(); + + dialog.buttons.button("@add", Icon.add, () -> { + BaseDialog addd = new BaseDialog("@add"); + addd.cont.pane(t -> { + t.background(Tex.button); + int i = 0; + for(Weather weather : content.getBy(ContentType.weather)){ + + t.button(weather.localizedName, Styles.cleart, () -> { + rules.weather.add(new WeatherEntry(weather)); + rebuild[0].run(); + + addd.hide(); + }).size(140f, 50f); + if(++i % 2 == 0) t.row(); + } + }); + addd.addCloseButton(); + addd.show(); + }).width(170f); + + //reset cooldown to random number + dialog.hidden(() -> rules.weather.each(w -> w.cooldown = Mathf.random(w.minFrequency, w.maxFrequency))); + + dialog.show(); + } } diff --git a/core/src/mindustry/world/blocks/defense/ForceProjector.java b/core/src/mindustry/world/blocks/defense/ForceProjector.java index f401aff34b..8d54dfad9f 100644 --- a/core/src/mindustry/world/blocks/defense/ForceProjector.java +++ b/core/src/mindustry/world/blocks/defense/ForceProjector.java @@ -70,10 +70,10 @@ public class ForceProjector extends Block{ Draw.color(Pal.gray); Lines.stroke(3f); - Lines.poly(x * tilesize, y * tilesize, 6, radius); + Lines.poly(x * tilesize + offset, y * tilesize + offset, 6, radius); Draw.color(player.team().color); Lines.stroke(1f); - Lines.poly(x * tilesize, y * tilesize, 6, radius); + Lines.poly(x * tilesize + offset, y * tilesize + offset, 6, radius); Draw.color(); } diff --git a/core/src/mindustry/world/meta/StatUnit.java b/core/src/mindustry/world/meta/StatUnit.java index 4cdc6a6182..721ac7c582 100644 --- a/core/src/mindustry/world/meta/StatUnit.java +++ b/core/src/mindustry/world/meta/StatUnit.java @@ -16,6 +16,7 @@ public enum StatUnit{ powerUnits, degrees, seconds, + minutes, perSecond, perMinute, timesSpeed(false),