vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- |
2 | -- MI2_Config.lua |
||
3 | -- |
||
4 | -- Configuration dialog related module of the MobInfo2 AddOn |
||
5 | -- |
||
6 | |||
7 | ----------------------------------------------------------------------------- |
||
8 | -- MI2_OptionsFrameOnLoad() |
||
9 | -- |
||
10 | -- This "OnLoad" event handler for the options dialog installs the |
||
11 | -- ESC key handler. |
||
12 | ----------------------------------------------------------------------------- |
||
13 | function MI2_OptionsFrameOnLoad() |
||
14 | tinsert(UISpecialFrames, "frmMIConfig") -- Esc Closes Options Frame |
||
15 | UIPanelWindows["frmMIConfig"] = {area = "center", pushable = 0} |
||
16 | |||
17 | PanelTemplates_SetNumTabs( MI2_MainOptionsFrame, 4 ) |
||
18 | MI2_MainOptionsFrame.selectedTab = 1 |
||
19 | PanelTemplates_UpdateTabs( MI2_MainOptionsFrame ) |
||
20 | PanelTemplates_SetNumTabs( MI2_SearchResultFrame, 2 ) |
||
21 | MI2_SearchResultFrame.selectedTab = 1 |
||
22 | PanelTemplates_UpdateTabs( MI2_SearchResultFrame ) |
||
23 | |||
24 | MI2_OptDisableMobInfoText:SetTextColor( 1.0, 1.0, 1.0 ) |
||
25 | |||
26 | MI2_OptHealthPosX:SetMinMaxValues( -50, 50 ) |
||
27 | MI2_OptHealthPosY:SetMinMaxValues( -40, 80 ) |
||
28 | MI2_OptManaPosX:SetMinMaxValues( -50, 50 ) |
||
29 | MI2_OptManaPosY:SetMinMaxValues( -40, 80 ) |
||
30 | MI2_OptTargetFontSize:SetMinMaxValues( 6, 20 ) |
||
31 | end -- MI2_OptionsFrameOnLoad() |
||
32 | |||
33 | |||
34 | ----------------------------------------------------------------------------- |
||
35 | -- MI2_SetHealthOptionsState() |
||
36 | -- |
||
37 | -- Set the state of health options in health options dialog to either |
||
38 | -- enabled or disabled, as indicated by "MobInfoConfig.DisableHealth". |
||
39 | ----------------------------------------------------------------------------- |
||
40 | function MI2_SetHealthOptionsState() |
||
41 | local r,g,b |
||
42 | |||
43 | if MobInfoConfig.DisableHealth == 2 then |
||
44 | MI2_MobHealthFrame:Hide() |
||
45 | end |
||
46 | end -- of MI2_SetHealthOptionsState() |
||
47 | |||
48 | |||
49 | ----------------------------------------------------------------------------- |
||
50 | -- MI2_UpdateOptions() |
||
51 | -- |
||
52 | -- Update state of all options in options dialog with correct values from |
||
53 | -- data structure "MobInfoConfig". |
||
54 | ----------------------------------------------------------------------------- |
||
55 | function MI2_UpdateOptions() |
||
56 | for index, value in MI2_OPTIONS do |
||
57 | local option = string.sub( index, 8 ) |
||
58 | --DEFAULT_CHAT_FRAME:AddMessage( "MI_DBG: index="..index..", cmnd="..value.cmnd..", opt="..option ) |
||
59 | if MobInfoConfig[option] then |
||
60 | if value.dd then |
||
61 | -- do nothing for dropdowns |
||
62 | elseif value.val then |
||
63 | getglobal(index):SetValue( MobInfoConfig[option] ) |
||
64 | elseif value.txt then |
||
65 | getglobal(index):SetText( MobInfoConfig[option] ) |
||
66 | else |
||
67 | getglobal(index):SetChecked( MobInfoConfig[option] ) |
||
68 | end |
||
69 | end |
||
70 | end |
||
71 | end -- MI2_UpdateOptions() |
||
72 | |||
73 | |||
74 | ----------------------------------------------------------------------------- |
||
75 | -- MI2_ShowOptionHelpTooltip() |
||
76 | -- |
||
77 | -- Show help text for current hovered option in options dialog |
||
78 | -- in the game tooltip window. |
||
79 | ----------------------------------------------------------------------------- |
||
80 | function MI2_ShowOptionHelpTooltip() |
||
81 | GameTooltip_SetDefaultAnchor( GameTooltip, UIParent ) |
||
82 | GameTooltip:SetText( mifontWhite..MI2_OPTIONS[this:GetName()].text ) |
||
83 | |||
84 | GameTooltip:AddLine(mifontGold..MI2_OPTIONS[this:GetName()].help) |
||
85 | if MI2_OPTIONS[this:GetName()].info then |
||
86 | GameTooltip:AddLine(mifontGold..MI2_OPTIONS[this:GetName()].info) |
||
87 | end |
||
88 | GameTooltip:Show() |
||
89 | end -- of MI2_ShowOptionHelpTooltip() |
||
90 | |||
91 | |||
92 | ----------------------------------------------------------------------------- |
||
93 | -- MI2_OptionsFrameOnShow() |
||
94 | -- |
||
95 | -- Show help text for current hovered option in options dialog |
||
96 | -- in the game tooltip window. |
||
97 | ----------------------------------------------------------------------------- |
||
98 | function MI2_OptionsFrameOnShow() |
||
99 | txtMIConfigTitle:SetText( MI_TXT_CONFIG_TITLE ) |
||
100 | MI2_UpdateOptions() |
||
101 | end -- MI2_OptionsFrameOnShow() |
||
102 | |||
103 | |||
104 | function miConfig_OnMouseDown(arg1) |
||
105 | if (arg1 == "LeftButton") then |
||
106 | frmMIConfig:StartMoving() |
||
107 | end |
||
108 | end |
||
109 | |||
110 | |||
111 | function miConfig_OnMouseUp(arg1) |
||
112 | if (arg1 == "LeftButton") then |
||
113 | frmMIConfig:StopMovingOrSizing() |
||
114 | end |
||
115 | end |
||
116 | |||
117 | |||
118 | function miConfig_btnMIDone_OnClick() |
||
119 | HideUIPanel(frmMIConfig) |
||
120 | if MYADDONS_ACTIVE_OPTIONSFRAME then |
||
121 | if (MYADDONS_ACTIVE_OPTIONSFRAME == this) then |
||
122 | ShowUIPanel(myAddOnsFrame) |
||
123 | end |
||
124 | end |
||
125 | end |
||
126 | |||
127 | ----------------------------------------------------------------------------- |
||
128 | -- MI2_TabButton_OnClick() |
||
129 | -- |
||
130 | -- Event handler: one of the options dialog TABs has been clicked. |
||
131 | -- Show the corresponding options frame and hide all other option frames. |
||
132 | ----------------------------------------------------------------------------- |
||
133 | function MI2_TabButton_OnClick( ) |
||
134 | PanelTemplates_Tab_OnClick( MI2_MainOptionsFrame ) |
||
135 | local selected = MI2_MainOptionsFrame.selectedTab |
||
136 | |||
137 | -- choose special information frame if mob health has been disabled |
||
138 | local healthFrame = MI2_FrmHealthOptions |
||
139 | if MobInfoConfig.DisableHealth ~= 0 then |
||
140 | healthFrame = MI2_FrmHealthDisabledInfo |
||
141 | end |
||
142 | |||
143 | if selected == 1 then |
||
144 | MI2_FrmTooltipOptions:Show() |
||
145 | else |
||
146 | MI2_FrmTooltipOptions:Hide() |
||
147 | end |
||
148 | |||
149 | if selected == 2 then |
||
150 | healthFrame:Show() |
||
151 | else |
||
152 | healthFrame:Hide() |
||
153 | end |
||
154 | |||
155 | if selected == 3 then |
||
156 | MI2_FrmDatabaseOptions:Show() |
||
157 | else |
||
158 | MI2_FrmDatabaseOptions:Hide() |
||
159 | end |
||
160 | |||
161 | if selected == 4 then |
||
162 | MI2_FrmSearchOptions:Show() |
||
163 | else |
||
164 | MI2_FrmSearchOptions:Hide() |
||
165 | end |
||
166 | end |
||
167 | |||
168 | |||
169 | ----------------------------------------------------------------------------- |
||
170 | -- MI2_OptTargetFont_OnClick() |
||
171 | -- |
||
172 | -- Event handler: one of the choices in the font selection box has been |
||
173 | -- clicked. Store it as a config option. |
||
174 | ----------------------------------------------------------------------------- |
||
175 | function MI2_OptTargetFont_OnClick() |
||
176 | local oldID = UIDropDownMenu_GetSelectedID( MI2_OptTargetFont ) |
||
177 | UIDropDownMenu_SetSelectedID( MI2_OptTargetFont, this:GetID()) |
||
178 | if oldID ~= this:GetID() then |
||
179 | MobInfoConfig.TargetFont = this:GetID() |
||
180 | MI2_MobHealth_SetPos() |
||
181 | end |
||
182 | end -- MI2_OptTargetFont_OnClick() |
||
183 | |||
184 | |||
185 | ----------------------------------------------------------------------------- |
||
186 | -- MI2_OptItemsQuality_OnClick() |
||
187 | -- |
||
188 | -- Event handler: one of the choices in the font selection box has been |
||
189 | -- clicked. Store it as a config option. |
||
190 | ----------------------------------------------------------------------------- |
||
191 | function MI2_OptItemsQuality_OnClick() |
||
192 | local oldID = UIDropDownMenu_GetSelectedID( MI2_OptItemsQuality ) |
||
193 | UIDropDownMenu_SetSelectedID( MI2_OptItemsQuality, this:GetID()) |
||
194 | if oldID ~= this:GetID() then |
||
195 | MobInfoConfig.ItemsQuality = this:GetID() |
||
196 | end |
||
197 | end -- MI2_OptItemsQuality_OnClick() |
||
198 | |||
199 | |||
200 | ----------------------------------------------------------------------------- |
||
201 | -- MI2_DropDown_Initialize() |
||
202 | -- |
||
203 | -- Initialize a dropdown list with entries that are retrieved from the |
||
204 | -- localization info. |
||
205 | ----------------------------------------------------------------------------- |
||
206 | function MI2_DropDown_Initialize() |
||
207 | if string.sub(this:GetName(),-6) ~= "Button" then return end |
||
208 | |||
209 | local dropDownName = string.sub(this:GetName(),1,-7) |
||
210 | local choice = MI2_OPTIONS[dropDownName].choice1 |
||
211 | local count = 1 |
||
212 | |||
213 | while choice do |
||
214 | local info = { text = choice, value = count, func = getglobal(dropDownName.."_OnClick") } |
||
215 | UIDropDownMenu_AddButton( info ) |
||
216 | count = count + 1 |
||
217 | choice = MI2_OPTIONS[dropDownName]["choice"..count] |
||
218 | end |
||
219 | end -- MI2_DropDown_Initialize() |
||
220 | |||
221 | |||
222 | ----------------------------------------------------------------------------- |
||
223 | -- MI2_OptItemsQuality_OnShow() |
||
224 | -- |
||
225 | -- Event handler: show a drop down list |
||
226 | -- Ensure that current selection is shown correctly. |
||
227 | ----------------------------------------------------------------------------- |
||
228 | function MI2_DropDown_OnShow() |
||
229 | local frameName = this:GetName() |
||
230 | local itemName = string.sub(frameName, 8) |
||
231 | local text = MI2_OPTIONS[frameName]["choice"..MobInfoConfig[itemName]] |
||
232 | |||
233 | UIDropDownMenu_SetSelectedID( this, MobInfoConfig[itemName] ) |
||
234 | UIDropDownMenu_SetText( text, this ) |
||
235 | end -- MI2_OptItemsQuality_OnShow() |
||
236 | |||
237 | |||
238 | ----------------------------------------------------------------------------- |
||
239 | -- MI2_DbOptionsFrameOnShow() |
||
240 | -- |
||
241 | ----------------------------------------------------------------------------- |
||
242 | function MI2_DbOptionsFrameOnShow() |
||
243 | local mobDbSize, healthDbSize, playerDbSize, itemDbSize = 0, 0, 0, 0 |
||
244 | |||
245 | -- count and diplay size of MobInfo database |
||
246 | for index in MobInfoDB do mobDbSize = mobDbSize + 1 end |
||
247 | MI2_TxtMobDbSize:SetText( MI_TXT_MOB_DB_SIZE..mifontWhite..(mobDbSize-1) ) |
||
248 | |||
249 | -- count and diplay size of MobHealth database |
||
250 | for index in MobHealthDB do healthDbSize = healthDbSize + 1 end |
||
251 | MI2_TxtHealthDbSize:SetText( MI_TXT_HEALTH_DB_SIZE..mifontWhite..healthDbSize ) |
||
252 | |||
253 | -- count and diplay size of MobHealthPlayer database |
||
254 | for index in MobHealthPlayerDB do playerDbSize = playerDbSize + 1 end |
||
255 | MI2_TxtPlayerDbSize:SetText( MI_TXT_PLAYER_DB_SIZE..mifontWhite..playerDbSize ) |
||
256 | |||
257 | -- count and diplay size of MI2_ItemNameTable database |
||
258 | -- for index in MI2_ItemNameTable do itemDbSize = itemDbSize + 1 end |
||
259 | -- MI2_TxtItemDbSize:SetText( MI_TXT_ITEM_DB_SIZE..mifontWhite..itemDbSize ) |
||
260 | |||
261 | -- update mob index display and state of "clear mob" button |
||
262 | if MI2_Target.mobIndex and MobInfoDB[MI2_Target.mobIndex] then |
||
263 | MI2_OptClearTarget:Enable() |
||
264 | MI2_TxtTargetIndex:SetText( MI_TXT_CUR_TARGET..mifontWhite..MI2_Target.mobIndex ) |
||
265 | else |
||
266 | MI2_OptClearTarget:Disable() |
||
267 | MI2_TxtTargetIndex:SetText( MI_TXT_CUR_TARGET..mifontWhite.."---" ) |
||
268 | end |
||
269 | |||
270 | -- update import status |
||
271 | if MI2_Import_Status then |
||
272 | if MobInfoConfig.ImportSignature == MI2_Import_Signature then |
||
273 | MI2_OptImportMobData:Disable() |
||
274 | MI2_TxtImportStatus:SetText( "Status: <data already imported ("..MI2_Import_Status..")>" ) |
||
275 | elseif MI2_Import_Status == "BADVER" then |
||
276 | MI2_OptImportMobData:Disable() |
||
277 | MI2_TxtImportStatus:SetText( "Status: <import database too old>" ) |
||
278 | else |
||
279 | MI2_OptImportMobData:Enable() |
||
280 | MI2_TxtImportStatus:SetText( "Status: "..MI2_Import_Status.." available for import" ) |
||
281 | end |
||
282 | else |
||
283 | MI2_OptImportMobData:Disable() |
||
284 | MI2_TxtImportStatus:SetText( "Status: <no import data>" ) |
||
285 | end |
||
286 | end -- MI2_DbOptionsFrameOnShow() |