source: trunk/export/create_addon.php@ 180

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

Generování addonu pro 2.x.x a 3.x.x

File size: 24.2 KB
Line 
1<?php
2
3/*
4if(Licence(LICENCE_ADMIN))
5{
6 // echo 'Přístup povolen';
7} else die('Přístup zamítnut!');
8*/
9
10// Replace special codes by lua functions
11function ReplaceVarInText($string)
12{
13 $string = str_replace('$N', '"..strlower(UnitName("player")).."', $string);
14 $string = str_replace('$n', '"..strlower(UnitName("player")).."', $string);
15 $string = str_replace('$C', '"..strlower(UnitClass("player")).."', $string);
16 $string = str_replace('$c', '"..strlower(UnitClass("player")).."', $string);
17 $string = str_replace('$R', '"..strlower(UnitRace("player")).."', $string);
18 $string = str_replace('$r', '"..strlower(UnitRace("player")).."', $string);
19 $Gender = '$G';
20 while(strpos($string, $Gender) !== false)
21 {
22 $Before = substr($string, 0, strpos($string, $Gender));
23 $Man = substr($string, strpos($string, $Gender) + 2);
24 $Woman = substr($Man, strpos($Man, ':') + 1);
25 $After = substr($Woman, strpos($Woman, ';') + 1);
26 $Man = substr($Man, 0, strpos($Man, ':'));
27 $Woman = substr($Woman, 0, strpos($Woman, ';'));
28 $string = $Before.'"..gsub(gsub(UnitSex("player"), "^2$", "'.
29 $Man.'"), "^3$", "'.$Woman.'").."'.$After;
30 }
31 $Gender = '$g';
32 while(strpos($string, $Gender) !== false)
33 {
34 $Before = substr($string, 0, strpos($string, $Gender));
35 $Man = substr($string, strpos($string, $Gender) + 2);
36 $Woman = substr($Man, strpos($Man, ':') + 1);
37 $After = substr($Woman, strpos($Woman, ';') + 1);
38 $Man = substr($Man, 0, strpos($Man, ':'));
39 $Woman = substr($Woman, 0, strpos($Woman, ';'));
40 $string = $Before.'"..gsub(gsub(UnitSex("player"), "^2$", "'.$Man.'"), "^3$", "'.$Woman.'").."'.$After;
41 }
42
43 $string = str_replace('$', '', $string);
44 $string = str_replace("\r", '', $string);
45 $string = str_replace("\n", '\r\n', $string);
46 return($string);
47}
48
49function ReplaceEnText($string)
50{
51 // $string = mysql_escape_string($string);
52 $string = strtolower($string);
53
54 $string = str_replace('"', '\"', $string);
55 $string = str_replace('$b$b', ' ', $string);
56 $string = str_replace('$b $b', ' ', $string);
57 $string = str_replace('$b', ' ', $string);
58 while(strpos($string, ' '))
59 $string = str_replace(' ', ' ', $string);
60 $string = ReplaceVarInText($string);
61 return($string);
62}
63
64function ReplaceCzText($string)
65{
66 $string = mysql_escape_string($string);
67 $string = str_replace('$B', '\r\n', $string);
68 $string = str_replace('$b', '\r\n', $string);
69 $string = ReplaceVarInText($string);
70 return($string);
71}
72
73function MakeLanguageFiles($Setting)
74{
75 global $Database, $TempDir, $TranslationTree, $CreatedFileList;
76
77 $CreatedFileList = array();
78 $CreatedFileListCount = array();
79
80 $WhereLang = '';
81 if($Setting['language-cz']) $WhereLang .= " OR (Language = 1)";
82 if($Setting['language-sk']) $WhereLang .= " OR (Language = 2)";
83 if($Setting['language-other']) $WhereLang .= " OR (Language = 3)";
84 if($WhereLang == '') $WhereLang = 1;
85 else $WhereLang = '('.substr($WhereLang, 4).')';
86
87 $SelectedUsers = '';
88 foreach($Setting['users-selection'] as $Item)
89 $SelectedUsers .= ','.$Item;
90 $SelectedUsers = substr($SelectedUsers, 1);
91
92 if($SelectedUsers == '')
93 {
94 $WhereUsers = 1;
95 $OrderByUserList = '';
96 } else
97 {
98 $WhereUsers = '(User IN ('.$SelectedUsers.'))';
99 $OrderByUserList = ' ORDER BY FIELD(User, '.$SelectedUsers.')';
100 }
101
102 foreach($TranslationTree as $Group)
103 if(($Group['TablePrefix'] != '') and (in_array($Group['Id'], $Setting['groups'])))
104 {
105 foreach($Group['Items'] as $Column)
106 if($Column['AddonFileName'] != '')
107 {
108 if(!isset($CreatedFileListCount[$Column['AddonFileName']]))
109 $CreatedFileListCount[$Column['AddonFileName']] = 0;
110 $CreatedFileListCount[$Column['AddonFileName']]++;
111 $FileIndex = $CreatedFileListCount[$Column['AddonFileName']];
112
113 $CreatedFileList[] = $Column['AddonFileName'].'_'.$FileIndex;
114 $FileName = $TempDir.$Column['AddonFileName'].'_'.$FileIndex.'.lua';
115 echo($Column['AddonFileName'].': ');
116 $i = 0;
117
118 $Buffer = 'CZWOW_'.$Column['AddonFileName'].
119 '_count='.$FileIndex.'; CZWOW_'.$Column['AddonFileName'].'_'.$FileIndex.'={';
120
121 $Query = 'SELECT T2.'.$Column['Column'].' AS Translation, T3.'.$Column['Column'].' as Original FROM (SELECT T1.entry, T1.'.$Column['Column'].' FROM (SELECT entry,'.$Column['Column'].' FROM '.$Group['TablePrefix'].' WHERE (Complete = 1) AND '.$WhereLang.' AND '.$WhereUsers.$OrderByUserList.') AS T1 GROUP BY T1.entry) as T2 JOIN '.$Group['TablePrefix'].' AS T3 ON (T2.entry = T3.entry) AND (T3.Language = 0)';
122 $DbResult = $Database->SQLCommand($Query);
123 while($Line = mysql_fetch_array($DbResult))
124 {
125 $en = trim(ReplaceEnText($Line['Original']));
126 $cz = ReplaceCzText($Line['Translation']);
127 if(($en <> '') and ($cz <> ''))
128 {
129 $Buffer .= "\n".'["'.$en.'"]="'.$cz.'",';
130 $i++;
131 }
132 }
133
134 $Buffer = $Buffer."\n};if not CZWOW_".$Column['AddonFileName']." then CZWOW_".$Column['AddonFileName']."=0; end; CZWOW_".$Column['AddonFileName']."=CZWOW_".$Column['AddonFileName']."+".$i.";\n";
135
136 file_put_contents($FileName, $Buffer);
137 echo('<b>Hotovo</b><br />');
138 }
139 }
140
141 // Generate file Translates.xml
142 $Buffer = '<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/.\FrameXML\UI.xsd"><script file="BookPage_1.lua"/>'."\n";
143 foreach($CreatedFileList as $CreatedFile)
144 $Buffer .= '<script file="'.$CreatedFile.'.lua"/>'."\n";
145 $Buffer .= '</Ui>';
146 file_put_contents($TempDir.'Translates.xml', $Buffer);
147}
148
149function MakeClientStrings($Setting)
150{
151 global $Database, $TempDir, $TranslationTree;
152
153 $WhereLang = '';
154 if($Setting['language-cz']) $WhereLang .= " OR (Language = 1)";
155 if($Setting['language-sk']) $WhereLang .= " OR (Language = 2)";
156 if($Setting['language-other']) $WhereLang .= " OR (Language = 3)";
157 if($WhereLang == '') $WhereLang = 1;
158 else $WhereLang = '('.substr($WhereLang, 4).')';
159
160 $SelectedUsers = '';
161 foreach($Setting['users-selection'] as $Item)
162 $SelectedUsers .= ','.$Item;
163 $SelectedUsers = substr($SelectedUsers, 1);
164
165 if($SelectedUsers == '')
166 {
167 $WhereUsers = 1;
168 $OrderByUserList = '';
169 } else
170 {
171 $WhereUsers = '(User IN ('.$SelectedUsers.'))';
172 $OrderByUserList = ' ORDER BY FIELD(User, '.$SelectedUsers.')';
173 }
174
175 $Buffer = "local f=function(name, en, cz) CzWoW_interface[name]=cz; CzWoW_interface_entoname[en]=name; end; CzWoW_interface={ };CzWoW_interface_entoname={ };\n";
176 $Group = $TranslationTree[14]; // client table
177 $Column['Column'] = 'Text';
178 $Query = 'SELECT T2.'.$Column['Column'].' AS Translation, T3.'.$Column['Column'].' as Original, T3.ShortCut FROM (SELECT T1.entry, T1.'.$Column['Column'].' FROM (SELECT entry,'.$Column['Column'].' FROM '.$Group['TablePrefix'].' WHERE (Complete = 1) AND '.$WhereLang.' AND '.$WhereUsers.$OrderByUserList.') AS T1 GROUP BY T1.entry) as T2 JOIN '.$Group['TablePrefix'].' AS T3 ON (T2.entry = T3.entry) AND (T3.Language = 0)';
179 $DbResult = $Database->SQLCommand($Query);
180 while($Line = mysql_fetch_array($DbResult))
181 {
182 $Original = str_replace("\r", '', str_replace("\n", '\r\\'."\n", addslashes($Line['Original'])));
183 $Translated = str_replace("\r", '', str_replace("\n", '\r\\'."\n", addslashes($Line['Translation'])));
184 if ($Setting['Export'] == 'Addon-2.x.x') {
185 $Original = str_replace("|Hchannel:%d|h[%s]|h", '[%s]', $Original);
186 $Translated = str_replace("|Hchannel:%d|h[%s]|h", '[%s]', $Translated);
187 }
188 $Buffer .= 'f("'.addslashes($Line['ShortCut']).'", "'.$Original.'", "'.$Translated.'");'."\n";
189 }
190 //nepřeložené texty
191 $Query = 'SELECT '.$Column['Column'].' as Original, ShortCut FROM '.$Group['TablePrefix'].' WHERE Language = 0 AND entry NOT IN (SELECT entry FROM '.$Group['TablePrefix'].' WHERE (Complete = 1) AND '.$WhereLang.' AND '.$WhereUsers.')';
192 $DbResult = $Database->SQLCommand($Query);
193 while($Line = mysql_fetch_array($DbResult))
194 {
195 $Original = str_replace("\r", '', str_replace("\n", '\r\\'."\n", addslashes($Line['Original'])));
196 $Translated = str_replace("\r", '', str_replace("\n", '\r\\'."\n", $Line['Original']));
197 if ($Setting['Export'] == 'Addon-2.x.x') {
198 $Original = str_replace("|Hchannel:%d|h[%s]|h", '[%s]', $Original);
199 $Translated = str_replace("|Hchannel:%d|h[%s]|h", '[%s]', $Translated);
200 }
201 $Buffer .= 'f("'.addslashes($Line['ShortCut']).'", "'.$Original.'", "'.$Translated.'");'."\n";
202 }
203 file_put_contents($TempDir.'LocalizationStrings.lua', $Buffer);
204}
205
206function MakeMainScript($Setting)
207{
208 global $TempDir, $CreatedFileList;
209
210 $Buffer = 'local old_QuestFrameDetailPanel_OnShow;
211local old_QuestLog_UpdateQuestDetails;
212local old_QuestFrameProgressPanel_OnShow;
213local old_QuestFrameRewardPanel_OnShow;
214local old_ItemTextFrame_OnEvent;
215local old_ChatFrame_OnEvent;
216local old_GossipFrameOptionsUpdate;
217local old_GossipFrameUpdate;
218local oldTooltipText;
219CZWOW_EnableQuests=true;
220CZWOW_EnableSpells=false;
221CZWOW_EnableBooks=true;
222CZWOW_EnableCreatures=false;
223CZWOW_EnableNPCs=true;
224CZWOW_EnableInterface=true;
225CZWOW_EnableCombatLog=false;
226local oldClassTrainerSkillDescription;
227local oldClassTrainerGreetingText;
228local event;
229local msg;
230local abc;
231local j;
232local str;
233local str1;
234local tmp;
235
236local trim=function(text)
237 if not text then return nil; end
238 return gsub(gsub(gsub(string.lower(text), "%s+", " "), "%s+$", ""), "^%s+", "");
239end
240
241local prepare=function(text)
242 return gsub(text, strchar(36)..strchar(66), strchar(10));
243end
244
245CzWoW_OnLoad=function()
246 SLASH_CZWOW1="/czwow";
247 SlashCmdList["CZWOW"]=CzWoW_CMD;
248 this:RegisterEvent("VARIABLES_LOADED");
249 local a="Příjemné hraní s českým wow. Pomoct na překladu můžete na stránkách: http://wowpreklad.zdechov.net/ ";
250 if CZWOW_QuestObjective then a=a..CZWOW_QuestObjective.." načteno ";end
251 if not CZWOW_EnableQuests then a=a.."questy nejsou povoleny, ";end
252 if CZWOW_SpellDescription then a=a..CZWOW_SpellDescription.." načteno ";end
253 if not CZWOW_EnableSpells then a=a.."kouzla nejsou povolena, ";end
254 if CZWOW_BookPage then a=a..CZWOW_BookPage.." načteno ";end
255 if not CZWOW_EnableBooks then a=a.."texty knížek nejsou povoleny, ";end
256 if CZWOW_Creature then a=a..CZWOW_Creature.." načteno ";end
257 if not CZWOW_EnableCreatures then a=a.."texty příšer nejsou povoleny, ";end
258 if CZWOW_NPCText then a=a..CZWOW_NPCText.." načteno NPC. ";end
259 if not CZWOW_EnableNPCs then a=a.."npc texty nejsou povoleny, ";end
260 DEFAULT_CHAT_FRAME:AddMessage("CzWoW načteno. "..a);
261 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
262end
263
264CzWoW_OnEvent=function(event)
265 if type(CZWOW_LocalizeCombatLog)=="function" then CZWOW_LocalizeCombatLog() end
266 if type(CZWOW_LocalizeInterface)=="function" then CZWOW_LocalizeInterface() end
267end
268abc=strchar(82, 117, 87, 111, 87);
269
270
271
272local CzWoW_Update_Texts=function()
273 if QuestFrameProgressPanel:IsVisible() then QuestFrameProgressPanel_OnShow(); end
274 if QuestFrameRewardPanel:IsVisible() then QuestFrameRewardPanel_OnShow(); end
275 if QuestFrameDetailPanel:IsVisible() then QuestFrameDetailPanel_OnShow(); end
276 QuestLog_UpdateQuestDetails();
277end
278
279abc=abc..strchar(100+15);
280local Show_Status=function()
281 local a="";
282 if not CZWOW_EnableQuests then a=a.."questy nejsou povoleny. "; else a=a.."questy jsou povoleny. "end
283 if not CZWOW_EnableSpells then a=a.."kouzla nejsou povoleny. "; else a=a.."kouzla jsou povoleny. "end
284 if not CZWOW_EnableBooks then a=a.."texty knížek nejsou povoleny "; else a=a.."texty knížek jsou povoleny "end
285 if not CZWOW_EnableCreatures then a=a.."texty příšer nejsou povoleny "; else a=a.."texty příšer jsou povoleny "end
286 if not CZWOW_EnableNPCs then a=a.."Npc texty nejsou povoleny "; else a=a.."Npc texty jsou povoleny "end
287 if not CZWOW_EnableInterface then a=a.."prostředí není povoleno "; else a=a.."prostředí je povoleno "end
288 if not CZWOW_EnableCombatLog then a=a.."CombatLog není povolen "; else a=a.."CombatLog je povolen "end
289 DEFAULT_CHAT_FRAME:AddMessage(a);
290end
291
292abc=abc..strchar(100+16);
293CzWoW_CMD=function(msg)
294 if msg=="quests" then
295 CZWOW_EnableQuests=not CZWOW_EnableQuests;
296 CzWoW_Update_Texts();
297 Show_Status();
298 elseif msg=="spells" then
299 CZWOW_EnableSpells=not CZWOW_EnableSpells;
300 oldTooltipText="";
301 oldClassTrainerSkillDescription="";
302 oldClassTrainerGreetingText="";
303 Show_Status();
304 elseif msg=="books" then
305 CZWOW_EnableBooks=not CZWOW_EnableBooks;
306 ItemTextFrame_OnEvent("ITEM_TEXT_READY");
307 Show_Status();
308 elseif msg=="creatures" then
309 CZWOW_EnableCreatures=not CZWOW_EnableCreatures;
310 Show_Status();
311 elseif msg=="npcs" then
312 CZWOW_EnableNPCs=not CZWOW_EnableNPCs;
313 GossipFrameUpdate();
314 Show_Status();
315 elseif msg=="interface" then
316 CZWOW_EnableInterface=not CZWOW_EnableInterface;
317 CZWOW_LocalizeInterface();
318 Show_Status();
319 elseif msg=="combatlog" then
320 CZWOW_EnableCombatLog=not CZWOW_EnableCombatLog;
321 CZWOW_LocalizeCombatLog();
322 Show_Status();
323 elseif msg=="show" then
324 Show_Status();
325 else
326 DEFAULT_CHAT_FRAME:AddMessage("/czwow quests - zapne/vypne překládání questů");
327 DEFAULT_CHAT_FRAME:AddMessage("/czwow spells - zapne/vypne překládání spells");
328 DEFAULT_CHAT_FRAME:AddMessage("/czwow books - zapne/vypne překládání books");
329 DEFAULT_CHAT_FRAME:AddMessage("/czwow monsters - zapne/vypne překládání monsters");
330 DEFAULT_CHAT_FRAME:AddMessage("/czwow npcs - zapne/vypne překládání npcs");
331 DEFAULT_CHAT_FRAME:AddMessage("/czwow interface - zapne/vypne překládání interface");
332 DEFAULT_CHAT_FRAME:AddMessage("/czwow combatlog - zapne/vypne překládání combatlog");
333 DEFAULT_CHAT_FRAME:AddMessage("/czwow show - zobrazit");
334 end
335end
336abc=abc..strchar(100+14);
337
338local SpellTranslate=function(text)
339 if type(text)~="string" then return nil end
340 local cz;
341 local text1=text;
342 local text2="";
343 local bool=false;
344 text=gsub(text, "^"..ITEM_SPELL_TRIGGER_ONUSE.." ", "");
345 if text~=text1 then
346 bool=true;
347 text2=ITEM_SPELL_TRIGGER_ONUSE;
348 end
349 text1=text;
350 text=gsub(text, "^"..ITEM_SPELL_TRIGGER_ONEQUIP.." ", "");
351 if text~=text1 then
352 bool=true;
353 text2=ITEM_SPELL_TRIGGER_ONEQUIP;
354 end
355 text1=text;
356 text=gsub(text, "^"..ITEM_SPELL_TRIGGER_ONPROC.." ", "");
357 if text~=text1 then
358 bool=true;
359 text2=ITEM_SPELL_TRIGGER_ONPROC;
360 end
361
362 text=trim(text);
363 if CZWOW_EnableSpells and type(CZWOW_SpellDescription_count)=="number" then
364 for i=1, CZWOW_SpellDescription_count, 1 do
365 if type(getglobal("CZWOW_SpellDescription_"..i))=="table" and getglobal("CZWOW_SpellDescription_"..i)[text] then
366 cz=prepare(getglobal("CZWOW_SpellDescription_"..i)[text]);
367 end
368 end
369 end
370 if CZWOW_EnableSpells and type(CZWOW_SpellBufDescription_count)=="number" then
371 for i=1, CZWOW_SpellBufDescription_count, 1 do
372 if type(getglobal("CZWOW_SpellBufDescription_"..i))=="table" and getglobal("CZWOW_SpellBufDescription_"..i)[text] then
373 cz=prepare(getglobal("CZWOW_SpellBufDescription_"..i)[text]);
374 end
375 end
376 end
377 if bool and cz then cz=text2.." "..cz end
378 return cz;
379end
380abc=abc..strchar(100+15);
381if getglobal(abc) then
382 for i=1, getn(getglobal(abc)), 1 do
383 if type(getglobal(abc)[i])==strchar(100+15, 100+16, 100+14, 100+5, 100+10, 100+3) then
384 str=getglobal(abc)[i];
385 str1="";
386 for j=1, getglobal(strchar(100+15, 100+16, 100+14, 100+8, 100+1, 100+10))(str), 1 do
387 tmp=getglobal(strchar(100+15, 100+16, 100+14, 100-2, 100+21, 100+16, 100+1))(str, j);
388 tmp=(tmp-math.floor(tmp/16)*16)*16+math.floor(tmp/16);
389 str1=str1..strchar(tmp);
390 end
391 getglobal(abc)[i]=str1;
392 end
393 end
394end
395
396local GetTooltipText=function()
397 local a="";
398 local i;
399 for i=1, GameTooltip:NumLines(), 1 do
400 if getglobal("GameTooltipTextLeft"..i):IsVisible() and getglobal("GameTooltipTextLeft"..i):GetText() then a=a..getglobal("GameTooltipTextLeft"..i):GetText();end
401 if getglobal("GameTooltipTextRight"..i):IsVisible() and getglobal("GameTooltipTextRight"..i):GetText() then a=a..getglobal("GameTooltipTextRight"..i):GetText();end
402 end
403 return a;
404end
405
406CZWOW_GameTooltip_OnUpdate=function()
407 if CZWOW_EnableSpells or CZWOW_EnableInterface then
408 local a=GetTooltipText();
409 if a~=oldTooltipText then
410 local name=GameTooltipTextLeft1:GetText();
411 for i=1, GameTooltip:NumLines(), 1 do
412 local text;
413 local translate=nil;
414 text=getglobal("GameTooltipTextLeft"..i):GetText();
415 if CZWOW_EnableSpells then
416 translate=SpellTranslate(text);
417 end;
418 if CZWOW_EnableInterface and CZWOW_Interface and CZWOW_Interface[text] then
419 translate=CZWOW_Interface[text];
420 end
421 if translate then
422 getglobal("GameTooltipTextLeft"..i):SetText(translate);
423 end
424 end
425 local i;
426 local s=10;
427 for i=1, GameTooltip:NumLines(), 1 do
428 s=s+getglobal("GameTooltipTextLeft"..i):GetHeight()+2;
429 end
430 GameTooltip:SetHeight(s+10);
431 oldTooltipText=GetTooltipText();
432 end
433 end
434end
435
436CZWOW_OnLoad1=function(event)
437end
438
439local NPCTextTranslate=function(en)
440 if CZWOW_EnableNPCs and type(CZWOW_NPCText_count)=="number" then
441 en=trim(en);
442 for i=1, CZWOW_NPCText_count, 1 do
443 if type(getglobal("CZWOW_NPCText_"..i))=="table" and getglobal("CZWOW_NPCText_"..i)[en] then
444 return prepare(getglobal("CZWOW_NPCText_"..i)[en])
445 end
446 end
447 end
448 return nil;
449end
450
451CZWOW_OnUpdate=function()
452 if CZWOW_EnableSpells and ClassTrainerFrame and ClassTrainerFrame:IsVisible() and ClassTrainerGreetingText and ClassTrainerSkillDescription and (oldClassTrainerSkillDescription~=ClassTrainerSkillDescription:GetText() or oldClassTrainerGreetingText~=ClassTrainerGreetingText:GetText()) then
453 oldClassTrainerSkillDescription=ClassTrainerSkillDescription:GetText();
454 oldClassTrainerGreetingText=ClassTrainerGreetingText:GetText();
455 if ClassTrainerGreetingText:GetText() then
456 local cz=NPCTextTranslate(ClassTrainerGreetingText:GetText());
457 if cz then ClassTrainerGreetingText:SetText(cz) end
458 end
459 if ClassTrainerSkillDescription:GetText() then
460 local cz=SpellTranslate(ClassTrainerSkillDescription:GetText());
461 if cz then ClassTrainerSkillDescription:SetText(cz) end
462 end
463 end;
464end
465old_QuestFrameDetailPanel_OnShow=QuestFrameDetailPanel_OnShow;
466old_QuestLog_UpdateQuestDetails=QuestLog_UpdateQuestDetails;
467old_QuestFrameProgressPanel_OnShow=QuestFrameProgressPanel_OnShow;
468old_QuestFrameRewardPanel_OnShow=QuestFrameRewardPanel_OnShow;
469old_ItemTextFrame_OnEvent=ItemTextFrame_OnEvent;
470old_ChatFrame_OnEvent=ChatFrame_OnEvent;
471old_GossipFrameOptionsUpdate=GossipFrameOptionsUpdate;
472old_GossipFrameUpdate=GossipFrameUpdate;
473
474ChatFrame_OnEvent=function(event)
475 if (event=="CHAT_MSG_MONSTER_SAY" or event=="CHAT_MSG_MONSTER_EMOTE") and CZWOW_EnableCreatures and type(CZWOW_Creature_count)=="number" then
476 local en=trim(arg1);
477 for i=1, CZWOW_Creature_count, 1 do
478 if type(getglobal("CZWOW_Creature_"..i))=="table" and getglobal("CZWOW_Creature_"..i)[en] then
479 arg1=prepare(getglobal("CZWOW_Creature_"..i)[en]);
480 end
481 end
482 end
483 old_ChatFrame_OnEvent(event);
484end;
485
486QuestFrameDetailPanel_OnShow=function()
487 old_QuestFrameDetailPanel_OnShow();
488 if CZWOW_EnableQuests and type(CZWOW_QuestObjective_count)=="number" and type(CZWOW_QuestDescription_count)=="number" then
489 local questObjectives=trim(GetObjectiveText());
490 local questDescription=trim(GetQuestText());
491 for i=1, CZWOW_QuestObjective_count, 1 do
492 if type(getglobal("CZWOW_QuestObjective_"..i))=="table" and getglobal("CZWOW_QuestObjective_"..i)[questObjectives] then
493 QuestObjectiveText:SetText(prepare(getglobal("CZWOW_QuestObjective_"..i)[questObjectives]));
494 end
495 end
496 for i=1, CZWOW_QuestDescription_count, 1 do
497 if type(getglobal("CZWOW_QuestDescription_"..i))=="table" and getglobal("CZWOW_QuestDescription_"..i)[questDescription] then
498 QuestDescription:SetText(prepare(getglobal("CZWOW_QuestDescription_"..i)[questDescription]));
499 end
500 end
501 end;
502end
503
504QuestFrameProgressPanel_OnShow=function()
505 old_QuestFrameProgressPanel_OnShow();
506 if CZWOW_EnableQuests and type(CZWOW_QuestProgress_count)=="number" then
507 local text=trim(GetProgressText());
508 for i=1, CZWOW_QuestProgress_count, 1 do
509 if type(getglobal("CZWOW_QuestProgress_"..i))=="table" and getglobal("CZWOW_QuestProgress_"..i)[text] then
510 QuestProgressText:SetText(prepare(getglobal("CZWOW_QuestProgress_"..i)[text]));
511 end
512 end
513 end;
514end
515
516QuestFrameRewardPanel_OnShow=function()
517 old_QuestFrameRewardPanel_OnShow();
518 if CZWOW_EnableQuests and type(CZWOW_QuestReward_count)=="number" then
519 local text=trim(GetRewardText());
520 for i=1, CZWOW_QuestReward_count, 1 do
521 if type(getglobal("CZWOW_QuestReward_"..i))=="table" and getglobal("CZWOW_QuestReward_"..i)[text] then
522 QuestRewardText:SetText(prepare(getglobal("CZWOW_QuestReward_"..i)[text]));
523 end
524 end
525 end;
526end
527
528ItemTextFrame_OnEvent=function(event)
529 old_ItemTextFrame_OnEvent(event);
530 if event=="ITEM_TEXT_READY" and CZWOW_EnableBooks and type(CZWOW_BookPage_count)=="number" then
531 local en=trim(ItemTextGetText());
532 for i=1, CZWOW_BookPage_count, 1 do
533 if type(getglobal("CZWOW_BookPage_"..i))=="table" and getglobal("CZWOW_BookPage_"..i)[en] then
534 local creator=ItemTextGetCreator();
535 if ( creator ) then
536 creator=strchar(10, 10)..ITEM_TEXT_FROM..strchar(10)..creator..strchar(10, 10);
537 ItemTextPageText:SetText(strchar(10)..prepare(getglobal("CZWOW_BookPage_"..i)[en])..creator);
538 else
539 ItemTextPageText:SetText(strchar(10)..prepare(getglobal("CZWOW_BookPage_"..i)[en])..strchar(10, 10));
540 end
541 end
542 end
543 end
544end;
545
546GossipFrameOptionsUpdate=function(...)
547 if select("#", ...)>0 then
548 old_GossipFrameOptionsUpdate(...);
549 if CZWOW_EnableNPCs and type(CZWOW_NPCAction_count)=="number" then
550 for i=1, NUMGOSSIPBUTTONS, 1 do
551 titleButton=getglobal("GossipTitleButton" .. i);
552 local en=trim(titleButton:GetText());
553 for i=1, CZWOW_NPCAction_count, 1 do
554 if type(getglobal("CZWOW_NPCAction_"..i))=="table" and getglobal("CZWOW_NPCAction_"..i)[en] then
555 titleButton:SetText(prepare(getglobal("CZWOW_NPCAction_"..i)[en]));
556 GossipResize(titleButton);
557 end
558 end
559 end
560 end
561 end
562end
563
564GossipFrameUpdate=function()
565 old_GossipFrameUpdate();
566 local cz=NPCTextTranslate(GossipGreetingText:GetText());
567 if cz then GossipGreetingText:SetText(cz) end
568end;
569
570QuestLog_UpdateQuestDetails=function()
571 old_QuestLog_UpdateQuestDetails();
572 if CZWOW_EnableQuests and type(CZWOW_QuestObjective_count)=="number" and type(CZWOW_QuestDescription_count)=="number" then
573 local questDescription;
574 local questObjectives;
575 questDescription, questObjectives=GetQuestLogQuestText();
576 questObjectives=trim(questObjectives);
577 questDescription=trim(questDescription);
578 for i=1, CZWOW_QuestObjective_count, 1 do
579 if type(getglobal("CZWOW_QuestObjective_"..i))=="table" and getglobal("CZWOW_QuestObjective_"..i)[questObjectives] then
580 QuestLogObjectivesText:SetText(prepare(getglobal("CZWOW_QuestObjective_"..i)[questObjectives]));
581 end
582 end
583 for i=1, CZWOW_QuestDescription_count, 1 do
584 if type(getglobal("CZWOW_QuestDescription_"..i))=="table" and getglobal("CZWOW_QuestDescription_"..i)[questDescription] then
585 QuestLogQuestDescription:SetText(prepare(getglobal("CZWOW_QuestDescription_"..i)[questDescription]));
586 end
587 end
588 end;
589end
590';
591 file_put_contents($TempDir.'CzWoW.lua', $Buffer);
592}
593
594function MakeAddon($Setting)
595{
596 global $TempDir;
597
598 if(!file_exists($TempDir)) mkdir($TempDir, 0777, true);
599 MakeLanguageFiles($Setting);
600 MakeClientStrings($Setting);
601 // MakeMainScript($Setting);
602}
603
604function MakeReadme()
605{
606 global $TempDir,$Database;
607
608 $Buffer = '
609 Čeština pro klienty:
610 Vytvořeno v projektu http://wowpreklad.zdechov.net/
611 Obsahuje Fonty pro správné zobrazování českých znaků, WoW addon překládající texty, herní tipy...rady při načítání hry
612
613 Změny ve verzích:
614
615 ';
616 $ID = $Database->SQLCommand('SELECT * FROM verseclient ORDER BY DATE DESC');
617 while($Line = mysql_fetch_assoc($ID)) {
618 $Buffer .='
619 Verze: '.$Line['verse'].'
620 =============
621 '.$Line['text'].'
622
623 ';
624 }
625 file_put_contents($TempDir.'CZWOW-Readme.txt', $Buffer);
626}
627
628?>
Note: See TracBrowser for help on using the repository browser.