Merge branch 'master' into crater

This commit is contained in:
Patrick 'Quezler' Mounier
2020-04-02 12:05:04 +02:00
72 changed files with 2348 additions and 642 deletions

View File

@@ -118,6 +118,7 @@ public class ContentLoader{
callable.get(content);
}catch(Throwable e){
if(content.minfo.mod != null){
Log.err(e);
mods.handleContentError(content, e);
}else{
throw new RuntimeException(e);
@@ -139,7 +140,7 @@ public class ContentLoader{
if(color == 0) continue;
Block block = block(i);
Color.rgba8888ToColor(block.color, color);
block.color.set(color);
}
}
pixmap.dispose();

View File

@@ -193,7 +193,7 @@ public class Control implements ApplicationListener, Loadable{
Core.settings.defaults(
"ip", "localhost",
"color-0", Color.rgba8888(playerColors[8]),
"color-0", playerColors[8].rgba(),
"name", "",
"lastBuild", 0
);

View File

@@ -81,7 +81,7 @@ public class NetClient implements ApplicationListener{
c.mods = mods.getModStrings();
c.mobile = mobile;
c.versionType = Version.type;
c.color = Color.rgba8888(player.color);
c.color = player.color.rgba();
c.usid = getUsid(packet.addressTCP);
c.uuid = platform.getUUID();
@@ -103,6 +103,7 @@ public class NetClient implements ApplicationListener{
logic.reset();
platform.updateRPC();
player.name = Core.settings.getString("name");
player.color.set(Core.settings.getInt("color-0"));
if(quiet) return;

View File

@@ -337,7 +337,7 @@ public class UI implements ApplicationListener, Loadable{
new Dialog(""){{
getCell(cont).growX();
cont.margin(15).add(info).width(400f).wrap().get().setAlignment(Align.center, Align.center);
buttons.addButton("$ok", this::hide).size(90, 50).pad(4);
buttons.addButton("$ok", this::hide).size(110, 50).pad(4);
}}.show();
}
@@ -376,7 +376,7 @@ public class UI implements ApplicationListener, Loadable{
Collapser col = new Collapser(base -> base.pane(t -> t.margin(14f).add(Strings.parseException(exc, true)).color(Color.lightGray).left()), true);
cont.addButton("$details", Styles.togglet, col::toggle).size(180f, 50f).checked(b -> !col.isCollapsed()).fillX().right();
cont.addButton("$ok", this::hide).size(100, 50).fillX().left();
cont.addButton("$ok", this::hide).size(110, 50).fillX().left();
cont.row();
cont.add(col).colspan(2).pad(2);
}}.show();
@@ -424,14 +424,14 @@ public class UI implements ApplicationListener, Loadable{
cont.row();
cont.add(text).width(400f).wrap().get().setAlignment(align, align);
cont.row();
buttons.addButton("$ok", this::hide).size(90, 50).pad(4);
buttons.addButton("$ok", this::hide).size(110, 50).pad(4);
}}.show();
}
public void showInfoText(String titleText, String text){
new Dialog(titleText){{
cont.margin(15).add(text).width(400f).wrap().left().get().setAlignment(Align.left, Align.left);
buttons.addButton("$ok", this::hide).size(90, 50).pad(4);
buttons.addButton("$ok", this::hide).size(110, 50).pad(4);
}}.show();
}
@@ -440,7 +440,7 @@ public class UI implements ApplicationListener, Loadable{
cont.margin(10).add(text);
titleTable.row();
titleTable.addImage().color(Pal.accent).height(3f).growX().pad(2f);
buttons.addButton("$ok", this::hide).size(90, 50).pad(4);
buttons.addButton("$ok", this::hide).size(110, 50).pad(4);
}}.show();
}

View File

@@ -900,7 +900,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
super.writeSave(buffer, !isLocal);
TypeIO.writeStringData(buffer, name);
buffer.writeByte(Pack.byteValue(isAdmin) | (Pack.byteValue(dead) << 1) | (Pack.byteValue(isBoosting) << 2) | (Pack.byteValue(isTyping) << 3)| (Pack.byteValue(isBuilding) << 4));
buffer.writeInt(Color.rgba8888(color));
buffer.writeInt(color.rgba());
buffer.writeByte(mech.id);
buffer.writeInt(mining == null ? noSpawner : mining.pos());
buffer.writeInt(spawner == null || !spawner.hasUnit(this) ? noSpawner : spawner.getTile().pos());

