Untitled diff

Created Diff never expires
package.path = package.path .. ";data/scripts/lib/?.lua"
package.path = package.path .. ";data/scripts/lib/?.lua"
package.path = package.path .. ";data/scripts/?.lua"
package.path = package.path .. ";data/scripts/?.lua"


require ("utility")
require ("utility")
require ("stringutility")
require ("stringutility")


local lyr_debug = false

local iconColor = ColorRGB(0.5, 0.5, 0.5)
local iconColor = ColorRGB(0.5, 0.5, 0.5)


local headLineSize = 25
local headLineSize = 22
local headLineFont = 15
local headLineFont = 16


local function fillWeaponTooltipData(obj, tooltip)
local function fillWeaponTooltipData(obj, tooltip)
local lyr = {}
lyr.generatesHeat = obj.maxHeat == 10
lyr.usesPower = obj.coolingType == 2
lyr.drainsEnergy = obj.coolingType == 1
lyr.burstFire = obj.shootingTime < 2
lyr.isBeam = obj.continuousBeam
lyr.isProjectile = not lyr.isBeam
lyr.activeWeapons = obj.simultaneousShooting and obj.numWeapons > 1 and obj.numWeapons or 1
lyr.projectilePerTurret = lyr.activeWeapons * obj.shotsPerFiring
lyr.damage = lyr.projectilePerTurret * obj.damage --lyr.damagePerShot
lyr.adjustedFireRate = obj.fireRate
if lyr.usesPower or lyr.drainsEnergy then
lyr.heatPerShot = lyr.activeWeapons * obj.heatPerShot
lyr.energyIncreasePerSecond = lyr.activeWeapons*obj.energyIncreasePerSecond
elseif lyr.generatesHeat then
lyr.coolingRate = obj.coolingRate
lyr.coolingPerShot = lyr.coolingRate/obj.fireRate
lyr.heatPerShot = lyr.activeWeapons * obj.heatPerShot
lyr.accumulatedHeat = lyr.heatPerShot
--lyr.timeToCooldown
lyr.timeToOverheat = 0
lyr.shotsToOverheat = 1
lyr.timePerShot = 1/ obj.fireRate
lyr.uptimeRatio = 1
lyr.adjustedHeatPerShot = lyr.heatPerShot - lyr.coolingPerShot
lyr.adjustedMaxHeat = obj.maxHeat - lyr.heatPerShot
lyr.neverOverheats = false
lyr.instantlyOverheats = false
--lyr.coolingEfficiency
if lyr.heatPerShot >= obj.maxHeat then
lyr.instantlyOverheats = true
elseif lyr.coolingPerShot >= lyr.heatPerShot then
lyr.neverOverheats = true
else
lyr.shotsToOverheat = math.ceil( lyr.adjustedMaxHeat / lyr.adjustedHeatPerShot ) +1
lyr.accumulatedHeat = lyr.accumulatedHeat + ( lyr.shotsToOverheat -1) * lyr.adjustedHeatPerShot
lyr.timeToOverheat = lyr.timeToOverheat + ( lyr.shotsToOverheat -1) * lyr.timePerShot
end
lyr.timeToCooldown = lyr.accumulatedHeat / lyr.coolingRate
lyr.cycle = lyr.timeToCooldown + lyr.timeToOverheat
if lyr.instantlyOverheats then
if lyr.timePerShot <= lyr.timeToCooldown then
lyr.adjustedFireRate = 1/ lyr.timeToCooldown
end
elseif not lyr.neverOverheats then
lyr.uptimeRatio = lyr.timeToOverheat / (lyr.cycle)
end
--lyr.coolingEfficiency = lyr.adjustedFireRate / obj.fireRate *100
lyr.coolingEfficiency = lyr.coolingPerShot / (lyr.heatPerShot*lyr.adjustedFireRate)
lyr.damagePerCycle = lyr.shotsToOverheat * lyr.damage
lyr.dps = lyr.damagePerCycle / lyr.cycle
end
-- rarity name
local line = TooltipLine(5, 12)
line.ltext = "Tech: "..round(obj.averageTech, 1) --lyr_nt
line.ctext = tostring(obj.rarity)
line.rtext = obj.material.name
line.rcolor = obj.material.color
line.ccolor = obj.rarity.color
tooltip:addLine(line)


