Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Openarl committed Apr 15, 2017
2 parents 3a67b36 + 46640fe commit e37b8ad
Show file tree
Hide file tree
Showing 84 changed files with 45,255 additions and 29,122 deletions.
15 changes: 9 additions & 6 deletions Classes/CalcBreakdownControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,13 @@ end

-- Add sections based on the breakdown data generated by the Calcs module
function CalcBreakdownClass:AddBreakdownSection(sectionData)
local actor = self.calcsTab.input.showMinion and self.calcsTab.calcsEnv.minion or self.calcsTab.calcsEnv.player
local breakdown
local ns, name = sectionData.breakdown:match("^(%a+)%.(%a+)$")
if ns then
breakdown = self.calcsTab.calcsEnv.breakdown[ns] and self.calcsTab.calcsEnv.breakdown[ns][name]
breakdown = actor.breakdown[ns] and actor.breakdown[ns][name]
else
breakdown = self.calcsTab.calcsEnv.breakdown[sectionData.breakdown]
breakdown = actor.breakdown[sectionData.breakdown]
end
if not breakdown then
return
Expand Down Expand Up @@ -181,15 +182,15 @@ end

-- Add a table section showing a list of modifiers
function CalcBreakdownClass:AddModSection(sectionData)
local env = self.calcsTab.calcsEnv
local actor = self.calcsTab.input.showMinion and self.calcsTab.calcsEnv.minion or self.calcsTab.calcsEnv.player
local build = self.calcsTab.build

-- Build list of modifiers to display
local cfg = (sectionData.cfg and env.mainSkill[sectionData.cfg.."Cfg"] and copyTable(env.mainSkill[sectionData.cfg.."Cfg"])) or { }
local cfg = (sectionData.cfg and actor.mainSkill[sectionData.cfg.."Cfg"] and copyTable(actor.mainSkill[sectionData.cfg.."Cfg"])) or { }
cfg.source = sectionData.modSource
cfg.tabulate = true
local rowList
local modDB = sectionData.enemy and env.enemyDB or env.modDB
local modDB = sectionData.enemy and actor.enemy.modDB or actor.modDB
if type(sectionData.modName) == "table" then
rowList = modDB:Sum(sectionData.modType, cfg, unpack(sectionData.modName))
else
Expand Down Expand Up @@ -321,7 +322,7 @@ function CalcBreakdownClass:AddModSection(sectionData)
end
elseif sourceType == "Skill" then
-- Extract skill name
row.sourceName = row.mod.source:match("Skill:(.+)")
row.sourceName = data.skills[row.mod.source:match("Skill:(.+)")].name
end
if row.mod.flags ~= 0 or row.mod.keywordFlags ~= 0 then
-- Combine, sort and format modifier flags
Expand All @@ -343,6 +344,8 @@ function CalcBreakdownClass:AddModSection(sectionData)
local desc
if tag.type == "Condition" then
desc = "Condition: "..(tag.neg and "Not " or "")..(tag.varList and table.concat(tag.varList, "/") or self:FormatModName(tag.var))
elseif tag.type == "EnemyCondition" then
desc = "Enemy Condition: "..(tag.neg and "Not " or "")..(tag.varList and table.concat(tag.varList, "/") or self:FormatModName(tag.var))
elseif tag.type == "Multiplier" then
if tag.base then
desc = (row.mod.type == "BASE" and string.format("%+g", tag.base) or tag.base.."%").." + "..math.abs(row.mod.value).." per "..self:FormatModName(tag.var)
Expand Down
24 changes: 11 additions & 13 deletions Classes/CalcSectionControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,35 +133,34 @@ function CalcSectionClass:UpdatePos()
end
end