View File

@@ -183,7 +183,7 @@ public class Schematics implements Loadable{
Tmp.m2.set(Draw.trans());
FrameBuffer buffer = new FrameBuffer((schematic.width + padding) * resolution, (schematic.height + padding) * resolution);
shadowBuffer.beginDraw(Color.clear);
shadowBuffer.begin(Color.clear);
Draw.trans().idt();
Draw.proj().setOrtho(0, 0, shadowBuffer.getWidth(), shadowBuffer.getHeight());
@@ -202,9 +202,9 @@ public class Schematics implements Loadable{
}
});
shadowBuffer.endDraw();
shadowBuffer.end();
buffer.beginDraw(Color.clear);
buffer.begin(Color.clear);
Draw.proj().setOrtho(0, buffer.getHeight(), buffer.getWidth(), -buffer.getHeight());
@@ -231,7 +231,7 @@ public class Schematics implements Loadable{
Draw.flush();
Draw.trans().idt();
buffer.endDraw();
buffer.end();
Draw.proj(Tmp.m1);
Draw.trans(Tmp.m2);

View File

@@ -183,14 +183,14 @@ public class LightRenderer{
}
Draw.color();
buffer.beginDraw(Color.clear);
buffer.begin(Color.clear);
Gl.blendEquationSeparate(Gl.funcAdd, Gl.max);
for(Runnable run : lights){
run.run();
}
Draw.reset();
buffer.endDraw();
buffer.end();
Gl.blendEquationSeparate(Gl.funcAdd, Gl.funcAdd);
Draw.color();

View File

@@ -169,7 +169,7 @@ public class MenuRenderer implements Disposable{
//draw shadows
Draw.proj().setOrtho(0, 0, shadows.getWidth(), shadows.getHeight());
shadows.beginDraw(Color.clear);
shadows.begin(Color.clear);
Draw.color(Color.black);
for(int x = 0; x < width; x++){
for(int y = 0; y < height; y++){
@@ -179,7 +179,7 @@ public class MenuRenderer implements Disposable{
}
}
Draw.color();
shadows.endDraw();
shadows.end();
SpriteBatch prev = Core.batch;

View File

@@ -75,7 +75,7 @@ public class MapIO{
Pixmap floors = new Pixmap(map.width, map.height, Format.RGBA8888);
Pixmap walls = new Pixmap(map.width, map.height, Format.RGBA8888);
int black = Color.rgba8888(Color.black);
int black = 255;
int shade = Color.rgba8888(0f, 0f, 0f, 0.5f);
CachedTile tile = new CachedTile(){
@Override
@@ -148,7 +148,7 @@ public class MapIO{
if(wall.synthetic()){
return team.color.rgba();
}
return Color.rgba8888(wall.solid ? wall.color : ore == Blocks.air ? floor.color : ore.color);
return (wall.solid ? wall.color : ore == Blocks.air ? floor.color : ore.color).rgba();
}
/** Reads a pixmap in the 3.5 pixmap format. */
@@ -164,7 +164,7 @@ public class MapIO{
if(block.ore != null) tile.setOverlay(block.ore);
//place core
if(color == Color.rgba8888(Color.green)){
if(color == Color.green.rgba()){
//actual core parts
tile.setBlock(Blocks.coreShard);
tile.setTeam(Team.sharded);

View File

@@ -244,7 +244,7 @@ public class TypeIO{
@WriteClass(Color.class)
public static void writeColor(ByteBuffer buffer, Color color){
buffer.putInt(Color.rgba8888(color));
buffer.putInt(color.rgba());
}
@ReadClass(Color.class)

View File

@@ -454,6 +454,8 @@ public class ContentParser{
if(t.getMessage() != null && t instanceof JsonParseException){
builder.append("[accent][[JsonParse][] ").append(":\n").append(t.getMessage());
}else if(t instanceof NullPointerException){
builder.append(Strings.parseException(t, true));
}else{
Array<Throwable> causes = Strings.getCauses(t);
for(Throwable e : causes){

View File

@@ -122,7 +122,7 @@ public class Scripts implements Disposable{
if(matched.find()){
LoadedMod required = Vars.mods.locateMod(matched.group(1));
String script = matched.group(2);
if(required == null || root.equals(required.root.child("scripts"))){ // Mod not found, or already using a mod
if(required == null){ // Mod not found, treat it as a folder
Fi dir = root.child(matched.group(1));
if(!dir.exists()) return null; // Mod and folder not found
return loadSource(script, dir, validator);

View File

@@ -1,7 +1,6 @@
package mindustry.ui.dialogs;
import arc.*;
import arc.graphics.*;
import arc.scene.ui.*;
import arc.util.*;
import mindustry.*;
@@ -33,7 +32,7 @@ public class HostDialog extends FloatingDialog{
ImageButton button = t.addImageButton(Tex.whiteui, Styles.clearFulli, 40, () -> {
new PaletteDialog().show(color -> {
player.color.set(color);
Core.settings.put("color-0", Color.rgba8888(color));
Core.settings.put("color-0", color.rgba());
Core.settings.save();
});
}).size(54f).get();

View File

@@ -1,16 +1,15 @@
package mindustry.ui.dialogs;
import arc.*;
import mindustry.annotations.Annotations.*;
import arc.struct.*;
import arc.graphics.*;
import arc.input.*;
import arc.math.*;
import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import arc.util.serialization.*;
import mindustry.*;
import mindustry.annotations.Annotations.*;
import mindustry.core.*;
import mindustry.gen.*;
import mindustry.graphics.*;
@@ -275,7 +274,7 @@ public class JoinDialog extends FloatingDialog{
ImageButton button = t.addImageButton(Tex.whiteui, Styles.clearFulli, 40, () -> {
new PaletteDialog().show(color -> {
player.color.set(color);
Core.settings.put("color-0", Color.rgba8888(color));
Core.settings.put("color-0", color.rgba());
Core.settings.save();
});
}).size(54f).get();

View File

@@ -21,6 +21,7 @@ public class PlayerListFragment extends Fragment{
private boolean visible = false;
private Table content = new Table().marginRight(13f).marginLeft(13f);
private Interval timer = new Interval();
private TextField sField;
@Override
public void build(Group parent){
@@ -44,6 +45,12 @@ public class PlayerListFragment extends Fragment{
cont.table(Tex.buttonTrans, pane -> {
pane.label(() -> Core.bundle.format(playerGroup.size() == 1 ? "players.single" : "players", playerGroup.size()));
pane.row();
sField = pane.addField(null, text -> {
rebuild();
}).grow().pad(8).get();
sField.setMaxLength(maxNameLength);
sField.setMessageText(Core.bundle.format("players.search"));
pane.row();
pane.pane(content).grow().get().setScrollingDisabled(true, false);
pane.row();
@@ -71,6 +78,7 @@ public class PlayerListFragment extends Fragment{
NetConnection connection = user.con;
if(connection == null && net.server() && !user.isLocal) return;
if(sField.getText().length() > 0 && !user.name.toLowerCase().contains(sField.getText().toLowerCase()) && !Strings.stripColors(user.name.toLowerCase()).contains(sField.getText().toLowerCase())) return;
Table button = new Table();
button.left();
@@ -105,9 +113,9 @@ public class PlayerListFragment extends Fragment{
t.defaults().size(bs);
t.addImageButton(Icon.hammer, Styles.clearPartiali,
() -> ui.showConfirm("$confirm", "$confirmban", () -> Call.onAdminRequest(user, AdminAction.ban)));
() -> ui.showConfirm("$confirm", "$confirmban", () -> Call.onAdminRequest(user, AdminAction.ban)));
t.addImageButton(Icon.cancel, Styles.clearPartiali,
() -> ui.showConfirm("$confirm", "$confirmkick", () -> Call.onAdminRequest(user, AdminAction.kick)));
() -> ui.showConfirm("$confirm", "$confirmkick", () -> Call.onAdminRequest(user, AdminAction.kick)));
t.row();
@@ -122,10 +130,10 @@ public class PlayerListFragment extends Fragment{
ui.showConfirm("$confirm", "$confirmadmin", () -> netServer.admins.adminPlayer(id, user.usid));
}
})
.update(b -> b.setChecked(user.isAdmin))
.disabled(b -> net.client())
.touchable(() -> net.client() ? Touchable.disabled : Touchable.enabled)
.checked(user.isAdmin);
.update(b -> b.setChecked(user.isAdmin))
.disabled(b -> net.client())
.touchable(() -> net.client() ? Touchable.disabled : Touchable.enabled)
.checked(user.isAdmin);
t.addImageButton(Icon.zoom, Styles.clearPartiali, () -> Call.onAdminRequest(user, AdminAction.trace));
@@ -134,7 +142,7 @@ public class PlayerListFragment extends Fragment{
button.add().growY();
button.addImageButton(Icon.hammer, Styles.clearPartiali,
() -> ui.showConfirm("$confirm", "$confirmvotekick", () -> Call.sendChatMessage("/votekick " + user.name))).size(h);
() -> ui.showConfirm("$confirm", "$confirmvotekick", () -> Call.sendChatMessage("/votekick " + user.name))).size(h);
}
content.add(button).padBottom(-6).width(350f).maxHeight(h + 14);
@@ -143,6 +151,10 @@ public class PlayerListFragment extends Fragment{
content.row();
});
if(sField.getText().length() > 0 && !playerGroup.all().contains(user -> user.name.toLowerCase().contains(sField.getText().toLowerCase()))) {
content.add(Core.bundle.format("players.notfound")).padBottom(6).width(350f).maxHeight(h + 14);
}
content.marginBottom(5);
}
@@ -150,6 +162,9 @@ public class PlayerListFragment extends Fragment{
visible = !visible;
if(visible){
rebuild();
}else{
Core.scene.setKeyboardFocus(null);
sField.clearText();
}
}

View File

@@ -43,15 +43,15 @@ public class LegacyColorMapper implements ContentList{
}
private void map(String color, Block block, Block wall, Block ore){
blockMap.put(Color.rgba8888(Color.valueOf(color)), new LegacyBlock(block, wall, ore));
blockMap.put(Color.valueOf(color).rgba(), new LegacyBlock(block, wall, ore));
}
private void map(String color, Block block, Block wall){
blockMap.put(Color.rgba8888(Color.valueOf(color)), new LegacyBlock(block, wall));
blockMap.put(Color.valueOf(color).rgba(), new LegacyBlock(block, wall));
}
private void map(String color, Block block){
blockMap.put(Color.rgba8888(Color.valueOf(color)), new LegacyBlock(block, Blocks.air));
blockMap.put(Color.valueOf(color).rgba(), new LegacyBlock(block, Blocks.air));
}
public static class LegacyBlock{

View File

@@ -100,7 +100,7 @@ public class ImpactReactor extends PowerGenerator{
Draw.rect(reg(bottomRegion), tile.drawx(), tile.drawy());
for(int i = 0; i < plasmas; i++){
float r = 29f + Mathf.absin(Time.time(), 2f + i * 1f, 5f - i * 0.5f);
float r = size * tilesize - 3f + Mathf.absin(Time.time(), 2f + i * 1f, 5f - i * 0.5f);
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);

View File

@@ -1,8 +1,8 @@
package mindustry.world.blocks.power;
import arc.*;
import arc.struct.*;
import arc.math.*;
import arc.struct.*;
import arc.util.*;
import mindustry.world.*;
import mindustry.world.consumers.*;
@@ -199,6 +199,8 @@ public class PowerGraph{
lastPowerNeeded = powerNeeded;
lastPowerProduced = powerProduced;
powerBalance.addValue((lastPowerProduced - lastPowerNeeded) / Time.delta());
if(!(consumers.size == 0 && producers.size == 0 && batteries.size == 0)){
if(!Mathf.equal(powerNeeded, powerProduced)){
@@ -214,8 +216,6 @@ public class PowerGraph{
distributePower(powerNeeded, powerProduced);
}
powerBalance.addValue((lastPowerProduced - lastPowerNeeded) / Time.delta());
//overproducing: 10 / 20 = 0.5
//underproducing: 20 / 10 = 2 -> clamp -> 1.0
//nothing being produced: 20 / 0 -> 1.0