Mercurial > wow > hansgar_and_franzok_assist
comparison Libs/DF/fw.lua @ 29:5da06cb420d4
- framework update.
| author | Tercioo |
|---|---|
| date | Sat, 02 Jan 2016 13:33:05 -0200 |
| parents | 7523376ecaa3 |
| children | d1963bd45219 |
comparison
equal
deleted
inserted
replaced
| 28:7523376ecaa3 | 29:5da06cb420d4 |
|---|---|
| 1 | 1 |
| 2 local dversion = 13 | 2 local dversion = 15 |
| 3 local major, minor = "DetailsFramework-1.0", dversion | 3 local major, minor = "DetailsFramework-1.0", dversion |
| 4 local DF, oldminor = LibStub:NewLibrary (major, minor) | 4 local DF, oldminor = LibStub:NewLibrary (major, minor) |
| 5 | 5 |
| 6 if (not DF) then | 6 if (not DF) then |
| 7 DetailsFrameworkCanLoad = false | 7 DetailsFrameworkCanLoad = false |
| 9 end | 9 end |
| 10 | 10 |
| 11 DetailsFrameworkCanLoad = true | 11 DetailsFrameworkCanLoad = true |
| 12 local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0") | 12 local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0") |
| 13 | 13 |
| 14 local _ | |
| 14 local _type = type | 15 local _type = type |
| 15 local _unpack = unpack | 16 local _unpack = unpack |
| 16 local _ | |
| 17 local upper = string.upper | 17 local upper = string.upper |
| 18 | 18 |
| 19 DF.LabelNameCounter = 1 | 19 --> will always give a very random name for our widgets |
| 20 DF.PictureNameCounter = 1 | 20 local init_counter = math.random (1, 1000000) |
| 21 DF.BarNameCounter = 1 | 21 |
| 22 DF.DropDownCounter = 1 | 22 DF.LabelNameCounter = DF.LabelNameCounter or init_counter |
| 23 DF.PanelCounter = 1 | 23 DF.PictureNameCounter = DF.PictureNameCounter or init_counter |
| 24 DF.ButtonCounter = 1 | 24 DF.BarNameCounter = DF.BarNameCounter or init_counter |
| 25 DF.SliderCounter = 1 | 25 DF.DropDownCounter = DF.DropDownCounter or init_counter |
| 26 DF.SplitBarCounter = 1 | 26 DF.PanelCounter = DF.PanelCounter or init_counter |
| 27 DF.SimplePanelCounter = DF.SimplePanelCounter or init_counter | |
| 28 DF.ButtonCounter = DF.ButtonCounter or init_counter | |
| 29 DF.SliderCounter = DF.SliderCounter or init_counter | |
| 30 DF.SwitchCounter = DF.SwitchCounter or init_counter | |
| 31 DF.SplitBarCounter = DF.SplitBarCounter or init_counter | |
| 27 | 32 |
| 28 DF.FrameWorkVersion = tostring (dversion) | 33 DF.FrameWorkVersion = tostring (dversion) |
| 29 function DF:PrintVersion() | 34 function DF:PrintVersion() |
| 30 print ("Details! Framework Version:", DF.FrameWorkVersion) | 35 print ("Details! Framework Version:", DF.FrameWorkVersion) |
| 31 end | 36 end |
| 32 | 37 |
| 33 LibStub:GetLibrary("AceTimer-3.0"):Embed (DF) | 38 LibStub:GetLibrary("AceTimer-3.0"):Embed (DF) |
| 34 | 39 |
| 40 --> get the working folder | |
| 35 do | 41 do |
| 36 local path = string.match (debugstack (1, 1, 0), "AddOns\\(.+)fw.lua") | 42 local path = string.match (debugstack (1, 1, 0), "AddOns\\(.+)fw.lua") |
| 37 if (path) then | 43 if (path) then |
| 38 DF.folder = "Interface\\AddOns\\" .. path | 44 DF.folder = "Interface\\AddOns\\" .. path |
| 39 else | 45 else |
| 40 DF.folder = "" | 46 --> if not found, try to use the last valid one |
| 47 DF.folder = DF.folder or "" | |
| 41 end | 48 end |
| 42 end | 49 end |
| 43 | 50 |
| 44 DF.debug = false | 51 DF.debug = false |
| 45 | 52 |
| 92 "NewSpecialLuaEditorEntry", | 99 "NewSpecialLuaEditorEntry", |
| 93 "ShowPromptPanel", | 100 "ShowPromptPanel", |
| 94 "ShowTextPromptPanel", | 101 "ShowTextPromptPanel", |
| 95 "www_icons", | 102 "www_icons", |
| 96 "GetTemplate", | 103 "GetTemplate", |
| 104 "InstallTemplate", | |
| 97 "GetFrameworkFolder", | 105 "GetFrameworkFolder", |
| 106 "ShowPanicWarning", | |
| 98 } | 107 } |
| 99 | 108 |
| 100 DF.table = {} | 109 DF.table = {} |
| 101 | 110 |
| 102 function DF:GetFrameworkFolder() | 111 function DF:GetFrameworkFolder() |
| 865 thumbwidth = 16, | 874 thumbwidth = 16, |
| 866 thumbheight = 14, | 875 thumbheight = 14, |
| 867 thumbcolor = {0, 0, 0, 0.5}, | 876 thumbcolor = {0, 0, 0, 0.5}, |
| 868 } | 877 } |
| 869 | 878 |
| 870 function DF:GetTemplate (type, template_name) | 879 function DF:InstallTemplate (widget_type, template_name, template) |
| 880 widget_type = string.lower (widget_type) | |
| 881 | |
| 871 local template_table | 882 local template_table |
| 872 if (type == "font") then | 883 if (widget_type == "font") then |
| 873 template_table = DF.font_templates | 884 template_table = DF.font_templates |
| 874 elseif (type == "dropdown") then | 885 elseif (widget_type == "dropdown") then |
| 875 template_table = DF.dropdown_templates | 886 template_table = DF.dropdown_templates |
| 876 elseif (type == "button") then | 887 elseif (widget_type == "button") then |
| 877 template_table = DF.button_templates | 888 template_table = DF.button_templates |
| 878 elseif (type == "switch") then | 889 elseif (widget_type == "switch") then |
| 879 template_table = DF.switch_templates | 890 template_table = DF.switch_templates |
| 880 elseif (type == "slider") then | 891 elseif (widget_type == "slider") then |
| 892 template_table = DF.slider_templates | |
| 893 end | |
| 894 | |
| 895 template_table [template_name] = template | |
| 896 | |
| 897 return template | |
| 898 end | |
| 899 | |
| 900 function DF:GetTemplate (widget_type, template_name) | |
| 901 widget_type = string.lower (widget_type) | |
| 902 | |
| 903 local template_table | |
| 904 if (widget_type == "font") then | |
| 905 template_table = DF.font_templates | |
| 906 elseif (widget_type == "dropdown") then | |
| 907 template_table = DF.dropdown_templates | |
| 908 elseif (widget_type == "button") then | |
| 909 template_table = DF.button_templates | |
| 910 elseif (widget_type == "switch") then | |
| 911 template_table = DF.switch_templates | |
| 912 elseif (widget_type == "slider") then | |
| 881 template_table = DF.slider_templates | 913 template_table = DF.slider_templates |
| 882 end | 914 end |
| 883 return template_table [template_name] | 915 return template_table [template_name] |
| 884 end | 916 end |
| 885 | 917 |
