Implemented dual wielding
This commit is contained in:
@@ -1,132 +0,0 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
|
||||
public class UpgradeDialog extends FloatingDialog{
|
||||
boolean wasPaused = false;
|
||||
|
||||
public UpgradeDialog() {
|
||||
super("$text.upgrades");
|
||||
setup();
|
||||
}
|
||||
|
||||
void setup(){
|
||||
/*
|
||||
addCloseButton();
|
||||
|
||||
hidden(()->{
|
||||
if(!wasPaused)
|
||||
GameState.set(State.playing);
|
||||
});
|
||||
shown(()->{
|
||||
wasPaused = GameState.is(State.paused);
|
||||
GameState.set(State.paused);
|
||||
});
|
||||
|
||||
Table weptab = new Table();
|
||||
weptab.margin(20);
|
||||
|
||||
int i = 0;
|
||||
for(Upgrade upgrade : Upgrade.getAllUpgrades()){
|
||||
if(!(upgrade instanceof Weapon)) continue;
|
||||
|
||||
Weapon weapon = (Weapon)upgrade;
|
||||
|
||||
TextButton button = new TextButton(weapon.localized());
|
||||
|
||||
Image img = new Image(Draw.region(weapon.name));
|
||||
button.add(img).size(8*5);
|
||||
button.getCells().reverse();
|
||||
button.row();
|
||||
button.margin(14);
|
||||
button.getLabelCell().left();
|
||||
button.pack();
|
||||
|
||||
button.update(()->{
|
||||
if(control.hasWeapon(weapon)){
|
||||
button.setDisabled(true);
|
||||
button.setColor(Color.GRAY);
|
||||
}else if(!control.hasItems(weapon.requirements)){
|
||||
button.setDisabled(true);
|
||||
}else{
|
||||
button.setDisabled(false);
|
||||
button.setColor(Color.WHITE);
|
||||
}
|
||||
});
|
||||
|
||||
if(i > 0 && (i)%2==0)
|
||||
weptab.row();
|
||||
|
||||
i++;
|
||||
|
||||
weptab.add(button).width(220);
|
||||
|
||||
Table tiptable = new Table();
|
||||
|
||||
Listenable run = ()->{
|
||||
tiptable.clearChildren();
|
||||
|
||||
String description = weapon.description;
|
||||
|
||||
tiptable.background("pane");
|
||||
tiptable.add("[orange]" + weapon.localized(), 0.5f).left().padBottom(4f);
|
||||
|
||||
Table reqtable = new Table();
|
||||
|
||||
tiptable.row();
|
||||
tiptable.add(reqtable).left();
|
||||
|
||||
if(!control.hasWeapon(weapon)){
|
||||
ItemStack[] req = weapon.requirements;
|
||||
for(ItemStack s : req){
|
||||
|
||||
int amount = Math.min(control.getAmount(s.item), s.amount);
|
||||
reqtable.addImage(Draw.region("icon-" + s.item.name)).padRight(3).size(8*2);
|
||||
reqtable.add(
|
||||
(amount >= s.amount ? "" : "[RED]")
|
||||
+ amount + " / " +s.amount, 0.5f).left();
|
||||
reqtable.row();
|
||||
}
|
||||
}
|
||||
|
||||
tiptable.row();
|
||||
tiptable.add().size(10);
|
||||
tiptable.row();
|
||||
tiptable.add("[gray]" + description).left();
|
||||
tiptable.row();
|
||||
if(control.hasWeapon(weapon)){
|
||||
tiptable.add("$text.purchased").padTop(6).left();
|
||||
}
|
||||
tiptable.margin(14f);
|
||||
};
|
||||
|
||||
run.listen();
|
||||
|
||||
Tooltip<Table> tip = new Tooltip<>(tiptable, run);
|
||||
|
||||
tip.setInstant(true);
|
||||
|
||||
button.addListener(tip);
|
||||
|
||||
button.clicked(()->{
|
||||
if(button.isDisabled()) return;
|
||||
|
||||
control.removeItems(weapon.requirements);
|
||||
control.addWeapon(weapon);
|
||||
ui.weaponfrag.update();
|
||||
run.listen();
|
||||
Effects.sound("purchase");
|
||||
|
||||
if(Net.active() && Net.client()){
|
||||
Vars.netClient.handleUpgrade(weapon);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
content().add("$text.weapons");
|
||||
content().row();
|
||||
content().add(weptab);
|
||||
content().row();
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
@@ -241,7 +241,6 @@ public class BlocksFragment implements Fragment{
|
||||
}).expandX().padLeft(3).top().right().size(40f, 44f).padTop(-2);
|
||||
}
|
||||
|
||||
|
||||
desctable.add().pad(2);
|
||||
|
||||
Table requirements = new Table();
|
||||
@@ -252,12 +251,11 @@ public class BlocksFragment implements Fragment{
|
||||
desctable.left();
|
||||
|
||||
for(ItemStack stack : recipe.requirements){
|
||||
ItemStack fs = stack;
|
||||
requirements.addImage(Draw.region("icon-"+stack.item.name)).size(8*3);
|
||||
Label reqlabel = new Label("");
|
||||
|
||||
reqlabel.update(()->{
|
||||
int current = control.getAmount(fs.item);
|
||||
int current = control.getAmount(stack.item);
|
||||
String text = Mathf.clamp(current, 0, stack.amount) + "/" + stack.amount;
|
||||
|
||||
reqlabel.setColor(current < stack.amount ? Colors.get("missingitems") : Color.WHITE);
|
||||
@@ -271,8 +269,7 @@ public class BlocksFragment implements Fragment{
|
||||
|
||||
desctable.row();
|
||||
|
||||
Label label = new Label("[health]"+ Bundles.get("text.health")+": " + recipe.result.health + (recipe.result.description == null ?
|
||||
"" : ("\n[]" + recipe.result.description)));
|
||||
Label label = new Label("[health]"+ Bundles.get("text.health")+": " + recipe.result.health);
|
||||
label.setWrap(true);
|
||||
desctable.add(label).width(200).padTop(4).padBottom(2);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.resource.Weapon;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Inputs;
|
||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||
import io.anuke.ucore.scene.ui.ImageButton;
|
||||
import io.anuke.ucore.scene.ui.Tooltip;
|
||||
@@ -29,6 +30,7 @@ public class WeaponFragment implements Fragment{
|
||||
weapontable.clearChildren();
|
||||
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
group.setMaxCheckCount(2);
|
||||
|
||||
weapontable.defaults().size(58, 62);
|
||||
|
||||
@@ -39,12 +41,16 @@ public class WeaponFragment implements Fragment{
|
||||
group.add(button);
|
||||
|
||||
button.clicked(()->{
|
||||
if(weapon == player.weapon) return;
|
||||
player.weapon = weapon;
|
||||
//if(weapon == player.weapon) return;
|
||||
if(Inputs.keyDown("weapon_alt_select")){
|
||||
player.weaponRight = weapon;
|
||||
}else {
|
||||
player.weaponLeft = weapon;
|
||||
}
|
||||
button.setChecked(true);
|
||||
});
|
||||
|
||||
button.setChecked(weapon == player.weapon);
|
||||
button.update(() -> button.setChecked(weapon == player.weaponLeft || weapon == player.weaponRight)); //TODO
|
||||
|
||||
weapontable.add(button);
|
||||
|
||||
@@ -52,7 +58,7 @@ public class WeaponFragment implements Fragment{
|
||||
String description = weapon.description;
|
||||
|
||||
tiptable.background("button");
|
||||
tiptable.add("$weapon."+weapon.name+".name", 0.5f).left().padBottom(3f);
|
||||
tiptable.add(weapon.localized(), 0.5f).left().padBottom(3f);
|
||||
|
||||
tiptable.row();
|
||||
tiptable.row();
|
||||
|
||||
Reference in New Issue
Block a user