private void GetWeaponData() { ArrayList v = CurMech.GetLoadout().GetNonCore(); ArrayList<ifWeapon> wep = new ArrayList<ifWeapon>(); ArrayList<Ammunition> ammo = new ArrayList<Ammunition>(); ArrayList<WeaponInfo> temp = new ArrayList<WeaponInfo>(); int cols = 0; for (int i = 0; i < v.size(); i++) { if (v.get(i) instanceof ifWeapon) { ifWeapon w = (ifWeapon) v.get(i); // do we already have a weapon of this name in the ArrayList? boolean add = true; for (int x = 0; x < wep.size(); x++) { if (wep.get(x).LookupName().equals(w.LookupName())) { add = false; } } if (add) { wep.add(w); if (w.GetRangeLong() > cols) { cols = w.GetRangeLong(); } } } else if (v.get(i) instanceof Ammunition) { Ammunition a = (Ammunition) v.get(i); // do we already have an ammo of this name in the ArrayList? boolean add = true; for (int x = 0; x < ammo.size(); x++) { if (ammo.get(x).LookupName().equals(a.LookupName())) { add = false; } } if (add) { ammo.add(a); if (a.GetLongRange() > cols) { cols = a.GetLongRange(); } } } } // construct the data ArrayList for (int i = 0; i < wep.size(); i++) { ifWeapon w = wep.get(i); if (w.HasAmmo()) { boolean added = false; // search for other ammunition for this weapon. for (int x = ammo.size() - 1; x >= 0; x--) { Ammunition a = ammo.get(x); if (w.GetAmmoIndex() == a.GetAmmoIndex()) { temp.add(new WeaponInfo(w, a)); ammo.remove(a); added = true; } } if (!added) { // add the weapon in by itself temp.add(new WeaponInfo(w)); } } else { temp.add(new WeaponInfo(w)); } } // sort the weapon info by range SortWeapons(temp); // turn the temporary ArrayList into an array cols += 1; data = new String[temp.size() * 2][cols]; for (int i = 0; i < temp.size(); i++) { WeaponInfo w = temp.get(i); for (int x = 0; x < cols; x++) { if (x == 0) { data[i * 2][x] = w.GetName(); data[i * 2 + 1][x] = ""; } else { int tohit = w.GetToHit(x); if (CurMech.UsingTC()) { if (tohit != 12 && w.CanUseTC()) { tohit -= 1; } } if (tohit >= 0) { data[i * 2][x] = "+" + tohit; } else { data[i * 2][x] = "" + tohit; } data[i * 2 + 1][x] = "" + w.GetDamage(x); } } } }