Custom map weather definition
This commit is contained in:
@@ -20,7 +20,7 @@ gameover = Game Over
|
|||||||
gameover.pvp = The[accent] {0}[] team is victorious!
|
gameover.pvp = The[accent] {0}[] team is victorious!
|
||||||
highscore = [accent]New highscore!
|
highscore = [accent]New highscore!
|
||||||
copied = Copied.
|
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.sound = Sounds
|
||||||
load.map = Maps
|
load.map = Maps
|
||||||
@@ -509,6 +509,11 @@ error.io = Network I/O error.
|
|||||||
error.any = Unknown network error.
|
error.any = Unknown network error.
|
||||||
error.bloom = Failed to initialize bloom.\nYour device may not support it.
|
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.unexplored = [lightgray]Unexplored
|
||||||
sectors.resources = Resources:
|
sectors.resources = Resources:
|
||||||
sectors.production = Production:
|
sectors.production = Production:
|
||||||
@@ -652,6 +657,7 @@ unit.liquidunits = liquid units
|
|||||||
unit.powerunits = power units
|
unit.powerunits = power units
|
||||||
unit.degrees = degrees
|
unit.degrees = degrees
|
||||||
unit.seconds = seconds
|
unit.seconds = seconds
|
||||||
|
unit.minutes = mins
|
||||||
unit.persecond = /sec
|
unit.persecond = /sec
|
||||||
unit.perminute = /min
|
unit.perminute = /min
|
||||||
unit.timesspeed = x speed
|
unit.timesspeed = x speed
|
||||||
@@ -842,7 +848,9 @@ rules.lighting = Lighting
|
|||||||
rules.fire = Fire
|
rules.fire = Fire
|
||||||
rules.explosions = Block/Unit Explosion Damage
|
rules.explosions = Block/Unit Explosion Damage
|
||||||
rules.ambientlight = Ambient Light
|
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.item.name = Items
|
||||||
content.liquid.name = Liquids
|
content.liquid.name = Liquids
|
||||||
|
|||||||
@@ -638,6 +638,7 @@ unit.liquidunits = жидкостных единиц
|
|||||||
unit.powerunits = энерг. единиц
|
unit.powerunits = энерг. единиц
|
||||||
unit.degrees = град.
|
unit.degrees = град.
|
||||||
unit.seconds = сек.
|
unit.seconds = сек.
|
||||||
|
unit.minutes = мин.
|
||||||
unit.persecond = /сек
|
unit.persecond = /сек
|
||||||
unit.timesspeed = x скорость
|
unit.timesspeed = x скорость
|
||||||
unit.percent = %
|
unit.percent = %
|
||||||
@@ -823,6 +824,7 @@ rules.title.environment = Окружение
|
|||||||
rules.lighting = Освещение
|
rules.lighting = Освещение
|
||||||
rules.ambientlight = Окружающий свет
|
rules.ambientlight = Окружающий свет
|
||||||
rules.solarpowermultiplier = Множитель солнечной энергии
|
rules.solarpowermultiplier = Множитель солнечной энергии
|
||||||
|
rules.weather = Погода
|
||||||
|
|
||||||
content.item.name = Предметы
|
content.item.name = Предметы
|
||||||
content.liquid.name = Жидкости
|
content.liquid.name = Жидкости
|
||||||
|
|||||||
@@ -329,6 +329,7 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void playTutorial(){
|
public void playTutorial(){
|
||||||
|
ui.showInfo("There is no tutorial yet.");
|
||||||
//TODO implement
|
//TODO implement
|
||||||
//ui.showInfo("death");
|
//ui.showInfo("death");
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -275,6 +275,8 @@ public class MapGenerateDialog extends BaseDialog{
|
|||||||
}
|
}
|
||||||
}).grow().left().pad(6).top();
|
}).grow().left().pad(6).top();
|
||||||
}).width(280f).pad(3).top().left().fillY();
|
}).width(280f).pad(3).top().left().fillY();
|
||||||
|
|
||||||
|
|
||||||
if(++i % cols == 0){
|
if(++i % cols == 0){
|
||||||
filterTable.row();
|
filterTable.row();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import arc.func.*;
|
|||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
|
import arc.scene.ui.layout.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
@@ -14,7 +15,7 @@ import mindustry.world.blocks.*;
|
|||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public abstract class Weather extends MappableContent{
|
public abstract class Weather extends UnlockableContent{
|
||||||
/** Default duration of this weather event in ticks. */
|
/** Default duration of this weather event in ticks. */
|
||||||
public float duration = 9f * Time.toMinutes;
|
public float duration = 9f * Time.toMinutes;
|
||||||
public Attributes attrs = new Attributes();
|
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
|
@Override
|
||||||
public ContentType getContentType(){
|
public ContentType getContentType(){
|
||||||
return ContentType.weather;
|
return ContentType.weather;
|
||||||
@@ -104,7 +115,7 @@ public abstract class Weather extends MappableContent{
|
|||||||
public Weather weather;
|
public Weather weather;
|
||||||
/** Minimum and maximum spacing between weather events. Does not include the time of the event itself. */
|
/** Minimum and maximum spacing between weather events. Does not include the time of the event itself. */
|
||||||
public float minFrequency, maxFrequency, minDuration, maxDuration;
|
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;
|
public float cooldown;
|
||||||
/** Intensity of the weather produced. */
|
/** Intensity of the weather produced. */
|
||||||
public float intensity = 1f;
|
public float intensity = 1f;
|
||||||
@@ -146,7 +157,7 @@ public abstract class Weather extends MappableContent{
|
|||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
if(life < fadeTime){
|
if(life < fadeTime){
|
||||||
opacity = life / fadeTime;
|
opacity = Math.min(life / fadeTime, opacity);
|
||||||
}else{
|
}else{
|
||||||
opacity = Mathf.lerpDelta(opacity, 1f, 0.004f);
|
opacity = Mathf.lerpDelta(opacity, 1f, 0.004f);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,19 +3,24 @@ package mindustry.ui.dialogs;
|
|||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.func.*;
|
import arc.func.*;
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
|
import arc.math.*;
|
||||||
import arc.scene.style.*;
|
import arc.scene.style.*;
|
||||||
import arc.scene.ui.*;
|
import arc.scene.ui.*;
|
||||||
|
import arc.scene.ui.ImageButton.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
|
import mindustry.ctype.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
|
import mindustry.type.Weather.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
|
||||||
|
import static arc.util.Time.*;
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class CustomRulesDialog extends BaseDialog{
|
public class CustomRulesDialog extends BaseDialog{
|
||||||
@@ -176,8 +181,9 @@ public class CustomRulesDialog extends BaseDialog{
|
|||||||
}}).grow();
|
}}).grow();
|
||||||
}).margin(4).size(50f).padRight(10);
|
}).margin(4).size(50f).padRight(10);
|
||||||
b.add("@rules.ambientlight");
|
b.add("@rules.ambientlight");
|
||||||
}, () -> ui.picker.show(rules.ambientLight, rules.ambientLight::set)).left().width(250f);
|
}, () -> ui.picker.show(rules.ambientLight, rules.ambientLight::set)).left().width(250f).row();
|
||||||
main.row();
|
|
||||||
|
main.button("@rules.weather", this::weatherDialog).width(250f).left().row();
|
||||||
|
|
||||||
//TODO add weather patterns
|
//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.image().color(Pal.accent).height(3f).padRight(100f).padBottom(20);
|
||||||
main.row();
|
main.row();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Cell<TextField> 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.<Weather>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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,10 +70,10 @@ public class ForceProjector extends Block{
|
|||||||
|
|
||||||
Draw.color(Pal.gray);
|
Draw.color(Pal.gray);
|
||||||
Lines.stroke(3f);
|
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);
|
Draw.color(player.team().color);
|
||||||
Lines.stroke(1f);
|
Lines.stroke(1f);
|
||||||
Lines.poly(x * tilesize, y * tilesize, 6, radius);
|
Lines.poly(x * tilesize + offset, y * tilesize + offset, 6, radius);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public enum StatUnit{
|
|||||||
powerUnits,
|
powerUnits,
|
||||||
degrees,
|
degrees,
|
||||||
seconds,
|
seconds,
|
||||||
|
minutes,
|
||||||
perSecond,
|
perSecond,
|
||||||
perMinute,
|
perMinute,
|
||||||
timesSpeed(false),
|
timesSpeed(false),
|
||||||
|
|||||||
Reference in New Issue
Block a user