diff --git a/TomTom.toc b/TomTom.toc index 075c2a0..a65a254 100755 --- a/TomTom.toc +++ b/TomTom.toc @@ -1,4 +1,4 @@ -## Interface: 20400 +## Interface: 30000 ## Title: TomTom ## Version: wowi:revision ## Notes: Acts as your portable navigation assistant diff --git a/libs/Astrolabe/Astrolabe.lua b/libs/Astrolabe/Astrolabe.lua index 7f6527e..a7737f8 100644 --- a/libs/Astrolabe/Astrolabe.lua +++ b/libs/Astrolabe/Astrolabe.lua @@ -1,7 +1,7 @@ --[[ Name: Astrolabe -Revision: $Rev: 91 $ -$Date: 2008-08-21 02:51:27 +0100 (Thu, 21 Aug 2008) $ +Revision: $Rev: 93 $ +$Date: 2008-10-14 22:00:24 +0100 (Tue, 14 Oct 2008) $ Author(s): Esamynn (esamynn at wowinterface.com) Inspired By: Gatherer by Norganna MapLibrary by Kristofer Karlsson (krka at kth.se) @@ -42,7 +42,7 @@ Note: -- DO NOT MAKE CHANGES TO THIS LIBRARY WITHOUT FIRST CHANGING THE LIBRARY_VERSION_MAJOR -- STRING (to something unique) OR ELSE YOU MAY BREAK OTHER ADDONS THAT USE THIS LIBRARY!!! local LIBRARY_VERSION_MAJOR = "Astrolabe-0.4" -local LIBRARY_VERSION_MINOR = tonumber(string.match("$Revision: 91 $", "(%d+)") or 1) +local LIBRARY_VERSION_MINOR = tonumber(string.match("$Revision: 93 $", "(%d+)") or 1) if not DongleStub then error(LIBRARY_VERSION_MAJOR .. " requires DongleStub.") end if not DongleStub:IsNewerVersion(LIBRARY_VERSION_MAJOR, LIBRARY_VERSION_MINOR) then return end @@ -1048,160 +1048,160 @@ WorldMapSize = { -- World Map of Azeroth [0] = { parentContinent = 0, - height = 29688.932932224, - width = 44537.340058402, + height = 31809.64857610083, + width = 47714.278579261, }, -- Kalimdor { -- [1] parentContinent = 0, height = 24533.025279205, width = 36800.210572494, - xOffset = -8311.793923510446, - yOffset = 1815.215685280706, + xOffset = -8590.40725049343, + yOffset = 5628.692856102324, zoneData = { Ashenvale = { - height = 3843.722811451077, - width = 5766.728884700476, - xOffset = 15366.76755576002, - yOffset = 8126.925260781192, + height = 3843.722331667447, + width = 5766.728885829694, + xOffset = 15366.76675592628, + yOffset = 8126.925930315996, }, Aszhara = { - height = 3381.225696279877, - width = 5070.888165752819, - xOffset = 20343.90485013144, - yOffset = 7458.180046130774, + height = 3381.22554790382, + width = 5070.886912363937, + xOffset = 20343.90431905976, + yOffset = 7458.18074892042, }, AzuremystIsle = { - height = 2714.561862167815, - width = 4070.883253576282, - xOffset = 9966.70736478994, - yOffset = 5460.278138661794, + height = 2714.563862990522, + width = 4070.87719998905, + xOffset = 9966.708003150136, + yOffset = 5460.278492344226, }, Barrens = { - height = 6756.202067150937, - width = 10133.44343943073, - xOffset = 14443.84117394525, - yOffset = 11187.32013604393, + height = 6756.201888541853, + width = 10133.44231353798, + xOffset = 14443.84040901447, + yOffset = 11187.32063797497, }, BloodmystIsle = { - height = 2174.984710698752, - width = 3262.517428121028, - xOffset = 9541.713418184554, - yOffset = 3424.874558234072, + height = 2174.984213312164, + width = 3262.535628257626, + xOffset = 9541.702868577344, + yOffset = 3424.87645454774, }, Darkshore = { - height = 4366.636219106706, - width = 6550.06962983463, - xOffset = 14125.08809600818, - yOffset = 4466.534412478246, + height = 4366.635262519317, + width = 6550.07142937905, + xOffset = 14125.0864431955, + yOffset = 4466.535577798089, }, Darnassis = { - height = 705.7248633938184, - width = 1058.342927027606, - xOffset = 14128.39258617903, - yOffset = 2561.565012455802, + height = 705.7244742259542, + width = 1058.344272032854, + xOffset = 14128.39058434346, + yOffset = 2561.565704787642, }, Desolace = { - height = 2997.895174253872, - width = 4495.882023201739, - xOffset = 12833.40729836031, - yOffset = 12347.72848626745, + height = 2997.895112390325, + width = 4495.882561567951, + xOffset = 12833.40568925697, + yOffset = 12347.7291386989, }, Durotar = { - height = 3524.975114832228, - width = 5287.558038649864, - xOffset = 19029.30699887344, - yOffset = 10991.48801260963, + height = 3524.975103516492, + width = 5287.556393263762, + xOffset = 19029.30641831177, + yOffset = 10991.48866520544, }, Dustwallow = { - height = 3499.975146240067, - width = 5250.057259791282, - xOffset = 18041.79657043901, - yOffset = 14833.12751666842, + height = 3499.975024621409, + width = 5250.057340719384, + xOffset = 18041.79555525144, + yOffset = 14833.12785083746, }, Felwood = { - height = 3833.305958270781, - width = 5750.062034325837, - xOffset = 15425.10163773161, - yOffset = 5666.526367166872, + height = 3833.30578953572, + width = 5750.062500603067, + xOffset = 15425.10050841866, + yOffset = 5666.52696052216, }, Feralas = { - height = 4633.30011661694, - width = 6950.075260353015, - xOffset = 11625.06045254075, - yOffset = 15166.45834829251, + height = 4633.300220031075, + width = 6950.07476479001, + xOffset = 11625.05968863682, + yOffset = 15166.45859885191, }, Moonglade = { - height = 1539.572509508711, - width = 2308.356845256911, - xOffset = 18448.05172159372, - yOffset = 4308.20254319874, + height = 1539.572004392277, + width = 2308.359613919473, + xOffset = 18448.04941280923, + yOffset = 4308.203668830446, }, Mulgore = { - height = 3424.975945100366, - width = 5137.555355060729, - xOffset = 15018.84750987729, - yOffset = 13072.72336630089, + height = 3424.975591847491, + width = 5137.555664509726, + xOffset = 15018.84638430639, + yOffset = 13072.72374939454, }, Ogrimmar = { - height = 935.4100697456119, - width = 1402.621211455915, - xOffset = 20747.42666130799, - yOffset = 10525.94769396873, + height = 935.4097495193695, + width = 1402.619172463506, + xOffset = 20747.42615230776, + yOffset = 10525.94819392488, }, Silithus = { - height = 2322.899061688691, - width = 3483.371975265956, - xOffset = 14529.25864164056, - yOffset = 18758.10068625832, + height = 2322.900917404436, + width = 3483.371660836989, + xOffset = 14529.25779832084, + yOffset = 18758.10034739171, }, StonetalonMountains = { - height = 3256.226691571251, - width = 4883.385977951072, - xOffset = 13820.91773479217, - yOffset = 9883.162892509636, + height = 3256.22685709556, + width = 4883.386126224323, + xOffset = 13820.91659894445, + yOffset = 9883.163451643639, }, Tanaris = { - height = 4599.965662459992, - width = 6900.073766103516, - xOffset = 17285.539010128, - yOffset = 18674.7673661939, + height = 4599.967247105565, + width = 6900.075410478199, + xOffset = 17285.53717337067, + yOffset = 18674.76738951156, }, Teldrassil = { - height = 3393.726923234355, - width = 5091.720903621394, - xOffset = 13252.16205313556, - yOffset = 968.6418744503761, + height = 3393.725685278266, + width = 5091.720159017256, + xOffset = 13252.16118637725, + yOffset = 968.6435100517717, }, TheExodar = { - height = 704.6826864472878, - width = 1056.781131437323, - xOffset = 10533.08314172693, - yOffset = 6276.205331713322, + height = 704.6827795715492, + width = 1056.782908333002, + xOffset = 10533.08067788734, + yOffset = 6276.205943683332, }, ThousandNeedles = { - height = 2933.312180524323, - width = 4400.046681282484, - xOffset = 17500.12437633161, - yOffset = 16766.44698282704, + height = 2933.311990587089, + width = 4400.046926738385, + xOffset = 17500.12330544135, + yOffset = 16766.44742072096, }, ThunderBluff = { - height = 695.8282721105132, - width = 1043.761263579803, - xOffset = 16550.11410485969, - yOffset = 13649.80260929285, + height = 695.8286363220358, + width = 1043.761162566134, + xOffset = 16550.11296988024, + yOffset = 13649.80296445508, }, UngoroCrater = { - height = 2466.647220780505, - width = 3700.040077455555, - xOffset = 16533.44712326324, - yOffset = 18766.4334494793, + height = 2466.648940830691, + width = 3700.039952384531, + xOffset = 16533.4461782123, + yOffset = 18766.43318304924, }, Winterspring = { - height = 4733.299561046713, - width = 7100.077599808275, - xOffset = 17383.45606038691, - yOffset = 4266.536453420381, + height = 4733.299352687333, + width = 7100.076688034489, + xOffset = 17383.45536235255, + yOffset = 4266.537029274375, }, }, }, @@ -1210,182 +1210,182 @@ WorldMapSize = { parentContinent = 0, height = 27149.795290881, width = 40741.175327834, - xOffset = 14407.1086092051, - yOffset = 290.3230897653046, + xOffset = 18542.31220836664, + yOffset = 3585.574573158966, zoneData = { Alterac = { - height = 1866.673586850316, - width = 2800.000436369314, - xOffset = 17388.63313899802, - yOffset = 9676.382605411302, + height = 1866.674220583334, + width = 2799.999464405289, + xOffset = 17388.63468066122, + yOffset = 9676.382149825957, }, Arathi = { - height = 2400.0092446309, - width = 3599.999380663208, - xOffset = 19038.63328411639, - yOffset = 11309.72201070757, + height = 2400.009317069356, + width = 3599.999517304195, + xOffset = 19038.63447926361, + yOffset = 11309.72195295708, }, Badlands = { - height = 1658.340965090961, - width = 2487.498490907989, - xOffset = 20251.1337564772, - yOffset = 17065.99404487956, + height = 1658.340337615859, + width = 2487.500569928747, + xOffset = 20251.13345045087, + yOffset = 17065.99453090572, }, BlastedLands = { - height = 2233.343415116865, - width = 3349.999381676505, - xOffset = 19413.63362865575, - yOffset = 21743.09582955139, + height = 2233.342487048268, + width = 3349.999380719363, + xOffset = 19413.63423284709, + yOffset = 21743.09620559562, }, BurningSteppes = { - height = 1952.091972408385, - width = 2929.16694293186, - xOffset = 18438.633261567, - yOffset = 18207.66513379744, + height = 1952.091015081907, + width = 2929.167049647848, + xOffset = 18438.63415866318, + yOffset = 18207.66550773985, }, DeadwindPass = { - height = 1666.673818905317, - width = 2499.999888210889, - xOffset = 19005.29993968603, - yOffset = 21043.0932328648, + height = 1666.673717206878, + width = 2499.999255461505, + xOffset = 19005.30099399293, + yOffset = 21043.09319963172, }, DunMorogh = { - height = 3283.345779814337, - width = 4924.998791911572, - xOffset = 16369.8840376619, - yOffset = 15053.48695195484, + height = 3283.346244075043, + width = 4925.000979131685, + xOffset = 16369.88372014602, + yOffset = 15053.48652833869, }, Duskwood = { - height = 1800.007653419076, - width = 2699.999669551933, - xOffset = 17338.63354148773, - yOffset = 20893.09259181909, + height = 1800.007435102674, + width = 2699.999451812027, + xOffset = 17338.63474984946, + yOffset = 20893.09262994406, }, EasternPlaguelands = { - height = 2581.259876367526, - width = 3870.832396995169, - xOffset = 20357.38356562001, - yOffset = 7376.373692430854, + height = 2687.510259086504, + width = 4031.248684963022, + xOffset = 20459.46800337001, + yOffset = 7472.207074316265, }, Elwynn = { - height = 2314.591970284716, - width = 3470.831971412848, - xOffset = 16636.55099386465, - yOffset = 19116.0027890283, + height = 2314.592478810788, + width = 3470.832795915813, + xOffset = 16636.55146195304, + yOffset = 19116.00248086271, }, EversongWoods = { - height = 3283.346366715794, - width = 4924.998483501337, - xOffset = 20259.46725884782, - yOffset = 2534.687567863296, + height = 3283.346090242183, + width = 4925.00271131707, + xOffset = 20259.46550654072, + yOffset = 2534.687768168357, }, Ghostlands = { - height = 2200.008945183733, - width = 3300.002855743766, - xOffset = 21055.29786070095, - yOffset = 5309.698546426793, + height = 2200.008615840919, + width = 3300.001914001321, + xOffset = 21055.29898547313, + yOffset = 5309.698628620597, }, Hilsbrad = { - height = 2133.341840477916, - width = 3200.000391416799, - xOffset = 17105.29968281043, - yOffset = 10776.38652289269, + height = 2133.341648261057, + width = 3199.998998314975, + xOffset = 17105.30161317513, + yOffset = 10776.38647689923, }, Hinterlands = { - height = 2566.676323518885, - width = 3849.998492380244, - xOffset = 19746.96704279287, - yOffset = 9709.715966757984, + height = 2566.6767425107, + width = 3849.999302583992, + xOffset = 19746.96759079755, + yOffset = 9709.715638073398, }, Ironforge = { - height = 527.6056771582851, - width = 790.6252518322632, - xOffset = 18885.55815177769, - yOffset = 15745.64795436116, + height = 527.6066263822604, + width = 790.625237342102, + xOffset = 18885.55918004965, + yOffset = 15745.64757909506, }, LochModan = { - height = 1839.590356444166, - width = 2758.33360594204, - xOffset = 20165.71623436714, - yOffset = 15663.90573348468, + height = 1839.589436540107, + width = 2758.333078630792, + xOffset = 20165.71744013867, + yOffset = 15663.90644131906, }, Redridge = { - height = 1447.922213393415, - width = 2170.833229570681, - xOffset = 19742.79960560691, - yOffset = 19751.42209395218, + height = 1447.921846941264, + width = 2170.833008876805, + xOffset = 19742.80073199006, + yOffset = 19751.42200372843, }, SearingGorge = { - height = 1487.505203229038, - width = 2231.250200533406, - xOffset = 18494.88325409831, - yOffset = 17276.41231120941, + height = 1487.505327445583, + width = 2231.249676776115, + xOffset = 18494.88412729142, + yOffset = 17276.41249042905, }, SilvermoonCity = { - height = 806.7751969249011, - width = 1211.458551923779, - xOffset = 22172.71573747824, - yOffset = 3422.647395021269, + height = 806.7736903384404, + width = 1211.459296502504, + xOffset = 22172.71642224908, + yOffset = 3422.648306718702, }, Silverpine = { - height = 2800.011187621704, - width = 4200.000573479695, - xOffset = 14721.96646274185, - yOffset = 9509.714741967448, + height = 2800.0110500699, + width = 4199.999060067367, + xOffset = 14721.96859379216, + yOffset = 9509.714862642681, }, Stormwind = { - height = 896.3598437319051, - width = 1344.270269919159, - xOffset = 16790.9956264139, - yOffset = 19455.27053790398, + height = 1158.337650999629, + width = 1737.500553362899, + xOffset = 16449.05109973784, + yOffset = 19172.25293704512, }, Stranglethorn = { - height = 4254.18312444072, - width = 6381.248484543122, - xOffset = 15951.13375783437, - yOffset = 22345.18258706305, + height = 4254.183097414531, + width = 6381.247773741421, + xOffset = 15951.13530113703, + yOffset = 22345.18245588815, }, Sunwell = { - height = 2218.756638064149, - width = 3327.084777999942, - xOffset = 21074.0484502027, - yOffset = 7.595267688679496, + height = 2218.75784157939, + width = 3327.080984022923, + xOffset = 21074.05125342849, + yOffset = 7.594755912743345, }, SwampOfSorrows = { - height = 1529.173695058727, - width = 2293.753807610138, - xOffset = 20394.88183258176, - yOffset = 20797.25913588854, + height = 1529.173582734637, + width = 2293.750686253685, + xOffset = 20394.88344424886, + yOffset = 20797.25895394673, }, Tirisfal = { - height = 3012.510490816506, - width = 4518.749381850256, - xOffset = 15138.63417865412, - yOffset = 7338.874503644808, + height = 3012.512329627232, + width = 4518.747902731258, + xOffset = 15138.6360714653, + yOffset = 7338.872677268415, }, Undercity = { - height = 640.1067253394195, - width = 959.3752013853186, - xOffset = 17298.77399735696, - yOffset = 9298.435338905521, + height = 640.1066040851099, + width = 959.3745478926886, + xOffset = 17298.77542115219, + yOffset = 9298.435370484816, }, WesternPlaguelands = { - height = 2866.677213191588, - width = 4299.998717025251, - xOffset = 17755.30067544475, - yOffset = 7809.708745090687, + height = 2866.677851772014, + width = 4299.999720893135, + xOffset = 17755.30124459509, + yOffset = 7809.708293788776, }, Westfall = { - height = 2333.342039971409, - width = 3500.001170481545, - xOffset = 15155.29922254704, - yOffset = 20576.42557120998, + height = 2333.342511708478, + width = 3499.999662793482, + xOffset = 15155.30169114852, + yOffset = 20576.42535247717, }, Wetlands = { - height = 2756.260286844545, - width = 4135.414389381328, - xOffset = 18561.55091405621, - yOffset = 13324.31339403164, + height = 2756.260945423485, + width = 4135.416085415621, + xOffset = 18561.55114967782, + yOffset = 13324.31325114659, }, }, }, @@ -1396,150 +1396,132 @@ WorldMapSize = { width = 17463.987300595, zoneData = { BladesEdgeMountains = { - height = 3616.553511321226, - width = 5424.972055480694, - xOffset = 4150.184214583454, - yOffset = 1412.98225932006, + height = 3616.553525584605, + width = 5424.971374542539, + xOffset = 4150.184588602209, + yOffset = 1412.982196881336, }, Hellfire = { - height = 3443.642450656037, - width = 5164.556104714847, - xOffset = 7456.417230912641, - yOffset = 4339.973750274888, + height = 3443.64230460125, + width = 5164.556244744065, + xOffset = 7456.417231266903, + yOffset = 4339.973859432732, }, Nagrand = { - height = 3683.218538167106, - width = 5524.971495006054, - xOffset = 2700.192018521809, - yOffset = 5779.511974812862, + height = 3683.218433421437, + width = 5524.971116484553, + xOffset = 2700.192056890117, + yOffset = 5779.512082963144, }, Netherstorm = { - height = 3716.550608724641, - width = 5574.970083688359, - xOffset = 7512.667416095402, - yOffset = 365.0979827402549, + height = 3716.550667470386, + width = 5574.970542741407, + xOffset = 7512.666973902843, + yOffset = 365.0979868806522, }, ShadowmoonValley = { - height = 3666.552070430093, - width = 5499.971770418525, - xOffset = 8770.993458280615, - yOffset = 7769.033264592288, + height = 3666.551832578994, + width = 5499.971055470069, + xOffset = 8770.993482940312, + yOffset = 7769.033432511459, }, ShattrathCity = { - height = 870.8059516186869, - width = 1306.242821388422, - xOffset = 6860.744740098593, - yOffset = 7295.086120456203, + height = 870.8062268244973, + width = 1306.243111124071, + xOffset = 6860.744657085816, + yOffset = 7295.086006462451, }, TerokkarForest = { - height = 3599.887783533737, - width = 5399.971351016305, - xOffset = 5912.675516998205, - yOffset = 6821.146319031154, + height = 3599.887549731843, + width = 5399.971897226099, + xOffset = 5912.67529110344, + yOffset = 6821.146327166267, }, Zangarmarsh = { - height = 3351.978710181591, - width = 5027.057650868489, - xOffset = 3521.020638264577, - yOffset = 3885.821278366336, + height = 3351.978661481413, + width = 5027.057239215307, + xOffset = 3521.020775148071, + yOffset = 3885.821395736634, }, }, }, -} - ---- WotLK Adjustments -if ( GetBuildInfo():sub(1, 3) == "3.0" ) then - WorldMapSize[0].height = 31809.64859753034; - WorldMapSize[0].width = 47714.27770954026; - - WorldMapSize[1].xOffset = -8590.409362625034; - WorldMapSize[1].yOffset = 5628.694276155668; - - WorldMapSize[2].xOffset = 18542.31268111796; - WorldMapSize[2].yOffset = 3585.574682467752; - WorldMapSize[2].zoneData.Stormwind = { - height = 1158.33686894901, - width = 1737.498058940429, - xOffset = 16449.05164642256, - yOffset = 19172.25350774846, - } - - WorldMapSize[4] = { + -- Northrend + { -- [4] parentContinent = 0, - height = 11834.31067391958, - width = 17751.3936186856, - xOffset = 16020.94093549576, - yOffset = 454.2464807713226, + height = 11834.3119870532, + width = 17751.3962441049, + xOffset = 16020.94044398222, + yOffset = 454.2451915717977, zoneData = { BoreanTundra = { - height = 3843.765503862232, - width = 5764.58206497758, - xOffset = 646.3186767730767, - yOffset = 5695.480016983896, + height = 3843.764953143499, + width = 5764.582303295793, + xOffset = 646.3192474426043, + yOffset = 5695.48114050537, }, CrystalsongForest = { - height = 1814.590053385046, - width = 2722.916164555434, - xOffset = 7773.400227973558, - yOffset = 4091.307437548815, + height = 1814.590295101352, + width = 2722.916513743646, + xOffset = 7773.401390128443, + yOffset = 4091.308181657137, }, Dalaran = { - height = 553.3419356683534, - width = 830.014625253355, - xOffset = 8164.640128758279, - yOffset = 4526.722218200071, + height = 553.3418567935553, + width = 830.0149393375432, + xOffset = 8164.641313001377, + yOffset = 4526.723129621716, }, Dragonblight = { - height = 3739.597759999098, - width = 5608.331259502691, - xOffset = 5590.067753073641, - yOffset = 5018.394106536425, + height = 3739.598062842169, + width = 5608.332396545997, + xOffset = 5590.068422600026, + yOffset = 5018.394866268677, }, GrizzlyHills = { - height = 3500.013349296343, - width = 5249.9986179934, - xOffset = 10327.56614428777, - yOffset = 5076.727864214266, + height = 3500.013689934217, + width = 5249.998732532693, + xOffset = 10327.56786162186, + yOffset = 5076.728707808831, }, HowlingFjord = { - height = 4031.266275060274, - width = 6045.831339550668, - xOffset = 10615.0658552538, - yOffset = 7476.736868262738, + height = 4031.265457002443, + width = 6045.831836878359, + xOffset = 10615.0679627145, + yOffset = 7476.73831512609, }, IcecrownGlacier = { - height = 4181.266116737856, - width = 6270.831861693458, - xOffset = 3304.65133149085, - yOffset = 1166.296192718834, + height = 4181.266519840844, + width = 6270.832975322177, + xOffset = 3773.401695036191, + yOffset = 1166.296622984233, }, LakeWintergrasp = { - height = 1983.342901980711, - width = 2974.999377667768, - xOffset = 4887.984320612982, - yOffset = 4876.725348039468, + height = 1983.341134082619, + width = 2974.99948105957, + xOffset = 4887.98528918423, + yOffset = 4876.727878058311, }, SholazarBasin = { - height = 2904.177559586215, - width = 4356.248328680455, - xOffset = 2287.985279107324, - yOffset = 3305.887993444818, + height = 2904.178067737769, + width = 4356.249510482578, + xOffset = 2287.985538503677, + yOffset = 3305.888591396293, }, TheStormPeaks = { - height = 4741.684940421732, - width = 7112.498205872217, - xOffset = 7375.483315518691, - yOffset = 395.4596828327046, + height = 4741.684740041381, + width = 7112.498187401986, + xOffset = 7375.484940713573, + yOffset = 395.46058562991, }, ZulDrak = { - height = 3329.179510740043, - width = 4993.747919923504, - xOffset = 9817.150055203074, - yOffset = 2924.636381254688, + height = 3329.179762967791, + width = 4993.749118857795, + xOffset = 9817.151095677416, + yOffset = 2924.637042390465, }, }, - } -end + }, +} local zeroData; zeroData = { xOffset = 0, height = 0, yOffset = 0, width = 0, __index = function() return zeroData end }; diff --git a/libs/LibStub/LibStub.lua b/libs/LibStub/LibStub.lua new file mode 100644 index 0000000..ae1900e --- /dev/null +++ b/libs/LibStub/LibStub.lua @@ -0,0 +1,51 @@ +-- $Id: LibStub.lua 76 2007-09-03 01:50:17Z mikk $ +-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info +-- LibStub is hereby placed in the Public Domain +-- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke +local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! +local LibStub = _G[LIBSTUB_MAJOR] + +-- Check to see is this version of the stub is obsolete +if not LibStub or LibStub.minor < LIBSTUB_MINOR then + LibStub = LibStub or {libs = {}, minors = {} } + _G[LIBSTUB_MAJOR] = LibStub + LibStub.minor = LIBSTUB_MINOR + + -- LibStub:NewLibrary(major, minor) + -- major (string) - the major version of the library + -- minor (string or number ) - the minor version of the library + -- + -- returns nil if a newer or same version of the lib is already present + -- returns empty library object or old library object if upgrade is needed + function LibStub:NewLibrary(major, minor) + assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") + minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") + + local oldminor = self.minors[major] + if oldminor and oldminor >= minor then return nil end + self.minors[major], self.libs[major] = minor, self.libs[major] or {} + return self.libs[major], oldminor + end + + -- LibStub:GetLibrary(major, [silent]) + -- major (string) - the major version of the library + -- silent (boolean) - if true, library is optional, silently return nil if its not found + -- + -- throws an error if the library can not be found (except silent is set) + -- returns the library object if found + function LibStub:GetLibrary(major, silent) + if not self.libs[major] and not silent then + error(("Cannot find a library instance of %q."):format(tostring(major)), 2) + end + return self.libs[major], self.minors[major] + end + + -- LibStub:IterateLibraries() + -- + -- Returns an iterator for the currently registered libraries + function LibStub:IterateLibraries() + return pairs(self.libs) + end + + setmetatable(LibStub, { __call = LibStub.GetLibrary }) +end diff --git a/libs/LibStub/LibStub.toc b/libs/LibStub/LibStub.toc new file mode 100644 index 0000000..4d9130c --- /dev/null +++ b/libs/LibStub/LibStub.toc @@ -0,0 +1,9 @@ +## Interface: 20400 +## Title: Lib: LibStub +## Notes: Universal Library Stub +## Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel +## X-Website: http://jira.wowace.com/browse/LS +## X-Category: Library +## X-License: Public Domain + +LibStub.lua