diff --git a/Classes/CalcSectionControl.lua b/Classes/CalcSectionControl.lua index bce8f7bd..e7e7aa35 100644 --- a/Classes/CalcSectionControl.lua +++ b/Classes/CalcSectionControl.lua @@ -133,6 +133,14 @@ function CalcSectionClass:UpdatePos() end end +function CalcSectionClass:FormatVal(val, p) + if main.showThousandsCalcs then + return formatNumSep(tostring(round(val, p))) + else + return round(val, p) + end +end + function CalcSectionClass:FormatStr(str, actor, colData) str = str:gsub("{output:([%a%.:]+)}", function(c) local ns, var = c:match("^(%a+)%.(%a+)$") @@ -145,9 +153,9 @@ function CalcSectionClass:FormatStr(str, actor, colData) str = str:gsub("{(%d+):output:([%a%.:]+)}", function(p, c) local ns, var = c:match("^(%a+)%.(%a+)$") if ns then - return formatRound(actor.output[ns] and actor.output[ns][var] or 0, tonumber(p)) + return self:FormatVal(actor.output[ns] and actor.output[ns][var] or 0, tonumber(p)) else - return formatRound(actor.output[c] or 0, tonumber(p)) + return self:FormatVal(actor.output[c] or 0, tonumber(p)) end end) str = str:gsub("{(%d+):mod:(%d+)}", function(p, n) @@ -165,7 +173,7 @@ function CalcSectionClass:FormatStr(str, actor, colData) if sectionData.modType == "MORE" then modVal = (modVal - 1) * 100 end - return formatRound(modVal, tonumber(p)) + return self:FormatVal(modVal, tonumber(p)) end) return str end diff --git a/Classes/ConfigTab.lua b/Classes/ConfigTab.lua index 73096d4c..8ec30ec4 100644 --- a/Classes/ConfigTab.lua +++ b/Classes/ConfigTab.lua @@ -567,7 +567,7 @@ local ConfigTabClass = common.NewClass("ConfigTab", "UndoHandler", "ControlHost" -- Special control for game version selector self.controls.gameVersion = common.New("DropDownControl", {"TOPLEFT",self.sectionList[1],"TOPLEFT"}, 234, 0, 118, 16, gameVersionDropList, function(index, value) if value.version ~= build.targetVersion then - main:OpenConfirmPopup("Convert Build", "^xFF9922Warning:^7 Converting a build to a different game version may have side effects.\nFor example, if the passive tree has changed, then some passives may be deallocated.\nYou should create a backup copy of the build before proceeding.", "Convert to "..value.versionPretty, function() + main:OpenConfirmPopup("Convert Build", colorCodes.WARNING.."Warning:^7 Converting a build to a different game version may have side effects.\nFor example, if the passive tree has changed, then some passives may be deallocated.\nYou should create a backup copy of the build before proceeding.", "Convert to "..value.versionPretty, function() if build.unsaved then build:OpenSavePopup("VERSION", value.version) else diff --git a/Classes/ImportTab.lua b/Classes/ImportTab.lua index ee144725..ce31306e 100644 --- a/Classes/ImportTab.lua +++ b/Classes/ImportTab.lua @@ -14,12 +14,26 @@ local ImportTabClass = common.NewClass("ImportTab", "ControlHost", "Control", fu self.build = build - self.charImportMode = "GETACCOUNTNAME" + self.charImportMode = build.targetVersion == liveTargetVersion and "GETACCOUNTNAME" or "VERSIONWARNING" self.charImportStatus = "Idle" self.controls.sectionCharImport = common.New("SectionControl", {"TOPLEFT",self,"TOPLEFT"}, 10, 18, 600, 230, "Character Import") + self.controls.charImportVersionWarning = common.New("LabelControl", {"TOPLEFT",self.controls.sectionCharImport,"TOPLEFT"}, 6, 20, 0, 16, colorCodes.WARNING..[[ +Warning:^7 Characters may not import into this build correctly, +as the build's game version is different from the live game version. +Some passives may be deallocated, and some gems may not be recognised. +If possible, change the game version in the Configuration tab before importing.]]) + self.controls.charImportVersionWarning.shown = function() + return self.charImportMode == "VERSIONWARNING" + end + self.controls.charImportVersionWarningGo = common.New("ButtonControl", {"TOPLEFT",self.controls.charImportVersionWarning,"TOPLEFT"}, 0, 70, 80, 20, "Continue", function() + self.charImportMode = "GETACCOUNTNAME" + end) self.controls.charImportStatusLabel = common.New("LabelControl", {"TOPLEFT",self.controls.sectionCharImport,"TOPLEFT"}, 6, 14, 200, 16, function() return "^7Character import status: "..self.charImportStatus end) + self.controls.charImportStatusLabel.shown = function() + return self.charImportMode ~= "VERSIONWARNING" + end -- Stage: input account name self.controls.accountNameHeader = common.New("LabelControl", {"TOPLEFT",self.controls.sectionCharImport,"TOPLEFT"}, 6, 40, 200, 16, "^7To start importing a character, enter the character's account name:") @@ -207,7 +221,7 @@ You can get this from your web browser's cookies while logged into the Path of E end self.controls.importCodeGo = common.New("ButtonControl", {"TOPLEFT",self.controls.importCodeMode,"BOTTOMLEFT"}, 0, 8, 60, 20, "Import", function() if self.controls.importCodeMode.selIndex == 1 then - main:OpenConfirmPopup("Build Import", "^xFF9922Warning:^7 Importing to the current build will erase ALL existing data for this build.", "Import", function() + main:OpenConfirmPopup("Build Import", colorCodes.WARNING.."Warning:^7 Importing to the current build will erase ALL existing data for this build.", "Import", function() self.build:Shutdown() self.build:Init(self.build.dbFileName, self.build.buildName, self.importCodeXML) self.build.viewMode = "TREE" diff --git a/Classes/SkillsTab.lua b/Classes/SkillsTab.lua index 744ca10c..26c8fdb6 100644 --- a/Classes/SkillsTab.lua +++ b/Classes/SkillsTab.lua @@ -421,7 +421,7 @@ function SkillsTabClass:ProcessSocketGroup(socketGroup) end end gem.skillId = gem.grantedEffect and gem.grantedEffect.id - if gem.grantedEffect.unsupported then + if gem.grantedEffect and gem.grantedEffect.unsupported then gem.errMsg = gem.nameSpec.." is not supported yet" gem.grantedEffect = nil end diff --git a/Data/Global.lua b/Data/Global.lua index 41c1f2da..8e2cec5f 100644 --- a/Data/Global.lua +++ b/Data/Global.lua @@ -14,6 +14,7 @@ colorCodes = { CRAFTED = "^xB8DAF1", CUSTOM = "^x5CF0BB", UNSUPPORTED = "^xF05050", + WARNING = "^xFF9922", FIRE = "^xD02020", COLD = "^x60A0E7", LIGHTNING = "^xFFD700", diff --git a/Export/skills.lua b/Export/skills.lua index db276162..c17c311a 100644 --- a/Export/skills.lua +++ b/Export/skills.lua @@ -437,10 +437,12 @@ directiveTable.mods = function(state, args, out) state.gem = nil end -for _, name in pairs({"act_str","act_dex","act_int","other",--[["minion","spectre",]]"sup_str","sup_dex","sup_int"}) do +for _, name in pairs({"act_str","act_dex","act_int","other","minion","spectre","sup_str","sup_dex","sup_int"}) do processTemplateFile("Skills/"..name, directiveTable) end -os.execute("xcopy Skills\\*.lua ..\\Data\\3_0\\Skills\\ /Y /Q") +os.execute("xcopy Skills\\act_*.lua ..\\Data\\3_0\\Skills\\ /Y /Q") +os.execute("xcopy Skills\\sup_*.lua ..\\Data\\3_0\\Skills\\ /Y /Q") +os.execute("xcopy Skills\\other.lua ..\\Data\\3_0\\Skills\\ /Y /Q") print("Skill data exported.") \ No newline at end of file diff --git a/Modules/Build.lua b/Modules/Build.lua index d01aa13f..b1212ab0 100644 --- a/Modules/Build.lua +++ b/Modules/Build.lua @@ -640,6 +640,9 @@ function buildMode:OnFrame(inputEvents) self.calcsTab:BuildOutput() self:RefreshStatList() end + if main.showThousandsSidebar ~= self.lastShowThousandsSidebar then + self:RefreshStatList() + end -- Update contents of main skill dropdowns self:RefreshSkillSelectControls(self.controls, self.mainSocketGroup, "") @@ -905,6 +908,18 @@ function buildMode:RefreshSkillSelectControls(controls, mainGroup, suffix) end end +function buildMode:FormatStat(statData, statVal) + local val = statVal * ((statData.pc or statData.mod) and 100 or 1) - (statData.mod and 100 or 0) + local color = (statVal >= 0 and "^7" or colorCodes.NEGATIVE) + local valStr = s_format("%"..statData.fmt, val) + if main.showThousandsSidebar then + return color..formatNumSep(valStr) + else + return color..valStr + end + self.lastShowThousandsSidebar = main.showThousandsSidebar +end + -- Add stat list for given actor function buildMode:AddDisplayStatList(statList, actor) local statBoxList = self.controls.statBox.list @@ -916,7 +931,7 @@ function buildMode:AddDisplayStatList(statList, actor) t_insert(statBoxList, { height = 16, "^7"..statData.label..":", - string.format("%s%"..statData.fmt, statVal >= 0 and "^7" or colorCodes.NEGATIVE, statVal * ((statData.pc or statData.mod) and 100 or 1) - (statData.mod and 100 or 0)) + self:FormatStat(statData, statVal), }) end end diff --git a/Modules/Common.lua b/Modules/Common.lua index 2114cd8e..b894126d 100644 --- a/Modules/Common.lua +++ b/Modules/Common.lua @@ -221,35 +221,11 @@ function round(val, dec) end end --- Formats 1234.56 -> "1,234.5" [dec=1] -function formatNumSep(val, dec) - dec = dec or 0 - val = val or 0 - local neg = val < 0 - val = m_floor(m_abs(val * 10 ^ dec) + 0.5) - local str = string.reverse(s_format("%.0f", val)) - if #str < (dec + 1) then - str = str .. string.rep("0", dec + 1 - #str) - end - local ret = "" - local pDec, pThou = dec, 3 - for ci = 1, #str do - local c = str:sub(ci, ci) - ret = c .. ret - if pDec > 0 then - pDec = pDec - 1 - if pDec == 0 then - ret = "." .. ret - end - else - pThou = pThou - 1 - if pThou == 0 and ci < #str then - ret = "," .. ret - pThou = 3 - end - end - end - return (neg and "-" or "") .. ret +-- Formats "1234.56" -> "1,234.5" +function formatNumSep(str) + return str:gsub("(%d*)(%d%.?)", function(s, e) + return s:reverse():gsub("(%d%d)(%d)","%1,%2"):reverse()..e + end) end function getFormatNumSep(dec) return function(val) diff --git a/Modules/Main.lua b/Modules/Main.lua index 37a737ae..571b6476 100644 --- a/Modules/Main.lua +++ b/Modules/Main.lua @@ -17,6 +17,7 @@ local m_cos = math.cos local m_pi = math.pi defaultTargetVersion = "2_6" +liveTargetVersion = "2_6" targetVersionList = { "2_6", "3_0" } LoadModule("Modules/Common") @@ -420,6 +421,8 @@ function main:LoadSettings() if node.attrib.nodePowerTheme then self.nodePowerTheme = node.attrib.nodePowerTheme end + self.showThousandsSidebar = node.attrib.showThousandsSidebar == "true" + self.showThousandsCalcs = node.attrib.showThousandsCalcs == "true" end end end @@ -455,6 +458,8 @@ function main:SaveSettings() proxyURL = launch.proxyURL, buildPath = (self.buildPath ~= self.defaultBuildPath and self.buildPath or nil), nodePowerTheme = self.nodePowerTheme, + showThousandsSidebar = tostring(self.showThousandsSidebar), + showThousandsCalcs = tostring(self.showThousandsCalcs), } }) local res, errMsg = common.xml.SaveXMLFile(setXML, self.userPath.."Settings.xml") if not res then @@ -492,7 +497,18 @@ function main:OpenOptionsPopup() controls.nodePowerThemeLabel = common.New("LabelControl", {"RIGHT",controls.nodePowerTheme,"LEFT"}, -4, 0, 0, 16, "^7Node Power colours:") controls.nodePowerTheme.tooltip = "Changes the colour scheme used for the node power display on the passive tree." controls.nodePowerTheme:SelByValue(self.nodePowerTheme, "theme") + controls.thousandsLabel = common.New("LabelControl", {"TOPRIGHT",nil,"TOPLEFT"}, 200, 94, 0, 16, "^7Show thousands separators in:") + controls.thousandsSidebar = common.New("CheckBoxControl", {"TOPLEFT",nil,"TOPLEFT"}, 270, 92, 20, "Sidebar:", function(state) + self.showThousandsSidebar = state + end) + controls.thousandsSidebar.state = self.showThousandsSidebar + controls.thousandsCalcs = common.New("CheckBoxControl", {"TOPLEFT",nil,"TOPLEFT"}, 370, 92, 20, "Calcs tab:", function(state) + self.showThousandsCalcs = state + end) + controls.thousandsCalcs.state = self.showThousandsCalcs local initialNodePowerTheme = self.nodePowerTheme + local initialThousandsSidebar = self.showThousandsSidebar + local initialThousandsCalcs = self.showThousandsCalcs controls.save = common.New("ButtonControl", nil, -45, 120, 80, 20, "Save", function() if controls.proxyURL.buf:match("%w") then launch.proxyURL = controls.proxyType.list[controls.proxyType.selIndex].scheme .. "://" .. controls.proxyURL.buf @@ -514,6 +530,8 @@ function main:OpenOptionsPopup() end) controls.cancel = common.New("ButtonControl", nil, 45, 120, 80, 20, "Cancel", function() self.nodePowerTheme = initialNodePowerTheme + self.showThousandsSidebar = initialThousandsSidebar + self.showThousandsCalcs = initialThousandsCalcs main:ClosePopup() end) self:OpenPopup(450, 150, "Options", controls, "save", nil, "cancel") diff --git a/PathOfBuilding.sln b/PathOfBuilding.sln index 2c897422..92dc59e1 100644 --- a/PathOfBuilding.sln +++ b/PathOfBuilding.sln @@ -81,6 +81,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{F2327651-CAA5-4DA0-91DB-EFA5E0E07A51}" ProjectSection(SolutionItems) = preProject Data\Global.lua = Data\Global.lua + Data\Misc.lua = Data\Misc.lua Data\New.lua = Data\New.lua EndProjectSection EndProject diff --git a/README.md b/README.md index ff5dc65b..8ea05271 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,11 @@ If you'd like to help support the development of Path of Building, I have a [Pat ![ss3](https://cloud.githubusercontent.com/assets/19189971/18089780/f0ff234a-6f04-11e6-8c88-6193fe59a5c4.png) ## Changelog +### 1.4.25 - 2017/06/11 + * Added options to the Options dialog to show thousands separators in the sidebar or Calcs tab + * Fixed error that could result from importing a character into a 3.0 build + * A warning is now shown before importing a character into a 3.0 build + ### 1.4.24 - 2017/06/09 * Converting builds between game versions will now automatically update the names of gems that been renamed For 3.0 builds: diff --git a/changelog.txt b/changelog.txt index 4a5f90a6..9006ec3c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +VERSION[1.4.25][2017/06/11] + * Added options to the Options dialog to show thousands separators in the sidebar or Calcs tab + * Fixed error that could result from importing a character into a 3.0 build + * A warning is now shown before importing a character into a 3.0 build VERSION[1.4.24][2017/06/09] * Converting builds between game versions will now automatically update the names of gems that been renamed For 3.0 builds: diff --git a/manifest.xml b/manifest.xml index 84a4b600..822b4f44 100644 --- a/manifest.xml +++ b/manifest.xml @@ -1,27 +1,27 @@ - + - + - + - + - + @@ -42,12 +42,12 @@ - + - + @@ -60,10 +60,10 @@ - + - + @@ -72,7 +72,7 @@ - +