@@ -37,8 +37,8 @@ local ImportTabClass = newClass("ImportTab", "ControlHost", "Control", function(
3737 self .controls .accountNameHeader .shown = function ()
3838 return self .charImportMode == " GETACCOUNTNAME"
3939 end
40- self .controls .accountRealm = new (" DropDownControl" , {" TOPLEFT" ,self .controls .accountNameHeader ," BOTTOMLEFT" }, {0 , 4 , 60 , 20 }, realmList )
41- self .controls .accountRealm :SelByValue ( main .lastRealm or " PC" , " id" )
40+ self .controls .accountRealm = new (" DropDownControl" , {" TOPLEFT" ,self .controls .accountNameHeader ," BOTTOMLEFT" }, {0 , 4 , 60 , 20 }, realmList )
41+ self .controls .accountRealm :SelByValue (main .lastRealm or " PC" , " id" )
4242 self .controls .accountName = new (" EditControl" , {" LEFT" ,self .controls .accountRealm ," RIGHT" }, {8 , 0 , 200 , 20 }, main .lastAccountName or " " , nil , " %c" , nil , nil , nil , nil , true )
4343 self .controls .accountName .pasteFilter = function (text )
4444 return text :gsub (" ." , function (c )
369369
370370function ImportTabClass :Load (xml , fileName )
371371 self .lastRealm = xml .attrib .lastRealm
372- self .controls .accountRealm :SelByValue ( self .lastRealm or main .lastRealm or " PC" , " id" )
372+ self .controls .accountRealm :SelByValue (self .lastRealm or main .lastRealm or " PC" , " id" )
373+ self .lastLeague = xml .attrib .lastLeague
374+ self .controls .charSelectLeague :SelByValue (self .lastLeague or " Standard" , " id" )
373375 self .lastAccountHash = xml .attrib .lastAccountHash
374376 self .importLink = xml .attrib .importLink
375377 self .controls .enablePartyExportBuffs .state = xml .attrib .exportParty == " true"
387389function ImportTabClass :Save (xml )
388390 xml .attrib = {
389391 lastRealm = self .lastRealm ,
392+ lastLeague = self .lastLeague ,
390393 lastAccountHash = self .lastAccountHash ,
391394 lastCharacterHash = self .lastCharacterHash ,
392395 exportParty = tostring (self .controls .enablePartyExportBuffs .state ),
@@ -414,6 +417,23 @@ function ImportTabClass:Draw(viewPort, inputEvents)
414417end
415418
416419function ImportTabClass :DownloadCharacterList ()
420+ function FindMatchingStandardLeague (league )
421+ -- Find a Standard league name for a given league name
422+ -- Reference https://api.pathofexile.com/league?realm=pc
423+ if string.find (league , " Hardcore" ) then
424+ return " Hardcore"
425+ elseif string.find (league , " HC SSF" ) then
426+ -- includes Ruthless "HC SSF R "
427+ return " SSF Hardcore"
428+ elseif string.find (league , " SSF" ) then
429+ -- Any non HardCore SSF's - includes Ruthless "SSF R "
430+ return " SSF Standard"
431+ else
432+ -- normal league and ruthless league (Sanctum, Ruthless Sanctum)
433+ return " Standard"
434+ end
435+ end
436+
417437 self .charImportMode = " DOWNLOADCHARLIST"
418438 self .charImportStatus = " Retrieving character list..."
419439 local realm = realmList [self .controls .accountRealm .selIndex ]
@@ -488,6 +508,7 @@ function ImportTabClass:DownloadCharacterList()
488508 end
489509 end
490510 table.sort (leagueList )
511+ charSelectLeague = self .controls .charSelectLeague
491512 wipeTable (self .controls .charSelectLeague .list )
492513 for _ , league in ipairs (leagueList ) do
493514 t_insert (self .controls .charSelectLeague .list , {
@@ -498,8 +519,25 @@ function ImportTabClass:DownloadCharacterList()
498519 t_insert (self .controls .charSelectLeague .list , {
499520 label = " All" ,
500521 })
501- if self .controls .charSelectLeague .selIndex > # self .controls .charSelectLeague .list then
502- self .controls .charSelectLeague .selIndex = 1
522+ -- set the league combo to the last used if possible, used for previously imported characters
523+ if self .lastLeague then
524+ charSelectLeague :SelByValue (self .lastLeague , " league" )
525+ -- check that it worked
526+ if charSelectLeague :GetSelValueByKey (" league" ) ~= self .lastLeague then
527+ -- League maybe over, Character will be in standard
528+ standardLeagueName = FindMatchingStandardLeague (self .lastLeague )
529+ self .controls .charSelectLeague :SelByValue (standardLeagueName , " league" )
530+ if charSelectLeague :GetSelValueByKey (" league" ) ~= standardLeagueName then
531+ -- give up and select the first entry. Ruthless mode may not have Standard equivalents
532+ charSelectLeague .selIndex = 1
533+ else
534+ self .lastLeague = standardLeagueName
535+ end
536+ end
537+ else
538+ if self .controls .charSelectLeague .selIndex > # self .controls .charSelectLeague .list then
539+ self .controls .charSelectLeague .selIndex = 1
540+ end
503541 end
504542 self .lastCharList = charList
505543 self :BuildCharacterList (self .controls .charSelectLeague :GetSelValueByKey (" league" ))
@@ -606,6 +644,9 @@ function ImportTabClass:DownloadPassiveTree()
606644 return
607645 end
608646 self .lastCharacterHash = common .sha1 (charData .name )
647+ if not self .lastLeague then
648+ self .lastLeague = charSelectLeague :GetSelValueByKey (" league" )
649+ end
609650 self :ImportPassiveTreeAndJewels (response .body , charData )
610651 end , sessionID and { header = " Cookie: POESESSID=" .. sessionID })
611652end
@@ -628,6 +669,9 @@ function ImportTabClass:DownloadItems()
628669 return
629670 end
630671 self .lastCharacterHash = common .sha1 (charData .name )
672+ if not self .lastLeague then
673+ self .lastLeague = charSelectLeague :GetSelValueByKey (" league" )
674+ end
631675 self :ImportItemsAndSkills (response .body )
632676 end , sessionID and { header = " Cookie: POESESSID=" .. sessionID })
633677end
@@ -711,6 +755,9 @@ function ImportTabClass:ImportPassiveTreeAndJewels(json, charData)
711755 self .build .treeTab :SetActiveSpec (self .build .treeTab .activeSpec )
712756 self .build .spec :BuildClusterJewelGraphs ()
713757 self .build .spec :AddUndoState ()
758+ if not self .lastLeague then
759+ self .lastLeague = charSelectLeague :GetSelValueByKey (" league" )
760+ end
714761 self .build .characterLevel = charData .level
715762 self .build .characterLevelAutoMode = false
716763 self .build .configTab :UpdateLevel ()
0 commit comments