function CalcSectionClass:FormatStr(str, output, colData)
function CalcSectionClass:FormatStr(str, actor, colData)
str = str:gsub("{output:([%a%.:]+)}", function(c)
local ns, var = c:match("^(%a+)%.(%a+)$")
if ns then
return output[ns][var] or ""
return actor.output[ns] and actor.output[ns][var] or ""
else
return output[c] or ""
return actor.output[c] or ""
end
end)
str = str:gsub("{(%d+):output:([%a%.:]+)}", function(p, c)
local ns, var = c:match("^(%a+)%.(%a+)$")
if ns then
return formatRound(output[ns][var] or 0, tonumber(p))
return formatRound(actor.output[ns] and actor.output[ns][var] or 0, tonumber(p))
else
return formatRound(output[c] or 0, tonumber(p))
return formatRound(actor.output[c] or 0, tonumber(p))
end
end)
str = str:gsub("{(%d+):mod:(%d+)}", function(p, n)
local sectionData = colData[tonumber(n)]
local env = self.calcsTab.calcsEnv
local modCfg = (sectionData.cfg and env.mainSkill[sectionData.cfg.."Cfg"]) or { }
local modCfg = (sectionData.cfg and actor.mainSkill[sectionData.cfg.."Cfg"]) or { }
if sectionData.modSource then
modCfg.source = sectionData.modSource
end
local modVal
if type(sectionData.modName) == "table" then
modVal = env.modDB:Sum(sectionData.modType, modCfg, unpack(sectionData.modName))
modVal = actor.modDB:Sum(sectionData.modType, modCfg, unpack(sectionData.modName))
else
modVal = env.modDB:Sum(sectionData.modType, modCfg, sectionData.modName)
modVal = actor.modDB:Sum(sectionData.modType, modCfg, sectionData.modName)
end
if sectionData.modType == "MORE" then
modVal = (modVal - 1) * 100
Expand All @@ -175,8 +174,7 @@ function CalcSectionClass:Draw(viewPort)
local x, y = self:GetPos()
local width, height = self:GetSize()
local cursorX, cursorY = GetCursorPos()
local env = self.calcsTab.calcsEnv
local output = self.calcsTab.calcsOutput
local actor = self.calcsTab.input.showMinion and self.calcsTab.calcsEnv.minion or self.calcsTab.calcsEnv.player
-- Draw border and background
SetDrawLayer(nil, -10)
SetDrawColor(self.col)
Expand All @@ -190,7 +188,7 @@ function CalcSectionClass:Draw(viewPort)
DrawString(x + 3, y + 3, "LEFT", 16, "VAR BOLD", "^7"..self.label..":")
if self.extra then
local x = x + 3 + DrawStringWidth(16, "VAR BOLD", self.label) + 10
DrawString(x, y + 3, "LEFT", 16, "VAR", self:FormatStr(self.extra, output))
DrawString(x, y + 3, "LEFT", 16, "VAR", self:FormatStr(self.extra, actor))
end
end
-- Draw line below label
Expand Down Expand Up @@ -231,7 +229,7 @@ function CalcSectionClass:Draw(viewPort)
end
local textSize = rowData.textSize or 14
SetViewport(colData.x + 3, colData.y, colData.width - 4, colData.height)
DrawString(1, 9 - textSize/2, "LEFT", textSize, "VAR", "^7"..self:FormatStr(colData.format, output, colData))
DrawString(1, 9 - textSize/2, "LEFT", textSize, "VAR", "^7"..self:FormatStr(colData.format, actor, colData))
SetViewport()
end
end
Expand Down
83 changes: 44 additions & 39 deletions Classes/CalcsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ local CalcsTabClass = common.NewClass("CalcsTab", "UndoHandler", "ControlHost",

self.input = { }
self.input.skill_number = 1
self.input.skill_activeNumber = 1
self.input.skill_part = 1
self.input.misc_buffMode = "EFFECTIVE"

self.colWidth = 230
Expand All @@ -45,18 +43,46 @@ local CalcsTabClass = common.NewClass("CalcsTab", "UndoHandler", "ControlHost",
}, },
{ label = "Active Skill", { controlName = "mainSkill",
control = common.New("DropDownControl", nil, 0, 0, 300, 16, nil, function(index)
self.input.skill_activeNumber = index
self:AddUndoState()
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.input.skill_number]
mainSocketGroup.mainActiveSkillCalcs = index
self.build.buildFlag = true
end)
}, },
{ label = "Skill Part", flag = "multiPart", { controlName = "mainSkillPart",
control = common.New("DropDownControl", nil, 0, 0, 130, 16, nil, function(index)
self.input.skill_part = index
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.input.skill_number]
mainSocketGroup.displaySkillListCalcs[mainSocketGroup.mainActiveSkillCalcs].activeGem.srcGem.skillPartCalcs = index
self:AddUndoState()
self.build.buildFlag = true
end)
}, },
{ label = "Show Minion Stats", flag = "haveMinion", { controlName = "showMinion",
control = common.New("CheckBoxControl", nil, 0, 0, 18, nil, function(state)
self.input.showMinion = state
self:AddUndoState()
end, "Show stats for the minion instead of the player.")
}, },
{ label = "Minion", flag = "minion", { controlName = "mainSkillMinion",
control = common.New("DropDownControl", nil, 0, 0, 150, 16, nil, function(index, val)
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.input.skill_number]
mainSocketGroup.displaySkillListCalcs[mainSocketGroup.mainActiveSkillCalcs].activeGem.srcGem.skillMinionCalcs = val.val
self:AddUndoState()
self.build.buildFlag = true
end)
} },
{ label = "Spectre Library", flag = "spectre", { controlName = "mainSkillMinionLibrary",
control = common.New("ButtonControl", nil, 0, 0, 100, 16, "Manage Spectres...", function()
self.build:OpenSpectreLibrary()
end)
} },
{ label = "Minion Skill", flag = "haveMinion", { controlName = "mainSkillMinionSkill",
control = common.New("DropDownControl", nil, 0, 0, 200, 16, nil, function(index)
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.input.skill_number]
mainSocketGroup.displaySkillListCalcs[mainSocketGroup.mainActiveSkillCalcs].activeGem.srcGem.skillMinionSkillCalcs = index
self:AddUndoState()
self.build.buildFlag = true
end)
} },
{ label = "Calculation Mode", {
controlName = "mode",
control = common.New("DropDownControl", nil, 0, 0, 100, 16, {
Expand All @@ -81,32 +107,8 @@ Effective DPS: Curses and enemy properties (such as resistances and status condi
{ label = "Combat Buffs", flag = "combat", textSize = 12, { format = "{output:CombatList}" }, },
{ label = "Curses and Debuffs", flag = "effective", textSize = 12, { format = "{output:CurseList}" }, },
}, function(section)
wipeTable(section.controls.mainSocketGroup.list)
for i, socketGroup in pairs(self.build.skillsTab.socketGroupList) do
section.controls.mainSocketGroup.list[i] = { val = i, label = socketGroup.displayLabel }
end
if #section.controls.mainSocketGroup.list == 0 then
section.controls.mainSocketGroup.list[1] = { val = 1, label = "<No skills added yet>" }
else
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.input.skill_number]
wipeTable(section.controls.mainSkill.list)
for i, activeSkill in ipairs(mainSocketGroup.displaySkillList) do
t_insert(section.controls.mainSkill.list, { val = i, label = activeSkill.activeGem.name })
end
section.controls.mainSkill.enabled = #mainSocketGroup.displaySkillList > 1
section.controls.mainSkill.sel = self.input.skill_activeNumber
if mainSocketGroup.displaySkillList[1] then
local activeGem = mainSocketGroup.displaySkillList[self.input.skill_activeNumber].activeGem
if activeGem and activeGem.data.parts and #activeGem.data.parts > 1 then
wipeTable(section.controls.mainSkillPart.list)
for i, part in ipairs(activeGem.data.parts) do
t_insert(section.controls.mainSkillPart.list, { val = i, label = part.name })
end
section.controls.mainSkillPart.sel = self.input.skill_part
end
end
end
section.controls.mainSocketGroup.sel = self.input.skill_number
self.build:RefreshSkillSelectControls(section.controls, self.input.skill_number, "Calcs")
section.controls.showMinion.state = self.input.showMinion
section.controls.mode:SelByValue(self.input.misc_buffMode)
end)

Expand Down Expand Up @@ -320,7 +322,8 @@ function CalcsTabClass:SetDisplayStat(displayData, pin)
end

function CalcsTabClass:CheckFlag(obj)
local skillFlags = self.calcsEnv.mainSkill.skillFlags
local actor = self.input.showMinion and self.calcsEnv.minion or self.calcsEnv.player
local skillFlags = actor.mainSkill.skillFlags
if obj.flag and not skillFlags[obj.flag] then
return
end
Expand All @@ -342,7 +345,7 @@ function CalcsTabClass:CheckFlag(obj)
end
end
if obj.haveOutput then
if not self.calcsOutput[obj.haveOutput] or self.calcsOutput[obj.haveOutput] == 0 then
if not actor.output[obj.haveOutput] or actor.output[obj.haveOutput] == 0 then
return
end
end
Expand All @@ -357,18 +360,16 @@ function CalcsTabClass:BuildOutput()
local start = GetTime()
SetProfiling(true)
for i = 1, 1000 do
wipeTable(self.mainOutput)
self.calcs.buildOutput(self.build, self.mainOutput, "MAIN")
self.calcs.buildOutput(self.build, "MAIN")
end
SetProfiling(false)
ConPrintf("Calc time: %d msec", GetTime() - start)
--]]