-- rarity name
-- primary stats, one by one
local line = TooltipLine(5, 12)
local fontSize = 14
line.ctext = tostring(obj.rarity)
local lineHeight = 20
line.ccolor = obj.rarity.color
tooltip:addLine(line)
tooltip:addLine(TooltipLine(25,15))
if lyr.isBeam then --beam weapons: teslaGun, repairBeam, laser, forceGun, salvagingLaser, miningLaser
if obj.stoneEfficiency > 0 or obj.metalEfficiency > 0 then
if obj.stoneEfficiency > 0 and obj.metalEfficiency > 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Mining & Salvaging" --lyr_nt
line.rtext = round(obj.dps, 1).."/s"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 1
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Efficiencies" --lyr_nt
line.rtext = round(obj.stoneEfficiency * 100, 1).."% & "..round(obj.metalEfficiency * 100, 1).."%"
line.icon = "data/textures/icons/recycle.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
elseif obj.stoneEfficiency > 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Mining" --lyr_nt
line.rtext = round(obj.dps, 1).."/s"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 1
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Efficiency" --lyr_nt
line.rtext = round(obj.stoneEfficiency * 100, 1).."%"
line.icon = "data/textures/icons/recycle.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
else --if obj.metalEfficiency > 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Salvaging" --lyr_nt
line.rtext = round(obj.dps, 1).."/s"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 1
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Efficiency" --lyr_nt
line.rtext = round(obj.metalEfficiency * 100, 1).."%"
line.icon = "data/textures/icons/recycle.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
end
elseif obj.otherForce ~= 0 or obj.selfForce ~= 0 then
-- if obj.otherForce == 0 or obj.selfForce == 0 then
-- tooltip:addLine(TooltipLine(lineHeight, fontSize)) --line 1
-- end
if obj.otherForce > 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Push"%_t
line.rtext = toReadableValue(obj.otherForce, "N /* unit: Newton*/"%_t)
line.icon = "data/textures/icons/back-forth.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 1 or 2
elseif obj.otherForce < 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Pull"%_t
line.rtext = toReadableValue(-obj.otherForce, "N /* unit: Newton*/"%_t)
line.icon = "data/textures/icons/back-forth.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 1 or 2
end
if obj.selfForce > 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Self Push"%_t
line.rtext = toReadableValue(obj.selfForce, "N /* unit: Newton*/"%_t)
line.icon = "data/textures/icons/back-forth.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
elseif obj.selfForce < 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Self Pull"%_t
line.rtext = toReadableValue(-obj.selfForce, "N /* unit: Newton*/"%_t)
line.icon = "data/textures/icons/back-forth.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
end
elseif obj.hullRepairRate > 0 or obj.shieldRepairRate > 0 then
-- if obj.hullRepairRate == 0 or obj.shieldRepairRate == 0 then
-- tooltip:addLine(TooltipLine(lineHeight, fontSize)) --line 1
-- end
if obj.hullRepairRate > 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Hull Repair" --lyr_nt
line.rtext = round(obj.hullRepairRate, 1).."/s"
line.icon = "data/textures/icons/health-normal.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 1 or 2
end
if obj.shieldRepairRate > 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Shield Charge" --lyr_nt
line.rtext = round(obj.shieldRepairRate, 1).."/s"
line.icon = "data/textures/icons/health-normal.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
end
else --if obj.damage > 0
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Continuous Damage" --lyr_nt
line.rtext = round(obj.dps, 1).."/s"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 1
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Tick Damage" --lyr_nt
line.rtext = round(obj.damage, 1).."/tick"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
end
else --projectile weapons: railGun, lightningGun, rocketLauncher, cannon, plasmaGun, bolter, chainGun
if lyr.generatesHeat and not lyr.neverOverheats then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Weighted Damage" --lyr_nt
line.rtext = round(lyr.dps, 1).."/s"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 1
if lyr.burstFire then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Burst Damage" --lyr_nt
line.rtext = round(lyr.damagePerCycle, 1).."/burst"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
else
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Projectile Damage" --lyr_nt
line.rtext = lyr.projectilePerTurret > 1 and lyr.projectilePerTurret.."x"..round(obj.damage, 1).."/shot" or round(obj.damage, 1).."/shot"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
end
else
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Sustained Damage" --lyr_nt
line.rtext = round(obj.dps, 1).."/s"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 1
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Projectile Damage" --lyr_nt
line.rtext = lyr.projectilePerTurret > 1 and lyr.projectilePerTurret.."x"..round(obj.damage, 1).."/shot" or round(obj.damage, 1).."/shot"
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line) --line 2
end
end


-- primary stats, one by one
-- fire rate
local fontSize = 14
if lyr.burstFire then
local lineHeight = 20
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Burst Rate" --lyr_nt
line.rtext = round(lyr.cycle, 1).."s/burst"
line.icon = "data/textures/icons/bullets.png";
line.iconColor = iconColor
tooltip:addLine(line)
else
local line = TooltipLine(lineHeight, fontSize)
line.ltext = lyr.isBeam and "Tick Rate" or "Fire Rate" --lyr_nt
line.rtext = round(lyr.adjustedFireRate, 1).."/s"
line.icon = "data/textures/icons/bullets.png";
line.iconColor = iconColor
tooltip:addLine(line)
end


