Merge branches 'master' and 'mech-rework' of https://github.com/Anuken/Mindustry into mech-rework

# Conflicts:
#	android/src/mindustry/android/AndroidLauncher.java
#	annotations/src/main/java/mindustry/annotations/SerializeAnnotationProcessor.java
#	annotations/src/main/java/mindustry/annotations/impl/AssetsAnnotationProcessor.java
#	build.gradle
#	core/assets-raw/fontgen/config.json
#	core/assets/bundles/bundle_cs.properties
#	core/assets/bundles/bundle_it.properties
#	core/assets/fonts/font.ttf
#	core/assets/fonts/icon.ttf
#	core/assets/icons/icons.properties
#	core/assets/sprites/block_colors.png
#	core/assets/sprites/sprites.atlas
#	core/assets/sprites/sprites.png
#	core/assets/sprites/sprites3.png
#	core/assets/sprites/sprites5.png
#	core/src/mindustry/content/UnitTypes.java
#	core/src/mindustry/core/NetClient.java
#	core/src/mindustry/core/NetServer.java
#	core/src/mindustry/entities/bullet/BulletType.java
#	core/src/mindustry/entities/type/TileEntity.java
#	core/src/mindustry/maps/filters/FilterOption.java
#	core/src/mindustry/mod/Scripts.java
#	core/src/mindustry/ui/Fonts.java
#	core/src/mindustry/ui/dialogs/DeployDialog.java
#	core/src/mindustry/ui/fragments/HudFragment.java
#	core/src/mindustry/ui/fragments/MenuFragment.java
#	core/src/mindustry/world/blocks/production/Cultivator.java
#	core/src/mindustry/world/blocks/units/CommandCenter.java
#	gradle.properties
#	tools/src/mindustry/tools/FontGenerator.java
This commit is contained in:
Anuken
2020-01-27 15:51:02 -05:00
144 changed files with 4577 additions and 3085 deletions

View File

