Skip to content

Commit

Permalink
Various small improvements for unitviewDetail.lua (#6037)
Browse files Browse the repository at this point in the history
Co-authored-by: lL1l1 <82986251+lL1l1@users.noreply.github.com>
  • Loading branch information
Basilisk3 and lL1l1 committed Apr 1, 2024
1 parent 698651c commit 0f75715
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 9 deletions.
4 changes: 2 additions & 2 deletions changelog/3807.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

## Other Changes

<!-- Remove header when empty -->
- (#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:

<!-- Remove when empty -->
- Basilisk3

With thanks to the following people who contributed through binary patches:

Expand Down
1 change: 1 addition & 0 deletions loc/US/strings_db.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
29 changes: 22 additions & 7 deletions lua/ui/game/unitviewDetail.lua
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ GetAbilityDesc = {
if v.RemoveEnhancements or (not v.Slot) then continue end
cnt = cnt + 1
end
return cnt
return LOCF('<LOC uvd_0016>Enhancements: %d', cnt)
end,
ability_massive = function(bp)
return string.format(LOC('<LOC uvd_0010>Damage: %.7g, Splash: %.3g'),
Expand Down Expand Up @@ -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('<LOC uvd_DPS>', 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('<LOC uvd_0015>Damage: %.8g x%d, Splash: %.3g')..', '..LOC('<LOC uvd_Range>')..', '..LOC('<LOC uvd_Reload>'),
Damage, CycleProjs, info.DamageRadius, info.MinRadius, info.MaxRadius, CycleTime)
weaponDetails2 = string.format(LOC('<LOC uvd_0015>Damage: %.8g x%d, Splash: %.3g')..', '..LOC('<LOC uvd_Range>')..', '..LOC('<LOC uvd_Reload>'),
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('<LOC uvd_0010>Damage: %.7g, Splash: %.3g')..', '..LOC('<LOC uvd_Range>'),
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('<LOC uvd_0010>Damage: %.7g, Splash: %.3g'),
Damage, info.DamageRadius)
else
weaponDetails2 = string.format(LOC('<LOC uvd_0010>Damage: %.7g, Splash: %.3g')..', '..LOC('<LOC uvd_Range>')..', '..LOC('<LOC uvd_Reload>'),
Damage, info.DamageRadius, info.MinRadius, info.MaxRadius, CycleTime)
Damage, info.DamageRadius, info.MinRadius, info.MaxRadius, CycleTime)
end


Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions units/UAL0001/UAL0001_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,7 @@ UnitBlueprint{
DamageType = "Normal",
DisplayName = "Teleport in",
DummyWeapon = true,
EnabledByEnhancement = "Teleporter",
Label = "TeleportWeapon",
ManualFire = true,
MaxRadius = 1,
Expand Down
1 change: 1 addition & 0 deletions units/UAL0301/UAL0301_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ UnitBlueprint{
DamageType = "Normal",
DisplayName = "Teleport in",
DummyWeapon = true,
EnabledByEnhancement = "Teleporter",
Label = "TeleportWeapon",
ManualFire = true,
MaxRadius = 1,
Expand Down
1 change: 1 addition & 0 deletions units/UEL0001/UEL0001_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,7 @@ UnitBlueprint {
DamageType = "Normal",
DisplayName = "Teleport in",
DummyWeapon = true,
EnabledByEnhancement = "Teleporter",
Label = "TeleportWeapon",
ManualFire = true,
MaxRadius = 1,
Expand Down
1 change: 1 addition & 0 deletions units/XSL0001/XSL0001_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,7 @@ UnitBlueprint{
DamageType = "Normal",
DisplayName = "Teleport in",
DummyWeapon = true,
EnabledByEnhancement = "Teleporter",
Label = "TeleportWeapon",
ManualFire = true,
MaxRadius = 1,
Expand Down
1 change: 1 addition & 0 deletions units/XSL0301/XSL0301_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,7 @@ UnitBlueprint{
DamageType = "Normal",
DisplayName = "Teleport in",
DummyWeapon = true,
EnabledByEnhancement = "Teleporter",
Label = "TeleportWeapon",
ManualFire = true,
MaxRadius = 1,
Expand Down

0 comments on commit 0f75715

Please sign in to comment.