vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 DeuceCommander
3 "A graphical interface for my Ace2 mods' /commands!? EGAD!"
4  
5 By Neronix of Hellscream EU
6 --]]
7  
8 DeuceCommander = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0", "AceConsole-2.0", "AceDB-2.0", "FuBarPlugin-2.0")
9  
10 DeuceCommander.hasIcon = "Interface\\Icons\\INV_Gizmo_07"
11 DeuceCommander.defaultPosition = "RIGHT"
12  
13 local console = AceLibrary("AceConsole-2.0")
14 local dewdrop = AceLibrary("Dewdrop-2.0")
15 local tablet = AceLibrary("Tablet-2.0")
16  
17 --localization need to translate for non-us client
18 local CATEGORIES = {
19 ["Action Bars"] = "Action Bars",
20 ["Auction"] = "Auction",
21 ["Audio"] = "Audio",
22 ["Battlegrounds/PvP"] = "Battlegrounds/PvP",
23 ["Buffs"] = "Buffs",
24 ["Chat/Communication"] = "Chat/Communication",
25 ["Druid"] = "Druid",
26 ["Hunter"] = "Hunter",
27 ["Mage"] = "Mage",
28 ["Paladin"] = "Paladin",
29 ["Priest"] = "Priest",
30 ["Rogue"] = "Rogue",
31 ["Shaman"] = "Shaman",
32 ["Warlock"] = "Warlock",
33 ["Warrior"] = "Warrior",
34 ["Healer"] = "Healer",
35 ["Tank"] = "Tank",
36 ["Caster"] = "Caster",
37 ["Combat"] = "Combat",
38 ["Compilations"] = "Compilations",
39 ["Data Export"] = "Data Export",
40 ["Development Tools"] = "Development Tools",
41 ["Guild"] = "Guild",
42 ["Frame Modification"] = "Frame Modification",
43 ["Interface Enhancements"] = "Interface Enhancements",
44 ["Inventory"] = "Inventory",
45 ["Library"] = "Library",
46 ["Map"] = "Map",
47 ["Mail"] = "Mail",
48 ["Miscellaneous"] = "Miscellaneous",
49 ["Quest"] = "Quest",
50 ["Raid"] = "Raid",
51 ["Tradeskill"] = "Tradeskill",
52 ["UnitFrame"] = "UnitFrame",
53 }
54 local DC_HINT = "Right-click me to get started!"
55 local DC_NODESC = "No Description Provided"
56  
57 if GetLocale() == "zhCN" then
58 CATEGORIES = {
59 ["Action Bars"] = "动作条",
60 ["Auction"] = "拍卖",
61 ["Audio"] = "声音",
62 ["Battlegrounds/PvP"] = "战场/PvP",
63 ["Buffs"] = "增益法术",
64 ["Chat/Communication"] = "聊天/交流",
65 ["Druid"] = "德鲁伊",
66 ["Hunter"] = "猎人",
67 ["Mage"] = "法师",
68 ["Paladin"] = "圣骑士",
69 ["Priest"] = "牧师",
70 ["Rogue"] = "盗贼",
71 ["Shaman"] = "萨满祭司",
72 ["Warlock"] = "术士",
73 ["Warrior"] = "战士",
74 ["Healer"] = "治疗者",
75 ["Tank"] = "坦克",
76 ["Caster"] = "施法者",
77 ["Combat"] = "战斗",
78 ["Compilations"] = "整合",
79 ["Data Export"] = "数据导出",
80 ["Development Tools"] = "开发工具",
81 ["Guild"] = "公会",
82 ["Frame Modification"] = "框体修改",
83 ["Interface Enhancements"] = "界面加强",
84 ["Inventory"] = "背包",
85 ["Library"] = "运行库",
86 ["Map"] = "地图",
87 ["Mail"] = "邮件",
88 ["Miscellaneous"] = "杂项",
89 ["Quest"] = "任务",
90 ["Raid"] = "团队",
91 ["Tradeskill"] = "商业技能",
92 ["UnitFrame"] = "人物框体",
93 }
94 DC_HINT = "右键点击显示菜单!"
95 DC_NODESC = "没有提供描述"
96 elseif GetLocale() == "koKR" then
97 CATEGORIES = {
98 ["Action Bars"] = "액션바",
99 ["Auction"] = "경매",
100 ["Audio"] = "음향",
101 ["Battlegrounds/PvP"] = "전장/PvP",
102 ["Buffs"] = "버프",
103 ["Chat/Communication"] = "대화/의사소통",
104 ["Druid"] = "드루이드",
105 ["Hunter"] = "사냥꾼",
106 ["Mage"] = "마법사",
107 ["Paladin"] = "성기사",
108 ["Priest"] = "사제",
109 ["Rogue"] = "도적",
110 ["Shaman"] = "주술사",
111 ["Warlock"] = "흑마법사",
112 ["Warrior"] = "전사",
113 ["Healer"] = "힐러",
114 ["Tank"] = "탱커",
115 ["Caster"] = "캐스터",
116 ["Combat"] = "전투",
117 ["Compilations"] = "복합",
118 ["Data Export"] = "자료 출력",
119 ["Development Tools"] = "개발 도구",
120 ["Guild"] = "길드",
121 ["Frame Modification"] = "구조 변경",
122 ["Interface Enhancements"] = "인터페이스 강화",
123 ["Inventory"] = "인벤토리",
124 ["Library"] = "라이브러리",
125 ["Map"] = "지도",
126 ["Mail"] = "우편",
127 ["Miscellaneous"] = "기타",
128 ["Quest"] = "퀘스트",
129 ["Raid"] = "공격대",
130 ["Tradeskill"] = "전문기술",
131 ["UnitFrame"] = "유닛 프레임",
132 }
133 DC_HINT = "우클릭시 설정창을 엽니다!"
134 end
135  
136 DeuceCommander:RegisterDB("DeuceCommanderDB")
137  
138 function DeuceCommander:OnInitialize()
139 self:RegisterChatCommand({"/deucecommander", "/deucecomm"})
140  
141 -- Create the root of our AceOptions table, ready for addons' tables to be inserted
142 self.theTable = { type = "group", args = {} }
143 end
144  
145 function DeuceCommander:OnEnable()
146 self:Construct()
147  
148 function self:OnMenuRequest(level, value)
149 dewdrop:FeedAceOptionsTable(self.theTable)
150 if level == 1 then dewdrop:AddLine() end
151 end
152  
153 -- When another addon's loaded, :Construct again to check if the new addon's got a slash command to be added. It's run 2 seconds after ADDON_LOADED to ensure that its slash command is definitely registered
154 self:RegisterEvent("ADDON_LOADED", function() self:ScheduleEvent(self.Construct, 2, self) end)
155 end
156  
157 function DeuceCommander:OnTooltipUpdate()
158 tablet:SetHint(DC_HINT)
159 end
160  
161 function DeuceCommander:Construct()
162 for k,v in pairs(console.registry) do -- v will be the current slash command being dealt with. k is almost always 8 randomly generated characters (Why, ckknight!?)
163  
164 -- Explanation of the following logic: If there's no handler and name attached to it, it's probably not a command we should deal with
165 -- In a slash command we want to deal with, .handler is a link to the addon object that the command belongs to
166 -- And if the entry for the mod's already there, no need to do it again
167 if type(v) == "table" and v.handler and v.handler.name and not self.theTable.args[v.handler.name] then
168  
169 local addonName = v.handler.name
170 local category = GetAddOnMetadata(addonName, "X-Category") or "Miscellaneous"
171 category = self:stripSpaces(category)
172 if not CATEGORIES[category] then
173 category = CATEGORIES["Miscellaneous"]
174 else
175 category = CATEGORIES[category]
176 end
177 -- remove space, because of a Dewdrop limitation
178 category = gsub(category, " ", "_")
179  
180 if not self.theTable.args[category] then
181 self.theTable.args[category] = {
182 name = category,
183 desc = string.format("AddOns in category %s.", category),
184 type = "group",
185 args = {}
186 }
187 end
188 local cattbl = self.theTable.args[category]
189  
190 -- remove space, because of a Dewdrop limitation
191 addonName = gsub(addonName, " ", "_")
192  
193 if (not v.name) or (v.name == "") then
194 v.name = addonName
195 end
196  
197 if (not v.desc) or (v.desc == "") then
198 if (not v.handler.notes) or (v.handler.notes == "") then
199 v.desc = DC_NODESC
200 else
201 v.desc = v.handler.notes
202 end
203 end
204  
205 cattbl.args[addonName] = v -- Stick the mod's table in the root group
206 end
207 end
208 end
209  
210 function DeuceCommander:stripSpaces(text)
211 if type(text) == "string" then
212 return (string.gsub(string.gsub(text, "^%s*(.-)%s*$", "%1"), "%s%s+", " "))
213 end
214 return text
215 end