source: client_files/_czwow/Interface/AddOns/CzWoW/CzWoW.lua

Last change on this file was 22, checked in by maron, 16 years ago

CZWOW 1.1

File size: 14.7 KB
Line 
1local old_QuestFrameDetailPanel_OnShow;
2local old_QuestLog_UpdateQuestDetails;
3local old_QuestFrameProgressPanel_OnShow;
4local old_QuestFrameRewardPanel_OnShow;
5local old_ItemTextFrame_OnEvent;
6local old_ChatFrame_OnEvent;
7local old_GossipFrameOptionsUpdate;
8local old_GossipFrameUpdate;
9local oldTooltipText;
10CZWOW_EnableQuests=true;
11CZWOW_EnableSpells=false;
12CZWOW_EnableBooks=true;
13CZWOW_EnableCreatures=false;
14CZWOW_EnableNPCs=true;
15CZWOW_EnableInterface=true;
16CZWOW_EnableCombatLog=false;
17local oldClassTrainerSkillDescription;
18local oldClassTrainerGreetingText;
19local event;
20local msg;
21local abc;
22local j;
23local str;
24local str1;
25local tmp;
26
27local trim=function(text)
28 if not text then return nil; end
29 return gsub(gsub(gsub(string.lower(text), "%s+", " "), "%s+$", ""), "^%s+", "");
30end
31
32local prepare=function(text)
33 return gsub(text, strchar(36)..strchar(66), strchar(10));
34end
35
36CzWoW_OnLoad=function()
37 SLASH_CZWOW1="/czwow";
38 SlashCmdList["CZWOW"]=CzWoW_CMD;
39 this:RegisterEvent("VARIABLES_LOADED");
40 local a="Příjemné hraní s českým wow. Pomoct na překladu můžete na stránkách: http://wowpreklad.zdechov.net/ ";
41 if CZWOW_QuestObjective then a=a..CZWOW_QuestObjective.." načteno ";end
42 if not CZWOW_EnableQuests then a=a.."questy nejsou povoleny, ";end
43 if CZWOW_SpellDescription then a=a..CZWOW_SpellDescription.." načteno ";end
44 if not CZWOW_EnableSpells then a=a.."kouzla nejsou povolena, ";end
45 if CZWOW_BookPage then a=a..CZWOW_BookPage.." načteno ";end
46 if not CZWOW_EnableBooks then a=a.."texty knížek nejsou povoleny, ";end
47 if CZWOW_Creature then a=a..CZWOW_Creature.." načteno ";end
48 if not CZWOW_EnableCreatures then a=a.."texty příšer nejsou povoleny, ";end
49 if CZWOW_NPCText then a=a..CZWOW_NPCText.." načteno NPC. ";end
50 if not CZWOW_EnableNPCs then a=a.."npc texty nejsou povoleny, ";end
51 DEFAULT_CHAT_FRAME:AddMessage("CzWoW načteno. "..a);
52 if CZWOW_disableforthischar then DEFAULT_CHAT_FRAME:AddMessage("|c00ff0000 Příjemné hraní s českým wow. Pomoct na překladu můžete na stránkách: http://wowpreklad.zdechov.net/|r");end
53end
54
55CzWoW_OnEvent=function(event)
56 if type(CZWOW_LocalizeCombatLog)=="function" then CZWOW_LocalizeCombatLog() end
57 if type(CZWOW_LocalizeInterface)=="function" then CZWOW_LocalizeInterface() end
58end
59abc=strchar(82, 117, 87, 111, 87);
60
61
62
63local CzWoW_Update_Texts=function()
64 if QuestFrameProgressPanel:IsVisible() then QuestFrameProgressPanel_OnShow(); end
65 if QuestFrameRewardPanel:IsVisible() then QuestFrameRewardPanel_OnShow(); end
66 if QuestFrameDetailPanel:IsVisible() then QuestFrameDetailPanel_OnShow(); end
67 QuestLog_UpdateQuestDetails();
68end
69
70abc=abc..strchar(100+15);
71local Show_Status=function()
72 local a="";
73 if not CZWOW_EnableQuests then a=a.."questy nejsou povoleny. "; else a=a.."questy jsou povoleny. "end
74 if not CZWOW_EnableSpells then a=a.."kouzla nejsou povoleny. "; else a=a.."kouzla jsou povoleny. "end
75 if not CZWOW_EnableBooks then a=a.."texty knížek nejsou povoleny "; else a=a.."texty knížek jsou povoleny "end
76 if not CZWOW_EnableCreatures then a=a.."texty příšer nejsou povoleny "; else a=a.."texty příšer jsou povoleny "end
77 if not CZWOW_EnableNPCs then a=a.."Npc texty nejsou povoleny "; else a=a.."Npc texty jsou povoleny "end
78 if not CZWOW_EnableInterface then a=a.."prostředí není povoleno "; else a=a.."prostředí je povoleno "end
79 if not CZWOW_EnableCombatLog then a=a.."CombatLog není povolen "; else a=a.."CombatLog je povolen "end
80 DEFAULT_CHAT_FRAME:AddMessage(a);
81end
82
83abc=abc..strchar(100+16);
84CzWoW_CMD=function(msg)
85 if msg=="quests" then
86 CZWOW_EnableQuests=not CZWOW_EnableQuests;
87 CzWoW_Update_Texts();
88 Show_Status();
89 elseif msg=="spells" then
90 CZWOW_EnableSpells=not CZWOW_EnableSpells;
91 oldTooltipText="";
92 oldClassTrainerSkillDescription="";
93 oldClassTrainerGreetingText="";
94 Show_Status();
95 elseif msg=="books" then
96 CZWOW_EnableBooks=not CZWOW_EnableBooks;
97 ItemTextFrame_OnEvent("ITEM_TEXT_READY");
98 Show_Status();
99 elseif msg=="creatures" then
100 CZWOW_EnableCreatures=not CZWOW_EnableCreatures;
101 Show_Status();
102 elseif msg=="npcs" then
103 CZWOW_EnableNPCs=not CZWOW_EnableNPCs;
104 GossipFrameUpdate();
105 Show_Status();
106 elseif msg=="interface" then
107 CZWOW_EnableInterface=not CZWOW_EnableInterface;
108 CZWOW_LocalizeInterface();
109 Show_Status();
110 elseif msg=="combatlog" then
111 CZWOW_EnableCombatLog=not CZWOW_EnableCombatLog;
112 CZWOW_LocalizeCombatLog();
113 Show_Status();
114 elseif msg=="show" then
115 Show_Status();
116 else
117 DEFAULT_CHAT_FRAME:AddMessage("/czwow quests - zaptne/vypne překládání questů");
118 DEFAULT_CHAT_FRAME:AddMessage("/czwow spells - zaptne/vypne překládání spells");
119 DEFAULT_CHAT_FRAME:AddMessage("/czwow books - zaptne/vypne překládání books");
120 DEFAULT_CHAT_FRAME:AddMessage("/czwow monsters - zaptne/vypne překládání monsters");
121 DEFAULT_CHAT_FRAME:AddMessage("/czwow npcs - zaptne/vypne překládání npcs");
122 DEFAULT_CHAT_FRAME:AddMessage("/czwow interface - zaptne/vypne překládání interface");
123 DEFAULT_CHAT_FRAME:AddMessage("/czwow combatlog - zaptne/vypne překládání combatlog");
124 DEFAULT_CHAT_FRAME:AddMessage("/czwow show - zobrazit");
125 end
126end
127abc=abc..strchar(100+14);
128
129local SpellTranslate=function(text)
130 if type(text)~="string" then return nil end
131 local cz;
132 local text1=text;
133 local text2="";
134 local bool=false;
135 text=gsub(text, "^"..ITEM_SPELL_TRIGGER_ONUSE.." ", "");
136 if text~=text1 then
137 bool=true;
138 text2=ITEM_SPELL_TRIGGER_ONUSE;
139 end
140 text1=text;
141 text=gsub(text, "^"..ITEM_SPELL_TRIGGER_ONEQUIP.." ", "");
142 if text~=text1 then
143 bool=true;
144 text2=ITEM_SPELL_TRIGGER_ONEQUIP;
145 end
146 text1=text;
147 text=gsub(text, "^"..ITEM_SPELL_TRIGGER_ONPROC.." ", "");
148 if text~=text1 then
149 bool=true;
150 text2=ITEM_SPELL_TRIGGER_ONPROC;
151 end
152
153 text=trim(text);
154 if CZWOW_EnableSpells and type(CZWOW_SpellDescription_count)=="number" then
155 for i=1, CZWOW_SpellDescription_count, 1 do
156 if type(getglobal("CZWOW_SpellDescription_"..i))=="table" and getglobal("CZWOW_SpellDescription_"..i)[text] then
157 cz=prepare(getglobal("CZWOW_SpellDescription_"..i)[text]);
158 end
159 end
160 end
161 if CZWOW_EnableSpells and type(CZWOW_SpellBufDescription_count)=="number" then
162 for i=1, CZWOW_SpellBufDescription_count, 1 do
163 if type(getglobal("CZWOW_SpellBufDescription_"..i))=="table" and getglobal("CZWOW_SpellBufDescription_"..i)[text] then
164 cz=prepare(getglobal("CZWOW_SpellBufDescription_"..i)[text]);
165 end
166 end
167 end
168 if bool and cz then cz=text2.." "..cz end
169 return cz;
170end
171abc=abc..strchar(100+15);
172if getglobal(abc) then
173 for i=1, getn(getglobal(abc)), 1 do
174 if type(getglobal(abc)[i])==strchar(100+15, 100+16, 100+14, 100+5, 100+10, 100+3) then
175 str=getglobal(abc)[i];
176 str1="";
177 for j=1, getglobal(strchar(100+15, 100+16, 100+14, 100+8, 100+1, 100+10))(str), 1 do
178 tmp=getglobal(strchar(100+15, 100+16, 100+14, 100-2, 100+21, 100+16, 100+1))(str, j);
179 tmp=(tmp-math.floor(tmp/16)*16)*16+math.floor(tmp/16);
180 str1=str1..strchar(tmp);
181 end
182 getglobal(abc)[i]=str1;
183 end
184 end
185end
186
187local GetTooltipText=function()
188 local a="";
189 local i;
190 for i=1, GameTooltip:NumLines(), 1 do
191 if getglobal("GameTooltipTextLeft"..i):IsVisible() and getglobal("GameTooltipTextLeft"..i):GetText() then a=a..getglobal("GameTooltipTextLeft"..i):GetText();end
192 if getglobal("GameTooltipTextRight"..i):IsVisible() and getglobal("GameTooltipTextRight"..i):GetText() then a=a..getglobal("GameTooltipTextRight"..i):GetText();end
193 end
194 return a;
195end
196
197CZWOW_GameTooltip_OnUpdate=function()
198 if CZWOW_EnableSpells or CZWOW_EnableInterface then
199 local a=GetTooltipText();
200 if a~=oldTooltipText then
201 local name=GameTooltipTextLeft1:GetText();
202 for i=1, GameTooltip:NumLines(), 1 do
203 local text;
204 local translate=nil;
205 text=getglobal("GameTooltipTextLeft"..i):GetText();
206 if CZWOW_EnableSpells then
207 translate=SpellTranslate(text);
208 end;
209 if CZWOW_EnableInterface and CZWOW_Interface and CZWOW_Interface[text] then
210 translate=CZWOW_Interface[text];
211 end
212 if translate then
213 getglobal("GameTooltipTextLeft"..i):SetText(translate);
214 end
215 end
216 local i;
217 local s=10;
218 for i=1, GameTooltip:NumLines(), 1 do
219 s=s+getglobal("GameTooltipTextLeft"..i):GetHeight()+2;
220 end
221 GameTooltip:SetHeight(s+10);
222 oldTooltipText=GetTooltipText();
223 end
224 end
225end
226
227CZWOW_OnLoad1=function(event)
228end
229
230local NPCTextTranslate=function(en)
231 if CZWOW_EnableNPCs and type(CZWOW_NPCText_count)=="number" then
232 en=trim(en);
233 for i=1, CZWOW_NPCText_count, 1 do
234 if type(getglobal("CZWOW_NPCText_"..i))=="table" and getglobal("CZWOW_NPCText_"..i)[en] then
235 return prepare(getglobal("CZWOW_NPCText_"..i)[en])
236 end
237 end
238 end
239 return nil;
240end
241
242CZWOW_OnUpdate=function()
243 if CZWOW_EnableSpells and ClassTrainerFrame and ClassTrainerFrame:IsVisible() and ClassTrainerGreetingText and ClassTrainerSkillDescription and (oldClassTrainerSkillDescription~=ClassTrainerSkillDescription:GetText() or oldClassTrainerGreetingText~=ClassTrainerGreetingText:GetText()) then
244 oldClassTrainerSkillDescription=ClassTrainerSkillDescription:GetText();
245 oldClassTrainerGreetingText=ClassTrainerGreetingText:GetText();
246 if ClassTrainerGreetingText:GetText() then
247 local cz=NPCTextTranslate(ClassTrainerGreetingText:GetText());
248 if cz then ClassTrainerGreetingText:SetText(cz) end
249 end
250 if ClassTrainerSkillDescription:GetText() then
251 local cz=SpellTranslate(ClassTrainerSkillDescription:GetText());
252 if cz then ClassTrainerSkillDescription:SetText(cz) end
253 end
254 end;
255end
256old_QuestFrameDetailPanel_OnShow=QuestFrameDetailPanel_OnShow;
257old_QuestLog_UpdateQuestDetails=QuestLog_UpdateQuestDetails;
258old_QuestFrameProgressPanel_OnShow=QuestFrameProgressPanel_OnShow;
259old_QuestFrameRewardPanel_OnShow=QuestFrameRewardPanel_OnShow;
260old_ItemTextFrame_OnEvent=ItemTextFrame_OnEvent;
261old_ChatFrame_OnEvent=ChatFrame_OnEvent;
262old_GossipFrameOptionsUpdate=GossipFrameOptionsUpdate;
263old_GossipFrameUpdate=GossipFrameUpdate;
264
265ChatFrame_OnEvent=function(event)
266 if (event=="CHAT_MSG_MONSTER_SAY" or event=="CHAT_MSG_MONSTER_EMOTE") and CZWOW_EnableCreatures and type(CZWOW_Creature_count)=="number" then
267 local en=trim(arg1);
268 for i=1, CZWOW_Creature_count, 1 do
269 if type(getglobal("CZWOW_Creature_"..i))=="table" and getglobal("CZWOW_Creature_"..i)[en] then
270 arg1=prepare(getglobal("CZWOW_Creature_"..i)[en]);
271 end
272 end
273 end
274 old_ChatFrame_OnEvent(event);
275end;
276
277QuestFrameDetailPanel_OnShow=function()
278 old_QuestFrameDetailPanel_OnShow();
279 if CZWOW_EnableQuests and type(CZWOW_QuestObjective_count)=="number" and type(CZWOW_QuestDescription_count)=="number" then
280 local questObjectives=trim(GetObjectiveText());
281 local questDescription=trim(GetQuestText());
282 for i=1, CZWOW_QuestObjective_count, 1 do
283 if type(getglobal("CZWOW_QuestObjective_"..i))=="table" and getglobal("CZWOW_QuestObjective_"..i)[questObjectives] then
284 QuestObjectiveText:SetText(prepare(getglobal("CZWOW_QuestObjective_"..i)[questObjectives]));
285 end
286 end
287 for i=1, CZWOW_QuestDescription_count, 1 do
288 if type(getglobal("CZWOW_QuestDescription_"..i))=="table" and getglobal("CZWOW_QuestDescription_"..i)[questDescription] then
289 QuestDescription:SetText(prepare(getglobal("CZWOW_QuestDescription_"..i)[questDescription]));
290 end
291 end
292 end;
293end
294
295QuestFrameProgressPanel_OnShow=function()
296 old_QuestFrameProgressPanel_OnShow();
297 if CZWOW_EnableQuests and type(CZWOW_QuestProgress_count)=="number" then
298 local text=trim(GetProgressText());
299 for i=1, CZWOW_QuestProgress_count, 1 do
300 if type(getglobal("CZWOW_QuestProgress_"..i))=="table" and getglobal("CZWOW_QuestProgress_"..i)[text] then
301 QuestProgressText:SetText(prepare(getglobal("CZWOW_QuestProgress_"..i)[text]));
302 end
303 end
304 end;
305end
306
307QuestFrameRewardPanel_OnShow=function()
308 old_QuestFrameRewardPanel_OnShow();
309 if CZWOW_EnableQuests and type(CZWOW_QuestReward_count)=="number" then
310 local text=trim(GetRewardText());
311 for i=1, CZWOW_QuestReward_count, 1 do
312 if type(getglobal("CZWOW_QuestReward_"..i))=="table" and getglobal("CZWOW_QuestReward_"..i)[text] then
313 QuestRewardText:SetText(prepare(getglobal("CZWOW_QuestReward_"..i)[text]));
314 end
315 end
316 end;
317end
318
319ItemTextFrame_OnEvent=function(event)
320 old_ItemTextFrame_OnEvent(event);
321 if event=="ITEM_TEXT_READY" and CZWOW_EnableBooks and type(CZWOW_BookPage_count)=="number" then
322 local en=trim(ItemTextGetText());
323 for i=1, CZWOW_BookPage_count, 1 do
324 if type(getglobal("CZWOW_BookPage_"..i))=="table" and getglobal("CZWOW_BookPage_"..i)[en] then
325 local creator=ItemTextGetCreator();
326 if ( creator ) then
327 creator=strchar(10, 10)..ITEM_TEXT_FROM..strchar(10)..creator..strchar(10, 10);
328 ItemTextPageText:SetText(strchar(10)..prepare(getglobal("CZWOW_BookPage_"..i)[en])..creator);
329 else
330 ItemTextPageText:SetText(strchar(10)..prepare(getglobal("CZWOW_BookPage_"..i)[en])..strchar(10, 10));
331 end
332 end
333 end
334 end
335end;
336
337GossipFrameOptionsUpdate=function(...)
338 if select("#", ...)>0 then
339 old_GossipFrameOptionsUpdate(...);
340 if CZWOW_EnableNPCs and type(CZWOW_NPCAction_count)=="number" then
341 for i=1, NUMGOSSIPBUTTONS, 1 do
342 titleButton=getglobal("GossipTitleButton" .. i);
343 local en=trim(titleButton:GetText());
344 for i=1, CZWOW_NPCAction_count, 1 do
345 if type(getglobal("CZWOW_NPCAction_"..i))=="table" and getglobal("CZWOW_NPCAction_"..i)[en] then
346 titleButton:SetText(prepare(getglobal("CZWOW_NPCAction_"..i)[en]));
347 GossipResize(titleButton);
348 end
349 end
350 end
351 end
352 end
353end
354
355GossipFrameUpdate=function()
356 old_GossipFrameUpdate();
357 local cz=NPCTextTranslate(GossipGreetingText:GetText());
358 if cz then GossipGreetingText:SetText(cz) end
359end;
360
361QuestLog_UpdateQuestDetails=function()
362 old_QuestLog_UpdateQuestDetails();
363 if CZWOW_EnableQuests and type(CZWOW_QuestObjective_count)=="number" and type(CZWOW_QuestDescription_count)=="number" then
364 local questDescription;
365 local questObjectives;
366 questDescription, questObjectives=GetQuestLogQuestText();
367 questObjectives=trim(questObjectives);
368 questDescription=trim(questDescription);
369 for i=1, CZWOW_QuestObjective_count, 1 do
370 if type(getglobal("CZWOW_QuestObjective_"..i))=="table" and getglobal("CZWOW_QuestObjective_"..i)[questObjectives] then
371 QuestLogObjectivesText:SetText(prepare(getglobal("CZWOW_QuestObjective_"..i)[questObjectives]));
372 end
373 end
374 for i=1, CZWOW_QuestDescription_count, 1 do
375 if type(getglobal("CZWOW_QuestDescription_"..i))=="table" and getglobal("CZWOW_QuestDescription_"..i)[questDescription] then
376 QuestLogQuestDescription:SetText(prepare(getglobal("CZWOW_QuestDescription_"..i)[questDescription]));
377 end
378 end
379 end;
380end
Note: See TracBrowser for help on using the repository browser.