@@ -28,7 +28,7 @@ public class ContentDisplay{
table.row();
if(block.description != null){
table.add(block.description).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.add(block.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage().height(3).color(Color.lightGray).pad(8).padLeft(0).padRight(0).fillX();
@@ -76,7 +76,7 @@ public class ContentDisplay{
table.row();
if(item.description != null){
table.add(item.description).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.add(item.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
@@ -110,7 +110,7 @@ public class ContentDisplay{
table.row();
if(liquid.description != null){
table.add(liquid.description).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.add(liquid.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
@@ -147,7 +147,7 @@ public class ContentDisplay{
table.row();
if(mech.description != null){
table.add(mech.description).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.add(mech.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
@@ -194,7 +194,7 @@ public class ContentDisplay{
table.row();
if(unit.description != null){
table.add(unit.description).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.add(unit.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();

View File

@@ -54,8 +54,9 @@ public class Fonts{
Core.assets.load("default", BitmapFont.class, new FreeTypeFontLoaderParameter(fontName, param)).loaded = f -> Fonts.def = (BitmapFont)f;
Core.assets.load("chat", BitmapFont.class, new FreeTypeFontLoaderParameter(fontName, param)).loaded = f -> Fonts.chat = (BitmapFont)f;
Core.assets.load("icon", BitmapFont.class, new FreeTypeFontLoaderParameter("fonts/icon.ttf", new FreeTypeFontParameter(){{
size = (int)(Scl.scl(30f));
size = 30;
incremental = true;
characters = "\0";
}})).loaded = f -> Fonts.icon = (BitmapFont)f;
}
@@ -104,12 +105,19 @@ public class Fonts{
FileHandleResolver resolver = new InternalFileHandleResolver();
Core.assets.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
Core.assets.setLoader(BitmapFont.class, null, new FreetypeFontLoader(resolver){
ObjectSet<FreeTypeFontParameter> scaled = new ObjectSet<>();
@Override
public BitmapFont loadSync(AssetManager manager, String fileName, Fi file, FreeTypeFontLoaderParameter parameter){
if(fileName.equals("outline")){
parameter.fontParameters.borderWidth = Scl.scl(2f);
parameter.fontParameters.spaceX -= parameter.fontParameters.borderWidth;
}
if(!scaled.contains(parameter.fontParameters)){
parameter.fontParameters.size = (int)(Scl.scl(parameter.fontParameters.size));
scaled.add(parameter.fontParameters);
}
parameter.fontParameters.magFilter = TextureFilter.Linear;
parameter.fontParameters.minFilter = TextureFilter.Linear;
parameter.fontParameters.packer = UI.packer;
@@ -119,8 +127,8 @@ public class Fonts{
FreeTypeFontParameter param = new FreeTypeFontParameter(){{
borderColor = Color.darkGray;
size = (int)(Scl.scl(18f));
incremental = true;
size = 18;
}};
Core.assets.load("outline", BitmapFont.class, new FreeTypeFontLoaderParameter("fonts/font.ttf", param)).loaded = t -> Fonts.outline = (BitmapFont)t;
@@ -162,7 +170,6 @@ public class Fonts{
if(g == null) throw new IllegalArgumentException("No glyph: " + glyph + " (" + (int)glyph + ")");
float size = Math.max(g.width, g.height);
float aspect = (float)g.height / g.width;
TextureRegionDrawable draw = new TextureRegionDrawable(new TextureRegion(font.getRegion().getTexture(), g.u, g.v2, g.u2, g.v)){
@Override
public void draw(float x, float y, float width, float height){
@@ -173,6 +180,19 @@ public class Fonts{
Draw.rect(region, cx + g.width/2f, cy + g.height/2f, g.width, g.height);
}
@Override
public void draw(float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation){
width *= scaleX;
height *= scaleY;
Draw.color(Tmp.c1.set(tint).mul(Draw.getColor()).toFloatBits());
float cx = x + width/2f - g.width/2f, cy = y + height/2f - g.height/2f;
cx = (int)cx;
cy = (int)cy;
originX = g.width/2f;
originY = g.height/2f;
Draw.rect(region, cx + g.width/2f, cy + g.height/2f, g.width, g.height, originX, originY, rotation);
}
@Override
public float imageSize(){
return size;
@@ -186,7 +206,7 @@ public class Fonts{
static FreeTypeFontParameter fontParameter(){
return new FreeTypeFontParameter(){{
size = (int)(Scl.scl(18f));
size = 18;
shadowColor = Color.darkGray;
shadowOffsetY = 2;
incremental = true;

View File

@@ -1,6 +1,7 @@
package mindustry.ui;
import arc.graphics.*;
import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import mindustry.core.GameState.*;
import mindustry.gen.*;
@@ -21,18 +22,31 @@ public class ItemsDisplay extends Table{
top().left();
margin(0);
table(Tex.button,t -> {
t.margin(10).marginLeft(15).marginTop(15f);
t.label(() -> state.is(State.menu) ? "$launcheditems" : "$launchinfo").colspan(3).padBottom(4).left().colspan(3).width(210f).wrap();
t.row();
for(Item item : content.items()){
if(item.type == ItemType.material && data.isUnlocked(item)){
t.label(() -> format(item)).left();
t.addImage(item.icon(Cicon.small)).size(8 * 3).padLeft(4).padRight(4);
t.add(item.localizedName).color(Color.lightGray).left();
t.row();
table(Tex.button, c -> {
c.margin(10).marginLeft(12).marginTop(15f);
c.marginRight(12f);
c.left();
Collapser col = new Collapser(base -> base.pane(t -> {
t.marginRight(30f);
t.left();
for(Item item : content.items()){
if(item.type == ItemType.material && data.isUnlocked(item)){
t.label(() -> format(item)).left();
t.addImage(item.icon(Cicon.small)).size(8 * 3).padLeft(4).padRight(4);
t.add(item.localizedName).color(Color.lightGray).left();
t.row();
}
}
}
}).get().setScrollingDisabled(true, false), false).setDuration(0.3f);
c.addImageTextButton("$launcheditems", Icon.downOpen, Styles.clearTogglet, col::toggle).update(t -> {
t.setText(state.is(State.menu) ? "$launcheditems" : "$launchinfo");
t.setChecked(col.isCollapsed());
((Image)t.getChildren().get(1)).setDrawable(col.isCollapsed() ? Icon.upOpen : Icon.downOpen);
}).padBottom(4).left().fillX().margin(12f);
c.row();
c.add(col);
});
}

View File

@@ -3,6 +3,7 @@ package mindustry.ui.dialogs;
import arc.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.scene.style.*;
import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import arc.util.*;
@@ -59,8 +60,9 @@ public class CustomGameDialog extends FloatingDialog{
image.table(t -> {
t.left();
for(Gamemode mode : Gamemode.all){
if(mode.valid(map) && Core.atlas.has("icon-mode-" + mode.name())){
t.addImage(Core.atlas.drawable("icon-mode-" + mode.name())).size(16f).pad(4f);
TextureRegionDrawable icon = Vars.ui.getIcon("mode" + Strings.capitalize(mode.name()) + "Small");
if(mode.valid(map) && Core.atlas.isFound(icon.getRegion())){
t.addImage(icon).size(16f).pad(4f);
}
}
}).left();

View File

@@ -122,7 +122,7 @@ public class DeployDialog extends FloatingDialog{
setFilter(TextureFilter.Linear);
}}){{
float[] time = {0};
setColor(Color.gray(0.3f));
setColor(Color.grays(0.3f));
setScale(1.5f);
update(() -> {
setOrigin(Align.center);
@@ -140,7 +140,7 @@ public class DeployDialog extends FloatingDialog{
Stack sub = new Stack();
if(slot.getZone() != null){
sub.add(new Table(f -> f.margin(4f).add(new Image()).color(Color.gray(0.1f)).grow()));
sub.add(new Table(f -> f.margin(4f).add(new Image()).color(Color.grays(0.1f)).grow()));
sub.add(new Table(f -> f.margin(4f).add(new Image(slot.getZone().preview).setScaling(Scaling.fit)).update(img -> {
TextureRegionDrawable draw = (TextureRegionDrawable)img.getDrawable();
@@ -254,7 +254,7 @@ public class DeployDialog extends FloatingDialog{
}
stack.setSize(Tmp.v1.x, Tmp.v1.y);
stack.add(new Table(t -> t.margin(4f).add(new Image(node.zone.preview).setScaling(Scaling.stretch)).color(node.zone.unlocked() ? Color.darkGray : Color.gray(0.2f)).grow()));
stack.add(new Table(t -> t.margin(4f).add(new Image(node.zone.preview).setScaling(Scaling.stretch)).color(node.zone.unlocked() ? Color.darkGray : Color.grays(0.2f)).grow()));
stack.update(() -> stack.setPosition(node.x + panX + width / 2f, node.y + panY + height / 2f, Align.center));
Button button = new Button(Styles.squaret);

View File

@@ -95,11 +95,16 @@ public class JoinDialog extends FloatingDialog{
}
});
onResize(this::setup);
onResize(() -> {
setup();
refreshLocal();
refreshRemote();
});
}
void setupRemote(){
remote.clear();
for(Server server : servers){
//why are java lambdas this bad
TextButton[] buttons = {null};
@@ -266,7 +271,7 @@ public class JoinDialog extends FloatingDialog{
cont.addCenteredImageTextButton("$server.add", Icon.add, () -> {
renaming = null;
add.show();
}).marginLeft(6).width(w).height(80f).update(button -> {
}).marginLeft(10).width(w).height(80f).update(button -> {
float pw = w;
float pad = 0f;
if(pane.getChildren().first().getPrefHeight() > pane.getHeight()){
@@ -363,7 +368,7 @@ public class JoinDialog extends FloatingDialog{
}
float targetWidth(){
return Core.graphics.isPortrait() ? 350f : 500f;
return Math.min(Core.graphics.getWidth() / Scl.scl() * 0.9f, 500f);//Core.graphics.isPortrait() ? 350f : 500f;
}
@SuppressWarnings("unchecked")

View File

@@ -1,7 +1,6 @@
package mindustry.ui.dialogs;
import arc.*;
import arc.struct.*;
import arc.files.*;
import arc.graphics.*;
import arc.graphics.Texture.*;
@@ -12,6 +11,7 @@ import arc.scene.ui.*;
import arc.scene.ui.SettingsDialog.SettingsTable.*;
import arc.scene.ui.TextButton.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import mindustry.core.GameState.*;
import mindustry.core.*;
@@ -240,10 +240,17 @@ public class SettingsMenuDialog extends SettingsDialog{
game.checkPref("buildautopause", false);
}
if(steam && !Version.modifier.contains("beta")){
game.checkPref("publichost", false, i -> {
if(steam){
game.sliderPref("playerlimit", 16, 2, 32, i -> {
platform.updateLobby();
return i + "";
});
if(!Version.modifier.contains("beta")){
game.checkPref("publichost", false, i -> {
platform.updateLobby();
});
}
}
game.pref(new Setting(){

View File

@@ -1,6 +1,7 @@
package mindustry.ui.dialogs;
import arc.*;
import arc.scene.ui.layout.Stack;
import arc.struct.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
@@ -25,6 +26,8 @@ import mindustry.ui.Cicon;
import mindustry.ui.layout.*;
import mindustry.ui.layout.TreeLayout.*;
import java.util.*;
import static mindustry.Vars.*;
public class TechTreeDialog extends FloatingDialog{
@@ -110,9 +113,25 @@ public class TechTreeDialog extends FloatingDialog{
}
void treeLayout(){
RadialTreeLayout layout = new RadialTreeLayout();
float spacing = 20f;
LayoutNode node = new LayoutNode(root, null);
layout.layout(node);
LayoutNode[] children = node.children;
LayoutNode[] leftHalf = Arrays.copyOfRange(node.children, 0, Mathf.ceil(node.children.length/2f));
LayoutNode[] rightHalf = Arrays.copyOfRange(node.children, Mathf.ceil(node.children.length/2f), node.children.length);
node.children = leftHalf;
new BranchTreeLayout(){{
gapBetweenLevels = gapBetweenNodes = spacing;
rootLocation = TreeLocation.top;
}}.layout(node);
node.children = rightHalf;
new BranchTreeLayout(){{
gapBetweenLevels = gapBetweenNodes = spacing;
rootLocation = TreeLocation.bottom;
}}.layout(node);
node.children = children;
float minx = 0f, miny = 0f, maxx = 0f, maxy = 0f;
copyInfo(node);
@@ -252,7 +271,7 @@ public class TechTreeDialog extends FloatingDialog{
button.setPosition(node.x + panX + width / 2f, node.y + panY + height / 2f + offset, Align.center);
button.getStyle().up = !locked(node.node) ? Tex.buttonOver : !data.hasItems(node.node.requirements) ? Tex.buttonRed : Tex.button;
((TextureRegionDrawable)button.getStyle().imageUp)
.setRegion(node.visible ? node.node.block.icon(Cicon.medium) : Core.atlas.find("icon-locked"));
.setRegion(node.visible ? node.node.block.icon(Cicon.medium) : Icon.lock.getRegion());
button.getImage().setColor(!locked(node.node) ? Color.white : Color.gray);
});
addChild(button);
@@ -358,7 +377,7 @@ public class TechTreeDialog extends FloatingDialog{
infoTable.row();
if(node.block.description != null){
infoTable.table(t -> t.margin(3f).left().labelWrap(node.block.description).color(Color.lightGray).growX()).fillX();
infoTable.table(t -> t.margin(3f).left().labelWrap(node.block.displayDescription()).color(Color.lightGray).growX()).fillX();
}
addChild(infoTable);
@@ -378,7 +397,12 @@ public class TechTreeDialog extends FloatingDialog{
Lines.stroke(Scl.scl(4f), locked(node.node) || locked(child.node) ? Pal.gray : Pal.accent);
Draw.alpha(parentAlpha);
Lines.line(node.x + offsetX, node.y + offsetY, child.x + offsetX, child.y + offsetY);
if(Mathf.equal(Math.abs(node.y - child.y), Math.abs(node.x - child.x), 1f) && Mathf.dstm(node.x, node.y, child.x, child.y) <= node.width*3){
Lines.line(node.x + offsetX, node.y + offsetY, child.x + offsetX, child.y + offsetY);
}else{
Lines.line(node.x + offsetX, node.y + offsetY, child.x + offsetX, node.y + offsetY);
Lines.line(child.x + offsetX, node.y + offsetY, child.x + offsetX, child.y + offsetY);
}
}
}

View File

@@ -75,7 +75,7 @@ public class HudFragment extends Fragment{
}
}).name("pause").update(i -> {
if(net.active()){
i.getStyle().imageUp = Icon.user;
i.getStyle().imageUp = Icon.players;
}else{
i.setDisabled(false);
i.getStyle().imageUp = state.is(State.paused) ? Icon.play : Icon.pause;
@@ -256,7 +256,7 @@ public class HudFragment extends Fragment{
t.add(new Minimap());
t.row();
//position
t.label(() -> world.toTile(player.x) + "," + world.toTile(player.y)).style(Styles.outlineLabel)
t.label(() -> world.toTile(player.x) + "," + world.toTile(player.y))
.visible(() -> Core.settings.getBool("position") && !state.rules.tutorial);
t.top().right();
});
@@ -352,7 +352,7 @@ public class HudFragment extends Fragment{
}
@Remote(targets = Loc.both, called = Loc.server)
public static void spawnUnitEditor(Player player, UnitDef type){
public static void spawnUnitEditor(Player player, UnitType type){
if(state.isEditor()){
BaseUnit unit = type.create(player.getTeam());
unit.set(player.x, player.y);

View File

@@ -171,7 +171,7 @@ public class MenuFragment extends Fragment{
new Buttoni("$loadgame", Icon.download, () -> checkPlay(ui.load::show)),
new Buttoni("$tutorial", Icon.info, () -> checkPlay(control::playTutorial))
),
new Buttoni("$editor", Icon.terrain, () -> checkPlay(ui.maps::show)), steam ? new Buttoni("$workshop", Icon.save, platform::openWorkshop) : null,
new Buttoni("$editor", Icon.terrain, () -> checkPlay(ui.maps::show)), steam ? new Buttoni("$workshop", Icon.book, platform::openWorkshop) : null,
new Buttoni(Core.bundle.get("mods"), Icon.bookOpen, ui.mods::show),
//not enough space for this button
//new Buttoni("$schematics", Icon.paste, ui.schematics::show),

View File

@@ -31,11 +31,13 @@ public class PlacementFragment extends Fragment{
Array<Block> returnArray = new Array<>();
Array<Category> returnCatArray = new Array<>();
boolean[] categoryEmpty = new boolean[Category.all.length];
ObjectMap<Category,Block> selectedBlocks = new ObjectMap<Category,Block>();
ObjectMap<Category,Block> selectedBlocks = new ObjectMap<>();
ObjectFloatMap<Category> scrollPositions = new ObjectFloatMap<>();
Block hovered, lastDisplay;
Tile lastHover;
Tile hoverTile;
Table blockTable, toggler, topTable;
ScrollPane blockPane;
boolean lastGround;
boolean blockSelectEnd;
int blockSelectSeq;
@@ -86,6 +88,8 @@ public class PlacementFragment extends Fragment{
}
boolean gridUpdate(InputHandler input){
scrollPositions.put(currentCategory, blockPane.getScrollY());
if(Core.input.keyDown(Binding.pick)){ //mouse eyedropper select
Tile tile = world.ltileWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
Block tryRecipe = tile == null ? null : tile.block();
@@ -240,6 +244,12 @@ public class PlacementFragment extends Fragment{
}
}
blockTable.act(0f);
blockPane.setScrollYForce(scrollPositions.get(currentCategory, 0));
Core.app.post(() -> {
blockPane.setScrollYForce(scrollPositions.get(currentCategory, 0));
blockPane.act(0f);
blockPane.layout();
});
};
//top table with hover info
@@ -343,14 +353,15 @@ public class PlacementFragment extends Fragment{
frame.row();
frame.table(Tex.pane2, blocksSelect -> {
blocksSelect.margin(4).marginTop(0);
blocksSelect.pane(blocks -> blockTable = blocks).height(194f).update(pane -> {
blockPane = blocksSelect.pane(blocks -> blockTable = blocks).height(194f).update(pane -> {
if(pane.hasScroll()){
Element result = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true);
if(result == null || !result.isDescendantOf(pane)){
Core.scene.setScrollFocus(null);
}
}
}).grow().get().setStyle(Styles.smallPane);
}).grow().get();
blockPane.setStyle(Styles.smallPane);
blocksSelect.row();
blocksSelect.table(control.input::buildPlacementUI).name("inputTable").growX();
}).fillY().bottom().touchable(Touchable.enabled);

View File

@@ -148,8 +148,7 @@ public class BranchTreeLayout implements TreeLayout{
wPlus.mode = wPlus.mode + shift;
}
private TreeNode apportion(TreeNode v, TreeNode defaultAncestor,
TreeNode leftSibling, TreeNode parentOfV){
private TreeNode apportion(TreeNode v, TreeNode defaultAncestor, TreeNode leftSibling, TreeNode parentOfV){
if(leftSibling == null){
return defaultAncestor;
}

View File

@@ -12,7 +12,7 @@ public class RadialTreeLayout implements TreeLayout{
@Override
public void layout(TreeNode root){
startRadius = root.height * 2.4f;
delta = root.height * 2.4f;
delta = root.height * 20.4f;
bfs(root, true);

View File

@@ -0,0 +1,36 @@
package mindustry.ui.layout;
import arc.struct.*;
public class RowTreeLayout implements TreeLayout{
@Override
public void layout(TreeNode root){
layout(root, 0, new IntArray());
/*
def minimum_ws(tree, depth=0):
tree.x = nexts[depth]
tree.y = depth
nexts[depth] += 1
for c in tree.children:
minimum_ws(tree, c)
*/
}
void layout(TreeNode node, int depth, IntArray nexts){
float size = node.height * 5f;
if(nexts.size < depth + 1){
nexts.ensureCapacity(depth + 1);
nexts.size = depth + 1;
}
node.x = size * nexts.get(depth);
node.y = size * depth;
nexts.incr(depth, 1);
for(TreeNode child : node.children){
layout(child, depth + 1, nexts);
}
}
}