From 4d3c6879b53b1cb90dfabfc012ed65ff4cc89187 Mon Sep 17 00:00:00 2001 From: Leonwang4234 <62972692+Leonwang4234@users.noreply.github.com> Date: Wed, 11 Nov 2020 13:27:03 -0800 Subject: [PATCH] Fix many things --- core/assets/bundles/bundle.properties | 1 - core/src/mindustry/world/meta/Stat.java | 1 - .../world/meta/values/AmmoListValue.java | 14 ++++++-- .../world/meta/values/WeaponListValue.java | 12 ++++--- tools/src/mindustry/tools/Generators.java | 32 ------------------- 5 files changed, 18 insertions(+), 42 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 96b3052e8b..98b25cfdee 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -629,7 +629,6 @@ stat.basepowergeneration = Base Power Generation stat.productiontime = Production Time stat.repairtime = Block Full Repair Time stat.weapons = Weapons -stat.mirrored = Mirrored stat.bullet = Bullet stat.speedincrease = Speed Increase stat.range = Range diff --git a/core/src/mindustry/world/meta/Stat.java b/core/src/mindustry/world/meta/Stat.java index a49b35ea28..8f1d23820b 100644 --- a/core/src/mindustry/world/meta/Stat.java +++ b/core/src/mindustry/world/meta/Stat.java @@ -56,7 +56,6 @@ public enum Stat{ instructions(StatCat.crafting), weapons(StatCat.function), - mirrored(StatCat.function), bullet(StatCat.function), speedIncrease(StatCat.function), diff --git a/core/src/mindustry/world/meta/values/AmmoListValue.java b/core/src/mindustry/world/meta/values/AmmoListValue.java index a0635e7650..2d3688cc72 100644 --- a/core/src/mindustry/world/meta/values/AmmoListValue.java +++ b/core/src/mindustry/world/meta/values/AmmoListValue.java @@ -1,6 +1,7 @@ package mindustry.world.meta.values; import arc.*; +import arc.func.*; import arc.graphics.g2d.*; import arc.math.*; import arc.scene.ui.layout.*; @@ -29,11 +30,12 @@ public class AmmoListValue implements StatValue{ table.row(); for(T t : map.keys()){ BulletType type = map.get(t); + //no point in displaying unit icon twice if(!(t instanceof UnitType)){ table.image(icon(t)).size(3 * 8).padRight(4).right().top(); table.add(t.localizedName).padRight(10).left().top(); } - table.table(Tex.underline, bt -> { + Cons tableCons = bt -> { bt.left().defaults().padRight(3).left(); if(type.damage > 0 && (type.collides || type.splashDamage <= 0)){ @@ -44,7 +46,8 @@ public class AmmoListValue implements StatValue{ sep(bt, Core.bundle.format("bullet.splashdamage", (int)type.splashDamage, Strings.fixed(type.splashDamageRadius / tilesize, 1))); } - if(!Mathf.equal(type.ammoMultiplier, 1f)) + //ammo multiplyers do not make sense for units + if(!(t instanceof UnitType) && !Mathf.equal(type.ammoMultiplier, 1f)) sep(bt, Core.bundle.format("bullet.multiplier", (int)type.ammoMultiplier)); if(!Mathf.equal(type.reloadMultiplier, 1f)) sep(bt, Core.bundle.format("bullet.reload", Strings.fixed(type.reloadMultiplier, 1))); @@ -89,7 +92,12 @@ public class AmmoListValue implements StatValue{ if(type.fragBullet != null){ sep(bt, "@bullet.frag"); } - }).left().padTop(-9); + }; + if(t instanceof UnitType){ + table.table(tableCons); + }else{ + table.table(Tex.underline, tableCons).left().padTop(-9); + } table.row(); } } diff --git a/core/src/mindustry/world/meta/values/WeaponListValue.java b/core/src/mindustry/world/meta/values/WeaponListValue.java index 60411447b0..9317a69fab 100644 --- a/core/src/mindustry/world/meta/values/WeaponListValue.java +++ b/core/src/mindustry/world/meta/values/WeaponListValue.java @@ -6,6 +6,7 @@ import arc.scene.ui.layout.*; import arc.struct.*; import mindustry.gen.*; import mindustry.type.*; +import mindustry.ui.*; import mindustry.world.meta.*; import static mindustry.Vars.*; @@ -30,15 +31,16 @@ public class WeaponListValue implements StatValue{ continue; } - table.image(Core.atlas.find(unit.name + "-weapon" + i)).size(15 * 8).right().top(); + 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.reload.localized() + ": " + (weapon.mirror ? "2x " : "") + "[white]" + Strings.autoFixed(60f / weapon.reload * weapon.shots, 1)); sep(w, "[lightgray]" + Stat.bullet.localized() + ":"); AmmoListValue bullet = new AmmoListValue(OrderedMap.of(unit, weapon.bullet)); diff --git a/tools/src/mindustry/tools/Generators.java b/tools/src/mindustry/tools/Generators.java index b4ee8a340b..1350a0ff24 100644 --- a/tools/src/mindustry/tools/Generators.java +++ b/tools/src/mindustry/tools/Generators.java @@ -504,38 +504,6 @@ public class Generators{ scaled.save(type.name + "-icon-logic"); } } - - //generate weapon stat UI - - //largest side calculated here to prevent sprite squishing - int largestSide = Math.max(image.width, image.height); - Image base = new Image(largestSide, largestSide); - - image.each((x, y) -> { - int newX = x - image.width/2 + base.width/2; - int newY = y - image.height/2 + base.height/2; - Color c = image.getColor(x, y); - base.draw(newX, newY, c.set(c.r, c.g, c.b, c.a * 0.2f)); - }); - - for(int i = 0;i < type.weapons.size;i ++){ - Weapon weapon = type.weapons.get(i); - - if(weapon.flipSprite){ - //fliped weapons are not given stats - continue; - } - - weapon.load(); - Image baseWithWeapon = base.copy(); - - baseWithWeapon.draw(outline.get(ImagePacker.get(weapon.region)), - (int)(weapon.x / Draw.scl + base.width / 2f - weapon.region.width / 2f), - (int)(-weapon.y / Draw.scl + base.height / 2f - weapon.region.height / 2f), - weapon.flipSprite, false); - - baseWithWeapon.save(type.name + "-weapon" + i); - } }catch(IllegalArgumentException e){ Log.err("WARNING: Skipping unit @: @", type.name, e.getMessage()); }