Mercurial > wow > askmrrobot
comparison Export.lua @ 81:0515882856f1 v38
updated for 7.0
| author | yellowfive |
|---|---|
| date | Tue, 19 Jul 2016 10:05:32 -0700 |
| parents | 69db1c3025ac |
| children | 8914581c912f |
comparison
equal
deleted
inserted
replaced
| 80:8f235b016212 | 81:0515882856f1 |
|---|---|
| 51 lbl2:SetPoint("TOPLEFT", lbl.frame, "BOTTOMLEFT", 0, -15) | 51 lbl2:SetPoint("TOPLEFT", lbl.frame, "BOTTOMLEFT", 0, -15) |
| 52 | 52 |
| 53 lbl = createLabel(panel, L.ExportSplash3, 650) | 53 lbl = createLabel(panel, L.ExportSplash3, 650) |
| 54 lbl:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.Text)) | 54 lbl:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.Text)) |
| 55 lbl:SetPoint("TOPLEFT", lbl2.frame, "BOTTOMLEFT", 0, -15) | 55 lbl:SetPoint("TOPLEFT", lbl2.frame, "BOTTOMLEFT", 0, -15) |
| 56 | |
| 57 lbl2 = createLabel(panel, L.ExportSplash4, 650) | |
| 58 lbl2:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.Text)) | |
| 59 lbl2:SetPoint("TOPLEFT", lbl.frame, "BOTTOMLEFT", 0, -15) | |
| 56 | 60 |
| 57 local btn = AceGUI:Create("AmrUiButton") | 61 local btn = AceGUI:Create("AmrUiButton") |
| 58 btn:SetText(L.ExportSplashClose) | 62 btn:SetText(L.ExportSplashClose) |
| 59 btn:SetBackgroundColor(Amr.Colors.Green) | 63 btn:SetBackgroundColor(Amr.Colors.Green) |
| 60 btn:SetFont(Amr.CreateFont("Bold", 16, Amr.Colors.White)) | 64 btn:SetFont(Amr.CreateFont("Bold", 16, Amr.Colors.White)) |
| 79 lbl:SetPoint("TOPLEFT", lbl2.frame, "BOTTOMLEFT", 0, -10) | 83 lbl:SetPoint("TOPLEFT", lbl2.frame, "BOTTOMLEFT", 0, -10) |
| 80 | 84 |
| 81 lbl2 = createLabel(container, L.ExportHelp3) | 85 lbl2 = createLabel(container, L.ExportHelp3) |
| 82 lbl2:SetPoint("TOPLEFT", lbl.frame, "BOTTOMLEFT", 0, -10) | 86 lbl2:SetPoint("TOPLEFT", lbl.frame, "BOTTOMLEFT", 0, -10) |
| 83 | 87 |
| 84 lbl = createLabel(container, L.ExportHelp4) | |
| 85 lbl:SetPoint("TOPLEFT", lbl2.frame, "BOTTOMLEFT", 0, -10) | |
| 86 | |
| 87 _txt = AceGUI:Create("AmrUiTextarea") | 88 _txt = AceGUI:Create("AmrUiTextarea") |
| 88 _txt:SetWidth(800) | 89 _txt:SetWidth(800) |
| 89 _txt:SetHeight(300) | 90 _txt:SetHeight(300) |
| 90 _txt:SetPoint("TOP", lbl.frame, "BOTTOM", 0, -20) | 91 _txt:SetPoint("TOP", lbl2.frame, "BOTTOM", 0, -20) |
| 91 _txt:SetFont(Amr.CreateFont("Regular", 12, Amr.Colors.Text)) | 92 _txt:SetFont(Amr.CreateFont("Regular", 12, Amr.Colors.Text)) |
| 92 _txt:SetCallback("OnTextChanged", onTextChanged) | 93 _txt:SetCallback("OnTextChanged", onTextChanged) |
| 93 container:AddChild(_txt) | 94 container:AddChild(_txt) |
| 94 | 95 |
| 95 local data = self:ExportCharacter() | 96 local data = self:ExportCharacter() |
| 149 end | 150 end |
| 150 end | 151 end |
| 151 | 152 |
| 152 -- get the player's current gear and save it, also returns the data from GetPlayerData for efficiency | 153 -- get the player's current gear and save it, also returns the data from GetPlayerData for efficiency |
| 153 local function getEquipped() | 154 local function getEquipped() |
| 154 local data = Amr.Serializer:GetPlayerData(Amr.db.char.SubSpecs) | 155 local data = Amr.Serializer:GetPlayerData() |
| 155 local spec = GetActiveSpecGroup() | 156 local spec = GetSpecialization() |
| 156 | 157 |
| 157 Amr.db.char.Equipped[spec] = data.Equipped[spec] | 158 Amr.db.char.Equipped[spec] = data.Equipped[spec] |
| 158 Amr.db.char.SubSpecs[spec] = data.SubSpecs[spec] | |
| 159 | 159 |
| 160 return data | 160 return data |
| 161 end | 161 end |
| 162 | 162 |
| 163 local function scanBags() | 163 local function scanBags() |
| 239 end | 239 end |
| 240 | 240 |
| 241 return reps | 241 return reps |
| 242 end | 242 end |
| 243 | 243 |
| 244 local function scanTalents() | |
| 245 local specPos = GetSpecialization() | |
| 246 if not specPos or specPos < 1 or specPos > 4 then return end | |
| 247 | |
| 248 local talentInfo = {} | |
| 249 local maxTiers = 7 | |
| 250 for tier = 1, maxTiers do | |
| 251 for col = 1, 3 do | |
| 252 local id, name, _, _, _, spellId, _, t, c, selected = GetTalentInfoBySpecialization(specPos, tier, col) | |
| 253 if selected then | |
| 254 talentInfo[tier] = col | |
| 255 end | |
| 256 end | |
| 257 end | |
| 258 | |
| 259 local str = "" | |
| 260 for i = 1, maxTiers do | |
| 261 if talentInfo[i] then | |
| 262 str = str .. talentInfo[i] | |
| 263 else | |
| 264 str = str .. '0' | |
| 265 end | |
| 266 end | |
| 267 | |
| 268 Amr.db.char.Talents[specPos] = str | |
| 269 end | |
| 270 | |
| 271 local function scanArtifact() | |
| 272 -- TODO: when they put in a real API for this, switch to that instead of using UI methods directly | |
| 273 local powers = C_ArtifactUI.GetPowers() | |
| 274 if not powers then return end | |
| 275 | |
| 276 local powerRanks = {} | |
| 277 for k,v in pairs(powers) do | |
| 278 local spellId, cost, rank, maxRank, relicRank = C_ArtifactUI.GetPowerInfo(v) | |
| 279 if rank - relicRank > 0 then | |
| 280 powerRanks[v] = rank - relicRank | |
| 281 end | |
| 282 end | |
| 283 | |
| 284 local relicInfo = {} | |
| 285 for i = 1,3 do | |
| 286 local _, _, _, link = C_ArtifactUI.GetRelicInfo(i); | |
| 287 table.insert(relicInfo, link or "") | |
| 288 end | |
| 289 | |
| 290 -- make sure that the artifact UI didn't get closed while we were reading it, GetPowers seems to return nil unless it is open | |
| 291 powers = C_ArtifactUI.GetPowers() | |
| 292 if not powers then return end | |
| 293 | |
| 294 local spec = GetSpecialization() | |
| 295 Amr.db.char.Artifacts[spec] = { | |
| 296 Powers = powerRanks, | |
| 297 Relics = relicInfo | |
| 298 } | |
| 299 end | |
| 300 | |
| 244 -- Returns a data object containing all information about the current player needed for an export: | 301 -- Returns a data object containing all information about the current player needed for an export: |
| 245 -- gear, spec, reputations, bag, bank, and void storage items. | 302 -- gear, spec, reputations, bag, bank, and void storage items. |
| 246 function Amr:ExportCharacter() | 303 function Amr:ExportCharacter() |
| 247 | 304 |
| 248 local data = getEquipped() | 305 local data = getEquipped() |
| 249 scanBags() | 306 scanBags() |
| 250 | 307 |
| 251 -- get extra data that is not necessary for the base serializer, but that we add here for completeness | 308 -- scan current spec's talents just before exporting |
| 309 scanTalents() | |
| 310 | |
| 311 data.Talents = Amr.db.char.Talents | |
| 312 data.Artifacts = Amr.db.char.Artifacts | |
| 252 data.Equipped = Amr.db.char.Equipped | 313 data.Equipped = Amr.db.char.Equipped |
| 253 data.Reputations = getReputations() | 314 data.Reputations = getReputations() |
| 254 data.BagItems = Amr.db.char.BagItems | 315 data.BagItems = Amr.db.char.BagItems |
| 255 data.BankItems = Amr.db.char.BankItems | 316 data.BankItems = Amr.db.char.BankItems |
| 256 data.VoidItems = Amr.db.char.VoidItems | 317 data.VoidItems = Amr.db.char.VoidItems |
| 270 | 331 |
| 271 Amr:AddEventHandler("VOID_STORAGE_OPEN", scanVoid) | 332 Amr:AddEventHandler("VOID_STORAGE_OPEN", scanVoid) |
| 272 Amr:AddEventHandler("VOID_STORAGE_CONTENTS_UPDATE", scanVoid) | 333 Amr:AddEventHandler("VOID_STORAGE_CONTENTS_UPDATE", scanVoid) |
| 273 Amr:AddEventHandler("VOID_STORAGE_DEPOSIT_UPDATE", scanVoid) | 334 Amr:AddEventHandler("VOID_STORAGE_DEPOSIT_UPDATE", scanVoid) |
| 274 Amr:AddEventHandler("VOID_STORAGE_UPDATE", scanVoid) | 335 Amr:AddEventHandler("VOID_STORAGE_UPDATE", scanVoid) |
| 336 | |
| 337 Amr:AddEventHandler("PLAYER_TALENT_UPDATE", scanTalents) | |
| 338 Amr:AddEventHandler("ARTIFACT_UPDATE", scanArtifact) |
