Added content unlock menu
This commit is contained in:
90
core/src/io/anuke/mindustry/ui/ContentDisplay.java
Normal file
90
core/src/io/anuke/mindustry/ui/ContentDisplay.java
Normal file
@@ -0,0 +1,90 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.OrderedMap;
|
||||
import io.anuke.mindustry.entities.units.UnitType;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.type.Mech;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.blocks.defense.turrets.Turret;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.BlockStats;
|
||||
import io.anuke.mindustry.world.meta.StatCategory;
|
||||
import io.anuke.mindustry.world.meta.StatValue;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
public class ContentDisplay {
|
||||
|
||||
public static void displayRecipe(Table table, Recipe recipe){
|
||||
Block block = recipe.result;
|
||||
|
||||
FloatingDialog dialog = new FloatingDialog("$text.blocks.blockinfo");
|
||||
dialog.addCloseButton();
|
||||
|
||||
table.table(title -> {
|
||||
int size = 8*6;
|
||||
|
||||
if(block instanceof Turret){
|
||||
size = (8 * block.size + 2) * (7 - block.size*2);
|
||||
}
|
||||
|
||||
title.addImage(Draw.region("block-icon-" + block.name)).size(size);
|
||||
title.add("[accent]" + block.formalName).padLeft(5);
|
||||
});
|
||||
|
||||
table.row();
|
||||
|
||||
table.addImage("white").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
|
||||
table.row();
|
||||
|
||||
if(block.fullDescription != null){
|
||||
table.add(block.fullDescription).padLeft(5).padRight(5).width(400f).wrap().fillX();
|
||||
table.row();
|
||||
|
||||
table.addImage("white").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
table.row();
|
||||
}
|
||||
|
||||
BlockStats stats = block.stats;
|
||||
|
||||
for(StatCategory cat : stats.toMap().keys()){
|
||||
OrderedMap<BlockStat, StatValue> map = stats.toMap().get(cat);
|
||||
|
||||
if(map.size == 0) continue;
|
||||
|
||||
table.add("$text.category." + cat.name()).color(Palette.accent).fillX();
|
||||
table.row();
|
||||
|
||||
for (BlockStat stat : map.keys()){
|
||||
table.table(inset -> {
|
||||
inset.left();
|
||||
inset.add("[LIGHT_GRAY]" + stat.localized() + ":[] ");
|
||||
map.get(stat).display(inset);
|
||||
}).fillX().padLeft(10);
|
||||
table.row();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void displayItem(Table table, Item item){
|
||||
|
||||
}
|
||||
|
||||
public static void displayLiquid(Table table, Liquid liquid){
|
||||
|
||||
}
|
||||
|
||||
public static void displayMech(Table table, Mech mech){
|
||||
|
||||
}
|
||||
|
||||
public static void displayUnit(Table table, UnitType unit){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ public class MenuButton extends TextButton{
|
||||
|
||||
public MenuButton(String icon, String text, String description, Listenable clicked){
|
||||
super("default");
|
||||
float s = 70f;
|
||||
float s = 66f;
|
||||
|
||||
clicked(clicked);
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
public class ContentInfoDialog extends FloatingDialog {
|
||||
|
||||
public ContentInfoDialog(){
|
||||
super("$text.info");
|
||||
|
||||
addCloseButton();
|
||||
}
|
||||
|
||||
public void show(UnlockableContent content){
|
||||
content().clear();
|
||||
|
||||
Table table = new Table();
|
||||
table.margin(10);
|
||||
|
||||
content.displayInfo(table);
|
||||
|
||||
ScrollPane pane = new ScrollPane(table, "clear-black");
|
||||
content().add(pane);
|
||||
|
||||
show();
|
||||
}
|
||||
}
|
||||
75
core/src/io/anuke/mindustry/ui/dialogs/UnlocksDialog.java
Normal file
75
core/src/io/anuke/mindustry/ui/dialogs/UnlocksDialog.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.OrderedMap;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.ContentLoader;
|
||||
import io.anuke.mindustry.game.Content;
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
||||
import io.anuke.ucore.scene.ui.Tooltip;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
import static io.anuke.mindustry.Vars.control;
|
||||
|
||||
public class UnlocksDialog extends FloatingDialog {
|
||||
|
||||
public UnlocksDialog() {
|
||||
super("$text.unlocks");
|
||||
|
||||
addCloseButton();
|
||||
shown(this::rebuild);
|
||||
}
|
||||
|
||||
void rebuild(){
|
||||
content().clear();
|
||||
|
||||
Table table = new Table();
|
||||
table.margin(20);
|
||||
ScrollPane pane = new ScrollPane(table, "clear-black");
|
||||
|
||||
OrderedMap<String, Array<Content>> allContent = ContentLoader.getContentMap();
|
||||
|
||||
//allContent.orderedKeys().reverse();
|
||||
|
||||
for(String key : allContent.orderedKeys()){
|
||||
Array<Content> array = allContent.get(key);
|
||||
if(array.size == 0 || !(array.first() instanceof UnlockableContent)) continue;
|
||||
|
||||
table.add("$content." +key + ".name").growX().left().color(Palette.accent);
|
||||
table.row();
|
||||
table.addImage("white").growX().pad(5).padLeft(0).padRight(0).height(3).color(Palette.accent);
|
||||
table.row();
|
||||
table.table(list -> {
|
||||
list.left();
|
||||
|
||||
int maxWidth = 14;
|
||||
int size = 8*6;
|
||||
|
||||
for (int i = 0; i < array.size; i++) {
|
||||
UnlockableContent unlock = (UnlockableContent)array.get(i);
|
||||
|
||||
Image image = control.database().isUnlocked(unlock) ? new Image(unlock.getContentIcon()) : new Image("icon-locked");
|
||||
list.add(image).size(size).pad(3);
|
||||
|
||||
if(control.database().isUnlocked(unlock)) {
|
||||
image.clicked(() -> Vars.ui.content.show(unlock));
|
||||
image.addListener(new Tooltip<>(new Table("clear"){{
|
||||
add(unlock.localizedName());
|
||||
margin(4);
|
||||
}}));
|
||||
}
|
||||
|
||||
if((i+1) % maxWidth == 0){
|
||||
list.row();
|
||||
}
|
||||
}
|
||||
}).growX().left().padBottom(10);
|
||||
table.row();
|
||||
}
|
||||
|
||||
content().add(pane);
|
||||
}
|
||||
}
|
||||
@@ -4,25 +4,15 @@ import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.OrderedMap;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.mindustry.type.Category;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.blocks.defense.turrets.Turret;
|
||||
import io.anuke.mindustry.world.meta.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.BlockStats;
|
||||
import io.anuke.mindustry.world.meta.StatCategory;
|
||||
import io.anuke.mindustry.world.meta.StatValue;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.actions.Actions;
|
||||
@@ -327,7 +317,7 @@ public class BlocksFragment implements Fragment{
|
||||
nameLabel.setWrap(true);
|
||||
header.add(nameLabel).padLeft(2).width(120f);
|
||||
|
||||
header.addButton("?", () -> showBlockInfo(recipe.result)).expandX().padLeft(3).top().right().size(40f, 44f).padTop(-2);
|
||||
header.addButton("?", () -> ui.content.show(recipe)).expandX().padLeft(3).top().right().size(40f, 44f).padTop(-2);
|
||||
|
||||
descTable.add().pad(2);
|
||||
|
||||
@@ -357,62 +347,6 @@ public class BlocksFragment implements Fragment{
|
||||
descTable.row();
|
||||
}
|
||||
|
||||
private void showBlockInfo(Block block){
|
||||
FloatingDialog dialog = new FloatingDialog("$text.blocks.blockinfo");
|
||||
dialog.addCloseButton();
|
||||
|
||||
Table table = new Table();
|
||||
ScrollPane pane = new ScrollPane(table, "clear");
|
||||
|
||||
table.table(title -> {
|
||||
int size = 8*6;
|
||||
|
||||
if(block instanceof Turret){
|
||||
size = (8 * block.size + 2) * (7 - block.size*2);
|
||||
}
|
||||
|
||||
title.addImage(Draw.region("block-icon-" + block.name)).size(size);
|
||||
title.add("[accent]" + block.formalName).padLeft(5);
|
||||
});
|
||||
|
||||
table.row();
|
||||
|
||||
table.addImage("white").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
|
||||
table.row();
|
||||
|
||||
if(block.fullDescription != null){
|
||||
table.add(block.fullDescription).padLeft(5).padRight(5).width(400f).wrap().fillX();
|
||||
table.row();
|
||||
|
||||
table.addImage("white").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
|
||||
table.row();
|
||||
}
|
||||
|
||||
BlockStats stats = block.stats;
|
||||
|
||||
for(StatCategory cat : stats.toMap().keys()){
|
||||
OrderedMap<BlockStat, StatValue> map = stats.toMap().get(cat);
|
||||
|
||||
if(map.size == 0) continue;
|
||||
|
||||
table.add("$text.category." + cat.name()).color(Palette.accent).fillX();
|
||||
table.row();
|
||||
|
||||
for (BlockStat stat : map.keys()){
|
||||
table.table(inset -> {
|
||||
inset.left();
|
||||
inset.add("[LIGHT_GRAY]" + stat.localized() + ":[] ");
|
||||
map.get(stat).display(inset);
|
||||
}).fillX().padLeft(10);
|
||||
table.row();
|
||||
}
|
||||
}
|
||||
|
||||
dialog.content().add(pane).grow();
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
String format(int number){
|
||||
if(number >= 1000000) {
|
||||
return Strings.toFixed(number/1000000f, 1) + "[gray]mil[]";
|
||||
|
||||
@@ -25,7 +25,7 @@ public class MenuFragment implements Fragment{
|
||||
float w = 200f;
|
||||
float bw = w * 2f + 10f;
|
||||
|
||||
defaults().size(w, 70f).padTop(5).padRight(5);
|
||||
defaults().size(w, 66f).padTop(5).padRight(5);
|
||||
|
||||
add(new MenuButton("icon-play-2", "$text.play", MenuFragment.this::showPlaySelect)).width(bw).colspan(2);
|
||||
|
||||
@@ -41,6 +41,12 @@ public class MenuFragment implements Fragment{
|
||||
|
||||
add(new MenuButton("icon-tools", "$text.settings", ui.settings::show));
|
||||
|
||||
row();
|
||||
|
||||
add(new MenuButton("icon-menu", "$text.changelog.title", ui.changelog::show));
|
||||
|
||||
add(new MenuButton("icon-unlocks", "$text.unlocks", ui.unlocks::show));
|
||||
|
||||
row();
|
||||
|
||||
if(!gwt){
|
||||
|
||||
Reference in New Issue
Block a user