mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-04 15:27:19 +07:00
Launch UI Max Button (#4238)
* max * Add @Nullable Co-authored-by: Leonwang4234 <62972692+Leonwang4234@users.noreply.github.com>
This commit is contained in:
@ -287,6 +287,7 @@ cancel = Cancel
|
|||||||
openlink = Open Link
|
openlink = Open Link
|
||||||
copylink = Copy Link
|
copylink = Copy Link
|
||||||
back = Back
|
back = Back
|
||||||
|
max = Max
|
||||||
crash.export = Export Crash Logs
|
crash.export = Export Crash Logs
|
||||||
crash.none = No crash logs found.
|
crash.none = No crash logs found.
|
||||||
crash.exported = Crash logs exported.
|
crash.exported = Crash logs exported.
|
||||||
|
@ -86,7 +86,10 @@ public class LaunchLoadoutDialog extends BaseDialog{
|
|||||||
ItemSeq stacks = universe.getLaunchResources();
|
ItemSeq stacks = universe.getLaunchResources();
|
||||||
Seq<ItemStack> out = stacks.toSeq();
|
Seq<ItemStack> out = stacks.toSeq();
|
||||||
|
|
||||||
loadout.show(selected.findCore().itemCapacity, out, UnlockableContent::unlocked, out::clear, () -> {}, () -> {
|
ItemSeq realItems = sitems.copy();
|
||||||
|
selected.requirements().each(realItems::remove);
|
||||||
|
|
||||||
|
loadout.show(selected.findCore().itemCapacity, realItems, out, UnlockableContent::unlocked, out::clear, () -> {}, () -> {
|
||||||
universe.updateLaunchResources(new ItemSeq(out));
|
universe.updateLaunchResources(new ItemSeq(out));
|
||||||
update.run();
|
update.run();
|
||||||
rebuildItems.run();
|
rebuildItems.run();
|
||||||
|
@ -22,6 +22,7 @@ public class LoadoutDialog extends BaseDialog{
|
|||||||
private Boolf<Item> validator = i -> true;
|
private Boolf<Item> validator = i -> true;
|
||||||
private Table items;
|
private Table items;
|
||||||
private int capacity;
|
private int capacity;
|
||||||
|
private @Nullable ItemSeq total;
|
||||||
|
|
||||||
public LoadoutDialog(){
|
public LoadoutDialog(){
|
||||||
super("@configure");
|
super("@configure");
|
||||||
@ -46,6 +47,8 @@ public class LoadoutDialog extends BaseDialog{
|
|||||||
|
|
||||||
buttons.button("@back", Icon.left, this::hide).size(210f, 64f);
|
buttons.button("@back", Icon.left, this::hide).size(210f, 64f);
|
||||||
|
|
||||||
|
buttons.button("@max", Icon.export, this::maxItems).size(210f, 64f);
|
||||||
|
|
||||||
buttons.button("@settings.reset", Icon.refresh, () -> {
|
buttons.button("@settings.reset", Icon.refresh, () -> {
|
||||||
resetter.run();
|
resetter.run();
|
||||||
reseed();
|
reseed();
|
||||||
@ -54,12 +57,23 @@ public class LoadoutDialog extends BaseDialog{
|
|||||||
}).size(210f, 64f);
|
}).size(210f, 64f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void maxItems() {
|
||||||
|
for(ItemStack stack : stacks){
|
||||||
|
stack.amount = total == null ? capacity : Math.min(capacity, total.get(stack.item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void show(int capacity, Seq<ItemStack> stacks, Boolf<Item> validator, Runnable reseter, Runnable updater, Runnable hider){
|
public void show(int capacity, Seq<ItemStack> stacks, Boolf<Item> validator, Runnable reseter, Runnable updater, Runnable hider){
|
||||||
|
show(capacity, null, stacks, validator, reseter, updater, hider);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void show(int capacity, ItemSeq total, Seq<ItemStack> stacks, Boolf<Item> validator, Runnable reseter, Runnable updater, Runnable hider){
|
||||||
this.originalStacks = stacks;
|
this.originalStacks = stacks;
|
||||||
this.validator = validator;
|
this.validator = validator;
|
||||||
this.resetter = reseter;
|
this.resetter = reseter;
|
||||||
this.updater = updater;
|
this.updater = updater;
|
||||||
this.capacity = capacity;
|
this.capacity = capacity;
|
||||||
|
this.total = total;
|
||||||
this.hider = hider;
|
this.hider = hider;
|
||||||
reseed();
|
reseed();
|
||||||
show();
|
show();
|
||||||
|
Reference in New Issue
Block a user