From 1555e77348939401fdc5030d1b89b20d30dbac01 Mon Sep 17 00:00:00 2001 From: Leonwang4234 <62972692+Leonwang4234@users.noreply.github.com> Date: Sat, 7 Nov 2020 17:21:03 -0800 Subject: [PATCH] Create WeaponListValue.java --- .../world/meta/values/WeaponListValue.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 core/src/mindustry/world/meta/values/WeaponListValue.java diff --git a/core/src/mindustry/world/meta/values/WeaponListValue.java b/core/src/mindustry/world/meta/values/WeaponListValue.java new file mode 100644 index 0000000000..118c494b5f --- /dev/null +++ b/core/src/mindustry/world/meta/values/WeaponListValue.java @@ -0,0 +1,65 @@ +package mindustry.world.meta.values; + +//TODO: remove unused imports +import arc.*; +import arc.graphics.*; +import arc.graphics.g2d.*; +import arc.math.*; +import arc.scene.ui.layout.*; +import arc.struct.*; +import arc.util.*; +import mindustry.content.*; +import mindustry.ctype.*; +import mindustry.entities.bullet.*; +import mindustry.gen.*; +import mindustry.ui.*; +import mindustry.type.*; +import mindustry.world.meta.*; + +import static mindustry.Vars.*; + +public class WeaponListValue implements StatValue{ + private final Seq weapons; + private final UnitType unit; + + public WeaponListValue(UnitType unit, Seq weapons){ + this.weapons = weapons; + this.unit = unit; + } + + @Override + public void display(Table table){ + table.row(); + for(Weapon weapon : weapons){ + if(weapon.flipSprite){ + continue; + } + + if(weapon.outlineRegion.found()){ + table.image(weapon.outlineRegion).size(10 * 8).right().top(); + }else{ + table.image(unit.icon(Cicon.full)).size(10 * 8).right().top(); + } + + table.table(Tex.underline, w -> { + w.left().defaults().padRight(3).left(); + + sep(w, "[lightgray]" + Stat.mirrored.localized() + ": [white]" + weapon.mirror); + sep(w, "[lightgray]" + Stat.inaccuracy.localized() + ": [white]" + (int)weapon.inaccuracy + " " + StatUnit.degrees.localized()); + sep(w, "[lightgray]" + Stat.reload.localized() + ": [white]" + Strings.autoFixed(60f / weapon.reload * weapon.shots, 1)); + sep(w, "[lightgray]" + Stat.targetsAir.localized() + ": [white]" + weapon.bullet.collidesAir); + sep(w, "[lightgray]" + Stat.targetsGround.localized() + ": [white]" + weapon.bullet.collidesGround); + sep(w, "[lightgray]" + Stat.bullet.localized() + ":"); + + AmmoListValue bullet = new AmmoListValue(OrderedMap.of(unit, weapon.bullet)); + bullet.display(w); + }).left().padTop(-9); + table.row(); + } + } + + void sep(Table table, String text){ + table.row(); + table.add(text); + } +}