From 9e78940ddc91173b0dbdb1128696ccff3b037ee1 Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 6 Nov 2016 18:51:30 +0100 Subject: [PATCH] add info popup box --- modules/gui.lua | 4 ++++ pfUI.lua | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/modules/gui.lua b/modules/gui.lua index 53f31bd9..24579fd7 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -147,6 +147,10 @@ pfUI:RegisterModule("gui", function () pfUI.gitter:Hide() end + pfUI.info:ShowInfoBox("|cff33ffccUnlock Mode|r\ + This mode allows you to move frames by dragging them using the mouse cursor. Frames can be scaled by scrolling up and down.\ + To scale multiple frames at once (eg. raidframes), hold down the shift key while scrolling. Click into an empty space to go back to the pfUI menu.", 15, pfUI.gitter) + if pfUI.gitter:IsShown() then pfUI.gitter:Hide() pfUI.gui:Show() diff --git a/pfUI.lua b/pfUI.lua index decaaee4..3e2c3558 100644 --- a/pfUI.lua +++ b/pfUI.lua @@ -104,3 +104,60 @@ ScriptErrors:SetScript("OnShow", function(msg) end) pfUI.uf = CreateFrame("Frame",nil,UIParent) + +pfUI.info = CreateFrame("Button", "pfInfoBox", UIParent) +pfUI.info:Hide() + +pfUI.info.text = pfUI.info:CreateFontString("Status", "HIGH", "GameFontNormal") +pfUI.info.text:SetFont("Interface\\AddOns\\pfUI\\fonts\\arial.ttf", 14, "OUTLINE") +pfUI.info.text:ClearAllPoints() +pfUI.info.text:SetFontObject(GameFontWhite) + +pfUI.info.timeout = CreateFrame("StatusBar", nil, pfUI.info) +pfUI.info.timeout:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") +pfUI.info.timeout:SetStatusBarColor(.3,1,.8,1) + +function pfUI.info:ShowInfoBox(text, time, parent, height) + if not text then return end + if not time then time = 5 end + if not parent then parent = UIParent end + if not height then height = 100 end + + pfUI.info:SetParent(parent) + pfUI.info:ClearAllPoints() + pfUI.info.text:SetAllPoints(pfUI.info) + pfUI.info.text:SetText(text) + + pfUI.info:SetWidth(pfUI.info.text:GetStringWidth() + 50) + pfUI.info:SetHeight(height) + pfUI.info:SetBackdrop(pfUI.backdrop) + pfUI.info:SetBackdropColor(0,0,0,.75) + pfUI.info:SetPoint("TOP", 0, -25) + + pfUI.info.timeout:ClearAllPoints() + pfUI.info.timeout:SetPoint("TOPLEFT", pfUI.info, "TOPLEFT", 3, -3) + pfUI.info.timeout:SetPoint("TOPRIGHT", pfUI.info, "TOPRIGHT", -3, 3) + pfUI.info.timeout:SetHeight(2) + pfUI.info.timeout:SetMinMaxValues(0, time) + pfUI.info.timeout:SetValue(time) + + pfUI.info.duration = time + pfUI.info.lastshow = GetTime() + pfUI.info:Show() +end + +pfUI.info:SetScript("OnUpdate", function() + local time = pfUI.info.lastshow + pfUI.info.duration - GetTime() + pfUI.info.timeout:SetValue(time) + + if GetTime() > pfUI.info.lastshow + pfUI.info.duration then + pfUI.info:SetAlpha(pfUI.info:GetAlpha()-0.05) + end + + if pfUI.info:GetAlpha() <= 0.1 then + pfUI.info:Hide() + pfUI.info:SetAlpha(1) + end +end) + +pfUI.info:SetScript("OnClick", function() this:Hide() end)