comparison Libs/DF/panel.lua @ 29:5da06cb420d4

- framework update.
author Tercioo
date Sat, 02 Jan 2016 13:33:05 -0200
parents e16b1fc13935
children 7944c081e5b4
comparison
equal deleted inserted replaced
28:7523376ecaa3 29:5da06cb420d4
15 local loadstring = loadstring --> lua local 15 local loadstring = loadstring --> lua local
16 16
17 local cleanfunction = function() end 17 local cleanfunction = function() end
18 local PanelMetaFunctions = {} 18 local PanelMetaFunctions = {}
19 local APIFrameFunctions 19 local APIFrameFunctions
20
21 local simple_panel_counter = 1
22 20
23 ------------------------------------------------------------------------------------------------------------ 21 ------------------------------------------------------------------------------------------------------------
24 --> metatables 22 --> metatables
25 23
26 PanelMetaFunctions.__call = function (_table, value) 24 PanelMetaFunctions.__call = function (_table, value)
1431 DF.IconPickFrame.callback = callback or DF.IconPickFrame.emptyFunction 1429 DF.IconPickFrame.callback = callback or DF.IconPickFrame.emptyFunction
1432 DF.IconPickFrame.click_close = close_when_select 1430 DF.IconPickFrame.click_close = close_when_select
1433 1431
1434 end 1432 end
1435 1433
1436 local simple_panel_counter = 1 1434 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1435
1436 function DF:ShowPanicWarning (text)
1437 if (not DF.PanicWarningWindow) then
1438 DF.PanicWarningWindow = CreateFrame ("frame", "DetailsFrameworkPanicWarningWindow", UIParent)
1439 DF.PanicWarningWindow:SetHeight (80)
1440 DF.PanicWarningWindow:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
1441 DF.PanicWarningWindow:SetBackdropColor (1, 0, 0, 0.2)
1442 DF.PanicWarningWindow:SetPoint ("topleft", UIParent, "topleft", 0, -250)
1443 DF.PanicWarningWindow:SetPoint ("topright", UIParent, "topright", 0, -250)
1444
1445 DF.PanicWarningWindow.text = DF.PanicWarningWindow:CreateFontString (nil, "overlay", "GameFontNormal")
1446 DF.PanicWarningWindow.text:SetPoint ("center", DF.PanicWarningWindow, "center")
1447 DF.PanicWarningWindow.text:SetTextColor (1, 0.6, 0)
1448 end
1449
1450 DF.PanicWarningWindow.text:SetText (text)
1451 DF.PanicWarningWindow:Show()
1452 end
1453
1454 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1455
1456
1437 local simple_panel_mouse_down = function (self, button) 1457 local simple_panel_mouse_down = function (self, button)
1438 if (button == "RightButton") then 1458 if (button == "RightButton") then
1439 if (self.IsMoving) then 1459 if (self.IsMoving) then
1440 self.IsMoving = false 1460 self.IsMoving = false
1441 self:StopMovingOrSizing() 1461 self:StopMovingOrSizing()
1476 1496
1477 local no_options = {} 1497 local no_options = {}
1478 function DF:CreateSimplePanel (parent, w, h, title, name, panel_options) 1498 function DF:CreateSimplePanel (parent, w, h, title, name, panel_options)
1479 1499
1480 if (not name) then 1500 if (not name) then
1481 name = "DetailsFrameworkSimplePanel" .. simple_panel_counter 1501 name = "DetailsFrameworkSimplePanel" .. DF.SimplePanelCounter
1482 simple_panel_counter = simple_panel_counter + 1 1502 DF.SimplePanelCounter = DF.SimplePanelCounter + 1
1483 end 1503 end
1484 if (not parent) then 1504 if (not parent) then
1485 parent = UIParent 1505 parent = UIParent
1486 end 1506 end
1487 1507
1535 f:SetScript ("OnMouseDown", simple_panel_mouse_down) 1555 f:SetScript ("OnMouseDown", simple_panel_mouse_down)
1536 f:SetScript ("OnMouseUp", simple_panel_mouse_up) 1556 f:SetScript ("OnMouseUp", simple_panel_mouse_up)
1537 1557
1538 f.SetTitle = simple_panel_settitle 1558 f.SetTitle = simple_panel_settitle
1539 1559
1540 simple_panel_counter = simple_panel_counter + 1
1541
1542 return f 1560 return f
1543 end 1561 end
1544 1562
1545 local Panel1PxBackdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 64, 1563 local Panel1PxBackdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 64,
1546 edgeFile = DF.folder .. "border_3", edgeSize = 9, insets = {left = 2, right = 2, top = 3, bottom = 3}} 1564 edgeFile = DF.folder .. "border_3", edgeSize = 9, insets = {left = 2, right = 2, top = 3, bottom = 3}}
1811 1829
1812 local prompt = f:CreateFontString (nil, "overlay", "GameFontNormal") 1830 local prompt = f:CreateFontString (nil, "overlay", "GameFontNormal")
1813 prompt:SetPoint ("top", f, "top", 0, -15) 1831 prompt:SetPoint ("top", f, "top", 0, -15)
1814 prompt:SetJustifyH ("center") 1832 prompt:SetJustifyH ("center")
1815 f.prompt = prompt 1833 f.prompt = prompt
1816 1834
1817 local button_true = DF:CreateButton (f, nil, 60, 20, "Okey") 1835 local button_text_template = DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")
1836 local options_dropdown_template = DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
1837
1838 local button_true = DF:CreateButton (f, nil, 60, 20, "Okey", nil, nil, nil, nil, nil, nil, options_dropdown_template, button_text_template)
1818 button_true:SetPoint ("bottomleft", f, "bottomleft", 10, 5) 1839 button_true:SetPoint ("bottomleft", f, "bottomleft", 10, 5)
1819 f.button_true = button_true 1840 f.button_true = button_true
1820 1841
1821 local button_false = DF:CreateButton (f, function() f.textbox:ClearFocus(); f:Hide() end, 60, 20, "Cancel") 1842 local button_false = DF:CreateButton (f, function() f.textbox:ClearFocus(); f:Hide() end, 60, 20, "Cancel", nil, nil, nil, nil, nil, nil, options_dropdown_template, button_text_template)
1822 button_false:SetPoint ("bottomright", f, "bottomright", -10, 5) 1843 button_false:SetPoint ("bottomright", f, "bottomright", -10, 5)
1823 f.button_false = button_false 1844 f.button_false = button_false
1824 1845
1825 local textbox = DF:CreateTextEntry (f, function()end, 380, 20, "textbox", nil, nil, nil, nil) 1846 local textbox = DF:CreateTextEntry (f, function()end, 380, 20, "textbox", nil, nil, options_dropdown_template)
1826 textbox:SetPoint ("topleft", f, "topleft", 10, -45) 1847 textbox:SetPoint ("topleft", f, "topleft", 10, -45)
1848 f.EntryBox = textbox
1827 1849
1828 button_true:SetClickFunction (function() 1850 button_true:SetClickFunction (function()
1829 local my_func = button_true.true_function 1851 local my_func = button_true.true_function
1830 if (my_func) then 1852 if (my_func) then
1831 local okey, errormessage = pcall (my_func, textbox:GetText()) 1853 local okey, errormessage = pcall (my_func, textbox:GetText())
1841 DF.text_prompt_panel = f 1863 DF.text_prompt_panel = f
1842 end 1864 end
1843 1865
1844 DF.text_prompt_panel:Show() 1866 DF.text_prompt_panel:Show()
1845 1867
1868 DetailsFrameworkPrompt.EntryBox:SetText ("")
1846 DF.text_prompt_panel.prompt:SetText (message) 1869 DF.text_prompt_panel.prompt:SetText (message)
1847 DF.text_prompt_panel.button_true.true_function = callback 1870 DF.text_prompt_panel.button_true.true_function = callback
1848 DF.text_prompt_panel.textbox:SetText ("") 1871
1849 DF.text_prompt_panel.textbox:SetFocus (true) 1872 DF.text_prompt_panel.textbox:SetFocus (true)
1850 1873
1851 end 1874 end
1852 1875
1853 ------------------------------------------------------------------------------------------------------------------------------------------------ 1876 ------------------------------------------------------------------------------------------------------------------------------------------------