@@ -112,6 +112,7 @@ function main:Init()
112112 self .POESESSID = " "
113113 self .showPublicBuilds = true
114114 self .showFlavourText = true
115+ self .errorReadingSettings = false
115116
116117 if not SetDPIScaleOverridePercent then SetDPIScaleOverridePercent = function (scale ) end end
117118
@@ -515,9 +516,16 @@ function main:CallMode(func, ...)
515516end
516517
517518function main :LoadSettings (ignoreBuild )
519+ if self .errorReadingSettings then
520+ return true
521+ end
518522 local setXML , errMsg = common .xml .LoadXMLFile (self .userPath .. " Settings.xml" )
519- if errMsg and not errMsg :match (" .*No such file or directory" ) then
520- ConPrintf (" Error: '%s'" , errMsg )
523+ if errMsg and errMsg :match (" .*file returns nil" ) then
524+ self .errorReadingSettings = true
525+ self :OpenCloudErrorPopup (self .userPath .. " Settings.xml" )
526+ return true
527+ elseif errMsg and not errMsg :match (" .*No such file or directory" ) then
528+ self .errorReadingSettings = true
521529 launch :ShowErrMsg (" ^1" .. errMsg )
522530 return true
523531 end
@@ -655,9 +663,16 @@ function main:LoadSettings(ignoreBuild)
655663end
656664
657665function main :LoadSharedItems ()
666+ if self .errorReadingSettings then
667+ return true
668+ end
658669 local setXML , errMsg = common .xml .LoadXMLFile (self .userPath .. " Settings.xml" )
659- if errMsg and not errMsg :match (" .*No such file or directory" ) then
660- ConPrintf (" Error: '%s'" , errMsg )
670+ if errMsg and errMsg :match (" .*file returns nil" ) then
671+ self .errorReadingSettings = true
672+ self :OpenCloudErrorPopup (self .userPath .. " Settings.xml" )
673+ return true
674+ elseif errMsg and not errMsg :match (" .*No such file or directory" ) then
675+ self .errorReadingSettings = true
661676 launch :ShowErrMsg (" ^1" .. errMsg )
662677 return true
663678 end
@@ -703,6 +718,9 @@ function main:LoadSharedItems()
703718end
704719
705720function main :SaveSettings ()
721+ if self .errorReadingSettings then
722+ return
723+ end
706724 local setXML = { elem = " PathOfBuilding" }
707725 local mode = { elem = " Mode" , attrib = { mode = self .mode } }
708726 for _ , val in ipairs ({ self :CallMode (" GetArgs" ) }) do
@@ -1553,6 +1571,35 @@ function main:OpenNewFolderPopup(path, onClose)
15531571 main :OpenPopup (370 , 100 , " New Folder" , controls , " create" , " edit" , " cancel" )
15541572end
15551573
1574+ -- Show an error popup if a file cannot be read due to cloud provider unavailability.
1575+ -- Help button opens a URL to PoB's GitHub wiki.
1576+ function main :OpenCloudErrorPopup (fileName )
1577+ local provider , _ , status = GetCloudProvider (fileName )
1578+ ConPrintf (' Error: file offline "%s" provider: "%s" status: "%s"' ,
1579+ fileName or " ?" , provider , status )
1580+ fileName = fileName and " \n\n ^8'" .. fileName .. " '" or " "
1581+ local pobVersion = " ^8v" .. launch .versionNumber .. (launch .versionBranch == " dev" and " (Dev)" or launch .versionBranch == " beta" and " (Beta)" or " " )
1582+ local title = " Error "
1583+ provider = provider or " your cloud provider"
1584+ local msg = " \n Cannot read file.\n\n Make sure " .. provider .. " is running then restart " .. APP_NAME .. " and try again." ..
1585+ fileName .. " \n\n " .. pobVersion
1586+ local url = " https://github.com/PathOfBuildingCommunity/PathOfBuilding/wiki/CloudError"
1587+ local controls = { }
1588+ local numMsgLines = 0
1589+ for line in string.gmatch (msg .. " \n " , " ([^\n ]*)\n " ) do
1590+ t_insert (controls , new (" LabelControl" , nil , {0 , 20 + numMsgLines * 16 , 0 , 16 }, line ))
1591+ numMsgLines = numMsgLines + 1
1592+ end
1593+ controls .help = new (" ButtonControl" , nil , {- 55 , 40 + numMsgLines * 16 , 80 , 20 }, " Help (web)" , function ()
1594+ OpenURL (url )
1595+ end )
1596+ controls .help .tooltipText = url
1597+ controls .close = new (" ButtonControl" , nil , {55 , 40 + numMsgLines * 16 , 80 , 20 }, " Ok" , function ()
1598+ main :ClosePopup ()
1599+ end )
1600+ return self :OpenPopup (m_max (DrawStringWidth (16 , " VAR" , msg ) + 30 , 190 ), 70 + numMsgLines * 16 , title , controls , " close" )
1601+ end
1602+
15561603function main :SetWindowTitleSubtext (subtext )
15571604 if not subtext or not self .showTitlebarName then
15581605 SetWindowTitle (APP_NAME )
0 commit comments