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