vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | if not SimpleCombatLog then return end |
2 | |||
3 | local dewdrop = AceLibrary("Dewdrop-2.0") |
||
4 | local defaultFormats = SimpleCombatLog.loc.defaultFormats |
||
5 | |||
6 | local L = SimpleCombatLog.loc.format |
||
7 | |||
8 | |||
9 | |||
10 | SimpleCombatLog.formatList = { |
||
11 | Combat = { |
||
12 | "hit", "hitCrit", "hitDOT", "heal", "healCrit", "healDOT", "miss", "gain", "drain", "leech", "environment" |
||
13 | }, |
||
14 | Spell = { |
||
15 | "buff", "debuff", "fade", "dispel", "dispelFailed", "extraattack", "cast", "castBegin", "castTargeted", "interrupt", |
||
16 | }, |
||
17 | Misc = { |
||
18 | "create", "death", "deathSource", "deathSkill", "honor", "honorKill", "dishonor", "experience", "reputation", "reputationRank", "reputationMinus", "enchant", "feedpet", "fail", |
||
19 | }, |
||
20 | Trailer = { |
||
21 | "crushing", "glancing", "absorb", "resist", "block", "vulnerable", "", |
||
22 | "expSource", "expBonus", "expGroup", "expRaid" |
||
23 | }, |
||
24 | } |
||
25 | |||
26 | function SimpleCombatLog:SetFormat(id, msgType, newFormat) |
||
27 | if not self.settings[id] then |
||
28 | self.settings[id] = {} |
||
29 | self.settingDB[id] = self.settings[id] |
||
30 | else |
||
31 | if self.settings[id].theme then |
||
32 | self.settings[id] = SimpleCombatLog.CopyTable({}, self.settings[id]) |
||
33 | self.settings[id].theme = nil |
||
34 | self.settingDB[id] = self.settings[id] |
||
35 | end |
||
36 | end |
||
37 | |||
38 | |||
39 | if not self.settings[id].formats then |
||
40 | self.settings[id].formats = {} |
||
41 | end |
||
42 | |||
43 | self.settings[id].formats[msgType] = newFormat |
||
44 | end |
||
45 | |||
46 | function SimpleCombatLog:RestoreDefaultFormats(id) |
||
47 | if self.settings[id] and self.settings[id].formats then |
||
48 | self.settings[id].formats = nil |
||
49 | end |
||
50 | end |
||
51 | |||
52 | -- arg1: the format string |
||
53 | -- arg2, arg3, ... : the tokens to replace with. |
||
54 | function SimpleCombatLog:ConvertFormat(...) |
||
55 | local msg = string.gsub(table.remove(arg, 1), "|", "||") -- "add slash" so that users can see color codes. |
||
56 | for i in pairs(arg) do |
||
57 | arg[i] = string.format("#%s#", arg[i]) |
||
58 | end |
||
59 | return string.format(msg, unpack(arg) ) |
||
60 | end |
||
61 | |||
62 | -- arg1: the format string |
||
63 | -- arg2, arg3, ... : the tokens to replace with. |
||
64 | function SimpleCombatLog:UnconvertFormat(...) |
||
65 | local msg = string.gsub(table.remove(arg, 1), "||", "|") -- "strip slash" to convert back to actual color codes. |
||
66 | local n = table.getn(arg) |
||
67 | for i in ipairs(arg) do |
||
68 | arg[i] = string.format("#%s#", arg[i]) |
||
69 | msg = string.gsub(msg, arg[i], string.format("%%%%%d$s", i) ) |
||
70 | end |
||
71 | return msg |
||
72 | end |
||
73 | |||
74 | local function UpdateFormatOptionsTable(self, id, level, value) |
||
75 | if level == 1 then |
||
76 | dewdrop:AddLine( |
||
77 | 'text', L["Formats"], |
||
78 | 'notCheckable', true, |
||
79 | 'hasArrow', true, |
||
80 | 'value', 'format' |
||
81 | ) |
||
82 | |||
83 | elseif level == 2 and value == 'format' then |
||
84 | |||
85 | self.currMenuType = 'format' |
||
86 | |||
87 | for i, group in { "Combat", "Spell", "Misc", "Trailer" } do |
||
88 | dewdrop:AddLine( |
||
89 | 'text', L[group], |
||
90 | 'hasArrow', true, |
||
91 | 'value', group |
||
92 | ) |
||
93 | end |
||
94 | |||
95 | dewdrop:AddLine() |
||
96 | dewdrop:AddLine( |
||
97 | 'text', L["Restore default formats"], |
||
98 | 'notCheckable', true, |
||
99 | 'func', function() self:RestoreDefaultFormats(id) end |
||
100 | ) |
||
101 | |||
102 | elseif level == 3 and self.currMenuType == 'format' then |
||
103 | |||
104 | local msgType, formats, isDefault |
||
105 | |||
106 | for i, v in self.formatList[value] do |
||
107 | if v ~= "" then |
||
108 | msgType = v |
||
109 | formats, isDefault = self:GetFormat(id, v) |
||
110 | if not isDefault then msgType = self:Colorize(msgType, self.defaultColors.dirty) end |
||
111 | dewdrop:AddLine( |
||
112 | 'text', msgType, |
||
113 | 'notCheckable', true, |
||
114 | 'hasArrow', true, |
||
115 | 'hasEditBox', true, |
||
116 | 'editBoxText', self:ConvertFormat(formats, unpack(defaultFormats[v][2])), |
||
117 | 'editBoxFunc', function(id, msgType, msgFormat) self:SetFormat(id, msgType, self:UnconvertFormat(msgFormat, unpack(defaultFormats[msgType][2]))) end, |
||
118 | 'editBoxArg1', id, |
||
119 | 'editBoxArg2', v |
||
120 | ) |
||
121 | else |
||
122 | dewdrop:AddLine() |
||
123 | end |
||
124 | end |
||
125 | |||
126 | end |
||
127 | |||
128 | end |
||
129 | |||
130 | if SimpleCombatLog.menuFunc then |
||
131 | SimpleCombatLog.menuFunc[4] = UpdateFormatOptionsTable |
||
132 | end |
||
133 |