vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 -- MetaKB Import Module
2 -- Written by MetaHawk aka Urshurak
3  
4 MMCVT_MAPNOTES = "MapNotes";
5 MMCVT_MAPMOD = "MapMod";
6 MMCVT_USERKB = "UserKB";
7 MMCVT_USERNOTES = "UserNotes";
8 MMCVT_BLT = "Default";
9  
10 local MetaMap_TempData = {};
11 local Import_MapNotes = false;
12 local Import_MapMod = false;
13 local Import_UserKB = false;
14 local Import_UserNotes = false;
15 local Import_BLT = false;
16  
17 function MetaMapCVT_CheckData()
18 local found = false;
19 local fileInfo = "MetaMap Imports module loaded."
20 if(MetaMap_NoteData) then
21 MetaMap_InstanceImportButton:Enable();
22 found = true;
23 end
24 if(MapNotes_Data) then
25 MetaMap_MapNotesImportButton:Enable();
26 Import_MapNotes = true;
27 found = true;
28 end
29 if(CT_UserMap_Notes) then
30 MetaMap_MapNotesImportButton:Enable();
31 Import_MapMod = true;
32 found = true;
33 end
34 if(MyKB_Data) then
35 if(not IsAddOnLoaded("MetaMapWKB")) then
36 LoadAddOn("MetaMapWKB");
37 end
38 if(IsAddOnLoaded("MetaMapWKB")) then
39 if(MyKB_Data[MetaKB_dbID]) then
40 MetaMap_KBImportButton:Enable();
41 Import_UserKB = true;
42 found = true;
43 end
44 end
45 end
46 if(MyNotes_Data) then
47 MetaMap_KBImportButton:Enable();
48 Import_UserNotes = true;
49 found = true;
50 end
51 if(MetaMapBLTDefaultData) then
52 if(not IsAddOnLoaded("MetaMapBLT")) then
53 LoadAddOn("MetaMapBLT");
54 end
55 if(IsAddOnLoaded("MetaMapBLT")) then
56 MetaMap_BLTImportButton:Enable();
57 Import_BLT = true;
58 found = true;
59 end
60 end
61 if(not found) then
62 fileInfo = fileInfo.."\nNo data files found";
63 end
64 MetaMap_ImportHeader:SetTextColor(1,1,1);
65 MetaMap_ImportHeader:SetText(fileInfo);
66 MetaMap_LoadImportsButton:Disable();
67 end
68  
69 function MetaMap_ImportOptions(mode)
70 local ShowFrame = true;
71 if(mode == 1) then
72 Import_MetaMapData();
73 ShowFrame = false;
74 elseif(mode == 2) then
75 MetaMap_SelectionButton1:SetText(MMCVT_MAPNOTES);
76 MetaMap_SelectionButton2:SetText(MMCVT_MAPMOD);
77 if(not Import_MapNotes) then
78 MetaMap_SelectionButton1:Disable();
79 end
80 if(not Import_MapMod) then
81 MetaMap_SelectionButton2:Disable();
82 end
83 elseif(mode == 3) then
84 MetaMap_SelectionButton1:SetText(MMCVT_USERKB);
85 MetaMap_SelectionButton2:SetText(MMCVT_USERNOTES);
86 if(not Import_UserKB) then
87 MetaMap_SelectionButton1:Disable();
88 end
89 if(not Import_UserNotes) then
90 MetaMap_SelectionButton2:Disable();
91 end
92 elseif(mode == 4) then
93 MetaMapBLT_ImportDefault();
94 ShowFrame = false;
95 end
96 if(ShowFrame) then
97 MetaMap_ConfirmationHeader:SetText(METAMAPBLT_CONFIRM_IMPORT);
98 MetaMap_ConfirmationDialog:Show();
99 end
100 end
101  
102 function MetaMap_SelectedImport(mode)
103 if(mode == MMCVT_MAPNOTES) then
104 MetaMap_ImportMapNotes();
105 elseif(mode == MMCVT_MAPMOD) then
106 MetaMap_ImportMapMod();
107 elseif(mode == MMCVT_USERKB) then
108 MetaMap_ImportUserKB();
109 elseif(mode == MMCVT_USERNOTES) then
110 MetaMap_ImportMetaNotes();
111 elseif(mode == MMCVT_BLT) then
112 MetaMapBLT_ImportDefault();
113 end
114 MetaMap_ConfirmationDialog:Hide();
115 end
116  
117 function Import_MetaMapData()
118 MetaMap_TempData = {};
119 MetaMap_TempData[0] = MetaMapNotes_Data[0];
120 MetaMapNotes_Data[0] = {};
121 MetaMapNotes_Data[0] = MetaMap_NoteData[0];
122 for zone, zoneTable in MetaMap_TempData[0] do
123 for index, value in MetaMap_TempData[0][zone] do
124 local oldData = MetaMap_TempData[0][zone][index];
125 if(oldData["lootid"] == nil) then
126 MetaMapNotes_AddNewNote(0, zone, oldData.xPos, oldData.yPos, oldData.name, oldData.inf1, oldData.inf2, oldData.creator, oldData.icon, oldData.ncol, oldData.in1c, oldData.in2c)
127 end
128 end
129 end
130 for i=1, 2, 1 do
131 for zone, zoneTable in MetaMapNotes_Data[i] do
132 for index, value in MetaMapNotes_Data[i][zone] do
133 if(MetaMapNotes_Data[i][zone][index]["lootid"] ~= nil) then
134 MetaMapNotes_Data[i][zone][index] = nil;
135 end
136 end
137 end
138 end
139 for i=1, 2, 1 do
140 for zone, zoneTable in MetaMap_WorldNoteData[i] do
141 for index, value in MetaMap_WorldNoteData[i][zone] do
142 local shiftedZone = MetaMapNotes_ZoneShift[i][zone];
143 MetaMapNotes_Data[i][shiftedZone][index] = value;
144 end
145 end
146 end
147 MetaMapNotes_MapUpdate();
148 MetaMap_ImportHeader:SetTextColor(0,1,0);
149 MetaMap_ImportHeader:SetText("Default instance data imported successfully");
150 end
151  
152 function MetaMap_ImportMapNotes()
153 local noteTotal = 0;
154 local noteImport = 0;
155 local noteDupe = 0;
156 local newCheck = false;
157 for continent=1, 2, 1 do
158 for zone, zoneTable in MapNotes_Data[continent] do
159 for i, value in MapNotes_Data[continent][zone] do
160 noteTotal = noteTotal +1;
161 local newNote = MapNotes_Data[continent][zone][i];
162 newCheck = MetaMapNotes_AddNewNote(continent, zone, newNote.xPos, newNote.yPos, newNote.name, newNote.inf1, newNote.inf2, newNote.creator, newNote.icon, newNote.ncol, newNote.in1c, newNote.in2c)
163 if(newCheck) then
164 noteImport = noteImport +1;
165 local zoneTable = MapNotes_Lines[continent][zone]
166 for i, value in zoneTable do
167 if(zoneTable[i].x1 == newNote.xPos and zoneTable[i].y1 == newNote.yPos) then
168 MetaMapNotes_ToggleLine(continent, zone, zoneTable[i].x1, zoneTable[i].y1, zoneTable[i].x2, zoneTable[i].y2)
169 end
170 end
171 else
172 noteDupe = noteDupe +1;
173 end
174 end
175 end
176 end
177 local msg = "Imported "..noteImport.." notes from MapNotes from a total of "..noteTotal.." with "..noteDupe.." duplicates not imported";
178 MetaMap_ImportHeader:SetTextColor(0,1,0);
179 MetaMap_ImportHeader:SetText(msg);
180 end
181  
182 function MetaMap_ImportMapMod()
183 local noteTotal = 0;
184 local noteImport = 0;
185 local noteDupe = 0;
186 for zoneName in CT_UserMap_Notes do
187 for index in CT_UserMap_Notes[zoneName] do
188 noteTotal = noteTotal +1;
189 if(CT_UserMap_Notes[zoneName][index].set < 6) then
190 local newNote = CT_UserMap_Notes[zoneName][index];
191 local continent, zone = MetaMap_NameToZoneID(zoneName, 1);
192 newCheck = MetaMapNotes_AddNewNote(continent, zone, newNote.x, newNote.y, newNote.name, newNote.descript, "", UnitName("Player"), newNote.set, newNote.set, 0, 0)
193 if(newCheck) then
194 noteImport = noteImport +1;
195 else
196 noteDupe = noteDupe +1;
197 end
198 end
199 end
200 end
201 local msg = "Imported "..noteImport.." notes from MapMod from a total of "..noteTotal.." with "..noteDupe.." positions already occupied";
202 MetaMap_ImportHeader:SetTextColor(0,1,0);
203 MetaMap_ImportHeader:SetText(msg);
204 end
205  
206 function MetaMapBLT_ImportDefault()
207 LoadAddOn("MetaMapBLT");
208 if(not IsAddOnLoaded("MetaMapBLT")) then
209 MetaMap_ImportHeader:SetTextColor(1,0,0);
210 MetaMap_ImportHeader:SetText(METAMAPBLT_NOT_ENABLED);
211 return;
212 end
213 MetaMapBLTData = {};
214 MetaMapBLTData = MetaMapBLTDefaultData;
215 MetaMap_ImportHeader:SetTextColor(0,1,0);
216 MetaMap_ImportHeader:SetText(METAMAPBLT_IMPORT_DONE);
217 end
218  
219 function MetaMap_ImportUserKB()
220 MetaMap_TempData[MetaKB_dbID] = {};
221 local dupe = false;
222 local unknown = false;
223 local totalCount = 0;
224 local importCount = 0;
225 local dupeCount = 0;
226 local unknownCount = 0;
227 for import, continentTable in MyKB_Data[MetaKB_dbID] do
228 for continent, zoneTable in continentTable do
229 for zone in zoneTable do
230 totalCount = totalCount +1;
231 for name in MetaKB_Data[MetaKB_dbID] do
232 if(name == import) then
233 dupeCount = dupeCount +1;
234 dupe = true;
235 end
236 end
237 if(not dupe) then
238 MetaMap_TempData[MetaKB_dbID][import] = {};
239 MetaMap_TempData[MetaKB_dbID][import][continent] = {};
240 MetaMap_TempData[MetaKB_dbID][import][continent][zone] = {};
241 local TempData = MetaMap_TempData[MetaKB_dbID][import][continent][zone];
242 local ImportData = MyKB_Data[MetaKB_dbID][import][continent][zone];
243 TempData["inf1"] = ImportData.inf1;
244 TempData["inf2"] = ImportData.inf2;
245 TempData["icon"] = ImportData.icon;
246 TempData[1] = ImportData[1];
247 TempData[2] = ImportData[2];
248 TempData[3] = ImportData[3];
249 TempData[4] = ImportData[4];
250 importCount = importCount +1;
251 end
252 dupe = false;
253 end
254 end
255 end
256 for index in MetaMap_TempData[MetaKB_dbID] do
257 MetaKB_Data[MetaKB_dbID][index] = MetaMap_TempData[MetaKB_dbID][index];
258 end
259 MetaMap_TempData = {};
260 MetaMap_ImportHeader:SetTextColor(0,1,0);
261 MetaMap_ImportHeader:SetText(format(METAKB_IMPORT_SUCCESSFUL, importCount, totalCount, unknownCount, dupeCount));
262 end
263  
264 function MetaMap_ImportMetaNotes()
265 local noteTotal = 0;
266 local noteImport = 0;
267 local noteDupe = 0;
268 local newCheck = false;
269 for continent=1, 2, 1 do
270 for zone, zoneTable in MyNotes_Data[continent] do
271 for i, value in MyNotes_Data[continent][zone] do
272 noteTotal = noteTotal +1;
273 local newNote = MyNotes_Data[continent][zone][i];
274 newCheck = MetaMapNotes_AddNewNote(continent, zone, newNote.xPos, newNote.yPos, newNote.name, newNote.inf1, newNote.inf2, newNote.creator, newNote.icon, newNote.ncol, newNote.in1c, newNote.in2c)
275 if(newCheck) then
276 noteImport = noteImport +1;
277 local zoneTable = MyLines_Data[continent][zone]
278 for i, value in zoneTable do
279 if(zoneTable[i].x1 == newNote.xPos and zoneTable[i].y1 == newNote.yPos) then
280 MetaMapNotes_ToggleLine(continent, zone, zoneTable[i].x1, zoneTable[i].y1, zoneTable[i].x2, zoneTable[i].y2)
281 end
282 end
283 else
284 noteDupe = noteDupe +1;
285 end
286 end
287 end
288 end
289 local msg = "Imported "..noteImport.." notes from MetaNotes from a total of "..noteTotal.." with "..noteDupe.." duplicates not imported";
290 MetaMap_ImportHeader:SetTextColor(0,1,0);
291 MetaMap_ImportHeader:SetText(msg);
292 end