local line = TooltipLine(lineHeight, fontSize)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Tech"%_t
line.ltext = "Accuracy"%_t
line.rtext = round(obj.averageTech, 1)
line.rtext = (lyr.isBeam or obj.accuracy == 1) and "Absolute" or round(obj.accuracy * 100, 1).."%"
line.icon = "data/textures/icons/circuitry.png";
line.icon = "data/textures/icons/reticule.png";
line.iconColor = iconColor
line.iconColor = iconColor
tooltip:addLine(line)
tooltip:addLine(line)


-- empty line
local line = TooltipLine(lineHeight, fontSize)
tooltip:addLine(TooltipLine(15, 15))
line.ltext = "Velocity" --lyr_nt
line.rtext = (lyr.isBeam or obj.shotSpeed > obj.reach*60) and "Instant" or round(obj.shotSpeed*10, 0).."m/s"
line.icon = "data/textures/icons/blaster.png";
line.iconColor = iconColor
tooltip:addLine(line)


if obj.damage > 0 then
local line = TooltipLine(lineHeight, fontSize)
if obj.continuousBeam then
line.ltext = "Range"%_t
line.rtext = round(obj.reach*10/1000, 2).."km"
line.icon = "data/textures/icons/target-shot.png";
line.iconColor = iconColor
tooltip:addLine(line)


local line = TooltipLine(lineHeight, fontSize)
-- empty line
line.ltext = "Damage /s"%_t
tooltip:addLine(TooltipLine(15, 15))
line.rtext = round(obj.dps, 1)
line.icon = "data/textures/icons/screen-impact.png";
if lyr.usesPower then
line.iconColor = iconColor
local line = TooltipLine(lineHeight, fontSize)
tooltip:addLine(line)
line.ltext = "Power Demand" --lyr_nt
line.rtext = round(lyr.heatPerShot+lyr.energyIncreasePerSecond, 1).."MW/s"
line.icon = "data/textures/icons/electric.png";
line.iconColor = iconColor
tooltip:addLine(line)


else
local line = TooltipLine(lineHeight, fontSize)
-- damage
line.ltext = "Accumulation" --lyr_nt
local line = TooltipLine(lineHeight, fontSize)
line.rtext = "+"..round(lyr.energyIncreasePerSecond, 0).."MW/s"
line.ltext = "Damage"%_t
line.icon = "data/textures/icons/electric.png";
line.rtext = round(obj.damage, 1)
line.iconColor = iconColor
if obj.shotsPerFiring > 1 then
tooltip:addLine(line)
line.rtext = line.rtext .. " x" .. obj.shotsPerFiring
end
line.icon = "data/textures/icons/screen-impact.png";
line.iconColor = iconColor
tooltip:addLine(line)


-- fire rate
local line = TooltipLine(lineHeight, fontSize)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Dispersion" --lyr_nt
line.ltext = "Fire Rate"%_t
line.rtext = "-"..round(obj.coolingRate, 0).."MW/s"
line.rtext = round(obj.fireRate, 1)
line.icon = "data/textures/icons/electric.png";
line.icon = "data/textures/icons/bullets.png";
line.iconColor = iconColor
line.iconColor = iconColor
tooltip:addLine(line)
tooltip:addLine(line)
end
end


if obj.otherForce > 0 then
local line = TooltipLine(lineHeight, fontSize)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Demand Ratio" --lyr_nt
line.ltext = "Push"%_t
line.rtext = round(obj.coolingRate/lyr.energyIncreasePerSecond).."x"
line.rtext = toReadableValue(obj.otherForce, "N /* unit: Newton*/"%_t)
line.icon = "data/textures/icons/electric.png";
line.icon = "data/textures/icons/back-forth.png";
line.iconColor = iconColor
line.iconColor = iconColor
tooltip:addLine(line)
tooltip:addLine(line)
elseif obj.otherForce < 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Pull"%_t
line.rtext = toReadableValue(-obj.otherForce, "N /* unit: Newton*/"%_t)
line.icon = "data/textures/icons/back-forth.png";
line.iconColor = iconColor
tooltip:addLine(line)
end


