vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2  
3 Bhaldie Recommended Level UI Panel:
4 Helps you configure your Mod.
5  
6 Website: http://wow.kingofnothin.net/
7 Author: Bhaldie (bhaldiemoveIT@kingofnothin.net)
8  
9  
10 Contributors:
11 Pkp
12 - Some initial xml work.
13  
14 Trentin and Grayhoof
15 - I "borrowed" a lot of the techniques and some code used in the options
16 frame of MonkeyBuddy and ScrollingCombatText. It was such an excellent implementation
17 that I just had to use it.
18  
19 --]]
20  
21 -- define the dialog box for reseting config
22 StaticPopupDialogs["BRL_RESET_ALL"] = {
23 text = TEXT(BRL_RESET_ALL_TEXT),
24 button1 = TEXT(OKAY),
25 button2 = TEXT(CANCEL),
26 OnAccept = function()
27 BRL_Reset_Everything();
28 BRL_UI_Panel_Refresh();
29 end,
30 timeout = 0,
31 exclusive = 1
32 };
33 -- this array is used to init the check buttons
34 local BRL_CheckButtons = { };
35 BRL_CheckButtons[BRL_ZONE_INFO_ENABLE] = {
36 id = 1,
37 strVar = "zone_info_enable",
38 pSlashCommand = BRL_Zone_Info_Enable
39 };
40 BRL_CheckButtons[BRL_TOOLTIP_ENABLE] = {
41 id = 2,
42 strVar = "tooltip_enable",
43 pSlashCommand = BRL_Tooltip_Enable
44 };
45 BRL_CheckButtons[BRL_MAP_TEXT_ENABLE] = {
46 id = 3,
47 strVar = "map_text_enable",
48 pSlashCommand = BRL_Map_Text_Enable
49 };
50 BRL_CheckButtons[BRL_TOOLTIP_OFFSET_LEFT] = {
51 id = 4,
52 strVar = "tooltip_offset_left",
53 pSlashCommand = BRL_Tooltip_Offset_Left
54 };
55 BRL_CheckButtons[BRL_TOOLTIP_OFFSET_BOTTOM] = {
56 id = 5,
57 strVar = "tooltip_offset_bottom",
58 pSlashCommand = BRL_Tooltip_Offset_Bottom
59 };
60 BRL_CheckButtons[BRL_SHOW_TOOLTIP_FACTION] = {
61 id = 6,
62 strVar = "show_tooltip_faction",
63 pSlashCommand = BRL_Show_Tooltip_Faction
64 };
65 BRL_CheckButtons[BRL_SHOW_TOOLTIP_INSTANCE] = {
66 id = 7,
67 strVar = "show_tooltip_instance",
68 pSlashCommand = BRL_Show_Tooltip_Instance
69 };
70 BRL_CheckButtons[BRL_SHOW_TOOLTIP_CONTINENT] = {
71 id = 8,
72 strVar = "show_tooltip_continent",
73 pSlashCommand = BRL_Show_Tooltip_Continent
74 };
75  
76  
77 local BRL_Sliders = { };
78 BRL_Sliders[BRL_BORDER_ALPHASLIDER] = {
79 id = 1,
80 strVar = "border_alpha",
81 pSlashCommand = BRL_Border_Alpha,
82 minValue = 0.0,
83 maxValue = 1.0,
84 valueStep = .01,
85 minText="0%",
86 maxText="100%",
87 };
88  
89 function BRL_UI_Panel_OnLoad()
90 this:RegisterEvent("VARIABLES_LOADED");
91 -- Add BRL_Frame to the UIPanelWindows list
92 UIPanelWindows["BRL_Frame"] = {area = "center", pushable = 0};
93 BRL_Frame_TitleText:SetTextColor(1.0, 0.8, 0.0);
94  
95 -- Slash commands for UI Window open.
96 SlashCmdList["BRL_UI_PANEL"] = BRL_UI_Panel_SlashHandler;
97 SLASH_BRL_UI_PANEL1 = "/brlconfig";
98 end
99  
100 function BRL_UI_Panel_SlashHandler()
101 ShowUIPanel(BRL_Frame);
102 BRL_Main_Frame:Show();
103 BRL_UI_Panel_Refresh();
104 end
105  
106 function BRL_OnEvent()
107 if (event == "VARIABLES_LOADED") then
108 -- Add Recommended Level to myAddOns
109 if (myAddOnsFrame_Register) then
110 myAddOnsFrame_Register ( {name = 'BMRecLevel', version = BMRECLEVEL_VERSION, optionsframe = 'BRL_Frame', category = MYADDONS_CATEGORY_OTHERS } );
111 end
112 end
113 end
114  
115 function BRL_Frame_OnClick()
116 ShowUIPanel(BRL_Frame);
117 BRL_Main_Frame:Show();
118 BRL_UI_Panel_Refresh();
119 end
120  
121 function BRL_OnShow()
122 ShowUIPanel(BRL_Frame);
123 BRL_Main_Frame:Show();
124 BRL_UI_Panel_Refresh();
125 end
126  
127 --Called when option page loads
128 function BRL_UI_Panel_Refresh()
129 -- Initial Values
130 local button, string, checked;
131 BRL_STARTUP.m_strPlayer = GetCVar("realmName") .. "|" .. UnitName("player");
132 -- Setup check buttons
133 for key, value in BRL_CheckButtons do
134 button = getglobal("BRL_Check" .. value.id);
135 string = getglobal("BRL_Check" .. value.id .. "Text");
136 checked = nil;
137 button.disabled = nil;
138  
139 --Check Box
140 if (BRL_CONFIG[BRL_STARTUP.m_strPlayer][value.strVar] == true) then
141 checked = 1;
142 else
143 checked = 0;
144 end
145 --DEFAULT_CHAT_FRAME:AddMessage("Item Checked: " .. button);
146 button:SetChecked(checked);
147 string:SetText(key);
148 button.pSlashCommand = value.pSlashCommand;
149 end
150  
151 local slider, string, low, high;
152  
153 -- Setup Sliders
154 for key, value in BRL_Sliders do
155 slider = getglobal("BRL_Slider"..value.id);
156 string = getglobal("BRL_Slider"..value.id.."Text");
157 low = getglobal("BRL_Slider"..value.id.."Low");
158 high = getglobal("BRL_Slider"..value.id.."High");
159  
160 slider.id = value.id;
161 slider.strVar = value.strVar;
162 slider.pSlashCommand = value.pSlashCommand;
163  
164 --OptionsFrame_EnableSlider(slider);
165 slider:SetMinMaxValues(value.minValue, value.maxValue);
166 slider:SetValueStep(value.valueStep);
167 slider:SetValue(BRL_CONFIG[BRL_STARTUP.m_strPlayer][value.strVar]);
168 string:SetText(key);
169 low:SetText(value.minText);
170 high:SetText(value.maxText);
171 end
172 end
173  
174 function BRL_CheckButton_OnClick()
175 local bChecked;
176 if (this:GetChecked()) then
177 bChecked = true;
178 else
179 bChecked = false;
180 end
181 this.pSlashCommand(bChecked,this:GetID());
182 end
183  
184 function BRL_Slider_OnValueChanged()
185  
186 BRL_CONFIG[BRL_STARTUP.m_strPlayer][this.strVar] = this:GetValue();
187  
188 this.pSlashCommand(this:GetValue());
189  
190 -- set the tool tip text
191 if (this:GetValue() == floor(this:GetValue())) then
192 GameTooltip:SetText(format("%d", this:GetValue()));
193 else
194 GameTooltip:SetText(format("%.2f", this:GetValue()));
195 end
196 end
197  
198 function BRL_Slider_OnEnter()
199 -- put the tool tip in the default position
200 GameTooltip:SetOwner(this, "ANCHOR_CURSOR");
201  
202 -- set the tool tip text
203 if (this:GetValue() == floor(this:GetValue())) then
204 GameTooltip:SetText(format("%d", this:GetValue()));
205 else
206 GameTooltip:SetText(format("%.2f", this:GetValue()));
207 end
208  
209 GameTooltip:Show();
210 end
211  
212 function BRL_Slider_OnLeave()
213 GameTooltip:Hide();
214 end