vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 -- FishingSetup
2 --
3 -- Load out translation strings and such
4  
5 FishingBuddy = {};
6  
7 FishingBuddy.VERSION = "0.8.6h";
8 FishingBuddy.CURRENTVERSION = 8600;
9  
10 FishingBuddy.Colors = {};
11 FishingBuddy.Colors.RED = "ffff0000";
12 FishingBuddy.Colors.GREEN = "ff00ff00";
13 FishingBuddy.Colors.BLUE = "ff0000ff";
14 FishingBuddy.Colors.WHITE = "ffffffff";
15  
16 -- debugging
17  
18 FishingBuddy.printable = function(foo)
19 if ( foo ) then
20 if ( type(foo) == "table" ) then
21 return "table";
22 elseif ( type(foo) == "boolean" ) then
23 if ( foo ) then
24 return "true";
25 else
26 return "false";
27 end
28 else
29 return foo;
30 end
31 else
32 return "nil";
33 end
34 end
35  
36 FishingBuddy.Output = function(msg, r, g, b)
37 if ( DEFAULT_CHAT_FRAME ) then
38 if ( not r ) then
39 DEFAULT_CHAT_FRAME:AddMessage(msg);
40 else
41 DEFAULT_CHAT_FRAME:AddMessage(msg, r, g, b);
42 end
43 end
44 end
45  
46 local FishingBuddy_Debugging = 1;
47 FishingBuddy.Debug = function(msg, fixlinks)
48 if ( FishingBuddy_Debugging == 1 ) then
49 if ( fixlinks ) then
50 msg = string.gsub(msg, "|", ";");
51 end
52 local name = FishingBuddy.Name or "Fishing Buddy";
53 FishingBuddy.Output("|c"..FishingBuddy.Colors.RED..name.." DEBUG|r "..msg);
54 end
55 end
56  
57 FishingBuddy.Dump = function(thing)
58 if ( FishingBuddy_Debugging == 1 ) then
59 if ( DevTools_Dump ) then
60 DevTools_Dump(thing);
61 else
62 FishingBuddy.Debug("Tried to dump a '"..FishingBuddy.printable(thing).."'.");
63 end
64 end
65 end
66  
67 local function LoadTranslation(lang)
68 local translation = FishingTranslations[lang];
69 for tag,value in translation do
70 if ( not FishingBuddy[tag] ) then
71 FishingBuddy[tag] = value;
72 end
73 end
74 end
75  
76 local function FixupThis(tag, what)
77 if ( type(what) == "table" ) then
78 for idx,str in what do
79 what[idx] = FixupThis(tag, str);
80 end
81 return what;
82 elseif ( type(what) == "string" ) then
83 local pattern = "#([A-Z0-9]+)#";
84 local s,e,w = string.find(what, pattern);
85 while ( w ) do
86 local s1 = strsub(what, 1, s-1);
87 local s2 = strsub(what, e+1);
88 what = s1..FishingBuddy[w]..s2;
89 s,e,w = string.find(what, pattern);
90 end
91 return what;
92 else
93 FishingBuddy.Debug("tag "..tag.." type "..type(what));
94 FishingBuddy.Dump(what);
95 end
96 end
97  
98 local function FixupStrings()
99 local translation = FishingTranslations["enUS"];
100 for tag,str in translation do
101 FishingBuddy[tag] = FixupThis(tag, str);
102 end
103 end
104  
105 local function FixupBindings(lang)
106 local translation = FishingTranslations[lang];
107 for tag,str in translation do
108 if ( string.find(tag, "^BINDING") ) then
109 setglobal(tag, FishingBuddy[tag]);
110 FishingBuddy[tag] = nil;
111 end
112 end
113 end
114  
115 local locale = GetLocale();
116 LoadTranslation(locale);
117 if ( locale ~= "enUS" ) then
118 LoadTranslation("enUS");
119 end
120 FixupStrings();
121 FixupBindings(locale);
122  
123 -- dump the memory we've allocated for all the translations
124 FishingTranslations = nil;
125  
126 FishingBuddy.BYWEEKS_TABLE = {["Jan"] = 0, ["Apr"] = 13, ["Jul"] = 26, ["Oct"] = 39, ["Dec"] = 52};
127  
128 FishingBuddy.KEYS_NONE = 0;
129 FishingBuddy.KEYS_SHIFT = 1;
130 FishingBuddy.KEYS_CTRL = 2;
131 FishingBuddy.KEYS_ALT = 3;
132 FishingBuddy.Keys = {};
133 FishingBuddy.Keys[FishingBuddy.KEYS_NONE] = FishingBuddy.KEYS_NONE_TEXT;
134 FishingBuddy.Keys[FishingBuddy.KEYS_SHIFT] = FishingBuddy.KEYS_SHIFT_TEXT;
135 FishingBuddy.Keys[FishingBuddy.KEYS_CTRL] = FishingBuddy.KEYS_CTRL_TEXT;
136 FishingBuddy.Keys[FishingBuddy.KEYS_ALT] = FishingBuddy.KEYS_ALT_TEXT;