Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
222 changes: 3 additions & 219 deletions src/Classes/GemSelectControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ local m_min = math.min
local m_max = math.max
local m_floor = math.floor

local gemTooltip = LoadModule("Classes/GemTooltip")

local toolTipText = "Prefix tag searches with a colon and exclude tags with a dash. e.g. :fire:lightning:-cold:area"

local GemSelectClass = newClass("GemSelectControl", "EditControl", function(self, anchor, rect, skillsTab, index, changeFunc, forceTooltip)
Expand Down Expand Up @@ -43,7 +45,6 @@ local GemSelectClass = newClass("GemSelectControl", "EditControl", function(self
self:BuildList(self.buf)
self:UpdateGem()
end
self.costs = data.costs
end)

function GemSelectClass:CalcOutputWithThisGem(calcFunc, gemData, useFullDPS)
Expand Down Expand Up @@ -539,224 +540,7 @@ function GemSelectClass:CheckSupporting(gemA, gemB)
end

function GemSelectClass:AddGemTooltip(gemInstance)
local fontSizeBig = main.showFlavourText and 18 or 16
local fontSizeTitle = main.showFlavourText and 24 or 20
self.tooltip.center = true
self.tooltip.color = colorCodes.GEM
local grantedEffect = gemInstance.gemData.grantedEffect
local additionalEffects = gemInstance.gemData.additionalGrantedEffects
self.tooltip.tooltipHeader = "GEM"
if grantedEffect.name:match("^Spectre:") or grantedEffect.name:match("^Companion:") then
self.tooltip:AddLine(fontSizeTitle, colorCodes.GEM .. (gemInstance.displayEffect and gemInstance.displayEffect.nameSpec or gemInstance.gemData.name), "FONTIN SC")
else
self.tooltip:AddLine(fontSizeTitle, colorCodes.GEM .. gemInstance.gemData.name, "FONTIN SC")
end
self.tooltip:AddSeparator(10)
self.tooltip:AddLine(fontSizeBig, colorCodes.NORMAL .. gemInstance.gemData.gemType, "FONTIN SC")
if gemInstance.gemData.tagString ~= "" then
self.tooltip:AddLine(fontSizeBig, "^x7F7F7F" .. gemInstance.gemData.tagString, "FONTIN SC")
end
if gemInstance.gemData.gemFamily then
self.tooltip:AddLine(fontSizeBig, "^x7F7F7FCategory: ^7" .. gemInstance.gemData.gemFamily, "FONTIN SC")
end
-- Will need rework if a gem can have 2+ additional supports
self:AddGrantedEffectInfo(gemInstance, grantedEffect, true)
for _, statSet in ipairs(grantedEffect.statSets) do
self:AddStatSetInfo(gemInstance, grantedEffect, statSet, nil , _)
end

for _, additional in ipairs(additionalEffects or {}) do
if not additional.support then
if additional.name ~= "" then
self.tooltip:AddSeparator(10)
self.tooltip:AddLine(fontSizeTitle, colorCodes.GEM .. additional.name, "FONTIN SC")
end
self.tooltip:AddSeparator(10)
self:AddGrantedEffectInfo(gemInstance, additional)
for _, statSet in ipairs(additional.statSets) do
self:AddStatSetInfo(gemInstance, additional, statSet, nil, _)
end
else
for _, statSet in ipairs(additional.statSets) do
self:AddStatSetInfo(gemInstance, additional, statSet, true, _)
end
end
end
if grantedEffect.flavourText and main.showFlavourText then
self.tooltip:AddSeparator(10)
for _, line in ipairs(grantedEffect.flavourText) do
self.tooltip:AddLine(fontSizeBig, colorCodes.UNIQUE .. line, "FONTIN SC ITALIC")
end
end
end

function GemSelectClass:AddGrantedEffectInfo(gemInstance, grantedEffect, addReq)
local fontSizeBig = main.showFlavourText and 18 or 16
local displayInstance = gemInstance.displayEffect or gemInstance
local grantedEffectLevel = grantedEffect.levels[displayInstance.level] or { }
if gemInstance.gemData.Tier and gemInstance.gemData.Tier > 0 and not grantedEffect.isLineage and not grantedEffect.hidden then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FTier: ^7%d", gemInstance.gemData.Tier), "FONTIN SC")
end
if addReq and not grantedEffect.support then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FLevel: ^7%d%s%s",
gemInstance.level,
((displayInstance.level > gemInstance.level) and " (" .. colorCodes.MAGIC .. "+" .. (displayInstance.level - gemInstance.level) .. "^7)") or ((displayInstance.level < gemInstance.level) and " (" .. colorCodes.WARNING .. "-" .. (gemInstance.level - displayInstance.level) .. "^7)") or "",
(gemInstance.level >= gemInstance.gemData.naturalMaxLevel) and " (Max)" or ""
),"FONTIN SC")
end
if grantedEffect.support then
if grantedEffectLevel.manaMultiplier and grantedEffectLevel.reservationMultiplier and grantedEffectLevel.manaMultiplier == grantedEffectLevel.reservationMultiplier then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FCost & Reservation Multiplier: ^7%d%%", grantedEffectLevel.manaMultiplier + 100), "FONTIN SC")
elseif grantedEffectLevel.reservationMultiplier then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FReservation Multiplier: ^7%d%%", grantedEffectLevel.reservationMultiplier + 100), "FONTIN SC")
elseif grantedEffectLevel.manaMultiplier then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FCost Multiplier: ^7%d%%", grantedEffectLevel.manaMultiplier + 100), "FONTIN SC")
end
if grantedEffectLevel.spiritReservationFlat then
if grantedEffect.support then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FAdditional Reservation: ^7%d Spirit", grantedEffectLevel.spiritReservationFlat), "FONTIN SC")
else
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FReservation: ^7%d Spirit", grantedEffectLevel.spiritReservationFlat), "FONTIN SC")
end
end
if grantedEffectLevel.cooldown then
local string = string.format("^x7F7F7FCooldown Time: ^7%.2f sec", grantedEffectLevel.cooldown)
if grantedEffectLevel.storedUses and grantedEffectLevel.storedUses > 1 then
string = string .. string.format(" (%d uses)", grantedEffectLevel.storedUses)
end
self.tooltip:AddLine(fontSizeBig, string, "FONTIN SC")
end
else
if gemInstance.skillMinion then
if gemInstance.nameSpec:match("^Spectre:") then
grantedEffectLevel.spiritReservationFlat = data.spectres[gemInstance.skillMinion].spectreReservation
elseif gemInstance.nameSpec:match("^Companion:") then
grantedEffectLevel.spiritReservationPercent = data.spectres[gemInstance.skillMinion].companionReservation
end
end
if grantedEffectLevel.spiritReservationFlat then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FReservation: ^7%d Spirit", grantedEffectLevel.spiritReservationFlat), "FONTIN SC")
end
if grantedEffectLevel.spiritReservationPercent then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FReservation: ^7%.1f%% Spirit", grantedEffectLevel.spiritReservationPercent), "FONTIN SC")
end
local cost
for _, res in ipairs(self.costs) do
if grantedEffectLevel.cost and grantedEffectLevel.cost[res.Resource] then
cost = (cost and (cost..", ") or "") .. res.ResourceString:gsub("{0}", string.format("%g", round(grantedEffectLevel.cost[res.Resource] / res.Divisor, 2)))
end
end
if cost then
self.tooltip:AddLine(fontSizeBig, "^x7F7F7FCost: ^7"..cost, "FONTIN SC")
end
if grantedEffectLevel.cooldown then
local string = string.format("^x7F7F7FCooldown Time: ^7%.2f sec", grantedEffectLevel.cooldown)
if grantedEffectLevel.storedUses and grantedEffectLevel.storedUses > 1 then
string = string .. string.format(" (%d uses)", grantedEffectLevel.storedUses)
end
self.tooltip:AddLine(fontSizeBig, string, "FONTIN SC")
end
if grantedEffectLevel.vaalStoredUses then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FCan Store ^7%d ^x7F7F7FUse (%d Souls)", grantedEffectLevel.vaalStoredUses, grantedEffectLevel.vaalStoredUses * grantedEffectLevel.cost.Soul), "FONTIN SC")
end
if grantedEffectLevel.soulPreventionDuration then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FSoul Gain Prevention: ^7%d sec", grantedEffectLevel.soulPreventionDuration), "FONTIN SC")
end
if gemInstance.gemData.tags.attack then
if grantedEffectLevel.attackSpeedMultiplier then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FAttack Speed: ^7%d%% of base", grantedEffectLevel.attackSpeedMultiplier + 100), "FONTIN SC")
end
if grantedEffectLevel.attackTime then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FAttack Time: ^7%.2f sec", grantedEffectLevel.attackTime / 1000), "FONTIN SC")
end
if grantedEffectLevel.baseMultiplier then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FAttack Damage: ^7%g%% of base", grantedEffectLevel.baseMultiplier * 100), "FONTIN SC")
end
elseif not grantedEffect.hidden then
if grantedEffect.castTime > 0 then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FCast Time: ^7%.2f sec", grantedEffect.castTime), "FONTIN SC")
else
self.tooltip:AddLine(fontSizeBig, "^x7F7F7FCast Time: ^7Instant", "FONTIN SC")
end
end
if grantedEffectLevel.critChance then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FCritical Hit Chance: ^7%.2f%%", grantedEffectLevel.critChance), "FONTIN SC")
end
if gemInstance.gemData.weaponRequirements and not grantedEffect.hidden then
self.tooltip:AddLine(fontSizeBig, "^x7F7F7F Requires: ^7" .. gemInstance.gemData.weaponRequirements, "FONTIN SC")
end
end
if addReq and displayInstance.quality > 0 then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FQuality: "..colorCodes.MAGIC.."+%d%%^7%s",
gemInstance.quality,
(displayInstance.quality > gemInstance.quality) and " ("..colorCodes.MAGIC.."+"..(displayInstance.quality - gemInstance.quality).."^7)" or ""
), "FONTIN SC")
end
self.tooltip:AddSeparator(10)
if addReq then
local reqLevel = grantedEffect.levels[gemInstance.level] and grantedEffect.levels[gemInstance.level].levelRequirement or 1
local reqStr = calcLib.getGemStatRequirement(reqLevel, gemInstance.gemData.reqStr, grantedEffect.support)
local reqDex = calcLib.getGemStatRequirement(reqLevel, gemInstance.gemData.reqDex, grantedEffect.support)
local reqInt = calcLib.getGemStatRequirement(reqLevel, gemInstance.gemData.reqInt, grantedEffect.support)
self.skillsTab.build:AddRequirementsToTooltip(self.tooltip, reqLevel, reqStr, reqDex, reqInt)
end
if grantedEffect.description then
local wrap = main:WrapString(grantedEffect.description, 16, m_max(DrawStringWidth(fontSizeBig, "VAR", gemInstance.gemData.tagString), 400))
for _, line in ipairs(wrap) do
self.tooltip:AddLine(fontSizeBig, colorCodes.GEMDESCRIPTION..line, "FONTIN ITALIC")
end
end
end
function GemSelectClass:AddStatSetInfo(gemInstance, grantedEffect, statSet, noLabel, index)
local fontSizeBig = main.showFlavourText and 18 or 16
local fontSizeTitle = main.showFlavourText and 24 or 20
local displayInstance = gemInstance.displayEffect or gemInstance
local statSetLevel = statSet.levels[displayInstance.level] or statSet.levels[1] or { }
if not (index == 1 and statSet.label == grantedEffect.name) and statSet.label ~= "" and not noLabel then
self.tooltip:AddSeparator(10)
self.tooltip:AddLine(fontSizeTitle, colorCodes.GEM .. statSet.label, "FONTIN SC")
self.tooltip:AddSeparator(10)
end
if statSetLevel.critChance then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FCritical Hit Chance: ^7%.2f%%", statSetLevel.critChance), "FONTIN SC")
end
if statSetLevel.baseMultiplier then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FAttack Damage: ^7%d%%", statSetLevel.baseMultiplier * 100), "FONTIN SC")
end
if self.skillsTab and self.skillsTab.build.data.describeStats then
if not noLabel then self.tooltip:AddSeparator(10) end
local stats = calcLib.buildSkillInstanceStats(displayInstance, grantedEffect, statSet)
--if mergeStatsFrom then
-- for stat, val in pairs(calcLib.buildSkillInstanceStats(displayInstance, mergeStatsFrom)) do
-- stats[stat] = (stats[stat] or 0) + val
-- end
--end
local descriptions, lineMap = self.skillsTab.build.data.describeStats(stats, statSet.statDescriptionScope)
for i, line in ipairs(descriptions) do
local source = statSet.statMap[lineMap[line]] or self.skillsTab.build.data.skillStatMap[lineMap[line]]
local bg = (i % 2 == 0) and "GemHoverModBg" or nil -- every second line gets background
if source then
if launch.devModeAlt then
local devText = lineMap[line]
if source[1] then
if not source[1].value then
source[1].value = lineMap[line]
end
devText = modLib.formatMod(source[1])
end
line = line .. " ^2" .. devText
end
self.tooltip:AddLine(fontSizeBig, colorCodes.MAGIC .. line, "FONTIN SC", bg)
else
if launch.devModeAlt then
line = line .. " ^1" .. lineMap[line]
end
local line = colorCodes.UNSUPPORTED .. line
line = main.notSupportedModTooltips and (line .. main.notSupportedTooltipText) or line
self.tooltip:AddLine(fontSizeBig, line, "FONTIN SC", bg)
end
end
end
gemTooltip.AddGemTooltip(self.tooltip, self.skillsTab.build, gemInstance)
end
function GemSelectClass:OnFocusGained()
self.EditControl:OnFocusGained()
Expand Down
Loading
Loading