Major refactoring of building, sound, inventory

This commit is contained in:
Anuken
2018-05-20 17:59:52 -04:00
parent de40df7f7b
commit c1a5482ad2
40 changed files with 348 additions and 991 deletions

View File

@@ -29,7 +29,7 @@ public class ColorPickDialog extends Dialog{
cons.accept(color);
hide();
}).size(44, 48).pad(0).padBottom(-5.1f).get();
button.setChecked(players[0].getColor().equals(color));
button.setChecked(players[0].color.equals(color));
button.getStyle().imageUpColor = color;
if(i%4 == 3){

View File

@@ -42,7 +42,7 @@ public class HostDialog extends FloatingDialog{
Settings.save();
});
}).size(50f, 54f).get();
button.update(() -> button.getStyle().imageUpColor = player.getColor());
button.update(() -> button.getStyle().imageUpColor = player.color);
}).width(w).height(70f).pad(4).colspan(3);
content().row();

View File

@@ -222,7 +222,7 @@ public class JoinDialog extends FloatingDialog {
Settings.save();
});
}).size(50f, 54f).get();
button.update(() -> button.getStyle().imageUpColor = player.getColor());
button.update(() -> button.getStyle().imageUpColor = player.color);
}).width(w).height(70f).pad(4);
content().row();
content().add(pane).width(w + 34).pad(0);

View File

@@ -17,7 +17,6 @@ import io.anuke.mindustry.ui.dialogs.FloatingDialog;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.BlockStats;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Hue;
import io.anuke.ucore.scene.Element;
import io.anuke.ucore.scene.Group;
import io.anuke.ucore.scene.actions.Actions;
@@ -40,6 +39,16 @@ public class BlocksFragment implements Fragment{
private boolean shown = true;
private Recipe hoveredDescriptionRecipe;
private IntSet itemset = new IntSet();
private int[] tmpItems;
{
int size = 0;
for(Item ignored : Item.getAllItems()){
size ++;
}
tmpItems = new int[size];
}
public void build(Group parent){
InputHandler input = control.input(0);
@@ -55,7 +64,7 @@ public class BlocksFragment implements Fragment{
itemtable = new Table("button");
itemtable.setVisible(() -> input.recipe == null && !state.mode.infiniteResources);
itemtable.update(() -> {
int[] items = state.inventory.readItems();
int[] items = tmpItems;
for(int i = 0; i < items.length; i ++){
if(itemset.contains(items[i]) != (items[i] > 0)){
updateItems();
@@ -186,10 +195,9 @@ public class BlocksFragment implements Fragment{
table.add(image).size(size + 8);
image.update(() -> {
boolean has = (state.inventory.hasItems(r.requirements));
image.setTouchable(Touchable.enabled);
for(Element e : istack.getChildren()){
e.setColor(has ? Color.WHITE : Hue.lightness(0.33f));
e.setColor(Color.WHITE);
}
for(Player player : players){
@@ -287,7 +295,7 @@ public class BlocksFragment implements Fragment{
Label reqlabel = new Label("");
reqlabel.update(()->{
int current = state.inventory.getAmount(stack.item);
int current = stack.amount;
String text = Mathf.clamp(current, 0, stack.amount) + "/" + stack.amount;
reqlabel.setColor(current < stack.amount ? Colors.get("missingitems") : Color.WHITE);
@@ -364,7 +372,7 @@ public class BlocksFragment implements Fragment{
};
int index = 0;
int[] items = state.inventory.readItems();
int[] items = tmpItems;
for(int i = 0; i < items.length; i ++){
int amount = items[i];

View File

@@ -118,7 +118,7 @@ public class PlayerListFragment implements Fragment{
});
button.add(stack).size(h);
button.labelWrap("[#" + player.getColor().toString().toUpperCase() + "]" + player.name).width(170f).pad(10);
button.labelWrap("[#" + player.color.toString().toUpperCase() + "]" + player.name).width(170f).pad(10);
button.add().grow();
button.addImage("icon-admin").size(14*2).visible(() -> player.isAdmin && !(!player.isLocal && Net.server())).padRight(5);

View File

@@ -3,7 +3,6 @@ package io.anuke.mindustry.ui.fragments;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Align;
import static io.anuke.mindustry.Vars.*;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.input.InputHandler;
import io.anuke.mindustry.input.PlaceMode;
@@ -12,6 +11,8 @@ import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.scene.Group;
import io.anuke.ucore.scene.ui.layout.Table;
import static io.anuke.mindustry.Vars.*;
public class ToolFragment implements Fragment{
private Table tools;
private InputHandler input;
@@ -52,7 +53,7 @@ public class ToolFragment implements Fragment{
});
tools.setVisible(() ->
!state.is(State.menu) && mobile && ((input.recipe != null && state.inventory.hasItems(input.recipe.requirements) &&
!state.is(State.menu) && mobile && ((input.recipe != null &&
input.placeMode == PlaceMode.cursor) || confirming)
);