Skip to content

Commit 542e7fb

Browse files
committed
refactor to include help button
1 parent 17d7b00 commit 542e7fb

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

src/Modules/Main.lua

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ end
518518

519519
function main:LoadSettings(ignoreBuild)
520520
local setXML, errMsg = common.xml.LoadXMLFile(self.userPath.."Settings.xml")
521+
self:OpenOneDriveErrPopup(self.userPath.."Settings.xml")
521522
if errMsg and errMsg:match(".*file returns nil") then
522523
self:OpenOneDriveErrPopup(self.userPath.."Settings.xml")
523524
return true
@@ -1565,16 +1566,28 @@ function main:OpenNewFolderPopup(path, onClose)
15651566
main:OpenPopup(370, 100, "New Folder", controls, "create", "edit", "cancel")
15661567
end
15671568

1568-
---Shows a OneDrive-specific error popup
1569+
---Shows a OneDrive-specific read error popup with a help button that opens a browser to PoB's GitHub wiki.
15691570
function main:OpenOneDriveErrPopup(fileName)
1570-
if fileName and fileName ~= "" then
1571-
fileName = "'"..fileName.."'"
1572-
else
1573-
fileName = ""
1574-
end
1575-
ConPrintf("Error: OneDrive: file unreadable: %s", fileName)
1576-
self:OpenMessagePopup(" Cannot read file ", "\nMake sure OneDrive is running then restart "..APP_NAME.." and try again.\n\n"..fileName)
1571+
ConPrintf("Error: OneDrive: file unreadable: %s", fileName or "?")
1572+
fileName = fileName and "\n\n'"..fileName.."'" or ""
1573+
local title = " Cannot read file "
1574+
local msg = "\nMake sure OneDrive is running then restart "..APP_NAME.." and try again."..fileName
1575+
local url = "https://github.com/PathOfBuildingCommunity/PathOfBuilding/wiki/OneDrive"
15771576
self.saveSettingsOnExit = false
1577+
local controls = { }
1578+
local numMsgLines = 0
1579+
for line in string.gmatch(msg .. "\n", "([^\n]*)\n") do
1580+
t_insert(controls, new("LabelControl", nil, {0, 20 + numMsgLines * 16, 0, 16}, line))
1581+
numMsgLines = numMsgLines + 1
1582+
end
1583+
controls.help = new("ButtonControl", nil, {-55, 40 + numMsgLines * 16, 80, 20}, "Help (web)", function()
1584+
OpenURL(url)
1585+
end)
1586+
controls.help.tooltipText = url
1587+
controls.close = new("ButtonControl", nil, {55, 40 + numMsgLines * 16, 80, 20}, "Ok", function()
1588+
main:ClosePopup()
1589+
end)
1590+
return self:OpenPopup(m_max(DrawStringWidth(16, "VAR", msg) + 30, 190), 70 + numMsgLines * 16, title, controls, "close")
15781591
end
15791592

15801593
function main:SetWindowTitleSubtext(subtext)

0 commit comments

Comments
 (0)