diff --git a/tools/wowsimsexporter/WowSimsExporter/WowSimsExporter.lua b/tools/wowsimsexporter/WowSimsExporter/WowSimsExporter.lua index d7a3cd6e45..4d9b875b5d 100644 --- a/tools/wowsimsexporter/WowSimsExporter/WowSimsExporter.lua +++ b/tools/wowsimsexporter/WowSimsExporter/WowSimsExporter.lua @@ -71,32 +71,18 @@ end function WowSimsExporter:CreateGlyphEntry() local minor = {} local major = {} - - for t = 1, 6 do - - local enabled, glyphType, glyphTooltipIndex, glyphSpellID, icon = GetGlyphSocketInfo(t); - local link = GetGlyphLink(t); - - if(enabled) then - - local name, _ = string.match(link,"Glyph of .+]") - if(name) then - local formattedName = name:gsub('%]', '') - - if(glyphType == 1 ) then-- major - table.insert(major, formattedName) - else if(glyphType == 2 ) then -- minor - table.insert(minor, formattedName) - end + for t = 1, 6 do + local enabled, glyphType, glyphSpellID = GetGlyphSocketInfo(t) + if enabled and glyphSpellID then + local localizedName = GetSpellInfo(glyphSpellID) + if localizedName then + local t = glyphType == 1 and major or minor + table.insert(t, {["name"] = localizedName, ["spellID"] = glyphSpellID}) end - end self.Character.glyphs.major = major self.Character.glyphs.minor = minor - - end - -end + end end function WowSimsExporter:CreateProfessionEntry() diff --git a/ui/core/components/importers.ts b/ui/core/components/importers.ts index 5f7c49f562..89872d97d7 100644 --- a/ui/core/components/importers.ts +++ b/ui/core/components/importers.ts @@ -18,6 +18,7 @@ import { classGlyphsConfig, talentSpellIdsToTalentString } from '../talents/fact import { GlyphConfig } from '../talents/glyphs_picker'; import { BaseModal } from './base_modal'; import { buf2hex } from '../utils'; +import { JsonObject } from '@protobuf-ts/runtime'; export abstract class Importer extends BaseModal { protected readonly textElem: HTMLTextAreaElement; @@ -409,7 +410,7 @@ export class IndividualAddonImporter extends Importer { `; } - onImport(data: string) { + async onImport(data: string) { const importJson = JSON.parse(data); // Parse all the settings. @@ -431,10 +432,12 @@ export class IndividualAddonImporter extends Importer { }); const talentsStr = (importJson['talents'] as string) || ''; - const glyphsConfig = classGlyphsConfig[charClass]; - const majorGlyphIDs = (importJson['glyphs']['major'] as Array).map(glyphName => glyphNameToID(glyphName, glyphsConfig.majorGlyphs)); - const minorGlyphIDs = (importJson['glyphs']['minor'] as Array).map(glyphName => glyphNameToID(glyphName, glyphsConfig.minorGlyphs)); + + const db = await Database.get(); + const majorGlyphIDs = (importJson['glyphs']['major'] as Array).map(g => glyphToID(g, db, glyphsConfig.majorGlyphs)); + const minorGlyphIDs = (importJson['glyphs']['minor'] as Array).map(g => glyphToID(g, db, glyphsConfig.minorGlyphs)); + const glyphs = Glyphs.create({ major1: majorGlyphIDs[0] || 0, major2: majorGlyphIDs[1] || 0, @@ -469,3 +472,12 @@ function glyphNameToID(glyphName: string, glyphsConfig: Record): number { + if (typeof glyph === 'string') { + // Legacy version: AddOn exports Glyphs by name (string) only. Names must be in English. + return glyphNameToID(glyph, glyphsConfig); + } + // New version exports glyph information in a table that includes the name and the glyph spell ID. + return db.glyphSpellToItemId(glyph['spellID'] as number); +}