Merge branch 'master' into port-field
This commit is contained in:
@@ -63,7 +63,7 @@ public class Bar extends Element{
|
||||
if(fraction == null) return;
|
||||
|
||||
float computed = Mathf.clamp(fraction.get());
|
||||
if(!Mathf.equal(lastValue, computed)){
|
||||
if(lastValue > computed){
|
||||
blink = 1f;
|
||||
lastValue = computed;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import static mindustry.Vars.*;
|
||||
|
||||
public class CoreItemsDisplay extends Table{
|
||||
private final ObjectSet<Item> usedItems = new ObjectSet<>();
|
||||
private CoreBuild core;
|
||||
|
||||
public CoreItemsDisplay(){
|
||||
rebuild();
|
||||
@@ -26,7 +27,7 @@ public class CoreItemsDisplay extends Table{
|
||||
margin(4);
|
||||
|
||||
update(() -> {
|
||||
CoreBuild core = Vars.player.team().core();
|
||||
core = Vars.player.team().core();
|
||||
|
||||
if(content.items().contains(item -> core != null && core.items.get(item) > 0 && usedItems.add(item))){
|
||||
rebuild();
|
||||
@@ -35,11 +36,10 @@ public class CoreItemsDisplay extends Table{
|
||||
|
||||
int i = 0;
|
||||
|
||||
CoreBuild core = Vars.player.team().core();
|
||||
for(Item item : content.items()){
|
||||
if(usedItems.contains(item)){
|
||||
image(item.icon(Cicon.small)).padRight(3);
|
||||
label(() -> core == null ? "0" : UI.formatAmount(core.items.get(item))).padRight(3);
|
||||
label(() -> core == null ? "0" : UI.formatAmount(core.items.get(item))).padRight(3).left();
|
||||
|
||||
if(++i % 4 == 0){
|
||||
row();
|
||||
|
||||
@@ -10,8 +10,12 @@ public class ItemImage extends Stack{
|
||||
public ItemImage(TextureRegion region, int amount){
|
||||
Table t = new Table().left().bottom();
|
||||
t.add(amount + "").name("item-label");
|
||||
t.pack();
|
||||
|
||||
add(new Image(region));
|
||||
add(new Table(o -> {
|
||||
o.left();
|
||||
o.add(new Image(region)).size(32f);
|
||||
}));
|
||||
add(t);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -162,7 +163,8 @@ public class CustomRulesDialog extends BaseDialog{
|
||||
number("@rules.enemycorebuildradius", f -> rules.enemyCoreBuildRadius = f * tilesize, () -> Math.min(rules.enemyCoreBuildRadius / tilesize, 200));
|
||||
|
||||
title("@rules.title.environment");
|
||||
number("@rules.solarpowermultiplier", f -> rules.solarPowerMultiplier = f, () -> rules.solarPowerMultiplier);
|
||||
check("@rules.explosions", b -> rules.damageExplosions = b, () -> rules.damageExplosions);
|
||||
check("@rules.fire", b -> rules.fire = b, () -> rules.fire);
|
||||
check("@rules.lighting", b -> rules.lighting = b, () -> rules.lighting);
|
||||
|
||||
main.button(b -> {
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package mindustry.ui.dialogs;
|
||||
|
||||
import arc.*;
|
||||
import arc.input.*;
|
||||
import arc.struct.*;
|
||||
import arc.graphics.*;
|
||||
import arc.input.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.event.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.ctype.*;
|
||||
@@ -14,7 +15,7 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
import static mindustry.Vars.ui;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class DatabaseDialog extends BaseDialog{
|
||||
|
||||
@@ -49,8 +50,7 @@ public class DatabaseDialog extends BaseDialog{
|
||||
table.table(list -> {
|
||||
list.left();
|
||||
|
||||
int maxWidth = Core.graphics.isPortrait() ? 7 : 13;
|
||||
|
||||
int cols = Mathf.clamp((Core.graphics.getWidth() - 30) / (32 + 10), 1, 18);
|
||||
int count = 0;
|
||||
|
||||
for(int i = 0; i < array.size; i++){
|
||||
@@ -77,7 +77,7 @@ public class DatabaseDialog extends BaseDialog{
|
||||
image.addListener(new Tooltip(t -> t.background(Tex.button).add(unlock.localizedName)));
|
||||
}
|
||||
|
||||
if((++count) % maxWidth == 0){
|
||||
if((++count) % cols == 0){
|
||||
list.row();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,14 +262,10 @@ public class JoinDialog extends BaseDialog{
|
||||
cont.clear();
|
||||
cont.table(t -> {
|
||||
t.add("@name").padRight(10);
|
||||
if(!steam){
|
||||
t.field(Core.settings.getString("name"), text -> {
|
||||
player.name(text);
|
||||
Core.settings.put("name", text);
|
||||
}).grow().pad(8).addInputDialog(maxNameLength);
|
||||
}else{
|
||||
t.add(player.name).update(l -> l.setColor(player.color())).grow().pad(8);
|
||||
}
|
||||
t.field(Core.settings.getString("name"), text -> {
|
||||
player.name(text);
|
||||
Core.settings.put("name", text);
|
||||
}).grow().pad(8).addInputDialog(maxNameLength);
|
||||
|
||||
ImageButton button = t.button(Tex.whiteui, Styles.clearFulli, 40, () -> {
|
||||
new PaletteDialog().show(color -> {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -162,11 +162,17 @@ public class ModsDialog extends BaseDialog{
|
||||
}}).size(h - 8f).padTop(-8f).padLeft(-8f).padRight(8f);
|
||||
|
||||
title.table(text -> {
|
||||
text.add("" + mod.meta.displayName() + "\n[lightgray]v" + mod.meta.version + (mod.enabled() ? "" : "\n" + Core.bundle.get("mod.disabled") + ""))
|
||||
boolean hideDisabled = !mod.isSupported() || mod.hasUnmetDependencies() || mod.hasContentErrors();
|
||||
|
||||
text.add("" + mod.meta.displayName() + "\n[lightgray]v" + mod.meta.version + (mod.enabled() || hideDisabled ? "" : "\n" + Core.bundle.get("mod.disabled") + ""))
|
||||
.wrap().top().width(300f).growX().left();
|
||||
|
||||
text.row();
|
||||
if(!mod.isSupported()){
|
||||
|
||||
if(mod.isOutdated()){
|
||||
text.labelWrap("@mod.outdated").growX();
|
||||
text.row();
|
||||
}else if(!mod.isSupported()){
|
||||
text.labelWrap(Core.bundle.format("mod.requiresversion", mod.meta.minGameVersion)).growX();
|
||||
text.row();
|
||||
}else if(mod.hasUnmetDependencies()){
|
||||
|
||||
@@ -88,7 +88,7 @@ public class PausedDialog extends BaseDialog{
|
||||
cont.buttonRow("@launchcore", Icon.up, () -> {
|
||||
hide();
|
||||
ui.planet.show(state.getSector(), player.team().core());
|
||||
}).disabled(b -> player.team().core() == null || !player.team().core().items.has(player.team().core().block.requirements));
|
||||
}).disabled(b -> player.team().core() == null);
|
||||
|
||||
cont.row();
|
||||
|
||||
|
||||
@@ -94,6 +94,8 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
}
|
||||
|
||||
public void show(Sector sector, CoreBuild launcher){
|
||||
if(launcher == null) return;
|
||||
|
||||
this.launcher = launcher;
|
||||
selected = null;
|
||||
hovered = null;
|
||||
@@ -127,10 +129,11 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
|
||||
//draw all sector stuff
|
||||
for(Sector sec : planet.sectors){
|
||||
|
||||
if(selectAlpha > 0.01f){
|
||||
if(canLaunch(sec) || sec.unlocked()){
|
||||
if(sec.baseCoverage > 0){
|
||||
planets.fill(sec, Tmp.c1.set(Team.crux.color).a(0.1f * sec.baseCoverage * selectAlpha), -0.002f);
|
||||
planets.fill(sec, Tmp.c1.set(Team.crux.color).a(0.5f * sec.baseCoverage * selectAlpha), -0.002f);
|
||||
}
|
||||
|
||||
Color color =
|
||||
@@ -290,7 +293,6 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
selectAlpha = Mathf.lerpDelta(selectAlpha, Mathf.num(planets.zoom < 1.9f), 0.1f);
|
||||
}
|
||||
|
||||
//TODO localize
|
||||
void updateSelected(){
|
||||
Sector sector = selected;
|
||||
|
||||
@@ -305,16 +307,21 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
|
||||
stable.add("[accent]" + (sector.preset == null ? sector.id : sector.preset.localizedName)).row();
|
||||
stable.image().color(Pal.accent).fillX().height(3f).pad(3f).row();
|
||||
stable.add(sector.save != null ? sector.save.getPlayTime() : "[lightgray]Unexplored").row();
|
||||
stable.add(sector.save != null ? sector.save.getPlayTime() : "@sectors.unexplored").row();
|
||||
if(sector.hasWaves() || sector.hasEnemyBase()){
|
||||
stable.add("[accent]Difficulty: " + (int)(sector.baseCoverage * 10)).row();
|
||||
}
|
||||
|
||||
if(sector.hasBase() && sector.hasWaves()){
|
||||
//TODO localize when finalized
|
||||
//these mechanics are likely to change and as such are not added to the bundle
|
||||
stable.add("[scarlet]Under attack!");
|
||||
stable.row();
|
||||
stable.add("[accent]" + Mathf.ceil(sectorDestructionTurns - (sector.getSecondsPassed() * 60) / turnDuration) + " turn(s)\nuntil destruction");
|
||||
stable.row();
|
||||
}
|
||||
|
||||
stable.add("Resources:").row();
|
||||
stable.add("@sectors.resources").row();
|
||||
stable.table(t -> {
|
||||
t.left();
|
||||
int idx = 0;
|
||||
@@ -327,7 +334,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
|
||||
//production
|
||||
if(sector.hasBase() && sector.save.meta.hasProduction){
|
||||
stable.add("Production:").row();
|
||||
stable.add("@sectors.production").row();
|
||||
stable.table(t -> {
|
||||
t.left();
|
||||
|
||||
@@ -335,7 +342,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
int total = (int)(stat.mean * 60);
|
||||
if(total > 1){
|
||||
t.image(item.icon(Cicon.small)).padRight(3);
|
||||
t.add(UI.formatAmount(total) + " /min").color(Color.lightGray);
|
||||
t.add(UI.formatAmount(total) + " " + Core.bundle.get("unit.perminute")).color(Color.lightGray);
|
||||
t.row();
|
||||
}
|
||||
});
|
||||
@@ -344,7 +351,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
|
||||
//stored resources
|
||||
if(sector.hasBase() && sector.save.meta.secinfo.coreItems.size > 0){
|
||||
stable.add("Stored:").row();
|
||||
stable.add("@sectors.stored").row();
|
||||
stable.table(t -> {
|
||||
t.left();
|
||||
|
||||
@@ -367,7 +374,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
stable.row();
|
||||
|
||||
if((sector.hasBase() && mode == look) || canLaunch(sector) || (sector.preset != null && sector.preset.alwaysUnlocked)){
|
||||
stable.button(sector.hasBase() ? "Resume" : "Launch", Styles.transt, () -> {
|
||||
stable.button(sector.hasBase() ? "@sectors.resume" : "@sectors.launch", Styles.transt, () -> {
|
||||
|
||||
boolean shouldHide = true;
|
||||
|
||||
|
||||
@@ -134,7 +134,9 @@ public class ResearchDialog extends BaseDialog{
|
||||
}
|
||||
});
|
||||
|
||||
view.addListener(new ElementGestureListener(){
|
||||
touchable = Touchable.enabled;
|
||||
|
||||
addCaptureListener(new ElementGestureListener(){
|
||||
@Override
|
||||
public void zoom(InputEvent event, float initialDistance, float distance){
|
||||
if(view.lastZoom < 0){
|
||||
|
||||
@@ -61,7 +61,7 @@ public class BlockConfigFragment extends Fragment{
|
||||
}
|
||||
|
||||
table.setOrigin(Align.center);
|
||||
if(configTile == null || configTile.block() == Blocks.air || !configTile.isValid()){
|
||||
if(configTile == null || configTile.block == Blocks.air || !configTile.isValid()){
|
||||
hideConfig();
|
||||
}else{
|
||||
configTile.updateTableAlign(table);
|
||||
|
||||
@@ -44,10 +44,12 @@ public class BlockInventoryFragment extends Fragment{
|
||||
|
||||
@Remote(called = Loc.server, targets = Loc.both, forward = true)
|
||||
public static void requestItem(Player player, Building tile, Item item, int amount){
|
||||
if(player == null || tile == null || !tile.interactable(player.team())) return;
|
||||
amount = Mathf.clamp(amount, 0, player.unit().itemCapacity());
|
||||
if(player == null || tile == null || !tile.interactable(player.team()) || !player.within(tile, buildingRange)) return;
|
||||
amount = Math.min(player.unit().maxAccepted(item), amount);
|
||||
int fa = amount;
|
||||
|
||||
if(amount == 0) return;
|
||||
|
||||
if(net.server() && (!Units.canInteract(player, tile) ||
|
||||
!netServer.admins.allowAction(player, ActionType.withdrawItem, tile.tile(), action -> {
|
||||
action.item = item;
|
||||
@@ -77,7 +79,7 @@ public class BlockInventoryFragment extends Fragment{
|
||||
return;
|
||||
}
|
||||
this.tile = t;
|
||||
if(tile == null || !tile.block().isAccessible() || tile.items.total() == 0)
|
||||
if(tile == null || !tile.block.isAccessible() || tile.items.total() == 0)
|
||||
return;
|
||||
rebuild(true);
|
||||
}
|
||||
@@ -106,7 +108,7 @@ public class BlockInventoryFragment extends Fragment{
|
||||
table.touchable = Touchable.enabled;
|
||||
table.update(() -> {
|
||||
|
||||
if(state.isMenu() || tile == null || !tile.isValid() || !tile.block().isAccessible() || emptyTime >= holdShrink){
|
||||
if(state.isMenu() || tile == null || !tile.isValid() || !tile.block.isAccessible() || emptyTime >= holdShrink){
|
||||
hide();
|
||||
}else{
|
||||
if(tile.items.total() == 0){
|
||||
@@ -129,7 +131,7 @@ public class BlockInventoryFragment extends Fragment{
|
||||
}
|
||||
|
||||
updateTablePosition();
|
||||
if(tile.block().hasItems){
|
||||
if(tile.block.hasItems){
|
||||
boolean dirty = false;
|
||||
if(shrinkHoldTimes.length != content.items().size) shrinkHoldTimes = new float[content.items().size];
|
||||
|
||||
@@ -155,7 +157,7 @@ public class BlockInventoryFragment extends Fragment{
|
||||
table.margin(4f);
|
||||
table.defaults().size(8 * 5).pad(4f);
|
||||
|
||||
if(tile.block().hasItems){
|
||||
if(tile.block.hasItems){
|
||||
|
||||
for(int i = 0; i < content.items().size; i++){
|
||||
Item item = content.item(i);
|
||||
@@ -163,7 +165,7 @@ public class BlockInventoryFragment extends Fragment{
|
||||
|
||||
container.add(i);
|
||||
|
||||
Boolp canPick = () -> player.unit().acceptsItem(item) && !state.isPaused();
|
||||
Boolp canPick = () -> player.unit().acceptsItem(item) && !state.isPaused() && player.within(tile, itemTransferRange);
|
||||
|
||||
HandCursorListener l = new HandCursorListener();
|
||||
l.setEnabled(canPick);
|
||||
@@ -231,7 +233,7 @@ public class BlockInventoryFragment extends Fragment{
|
||||
}
|
||||
|
||||
private void updateTablePosition(){
|
||||
Vec2 v = Core.input.mouseScreen(tile.x + tile.block().size * tilesize / 2f, tile.y + tile.block().size * tilesize / 2f);
|
||||
Vec2 v = Core.input.mouseScreen(tile.x + tile.block.size * tilesize / 2f, tile.y + tile.block.size * tilesize / 2f);
|
||||
table.pack();
|
||||
table.setPosition(v.x, v.y, Align.topLeft);
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ public class HudFragment extends Fragment{
|
||||
//core items
|
||||
parent.fill(t -> {
|
||||
t.top().add(coreItems);
|
||||
t.visible(() -> Core.settings.getBool("coreitems") && !mobile && !state.isPaused());
|
||||
t.visible(() -> Core.settings.getBool("coreitems") && !mobile && !state.isPaused() && shown);
|
||||
});
|
||||
|
||||
//spawner warning
|
||||
|
||||
@@ -23,7 +23,7 @@ import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.blocks.BuildBlock.*;
|
||||
import mindustry.world.blocks.ConstructBlock.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@@ -95,7 +95,7 @@ public class PlacementFragment extends Fragment{
|
||||
|
||||
if(Core.input.keyDown(Binding.pick) && player.isBuilder()){ //mouse eyedropper select
|
||||
Building tile = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
||||
Block tryRecipe = tile == null ? null : tile.block() instanceof BuildBlock ? ((BuildEntity)tile).cblock : tile.block;
|
||||
Block tryRecipe = tile == null ? null : tile.block instanceof ConstructBlock ? ((ConstructBuild)tile).cblock : tile.block;
|
||||
Object tryConfig = tile == null ? null : tile.config();
|
||||
|
||||
for(BuildPlan req : player.builder().plans()){
|
||||
|
||||
Reference in New Issue
Block a user