@@ -78,8 +78,8 @@ local ImportTabClass = newClass("ImportTab", "ControlHost", "Control", function(
7878 self .controls .accountNameHeader .shown = function ()
7979 return self .charImportMode == " GETACCOUNTNAME"
8080 end
81- self .controls .accountRealm = new (" DropDownControl" , {" TOPLEFT" ,self .controls .accountNameHeader ," BOTTOMLEFT" }, {0 , 4 , 60 , 20 }, realmList )
82- self .controls .accountRealm :SelByValue ( main .lastRealm or " PC" , " id" )
81+ self .controls .accountRealm = new (" DropDownControl" , {" TOPLEFT" ,self .controls .accountNameHeader ," BOTTOMLEFT" }, {0 , 4 , 60 , 20 }, realmList )
82+ self .controls .accountRealm :SelByValue (main .lastRealm or " PC" , " id" )
8383
8484 self .controls .accountNameGo = new (" ButtonControl" , {" LEFT" ,self .controls .accountNameHeader ," RIGHT" }, {8 , 0 , 60 , 20 }, " Start" , function ()
8585 self :DownloadCharacterList ()
364364
365365function ImportTabClass :Load (xml , fileName )
366366 self .lastRealm = xml .attrib .lastRealm
367- self .controls .accountRealm :SelByValue ( self .lastRealm or main .lastRealm or " PC" , " id" )
367+ self .controls .accountRealm :SelByValue (self .lastRealm or main .lastRealm or " PC" , " id" )
368+ self .lastLeague = xml .attrib .lastLeague
369+ self .controls .charSelectLeague :SelByValue (self .lastLeague or " Standard" , " id" )
368370 self .lastAccountHash = xml .attrib .lastAccountHash
369371 self .importLink = xml .attrib .importLink
370372 self .controls .enablePartyExportBuffs .state = xml .attrib .exportParty == " true"
382384function ImportTabClass :Save (xml )
383385 xml .attrib = {
384386 lastRealm = self .lastRealm ,
387+ lastLeague = self .lastLeague ,
385388 lastAccountHash = self .lastAccountHash ,
386389 lastCharacterHash = self .lastCharacterHash ,
387390 exportParty = tostring (self .controls .enablePartyExportBuffs .state ),
@@ -409,6 +412,23 @@ function ImportTabClass:Draw(viewPort, inputEvents)
409412end
410413
411414function ImportTabClass :DownloadCharacterList ()
415+ function FindMatchingStandardLeague (league )
416+ -- Find a Standard league name for a given league name
417+ -- Reference https://api.pathofexile.com/league?realm=pc
418+ if string.find (league , " Hardcore" ) then
419+ return " Hardcore"
420+ elseif string.find (league , " HC SSF" ) then
421+ -- includes Ruthless "HC SSF R "
422+ return " SSF Hardcore"
423+ elseif string.find (league , " SSF" ) then
424+ -- Any non HardCore SSF's - includes Ruthless "SSF R "
425+ return " SSF Standard"
426+ else
427+ -- normal league and ruthless league (Sanctum, Ruthless Sanctum)
428+ return " Standard"
429+ end
430+ end
431+
412432 self .charImportMode = " DOWNLOADCHARLIST"
413433 self .charImportStatus = " Retrieving character list..."
414434 local realm = realmList [self .controls .accountRealm .selIndex ]
@@ -470,6 +490,7 @@ function ImportTabClass:DownloadCharacterList()
470490 end
471491 end
472492 table.sort (leagueList )
493+ charSelectLeague = self .controls .charSelectLeague
473494 wipeTable (self .controls .charSelectLeague .list )
474495 for _ , league in ipairs (leagueList ) do
475496 t_insert (self .controls .charSelectLeague .list , {
@@ -480,8 +501,25 @@ function ImportTabClass:DownloadCharacterList()
480501 t_insert (self .controls .charSelectLeague .list , {
481502 label = " All" ,
482503 })
483- if self .controls .charSelectLeague .selIndex > # self .controls .charSelectLeague .list then
484- self .controls .charSelectLeague .selIndex = 1
504+ -- set the league combo to the last used if possible, used for previously imported characters
505+ if self .lastLeague then
506+ charSelectLeague :SelByValue (self .lastLeague , " league" )
507+ -- check that it worked
508+ if charSelectLeague :GetSelValueByKey (" league" ) ~= self .lastLeague then
509+ -- League maybe over, Character will be in standard
510+ local standardLeagueName = FindMatchingStandardLeague (self .lastLeague )
511+ self .controls .charSelectLeague :SelByValue (standardLeagueName , " league" )
512+ if charSelectLeague :GetSelValueByKey (" league" ) ~= standardLeagueName then
513+ -- give up and select the first entry. Ruthless mode may not have Standard equivalents
514+ charSelectLeague .selIndex = 1
515+ else
516+ self .lastLeague = standardLeagueName
517+ end
518+ end
519+ else
520+ if self .controls .charSelectLeague .selIndex > # self .controls .charSelectLeague .list then
521+ self .controls .charSelectLeague .selIndex = 1
522+ end
485523 end
486524 self .lastCharList = charList
487525 self :BuildCharacterList (self .controls .charSelectLeague :GetSelValueByKey (" league" ))
@@ -560,6 +598,9 @@ function ImportTabClass:DownloadCharacter(callback)
560598 return
561599 end
562600 self .lastCharacterHash = common .sha1 (charData .name )
601+ if not self .lastLeague then
602+ self .lastLeague = charSelectLeague :GetSelValueByKey (" league" )
603+ end
563604 -- local out = io.open("get-passive-skills.json", "w")
564605 -- out:write(json)
565606 -- out:close()
@@ -720,6 +761,9 @@ function ImportTabClass:ImportPassiveTreeAndJewels(charData)
720761
721762 self .build .spec :AddUndoState ()
722763 self :ImportQuestRewardConfig (charPassiveData .quest_stats )
764+ if not self .lastLeague then
765+ self .lastLeague = charSelectLeague :GetSelValueByKey (" league" )
766+ end
723767 self .build .characterLevel = charData .level
724768 self .build .characterLevelAutoMode = false
725769 self .build .configTab :UpdateLevel ()
0 commit comments