From 2d644d6d029e40f61a8ef6cb5b5c873b797dac2f Mon Sep 17 00:00:00 2001 From: ppoelzl <33464174+ppoelzl@users.noreply.github.com> Date: Mon, 9 Nov 2020 18:18:59 +0100 Subject: [PATCH] Remove legacy data module --- Classes/Item.lua | 2 +- Classes/ItemSetListControl.lua | 3 +-- Classes/SharedItemListControl.lua | 31 ++++++++++------------------ Classes/SharedItemSetListControl.lua | 15 ++++++-------- Data/Generated.lua | 4 ++-- Modules/Build.lua | 6 +++--- Modules/ConfigOptions.lua | 2 +- Modules/Data.lua | 8 ------- Modules/Main.lua | 22 ++++++++------------ Modules/ModParser.lua | 10 ++++----- 10 files changed, 39 insertions(+), 64 deletions(-) diff --git a/Classes/Item.lua b/Classes/Item.lua index 04c71eee..1e2923de 100644 --- a/Classes/Item.lua +++ b/Classes/Item.lua @@ -63,7 +63,7 @@ end -- Parse raw item data and extract item name, base type, quality, and modifiers function ItemClass:ParseRaw(raw) self.raw = raw - local verData = data[liveTargetVersion] + local verData = data self.name = "?" self.rarity = "UNIQUE" self.quality = nil diff --git a/Classes/ItemSetListControl.lua b/Classes/ItemSetListControl.lua index c38e8088..2a96f6c5 100644 --- a/Classes/ItemSetListControl.lua +++ b/Classes/ItemSetListControl.lua @@ -93,8 +93,7 @@ function ItemSetListClass:ReceiveDrag(type, value, source) if type == "SharedItemList" then local itemSet = self.itemsTab:NewItemSet() itemSet.title = value.title - for slotName, verItem in pairs(value.slots) do - local item = verItem[self.itemsTab.build.targetVersion] + for slotName, item in pairs(value.slots) do local newItem = new("Item", item.raw) newItem:NormaliseQuality() self.itemsTab:AddItem(newItem, true) diff --git a/Classes/SharedItemListControl.lua b/Classes/SharedItemListControl.lua index 75ec00f7..73fedcbf 100644 --- a/Classes/SharedItemListControl.lua +++ b/Classes/SharedItemListControl.lua @@ -21,58 +21,49 @@ local SharedItemListClass = newClass("SharedItemListControl", "ListControl", fun end end) -function SharedItemListClass:GetRowValue(column, index, verItem) - local item = verItem[self.itemsTab.build.targetVersion] +function SharedItemListClass:GetRowValue(column, index, item) if column == 1 then return colorCodes[item.rarity] .. item.name end end -function SharedItemListClass:AddValueTooltip(tooltip, index, verItem) +function SharedItemListClass:AddValueTooltip(tooltip, index, item) if main.popups[1] then tooltip:Clear() return end - local item = verItem[self.itemsTab.build.targetVersion] if tooltip:CheckForUpdate(item, IsKeyDown("SHIFT"), launch.devModeAlt, self.itemsTab.build.outputRevision) then self.itemsTab:AddItemTooltip(tooltip, item) end end -function SharedItemListClass:GetDragValue(index, verItem) - local item = verItem[self.itemsTab.build.targetVersion] +function SharedItemListClass:GetDragValue(index, item) return "Item", item end function SharedItemListClass:ReceiveDrag(type, value, source) if type == "Item" then - local verItem = { raw = value:BuildRaw() } - for _, targetVersion in ipairs(targetVersionList) do - local newItem = new("Item", verItem.raw) - if not value.id then - newItem:NormaliseQuality() - end - verItem[targetVersion] = newItem + local rawItem = { raw = value:BuildRaw() } + local newItem = new("Item", rawItem.raw) + if not value.id then + newItem:NormaliseQuality() end - t_insert(self.list, self.selDragIndex or #self.list, verItem) + t_insert(self.list, self.selDragIndex or #self.list, newItem) end end -function SharedItemListClass:OnSelClick(index, verItem, doubleClick) - local item = verItem[self.itemsTab.build.targetVersion] +function SharedItemListClass:OnSelClick(index, item, doubleClick) if doubleClick then self.itemsTab:CreateDisplayItemFromRaw(item.raw, true) self.selDragging = false end end -function SharedItemListClass:OnSelCopy(index, verItem) - local item = verItem[self.itemsTab.build.targetVersion] +function SharedItemListClass:OnSelCopy(index, item) Copy(item:BuildRaw():gsub("\n","\r\n")) end -function SharedItemListClass:OnSelDelete(index, verItem) - local item = verItem[self.itemsTab.build.targetVersion] +function SharedItemListClass:OnSelDelete(index, item) main:OpenConfirmPopup("Delete Item", "Are you sure you want to remove '"..item.name.."' from the shared item list?", "Delete", function() t_remove(self.list, index) self.selIndex = nil diff --git a/Classes/SharedItemSetListControl.lua b/Classes/SharedItemSetListControl.lua index 32b12bf5..005b7c99 100644 --- a/Classes/SharedItemSetListControl.lua +++ b/Classes/SharedItemSetListControl.lua @@ -55,7 +55,7 @@ function SharedItemSetListClass:AddValueTooltip(tooltip, index, sharedItemSet) for _, slot in ipairs(self.itemsTab.orderedSlots) do if not slot.nodeId then local slotName = slot.slotName - local item = sharedItemSet.slots[slotName] and sharedItemSet.slots[slotName][self.itemsTab.build.targetVersion] + local item = sharedItemSet.slots[slotName] if item then tooltip:AddLine(16, s_format("^7%s: %s%s", self.itemsTab.slots[slotName].label, colorCodes[item.rarity], item.name)) end @@ -81,15 +81,12 @@ function SharedItemSetListClass:ReceiveDrag(type, value, source) end if slot.selItemId ~= 0 then local item = self.itemsTab.items[slot.selItemId] - local verItem = { raw = item:BuildRaw() } - for _, targetVersion in ipairs(targetVersionList) do - local newItem = new("Item", verItem.raw) - if not value.id then - newItem:NormaliseQuality() - end - verItem[targetVersion] = newItem + local rawItem = { raw = item:BuildRaw() } + local newItem = new("Item", rawItem.raw) + if not value.id then + newItem:NormaliseQuality() end - sharedItemList.slots[slotName] = verItem + sharedItemList.slots[slotName] = newItem end end end diff --git a/Data/Generated.lua b/Data/Generated.lua index ff70b7a8..eca431b9 100644 --- a/Data/Generated.lua +++ b/Data/Generated.lua @@ -17,7 +17,7 @@ local megalomaniac = { "Added Small Passive Skills grant Nothing", } local notables = { } -for name in pairs(data["3_0"].clusterJewels.notableSortOrder) do +for name in pairs(data.clusterJewels.notableSortOrder) do table.insert(notables, name) end table.sort(notables) @@ -51,7 +51,7 @@ local excludedGems = { "Item Quantity", } local gems = { } -for _, gemData in pairs(data["3_0"].gems) do +for _, gemData in pairs(data.gems) do local grantedEffect = gemData.grantedEffect if grantedEffect.support and not (grantedEffect.plusVersionOf) and not isValueInArray(excludedGems, grantedEffect.name) then table.insert(gems, grantedEffect.name) diff --git a/Modules/Build.lua b/Modules/Build.lua index e0a5246b..13bdc67f 100644 --- a/Modules/Build.lua +++ b/Modules/Build.lua @@ -545,7 +545,7 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild) end -- Initialise build components - self.data = data[self.targetVersion] + self.data = data self.latestTree = main.tree[self.targetVersionData.latestTreeVersion] self.importTab = new("ImportTab", self) self.notesTab = new("NotesTab", self) @@ -668,7 +668,7 @@ function buildMode:CloseBuild() end function buildMode:Load(xml, fileName) - self.targetVersion = data[xml.attrib.targetVersion] and xml.attrib.targetVersion or defaultTargetVersion + self.targetVersion = xml.attrib.targetVersion or defaultTargetVersion if xml.attrib.viewMode then self.viewMode = xml.attrib.viewMode end @@ -680,7 +680,7 @@ function buildMode:Load(xml, fileName) wipeTable(self.spectreList) for _, child in ipairs(xml) do if child.elem == "Spectre" then - if child.attrib.id and data[self.targetVersion].minions[child.attrib.id] then + if child.attrib.id and data.minions[child.attrib.id] then t_insert(self.spectreList, child.attrib.id) end end diff --git a/Modules/ConfigOptions.lua b/Modules/ConfigOptions.lua index 97741e79..9a85a701 100644 --- a/Modules/ConfigOptions.lua +++ b/Modules/ConfigOptions.lua @@ -13,7 +13,7 @@ return { { var = "resistancePenalty", type = "list", label = "Resistance penalty:", list = {{val=0,label="None"},{val=-30,label="Act 5 (-30%)"},{val=nil,label="Act 10 (-60%)"}} }, { var = "enemyLevel", type = "count", label = "Enemy Level:", tooltip = "This overrides the default enemy level used to estimate your hit and evade chances.\nThe default level is your character level, capped at 84, which is the same value\nused in-game to calculate the stats on the character sheet." }, { var = "enemyHit", type = "count", label = "Enemy Hit Damage:", tooltip = "This overrides the default damage amount used to estimate your damage reduction from armour.\nThe default is 1.5 times the enemy's base damage, which is the same value\nused in-game to calculate the estimate shown on the character sheet." }, - { var = "detonateDeadCorpseLife", type = "count", label = "Enemy Corpse Life:", tooltip = "Sets the maximum life of the target corpse for Detonate Dead and similar skills.\nFor reference, a level 70 monster has "..data["3_0"].monsterLifeTable[70].." base life, and a level 80 monster has "..data["3_0"].monsterLifeTable[80]..".", apply = function(val, modList, enemyModList) + { var = "detonateDeadCorpseLife", type = "count", label = "Enemy Corpse Life:", tooltip = "Sets the maximum life of the target corpse for Detonate Dead and similar skills.\nFor reference, a level 70 monster has "..data.monsterLifeTable[70].." base life, and a level 80 monster has "..data.monsterLifeTable[80]..".", apply = function(val, modList, enemyModList) modList:NewMod("SkillData", "LIST", { key = "corpseLife", value = val }, "Config") end }, { var = "conditionStationary", type = "count", label = "Are you stationary?", ifCond = "Stationary", diff --git a/Modules/Data.lua b/Modules/Data.lua index 89c51ac1..b5c576fb 100644 --- a/Modules/Data.lua +++ b/Modules/Data.lua @@ -281,14 +281,6 @@ data.misc = { -- magic numbers PurposefulHarbingerMaxBuffPercent = 40, } ---------------------------- --- Version-specific Data -- ---------------------------- - -local targetVersion = liveTargetVersion -local verData = setmetatable({ }, { __index = data }) -data[targetVersion] = verData - -- Misc data tables LoadModule("Data/Misc", data) diff --git a/Modules/Main.lua b/Modules/Main.lua index 1e8cc45f..6e1b728e 100644 --- a/Modules/Main.lua +++ b/Modules/Main.lua @@ -86,7 +86,7 @@ function main:Init() end end self.rareDB = { list = { } } - for _, raw in pairs(data[liveTargetVersion].rares) do + for _, raw in pairs(data.rares) do local newItem = new("Item", "Rarity: Rare\n"..raw) if newItem.base then newItem:NormaliseQuality() @@ -416,30 +416,26 @@ function main:LoadSettings() elseif node.elem == "SharedItems" then for _, child in ipairs(node) do if child.elem == "Item" then - local verItem = { raw = "" } + local rawItem = { raw = "" } for _, subChild in ipairs(child) do if type(subChild) == "string" then - verItem.raw = subChild + rawItem.raw = subChild end end - for _, targetVersion in ipairs(targetVersionList) do - verItem[targetVersion] = new("Item", verItem.raw) - end - t_insert(self.sharedItemList, verItem) + local newItem = new("Item", rawItem.raw) + t_insert(self.sharedItemList, newItem) elseif child.elem == "ItemSet" then local sharedItemSet = { title = child.attrib.title, slots = { } } for _, grandChild in ipairs(child) do if grandChild.elem == "Item" then - local verItem = { raw = "" } + local rawItem = { raw = "" } for _, subChild in ipairs(grandChild) do if type(subChild) == "string" then - verItem.raw = subChild + rawItem.raw = subChild end end - for _, targetVersion in ipairs(targetVersionList) do - verItem[targetVersion] = new("Item", verItem.raw) - end - sharedItemSet.slots[grandChild.attrib.slotName] = verItem + local newItem = new("Item", rawItem.raw) + sharedItemSet.slots[grandChild.attrib.slotName] = newItem end end t_insert(self.sharedItemSetList, sharedItemSet) diff --git a/Modules/ModParser.lua b/Modules/ModParser.lua index a5625e30..5e5cf669 100644 --- a/Modules/ModParser.lua +++ b/Modules/ModParser.lua @@ -1267,7 +1267,7 @@ end local gemIdLookup = { ["power charge on critical strike"] = "SupportPowerChargeOnCrit", } -for name, grantedEffect in pairs(data["3_0"].skills) do +for name, grantedEffect in pairs(data.skills) do if not grantedEffect.hidden or grantedEffect.fromItem then gemIdLookup[grantedEffect.name:lower()] = grantedEffect.id end @@ -2697,7 +2697,7 @@ local skillNameList = { [" corpse cremation " ] = { tag = { type = "SkillName", skillName = "Cremation" } }, -- Sigh. } local preSkillNameList = { } -for gemId, gemData in pairs(data["3_0"].gems) do +for gemId, gemData in pairs(data.gems) do local grantedEffect = gemData.grantedEffect if not grantedEffect.hidden and not grantedEffect.support then local skillName = grantedEffect.name @@ -3034,15 +3034,15 @@ end -- Generate list of cluster jewel skills local clusterJewelSkills = {} -for baseName, jewel in pairs(data["3_0"].clusterJewels.jewels) do +for baseName, jewel in pairs(data.clusterJewels.jewels) do for skillId, skill in pairs(jewel.skills) do clusterJewelSkills[table.concat(skill.enchant, " "):lower()] = { mod("JewelData", "LIST", { key = "clusterJewelSkill", value = skillId }) } end end -for notable in pairs(data["3_0"].clusterJewels.notableSortOrder) do +for notable in pairs(data.clusterJewels.notableSortOrder) do clusterJewelSkills["1 added passive skill is "..notable:lower()] = { mod("ClusterJewelNotable", "LIST", notable) } end -for _, keystone in ipairs(data["3_0"].clusterJewels.keystones) do +for _, keystone in ipairs(data.clusterJewels.keystones) do clusterJewelSkills["adds "..keystone:lower()] = { mod("JewelData", "LIST", { key = "clusterJewelKeystone", value = keystone }) } end