vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --
2 -- MI2_Slash.lua
3 --
4 -- Handle all slash commands and the actions performed by slash commands.
5 -- All option dialog settings use slash commands for performing their
6 -- actions.
7 --
8  
9 miVersionNo = ' 2.97'
10  
11 miVersion = mifontYellow..'MobInfo-2 Version '..miVersionNo..mifontGreen..' http://www.dizzarian.com/forums/viewforum.php?f=16'
12 miPatchNotes = mifontYellow..
13 'MobInfo-2 Version '..miVersionNo..'\n'..
14 ' ver 2.97\n'..
15 ' - updated to comply with newest WoW version 1.11\n'..
16 ' - show items on search options page in correct item color\n'..
17 ' - search options page again shows result list size\n'..
18 ' - fixed bug in search for Mobs that drop a certain item\n\n'..
19 ' ver 2.96\n'..
20 ' - new feature: store health value obtained through Beast Lore in health database\n'..
21 ' - new feature: added chinese translation submitted by Andyca Chiou\n'..
22 ' - fixed nil error for items with legendary and artifact rarity\n\n'..
23 ' ver 2.95\n'..
24 ' - bugfix release : fixes wrong max health display\n\n'..
25 ' ver 2.94\n'..
26 ' - huge update of MobInfo vendor sell price table (over 1000 new prices)\n'..
27 ' - DropRate conversion now supports LootLink databases\n'..
28 ' - fixed: DropRate conversion nil bug "Mobinfo2.lua Line: 383"\n'..
29 ' - fixed bug where health was displayed wrong after using "BeastLore" on Mob\n\n'..
30 ' ver 2.93\n'..
31 ' - new feature: implemented DropRate database converter from NakorNH\n'..
32 ' - bugfix: correctly import locations for mobs in instances\n'..
33 ' - added new items (loot from Silithus) to MobInfo item price table\n'..
34 ' - several new skinning loot items added to skinning loot detection table\n\n'..
35 ' ver 2.92\n'..
36 ' - new feature: you can choose to import only unknown (ie. new) Mobs\n'..
37 ' - improved item colors in Mob tooltip for better readability\n'..
38 ' - fixed all health/mana updating issues for unit frame and tooltip\n'..
39 ' - fixed max health not increasing correctly for group member targets\n\n'..
40 ' ver 2.91\n'..
41 ' - new feature: importing of externally supplied MobInfo databases\n'..
42 ' - new feature: option to delete all Mobs shown in search result\n'..
43 ' - added Turtle Scales to skinning loot detection table\n'..
44 ' - show all "green hills of Strangle" pages on one tooltip line\n'..
45 ' - item list on search page: show all items if item name field is empty\n'..
46 ' - fixed: mob name search errors on special chars\n'..
47 ' - fixed: correct independant show/hide of basic loot items\n\n'..
48 ' ver 2.90\n'..
49 ' - added separate tooltip option for cloth and skinning loot\n'..
50 ' - show drop percentages for items in Mob tooltip\n'..
51 ' - calculate skinning loot percantage based on skinned counter\n'..
52 ' - rearranged tooltips options page\n'..
53 ' - new skinning loot support for Shiny Fish Scales and Red Whelp Scales\n\n'..
54 ' For all previous patch notes and to report bugs please visit http://www.dizzarian.com/forums/viewforum.php?f=16'
55  
56  
57 local MI2_DeleteMode = ""
58  
59  
60 -- Configs
61 function MI2_SlashAction_Default()
62 MobInfoConfig.ShowClass = 1
63 MobInfoConfig.ShowHealth = 1
64 MobInfoConfig.ShowMana = 0
65 MobInfoConfig.ShowDamage = 1
66 MobInfoConfig.ShowKills = 0
67 MobInfoConfig.ShowLoots = 1
68 MobInfoConfig.ShowEmpty = 0
69 MobInfoConfig.ShowXp = 1
70 MobInfoConfig.ShowNo2lev = 1
71 MobInfoConfig.ShowQuality = 1
72 MobInfoConfig.ShowCloth = 1
73 MobInfoConfig.ShowCoin = 0
74 MobInfoConfig.ShowIV = 0
75 MobInfoConfig.ShowTotal = 1
76 MobInfoConfig.ShowCombined = 0
77 MobInfoConfig.ShowItems = 1
78 MobInfoConfig.ShowLocation = 1
79 MobInfoConfig.ShowClothSkin = 1
80 end
81  
82 function MI2_SlashAction_AllOn()
83 MobInfoConfig.ShowClass = 1
84 MobInfoConfig.ShowHealth = 1
85 MobInfoConfig.ShowMana = 1
86 MobInfoConfig.ShowKills = 1
87 MobInfoConfig.ShowDamage = 1
88 MobInfoConfig.ShowXp = 1
89 MobInfoConfig.ShowNo2lev = 1
90 MobInfoConfig.ShowLoots = 1
91 MobInfoConfig.ShowEmpty = 1
92 MobInfoConfig.ShowCoin = 1
93 MobInfoConfig.ShowIV = 1
94 MobInfoConfig.ShowTotal = 1
95 MobInfoConfig.ShowQuality = 1
96 MobInfoConfig.ShowCloth = 1
97 MobInfoConfig.ShowCombined = 1
98 MobInfoConfig.ShowItems = 1
99 MobInfoConfig.ShowLocation = 1
100 MobInfoConfig.ShowClothSkin = 1
101 end
102  
103 function MI2_SlashAction_AllOff()
104 MobInfoConfig.ShowClass = 0
105 MobInfoConfig.ShowHealth = 0
106 MobInfoConfig.ShowMana = 0
107 MobInfoConfig.ShowKills = 0
108 MobInfoConfig.ShowDamage = 0
109 MobInfoConfig.ShowXp = 0
110 MobInfoConfig.ShowNo2lev = 0
111 MobInfoConfig.ShowLoots = 0
112 MobInfoConfig.ShowEmpty = 0
113 MobInfoConfig.ShowCoin = 0
114 MobInfoConfig.ShowIV = 0
115 MobInfoConfig.ShowTotal = 0
116 MobInfoConfig.ShowQuality = 0
117 MobInfoConfig.ShowCloth = 0
118 MobInfoConfig.ShowCombined = 0
119 MobInfoConfig.ShowItems = 0
120 MobInfoConfig.ShowLocation = 0
121 MobInfoConfig.ShowClothSkin = 0
122 end
123  
124 function MI2_SlashAction_Minimal()
125 MobInfoConfig.ShowClass = 1
126 MobInfoConfig.ShowHealth = 1
127 MobInfoConfig.ShowMana = 0
128 MobInfoConfig.ShowKills = 0
129 MobInfoConfig.ShowDamage = 0
130 MobInfoConfig.ShowXp = 0
131 MobInfoConfig.ShowNo2lev = 1
132 MobInfoConfig.ShowLoots = 0
133 MobInfoConfig.ShowEmpty = 0
134 MobInfoConfig.ShowCoin = 0
135 MobInfoConfig.ShowIV = 0
136 MobInfoConfig.ShowTotal = 1
137 MobInfoConfig.ShowQuality = 0
138 MobInfoConfig.ShowCloth = 0
139 MobInfoConfig.ShowCombined = 0
140 MobInfoConfig.ShowItems = 0
141 MobInfoConfig.ShowLocation = 0
142 MobInfoConfig.ShowClothSkin = 0
143 end
144  
145  
146 -----------------------------------------------------------------------------
147 -- MI2_RegisterWithAddonManagers()
148 --
149 -- Register MobInfo with the KHAOS AddOn manager. This is a very simple
150 -- registration that merely creates a button to open the MobInfo options
151 -- dialog.
152 --
153 -- Register MobInfo with the myAddons manager.
154 --
155 -- Register with the EARTH AddOn manager.
156 -----------------------------------------------------------------------------
157 function MI2_RegisterWithAddonManagers()
158  
159 -- register with myAddons manager
160 if ( myAddOnsFrame_Register ) then
161 local mobInfo2Details = {
162 name = "MobInfo2",
163 version = miVersionNo,
164 author = "Skeeve & Dizzarian",
165 website = "http://www.dizzarian.com/forums/viewforum.php?f=16",
166 category = MYADDONS_CATEGORY_OTHERS,
167 optionsframe = "frmMIConfig"
168 }
169 myAddOnsFrame_Register( mobInfo2Details )
170 end
171  
172 -- register with EARTH manager (mainly for Cosmos support)
173 if EarthFeature_AddButton then
174 EarthFeature_AddButton(
175 {
176 id = "MobInfo2",
177 name = "MobInfo2",
178 subtext = "v"..miVersionNo,
179 tooltip = MI_DESCRIPTION,
180 icon = "Interface\\AddOns\\MobInfo2\\MobInfoIcon",
181 callback = function(state) MI2_SlashParse( "", false ) end,
182 test = nil
183 }
184 )
185  
186 -- register with KHAOS (only if EARTH not found)
187 elseif Khaos then
188 Khaos.registerOptionSet(
189 "tooltip",
190 {
191 id = "MobInfo2OptionSet",
192 text = "MobInfo 2",
193 helptext = MI_DESCRIPTION,
194 difficulty = 1,
195 callback = function(state) end,
196 default = true,
197 options = {
198 {
199 id = "MobInfo2OptionsHeader",
200 type = K_HEADER,
201 difficulty = 1,
202 text = MI_TXT_WELCOME,
203 helptext = MI_DESCRIPTION
204 },
205 {
206 id = "MobInfo2OptionsButton",
207 type = K_BUTTON,
208 difficulty = 1,
209 text = MI_TXT_CONFIG_TITLE,
210 helptext = "",
211 callback = function(state) MI2_SlashParse( "", false ) end,
212 feedback = function(state) end,
213 setup = { buttonText = MI_TXT_OPEN }
214 }
215 }
216 }
217 )
218 end
219 end -- MI2_RegisterWithAddonManagers()
220  
221  
222 -----------------------------------------------------------------------------
223 -- MI2_SlashAction_ClearTarget()
224 --
225 -- Clear MobInfo and MobHealth data for current target.
226 -----------------------------------------------------------------------------
227 function MI2_SlashAction_ClearTarget()
228 local index = MI2_Target.mobIndex
229 if index then
230 MI2_MobHealth_ClearTargetData()
231 MI2_DeleteMobData( index )
232 MI2_DbOptionsFrameOnShow()
233 ClearTarget()
234 chattext( "data for "..mifontGreen..index..mifontWhite.." has been cleared" )
235 end
236 end -- MI2_SlashAction_ClearTarget()
237  
238  
239 -----------------------------------------------------------------------------
240 -- MI2_Slash_ClearAllConfirmed()
241 --
242 -- Clear-All-Confirmation-Handler : Clear entire contents of MobInfo and
243 -- MobHealth databases.
244 -----------------------------------------------------------------------------
245 function MI2_Slash_ClearAllConfirmed()
246  
247 if MI2_DeleteMode == "MobDb" then
248 MobInfoDB = {}
249 MI2_ItemNameTable = {}
250 MobInfoDB["DatabaseVersion:0"] = { ver = MI2_DB_VERSION }
251 MI2_CharTable = {}
252 MI2_CharTable.charCount = 0
253 elseif MI2_DeleteMode == "HealthDb" then
254 MI2_MobHealth_Reset()
255 elseif MI2_DeleteMode == "PlayerDb" then
256 MobHealthPlayerDB = {}
257 end
258 chattext( "<MobInfo> database deleted" )
259 MI2_DbOptionsFrameOnShow()
260 end -- MI2_Slash_ClearAllConfirmed()
261  
262  
263 -----------------------------------------------------------------------------
264 -- MI2_SlashAction_ClearHealthDb()
265 --
266 -- Clear entire contents of MobInfo and MobHealth databases.
267 -- Ask for confirmation before performing the clear operation.
268 -----------------------------------------------------------------------------
269 function MI2_SlashAction_ClearHealthDb()
270 StaticPopupDialogs["MOBINFO_CONFIRMATION"].text = MI_TXT_CLR_ALL_CONFIRM.."'"..MI2_OPTIONS[this:GetName()].help.."' ?"
271 StaticPopupDialogs["MOBINFO_CONFIRMATION"].OnAccept = MI2_Slash_ClearAllConfirmed
272 MI2_DeleteMode = "HealthDb"
273 local dialog = StaticPopup_Show( "MOBINFO_CONFIRMATION", "")
274 end -- MI2_SlashAction_ClearHealthDb()
275  
276  
277 -----------------------------------------------------------------------------
278 -- MI2_SlashAction_ClearPlayerDb()
279 --
280 -- Clear entire contents of MobInfo and MobHealth databases.
281 -- Ask for confirmation before performing the clear operation.
282 -----------------------------------------------------------------------------
283 function MI2_SlashAction_ClearPlayerDb()
284 StaticPopupDialogs["MOBINFO_CONFIRMATION"].text = MI_TXT_CLR_ALL_CONFIRM.."'"..MI2_OPTIONS[this:GetName()].help.."' ?"
285 StaticPopupDialogs["MOBINFO_CONFIRMATION"].OnAccept = MI2_Slash_ClearAllConfirmed
286 MI2_DeleteMode = "PlayerDb"
287 local dialog = StaticPopup_Show( "MOBINFO_CONFIRMATION", "")
288 end -- MI2_SlashAction_ClearPlayerDb()
289  
290  
291 -----------------------------------------------------------------------------
292 -- MI2_SlashAction_ClearMobDb()
293 --
294 -- Clear entire contents of MobInfo and MobHealth databases.
295 -- Ask for confirmation before performing the clear operation.
296 -----------------------------------------------------------------------------
297 function MI2_SlashAction_ClearMobDb()
298 StaticPopupDialogs["MOBINFO_CONFIRMATION"].text = MI_TXT_CLR_ALL_CONFIRM.."'"..MI2_OPTIONS[this:GetName()].help.."' ?"
299 StaticPopupDialogs["MOBINFO_CONFIRMATION"].OnAccept = MI2_Slash_ClearAllConfirmed
300 MI2_DeleteMode = "MobDb"
301 local dialog = StaticPopup_Show( "MOBINFO_CONFIRMATION", "")
302 end -- MI2_SlashAction_ClearMobDb()
303  
304  
305 -----------------------------------------------------------------------------
306 -- MI2_Slash_TrimDownConfirmed()
307 --
308 -- Trim down the contents of the mob info database by removing all data
309 -- that is not set as being recorded. This function is called when the
310 -- user confirms the delete confirmation.
311 -----------------------------------------------------------------------------
312 function MI2_Slash_TrimDownConfirmed()
313 MobInfoDB["DatabaseVersion:0"] = nil
314  
315 -- loop through database and check each record
316 -- remove all fields within the record where recording of the field is disabled
317 for idx, mobInfo in MobInfoDB do
318 if MobInfoConfig.SaveBasicInfo == 0 then
319 mobInfo.bi = nil
320 end
321 if MobInfoConfig.SaveQualityData == 0 then
322 mobInfo.qi = nil
323 end
324 if MobInfoConfig.SaveLocation == 0 then
325 mobInfo.ml = nil
326 end
327 if MobInfoConfig.SaveItems == 0 then
328 mobInfo.il = nil
329 end
330 if MobInfoConfig.SaveCharData == 0 then
331 MI2_RemoveCharData( mobInfo )
332 end
333 end
334  
335 if MobInfoConfig.SaveItems == 0 then
336 MI2_ItemNameTable = {}
337 end
338  
339 -- char table can be deleted when not saving char specific data
340 if MobInfoConfig.SaveCharData == 0 then
341 MI2_CharTable = { charCount = 0 }
342 end
343  
344 -- force a cleanup after trimming down
345 MobInfoDB["DatabaseVersion:0"] = { ver = MI2_DB_VERSION - 1 }
346 MI2_CleanupDatabases()
347  
348 MI2_DbOptionsFrameOnShow()
349 end -- MI2_Slash_TrimDownConfirmed()
350  
351  
352 -----------------------------------------------------------------------------
353 -- MI2_SlashAction_TrimDownMobData()
354 --
355 -- Trim down the contents of the mob info database by removing all data
356 -- that is not set as being recorded. Ask for a confirmation before
357 -- actually deleting anything.
358 -----------------------------------------------------------------------------
359 function MI2_SlashAction_TrimDownMobData()
360 StaticPopupDialogs["MOBINFO_CONFIRMATION"].text = MI_TXT_TRIM_DOWN_CONFIRM
361 StaticPopupDialogs["MOBINFO_CONFIRMATION"].OnAccept = MI2_Slash_TrimDownConfirmed
362 local dialog = StaticPopup_Show( "MOBINFO_CONFIRMATION", "")
363 end -- MI2_SlashAction_TrimDownMobData()
364  
365  
366 -----------------------------------------------------------------------------
367 -- MI2_UpdateMob()
368 --
369 -- Update a specific existing mob by adding to it the given new Mob data.
370 -----------------------------------------------------------------------------
371 local function MI2_UpdateMob( mobIndex, newMobInfo )
372 local existingMobInfo = MobInfoDB[mobIndex]
373 local existingMobData, newMobData = {}, {}
374 MI2_GetMobDataFromMobInfo( existingMobInfo, existingMobData )
375 MI2_GetMobDataFromMobInfo( newMobInfo, newMobData )
376 MI2_AddTwoMobs( existingMobData, newMobData )
377 MI2x_StoreMobData( existingMobData, nil, nil, MI2_PlayerName, mobIndex )
378 end -- MI2_UpdateMob()
379  
380 -----------------------------------------------------------------------------
381 -- MI2_AdaptImportLocation()
382 --
383 -- Adapt the location info of an imported Mob. This is only necessary for
384 -- Mobs in instances, because instances are not available in the WoW
385 -- zone tables.
386 -----------------------------------------------------------------------------
387 local function MI2_AdaptImportLocation( mobInfo, importZoneTable )
388 -- decode mob location information: only adapt mobs from instances
389 local mobData = {}
390 MI2_DecodeMobLocation( mobInfo, mobData )
391 if not mobData.location or mobData.location.z < 100 then return end
392  
393 -- instance mob found: find the name of the instance
394 local zoneId = mobData.location.z
395 local zoneName = importZoneTable[zoneId]
396 if not zoneName then
397 -- unknown import zone ID : search zone name and add it to the zone table
398 for name, id in importZoneTable do
399 if id == zoneId then
400 zoneName = name
401 importZoneTable[zoneId] = zoneName
402 end
403 end
404 end
405  
406 -- find the corrected zone ID for the zone name
407 if zoneName then
408 if not MI2_ZoneTable[zoneName] then
409 MI2_ZoneTable.cnt = MI2_ZoneTable.cnt + 1
410 MI2_ZoneTable[zoneName] = 100 + MI2_ZoneTable.cnt
411 end
412 local correctedZoneId = MI2_ZoneTable[zoneName]
413 local loc = mobData.location
414 mobInfo.ml = (loc.x1 or "").."/"..(loc.y1 or "").."/"..(loc.x2 or "").."/"..(loc.y2 or "").."/0/"..correctedZoneId
415 else
416 mobInfo.ml = nil
417 end
418 end -- MI2_AdaptImportLocation()
419  
420  
421 -----------------------------------------------------------------------------
422 -- MI2_SlashAction_ImportMobData()
423 --
424 -- Import externally supplied MobInfo database into own database.
425 -----------------------------------------------------------------------------
426 function MI2_SlashAction_ImportMobData()
427 local newMobs, updatedMobs, newHealth, newItems = 0, 0, 0, 0
428 local chatPrefix = mifontLightBlue.."<MobInfo Import>"..mifontWhite
429  
430 chattext( chatPrefix.." starting external database import ...." )
431  
432 -- import loot items into main loot item database
433 for itemId, itemInfo in MI2_ItemNameTable_Import do
434 if not MI2_ItemNameTable[itemId] then
435 MI2_ItemNameTable[itemId] = itemInfo
436 newItems = newItems + 1
437 end
438 end
439  
440 -- import health data into main Mob health database
441 for mobIndex, healthInfo in MobHealthDB_Import do
442 if not MobHealthDB[mobIndex] then
443 MobHealthDB[mobIndex] = healthInfo
444 newHealth = newHealth + 1
445 end
446 end
447  
448 -- import Mobs into main Mob database
449 for mobIndex, mobInfo in MobInfoDB_Import do
450 MI2_RemoveCharData( mobInfo )
451 MI2_AdaptImportLocation( mobInfo, MI2_ZoneTable_Import )
452 if MobInfoDB[mobIndex] then
453 updatedMobs = updatedMobs + 1
454 if MobInfoConfig.ImportOnlyNew == 0 then
455 -- import Mob that already exists
456 MI2_UpdateMob( mobIndex, mobInfo )
457 end
458 else
459 -- import unknown Mob
460 MobInfoDB[mobIndex] = mobInfo
461 newMobs = newMobs + 1
462 end
463 end
464  
465 -- update item cross reference table after import
466 if MobInfoConfig.ImportOnlyNew == 0 then
467 MI2_BuildXRefItemTable()
468 end
469  
470 chattext( chatPrefix.." imported "..newMobs.." new Mobs" )
471 chattext( chatPrefix.." imported "..newHealth.." new health values" )
472 chattext( chatPrefix.." imported "..newItems.." new loot items" )
473 if MobInfoConfig.ImportOnlyNew == 0 then
474 chattext( chatPrefix.." updated data for "..updatedMobs.." existing Mobs" )
475 else
476 chattext( chatPrefix.." did NOT update data for "..updatedMobs.." existing Mobs" )
477 end
478  
479 -- update database options frame
480 MobInfoConfig.ImportSignature = MI2_Import_Signature
481 MI2_DbOptionsFrameOnShow()
482 end -- MI2_SlashAction_ImportMobData()
483  
484  
485 -----------------------------------------------------------------------------
486 -- MI2_SlashAction_DeleteSearch()
487 --
488 -- Delete all Mobs in the search result list from the MobInfo database.
489 -- This function will ask for confirmation before deleting.
490 -----------------------------------------------------------------------------
491 function MI2_SlashAction_DeleteSearch()
492 local confirmationText = string.format( MI_TXT_DEL_SEARCH_CONFIRM, MI2_NumMobsFound )
493 StaticPopupDialogs["MOBINFO_CONFIRMATION"].text = confirmationText
494 StaticPopupDialogs["MOBINFO_CONFIRMATION"].OnAccept = MI2_DeleteSearchResultMobs
495 local dialog = StaticPopup_Show( "MOBINFO_CONFIRMATION", "")
496 end -- MI2_SlashAction_DeleteSearch()
497  
498  
499 -----------------------------------------------------------------------------
500 -- MI2_SlashInit()
501 --
502 -- Add all Slash Commands
503 -----------------------------------------------------------------------------
504 function MI2_SlashInit()
505 SlashCmdList["MOBINFO"] = MI2_SlashParse
506 SLASH_MOBINFO1 = "/mobinfo2"
507 SLASH_MOBINFO2 = "/mi2"
508 end -- MI2_SlashInit()
509  
510  
511 -----------------------------------------------------------------------------
512 -- MI2_SlashParse()
513 --
514 -- Parses the msg entered as a slash command. This function is also used
515 -- for the internal purpose of setting all options in the options dialog.
516 -- When used by the options dialog there is no need to actually update the
517 -- dialog, which is indicated by the "updateOptions" parameter.
518 -----------------------------------------------------------------------------
519 function MI2_SlashParse( msg, updateOptions )
520 -- extract option name and option argument from message string
521 local _, _, cmd, param = string.find( string.lower(msg), "([%w_]*)[ ]*([-%w]*)")
522  
523 -- handle show/hide of options dialog first of all
524 -- handle all simple commands that dont require parsing right here
525 if not cmd or cmd == "" or cmd == "config" then
526 if frmMIConfig:IsVisible() then
527 frmMIConfig:Hide()
528 else
529 frmMIConfig:Show()
530 end
531 return
532 elseif cmd == 'version' then
533 chattext( miVersion )
534 return
535 elseif cmd == 'notes' then
536 chattext( miPatchNotes )
537 return
538 elseif cmd == 'convertdroprate' then
539 MI2_StartDropRateConversion()
540 return
541 elseif cmd == 'help' then
542 chattext( mifontYellow.. 'Usage /mobinfo2 <cmd> or /mi2 <cmd>' )
543 chattext( 'Where <cmd> is any of the following:' )
544 for idx, val in MI2_OPTIONS do
545 if val.help and val.help ~= "" then
546 local prefix = string.sub(idx, 1, 7)
547 local option = string.lower( string.sub(idx, 8) )
548 if prefix == "MI2_Opt" then
549 chattext( mifontGreen..option..' - '..mifontYellow..val.help )
550 end
551 end
552 end
553 return
554 end
555  
556 -- search for the option data structure matching the command
557 local optionName, optionData
558 for idx, val in MI2_OPTIONS do
559 local lower_opt = string.lower( idx )
560 local optionCommand = string.sub(lower_opt, 8)
561 if cmd == lower_opt or cmd == optionCommand then
562 optionName = string.sub(idx, 8)
563 optionData = val
564 break
565 end
566 end
567  
568 -- now call the option handler for the more complex commands
569 if optionData then
570 MI2_OptionParse( optionName, optionData, param, updateOptions )
571 end
572 end -- of MI2_SlashParse()
573  
574  
575 -----------------------------------------------------------------------------
576 -- MI2_OptionParse()
577 --
578 -- Parses the more complex option toggle/set commands. There are 4
579 -- categories of options:
580 -- * options that can toggle between an on and off state
581 -- * options that represent a numeric value
582 -- * options that represent a text
583 -- * options that activate a special functionality represented by a
584 -- handler function that must correspond to a specific naming convention
585 -----------------------------------------------------------------------------
586 function MI2_OptionParse( optionName, optionData, param, updateOptions )
587 -- handle the option according to its option type: its either a
588 -- switch being toggleg, a value being set, or a special action
589 if optionData.val then
590 -- it is a slider setting a value
591 -- get new option value from parameter and set it
592 local optValue = tonumber( param ) or 0
593 MobInfoConfig[optionName] = optValue
594 if updateOptions then
595 chattext( optionData.text.." : "..mifontGreen..optValue )
596 end
597  
598 elseif optionData.txt then
599 -- it is a text based option
600 MobInfoConfig[optionName] = param
601 if updateOptions then
602 chattext( optionData.text.." : "..mifontGreen..param )
603 end
604  
605 elseif MobInfoConfig[optionName] then
606 -- it is a switch toggle option:
607 -- get current option value and toggle it to the opposite state (On<->Off)
608 local valTxt = { val0 = "-OFF-", val1 = "-ON-" }
609 local optValue = MobInfoConfig[ optionName ]
610 optValue = 1 - optValue -- toggle option
611 MobInfoConfig[optionName] = optValue
612 chattext( optionData.text.." : "..mifontGreen..valTxt["val"..optValue] )
613  
614 -- special case: disabling MobInfo requires extra processing
615 if optionName == "DisableMobInfo" then MI2_UpdateMobInfoState() end
616  
617 else
618 -- special action commands have a corresponding handler function
619 local actionHandlerName = "MI2_SlashAction_"..optionName
620 local actionHandler = getglobal( actionHandlerName )
621 if actionHandler then
622 actionHandler()
623 updateOptions = true -- for AllOn, AllOff, etc.
624 end
625 end
626  
627 -- update font and position of health / mana texts
628 MI2_MobHealth_SetPos()
629  
630 -- update options dialog if shown and if requested
631 if frmMIConfig:IsVisible() and updateOptions then
632 MI2_UpdateOptions()
633 end
634  
635 end -- MI2_OptionParse()
636