if obj.selfForce > 0 then
-- empty line
local line = TooltipLine(lineHeight, fontSize)
tooltip:addLine(TooltipLine(15, 15))
line.ltext = "Self Push"%_t
elseif lyr.drainsEnergy then
line.rtext = toReadableValue(obj.selfForce, "N /* unit: Newton*/"%_t)
local line = TooltipLine(lineHeight, fontSize)
line.icon = "data/textures/icons/back-forth.png";
line.ltext = "Energy Drain" --lyr_nt
line.iconColor = iconColor
line.rtext = round(lyr.heatPerShot+lyr.energyIncreasePerSecond, 1).."MJ/shot"
tooltip:addLine(line)
line.icon = "data/textures/icons/battery-pack-alt.png";
elseif obj.selfForce < 0 then
line.iconColor = iconColor
local line = TooltipLine(lineHeight, fontSize)
tooltip:addLine(line)
line.ltext = "Self Pull"%_t
line.rtext = toReadableValue(-obj.selfForce, "N /* unit: Newton*/"%_t)
line.icon = "data/textures/icons/back-forth.png";
line.iconColor = iconColor
tooltip:addLine(line)
end


if obj.stoneEfficiency > 0 and obj.metalEfficiency > 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Accumulation" --lyr_nt
line.rtext = "+"..round(lyr.energyIncreasePerSecond*lyr.adjustedFireRate, 0).."MJ/s"
line.icon = "data/textures/icons/battery-pack-alt.png";
line.iconColor = iconColor
tooltip:addLine(line)


local line = TooltipLine(lineHeight, fontSize)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Eff. Stone"%_t
line.ltext = "Dispersion" --lyr_nt
line.rtext = round(obj.stoneEfficiency * 100, 1)
line.rtext = "-"..round(obj.coolingRate, 0).."MJ/s"
line.icon = "data/textures/icons/recycle.png";
line.icon = "data/textures/icons/battery-pack-alt.png";
line.iconColor = iconColor
line.iconColor = iconColor
tooltip:addLine(line)
tooltip:addLine(line)


local line = TooltipLine(lineHeight, fontSize)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Eff. Metal"%_t
line.ltext = "Drain Ratio" --lyr_nt
line.rtext = round(obj.metalEfficiency * 100, 1)
line.rtext = round((obj.coolingRate/lyr.energyIncreasePerSecond)/lyr.adjustedFireRate).."x"
line.icon = "data/textures/icons/recycle.png";
line.icon = "data/textures/icons/battery-pack-alt.png";
line.iconColor = iconColor
line.iconColor = iconColor
tooltip:addLine(line)
tooltip:addLine(line)


elseif obj.stoneEfficiency > 0 then
-- empty line
local line = TooltipLine(lineHeight, fontSize)
tooltip:addLine(TooltipLine(15, 15))
line.ltext = "Efficiency"%_t
elseif lyr.generatesHeat and not lyr.neverOverheats then
line.rtext = round(obj.stoneEfficiency * 100, 1)
local line = TooltipLine(lineHeight, fontSize)
line.icon = "data/textures/icons/recycle.png";
line.ltext = "Heat Generation" --lyr_nt
line.iconColor = iconColor
line.rtext = "+"..round(lyr.heatPerShot*10, 0).."%/shot"
tooltip:addLine(line)
line.icon = "data/textures/icons/flame.png";
elseif obj.metalEfficiency > 0 then
line.iconColor = iconColor
local line = TooltipLine(lineHeight, fontSize)
tooltip:addLine(line)
line.ltext = "Efficiency"%_t
line.rtext = round(obj.metalEfficiency * 100, 1)
local line = TooltipLine(lineHeight, fontSize)
line.icon = "data/textures/icons/recycle.png";
line.ltext = "Overheat Time" --lyr_nt
line.iconColor = iconColor
line.rtext = round(lyr.timeToOverheat, 1).."s"
tooltip:addLine(line)
line.icon = "data/textures/icons/flame.png";
end
line.iconColor = iconColor

tooltip:addLine(line)
if obj.hullRepairRate > 0 then
local line = TooltipLine(lineHeight, fontSize)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Hull Dmg /s"%_t
line.ltext = "Heat Dissipation" --lyr_nt
line.rtext = round(obj.hullRepairRate, 1)
line.rtext = "-"..round(obj.coolingRate*10, 0).."%/s"
line.icon = "data/textures/icons/health-normal.png";
line.icon = "data/textures/icons/flame.png";
line.iconColor = iconColor
line.iconColor = iconColor
tooltip:addLine(line)
tooltip:addLine(line)
end

local line = TooltipLine(lineHeight, fontSize)
if obj.shieldRepairRate > 0 then
line.ltext = "Cooldown Time" --lyr_nt
local line = TooltipLine(lineHeight, fontSize)
line.rtext = round(lyr.timeToCooldown, 1).."s"
line.ltext = "Shield Dmg /s"%_t
line.icon = "data/textures/icons/flame.png";
line.rtext = round(obj.shieldRepairRate, 1)
line.iconColor = iconColor
line.icon = "data/textures/icons/health-normal.png";
tooltip:addLine(line)
line.iconColor = iconColor
tooltip:addLine(line)
-- empty line
end
tooltip:addLine(TooltipLine(15, 15))

