vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[ RecapOptions.lua ]]
2  
3 local classabr = { ["WARRIOR"] = "WAR", ["MAGE"] = "MAG", ["ROGUE"] = "ROG", ["DRUID"] = "DRU",
4 ["HUNTER"] = "HNT", ["SHAMAN"] = "SHM", ["PRIEST"] = "PRI", ["WARLOCK"] = "WLK",
5 ["PALADIN"] = "PAL", ["Pet"] = "PET" }
6  
7  
8 -- knob=nil to use current values
9 local function set_anchor_buttons(knob)
10  
11 RecapAnchorTopLeft:SetNormalTexture("Interface\\AddOns\\Recap\\RecapButtons-Down")
12 RecapAnchorTopLeft:UnlockHighlight()
13 RecapAnchorTopRight:SetNormalTexture("Interface\\AddOns\\Recap\\RecapButtons-Down")
14 RecapAnchorTopRight:UnlockHighlight()
15 RecapAnchorBottomLeft:SetNormalTexture("Interface\\AddOns\\Recap\\RecapButtons-Down")
16 RecapAnchorBottomLeft:UnlockHighlight()
17 RecapAnchorBottomRight:SetNormalTexture("Interface\\AddOns\\Recap\\RecapButtons-Down")
18 RecapAnchorBottomRight:UnlockHighlight()
19  
20 if knob=="RecapAnchorTopLeft" then
21 recap.Opt.GrowUpwards.value = false
22 recap.Opt.GrowLeftwards.value = false
23 elseif knob=="RecapAnchorTopRight" then
24 recap.Opt.GrowUpwards.value = false
25 recap.Opt.GrowLeftwards.value = true
26 elseif knob=="RecapAnchorBottomLeft" then
27 recap.Opt.GrowUpwards.value = true
28 recap.Opt.GrowLeftwards.value = false
29 elseif knob=="RecapAnchorBottomRight" then
30 recap.Opt.GrowUpwards.value = true
31 recap.Opt.GrowLeftwards.value = true
32 else
33 knob = "RecapAnchor"..(recap.Opt.GrowUpwards.value and "Bottom" or "Top")..(recap.Opt.GrowLeftwards.value and "Right" or "Left")
34 end
35 getglobal(knob):SetNormalTexture("Interface\\AddOns\\Recap\\RecapButtons-Up")
36 getglobal(knob):LockHighlight()
37  
38 Recap_MoveMinimize()
39 if recap.Opt.Minimized.value then
40 Recap_Minimize()
41 end
42  
43 end
44  
45 function Recap_InitializeOptions()
46  
47 local chatname,chatid,i
48  
49 RecapAutoFadeSlider:SetValue(recap.Opt.AutoFadeTimer.value)
50 RecapIdleFightSlider:SetValue(recap.Opt.IdleFightTimer.value)
51 RecapMaxRowsSlider:SetValue(recap.Opt.MaxRows.value)
52 RecapMaxRankSlider:SetValue(recap.Opt.MaxRank.value)
53 RecapOptTab1:LockHighlight()
54 RecapOptSubFrame1:Show()
55 RecapOpt_StatDropDownText:SetText(recap.Opt.AutoPost.Stat)
56 _,_,chatid,chatname = string.find(recap.Opt.AutoPost.Channel,"(%d+)-(%w+)")
57 if chatid and chatid~=GetChannelName(chatid) then
58 recap.Opt.AutoPost.Channel = "Self"
59 end
60 RecapOpt_ChannelDropDownText:SetText(recap.Opt.AutoPost.Channel)
61  
62 if recap.UseOneSettings then
63 RecapOptCheck_UseOneSettings:SetChecked(1)
64 else
65 RecapOptCheck_UseOneSettings:SetChecked(0)
66 end
67  
68 -- set check state for all checked options
69 for i in recap.Opt do
70 if RecapOptFrame and recap.Opt[i].type=="Check" then
71 if recap.Opt[i].value==true then
72 getglobal("RecapOptCheck_"..i):SetChecked(1)
73 else
74 getglobal("RecapOptCheck_"..i):SetChecked(0)
75 end
76 end
77 end
78  
79 set_anchor_buttons()
80 end
81  
82 function RecapOpt_OnMouseDown(arg1)
83  
84 if recap_temp.Loaded and arg1=="LeftButton" then
85 RecapOptFrame:StartMoving()
86 end
87 end
88  
89 function RecapOpt_OnMouseUp(arg1)
90  
91 if recap_temp.Loaded and arg1=="LeftButton" then
92 RecapOptFrame:StopMovingOrSizing()
93 end
94 end
95  
96 function Recap_AutoFadeSlider_OnValueChanged(arg1)
97  
98 if recap_temp.Loaded and arg1 then
99 RecapAutoFadeSlider_Text:SetText(arg1.." seconds")
100 recap.Opt.AutoFadeTimer.value = arg1
101 end
102 end
103  
104 function Recap_IdleFightSlider_OnValueChanged(arg1)
105  
106 if recap_temp.Loaded and arg1 then
107 RecapIdleFightSlider_Text:SetText(arg1.." seconds")
108 recap.Opt.IdleFightTimer.value = arg1
109 end
110 end
111  
112 function Recap_MaxRowsSlider_OnValueChanged(arg1)
113  
114 if recap_temp.Loaded and arg1 then
115 RecapMaxRowsSlider_Text:SetText(arg1.." rows")
116 recap.Opt.MaxRows.value = arg1
117 RecapScrollBar_Update()
118 end
119 end
120  
121 function Recap_MaxRankSlider_OnValueChanged(arg1)
122  
123 if recap_temp.Loaded and arg1 then
124 RecapMaxRankSlider_Text:SetText("Rank top "..arg1)
125 recap.Opt.MaxRank.value = arg1
126 end
127 end
128  
129  
130 function RecapOptCheck_OnEnter()
131  
132 local id = this:GetID()
133 Recap_Tooltip(recap_temp.OptList[id][2],recap_temp.OptList[id][3])
134 end
135  
136 function RecapOptCheck_OnClick()
137  
138 local i
139 local id = this:GetID()
140  
141 RecapSetEditBox:ClearFocus()
142  
143 if id>0 and recap_temp.OptList[id][1] then
144 i = getglobal("RecapOptCheck_"..recap_temp.OptList[id][1]):GetChecked()
145 if i==1 then
146 recap.Opt[recap_temp.OptList[id][1]].value = true
147 PlaySound("igMainMenuOptionCheckBoxOn")
148 else
149 recap.Opt[recap_temp.OptList[id][1]].value = false
150 PlaySound("igMainMenuOptionCheckBoxOff")
151 end
152 -- if display list/self checks
153 if ((id>=11 and id<=16) or (id>=26 and id<=27) or (id>=30 and id<=34) or (id>=43 and id<=45)) and not recap.Opt.SelfView.value and not recap.Opt.Minimized.value then
154 Recap_Maximize()
155 elseif (id>=48 and id<=62) and recap.Opt.SelfView.value and not recap.Opt.Minimized.value then
156 Recap_Maximize()
157 -- if display minimized checks
158 elseif ((id>=17 and id<=22) or id==36) and recap.Opt.Minimized.value then
159 Recap_Minimize()
160 elseif recap_temp.OptList[id][1]=="UseColor" then
161 Recap_SetColors()
162 if not recap.Opt.Minimized.value then
163 Recap_SetView()
164 end
165 elseif recap_temp.OptList[id][1]=="ShowTooltips" then
166 GameTooltip:Hide()
167 Recap_OnTooltip("ShowTooltips")
168 elseif recap_temp.OptList[id][1]=="HideFoe" then
169 Recap_SetView()
170 elseif recap_temp.OptList[id][1]=="HideZero" then
171 Recap_SetView()
172 elseif recap_temp.OptList[id][1]=="HideYardTrash" then
173 Recap_SetView()
174 elseif recap_temp.OptList[id][1]=="IdleFight" then
175 if recap.Opt.IdleFight.value and recap.Opt.State.value=="Active" then
176 recap_temp.IdleTimer = 0
177 else
178 recap_temp.IdleTimer = -1
179 end
180 elseif recap_temp.OptList[id][1]=="TooltipFollow" then
181 Recap_OnTooltip("TooltipFollow")
182 elseif recap_temp.OptList[id][1]=="AutoFade" then
183 recap_temp.FadeTimer = -1
184 elseif recap_temp.OptList[id][1]=="MergePets" and not UnitIsVisible then
185 recap.Opt.MergePets.value = false
186 RecapOptCheck_MergePets:SetChecked(0)
187 elseif recap_temp.OptList[id][1]=="GrowLeftwards" or recap_temp.OptList[id][1]=="GrowUpwards" or recap_temp.OptList[id][1]=="AutoMinimize" then
188 Recap_MoveMinimize()
189 if recap.Opt.Minimized.value then
190 Recap_Minimize()
191 end
192 elseif recap_temp.OptList[id][1]=="ShowPanel" then
193 if RecapPanel:IsVisible() then
194 RecapPanel_Hide(1)
195 end
196 elseif recap_temp.OptList[id][1]=="LightData" then
197 if recap.Opt.LightData.value then
198 msg = recap_temp.Local.ConfirmLightData
199 else
200 msg = recap_temp.Local.ConfirmHeavyData
201 end
202 StaticPopupDialogs["RECAP_CONFIRMLIGHTDATA"] = {
203 text = TEXT(msg),
204 button1 = TEXT(ACCEPT),
205 button2 = TEXT(CANCEL),
206 OnAccept = function()
207 recap.DataVersion = recap.DataVersion - 0.01 -- force rebuild of data
208 ReloadUI()
209 end,
210 OnHide = function()
211 RecapOptCheck_LightData:Enable()
212 end,
213 OnCancel = function()
214 recap.Opt.LightData.value = not recap.Opt.LightData.value
215 if recap.Opt.LightData.value then
216 RecapOptCheck_LightData:SetChecked(1)
217 else
218 RecapOptCheck_LightData:SetChecked(0)
219 end
220 end,
221 timeout = 0,
222 showAlert = 1,
223 whileDead = 1
224 }
225  
226 RecapOptCheck_LightData:Disable()
227 StaticPopup_Show("RECAP_CONFIRMLIGHTDATA")
228  
229 elseif recap_temp.OptList[id][1]=="ShowGauges" then
230 RecapScrollBar_Update()
231 end
232  
233 end
234 end
235  
236 function Recap_UseOneSettings_OnClick()
237  
238 i = RecapOptCheck_UseOneSettings:GetChecked()
239 if i==1 then
240 recap.UseOneSettings = true
241 PlaySound("igMainMenuOptionCheckBoxOn")
242 msg = recap_temp.Local.ConfirmGlobalSettings
243 else
244 recap.UseOneSettings = false
245 PlaySound("igMainMenuOptionCheckBoxOff")
246 msg = recap_temp.Local.ConfirmSeparateSettings
247 end
248  
249 StaticPopupDialogs["RECAP_CONFIRMLIGHTDATA"] = {
250 text = TEXT(msg),
251 button1 = TEXT(ACCEPT),
252 button2 = TEXT(CANCEL),
253 OnAccept = function()
254  
255 if recap.UseOneSettings then
256 local i,user
257  
258 for i in recap_set do
259 _,_,user = string.find(i,"^UserData:(.+)")
260 if user and user~=recap_temp.p then
261 recap_set["UserData:"..user] = nil
262 recap[user] = nil
263 end
264 end
265 end
266  
267 ReloadUI()
268 end,
269 OnHide = function()
270 RecapOptCheck_UseOneSettings:Enable()
271 end,
272 OnCancel = function()
273 recap.UseOneSettings = not recap.UseOneSettings
274 if recap.UseOneSettings then
275 RecapOptCheck_UseOneSettings:SetChecked(1)
276 else
277 RecapOptCheck_UseOneSettings:SetChecked(0)
278 end
279 end,
280 timeout = 0,
281 showAlert = 1,
282 whileDead = 1
283 }
284  
285 RecapOptCheck_UseOneSettings:Disable()
286 StaticPopup_Show("RECAP_CONFIRMLIGHTDATA")
287  
288 end
289  
290 --[[ Fight Data Set functions ]]
291  
292 function Recap_InitDataSets()
293  
294 if RecapOptTitle then
295  
296 RecapFightDataSetHeader_Name:SetTextColor(recap_temp.ColorNone.r,recap_temp.ColorNone.g,recap_temp.ColorNone.b)
297 RecapFightDataSetHeader_Date:SetTextColor(recap_temp.ColorNone.r,recap_temp.ColorNone.g,recap_temp.ColorNone.b)
298 RecapFightDataSetHeader_Combatants:SetTextColor(recap_temp.ColorNone.r,recap_temp.ColorNone.g,recap_temp.ColorNone.b)
299  
300 RecapSaveButton:Disable()
301 RecapLoadButton:Disable()
302 RecapDeleteButton:Disable()
303  
304 Recap_BuildFightSets()
305  
306 RecapOptTitle:SetText("Recap v"..Recap_Version.." for "..recap_temp.Player.." of "..recap_temp.Server)
307 end
308 end
309  
310 function Recap_SetEditValidateButtons()
311  
312 local text
313  
314 if recap_temp.Loaded then
315  
316 text = RecapSetEditBox:GetText()
317  
318 if text and text~="" then
319 RecapSaveButton:Enable()
320 else
321 RecapSaveButton:Disable()
322 RecapLoadButton:Disable()
323 RecapDeleteButton:Disable()
324 end
325  
326 recap_temp.FightSetSelected = Recap_SetExists(text)
327 RecapFightSetsScrollBar_Update()
328  
329 if recap_temp.FightSetSelected~=0 then
330 RecapLoadButton:Enable()
331 RecapDeleteButton:Enable()
332 else
333 RecapLoadButton:Disable()
334 RecapDeleteButton:Disable()
335 end
336 end
337 end
338  
339 -- populates recap_temp.FightSets with a list of existing fight sets
340 function Recap_BuildFightSets()
341  
342 local i,friendly
343  
344 recap_temp.FightSetsSize = 1
345 for i in recap_set do
346 if recap_set[i] and not string.find(i,"^UserData:") then
347 if not recap_temp.FightSets[recap_temp.FightSetsSize] then
348 recap_temp.FightSets[recap_temp.FightSetsSize] = {}
349 end
350 recap_temp.FightSets[recap_temp.FightSetsSize].Name = i
351 recap_temp.FightSets[recap_temp.FightSetsSize].Date = recap_set[i].TimeStamp
352 friendly = 0
353 for j in recap_set[i].Combatant do
354 if string.find(recap_set[i].Combatant[j],"^true") then
355 friendly = friendly + 1
356 end
357 end
358 recap_temp.FightSets[recap_temp.FightSetsSize].Combatants = recap_set[i].ListSize .. " ("..friendly..")"
359 recap_temp.FightSetsSize = recap_temp.FightSetsSize + 1
360 end
361 end
362 table.sort(recap_temp.FightSets,Recap_SetSort)
363 end
364  
365 function RecapFightSetsScrollBar_Update()
366  
367 local i, index, item
368  
369 if recap_temp.Loaded then
370  
371 FauxScrollFrame_Update(RecapFightSetsScrollBar,recap_temp.FightSetsSize-1,10,5)
372  
373 for i=1,10 do
374 index = i + FauxScrollFrame_GetOffset(RecapFightSetsScrollBar)
375 if index < recap_temp.FightSetsSize then
376 getglobal("RecapList"..i.."Back"):Hide()
377 getglobal("RecapFightDataList"..i.."_Name"):SetText(recap_temp.FightSets[index].Name)
378 getglobal("RecapFightDataList"..i.."_Date"):SetText(recap_temp.FightSets[index].Date)
379 getglobal("RecapFightDataList"..i.."_Combatants"):SetText(recap_temp.FightSets[index].Combatants)
380 item = getglobal("RecapFightDataList"..i)
381 item:Show()
382 if recap_temp.FightSetSelected == index then
383 item:LockHighlight()
384 else
385 item:UnlockHighlight()
386 end
387 else
388 item = getglobal("RecapFightDataList"..i)
389 item:Hide()
390 item:UnlockHighlight()
391 getglobal("RecapList"..i.."Back"):Show()
392 end
393 end
394  
395 end
396 end
397  
398 function RecapFightData_OnClick()
399  
400 local id = this:GetID()
401  
402 RecapSetEditBox:ClearFocus()
403  
404 index = id + FauxScrollFrame_GetOffset(RecapFightSetsScrollBar)
405  
406 if index < recap_temp.FightSetsSize then
407 recap_temp.FightSetSelected = index
408 RecapSetEditBox:SetText(recap_temp.FightSets[index].Name)
409 RecapSaveButton:Enable()
410 RecapLoadButton:Enable()
411 RecapDeleteButton:Enable()
412 RecapFightSetsScrollBar_Update()
413 end
414 end
415  
416 function Recap_SetExists(arg1)
417  
418 local result = 0
419  
420 for i in recap_temp.FightSets do
421 if recap_temp.FightSets[i].Name == arg1 then
422 result = i
423 end
424 end
425  
426 return result
427 end
428  
429 -- fight data set sort (by date)
430 function Recap_SetSort(e1,e2)
431 if e1 and e2 and ( e1.Date > e2.Date ) then
432 return true
433 else
434 return false
435 end
436 end
437  
438 --[[ Options tabs ]]
439  
440 function RecapOptTab_OnEnter()
441  
442 id = this:GetID()
443  
444 if id and id>0 then
445 Recap_OnTooltip("OptTab"..id)
446 end
447 end
448  
449 function RecapOptTab_OnClick()
450  
451 local id,i = this:GetID()
452 PlaySound("GAMEGENERICBUTTONPRESS")
453  
454 if id and id>0 then
455 for i=1,4 do
456 getglobal("RecapOptTab"..i):UnlockHighlight()
457 getglobal("RecapOptSubFrame"..i):Hide()
458 end
459 RecapOptClipFrame:Hide()
460 getglobal("RecapOptTab"..id):LockHighlight()
461 getglobal("RecapOptSubFrame"..id):Show()
462 end
463 end
464  
465 --[[ drop down lists ]]
466  
467 function RecapDropMenu_OnClick()
468  
469 local id = this:GetID()
470  
471 if recap_temp.CurrentDrop==RecapOpt_StatDropDownButton then
472 recap.Opt.AutoPost.Stat = getglobal("RecapDropMenu"..id.."_Text"):GetText()
473 RecapOpt_StatDropDownText:SetText(recap.Opt.AutoPost.Stat)
474 else
475 recap.Opt.AutoPost.Channel = getglobal("RecapDropMenu"..id.."_Text"):GetText()
476 RecapOpt_ChannelDropDownText:SetText(recap.Opt.AutoPost.Channel)
477 end
478 Recap_DropMenu:Hide()
479 recap_temp.CurrentDrop = nil
480  
481 end
482  
483 function RecapDropMenu_OnEnter()
484  
485 end
486  
487 function Recap_ToggleDropDown()
488  
489 if Recap_DropMenu:IsVisible() and recap_temp.CurrentDrop==this then
490 Recap_DropMenu:Hide()
491 recap_temp.CurrentDrop = nil
492 elseif recap_temp.CurrentDrop~=this and this==RecapOpt_StatDropDownButton then
493 Recap_ShowStatDrop()
494 recap_temp.CurrentDrop = this
495 elseif recap_temp.CurrentDrop~=this then
496 Recap_ShowChannelDrop()
497 recap_temp.CurrentDrop = this
498 end
499  
500 end
501  
502 function Recap_ShowStatDrop()
503  
504 Recap_DropMenu:ClearAllPoints()
505 Recap_DropMenu:SetPoint("TOPLEFT","RecapOpt_StatDropDown","BOTTOMLEFT",16,8)
506 Recap_PopulateDrop(recap_temp.StatDropList)
507 end
508  
509 function Recap_ShowChannelDrop()
510 local new_list = {}
511  
512 Recap_DropMenu:ClearAllPoints()
513 Recap_DropMenu:SetPoint("TOPLEFT","RecapOpt_ChannelDropDown","BOTTOMLEFT",16,8)
514  
515 for i=1,table.getn(recap_temp.ChannelDropList) do
516 table.insert(new_list,recap_temp.ChannelDropList[i])
517 end
518 for i=1,10 do
519 c,name = GetChannelName(i)
520 if name then
521 for i=1,table.getn(recap_temp.Local.SkipChannels) do
522 if string.find(name,recap_temp.Local.SkipChannels[i]) then
523 name = nil
524 i = table.getn(recap_temp.Local.SkipChannels)
525 end
526 end
527 end
528 if name then
529 table.insert(new_list,c.."-"..name)
530 end
531 end
532 Recap_PopulateDrop(new_list)
533 end
534  
535 function Recap_PopulateDrop(arg1)
536  
537 local height = 0
538  
539 for i=1,math.min(8,table.getn(arg1)) do
540 getglobal("RecapDropMenu"..i.."_Text"):SetText(arg1[i])
541 getglobal("RecapDropMenu"..i):Show()
542 height = height + 16
543 end
544 for i=table.getn(arg1)+1,8 do
545 getglobal("RecapDropMenu"..i):Hide()
546 end
547  
548 Recap_DropMenu:SetHeight(height+4)
549 Recap_DropMenu:Show()
550 end
551  
552 function RecapDropMenu_OnUpdate(arg1)
553  
554 if not recap_temp.MenuTimer or MouseIsOver(Recap_DropMenu) or
555 (recap_temp.CurrentDrop and MouseIsOver(recap_temp.CurrentDrop)) then
556 recap_temp.MenuTimer = 0
557 end
558  
559 recap_temp.MenuTimer = recap_temp.MenuTimer + arg1
560 if recap_temp.MenuTimer > .25 then
561 recap_temp.MenuTimer = 0
562 Recap_DropMenu:Hide()
563 recap_temp.CurrentDrop = nil
564 end
565 end
566  
567 local function logline(arg1,clip)
568  
569 local lineformat = recap_temp.Local.LogFormat
570 local str
571 local prefix = recap.Opt.HTML.value and "<b>" or ""
572 local suffix = recap.Opt.HTML.value and "</b>" or ""
573 if recap.Opt.HTML.value then
574 lineformat = recap_temp.Local.HTMLFormat
575 end
576  
577 if arg1=="FirstLine" then
578 str = string.format(lineformat,prefix..recap_temp.Local.Log[1]..suffix,
579 prefix..recap_temp.Local.Log[2]..suffix,
580 prefix..recap_temp.Local.Log[3]..suffix,
581 prefix..recap_temp.Local.Log[4]..suffix,
582 prefix..recap_temp.Local.Log[5]..suffix,
583 prefix..recap_temp.Local.Log[6]..suffix,
584 prefix..recap_temp.Local.Log[7]..suffix,
585 prefix..recap_temp.Local.Log[8]..suffix,
586 prefix..recap_temp.Local.Log[9]..suffix,
587 prefix..recap_temp.Local.Log[10]..suffix,
588 prefix..recap_temp.Local.Log[11]..suffix,
589 prefix..recap_temp.Local.Log[12]..suffix)
590 elseif arg1=="Spacer" then
591 str = recap.Opt.HTML.value and string.format(lineformat," "," "," "," "," "," "," "," "," "," "," "," ") or " "
592 else
593 str = string.format(lineformat,
594 recap_temp.List[arg1].Name,
595 Recap_FormatLevel(recap.Combatant[recap_temp.List[arg1].Name].Level),
596 Recap_FormatClass(recap.Combatant[recap_temp.List[arg1].Name].Class),
597 Recap_FormatTime(recap_temp.List[arg1].Time),
598 recap_temp.List[arg1].Heal,
599 recap_temp.List[arg1].HealP.."%%",
600 recap_temp.List[arg1].DmgIn,
601 recap_temp.List[arg1].DmgInP.."%%",
602 recap_temp.List[arg1].DmgOut,
603 recap_temp.List[arg1].DmgOutP.."%%",
604 recap_temp.List[arg1].MaxHit,
605 string.format("%.1f",recap_temp.List[arg1].DPS))
606 end
607  
608 if str then
609 str = str .. ((clip and not recap.Opt.HTML.value) and "\n" or "")
610 if clip then
611 str = string.gsub(str,"%%%%","%%")
612 end
613 return str
614 end
615 end
616  
617 function Recap_WriteClip()
618  
619 local i,donefriends
620 local headerformat = recap_temp.Local.LogHeader
621  
622 RecapClipEditBox:SetText("")
623 RecapOptSubFrame4:Hide()
624 RecapOptClipFrame:Show()
625 RecapClipEditBox:SetFocus()
626  
627 if recap.Opt.HTML.value then
628 headerformat = recap_temp.Local.HTMLHeader
629 RecapClipEditBox:Insert(recap_temp.Local.HTMLPrefix)
630 end
631  
632 RecapClipEditBox:Insert(string.format(headerformat,UnitName("player"),recap_temp.Local.LastAll[recap.Opt.View.value],date(),GetRealZoneText()).."\n")
633 RecapClipEditBox:Insert(logline("FirstLine","clip"))
634  
635 for i=1,recap_temp.ListSize-1 do
636  
637 if not donefriends and not recap.Combatant[recap_temp.List[i].Name].Friend then
638 if not recap.Opt.WriteFriends.value then
639 RecapClipEditBox:Insert(logline("Spacer","clip"))
640 end
641 donefriends = true
642 end
643  
644 if not donefriends or not recap.Opt.WriteFriends.value then
645 RecapClipEditBox:Insert(logline(i,"clip"))
646 end
647 end
648  
649 if recap.Opt.HTML.value then
650 RecapClipEditBox:Insert(recap_temp.Local.HTMLSuffix)
651 end
652  
653 RecapClipEditBox:HighlightText()
654  
655 end
656  
657  
658 function Recap_WriteLog()
659  
660 local i,chatnum,chatname,freeslot,donefriends,alreadyin
661 local lines = 0
662 local logchat = "recaplog"..string.lower(UnitName("player"))
663 local headerformat = recap_temp.Local.LogHeader
664 local prefix,suffix = "", ""
665  
666 for i=1,10 do
667 _,chatname = GetChannelName(i)
668 if not chatname then
669 freeslot = true
670 elseif string.lower(chatname)==logchat then
671 freeslot = true
672 alreadyin = true
673 end
674 end
675  
676 if freeslot then
677  
678 if not alreadyin then
679 RecapFrame:RegisterEvent("CHAT_MSG_CHANNEL_NOTICE")
680 JoinChannelByName(logchat)
681 RecapOpt_WriteLogLabel:SetText(RECAP_ACQUIRING_CHANNEL)
682 end
683  
684 chatnum = nil
685 for i=1,10 do
686 j,chatname = GetChannelName(i)
687 if chatname and string.lower(chatname)==logchat then
688 chatnum=j
689 end
690 end
691  
692 if chatnum then
693  
694 if recap.Opt.HTML.value then
695 headerformat = recap_temp.Local.HTMLHeader
696 prefix = "-->"
697 suffix = "<!--"
698 SendChatMessage(recap_temp.Local.HTMLPrefix..prefix,"CHANNEL",nil,chatnum)
699 end
700  
701 -- we're in a channel
702 SendChatMessage(prefix..string.format(headerformat,UnitName("player"),recap_temp.Local.LastAll[recap.Opt.View.value],date(),GetRealZoneText())..suffix,"CHANNEL",nil,chatnum)
703 SendChatMessage(prefix..logline("FirstLine")..suffix,"CHANNEL",nil,chatnum)
704  
705 for i=1,recap_temp.ListSize-1 do
706  
707 if lines<(recap_temp.MaxLogLines/(recap.Opt.HTML.value and 2 or 1)) then
708 -- MaxLogLines defined in localization.lua. When writing in HTML, halve the limit to prevent disconnect
709 if not donefriends and not recap.Combatant[recap_temp.List[i].Name].Friend then
710 if not recap.Opt.WriteFriends.value then
711 SendChatMessage(prefix..logline("Spacer")..suffix,"CHANNEL",nil,chatnum)
712 end
713 donefriends = true
714 end
715  
716 if not donefriends or not recap.Opt.WriteFriends.value then
717 SendChatMessage(prefix..logline(i)..suffix,"CHANNEL",nil,chatnum)
718 end
719  
720 lines = lines + 1
721 end
722 end
723  
724 if recap.Opt.HTML.value then
725 SendChatMessage(prefix..recap_temp.Local.HTMLSuffix,"CHANNEL",nil,chatnum)
726 end
727 SendChatMessage("EOF","CHANNEL",nil,chatnum)
728  
729 end
730  
731 else
732 DEFAULT_CHAT_FRAME:AddMessage(recap_temp.Local.NoFreeChannels)
733 RecapWriteLogButton:Enable()
734 end
735  
736 end
737  
738 function Recap_FormatLevel(arg1)
739  
740 if arg1 and arg==-1 then
741 return "??"
742 elseif arg1 and tonumber(arg1) and tonumber(arg1)>0 then
743 return arg1
744 else
745 return ""
746 end
747 end
748  
749 function Recap_FormatClass(arg1)
750  
751 if classabr[arg1] then
752 return classabr[arg1]
753 else
754 return ""
755 end
756 end
757  
758 -- removes character-specific
759 function Recap_UseOneSettings()
760  
761 for i in recap_set do
762 _,_,user = string.find(i,"^UserData:(.+)")
763 if user and user~=recap_temp.p then
764 recap_set["UserData:"..user] = nil
765 recap[user] = nil
766 end
767 end
768 recap.UseOneSettings = true
769  
770 end
771  
772 function RecapAnchor_OnEnter()
773 Recap_OnTooltip(this:GetName())
774 end
775  
776  
777 function RecapAnchor_OnClick()
778  
779 set_anchor_buttons(this:GetName())
780  
781 end