Auto-max resources on launch
This commit is contained in:
@@ -570,6 +570,7 @@ configure = Configure Loadout
|
|||||||
|
|
||||||
loadout = Loadout
|
loadout = Loadout
|
||||||
resources = Resources
|
resources = Resources
|
||||||
|
resources.max = Max
|
||||||
bannedblocks = Banned Blocks
|
bannedblocks = Banned Blocks
|
||||||
bannedunits = Banned Units
|
bannedunits = Banned Units
|
||||||
addall = Add All
|
addall = Add All
|
||||||
@@ -616,7 +617,7 @@ sectors.rename = Rename Sector
|
|||||||
sectors.enemybase = [scarlet]Enemy Base
|
sectors.enemybase = [scarlet]Enemy Base
|
||||||
sectors.vulnerable = [scarlet]Vulnerable
|
sectors.vulnerable = [scarlet]Vulnerable
|
||||||
sectors.underattack = [scarlet]Under attack! [accent]{0}% damaged
|
sectors.underattack = [scarlet]Under attack! [accent]{0}% damaged
|
||||||
sectors.underattack.nodamage = [scarlet]Under attack!
|
sectors.underattack.nodamage = [scarlet]Enemy Present
|
||||||
sectors.survives = [accent]Survives {0} waves
|
sectors.survives = [accent]Survives {0} waves
|
||||||
sectors.go = Go
|
sectors.go = Go
|
||||||
sector.curcapture = Sector Captured
|
sector.curcapture = Sector Captured
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package mindustry.ui.dialogs;
|
|||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.func.*;
|
import arc.func.*;
|
||||||
|
import arc.math.*;
|
||||||
import arc.scene.ui.*;
|
import arc.scene.ui.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
@@ -66,6 +67,15 @@ public class LaunchLoadoutDialog extends BaseDialog{
|
|||||||
|
|
||||||
ItemSeq schems = selected.requirements();
|
ItemSeq schems = selected.requirements();
|
||||||
ItemSeq launches = universe.getLaunchResources();
|
ItemSeq launches = universe.getLaunchResources();
|
||||||
|
int capacity = lastCapacity;
|
||||||
|
|
||||||
|
if(getMax()){
|
||||||
|
for(Item item : content.items()){
|
||||||
|
launches.set(item, Mathf.clamp(sitems.get(item) - launches.get(item), 0, capacity));
|
||||||
|
}
|
||||||
|
|
||||||
|
universe.updateLaunchResources(launches);
|
||||||
|
}
|
||||||
|
|
||||||
for(ItemStack s : total){
|
for(ItemStack s : total){
|
||||||
table.image(s.item.uiIcon).left().size(iconSmall);
|
table.image(s.item.uiIcon).left().size(iconSmall);
|
||||||
@@ -87,7 +97,13 @@ public class LaunchLoadoutDialog extends BaseDialog{
|
|||||||
|
|
||||||
Runnable rebuildItems = () -> rebuild.get(items);
|
Runnable rebuildItems = () -> rebuild.get(items);
|
||||||
|
|
||||||
buttons.button("@resources", Icon.terrain, () -> {
|
buttons.button("@resources.max", Icon.add, Styles.togglet, () -> {
|
||||||
|
setMax(!getMax());
|
||||||
|
update.run();
|
||||||
|
rebuildItems.run();
|
||||||
|
}).checked(b -> getMax());
|
||||||
|
|
||||||
|
buttons.button("@resources", Icon.edit, () -> {
|
||||||
ItemSeq stacks = universe.getLaunchResources();
|
ItemSeq stacks = universe.getLaunchResources();
|
||||||
Seq<ItemStack> out = stacks.toSeq();
|
Seq<ItemStack> out = stacks.toSeq();
|
||||||
|
|
||||||
@@ -99,7 +115,7 @@ public class LaunchLoadoutDialog extends BaseDialog{
|
|||||||
update.run();
|
update.run();
|
||||||
rebuildItems.run();
|
rebuildItems.run();
|
||||||
});
|
});
|
||||||
}).width(204);
|
}).disabled(b -> getMax());
|
||||||
|
|
||||||
boolean rows = Core.graphics.isPortrait() && mobile;
|
boolean rows = Core.graphics.isPortrait() && mobile;
|
||||||
|
|
||||||
@@ -112,7 +128,7 @@ public class LaunchLoadoutDialog extends BaseDialog{
|
|||||||
}).disabled(b -> !valid);
|
}).disabled(b -> !valid);
|
||||||
|
|
||||||
if(rows){
|
if(rows){
|
||||||
cell.colspan(2).size(160f + 204f + 4f, 64f);
|
cell.colspan(2).size(160f + 160f + 4f, 64f);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cols = Math.max((int)(Core.graphics.getWidth() / Scl.scl(230)), 1);
|
int cols = Math.max((int)(Core.graphics.getWidth() / Scl.scl(230)), 1);
|
||||||
@@ -169,4 +185,12 @@ public class LaunchLoadoutDialog extends BaseDialog{
|
|||||||
|
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setMax(boolean max){
|
||||||
|
Core.settings.put("maxresources", max);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean getMax(){
|
||||||
|
return Core.settings.getBool("maxresources", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
//preset sectors can only be selected once unlocked
|
//preset sectors can only be selected once unlocked
|
||||||
if(sector.preset != null){
|
if(sector.preset != null){
|
||||||
TechNode node = sector.preset.techNode;
|
TechNode node = sector.preset.techNode;
|
||||||
return node == null || node.parent == null || node.parent.content.unlocked();
|
return node == null || node.parent == null || (node.parent.content.unlocked() && (!(node.parent.content instanceof SectorPreset preset) || preset.sector.hasBase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return sector.planet.generator != null ?
|
return sector.planet.generator != null ?
|
||||||
|
|||||||
Reference in New Issue
Block a user