end
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Accuracy"%_t
--lyr_test
line.rtext = round(obj.accuracy * 100, 1)
if lyr_debug then
line.icon = "data/textures/icons/reticule.png";
local line = TooltipLine(lineHeight, fontSize)
line.iconColor = iconColor
line.ltext = "drainTest"
tooltip:addLine(line)
line.rtext = obj.baseEnergyPerSecond/obj.shotsPerSecond+obj.energyIncreasePerSecond

tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Range"%_t
local line = TooltipLine(lineHeight, fontSize)
line.rtext = round(obj.reach * 10 / 1000, 2)
line.ltext = "numWeapons"
line.icon = "data/textures/icons/target-shot.png";
line.rtext = obj.numWeapons and round(obj.numWeapons, 3) or "-"
line.iconColor = iconColor
tooltip:addLine(line)
tooltip:addLine(line)

local line = TooltipLine(lineHeight, fontSize)
-- empty line
line.ltext = "numVisibleWeapons"
tooltip:addLine(TooltipLine(15, 15))
line.rtext = obj.numVisibleWeapons and round(obj.numVisibleWeapons, 3) or "-"

tooltip:addLine(line)
if obj.coolingType == 1 or obj.coolingType == 2 then

local line = TooltipLine(lineHeight, fontSize)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "coolingType"

line.rtext = obj.coolingType and round(obj.coolingType, 3) or "-"
if obj.coolingType == 2 then
tooltip:addLine(line)
line.ltext = "Energy /s"%_t
else
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Energy /shot"%_t
line.ltext = "coolingTime"
end
line.rtext = obj.coolingTime and round(obj.coolingTime, 3) or "-"
line.rtext = round(obj.baseEnergyPerSecond)
tooltip:addLine(line)
line.icon = "data/textures/icons/electric.png";
line.iconColor = iconColor
local line = TooltipLine(lineHeight, fontSize)
tooltip:addLine(line)
line.ltext = "shootingTime"

line.rtext = obj.shootingTime and round(obj.shootingTime, 3) or "-"
local line = TooltipLine(lineHeight, fontSize)
tooltip:addLine(line)
line.ltext = "Energy Increase /s"%_t
line.rtext = round(obj.energyIncreasePerSecond, 1)
local line = TooltipLine(lineHeight, fontSize)
line.icon = "data/textures/icons/electric.png";
line.ltext = "heatPerShot"
line.iconColor = iconColor
line.rtext = obj.heatPerShot and round(obj.heatPerShot, 3) or "-"
tooltip:addLine(line)
tooltip:addLine(line)

-- empty line
local line = TooltipLine(lineHeight, fontSize)
tooltip:addLine(TooltipLine(15, 15))
line.ltext = "dps"
end
line.rtext = obj.dps and round(obj.dps, 3) or "-"

tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Material"%_t
local line = TooltipLine(lineHeight, fontSize)
line.rtext = obj.material.name
line.ltext = "damage"
line.rcolor = obj.material.color
line.rtext = obj.damage and round(obj.damage, 3) or "-"
line.icon = "data/textures/icons/metal-bar.png";
tooltip:addLine(line)
line.iconColor = iconColor
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)

