Fix loadout reset

This commit is contained in:
Patrick 'Quezler' Mounier
2019-10-16 15:51:18 +02:00
committed by GitHub
parent af3067c08b
commit 596d58b539

View File

@@ -48,6 +48,7 @@ public class LoadoutDialog extends FloatingDialog{
buttons.addImageTextButton("$settings.reset", Icon.refreshSmall, () -> {
resetter.run();
reseed();
updater.run();
setup();
}).size(210f, 64f);
@@ -55,10 +56,7 @@ public class LoadoutDialog extends FloatingDialog{
public void show(int capacity, Array<ItemStack> stacks, Runnable reseter, Runnable updater, Runnable hider){
this.originalStacks = stacks;
this.stacks = stacks.map(ItemStack::copy);
this.stacks.addAll(content.items().select(i -> i.type == ItemType.material &&
!stacks.contains(stack -> stack.item == i)).map(i -> new ItemStack(i, 0)));
this.stacks.sort(Structs.comparingInt(s -> s.item.id));
reseed();
this.resetter = reseter;
this.updater = updater;
this.capacity = capacity;
@@ -110,6 +108,13 @@ public class LoadoutDialog extends FloatingDialog{
}
}
private void reseed(){
this.stacks = originalStacks.map(ItemStack::copy);
this.stacks.addAll(content.items().select(i -> i.type == ItemType.material &&
!stacks.contains(stack -> stack.item == i)).map(i -> new ItemStack(i, 0)));
this.stacks.sort(Structs.comparingInt(s -> s.item.id));
}
private int step(int amount){
if(amount < 1000){
return 100;