@@ -106,6 +106,7 @@ function main:Init()
106106 self .POESESSID = " "
107107 -- self.showPublicBuilds = true
108108 self .showFlavourText = true
109+ self .errorReadingSettings = false
109110
110111 if self .userPath then
111112 self :ChangeUserPath (self .userPath , ignoreBuild )
@@ -506,9 +507,16 @@ function main:CallMode(func, ...)
506507end
507508
508509function main :LoadSettings (ignoreBuild )
510+ if self .errorReadingSettings then
511+ return true
512+ end
509513 local setXML , errMsg = common .xml .LoadXMLFile (self .userPath .. " Settings.xml" )
510- if errMsg and not errMsg :match (" .*No such file or directory" ) then
511- ConPrintf (" Error: '%s'" , errMsg )
514+ if errMsg and errMsg :match (" .*file returns nil" ) then
515+ self .errorReadingSettings = true
516+ self :OpenCloudErrorPopup (self .userPath .. " Settings.xml" )
517+ return true
518+ elseif errMsg and not errMsg :match (" .*No such file or directory" ) then
519+ self .errorReadingSettings = true
512520 launch :ShowErrMsg (" ^1" .. errMsg )
513521 return true
514522 end
@@ -649,9 +657,16 @@ function main:LoadSettings(ignoreBuild)
649657end
650658
651659function main :LoadSharedItems ()
660+ if self .errorReadingSettings then
661+ return true
662+ end
652663 local setXML , errMsg = common .xml .LoadXMLFile (self .userPath .. " Settings.xml" )
653- if errMsg and not errMsg :match (" .*No such file or directory" ) then
654- ConPrintf (" Error: '%s'" , errMsg )
664+ if errMsg and errMsg :match (" .*file returns nil" ) then
665+ self .errorReadingSettings = true
666+ self :OpenCloudErrorPopup (self .userPath .. " Settings.xml" )
667+ return true
668+ elseif errMsg and not errMsg :match (" .*No such file or directory" ) then
669+ self .errorReadingSettings = true
655670 launch :ShowErrMsg (" ^1" .. errMsg )
656671 return true
657672 end
@@ -697,6 +712,9 @@ function main:LoadSharedItems()
697712end
698713
699714function main :SaveSettings ()
715+ if self .errorReadingSettings then
716+ return
717+ end
700718 local setXML = { elem = " PathOfBuilding2" }
701719 local mode = { elem = " Mode" , attrib = { mode = self .mode } }
702720 for _ , val in ipairs ({ self :CallMode (" GetArgs" ) }) do
@@ -1546,6 +1564,35 @@ function main:OpenNewFolderPopup(path, onClose)
15461564 main :OpenPopup (370 , 100 , " New Folder" , controls , " create" , " edit" , " cancel" )
15471565end
15481566
1567+ -- Show an error popup if a file cannot be read due to cloud provider unavailability.
1568+ -- Help button opens a URL to PoB's GitHub wiki.
1569+ function main :OpenCloudErrorPopup (fileName )
1570+ local provider , _ , status = GetCloudProvider (fileName )
1571+ ConPrintf (' ^1Error: file offline "%s" provider: "%s" status: "%s"' , fileName or " ?" , provider , status )
1572+ fileName = fileName and " \n\n ^8'" .. fileName .. " '" or " "
1573+ local version = " ^8v" .. launch .versionNumber .. (launch .versionBranch and " " .. launch .versionBranch or " " ).. (launch .devMode and " (dev)" or " " )
1574+ local title = " ^1Error "
1575+ provider = provider or " your cloud provider"
1576+ local statusText = tostring (status ) or " nil"
1577+ local msg = " \n ^7Cannot read file.\n\n Make sure " .. provider .. " is running then restart " .. APP_NAME .. " and try again." ..
1578+ fileName .. " \n status: " .. statusText .. " \n\n " .. version
1579+ local url = " https://github.com/PathOfBuildingCommunity/PathOfBuilding/wiki/CloudError"
1580+ local controls = { }
1581+ local numMsgLines = 0
1582+ for line in string.gmatch (msg .. " \n " , " ([^\n ]*)\n " ) do
1583+ t_insert (controls , new (" LabelControl" , nil , {0 , 20 + numMsgLines * 16 , 0 , 16 }, line ))
1584+ numMsgLines = numMsgLines + 1
1585+ end
1586+ controls .help = new (" ButtonControl" , nil , {- 55 , 40 + numMsgLines * 16 , 80 , 20 }, " Help (web)" , function ()
1587+ OpenURL (url )
1588+ end )
1589+ controls .help .tooltipText = url
1590+ controls .close = new (" ButtonControl" , nil , {55 , 40 + numMsgLines * 16 , 80 , 20 }, " Ok" , function ()
1591+ main :ClosePopup ()
1592+ end )
1593+ return self :OpenPopup (m_max (DrawStringWidth (16 , " VAR" , msg ) + 30 , 190 ), 70 + numMsgLines * 16 , title , controls , " close" )
1594+ end
1595+
15491596function main :SetWindowTitleSubtext (subtext )
15501597 if not subtext or not self .showTitlebarName then
15511598 SetWindowTitle (APP_NAME )
0 commit comments