vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Guild Event Manager by Kiki of European Cho'gall (Alliance) |
||
3 | External module - By Kiki |
||
4 | ]] |
||
5 | |||
6 | |||
7 | --------------- Local variables --------------- |
||
8 | local GEM_EXTERNAL_CBFunc = nil; |
||
9 | |||
10 | --------------- Internal functions --------------- |
||
11 | |||
12 | |||
13 | |||
14 | --------------- From XML functions --------------- |
||
15 | local function GEMExternal_CheckValues(tab) |
||
16 | if(tab.name == nil or tab.name == "") |
||
17 | then |
||
18 | GEM_ChatPrint(GEM_TEXT_EXTERNAL_ERR_GIVE_NAME); |
||
19 | getglobal("GEMExternalFrame_Name"):SetFocus(); |
||
20 | return; |
||
21 | end |
||
22 | tab.name = string.upper(string.sub(tab.name,1,1)) .. string.sub(tab.name,2); |
||
23 | |||
24 | if(tab.level == nil) |
||
25 | then |
||
26 | GEM_ChatPrint(GEM_TEXT_EXTERNAL_ERR_GIVE_LEVEL); |
||
27 | getglobal("GEMExternalFrame_Level"):SetFocus(); |
||
28 | return; |
||
29 | end |
||
30 | if(tab.guild == nil) |
||
31 | then |
||
32 | tab.guild = ""; |
||
33 | end; |
||
34 | if(tab.comment == nil) |
||
35 | then |
||
36 | tab.comment = ""; |
||
37 | end; |
||
38 | |||
39 | GEM_ChatDebug(GEM_DEBUG_GLOBAL,"Adding external "..tab.name.." guild="..tab.guild.." level="..tab.level.." class="..tab.class.." comment="..tab.comment.." forcesub="..tab.forcesub); |
||
40 | if(GEM_EXTERNAL_CBFunc) |
||
41 | then |
||
42 | GEM_EXTERNAL_CBFunc(tab); |
||
43 | end |
||
44 | GEMExternalFrame_Name:SetText(""); |
||
45 | GEMExternalFrame_Guild:SetText(""); |
||
46 | GEMExternalFrame_Level:SetText(""); |
||
47 | GEMExternalFrame_Comment:SetText(""); |
||
48 | GEMExternalFrame_Forcesub:SetChecked(0); |
||
49 | GEMExternalFrame:Hide(); |
||
50 | end |
||
51 | |||
52 | function GEMExternalTarget_OnClick() |
||
53 | local tab = {}; |
||
54 | |||
55 | if(not UnitExists("target") or not UnitIsFriend("player","target") or not UnitIsPlayer("target")) |
||
56 | then |
||
57 | GEM_ChatPrint(GEM_TEXT_EXTERNAL_ERR_INVALID); |
||
58 | return; |
||
59 | end |
||
60 | |||
61 | local _,clas = UnitClass("target"); |
||
62 | tab.name = UnitName("target"); |
||
63 | tab.guild = GetGuildInfo("target"); |
||
64 | tab.level = UnitLevel("target"); |
||
65 | tab.class = clas; |
||
66 | tab.comment = string.gsub(getglobal("GEMExternalFrame_Comment"):GetText(),"[%c]"," "); |
||
67 | local forcesub = getglobal("GEMExternalFrame_Forcesub"):GetChecked(); |
||
68 | if(forcesub == nil) then forcesub = 0; end; |
||
69 | tab.forcesub = forcesub; |
||
70 | |||
71 | GEMExternal_CheckValues(tab); |
||
72 | end |
||
73 | |||
74 | function GEMExternalAdd_OnClick() |
||
75 | local tab = {} |
||
76 | tab.name = getglobal("GEMExternalFrame_Name"):GetText(); |
||
77 | tab.guild = getglobal("GEMExternalFrame_Guild"):GetText(); |
||
78 | local level = getglobal("GEMExternalFrame_Level"):GetText(); |
||
79 | tab.class = getglobal("GEMExternalClassDropDown").class; |
||
80 | tab.comment = string.gsub(getglobal("GEMExternalFrame_Comment"):GetText(),"[%c]"," "); |
||
81 | tab.level = tonumber(level,10); |
||
82 | local forcesub = getglobal("GEMExternalFrame_Forcesub"):GetChecked(); |
||
83 | if(forcesub == nil) then forcesub = 0; end; |
||
84 | tab.forcesub = forcesub; |
||
85 | |||
86 | GEMExternal_CheckValues(tab); |
||
87 | end |
||
88 | |||
89 | function GEMExternal_OnShow() |
||
90 | GEMExternalFrame_Name:SetFocus(); |
||
91 | end |
||
92 | |||
93 | function GEMExternalClassDropDown_OnShow() |
||
94 | getglobal("GEMExternalClassDropDown").class = "WARRIOR"; |
||
95 | UIDropDownMenu_Initialize(GEMExternalClassDropDown, GEMExternalClassDropDown_Init); |
||
96 | UIDropDownMenu_SetText(GEM_Classes["WARRIOR"], GEMExternalClassDropDown); |
||
97 | UIDropDownMenu_SetWidth(90, GEMExternalClassDropDown); |
||
98 | end |
||
99 | |||
100 | function GEMExternalClassDropDown_OnClick() |
||
101 | getglobal("GEMExternalClassDropDown").class = this.value; |
||
102 | UIDropDownMenu_SetText(GEM_Classes[this.value],GEMExternalClassDropDown); |
||
103 | end |
||
104 | |||
105 | function GEMExternalClassDropDown_Init() |
||
106 | for us,locale in GEM_Classes do |
||
107 | local info = { }; |
||
108 | info.text = locale; |
||
109 | info.value = us; |
||
110 | info.func = GEMExternalClassDropDown_OnClick; |
||
111 | UIDropDownMenu_AddButton(info); |
||
112 | end |
||
113 | end |
||
114 | |||
115 | |||
116 | --------------- GUI Exported functions --------------- |
||
117 | |||
118 | --[[ |
||
119 | function GEMExternal_Choose : |
||
120 | Opens the ExternalAdd frame |
||
121 | CBFunc : Function -- The CB function : void (*func)(infos) -- Called with the player (infos={name,guild,level,class}) |
||
122 | title : String -- Title of the window |
||
123 | -- |
||
124 | Returns false if ExternalAdd is already open, True otherwise |
||
125 | ]] |
||
126 | function GEMExternal_Choose(CBFunc,title,buttons) |
||
127 | if(GEMExternalFrame:IsVisible()) |
||
128 | then |
||
129 | return false; |
||
130 | end |
||
131 | GEM_EXTERNAL_CBFunc = CBFunc; |
||
132 | GEMExternalFrameTitle:SetText(title); |
||
133 | if(buttons[1]) |
||
134 | then |
||
135 | GEMExternalFrame_CommentString:Show(); |
||
136 | GEMExternalFrame_Comment:Show(); |
||
137 | else |
||
138 | GEMExternalFrame_CommentString:Hide(); |
||
139 | GEMExternalFrame_Comment:Hide(); |
||
140 | end |
||
141 | if(buttons[2]) |
||
142 | then |
||
143 | GEMExternalFrame_ForcesubString:Show(); |
||
144 | GEMExternalFrame_Forcesub:Show(); |
||
145 | else |
||
146 | GEMExternalFrame_ForcesubString:Hide(); |
||
147 | GEMExternalFrame_Forcesub:Hide(); |
||
148 | end |
||
149 | GEMExternalFrame:Show(); |
||
150 | return true; |
||
151 | end |
||
152 | |||
153 | -- /script GEMExternal_Choose(nil,"test",{}) |