self.mainEnv = self.calcs.buildOutput(self.build, "MAIN")
self.mainOutput = self.mainEnv.output
self.mainOutput = self.mainEnv.player.output
self.calcsEnv = self.calcs.buildOutput(self.build, "CALCS")
self.calcsOutput = self.calcsEnv.output
self.calcsBreakdown = self.calcsEnv.breakdown
self.calcsOutput = self.calcsEnv.player.output

if self.displayData then
self.controls.breakdown:SetBreakdownData()
Expand Down Expand Up @@ -421,7 +422,11 @@ function CalcsTabClass:PowerBuilder()
cache[node.modKey] = calcFunc({node})
end
local output = cache[node.modKey]
node.power.dps = (output.CombinedDPS - calcBase.CombinedDPS) / calcBase.CombinedDPS
if calcBase.Minion then
node.power.dps = (output.Minion.CombinedDPS - calcBase.Minion.CombinedDPS) / calcBase.Minion.CombinedDPS
else
node.power.dps = (output.CombinedDPS - calcBase.CombinedDPS) / calcBase.CombinedDPS
end
node.power.def = (output.LifeUnreserved - calcBase.LifeUnreserved) / m_max(3000, calcBase.Life) +
(output.Armour - calcBase.Armour) / m_max(10000, calcBase.Armour) +
(output.EnergyShield - calcBase.EnergyShield) / m_max(3000, calcBase.EnergyShield) +
Expand Down
3 changes: 2 additions & 1 deletion Classes/CheckBoxControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
--
local launch, main = ...

local CheckBoxClass = common.NewClass("CheckBoxControl", "Control", function(self, anchor, x, y, size, label, changeFunc)
local CheckBoxClass = common.NewClass("CheckBoxControl", "Control", function(self, anchor, x, y, size, label, changeFunc, tooltip)
self.Control(anchor, x, y, size, size)
self.label = label
self.changeFunc = changeFunc
self.tooltip = tooltip
self.tooltipFunc = function(state)
local tooltip = self:GetProperty("tooltip")
if tooltip then
Expand Down
Loading

0 comments on commit e37b8ad

Please sign in to comment.