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
174 changes: 2 additions & 172 deletions src/Classes/GemSelectControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ 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 imbuedTooltipText = "\"Socketed in\" item must be set in order to add an imbued support.\nOnly one imbued support is allowed per item."

Expand Down Expand Up @@ -595,178 +596,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
self.tooltip.tooltipHeader = "GEM"
local primary = gemInstance.gemData.grantedEffect
local secondary = gemInstance.gemData.secondaryGrantedEffect
if secondary and (not secondary.support or gemInstance.gemData.secondaryEffectName) then
local grantedEffect = gemInstance.gemData.VaalGem and secondary or primary
local grantedEffectSecondary = gemInstance.gemData.VaalGem and primary or secondary
self.tooltip:AddLine(fontSizeTitle, colorCodes.GEM..grantedEffect.name, "FONTIN SC")
self.tooltip:AddSeparator(10)
self.tooltip:AddLine(fontSizeBig, "^x7F7F7F" .. gemInstance.gemData.tagString, "FONTIN SC")
self:AddCommonGemInfo(gemInstance, grantedEffect, true)
self.tooltip:AddSeparator(10)
self.tooltip:AddLine(fontSizeTitle, colorCodes.GEM .. (gemInstance.gemData.secondaryEffectName or grantedEffectSecondary.name), "FONTIN SC")
self.tooltip:AddSeparator(10)
self:AddCommonGemInfo(gemInstance, grantedEffectSecondary)
else
local grantedEffect = gemInstance.gemData.grantedEffect
self.tooltip:AddLine(fontSizeTitle, colorCodes.GEM..grantedEffect.name, "FONTIN SC")
self.tooltip:AddSeparator(10)
if grantedEffect.legacy then
self.tooltip:AddLine(fontSizeTitle, colorCodes.WARNING .. "Legacy Gem", "FONTIN SC")
self.tooltip:AddLine(fontSizeBig, colorCodes.WARNING .. "Gem only exists in Standard League", "FONTIN SC")
self.tooltip:AddSeparator(10)
end
self.tooltip:AddLine(fontSizeBig, "^x7F7F7F" .. gemInstance.gemData.tagString, "FONTIN SC")
self:AddCommonGemInfo(gemInstance, grantedEffect, true, secondary and secondary.support and secondary)
end
end

function GemSelectClass:AddCommonGemInfo(gemInstance, grantedEffect, addReq, mergeStatsFrom)
local fontSizeBig = main.showFlavourText and 18 or 16
local displayInstance = gemInstance.displayEffect or gemInstance
local grantedEffectLevel = grantedEffect.levels[displayInstance.level] or { }
if addReq 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 then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FCost & Reservation Multiplier: ^7%d%%", grantedEffectLevel.manaMultiplier + 100), "FONTIN SC")
end
local reservation
for name, res in pairs(self.reservationMap) do
if grantedEffectLevel[name] then
reservation = (reservation and (reservation .. ", ") or "") .. self.costs[isValueInArrayPred(self.costs, function(v) return v.Resource == res end)].ResourceString:gsub("{0}", string.format("%d", grantedEffectLevel[name]))
end
end
if reservation then
self.tooltip:AddLine(fontSizeBig, "^x7F7F7FReservation Override: ^7"..reservation, "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
else
local reservation
for name, res in pairs(self.reservationMap) do
if grantedEffectLevel[name] then
reservation = (reservation and (reservation..", ") or "") .. self.costs[isValueInArrayPred(self.costs, function(v) return v.Resource == res end)].ResourceString:gsub("{0}", string.format("%d", grantedEffectLevel[name]))
end
end
if reservation then
self.tooltip:AddLine(fontSizeBig, "^x7F7F7FReservation: ^7" .. reservation, "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, "FONTIN SC")
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
else
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 Strike Chance: ^7%.2f%%", grantedEffectLevel.critChance), "FONTIN SC")
end
if grantedEffectLevel.damageEffectiveness then
self.tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FEffectiveness of Added Damage: ^7%d%%", grantedEffectLevel.damageEffectiveness * 100), "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, grantedEffect.support, gemInstance.gemData.reqStr)
local reqDex = calcLib.getGemStatRequirement(reqLevel, grantedEffect.support, gemInstance.gemData.reqDex)
local reqInt = calcLib.getGemStatRequirement(reqLevel, grantedEffect.support, gemInstance.gemData.reqInt)
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(16, "VAR", gemInstance.gemData.tagString), 400))
for _, line in ipairs(wrap) do
self.tooltip:AddLine(fontSizeBig, colorCodes.GEM..line, "FONTIN SC")
end
end
if self.skillsTab.build.data.describeStats then
self.tooltip:AddSeparator(10)
local stats = calcLib.buildSkillInstanceStats(displayInstance, grantedEffect)
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, grantedEffect.statDescriptionScope)
for _, line in ipairs(descriptions) do
local source = grantedEffect.statMap[lineMap[line]] or self.skillsTab.build.data.skillStatMap[lineMap[line]]
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")
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")
end
end
end
gemTooltip.AddGemTooltip(self.tooltip, self.skillsTab.build, gemInstance)
end

function GemSelectClass:OnFocusGained()
Expand Down
Loading
Loading