line.ltext = "heat"
line.rtext = obj.heat and round(obj.heat, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "requiredShootingEnergy"
line.rtext = obj.requiredShootingEnergy and round(obj.requiredShootingEnergy, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "fireRate"
line.rtext = obj.fireRate and round(obj.fireRate, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "maxHeat"
line.rtext = obj.maxHeat and round(obj.maxHeat, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "coolingRate"
line.rtext = obj.coolingRate and round(obj.coolingRate, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "baseEnergyPerSecond"
line.rtext = obj.baseEnergyPerSecond and round(obj.baseEnergyPerSecond, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "energyIncreasePerSecond"
line.rtext = obj.energyIncreasePerSecond and round(obj.energyIncreasePerSecond, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "firingsPerSecond"
line.rtext = obj.firingsPerSecond and round(obj.firingsPerSecond, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "shotsPerSecond"
line.rtext = obj.shotsPerSecond and round(obj.shotsPerSecond, 3) or "-"
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "shotsPerFiring"
line.rtext = obj.shotsPerFiring and round(obj.shotsPerFiring, 3) or "-"
tooltip:addLine(line)
tooltip:addLine(TooltipLine(15, 15))
end
--lyr_test
end
end


local function fillDescriptions(obj, tooltip, additional)
local function fillDescriptions(obj, tooltip)

local ignoreList = {["Burst Fire"] = true, ["Consumes Energy"] = true, ["Overheats"] = true}
-- now count the lines, as there will have to be lines inserted
--local ignoreList = {}
-- to make sure that the icon of the weapon won't overlap with the stats
local extraLines = 0
-- now count the lines, as there will have to be lines inserted
local fontSize = 14
-- to make sure that the icon of the weapon won't overlap with the stats
local lineHeight = 18
local extraLines = 1
additional = additional or {}
local fontSize = 12

local lineHeight = 15
-- one line for flavor text
local line = TooltipLine(lineHeight, fontSize)
line.ltext = obj.flavorText
line.lcolor = ColorRGB(1.0, 0.7, 0.7)
tooltip:addLine(line)

extraLines = extraLines + 1

local descriptions = obj:getDescriptions()

for desc, value in pairs(descriptions) do
local line = TooltipLine(lineHeight, fontSize)

if value == "" then
line.ltext = desc % _t
else
line.ltext = string.format(desc % _t, value)
end

local existsAlready
for _, desc in pairs(additional) do
if desc == line.ltext then
existsAlready = true
end
end


if not existsAlready then
-- one line for flavor text
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
extraLines = extraLines + 1
line.ltext = obj.flavorText
end
line.lcolor = ColorRGB(1.0, 0.7, 0.7)
end
tooltip:addLine(line)


if obj.seeker then
local descriptions = obj:getDescriptions()
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Seeker Missiles"%_t
tooltip:addLine(line)
extraLines = extraLines + 1
end


for _, text in pairs(additional) do
for desc, value in pairs(descriptions) do
local line = TooltipLine(lineHeight, fontSize)
if not ignoreList[desc] then
line.ltext = text
extraLines = extraLines + 1
tooltip:addLine(line)
end
extraLines = extraLines + 1
end
end


for i = 1, 3 - extraLines do
for i = 1, 3 - extraLines do
-- empty line
-- empty line
tooltip:addLine(TooltipLine(15, 15))
tooltip:addLine(TooltipLine(lineHeight, fontSize))
end
end


for desc, value in pairs(descriptions) do
if not ignoreList[desc] then
local line = TooltipLine(lineHeight, fontSize)
if value == "" then
line.ltext = desc % _t
else
line.ltext = string.format(desc % _t, value)
end
tooltip:addLine(line)
end
end
end
end


function makeTurretTooltip(turret)
function makeTurretTooltip(turret)
local tooltip = Tooltip()
local tooltip = Tooltip()
local description = {}


-- create tool tip
-- create tool tip
tooltip.icon = turret.weaponIcon
tooltip.icon = turret.weaponIcon


-- build title
-- build title
local title = ""
local title = ""


local weapon = turret.weaponPrefix .. " /* Weapon Prefix*/"
local weapon = turret.weaponPrefix .. " /* Weapon Prefix*/"
weapon = weapon % _t
weapon = weapon % _t


local tbl = {material = turret.material.name, weaponPrefix = weapon}
local tbl = {material = turret.material.name, weaponPrefix = weapon}


if turret.stoneEfficiency > 0 or turret.metalEfficiency > 0 then
if turret.stoneEfficiency > 0 or turret.metalEfficiency > 0 then
if turret.numVisibleWeapons == 1 then
if turret.numVisibleWeapons == 1 then
title = "${material} ${weaponPrefix} Turret"%_t % tbl
title = "${material} ${weaponPrefix} Turret"%_t % tbl
elseif turret.numVisibleWeapons == 2 then
elseif turret.numVisibleWeapons == 2 then
title = "Double ${material} ${weaponPrefix} Turret"%_t % tbl
title = "Double ${material} ${weaponPrefix} Turret"%_t % tbl
elseif turret.numVisibleWeapons == 3 then
elseif turret.numVisibleWeapons == 3 then
title = "Triple ${material} ${weaponPrefix} Turret"%_t % tbl
title = "Triple ${material} ${weaponPrefix} Turret"%_t % tbl
elseif turret.numVisibleWeapons == 4 then
elseif turret.numVisibleWeapons == 4 then
title = "Quad ${material} ${weaponPrefix} Turret"%_t % tbl
title = "Quad ${material} ${weaponPrefix} Turret"%_t % tbl
else
else
title = "Multi ${material} ${weaponPrefix} Turret"%_t % tbl
title = "Multi ${material} ${weaponPrefix} Turret"%_t % tbl
end
end
else
else
if turret.numVisibleWeapons == 1 then
if turret.numVisibleWeapons == 1 then
title = "${weaponPrefix} Turret"%_t % tbl
title = "${weaponPrefix} Turret"%_t % tbl
elseif turret.numVisibleWeapons == 2 then
elseif turret.numVisibleWeapons == 2 then
title = "Double ${weaponPrefix} Turret"%_t % tbl
title = "Double ${weaponPrefix} Turret"%_t % tbl
elseif turret.numVisibleWeapons == 3 then
elseif turret.numVisibleWeapons == 3 then
title = "Triple ${weaponPrefix} Turret"%_t % tbl
title = "Triple ${weaponPrefix} Turret"%_t % tbl
elseif turret.numVisibleWeapons == 4 then
elseif turret.numVisibleWeapons == 4 then
title = "Quad ${weaponPrefix} Turret"%_t % tbl
title = "Quad ${weaponPrefix} Turret"%_t % tbl
else
else
title = "Multi ${weaponPrefix} Turret"%_t % tbl
title = "Multi ${weaponPrefix} Turret"%_t % tbl
end
end
end
end


-- head line
-- head line
local line = TooltipLine(headLineSize, headLineFont)
local line = TooltipLine(headLineSize-5, headLineFont)
line.ctext = title
line.ctext = title
line.ccolor = turret.rarity.color
line.ccolor = turret.rarity.color
tooltip:addLine(line)
tooltip:addLine(line)


local fontSize = 14;
local fontSize = 14
local lineHeight = 20;
local lineHeight = 20


fillWeaponTooltipData(turret, tooltip)
fillWeaponTooltipData(turret, tooltip)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Size"%_t
line.rtext = round(turret.size, 1)
line.icon = "data/textures/icons/shotgun.png";
line.iconColor = iconColor
tooltip:addLine(line)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Tracking Speed" --lyr_nt
line.rtext = round(turret.turningSpeed, 1)
line.icon = "data/textures/icons/clockwise-rotation.png";
line.iconColor = iconColor
tooltip:addLine(line)
-- crew requirements
local crew = turret:getCrew()


-- size
for crewman, amount in pairs(crew:getMembers()) do
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Size"%_t
line.rtext = round(turret.size, 1)
line.icon = "data/textures/icons/shotgun.png";
line.iconColor = iconColor
tooltip:addLine(line)


-- automatic/independent firing
if amount > 0 then
if turret.automatic then
local profession = crewman.profession
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Independent Targeting"%_t
line.icon = "data/textures/icons/cog.png";
line.iconColor = iconColor
tooltip:addLine(line)
end


-- empty line
local line = TooltipLine(lineHeight, fontSize)
tooltip:addLine(TooltipLine(15, 15))
line.ltext = profession.name
line.rtext = round(amount)
line.icon = profession.icon;
line.iconColor = iconColor
tooltip:addLine(line)


-- crew requirements
end
local crew = turret:getCrew()
end

for crewman, amount in pairs(crew:getMembers()) do
-- empty line
tooltip:addLine(TooltipLine(15, 15))
local addBlankLine = false


if amount > 0 then
if turret.automatic then
local profession = crewman.profession
local line = TooltipLine(lineHeight, fontSize+2)
line.ltext = "Independent Targeting" --lyr_nt
line.lcolor = ColorRGB(0.6, 1.0, 0.0)
line.icon = "data/textures/icons/processor.png";
line.iconColor = iconColor
tooltip:addLine(line)
--table.insert(description, "Programmable Turret: Can be set to fire automatically")
addBlankLine = true
end
if turret.simultaneousShooting and turret.numWeapons > 1 then
local line = TooltipLine(lineHeight, fontSize+2)
line.ltext = "Synchronized Weapons" --lyr_nt
line.lcolor = ColorRGB(0.45, 1.0, 0.15)
line.icon = "data/textures/icons/missile-pod.png";
line.iconColor = iconColor
tooltip:addLine(line)
--table.insert(description, "Synchronized Weapons: Fires all weapons at the same time")
addBlankLine = true
end
if turret.shotsPerFiring > 1 then
local line = TooltipLine(lineHeight, fontSize+2)
line.ltext = "Multiple Projectiles" --lyr_nt
line.lcolor = ColorRGB(0.30, 1.0, 0.3)
line.icon = "data/textures/icons/missile-swarm.png";
line.iconColor = iconColor
tooltip:addLine(line)
--table.insert(description, "Multiple Projectiles: Weapons fire multiple projectiles")
addBlankLine = true
end
--if turret.shootingTime == 1 then
if turret.shootingTime < 2 then
local line = TooltipLine(lineHeight, fontSize+2)
line.ltext = "Burst Fire" --lyr_nt
line.lcolor = ColorRGB(0.15, 1.0, 0.45)
line.icon = "data/textures/icons/bullets.png";
line.iconColor = iconColor
tooltip:addLine(line)
--table.insert(description, "Burst Fire: Fires rapidly for a second, then cools down")
addBlankLine = true
end
if turret.seeker then
local line = TooltipLine(lineHeight, fontSize+2)
line.ltext = "Guided Missiles" --lyr_nt
line.lcolor = ColorRGB(0.0, 1.0, 0.6)
line.icon = "data/textures/icons/rocket-thruster.png";
line.iconColor = iconColor
tooltip:addLine(line)
--table.insert(description, "Guided Missiles: Missiles track the targets")
addBlankLine = true
end


local line = TooltipLine(lineHeight, fontSize)
-- empty line
line.ltext = profession.name
if addBlankLine then tooltip:addLine(TooltipLine(15, 15)) end
line.rtext = round(amount)
line.icon = profession.icon;
line.iconColor = iconColor
tooltip:addLine(line)


end
fillDescriptions(turret, tooltip, description)
end


-- empty line
return tooltip
tooltip:addLine(TooltipLine(15, 15))

local description = {}
if turret.automatic then
table.insert(description, "Independent targeting, but deals less damage"%_t)
end

fillDescriptions(turret, tooltip, description)

return tooltip
end
end




function makeFighterTooltip(fighter)
function makeFighterTooltip(fighter)
-- create tool tip
local tooltip = Tooltip()
tooltip.icon = fighter.weaponIcon


-- create tool tip
-- title
local tooltip = Tooltip()
local title = "${weaponPrefix} Fighter"%_t % fighter
tooltip.icon = fighter.weaponIcon


-- title
local line = TooltipLine(headLineSize-5, headLineFont)
local title = "${weaponPrefix} Fighter"%_t % fighter
line.ctext = title
line.ccolor = fighter.rarity.color
tooltip:addLine(line)


local line = TooltipLine(headLineSize, headLineFont)
-- primary stats, one by one
line.ctext = title
local fontSize = 14
line.ccolor = fighter.rarity.color
local lineHeight = 20
tooltip:addLine(line)


-- primary stats, one by one
fillWeaponTooltipData(fighter, tooltip)
local fontSize = 14
local lineHeight = 20


fillWeaponTooltipData(fighter, tooltip)
-- durability
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Durability"%_t
line.rtext = round(fighter.durability)
line.icon = "data/textures/icons/health-normal.png";
line.iconColor = iconColor
tooltip:addLine(line)


-- size
local line = TooltipLine(lineHeight, fontSize)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Shield"%_t
line.ltext = "Size"%_t
line.rtext = fighter.shield > 0 and round(fighter.durability) or "None"
line.rtext = round(fighter.volume)
line.icon = "data/textures/icons/health-normal.png";
line.icon = "data/textures/icons/fighter.png";
line.iconColor = iconColor
line.iconColor = iconColor
tooltip:addLine(line)
tooltip:addLine(line)


-- empty line
-- empty line
tooltip:addLine(TooltipLine(15, 15))
tooltip:addLine(TooltipLine(15, 15))


-- durability
-- size
local line = TooltipLine(lineHeight, fontSize)
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Durability"%_t
line.ltext = "Size"%_t
line.rtext = round(fighter.durability)
line.rtext = round(fighter.volume)
line.icon = "data/textures/icons/health-normal.png";
line.icon = "data/textures/icons/fighter.png";
line.iconColor = iconColor
line.iconColor = iconColor
tooltip:addLine(line)
tooltip:addLine(line)

if fighter.shield > 0 then
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Shield"%_t
line.rtext = round(fighter.durability)
line.icon = "data/textures/icons/health-normal.png";
line.iconColor = iconColor
tooltip:addLine(line)
end

-- empty line
tooltip:addLine(TooltipLine(15, 15))

-- maneuverability
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Maneuverability"%_t
line.rtext = round(fighter.turningSpeed, 2)
line.icon = "data/textures/icons/dodge.png";
line.iconColor = iconColor
tooltip:addLine(line)

-- velocity
local line = TooltipLine(lineHeight, fontSize)
line.ltext = "Speed"%_t
line.rtext = round(fighter.maxVelocity * 10.0)
line.icon = "data/textures/icons/afterburn.png";
line.iconColor = iconColor
tooltip:addLine(line)


-- empty line
-- maneuverability
tooltip:addLine(TooltipLine(15, 15))
local line = TooltipLine(lineHeight, fontSize)

line.ltext = "Maneuverability"%_t
-- crew requirements
line.rtext = round(fighter.turningSpeed, 2) --what's the unit?
local pilot = CrewProfession(CrewProfessionType.Pilot)
line.icon = "data/textures/icons/dodge.png";

line.iconColor = iconColor
local line = TooltipLine(lineHeight, fontSize)
toolt
line.ltext = pilot.name
line.rtext = round(fighter.crew)
line.icon = pilot.icon
line.iconColor = iconColor
tooltip:addLine(line)


-- empty line
tooltip:addLine(TooltipLine(15, 15))

fillDescriptions(fighter, tooltip)

return tooltip
end