Files
Mindustry/core/src/mindustry/ui/ContentDisplay.java
Anuken ad6e0bcd0f Merge branches 'master' and 'mech-rework' of https://github.com/Anuken/Mindustry into mech-rework
# Conflicts:
#	android/src/mindustry/android/AndroidLauncher.java
#	annotations/src/main/java/mindustry/annotations/SerializeAnnotationProcessor.java
#	annotations/src/main/java/mindustry/annotations/impl/AssetsAnnotationProcessor.java
#	build.gradle
#	core/assets-raw/fontgen/config.json
#	core/assets/bundles/bundle_cs.properties
#	core/assets/bundles/bundle_it.properties
#	core/assets/fonts/font.ttf
#	core/assets/fonts/icon.ttf
#	core/assets/icons/icons.properties
#	core/assets/sprites/block_colors.png
#	core/assets/sprites/sprites.atlas
#	core/assets/sprites/sprites.png
#	core/assets/sprites/sprites3.png
#	core/assets/sprites/sprites5.png
#	core/src/mindustry/content/UnitTypes.java
#	core/src/mindustry/core/NetClient.java
#	core/src/mindustry/core/NetServer.java
#	core/src/mindustry/entities/bullet/BulletType.java
#	core/src/mindustry/entities/type/TileEntity.java
#	core/src/mindustry/maps/filters/FilterOption.java
#	core/src/mindustry/mod/Scripts.java
#	core/src/mindustry/ui/Fonts.java
#	core/src/mindustry/ui/dialogs/DeployDialog.java
#	core/src/mindustry/ui/fragments/HudFragment.java
#	core/src/mindustry/ui/fragments/MenuFragment.java
#	core/src/mindustry/world/blocks/production/Cultivator.java
#	core/src/mindustry/world/blocks/units/CommandCenter.java
#	gradle.properties
#	tools/src/mindustry/tools/FontGenerator.java
2020-01-27 15:51:02 -05:00

213 lines
7.0 KiB
Java

package mindustry.ui;
import arc.*;
import arc.struct.*;
import arc.graphics.*;
import arc.scene.ui.layout.*;
import arc.util.*;
import mindustry.graphics.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.meta.*;
public class ContentDisplay{
public static void displayBlock(Table table, Block block){
table.table(title -> {
int size = 8 * 6;
title.addImage(block.icon(Cicon.xlarge)).size(size);
title.add("[accent]" + block.localizedName).padLeft(5);
});
table.row();
table.addImage().height(3).color(Color.lightGray).pad(8).padLeft(0).padRight(0).fillX();
table.row();
if(block.description != null){
table.add(block.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage().height(3).color(Color.lightGray).pad(8).padLeft(0).padRight(0).fillX();
table.row();
}
BlockStats stats = block.stats;
for(StatCategory cat : stats.toMap().keys()){
OrderedMap<BlockStat, Array<StatValue>> map = stats.toMap().get(cat);
if(map.size == 0) continue;
table.add("$category." + cat.name()).color(Pal.accent).fillX();
table.row();
for(BlockStat stat : map.keys()){
table.table(inset -> {
inset.left();
inset.add("[LIGHT_GRAY]" + stat.localized() + ":[] ").left();
Array<StatValue> arr = map.get(stat);
for(StatValue value : arr){
value.display(inset);
inset.add().size(10f);
}
//map.get(stat).display(inset);
}).fillX().padLeft(10);
table.row();
}
}
}
public static void displayItem(Table table, Item item){
table.table(title -> {
title.addImage(item.icon(Cicon.xlarge)).size(8 * 6);
title.add("[accent]" + item.localizedName).padLeft(5);
});
table.row();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
if(item.description != null){
table.add(item.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
}
table.left().defaults().fillX();
table.add(Core.bundle.format("item.corestorable", item.type == ItemType.material ? Core.bundle.format("yes") : Core.bundle.format("no")));
table.row();
table.add(Core.bundle.format("item.explosiveness", (int)(item.explosiveness * 100)));
table.row();
table.add(Core.bundle.format("item.flammability", (int)(item.flammability * 100)));
table.row();
table.add(Core.bundle.format("item.radioactivity", (int)(item.radioactivity * 100)));
table.row();
}
public static void displayLiquid(Table table, Liquid liquid){
table.table(title -> {
title.addImage(liquid.icon(Cicon.xlarge)).size(8 * 6);
title.add("[accent]" + liquid.localizedName).padLeft(5);
});
table.row();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
if(liquid.description != null){
table.add(liquid.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
}
table.left().defaults().fillX();
table.add(Core.bundle.format("item.explosiveness", (int)(liquid.explosiveness * 100)));
table.row();
table.add(Core.bundle.format("item.flammability", (int)(liquid.flammability * 100)));
table.row();
table.add(Core.bundle.format("liquid.heatcapacity", (int)(liquid.heatCapacity * 100)));
table.row();
table.add(Core.bundle.format("liquid.temperature", (int)(liquid.temperature * 100)));
table.row();
table.add(Core.bundle.format("liquid.viscosity", (int)(liquid.viscosity * 100)));
table.row();
}
//TODO implement later
/*
public static void displayMech(Table table, Mech mech){
table.table(title -> {
title.addImage(mech.icon(Cicon.xlarge)).size(8 * 6);
title.add("[accent]" + mech.localizedName).padLeft(5);
});
table.left().defaults().left();
table.row();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
if(mech.description != null){
table.add(mech.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
}
table.left().defaults().fillX();
if(Core.bundle.has("mech." + mech.name + ".weapon")){
table.add(Core.bundle.format("mech.weapon", Core.bundle.get("mech." + mech.name + ".weapon")));
table.row();
}
if(Core.bundle.has("mech." + mech.name + ".ability")){
table.add(Core.bundle.format("mech.ability", Core.bundle.get("mech." + mech.name + ".ability")));
table.row();
}
table.add(Core.bundle.format("mech.buildspeed", (int)(mech.buildPower * 100f)));
table.row();
table.add(Core.bundle.format("mech.health", (int)mech.health));
table.row();
table.add(Core.bundle.format("mech.itemcapacity", mech.itemCapacity));
table.row();
if(mech.drillPower > 0){
table.add(Core.bundle.format("mech.minespeed", (int)(mech.mineSpeed * 100f)));
table.row();
table.add(Core.bundle.format("mech.minepower", mech.drillPower));
table.row();
}
}*/
public static void displayUnit(Table table, UnitDef unit){
table.table(title -> {
title.addImage(unit.icon(Cicon.xlarge)).size(8 * 6);
title.add("[accent]" + unit.localizedName).padLeft(5);
});
table.row();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
if(unit.description != null){
table.add(unit.displayDescription()).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
}
table.left().defaults().fillX();
table.add(Core.bundle.format("unit.health", unit.health));
table.row();
table.add(Core.bundle.format("unit.speed", Strings.fixed(unit.speed, 1)));
table.row();
table.row();
}
}