From 0f757159a92a6ba7667a18ad2c6d9008a6dc937f Mon Sep 17 00:00:00 2001 From: Basilisk3 <126026384+Basilisk3@users.noreply.github.com> Date: Mon, 1 Apr 2024 22:07:00 +0200 Subject: [PATCH] Various small improvements for `unitviewDetail.lua` (#6037) Co-authored-by: lL1l1 <82986251+lL1l1@users.noreply.github.com> --- changelog/3807.md | 4 ++-- loc/US/strings_db.lua | 1 + lua/ui/game/unitviewDetail.lua | 29 ++++++++++++++++++++++------- units/UAL0001/UAL0001_unit.bp | 1 + units/UAL0301/UAL0301_unit.bp | 1 + units/UEL0001/UEL0001_unit.bp | 1 + units/XSL0001/XSL0001_unit.bp | 1 + units/XSL0301/XSL0301_unit.bp | 1 + 8 files changed, 30 insertions(+), 9 deletions(-) diff --git a/changelog/3807.md b/changelog/3807.md index e34dc8e756..c5b730a4b7 100644 --- a/changelog/3807.md +++ b/changelog/3807.md @@ -22,13 +22,13 @@ ## Other Changes - +- (#6037) Various smaller improvements to the additional unit details displayed when `Show Armament Detail in Build Menu` is enabled in the settings. ## Contributors With thanks to the following people who contributed through coding: - +- Basilisk3 With thanks to the following people who contributed through binary patches: diff --git a/loc/US/strings_db.lua b/loc/US/strings_db.lua index 73f570e0f0..38ed054268 100644 --- a/loc/US/strings_db.lua +++ b/loc/US/strings_db.lua @@ -6760,6 +6760,7 @@ uvd_0012="Speed: %0.1f, Reverse: %0.1f, Acceleration: %0.1f, Turning: %d" uvd_0013="Vision: %d, Underwater Vision: %d, Regen: %0.1f, Cap Cost: %0.1f" uvd_0014="Damage: %.8g - %.8g, Splash: %.3g - %.3g" uvd_0015="Damage: %.8g x%d, Splash: %.3g" +uvd_0016="Enhancements: %d" uvd_DPS="(DPS: %d)" uvd_ManualFire="(Manual Fire)" diff --git a/lua/ui/game/unitviewDetail.lua b/lua/ui/game/unitviewDetail.lua index c1a40b24d9..dc702b363b 100644 --- a/lua/ui/game/unitviewDetail.lua +++ b/lua/ui/game/unitviewDetail.lua @@ -399,7 +399,7 @@ GetAbilityDesc = { if v.RemoveEnhancements or (not v.Slot) then continue end cnt = cnt + 1 end - return cnt + return LOCF('Enhancements: %d', cnt) end, ability_massive = function(bp) return string.format(LOC('Damage: %.7g, Splash: %.3g'), @@ -632,24 +632,32 @@ function WrapAndPlaceText(bp, builder, descID, control) CycleTime = CycleTime + FiringCooldown end - if not info.ManualFire and info.WeaponCategory ~= 'Kamikaze' then + if not info.ManualFire and info.WeaponCategory ~= 'Kamikaze' and info.WeaponCategory ~= 'Defense' then --Round DPS, or else it gets floored in string.format. local DPS = MATH_IRound(Damage * CycleProjs / CycleTime) weaponDetails1 = weaponDetails1..LOCF('', DPS) end -- Avoid saying a unit fires a salvo when it in fact has a constant rate of fire - if singleShot and ReloadTime == 0 then + if singleShot and ReloadTime == 0 and CycleProjs > 1 then CycleTime = CycleTime / CycleProjs CycleProjs = 1 end if CycleProjs > 1 then - weaponDetails2 = string.format(LOC('Damage: %.8g x%d, Splash: %.3g')..', '..LOC('')..', '..LOC(''), - Damage, CycleProjs, info.DamageRadius, info.MinRadius, info.MaxRadius, CycleTime) + weaponDetails2 = string.format(LOC('Damage: %.8g x%d, Splash: %.3g')..', '..LOC('')..', '..LOC(''), + Damage, CycleProjs, info.DamageRadius, info.MinRadius, info.MaxRadius, CycleTime) + -- Do not display Reload stats for Kamikaze weapons + elseif info.WeaponCategory == 'Kamikaze' then + weaponDetails2 = string.format(LOC('Damage: %.7g, Splash: %.3g')..', '..LOC(''), + Damage, info.DamageRadius, info.MinRadius, info.MaxRadius) + -- Do not display 'Range' and Reload stats for 'Teleport in' weapons + elseif info.WeaponCategory == 'Teleport' then + weaponDetails2 = string.format(LOC('Damage: %.7g, Splash: %.3g'), + Damage, info.DamageRadius) else weaponDetails2 = string.format(LOC('Damage: %.7g, Splash: %.3g')..', '..LOC('')..', '..LOC(''), - Damage, info.DamageRadius, info.MinRadius, info.MaxRadius, CycleTime) + Damage, info.DamageRadius, info.MinRadius, info.MaxRadius, CycleTime) end @@ -658,7 +666,14 @@ function WrapAndPlaceText(bp, builder, descID, control) weaponDetails1 = weaponDetails1..' x'..weapon.count end table.insert(blocks, {color = UIUtil.fontColor, lines = {weaponDetails1}}) - table.insert(blocks, {color = 'FFFFB0B0', lines = {weaponDetails2}}) + + if info.DamageType == 'Overcharge' then + table.insert(blocks, {color = 'FF5AB34B', lines = {weaponDetails2}}) -- Same color as auto-overcharge highlight (autocast_green.dds) + elseif info.WeaponCategory == 'Kamikaze' then + table.insert(blocks, {color = 'FFFF2C2C', lines = {weaponDetails2}}) + else + table.insert(blocks, {color = 'FFFFB0B0', lines = {weaponDetails2}}) + end if info.EnergyRequired > 0 and info.EnergyDrainPerSecond > 0 then local weaponDetails3 = string.format('Charge Cost: -%d E (-%d E/s)', info.EnergyRequired, info.EnergyDrainPerSecond) diff --git a/units/UAL0001/UAL0001_unit.bp b/units/UAL0001/UAL0001_unit.bp index e3aeb814b5..97c6bfb234 100644 --- a/units/UAL0001/UAL0001_unit.bp +++ b/units/UAL0001/UAL0001_unit.bp @@ -1065,6 +1065,7 @@ UnitBlueprint{ DamageType = "Normal", DisplayName = "Teleport in", DummyWeapon = true, + EnabledByEnhancement = "Teleporter", Label = "TeleportWeapon", ManualFire = true, MaxRadius = 1, diff --git a/units/UAL0301/UAL0301_unit.bp b/units/UAL0301/UAL0301_unit.bp index 8f518cc9d1..95254089fc 100644 --- a/units/UAL0301/UAL0301_unit.bp +++ b/units/UAL0301/UAL0301_unit.bp @@ -698,6 +698,7 @@ UnitBlueprint{ DamageType = "Normal", DisplayName = "Teleport in", DummyWeapon = true, + EnabledByEnhancement = "Teleporter", Label = "TeleportWeapon", ManualFire = true, MaxRadius = 1, diff --git a/units/UEL0001/UEL0001_unit.bp b/units/UEL0001/UEL0001_unit.bp index 44239ef63e..4b2ed10f2e 100644 --- a/units/UEL0001/UEL0001_unit.bp +++ b/units/UEL0001/UEL0001_unit.bp @@ -1129,6 +1129,7 @@ UnitBlueprint { DamageType = "Normal", DisplayName = "Teleport in", DummyWeapon = true, + EnabledByEnhancement = "Teleporter", Label = "TeleportWeapon", ManualFire = true, MaxRadius = 1, diff --git a/units/XSL0001/XSL0001_unit.bp b/units/XSL0001/XSL0001_unit.bp index bed56ba4e3..e15cd1c644 100644 --- a/units/XSL0001/XSL0001_unit.bp +++ b/units/XSL0001/XSL0001_unit.bp @@ -1053,6 +1053,7 @@ UnitBlueprint{ DamageType = "Normal", DisplayName = "Teleport in", DummyWeapon = true, + EnabledByEnhancement = "Teleporter", Label = "TeleportWeapon", ManualFire = true, MaxRadius = 1, diff --git a/units/XSL0301/XSL0301_unit.bp b/units/XSL0301/XSL0301_unit.bp index 6637c316c3..110ddb5096 100644 --- a/units/XSL0301/XSL0301_unit.bp +++ b/units/XSL0301/XSL0301_unit.bp @@ -903,6 +903,7 @@ UnitBlueprint{ DamageType = "Normal", DisplayName = "Teleport in", DummyWeapon = true, + EnabledByEnhancement = "Teleporter", Label = "TeleportWeapon", ManualFire = true, MaxRadius = 1,