Added weapon upgrades, bugfixes
This commit is contained in:
48
core/src/io/anuke/mindustry/ui/LevelDialog.java
Normal file
48
core/src/io/anuke/mindustry/ui/LevelDialog.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
|
||||
import io.anuke.mindustry.GameState;
|
||||
import io.anuke.mindustry.World;
|
||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||
import io.anuke.ucore.scene.ui.Dialog;
|
||||
import io.anuke.ucore.scene.ui.ImageButton;
|
||||
|
||||
public class LevelDialog extends Dialog{
|
||||
private int selectedMap;
|
||||
|
||||
public LevelDialog(){
|
||||
super("Level Select");
|
||||
setup();
|
||||
}
|
||||
|
||||
void setup(){
|
||||
ButtonGroup<ImageButton> mapgroup = new ButtonGroup<>();
|
||||
|
||||
addCloseButton();
|
||||
getButtonTable().addButton("Play", ()->{
|
||||
hide();
|
||||
World.loadMap(selectedMap);
|
||||
GameState.play();
|
||||
});
|
||||
|
||||
for(int i = 0; i < maps.length; i ++){
|
||||
content().add(maps[i]);
|
||||
}
|
||||
|
||||
content().row();
|
||||
|
||||
for(int i = 0; i < maps.length; i ++){
|
||||
int index = i;
|
||||
ImageButton image = new ImageButton(new TextureRegion(mapTextures[i]), "togglemap");
|
||||
mapgroup.add(image);
|
||||
image.clicked(()->{
|
||||
selectedMap = index;
|
||||
});
|
||||
image.getImageCell().size(150, 150);
|
||||
content().add(image).size(180);
|
||||
}
|
||||
}
|
||||
}
|
||||
40
core/src/io/anuke/mindustry/ui/MenuDialog.java
Normal file
40
core/src/io/anuke/mindustry/ui/MenuDialog.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import io.anuke.ucore.scene.ui.ConfirmDialog;
|
||||
import io.anuke.ucore.scene.ui.Dialog;
|
||||
|
||||
public class MenuDialog extends Dialog{
|
||||
|
||||
public MenuDialog(){
|
||||
super("Paused", "dialog");
|
||||
setup();
|
||||
}
|
||||
|
||||
void setup(){
|
||||
content().addButton("Back", ()->{
|
||||
hide();
|
||||
paused = false;
|
||||
}).width(200);
|
||||
|
||||
content().row();
|
||||
content().addButton("Settings", ()->{
|
||||
ui.showPrefs();
|
||||
}).width(200);
|
||||
|
||||
content().row();
|
||||
content().addButton("Controls", ()->{
|
||||
ui.showControls();
|
||||
}).width(200);
|
||||
|
||||
content().row();
|
||||
content().addButton("Back to menu", ()->{
|
||||
new ConfirmDialog("Confirm", "Are you sure you want to quit?", ()->{
|
||||
hide();
|
||||
paused = false;
|
||||
playing = false;
|
||||
});
|
||||
}).width(200);
|
||||
}
|
||||
}
|
||||
35
core/src/io/anuke/mindustry/ui/TutorialDialog.java
Normal file
35
core/src/io/anuke/mindustry/ui/TutorialDialog.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.scene.ui.TextDialog;
|
||||
|
||||
public class TutorialDialog extends TextDialog{
|
||||
|
||||
public TutorialDialog(){
|
||||
super("Tutorial", tutorialText);
|
||||
setup();
|
||||
}
|
||||
|
||||
void setup(){
|
||||
setDialog();
|
||||
|
||||
hidden(()->{
|
||||
playing = true;
|
||||
paused = false;
|
||||
});
|
||||
|
||||
getButtonTable().addButton("OK", ()->{
|
||||
hide();
|
||||
});
|
||||
|
||||
content().pad(8);
|
||||
|
||||
content().row();
|
||||
content().addCheck("Don't show again", b->{
|
||||
Settings.putBool("tutorial", !b);
|
||||
Settings.save();
|
||||
}).padTop(4);
|
||||
}
|
||||
}
|
||||
119
core/src/io/anuke/mindustry/ui/UpgradeDialog.java
Normal file
119
core/src/io/anuke/mindustry/ui/UpgradeDialog.java
Normal file
@@ -0,0 +1,119 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
|
||||
import io.anuke.mindustry.Inventory;
|
||||
import io.anuke.mindustry.entities.Weapon;
|
||||
import io.anuke.mindustry.resource.ItemStack;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.scene.event.Touchable;
|
||||
import io.anuke.ucore.scene.ui.*;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
public class UpgradeDialog extends Dialog{
|
||||
|
||||
public UpgradeDialog() {
|
||||
super("Upgrades");
|
||||
setup();
|
||||
}
|
||||
|
||||
void setup(){
|
||||
addCloseButton();
|
||||
|
||||
hidden(()->{
|
||||
paused = false;
|
||||
});
|
||||
shown(()->{
|
||||
paused = true;
|
||||
});
|
||||
|
||||
getButtonTable().addButton("Ok", ()->{
|
||||
hide();
|
||||
});
|
||||
|
||||
Table weptab = new Table();
|
||||
weptab.background("button");
|
||||
weptab.pad(20);
|
||||
|
||||
for(Weapon weapon : Weapon.values()){
|
||||
TextButton button = new TextButton(weapon.name());
|
||||
|
||||
Image img = new Image(Draw.region("weapon-"+weapon.name()));
|
||||
button.add(img).size(8*5);
|
||||
button.getCells().reverse();
|
||||
button.row();
|
||||
button.pack();
|
||||
|
||||
button.update(()->{
|
||||
|
||||
if(weapons.get(weapon) == Boolean.TRUE){
|
||||
button.setDisabled(true);
|
||||
button.setColor(Color.GRAY);
|
||||
button.setTouchable(Touchable.disabled);
|
||||
}else{
|
||||
button.setColor(Color.WHITE);
|
||||
button.setDisabled(false);
|
||||
}
|
||||
|
||||
button.setDisabled(!Inventory.hasItems(weapon.requirements));
|
||||
});
|
||||
|
||||
|
||||
weptab.add(button).width(160);
|
||||
|
||||
Table tiptable = new Table();
|
||||
|
||||
Runnable run = ()->{
|
||||
tiptable.clearChildren();
|
||||
|
||||
String description = weapon.description;
|
||||
|
||||
tiptable.background("button");
|
||||
tiptable.add("[PURPLE]" + weapon.name(), 0.75f).left().padBottom(2f);
|
||||
|
||||
if(weapons.get(weapon) != Boolean.TRUE){
|
||||
ItemStack[] req = weapon.requirements;
|
||||
for(ItemStack s : req){
|
||||
tiptable.row();
|
||||
int amount = Math.min(items.get(s.item, 0), s.amount);
|
||||
tiptable.add(
|
||||
(amount >= s.amount ? "[YELLOW]" : "[RED]")
|
||||
+s.item + ": " + amount + " / " +s.amount, 0.5f).left();
|
||||
}
|
||||
}
|
||||
|
||||
tiptable.row();
|
||||
tiptable.add().size(10);
|
||||
tiptable.row();
|
||||
tiptable.add("[ORANGE]" + description).left();
|
||||
tiptable.row();
|
||||
if(weapons.get(weapon) == Boolean.TRUE)
|
||||
tiptable.add("[LIME]Purchased!").left();
|
||||
tiptable.pad(10f);
|
||||
};
|
||||
|
||||
run.run();
|
||||
|
||||
Tooltip tip = new Tooltip(tiptable, run);
|
||||
|
||||
tip.setInstant(true);
|
||||
|
||||
button.addListener(tip);
|
||||
|
||||
button.clicked(()->{
|
||||
Inventory.removeItems(weapon.requirements);
|
||||
weapons.put(weapon, true);
|
||||
ui.updateWeapons();
|
||||
run.run();
|
||||
});
|
||||
}
|
||||
|
||||
content().add("Weapons");
|
||||
content().row();
|
||||
content().add(weptab);
|
||||
content().row();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user