mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-30 19:19:59 +00:00
firstrun: simplify question dialog
This commit is contained in:
+23
-10
@@ -336,6 +336,19 @@ function pfUI.api.CreateQuestionDialog(text, yes, no, editbox)
|
||||
return
|
||||
end
|
||||
|
||||
local yes, no = yes, no
|
||||
local yescap, nocap = "Yes", "No"
|
||||
|
||||
if yes and type(yes) == "table" then
|
||||
yescap = yes[1]
|
||||
yes = yes[2]
|
||||
end
|
||||
|
||||
if no and type(no) == "table" then
|
||||
nocap = no[1]
|
||||
no = no[2]
|
||||
end
|
||||
|
||||
if not text then text = "Are you sure?" end
|
||||
|
||||
local border = tonumber(pfUI_config.appearance.border.default)
|
||||
@@ -355,7 +368,7 @@ function pfUI.api.CreateQuestionDialog(text, yes, no, editbox)
|
||||
question:SetScript("OnMouseUp",function()
|
||||
this:StopMovingOrSizing()
|
||||
end)
|
||||
pfUI.api.CreateBackdrop(question)
|
||||
pfUI.api.CreateBackdrop(question, nil, nil, .85)
|
||||
|
||||
-- text
|
||||
question.text = question:CreateFontString("Status", "LOW", "GameFontNormal")
|
||||
@@ -383,33 +396,33 @@ function pfUI.api.CreateQuestionDialog(text, yes, no, editbox)
|
||||
question.yes = CreateFrame("Button", "pfQuestionDialogYes", question, "UIPanelButtonTemplate")
|
||||
pfUI.api.SkinButton(question.yes)
|
||||
question.yes:SetWidth(100)
|
||||
question.yes:SetHeight(20)
|
||||
question.yes:SetText("Yes")
|
||||
question.yes:SetHeight(22)
|
||||
question.yes:SetText(yescap)
|
||||
question.yes:SetScript("OnClick", function()
|
||||
if yes then yes() end
|
||||
this:GetParent():Hide()
|
||||
end)
|
||||
|
||||
if question.input then
|
||||
question.yes:SetPoint("TOPLEFT", question.input, "BOTTOMLEFT", -border, -padding)
|
||||
question.yes:SetPoint("TOPRIGHT", question.input, "BOTTOM", -3*border, -padding)
|
||||
else
|
||||
question.yes:SetPoint("TOPLEFT", question.text, "BOTTOMLEFT", 0, -padding)
|
||||
question.yes:SetPoint("TOPRIGHT", question.text, "BOTTOM", -3*border, -padding)
|
||||
end
|
||||
|
||||
question.no = CreateFrame("Button", "pfQuestionDialogNo", question, "UIPanelButtonTemplate")
|
||||
pfUI.api.SkinButton(question.no)
|
||||
question.no:SetWidth(85)
|
||||
question.no:SetHeight(20)
|
||||
question.no:SetText("No")
|
||||
question.no:SetWidth(100)
|
||||
question.no:SetHeight(22)
|
||||
question.no:SetText(nocap)
|
||||
question.no:SetScript("OnClick", function()
|
||||
if no then no() end
|
||||
this:GetParent():Hide()
|
||||
end)
|
||||
|
||||
if question.input then
|
||||
question.no:SetPoint("TOPRIGHT", question.input, "BOTTOMRIGHT", border, -padding)
|
||||
question.no:SetPoint("TOPLEFT", question.input, "BOTTOM", 3*border, -padding)
|
||||
else
|
||||
question.no:SetPoint("TOPRIGHT", question.text, "BOTTOMRIGHT", 0, -padding)
|
||||
question.no:SetPoint("TOPLEFT", question.text, "BOTTOM", 3*border, -padding)
|
||||
end
|
||||
|
||||
question.close = CreateFrame("Button", "pfQuestionDialogClose", question)
|
||||
|
||||
+12
-5
@@ -24,6 +24,7 @@ pfUI:RegisterModule("firstrun", function ()
|
||||
"This will enable settings that can be found in the Interface section of your client.\n"..
|
||||
"Options like Buff Durations, Instant Quest Text, Auto Selfcast and others will be set.\n")
|
||||
|
||||
local all_yes = false
|
||||
function pfUI.firstrun:NextStep()
|
||||
if pfUI_init and next(pfUI_init) == nil then
|
||||
local yes = function()
|
||||
@@ -34,15 +35,16 @@ pfUI:RegisterModule("firstrun", function ()
|
||||
|
||||
local no = function()
|
||||
this:GetParent():Hide()
|
||||
pfUI_init["welcome"] = true
|
||||
all_yes = true
|
||||
pfUI.firstrun:NextStep()
|
||||
end
|
||||
|
||||
CreateQuestionDialog("Welcome to |cff33ffccpf|cffffffffUI|r!\n\n"..
|
||||
"I'm the first run wizzard that will guide you through some basic configuration.\n"..
|
||||
"You'll now be prompted for several questions. To get a default installation,\n"..
|
||||
"you might want to click \"Yes\" everywhere. A few settings are client settings\n"..
|
||||
"(e.g chat questions) so if you don't want to lose your chat configurations, you\n"..
|
||||
"should be careful with your choices.\n\n"..
|
||||
"Visit |cff33ffcchttp://shagu.org|r to check for the latest version.", yes, no)
|
||||
"If you're lazy, feel free to hit the \"Use Defaults\" button. If you whish to run this\n"..
|
||||
"dialog again, go to the settings and hit the \"Reset Firstrun\" button.\n\n"..
|
||||
"Visit |cff33ffcchttp://shagu.org|r to check for the latest version.", { "Customize", yes } , { "Use Defaults", no })
|
||||
return
|
||||
end
|
||||
|
||||
@@ -64,6 +66,11 @@ pfUI:RegisterModule("firstrun", function ()
|
||||
pfUI.firstrun:NextStep()
|
||||
end
|
||||
|
||||
if all_yes == true then
|
||||
yes()
|
||||
return
|
||||
end
|
||||
|
||||
if step.cmpnt and step.cmpnt == "edit" then
|
||||
CreateQuestionDialog(step.descr, yes, no, true)
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user