Fixed #2449 / Fixed #2456 / Fixed #2458 / Fixed #2459 / Fixed #2466 / Fixed #2474

This commit is contained in:
Anuken
2020-09-01 11:34:03 -04:00
parent 6e3162aec2
commit 8e17571824
20 changed files with 129 additions and 83 deletions
@@ -143,6 +143,7 @@ public class CustomRulesDialog extends BaseDialog{
main.button("@configure",
() -> loadoutDialog.show(Blocks.coreShard.itemCapacity, rules.loadout,
i -> true,
() -> rules.loadout.clear().add(new ItemStack(Items.copper, 100)),
() -> {}, () -> {}
)).left().width(300f);
@@ -5,6 +5,7 @@ import arc.func.*;
import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import mindustry.ctype.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.type.*;
@@ -71,7 +72,7 @@ public class LaunchLoadoutDialog extends BaseDialog{
Runnable rebuildItems = () -> rebuild.get(items);
buttons.button("@resources", Icon.terrain, () -> {
loadout.show(core.itemCapacity, stacks, stacks::clear, () -> {}, () -> {
loadout.show(core.itemCapacity, stacks, UnlockableContent::unlocked, stacks::clear, () -> {}, () -> {
universe.updateLaunchResources(stacks);
update.run();
rebuildItems.run();
@@ -1,9 +1,10 @@
package mindustry.ui.dialogs;
import arc.*;
import arc.struct.*;
import arc.func.*;
import arc.input.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import mindustry.gen.*;
import mindustry.type.*;
@@ -17,6 +18,7 @@ public class LoadoutDialog extends BaseDialog{
private Runnable updater;
private Seq<ItemStack> stacks = new Seq<>();
private Seq<ItemStack> originalStacks = new Seq<>();
private Boolf<Item> validator = i -> true;
private Table items;
private int capacity;
@@ -51,13 +53,14 @@ public class LoadoutDialog extends BaseDialog{
}).size(210f, 64f);
}
public void show(int capacity, Seq<ItemStack> stacks, Runnable reseter, Runnable updater, Runnable hider){
public void show(int capacity, Seq<ItemStack> stacks, Boolf<Item> validator, Runnable reseter, Runnable updater, Runnable hider){
this.originalStacks = stacks;
reseed();
this.validator = validator;
this.resetter = reseter;
this.updater = updater;
this.capacity = capacity;
this.hider = hider;
reseed();
show();
}
@@ -106,7 +109,7 @@ public class LoadoutDialog extends BaseDialog{
private void reseed(){
this.stacks = originalStacks.map(ItemStack::copy);
this.stacks.addAll(content.items().select(i -> !stacks.contains(stack -> stack.item == i)).map(i -> new ItemStack(i, 0)));
this.stacks.addAll(content.items().select(i -> validator.get(i) && !stacks.contains(stack -> stack.item == i)).map(i -> new ItemStack(i, 0)));
this.stacks.sort(Structs.comparingInt(s -> s.item.id));
}
@@ -134,7 +134,9 @@ public class ResearchDialog extends BaseDialog{
}
});
view.addListener(new ElementGestureListener(){
touchable = Touchable.enabled;
addListener(new ElementGestureListener(){
@Override
public void zoom(InputEvent event, float initialDistance, float distance){
if(view.lastZoom < 0){