PK NK FishingBuddy/Bindings.xml
if ( keystate == "down" ) then
FishingBuddy.Command("");
end
if ( keystate == "down" ) then
ToggleFishingBuddyFrame("FishingLocationsFrame");
end
if ( keystate == "down" ) then
ToggleFishingBuddyFrame("FishingOptionsFrame");
end
if ( keystate == "down" ) then
FishingBuddy.Command(FBConstants.SWITCH);
end
PK ȭ"LQ3 3 FishingBuddy/FishingAbout.lua-- Display some information about the people who helped
-- Some information about whom to thank
local credits = {};
-- Translation help
credits[FBConstants.ROLE_TRANSLATE_ZHTW] = {
["machihchung"] = { "V0.9.9e4" },
["Indra (Eastern.Stories)"] = { "v0.9.3", "v0.9.3i", "v0.9.4", "v0.9.4b", "v0.9.7d", },
["Whocare"] = { "bahamut, an influential gamer forum in Taiwan 11/24/2007", },
["smartdavislin"] = { "V1.0.2", },
["Andyca"] = { "V1.0.7a" },
["zhTW"] = { "V1.0.9e", },
["titanium0107"] = { "V1.1e", "V1.2", "V1.2a", "V1.2c", "V1.2e", },
["alec65 "] = { "V1.4u", },
["gaspy10"] = { "V1.7.13c" }
};
credits[FBConstants.ROLE_TRANSLATE_ITIT] = {
["bER92"] = { "V1.0.9f" },
["Impaler"] = { "V1.0.9f" },
["_YuSaKu_"] = { "V1.4d", },
};
credits[FBConstants.ROLE_TRANSLATE_ZHCN] = {
["biAji"] = { "v0.9.3d" },
["wowuicon"] = { "V0.9.9e4", "V1.0.2", },
["yahooor"] = { "V0.9.9e4" },
["foxdodo"] = { "V1.0.2" },
["dh0000"] = { "V1.0.7a", "V1.0.7e", "V1.0.7h", },
["yuningning520}"] = { "V1.5" },
};
credits[FBConstants.ROLE_TRANSLATE_DEDE] = {
["Leidbringer"] = { "v0.9.7d", },
["Chinkuwaila"] = { "v0.8.9", },
["blackrat"] = { "v0.8.1d", },
["RustyXXL"] = { "V1.0.4", },
["Ithilrandir"] = { "V1.0.5", },
["DirtyHarryGermany"] = { "V1.0.7h", "V1.0.9e", "V1.1e", "V1.2a", "V1.2c", "V1.2d", "V1.2f", "V1.2g", "v1.3c" },
["Freydis88"] = { "V1.0.9e", },
["Frontiii"] = { "V1.0.9e", },
};
credits[FBConstants.ROLE_TRANSLATE_FRFR] = {
["krogh"] = { "v0.8.7", },
["Corwin Whitehorn"] = { "v0.8.5", },
["PierrotIV"] = { "V1.0.9e", },
["boidan01"] = { "V1.0.9e", },
["Matisk"] = { "V1.2a", "V1.4n" },
["ckeurk"] = { "V1.4n" },
["Mips"] = { "V1.4n" },
["Dabeuliou"] = { "V1.4d", "V1.4g" },
["gurki35 "] = { "V1.7.7" },
};
credits[FBConstants.ROLE_TRANSLATE_ESES] = {
["Fili"] = { "v0.8.6b", "v0.9.7d", },
["Valdesca"] = { "v0.9.9e6", },
["Winderfind Drakkari"] = { "v1.0.7a" },
["jmaister"] = { "V1.0.9e", },
["karrash76"] = { "V1.2f", "V1.2g", },
["Magire"] = { "V1.2j", },
};
credits[FBConstants.ROLE_TRANSLATE_KOKR] = {
["maknae"] = { "V0.9.9e4" },
["post"] = { "V0.9.9e4" },
["seashop"] = { "V1.0.2" },
};
credits[FBConstants.ROLE_TRANSLATE_RURU] = {
["StingerSoft"] = { "v0.9.8l", "V0.9.9e4" },
["hellquister"] = { "V0.9.9e4" },
["D_Angel"] = { "V0.9.9e4", "V1.0.2", "V1.1c" },
["AlenaM"] = { "V1.0" },
["KVVV"] = { "V1.0" },
["frodo10"] = { "V1.0" },
["DVK"] = { "V1.1f" },
["Ant1dotE"] = { "V1.0.1", "V1.0.2", "V1.0.4" },
["BloodyFess"] = { "V1.2d", "V1.2h" },
["Turbid121"] = { "V1.2h", "V1.2i" },
["PocoMaxa"] = { "V1.6b", },
};
credits[FBConstants.ROLE_TRANSLATE_PTBR] = {
["nomadbr"] = { "V1.0.7a" },
["tiagopl"] = { "V1.2j", },
};
-- Testers/bug fixers
credits[FBConstants.ROLE_HELP_BUGS] = {
["Goose"] = { "Fishing skill-up help", },
["Moleculor"] = { "Fishing skill-up help", },
["Shadrin"] = { "Text cleanup and bug fixes", },
["ZeroKnowledge"] = { "Automatic lure improvements", },
["dwex"] = { "Bug fixes", },
["Saur"] = { "Nat Pagle's Fishing Terminator", },
["Draznar"] = { "for the Fishing FAQ and style!", },
["bsmorgan"] = { "Minimap button radius improvements", "Auto-lure improvments", "Skill-up tabulation", "Checking for usable toys." },
["Wildcard_25"] = { "Fish watcher displays days!", },
["Bodar"] = { "GetProfessions change in 4.0.6", "Watch Bobber fix", "Deprecated Blizz acution APIs", },
["Exaid"] = { "Fix for uncertain gear manager set on login" },
["x87bliss"] = { "Help with tracking down exit with pole crashes" },
["oscarucb"] = { "Help with the fix for repeat lure bug" },
["callumw"] = { "Typo identification in fishing lib" },
["Ninmah"] = { "Beta tester", "Auto-loot reset bug" },
["WildCard_25"] = { "Fish Watcher update bug" },
["Grizzly_UK"] = { "Forum support and understanding", "Debugging watcher location", },
["Badmunkay@Shadow Council"] = { "Better Extravaganza time handling", },
["esiemiat"] = { "Minimap icon move bug help", },
["DirtyHarryGermany"] = { "Beta tester", },
["Alindrios"] = { "Fish Watcher bugs", },
["Dehvid"] = { "64-bit crash bug", },
["ProphetV"] = { "Fish Watcher accounting errors", },
["Bodar"] = { "Better Nat's quest handling", "Watch Bobber fix", },
["miss_kallistra"] = { "Pet handling fixes for Legion", },
["Baconslicer"] = { "Lure managment bug"},
["Gulduka"] = { "German language testing for LibBabble-SubZone" },
["Mastigophoran"] = { "Help with Truthseeker/Oathbreaker issue" },
["Resike"] = { "Help fix leaking globals, potentional taint hazards" }
};
-- Ideas and suggestions
credits[FBConstants.ROLE_HELP_SUGGESTIONS] = {
["secutanudu"] = { "Turn on sound in background while fishing", },
["Lufunpsy"] = { "Turn up particle density when fishing", "Turn on sound if it's off", },
["mysticalos"] = { "Turn off PvP while fishing", },
["Lrdx"] = { "Count tastyfish in your bag instead of as you catch them",
"Only fish in schools during Extravaganza", },
["Alcasius"] = { "multi-machine database merge", },
["SBaL"] = { "Mute everything but bobber sounds", },
["Xantandor"] = { "More summary information while fishing", },
["zino"] = { "Remove quest items from the list of things caught", },
["Daisyvondoom"] = { "Separate out Pygmy fish from counts", },
["Dark Imakuni"] = { "Save the show fish/locations choice",
"Force item slot empty in ODF",
"Titan Panel support",
"Only show counts -- no percentages", },
["LBlaze"] = { "Display both lifetime and current fish info in the watcher", },
["Valzic"] = { "Save helm/cloak settings per outfit", },
["KayJayDK"] = { "Remember tastyfish pool locations", },
["Bruntlief"] = { "Track cycle fish", },
["Buio"] = { "Show current zone in watcher", },
["Tarklash"] = { "Minimap icon", },
["Anakar"] = { "Elapsed fishing time", },
["Valzic"] = { "Show current skill level in watcher", },
["Vreejack"] = { "Gatherer integration", },
["truefreak"] = { "Display total fish caught all time and this session", },
["Yeoman and RamahP"] = { "Save fishing level information", },
["RamahP"] = { "Lost fish count", },
["Ravynne"] = { "ZOMG *all* the pets!", },
["El's Extreme Anglin'"] = { "Subzone fishing levels", "Fishing skill up table" },
["brykrys"] = { "Corpse Worm" },
["Ross"] = { "Improved action button" },
};
credits[FBConstants.ROLE_ADDON_AUTHORS] = {
["x87bliss"] = { "FishWarden", },
["Mundocani"] = { "Outfitter", },
["The Cosmos Team"] = { "TackleBox", },
["Impp"] = { "Impp's Fishing DB", },
["Iriel"] = { "QuickWeaponSwap", "DevTools", },
["Esamynn"] = { "Astrolabe", },
["ckknight"] = { "LibTourist-3.0", "LibBabble-Zone-3.0", "LibCrayon-3.0", },
["Arrowmaster"] = { "LibTourist-3.0", },
["Odica"] = { "LibTourist-3.0", },
["Ackis"] = { "LibBabble-Zone-3.0", },
["Nevcairiel"] = { "LibBabble-Zone-3.0", "LibStub", "LibBabble-SubZone-3.0", "CallbackHandler-1.0", },
["Kaelten"] = { "LibStub", },
["Ammo"] = { "LibStub", },
["Cladhaire"] = { "LibStub", },
["mikk"] = { "LibStub", "CallbackHandler-1.0", },
["arith"] = { "LibBabble-SubZone-3.0", },
["Dynaletik"] = { "LibBabble-SubZone-3.0", },
["Tekkub"] = { "LibDataBroker-1.1", },
["Cryect (cryect@gmail.com)"] = { "LibGraph-2.0", },
["Xinhuan"] = { "LibGraph-2.0", },
["KarlKFI"] = { "MobileMinimapButtons" },
["endx7"] = { "LibPetJournal-2.0" },
};
local CREDITSKIP = 7;
local function UpdateCreditPanel(self, elapsed)
if ( not self.started ) then
self.started = true;
self.fadestate = 5;
self.fadevalue = 0;
self.whatidx = 1;
self.currenttime = math.random()*2.5 + elapsed + 0.5;
end
self.currenttime = self.currenttime - elapsed;
if (self.currenttime > 0) then
return;
end
if (self.fadestate == 0) then
-- pick a new thing to display, and fade it in
self.data = self.credits[self.idx]
self.lines[1]:SetText(self.categories[self.data.title])
self.lines[2]:SetText(self.data.who)
local what = self.data.what[self.whatidx];
if (string.sub(what,1,1) == "v") then
what = "Version "..string.sub(what,2);
elseif (string.sub(what,1,1) == "V") then
what = "Version "..string.sub(what,2).." (CurseForge)";
end
self.lines[3]:SetText(what)
self:SetHeight(self.lines[1]:GetHeight()*4)
self:SetPoint("TOP", self.parent.Thanks, "BOTTOM", 0, -(self.offset-1)*self:GetHeight()-self.lines[1]:GetHeight());
-- Fade in everything
for _,line in ipairs(self.lines) do
line:SetAlpha(self.fadevalue)
end
if ( self.fadevalue < 1.0) then
self.fadevalue = self.fadevalue + 0.05
self.currenttime = 0.1
else
self.fadestate = 1
self.currenttime = 5.0 + math.random()*1.0;
self.fadevalue = 1.0
end
elseif (self.fadestate == 1) then
-- Pause for display
-- check for detail change
self.whatidx = self.whatidx + 1
if ( self.data.what[self.whatidx] ) then
self.fadestate = 2
else
self.idx = self.idx + CREDITSKIP
if ( self.idx > #self.credits ) then
self.idx = self.idx % CREDITSKIP
end
if ( self.idx == 0 ) then
self.idx = 1
end
self.whatidx = 1
self.fadestate = 4
end
elseif (self.fadestate == 2) then
-- Fade out detail
self.lines[3]:SetAlpha(self.fadevalue);
if ( self.fadevalue > 0.0) then
self.fadevalue = self.fadevalue - 0.05
self.currenttime = 0.1
else
self.fadestate = 3
self.fadevalue = 0.0
end
elseif (self.fadestate == 3) then
-- Fade in detail
self.lines[3]:SetText(self.data.what[self.whatidx])
self.lines[3]:SetAlpha(self.fadevalue);
if ( self.fadevalue < 1.0) then
self.fadevalue = self.fadevalue + 0.05
self.currenttime = 0.1
else
self.fadestate = 1
self.currenttime = 5.0 + math.random()*1.0;
self.fadevalue = 1.0
end
elseif (self.fadestate == 4) then
-- Fade out everything
for _,line in pairs(self.lines) do
line:SetAlpha(self.fadevalue)
end
if ( self.fadevalue > 0.0) then
self.fadevalue = self.fadevalue - 0.05
self.currenttime = 0.1
else
self.fadestate = 5
self.fadevalue = 0.0
end
elseif (self.fadestate == 5) then
-- Pause after fading out
self.fadestate = 0
self.currenttime = math.random()*0.15;
end
-- all the reset times are offset
self.currenttime = self.currenttime + elapsed;
end
local function MakeCreditPanel(parent, alignment, offset)
local panel = CreateFrame("FRAME", nil, parent)
panel.lines = {};
local point = panel
local where = "TOP"
for idx=1,3 do
local line = panel:CreateFontString(nil, "OVERLAY", "GameFontNormal")
line:SetPoint("TOPLEFT", point, where.."LEFT", 0, 0)
line:SetPoint("TOPRIGHT", point, where.."RIGHT", 0, 0)
tinsert(panel.lines, line)
point = line
where = "BOTTOM"
end
panel.display = {}
panel.started = false
panel.parent = parent
panel:SetScript("OnUpdate", UpdateCreditPanel);
panel:ClearAllPoints()
panel.offset = offset
panel:SetPoint("LEFT", alignment, "LEFT", 0, 0);
panel:SetPoint("RIGHT", alignment, "RIGHT", 0, 0);
return panel
end
local function AboutSetup(self)
if (not self.Author) then
self.Author = self:CreateFontString(nil, "OVERLAY", "GameFontNormal")
self.Author:SetPoint("TOP", self, "TOP", -4, 0)
self.Author:SetPoint("LEFT", self, "LEFT", 0, 0)
self.Author:SetPoint("RIGHT", self, "RIGHT", -48, 0)
self.Author:SetText(FBConstants.AUTHOR)
self.Author:Show()
self.Copyright = self:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
self.Copyright:SetPoint("TOP", self.Author, "BOTTOM", 0, -10)
self.Copyright:SetPoint("LEFT", self, "LEFT", 0, 0)
self.Copyright:SetPoint("RIGHT", self, "RIGHT", -48, 0)
self.Copyright:SetJustifyH("CENTER")
self.Copyright:SetText(FBConstants.COPYRIGHT)
self.Copyright:Show()
self.Thanks = self:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
self.Thanks:SetPoint("TOP", self.Copyright, "BOTTOM", 0, -10)
self.Thanks:SetPoint("LEFT", self, "LEFT", 0, 0)
self.Thanks:SetPoint("RIGHT", self, "RIGHT", -48, 0)
self.Thanks:SetJustifyH("CENTER")
self.Thanks:SetText(FBConstants.THANKS)
self.Thanks:Show()
self.Thanks.idx = -1;
self.categories = {}
for what,_ in pairs(credits) do
tinsert(self.categories, what)
end
self.credits = {}
for idx,shownext in ipairs(self.categories) do
for who,what in pairs(credits[shownext]) do
tinsert(self.credits, { title=idx, who=who, what=what, sort=math.random() })
end
end
self.Panels = {};
for idx=1,5 do
local panel = MakeCreditPanel(self, self.Thanks, idx)
panel.idx = idx
panel.credits = self.credits
panel.categories = self.categories
tinsert(self.Panels, panel)
end
-- Dump the storage, now that we have a better table
credits = nil;
table.sort(self.credits, function (a, b) return a.sort < b.sort; end)
self:ClearAllPoints();
self:SetAllPoints(FishingBuddyFrameInset);
end
end
local AboutOptions = {
["AboutFrame"] = {
["button"] = "FishingAboutFrame",
["setup"] = AboutSetup,
["margin"] = { 32, 16 },
},
};
local function OnEvent(self, event)
FishingBuddy.OptionsFrame.HandleOptions(FBConstants.ABOUT_TAB, "Interface\\Icons\\Inv_Misc_Questionmark", AboutOptions, nil, nil, true);
self:UnregisterEvent("VARIABLES_LOADED");
end
local frame = CreateFrame("FRAME", "FishingAboutFrame", FishingBuddyFrame)
frame:SetScript("OnEvent", OnEvent)
frame:RegisterEvent("VARIABLES_LOADED")
PK
z/L|A A FishingBuddy/FishingBuddy.lua-- FishingBuddy
--
-- Everything you wanted support for in your fishing endeavors
-- 5.0.4 has a problem with a global "_" (see some for loops below)
local _
local Crayon = LibStub("LibCrayon-3.0");
local FL = LibStub("LibFishing-1.0");
local Crayon = LibStub("LibCrayon-3.0");
local LO = LibStub("LibOptionsFrame-1.0");
-- Information for the stylin' fisherman
local POLES = {
["Fishing Pole"] = "6256:0:0:0",
["Strong Fishing Pole"] = "6365:0:0:0",
["Darkwood Fishing Pole"] = "6366:0:0:0",
["Big Iron Fishing Pole"] = "6367:0:0:0",
["Blump Family Fishing Pole"] = "12225:0:0:0",
["Nat Pagle's Extreme Angler FC-5000"] = "19022:0:0:0",
["Arcanite Fishing Pole"] = "19970:0:0:0",
["Seth's Graphite Fishing Pole"] = "25978:0:0:0",
["Nat's Lucky Fishing Pole"] = "45858:0:0:0",
["Mastercraft Kalu'ak Fishing Pole"] = "44050:0:0:0",
["Bone Fishing Pole"] = "45991:0:0:0",
["Jeweled Fishing Pole"] = "45992:0:0:0",
-- yeah, so you can't really use these (for now :-)
["Dwarven Fishing Pole"] = "3567:0:0:0",
["Goblin Fishing Pole"] = "4598:0:0:0",
["Nat Pagle's Fish Terminator"] = "19944:0:0:0",
}
local FISHINGHATS = {
[118393] = true, -- Tentacled Hat
[118380] = true, -- HightFish Cap
};
local GeneralOptions = {
["ShowNewFishies"] = {
["text"] = FBConstants.CONFIG_SHOWNEWFISHIES_ONOFF,
["tooltip"] = FBConstants.CONFIG_SHOWNEWFISHIES_INFO,
["v"] = 1,
["default"] = true },
["TurnOffPVP"] = {
["text"] = FBConstants.CONFIG_TURNOFFPVP_ONOFF,
["tooltip"] = FBConstants.CONFIG_TURNOFFPVP_INFO,
["v"] = 1,
["m"] = 1,
["default"] = false },
["SortByPercent"] = {
["text"] = FBConstants.CONFIG_SORTBYPERCENT_ONOFF,
["tooltip"] = FBConstants.CONFIG_SORTBYPERCENT_INFO,
["v"] = 1,
["default"] = true },
["DingQuestFish"] = {
["text"] = FBConstants.CONFIG_DINGQUESTFISH_ONOFF,
["tooltip"] = FBConstants.CONFIG_DINGQUESTFISH_INFO,
["v"] = 1,
["default"] = true, },
["EnhanceFishingSounds"] = {
["text"] = FBConstants.CONFIG_ENHANCESOUNDS_ONOFF,
["tooltip"] = FBConstants.CONFIG_ENHANCESOUNDS_INFO,
["v"] = 1,
["m"] = 1,
["p"] = 1,
["default"] = false },
["BackgroundSounds"] = {
["text"] = FBConstants.CONFIG_BGSOUNDS_ONOFF,
["tooltip"] = FBConstants.CONFIG_BGSOUNDS_INFO,
["v"] = 1,
["m"] = 1,
["default"] = false,
["parents"] = { ["EnhanceFishingSounds"] = "d" }, },
["TurnOnSound"] = {
["text"] = FBConstants.CONFIG_TURNONSOUND_ONOFF,
["tooltip"] = FBConstants.CONFIG_TURNONSOUND_INFO,
["v"] = 1,
["m"] = 1,
["default"] = false,
["parents"] = { ["EnhanceFishingSounds"] = "d", },
},
["MaxSound"] = {
["tooltip"] = FBConstants.CONFIG_MAXSOUND_INFO,
["parents"] = { ["EnhanceFishingSounds"] = "d", },
["button"] = "FishingBuddyOption_MaxVolumeSlider",
["margin"] = { 12, 8 }, },
["EnhancePools"] = {
["text"] = FBConstants.CONFIG_SPARKLIES_ONOFF,
["tooltip"] = FBConstants.CONFIG_SPARKLIES_INFO,
["v"] = 1,
["default"] = false,
["parents"] = { ["EnhanceFishingSounds"] = "d" }, },
-- ["CreateMacro"] = {
-- ["text"] = FBConstants.CONFIG_CREATEMACRO_ONOFF,
-- ["tooltip"] = FBConstants.CONFIG_CREATEMACRO_INFO,
-- ["v"] = 1,
-- ["global"] = 1,
-- ["default"] = false, },
-- ["PreventRecast"] = {
-- ["text"] = FBConstants.CONFIG_PREVENTRECAST_ONOFF,
-- ["tooltip"] = FBConstants.CONFIG_PREVENTRECAST_INFO,
-- ["v"] = 1,
-- ["global"] = 1,
-- ["default"] = false,
-- ["parents"] = { ["CreateMacro"] = "d" }, },
-- ["ToonMacro"] = {
-- ["text"] = FBConstants.CONFIG_TOONMACRO_ONOFF,
-- ["tooltip"] = FBConstants.CONFIG_TOONMACRO_INFO,
-- ["v"] = 1,
-- ["global"] = 1,
-- ["default"] = false,
-- ["parents"] = { ["CreateMacro"] = "d" }, },
};
-- x87bliss has implemented IsFishWardenEnabled as a public function, so
-- we can retire the GUID based check
local function IsWardenEnabled()
-- local FishWarden = FishWarden_79a6ca19_6666_4759_9b8f_a67708694e5b;
local doautoloot = 1;
if ( FiWaAPI_IsFishWardenEnabled and FiWaAPI_IsFishWardenEnabled() ) then
doautoloot = 0;
end
return "d", doautoloot;
end
local function ShouldAutoLoot()
local _, autoloot = IsWardenEnabled();
return FishingBuddy.GetSettingBool("AutoLoot") and (autoloot == 1);
end
local function IsFishingAceEnabled()
-- return FishingAce and FishingAce.enabledState;
if ( FishingAce and FishingAce.enabledState ) then
return true;
end
return false;
end
local EasyCastInit;
local CastingOptions = {
["EasyCast"] = {
["text"] = FBConstants.CONFIG_EASYCAST_ONOFF,
["tooltip"] = FBConstants.CONFIG_EASYCAST_INFO,
["tooltipd"] = FBConstants.CONFIG_EASYCAST_INFOD,
["enabled"] = function() return (not IsFishingAceEnabled()) and 1 or 0 end,
["init"] = function(o, b) EasyCastInit(o, b); end,
["v"] = 1,
["m"] = 1,
["p"] = 1,
["default"] = true },
["MountedCast"] = {
["text"] = FBConstants.CONFIG_MOUNTEDCAST_ONOFF,
["tooltip"] = FBConstants.CONFIG_MOUNTEDCAST_INFO,
["v"] = 1,
["parents"] = { ["EasyCast"] = "d", },
["default"] = false },
["AutoLoot"] = {
["text"] = FBConstants.CONFIG_AUTOLOOT_ONOFF,
["tooltip"] = FBConstants.CONFIG_AUTOLOOT_INFO,
["tooltipd"] = function()
if ( FiWaAPI_IsFishWardenEnabled and not IsFishingAceEnabled() ) then
return FBConstants.CONFIG_AUTOLOOT_INFOD;
end
-- return nil;
end,
["v"] = 1,
["m"] = 1,
["p"] = 1,
["parents"] = { ["EasyCast"] = "d", ["EasyCast"] = IsWardenEnabled },
["default"] = false },
["AutoOpen"] = {
["text"] = FBConstants.CONFIG_AUTOOPEN_ONOFF,
["tooltip"] = FBConstants.CONFIG_AUTOOPEN_INFO,
["v"] = 1,
["parents"] = { ["EasyCast"] = "d" },
["default"] = false },
["UseAction"] = {
["text"] = FBConstants.CONFIG_USEACTION_ONOFF,
["tooltip"] = FBConstants.CONFIG_USEACTION_INFO,
["v"] = 1,
["parents"] = { ["EasyCast"] = "d" },
["default"] = false },
["PartialGear"] = {
["text"] = FBConstants.CONFIG_PARTIALGEAR_ONOFF,
["tooltip"] = FBConstants.CONFIG_PARTIALGEAR_INFO,
["v"] = 1,
["parents"] = { ["EasyCast"] = "d" },
["default"] = true },
["WatchBobber"] = {
["text"] = FBConstants.CONFIG_WATCHBOBBER_ONOFF,
["tooltip"] = FBConstants.CONFIG_WATCHBOBBER_INFO,
["v"] = 1,
["parents"] = { ["EasyCast"] = "d" },
["default"] = true },
["ContestSupport"] = {
["text"] = FBConstants.CONFIG_CONTESTS_ONOFF,
["tooltip"] = FBConstants.CONFIG_CONTESTS_INFO,
["v"] = 1,
["default"] = false },
["STVTimer"] = {
["text"] = FBConstants.CONFIG_STVTIMER_ONOFF,
["tooltip"] = FBConstants.CONFIG_STVTIMER_INFO,
["v"] = 1,
["default"] = false,
["parents"] = { ["ContestSupport"] = "d" }
},
["STVPoolsOnly"] = {
["text"] = FBConstants.CONFIG_STVPOOLSONLY_ONOFF,
["tooltip"] = FBConstants.CONFIG_STVPOOLSONLY_INFO,
["v"] = 1,
["default"] = false,
["primary"] = "ContestSupport",
["parents"] = { ["ContestSupport"] = "d", ["EasyCast"] = "d" }
},
["EasyCastKeys"] = {
["default"] = FBConstants.KEYS_NONE,
["button"] = "FBEasyKeys",
["tooltipd"] = FBConstants.CONFIG_EASYCASTKEYS_INFO,
["parents"] = { ["EasyCast"] = "h" },
["init"] = function(o, b) b.InitMappedMenu(o,b); end,
["setup"] =
function(button)
local gs = FishingBuddy.GetSetting;
FBEasyKeys.menu:SetMappedValue("EasyCastKeys", gs("EasyCastKeys"));
end,
},
["MouseEvent"] = {
["default"] = "RightButtonUp",
["button"] = "FBMouseEvent",
["tooltipd"] = FBConstants.CONFIG_MOUSEEVENT_INFO,
["parents"] = { ["EasyCast"] = "h" },
["alone"] = 1,
["init"] = function(o, b) b.InitMappedMenu(o,b); end,
["setup"] =
function(button)
local gs = FishingBuddy.GetSetting;
FBMouseEvent.menu:SetMappedValue("MouseEvent", gs("MouseEvent"));
end,
},
["EasyLures"] = {
["text"] = FBConstants.CONFIG_EASYLURES_ONOFF,
["tooltip"] = FBConstants.CONFIG_EASYLURES_INFO,
["v"] = 1,
["m"] = 1,
["depends"] = { ["EasyCast"] = "d" },
["default"] = false },
["AlwaysLure"] = {
["text"] = FBConstants.CONFIG_ALWAYSLURE_ONOFF,
["tooltip"] = FBConstants.CONFIG_ALWAYSLURE_INFO,
["v"] = 1,
["m"] = 1,
["parents"] = { ["EasyLures"] = "d" },
["default"] = false },
["BigDraenor"] = {
["text"] = FBConstants.CONFIG_BIGDRAENOR_ONOFF,
["tooltip"] = FBConstants.CONFIG_BIGDRAENOR_INFO,
["v"] = 1,
["m"] = 1,
["parents"] = { ["EasyLures"] = "d" },
["default"] = true },
["LastResort"] = {
["text"] = FBConstants.CONFIG_LASTRESORT_ONOFF,
["tooltip"] = FBConstants.CONFIG_LASTRESORT_INFO,
["v"] = 1,
["parents"] = { ["EasyLures"] = "d" },
["default"] = false },
["DraenorBait"] = {
["text"] = FBConstants.CONFIG_DRAENORBAIT_ONOFF,
["tooltip"] = FBConstants.CONFIG_DRAENORBAIT_INFO,
["v"] = 1,
["m"] = 1,
["primary"] = "EasyLures",
["parents"] = { ["EasyLures"] = "d", ["EasyLures"] = "d" },
["default"] = true },
["DraenorBaitMaintainOnly"] = {
["text"] = FBConstants.CONFIG_DRAENORBAITMAINTAIN_ONOFF,
["tooltip"] = FBConstants.CONFIG_DRAENORBAITMAINTAIN_INFO,
["v"] = 1,
["primary"] = "EasyLures",
["parents"] = { ["DraenorBait"] = "d", ["EasyLures"] = "d", },
["default"] = true },
["DalaranLures"] = {
["text"] = FBConstants.CONFIG_DALARANLURES_ONOFF,
["tooltip"] = FBConstants.CONFIG_DALARANLURES_INFO,
["v"] = 1,
["parents"] = { ["EasyLures"] = "d", },
["default"] = true },
};
local InvisibleOptions = {
-- options not directly manipulatable from the UI
["TooltipInfo"] = {
["text"] = FBConstants.CONFIG_TOOLTIPS_ONOFF,
["tooltip"] = FBConstants.CONFIG_TOOLTIPS_INFO,
["default"] = false },
["GroupByLocation"] = {
["default"] = true,
},
-- bar switching
["ClickToSwitch"] = {
["default"] = true,
},
-- sound enhancement
["EnhanceSound_SFXVolume"] = {
["default"] = 1.0,
},
["EnhanceSound_MasterVolume"] = {
["scale"] = 1,
["default"] = 100,
},
["EnhanceSound_MusicVolume"] = {
["default"] = 0.0,
},
["EnhanceSound_AmbienceVolume"] = {
["default"] = 0.0,
},
["EnhanceMapWaterSounds"] = {
["default"] = false,
},
["EnhanceSound_EnableSoundWhenGameIsInBG"] = {
["default"] = 1.0,
},
["EnhanceSound_EnableAllSound"] = {
["default"] = 1.0,
},
["EnhanceSound_EnableSFX"] = {
["default"] = 1.0,
},
["EnhanceparticleDensity"] = {
["default"] = 1.0,
},
["MinimapButtonPosition"] = {
["default"] = FBConstants.DEFAULT_MINIMAP_POSITION,
},
["MinimapButtonRadius"] = {
["default"] = FBConstants.DEFAULT_MINIMAP_RADIUS,
},
["TotalTimeFishing"] = {
["default"] = 1,
},
["FishDebug"] = {
["default"] = false,
},
}
local VolumeSlider =
{
["name"] = "FishingBuddyOption_MaxVolumeSlider",
["format"] = VOLUME.." - %d%%",
["min"] = 0,
["max"] = 100,
["step"] = 5,
["scale"] = 1,
["rightextra"] = 32,
["setting"] = "EnhanceSound_MasterVolume",
};
EasyCastInit = function(option, button)
-- prettify drop down?
local check = FBEasyKeys.menu.label:GetWidth() + FBEasyKeys:GetWidth();
if (FishingBuddy.FitInOptionFrame(check)) then
CastingOptions["EasyCast"].layoutright = "EasyCastKeys";
else
CastingOptions["EasyCastKeys"].alone = 1;
end
end
-- default FishingBuddy option handlers
FishingBuddy.BaseGetSetting = function(setting)
if ( not FishingBuddy_Player or
not FishingBuddy_Player["Settings"] ) then
return;
end
local val = FishingBuddy_Player["Settings"][setting];
if ( val == nil and FishingBuddy.GetDefault ) then
val = FishingBuddy.GetDefault(setting);
end
return val;
end
FishingBuddy.BaseSetSetting = function(setting, value)
if ( FishingBuddy_Player and setting ) then
local val = nil;
if ( FishingBuddy.GetDefault ) then
val = FishingBuddy.GetDefault(setting);
end
if ( val == value ) then
FishingBuddy_Player["Settings"][setting] = nil;
else
FishingBuddy_Player["Settings"][setting] = value;
end
end
end
FishingBuddy.GlobalGetSetting = function(setting)
if ( not FishingBuddy_Info or
not FishingBuddy_Info["Settings"] ) then
return;
end
return FishingBuddy_Info["Settings"][setting];
end
FishingBuddy.GlobalSetSetting = function(setting, value)
if ( FishingBuddy_Info and setting ) then
if (not FishingBuddy_Info["Settings"]) then
FishingBuddy_Info["Settings"] = {};
end
FishingBuddy_Info["Settings"][setting] = value;
end
end
FishingBuddy.FishingHats = FISHINGHATS;
FishingBuddy.ByFishie = nil;
FishingBuddy.SortedFishies = nil;
FishingBuddy.StartedFishing = nil;
local CastingNow = false;
-- Let's wait at least five seconds before we attempt to lure again
local RELURE_DELAY = 8.0;
local AddingLure = false;
local DoEscaped = nil;
local LureState = 0;
local LastLure = nil;
local LastUsed = nil;
local OpenThisFishId = {};
local DoAutoOpenLoot = nil;
-- handle zone markers
local function zmto(zidx, sidx)
if ( not zidx ) then
return 0;
end
if ( not sidx ) then
sidx = 0;
end
return zidx*1000 + sidx;
end
FishingBuddy.ZoneMarkerTo = zmto;
local function zmex(packed)
local sidx = math.fmod(packed, 1000);
return math.floor(packed/1000), sidx;
end
FishingBuddy.ZoneMarkerEx = zmex;
-- event handling
local function IsFakeEvent(evt)
return (evt == "VARIABLES_LOADED") or FBConstants.FBEvents[evt];
end
-- let's delay bag update when we leave the world
local bagupdateframe = CreateFrame("Frame");
bagupdateframe:Hide();
-- we want to do all the magic stuff even when we didn't equip anything
local autopoleframe = CreateFrame("Frame");
autopoleframe:Hide();
-- we want to dismiss the loot window as fast as possible
local lootframe = CreateFrame("Frame");
lootframe:Hide();
local LastCastTime = nil;
local FISHINGSPAN = 60;
local handlerframe = CreateFrame("Frame");
handlerframe:Hide();
local reg_events = {};
local event_handlers = {};
local function AddHandler(evt, func)
if ( not event_handlers[evt] ) then
event_handlers[evt] = {};
end
tinsert(event_handlers[evt], func);
end
local function RemoveHandler(evt, func)
if ( event_handlers[evt] ) then
local jdx;
for idx,f in ipairs(event_handlers[evt]) do
if ( f == func ) then
jdx = idx;
end
end
if ( jdx) then
table.remove(event_handlers[evt], jdx);
end
end
end
local function RegisterHandlers(handlers)
if (not handlers) then
return
end
for evt,info in pairs(handlers) do
local func, fake;
if ( not event_handlers[evt] ) then
event_handlers[evt] = {};
end
fake = IsFakeEvent(evt);
if ( type(info) == "function" ) then
func = info;
else
func = info.func;
fake = fake or info.fake;
end
tinsert(event_handlers[evt], func);
if ( not fake ) then
-- register the event, if we haven't already
if ( not reg_events[evt] ) then
FishingBuddy.RegisterEvent(evt, nil, handlerframe);
end
reg_events[evt] = 1;
end
end
end
-- these should be internal use only, FBAPI has "constant" interfaces
FishingBuddy.RegisterHandlers = RegisterHandlers;
FishingBuddy.GetHandlers = function(what) return event_handlers[what]; end;
local function RunHandlers(what, ...)
local eh = event_handlers[what];
if ( eh ) then
for idx,func in pairs(eh) do
func(...);
end
end
end
FishingBuddy.RunHandlers = RunHandlers;
-- we want to make sure we handle our registered events for everyone
handlerframe:SetScript("OnEvent", function(self, event, ...)
RunHandlers(event, ...);
RunHandlers("*", ...);
end)
-- look at tooltips
local function LastTooltipText()
return FL:GetLastTooltipText();
end
FishingBuddy.LastTooltipText = LastTooltipText;
local function ClearTooltipText()
FL:ClearLastTooltipText();
end
FishingBuddy.ClearTooltipText = ClearTooltipText;
-- translate zones and subzones
-- need to handle the fact that French uses "Stormwind" instead of "Stormwind City"
local function GetBaseZoneIndex(idx)
return FL:GetBaseZone(FishingBuddy_Info["ZoneIndex"][idx]);
end
FishingBuddy.GetBaseZoneIndex = GetBaseZoneIndex;
local function GetLocZoneIndex(idx)
return FL:GetLocZone(FishingBuddy_Info["ZoneIndex"][idx]);
end
FishingBuddy.GetLocZoneIndex = GetLocZoneIndex;
-- build a list of zones where a given fish can be found
local function FishZoneList(fishid)
if ( FishingBuddy.ByFishie[fishid] ) then
local slist = {};
for idx,count in pairs(FishingBuddy.ByFishie[fishid]) do
local zidx, sidx = zmex(idx);
if ( sidx > 0 ) then
slist[idx] = 1;
end
end
local names = {};
for idx,_ in pairs(slist) do
tinsert(names, FishingBuddy_Info["SubZones"][idx]);
end
table.sort(names);
return FishingBuddy.EnglishList(names);
end
-- return nil;
end
-- handle option keys for enabling casting
local key_actions = {
[FBConstants.KEYS_NONE] = function(mouse) return mouse ~= "RightButtonUp"; end,
[FBConstants.KEYS_SHIFT] = function(mouse) return IsShiftKeyDown(); end,
[FBConstants.KEYS_CTRL] = function(mouse) return IsControlKeyDown(); end,
[FBConstants.KEYS_ALT] = function(mouse) return IsAltKeyDown(); end,
}
local function CastingKeys()
local setting = FishingBuddy.GetSetting("EasyCastKeys");
local mouse = FishingBuddy.GetSetting("MouseEvent");
if ( setting and key_actions[setting] ) then
return key_actions[setting](mouse);
else
return true;
end
end
-- handle the vagaries of zones and subzones
local zonemapping;
local subzonemapping;
local function DumpMappings(both)
FishingBuddy.Debug("Zone mapping");
FishingBuddy.Dump(zonemapping);
if ( both ) then
FishingBuddy.Debug("SubZone mapping");
FishingBuddy.Dump(subzonemapping);
end
end
FishingBuddy.DumpMappings = DumpMappings;
local function ResetMappings()
zonemapping = nil;
subzonemapping = nil;
end
FishingBuddy.ResetMappings = ResetMappings;
local function initmappings()
if ( not zonemapping ) then
zonemapping = {};
subzonemapping = {};
for zidx,z in pairs(FishingBuddy_Info["ZoneIndex"]) do
zonemapping[z] = zidx;
local zidm = zmto(zidx,0);
local count = FishingBuddy_Info["SubZones"][zidm];
if ( count and count > 0 ) then
subzonemapping[zidx] = {};
for s=1,count,1 do
zidm = zmto(zidx, s);
local sz = FishingBuddy_Info["SubZones"][zidm];
subzonemapping[zidx][sz] = s;
end
end
end
end
end
local function GetZoneIndex(zone, subzone, marker)
initmappings();
if ( not zone ) then
zone, subzone = FL:GetZoneInfo();
end
zone = FL:GetBaseZone(zone);
local zidx = zonemapping[zone];
if ( not zidx ) then
return;
end
if ( not subzonemapping[zidx] ) then
subzonemapping[zidx] = {};
end
subzone = FL:GetBaseSubZone(subzone);
if ( not subzone or not subzonemapping[zidx][subzone] ) then
if ( marker ) then
return zmto(zidx, 0);
else
return zidx;
end
end
if ( marker ) then
return zmto(zidx, subzonemapping[zidx][subzone]);
else
return zidx, subzonemapping[zidx][subzone];
end
end
FishingBuddy.GetZoneIndex = GetZoneIndex;
local function AddZoneIndex(zone, subzone, marker)
if ( not zone ) then
zone, subzone = FL:GetZoneInfo();
end
if ( type(zone) ~= "string" ) then
FishingBuddy.Debug("AddZoneIndex "..zone);
end
zone = FL:GetBaseZone(zone);
subzone = FL:GetBaseSubZone(subzone);
local loczone = FL:GetLocZone(zone);
local zidx, sidx = GetZoneIndex(zone, subzone);
if ( not zidx ) then
tinsert(FishingBuddy_Info["ZoneIndex"], zone);
zidx = table.getn(FishingBuddy_Info["ZoneIndex"]);
zonemapping[zone] = zidx;
-- keep sort helpers up to date
if ( FishingBuddy.SortedZones ) then
tinsert(FishingBuddy.SortedZones, loczone);
table.sort(FishingBuddy.SortedZones);
end
end
local zidm = zmto(zidx, 0);
if ( not subzone ) then
if ( marker ) then
return zidm;
else
return zidx;
end
end
local locsubzone = FL:GetLocSubZone(subzone);
if ( not subzonemapping[zidx] ) then
subzonemapping[zidx] = {};
end
local newsubzone = false;
if ( not subzonemapping[zidx][subzone] ) then
newsubzone = true;
sidx = FishingBuddy_Info["SubZones"][zidm];
if ( not sidx ) then
sidx = 1;
else
sidx = sidx + 1;
end
FishingBuddy_Info["SubZones"][zidm] = sidx;
local sidm = zmto(zidx, sidx);
FishingBuddy_Info["SubZones"][sidm] = subzone;
subzonemapping[zidx][subzone] = sidx;
end
-- keep sort helpers up to date
if ( newsubzone and FishingBuddy.SortedByZone ) then
if ( not FishingBuddy.SortedByZone[loczone] ) then
FishingBuddy.SortedByZone[loczone] = {};
end
tinsert(FishingBuddy.SortedByZone[loczone], locsubzone);
table.sort(FishingBuddy.SortedByZone[loczone]);
if ( not FishingBuddy.UniqueSubZones[locsubzone] ) then
FishingBuddy.UniqueSubZones[locsubzone] = 1;
tinsert(FishingBuddy.SortedSubZones, locsubzone);
table.sort(FishingBuddy.SortedSubZones);
end
if ( not FishingBuddy.SubZoneMap[subzone] ) then
FishingBuddy.SubZoneMap[subzone] = {};
end
local sidm = zmto(zidx, sidx);
FishingBuddy.SubZoneMap[subzone][sidm] = 1;
end
if ( marker ) then
return zmto(zidx, subzonemapping[zidx][subzone]);
else
return zidx, subzonemapping[zidx][subzone];
end
end
FishingBuddy.AddZoneIndex = AddZoneIndex;
-- we should collect these, but then they would be in the cache
local QuestItems = {};
QuestItems[6717] = {
["enUS"] = "Gaffer Jack",
["deDE"] = "Klemm-Muffen",
["esES"] = "Mecanismo el�ctrico",
["frFR"] = "Rouage �lectrique",
};
QuestItems[6718] = {
["enUS"] = "Electropeller",
["deDE"] = "Elektropeller",
["esES"] = "Electromuelle",
["frFR"] = "Electropeller",
};
QuestItems[16970] = {
["enUS"] = "Misty Reed Mahi Mahi",
["deDE"] = "Nebelschilf-Mahi-Mahi",
["frFR"] = "Mahi Mahi de Brumejonc",
};
QuestItems[16968] = {
["enUS"] = "Sar'theris Striker",
["deDE"] = "Sar'theris-Barsch",
["frFR"] = "Frappeur Sar'theris",
};
QuestItems[16969] = {
["enUS"] = "Savage Coast Blue Sailfin",
["deDE"] = "Blauwimpel von der ungez�hmten K�ste",
["frFR"] = "Sailfin bleu de la C�te sauvage",
};
QuestItems[16967] = {
["enUS"] = "Feralas Ahi",
["frFR"] = "Ahi de Feralas",
};
QuestItems[34865] = {
["enUS"] = "Blackfin Darter",
};
QuestItems[45328] = {
["enUS"] = "Bloated Slippery Eel",
open = true,
};
QuestItems[35313] = {
["enUS"] = "Bloated Barbed Gill Trout",
open = true,
};
QuestItems[58856] = {
["enUS"] = "Royal Monkfish",
open = true,
};
QuestItems[69914] = {
["enUS"] = "Giant Catfish",
open = true,
};
QuestItems[69956] = {
["enUS"] = "Blind Cavefish",
open = true,
};
FishingBuddy.QuestItems = QuestItems;
-- Nat Pagle fish
local PagleFish = {};
PagleFish[86545] = {
["enUS"] = "Mimic Octopus",
quest = 31446,
};
PagleFish[86544] = {
["enUS"] = "Spinefish Alpha",
quest = 31444,
};
PagleFish[86542] = {
["enUS"] = "Flying Tiger Gourami",
quest = 31443,
};
-- Lunkers
PagleFish[116817] = {
["enUS"] = "Blackwater Whiptail Lunker",
lunker = true,
};
PagleFish[116818] = {
["enUS"] = "Abyssal Gulper Lunker",
lunker = true,
};
PagleFish[116819] = {
["enUS"] = "Fire Ammonite Lunker",
lunker = true,
};
PagleFish[116820] = {
["enUS"] = "Blind Lake Lunker",
lunker = true,
};
PagleFish[116821] = {
["enUS"] = "Fat Sleeper Lunker",
lunker = true,
};
PagleFish[116822] = {
["enUS"] = "Jawless Skulker Lunker",
lunker = true,
};
PagleFish[127994] = {
["enUS"] = "Felmouth Frenzy Lunker",
lunker = true,
};
PagleFish[116158] = {
["enUS"] = "Lunarfall Carp",
};
PagleFish[112633] = {
["enUS"] = "Frostdeep Minnow",
};
PagleFish[122696] = {
["enUS"] = "Sea Scorpion Minnow",
};
PagleFish[110508] = {
["enUS"] = "Sea Scorpion Minnow",
};
PagleFish[138777] = {
["enUS"] = "Drowned Mana",
zone = "Dalaran (Broken Isles)",
silent = 1,
limit = 100
};
PagleFish[146959] = {
["enUS"] = "Corrupted Globule",
zone = "Val'sharah",
silent = 1,
limit = 100
};
PagleFish[146960] = {
["enUS"] = "Ancient Totem Fragment",
zone = "Thunder Totem",
silent = 1,
limit = 100
};
PagleFish[146961] = {
["enUS"] = "Shiny Bauble",
zone = "Stormheim",
silent = 1,
limit = 100
};
PagleFish[146962] = {
["enUS"] = "Golden Minnow",
zone = "Suramar",
silent = 1,
limit = 100
};
PagleFish[146963] = {
["enUS"] = "Desecrated Seaweed",
zone = "Broken Shore",
silent = 1,
limit = 100
};
PagleFish[146848] = {
["enUS"] = "Fragmented Enchantment",
zone = "Azsuna",
silent = 1,
limit = 100
};
PagleFish[141975] = {
["enUS"] = "Mark of Aquaos",
getcolor = function ()
local mana = GetItemCount(138777);
if (mana < 70) then
return Crayon.COLOR_HEX_GREEN;
elseif (mana > 79) then
return Crayon.COLOR_HEX_RED;
else
return Crayon.COLOR_HEX_YELLOW;
end
end
};
FishingBuddy.PagleFish = PagleFish;
local QuestLures = {};
QuestLures[58788] = {
["enUS"] = "Overgrown Earthworm", -- Diggin' for Worms
spell = 80534,
};
QuestLures[58949] = {
["enUS"] = "Stag Eye", -- A Staggering Effort
spell = 80868,
};
QuestLures[45902] = {
["enUS"] = "Phantom Ghostfish",
spell = 45902,
};
QuestLures[69907] = {
["enUS"] = "Corpse Worm",
spell = 99315,
};
local function SetFishingLevel(skillcheck, zone, subzone, fishid)
if ( not zone ) then
zone, subzone = FL:GetZoneInfo();
end
local idx = AddZoneIndex(zone, subzone, true);
local fs = FishingBuddy_Info["FishingSkill"];
if ( not fs[idx] ) then
fs[idx] = 0;
end
local skill, mods, _ = FL:GetCurrentSkill();
if ( not skillcheck ) then
skillcheck = skill + mods;
end
if ( skillcheck > 0 ) then
if ( not fs[idx] or skillcheck < fs[idx] ) then
fs[idx] = skillcheck;
end
if ( fishid ) then
if ( not FishingBuddy_Info["Fishies"][fishid].level or
skillcheck < FishingBuddy_Info["Fishies"][fishid].level ) then
FishingBuddy_Info["Fishies"][fishid].level = skillcheck;
FishingBuddy_Info["Fishies"][fishid].skill = skill;
FishingBuddy_Info["Fishies"][fishid].mods = mods;
end
end
end
return skill + mods;
end
local questType = _G.GetItemClassInfo(LE_ITEM_CLASS_QUESTITEM);
local CurLoc = GetLocale();
local function AddFishie(color, id, name, zone, subzone, texture, quantity, quality, level, it, st, poolhint)
local GSB = FishingBuddy.GetSettingBool;
if ( id and not FishingBuddy_Info["Fishies"][id] ) then
if ( not color ) then
local _,_,_,hex = GetItemQualityColor(quality);
_,_,color = string.find(hex, "|c(%a+)");
end
FishingBuddy_Info["Fishies"][id] = { };
FishingBuddy_Info["Fishies"][id][CurLoc] = name;
FishingBuddy_Info["Fishies"][id].texture = texture;
FishingBuddy_Info["Fishies"][id].quality = quality;
if ( color ~= "ffffffff" ) then
FishingBuddy_Info["Fishies"][id].color = color;
end
if ( FishingBuddy.SortedFishies ) then
tinsert(FishingBuddy.SortedFishies, { text = name, id = id });
FishingBuddy.FishSort(FishingBuddy.SortedFishies, true);
end
end
if ( name and not FishingBuddy_Info["Fishies"][id][CurLoc] ) then
FishingBuddy_Info["Fishies"][id][CurLoc] = name;
end
-- Only quest items have matching itemType and subType values, as well
if ( (it and it == questType) or QuestItems[id] ) then
-- subtype is Quest as well
if ( FishingBuddy_Info["Fishies"][id].canopen == nil ) then
FishingBuddy_Info["Fishies"][id].quest = true;
local canopen, locked;
if ( QuestItems[id] and QuestItems[id].open ) then
canopen = QuestItems[id].open;
else
canopen, locked = FL:IsOpenable(id);
end
-- if it's locked, let's not deal with it (not that I can think of any
-- quest items that are locked and openable...)
if ( not locked ) then
FishingBuddy_Info["Fishies"][id].canopen = canopen;
end
end
if ( FishingBuddy_Info["Fishies"][id].canopen ) then
table.insert(OpenThisFishId, id);
end
end
-- Play a sound on Nat Pagle rep
if ( PagleFish[id] and not PagleFish[id].silent and GSB("DingQuestFish") ) then
PlaySound(SOUNDKIT.IG_QUEST_LIST_COMPLETE, "master");
end
if ( not zone ) then
zone = UNKNOWN;
end
if ( not subzone ) then
subzone = zone;
end
local zidx, sidx = AddZoneIndex(zone, subzone);
local idx = zmto(zidx, sidx);
local ft = FishingBuddy_Info["FishTotals"];
local totidx = zmto(zidx, 0);
if( not ft[totidx] ) then
ft[totidx] = quantity;
else
ft[totidx] = ft[totidx] + quantity;
end
if( not ft[idx] ) then
ft[idx] = quantity;
else
ft[idx] = ft[idx] + quantity;
end
local fh = FishingBuddy_Info["FishingHoles"];
if ( not fh[idx] ) then
fh[idx] = {};
end
if ( not fh[idx][id] ) then
fh[idx][id] = quantity;
if ( GSB("ShowNewFishies") ) then
FishingBuddy.Print(FBConstants.ADDFISHINFOMSG, name or UNKNOWN, subzone or zone);
end
else
fh[idx][id] = fh[idx][id] + quantity;
end
if ( FishingBuddy.ByFishie ) then
if ( not FishingBuddy.ByFishie[id] ) then
FishingBuddy.ByFishie[id] = {};
end
if ( not FishingBuddy.ByFishie[id][idx] ) then
FishingBuddy.ByFishie[id][idx] = quantity;
else
FishingBuddy.ByFishie[id][idx] = FishingBuddy.ByFishie[id][idx] + quantity;
end
end
if ( level ) then
if ( not FishingBuddy_Info["Fishies"][id].level or
level < FishingBuddy_Info["Fishies"][id].level ) then
FishingBuddy_Info["Fishies"][id].level = level;
else
level = FishingBuddy_Info["Fishies"][id].level;
end
end
RunHandlers(FBConstants.ADD_FISHIE_EVT, id, name, zone, subzone, texture, quantity, quality, level, idx, poolhint);
end
FishingBuddy.AddFishie = AddFishie;
-- User interface handling
local function IsRareFish(id, forced)
-- always skip extravaganza fish
if ( FishingBuddy.Extravaganza.Fish[id] ) then
return true;
end
return ( not forced and QuestItems[id] );
end
local function IsQuestFish(id)
if ( FishingBuddy_Info["Fishies"][id].quest or QuestItems[id] ) then
return true;
end
-- return nil;
end
FishingBuddy.IsQuestFish = IsQuestFish;
FishingBuddy.IsCountedFish = function(id)
id = tonumber(id);
if ( IsQuestFish(id) or IsRareFish(id) or FL:IsMissedFish(id) ) then
return false;
end
if ( id == 40199 ) then
return false; -- Pygmy Suckerfish
end
return true;
end
-- Get an array of all the lures we have in our inventory, sorted by
-- cost, then bonus
-- We'll want to use the cheapest ones we can until our fish don't get
-- away from us
-- Full combat check function
local function CheckCombat()
return InCombatLockdown() or UnitAffectingCombat("player") or UnitAffectingCombat("pet")
end
FishingBuddy.CheckCombat = CheckCombat;
local function PostCastUpdate()
local stop = true;
if ( not CheckCombat() ) then
FL:ResetOverride();
if ( AddingLure ) then
local sp, sub, txt, tex, st, et, trade, int = UnitChannelInfo("player");
local _, lure = FL:GetPoleBonus();
if ( not sp or not LastLure or (lure and lure == LastLure.b) ) then
AddingLure = false;
FL:UpdateLureInventory();
else
stop = false;
end
end
if ( stop ) then
FishingBuddy_PostCastUpdateFrame:Hide();
end
end
end
FishingBuddy.PostCastUpdate = PostCastUpdate;
local function HideAwayAll(self, button, down)
FishingBuddy_PostCastUpdateFrame:Show();
end
local function HaveThing(itemid, info)
if (info.toy) then
return PlayerHasToy(itemid)
else
return GetItemCount(itemid) > 0;
end
end
local function GetFishingItem(itemtable)
local GSB = FishingBuddy.GetSettingBool;
for itemid, info in pairs(itemtable) do
if ( info.always or (HaveThing(itemid, info) and (not info.setting or GSB(info.setting))) ) then
if (not info[CurLoc]) then
info[CurLoc] = GetItemInfo(itemid);
end
if ( not info.usable or info.usable(info) ) then
local buff = GetSpellInfo(info.spell);
local doit = not FL:HasBuff(buff);
local it = nil;
if ( info.check ) then
doit, itemid, it = info.check(info, buff, doit, itemid);
elseif (info.toy) then
_, itemid = C_ToyBox.GetToyInfo(itemid);
end
if ( doit ) then
return doit, itemid, info[CurLoc], it or info.type;
end
end
end
end
-- return nil;
end
local function GetFishieRaw(fishid)
local fi = FishingBuddy_Info["Fishies"][fishid];
if ( not fi or not fi[CurLoc] ) then
local _,_,_,_,it,_,_,_,_,_ = FL:GetItemInfo(fishid);
local color, id, name = FL:SplitFishLink(fishid);
if (not fi) then
return fishid, it, color, 1, nil, name, nil;
else
fi.texture = it;
fi.color = color;
fi.quantity = 1;
fi[CurLoc] = name;
end
end
return fishid,
fi.texture,
fi.color,
fi.quantity,
fi.quality,
fi[CurLoc],
fi.quest;
end
FishingBuddy.GetFishieRaw = GetFishieRaw;
local function OnNatPagleQuest()
local i = 1;
while GetQuestLogTitle(i) do
local questTitle, level, questTag, suggestedGroup, isHeader, isCollapsed, isComplete, isDaily, questID = GetQuestLogTitle(i)
if ( questID == 36611) then
return true;
end
i = i + 1;
end
-- return nil;
end
local function GetUpdateLure()
local GSB = FishingBuddy.GetSettingBool;
local usedrinks = GSB("FishingFluff") and GSB("DrinkHeavily");
local lureinventory, useinventory = FL:GetLureInventory();
DoAutoOpenLoot = nil;
-- drink first, then apply a lure if we need to
if ( usedrinks ) then
-- Drink, drink, drink
if ( #useinventory > 0 ) then
if ( not LastUsed or not FL:HasBuff(LastUsed.n) ) then
local id = useinventory[1].id;
if ( not FL:HasBuff(useinventory[1].n) ) then
LastUsed = useinventory[1];
return true, LastUsed.id, LastUsed.n;
end
end
end
end
local doit, id, name, it = FishingBuddy.GetPlan()
if ( doit ) then
return doit, id, name, it;
end
-- look for bonus items, like the Ancient Pandaren Fishing Charm
if ( FishingBuddy.FishingItems ) then
doit, id, name, it = GetFishingItem(FishingBuddy.FishingItems);
if ( doit ) then
return doit, id, name, it;
end
end
if ( GSB("EasyLures") ) then
-- Is this a quest fish we should open up?
if ( GSB("AutoOpen") ) then
while ( table.getn(OpenThisFishId) > 0 ) do
local id = OpenThisFishId[1];
local c = GetItemCount(id);
if (c < 2) then
table.remove(OpenThisFishId, 1);
end
if ( c > 0 ) then
DoAutoOpenLoot = true;
local _,_,_,_,_,name,_ = GetFishieRaw(id);
return true, id, name;
end
end
-- look for quest lures
doit, id, name, it = GetFishingItem(QuestLures);
if ( doit ) then
return doit, id, name, it;
end
end
-- only apply a lure if we're actually fishing with a "real" pole
if (FL:IsFishingPole()) then
-- Let's wait a bit so that the enchant can show up before we lure again
if ( LastLure and LastLure.time and ((LastLure.time - GetTime()) > 0) ) then
return false;
end
if ( LastLure ) then
LastLure.time = nil;
end
local skill, _, _, _ = FL:GetCurrentSkill();
if (skill > 0) then
local NextLure, NextState;
local pole, tempenchant = FL:GetPoleBonus();
local continent = GetCurrentMapContinent()
local bigdraenor = (GSB("BigDraenor") and (continent == 7 or continent == 8));
local state, bestlure = FL:FindBestLure(tempenchant, LureState, false, bigdraenor);
if ( DoEscaped ) then
if ( state or bestlure ) then
NextState = state or LureState;
NextLure = bestlure;
else
NextLure = nil;
end
elseif ( GSB("AlwaysLure") or bigdraenor) then
-- don't put on a lure if we've already got one
if ( tempenchant == 0 ) then
if ( not state ) then
NextState, NextLure = FL:FindNextLure(nil, 0);
else
NextState = state;
NextLure = bestlure;
end
elseif (state and bestlure) then
NextState = state;
NextLure = bestlure;
else
NextLure = nil -- oscarucb
end
elseif ( state and bestlure and tempenchant == 0 and GSB("LastResort") ) then
NextState = state;
NextLure = bestlure;
else
NextLure = nil;
end
local DoLure = NextLure;
if ( DoLure and DoLure.id ) then
-- if the pole has an enchantment, we can assume it's got a lure on it (so far, anyway)
-- remove the main hand enchantment (since it's a fishing pole, we know what it is)
local startTime, duration, enable = GetItemCooldown(DoLure.id);
if (startTime == 0) then
AddingLure = true;
LastLure = DoLure;
LureState = NextState;
LastLure.time = GetTime() + RELURE_DELAY;
local id = DoLure.id;
local name = DoLure.n;
return true, id, name;
elseif ( LastLure and not LastLure.time ) then
LastLure = nil;
LastState = 0;
AddingLure = false;
end
end
end
end
end
return false;
end
local CaptureEvents = {};
local trackedtime = 0;
local TRACKING_DELAY = 0.75;
CaptureEvents["TRACKED_ACHIEVEMENT_UPDATE"] = function(id, criterion, actualtime, timelimit)
if ( id == 5036 ) then
-- Last catch was in a pool
-- We should add it
-- Do we know it was our catch?
trackedtime = GetTime();
end
end
local function ClearAddingLure()
AddingLure = false;
end
CaptureEvents["UNIT_SPELLCAST_STOP"] = ClearAddingLure;
CaptureEvents["UNIT_SPELLCAST_INTERRUPTED"] = ClearAddingLure;
CaptureEvents["UNIT_SPELLCAST_FAILED"] = ClearAddingLure;
CaptureEvents["UNIT_SPELLCAST_FAILED_QUIET"] = ClearAddingLure;
StatusEvents = {};
StatusEvents["ACTIONBAR_SLOT_CHANGED"] = function()
if ( FishingBuddy.GetSettingBool("UseAction") ) then
FL:GetFishingActionBarID(true);
end
end
StatusEvents["UNIT_AURA"] = function(arg1)
if ( arg1 == "player" ) then
local hmhe,_,_,_,_,_ = GetWeaponEnchantInfo();
if ( not hmhe ) then
LastLure = nil;
end
end
end
local function ReadyForFishing()
local GSB = FishingBuddy.GetSettingBool;
local id = FL:GetMainHandItem(true);
-- if we're holding the spear, assume we're fishing
return (GSB("UseTuskarrSpear") and (id == 88535)) or FL:IsFishingReady(GSB("PartialGear"));
end
FishingBuddy.ReadyForFishing = ReadyForFishing;
local function NormalHijackCheck()
local GSB = FishingBuddy.GetSettingBool;
if ( not AddingLure and
not CheckCombat() and (not IsMounted() or GSB("MountedCast")) and
not IsFishingAceEnabled() and
GSB("EasyCast") and (CastingKeys() or ReadyForFishing()) ) then
return true;
end
end
FishingBuddy.NormalHijackCheck = NormalHijackCheck;
local HijackCheck = NormalHijackCheck;
local function SetHijackCheck(func)
if ( not func ) then
func = NormalHijackCheck;
end
HijackCheck = func;
end
FishingBuddy.SetHijackCheck = SetHijackCheck;
local function NormalStealClick()
-- return nil;
end
local StealClick = NormalStealClick;
local function SetStealClick(func)
if ( not func ) then
func = NormalStealClick;
end
StealClick = func;
end
FishingBuddy.SetStealClick = SetStealClick;
local function CentralCasting()
-- put on a lure if we need to
if ( not StealClick() ) then
local update, id, n, target = GetUpdateLure();
if (update and id) then
FL:InvokeLuring(id, target);
else
if ( not FL:GetLastTooltipText() or not FL:OnFishingBobber() ) then
-- watch for fishing holes
FL:SaveTooltipText();
end
LastCastTime = GetTime();
autopoleframe:Show();
FL:InvokeFishing(FishingBuddy.GetSettingBool("UseAction"));
end
end
FL:OverrideClick(HideAwayAll);
end
local SavedWFOnMouseDown;
-- handle mouse up and mouse down in the WorldFrame so that we can steal
-- the hardware events to implement 'Easy Cast'
-- Thanks to the Cosmos team for figuring this one out -- I didn't realize
-- that the mouse handler in the WorldFrame got everything first!
local function WF_OnMouseDown(...)
-- Only steal 'right clicks' (self is arg #1!)
local button = select(2, ...);
if ( HijackCheck() ) then
FishingBuddy.ExecutePlans()
if ( FL:CheckForDoubleClick(button) ) then
-- We're stealing the mouse-up event, make sure we exit MouseLook
if ( IsMouselooking() ) then
MouselookStop();
end
CentralCasting();
end
if ( SavedWFOnMouseDown ) then
SavedWFOnMouseDown(...);
end
end
end
local function SafeHookMethod(object, method, newmethod)
local oldValue = object[method];
if ( oldValue ~= _G[newmethod] ) then
object[method] = newmethod;
return true;
end
return false;
end
local function SafeHookScript(frame, handlername, newscript)
local oldValue = frame:GetScript(handlername);
frame:SetScript(handlername, newscript);
return oldValue;
end
local skip = {};
skip["mods"] = 1;
skip["texture"] = 1;
skip["quest"] = 1;
skip["level"] = 1;
skip["skill"] = 1;
skip["quality"] = 1;
skip["color"] = 1;
FishingBuddy.GetFishie = function(fishid)
local fi = FishingBuddy_Info["Fishies"][fishid];
if( fi ) then
local name = fi[CurLoc];
if ( not name ) then
-- try a hyperlink
local link = "item:"..fishid;
local n,l,_,_,_,_,_,_ = FL:GetItemInfo(link);
if ( n and l ) then
name = n;
fi[CurLoc] = n;
else
-- try for anything we might be able to display
for k,val in pairs(fi) do
if ( not skip[k] and not name ) then
name = val;
end
end
end
end
if ( not name ) then
name = UNKNOWN;
end
return string.format("%d:0:0:0:0:0:0:0", fishid),
fi.texture,
fi.color,
fi.quantity,
fi.quality,
name,
fi.quest;
end
end
-- do everything we think is necessary when we start fishing
-- even if we didn't do the switch to a fishing pole
local resetClickToMove = nil;
local function StartFishingMode()
if ( not FishingBuddy.StartedFishing ) then
-- Disable Click-to-Move if we're fishing
if ( GetCVar("autointeract") == "1" ) then
resetClickToMove = true;
SetCVar("autointeract", "0");
end
FishingBuddy.EnhanceFishingSounds(true);
handlerframe:Show();
LureState = 0; -- start with the cheapest lure
local pole, lure = FL:GetPoleBonus();
if ( not lure or lure == 0 ) then
LastLure = {};
LastLure.b = lure;
end
FishingBuddy.StartedFishing = GetTime();
RunHandlers(FBConstants.FISHING_ENABLED_EVT);
end
-- we get invoked when items get equipped as well
FL:UpdateLureInventory();
end
local function StopFishingMode(logout)
if ( FishingBuddy.StartedFishing ) then
if ( not logout ) then
FishingBuddy.WatchUpdate();
end
autopoleframe:Hide();
handlerframe:Hide();
local started = FishingBuddy.StartedFishing;
FishingBuddy.StartedFishing = nil;
RunHandlers(FBConstants.FISHING_DISABLED_EVT, started, logout);
end
-- reset everything that we might have set
FishingBuddy.EnhanceFishingSounds(false, logout);
if ( resetClickToMove ) then
-- Re-enable Click-to-Move if we changed it
SetCVar("autointeract", "1");
resetClickToMove = nil;
end
AddingLure = false;
end
local function FishingMode()
local ready = ReadyForFishing();
if ( ready ) then
StartFishingMode();
else
StopFishingMode();
end
end
FishingBuddy.FishingMode = FishingMode;
local function AutoPoleCheck(self, ...)
if (not CheckCombat() ) then
if ( not LastCastTime or ReadyForFishing() ) then
self:Hide();
LastCastTime = nil;
return;
end
local elapsed = (GetTime() - LastCastTime);
if ( elapsed > FISHINGSPAN ) then
LastCastTime = nil;
StopFishingMode();
elseif ( not FishingBuddy.StartedFishing ) then
StartFishingMode();
end
end
end
autopoleframe:SetScript("OnUpdate", AutoPoleCheck);
FishingBuddy.AreWeFishing = function()
return (FishingBuddy.StartedFishing ~= nil);
end
FishingBuddy.IsSwitchClick = function(setting)
if ( not setting ) then
setting = "ClickToSwitch";
end
local a = IsShiftKeyDown();
local b = FishingBuddy.GetSettingBool(setting);
return ( (a and (not b)) or ((not a) and b) );
end
local function TrapWorldMouse()
if ( WorldFrame.OnMouseDown ) then
hooksecurefunc(WorldFrame, "OnMouseDown", WF_OnMouseDown)
else
SavedWFOnMouseDown = SafeHookScript(WorldFrame, "OnMouseDown", WF_OnMouseDown);
end
end
FishingBuddy.TrapWorldMouse = TrapWorldMouse;
FishingBuddy.Commands[FBConstants.UPDATEDB] = {};
FishingBuddy.Commands[FBConstants.UPDATEDB].help = FBConstants.UPDATEDB_HELP;
FishingBuddy.Commands[FBConstants.UPDATEDB].func =
function(what)
local ff = FishingBuddy_Info["Fishies"];
local forced;
if ( what and what == FBConstants.FORCE ) then
forced = true;
end
FishingBuddyTooltip:SetOwner(FishingBuddyFrame, "ANCHOR_RIGHT");
FishingBuddyTooltip:Show();
local count = 0;
for id,info in pairs(ff) do
local item = id..":0:0:0";
if ( forced or not FL:IsLinkableItem(item) or not info.name ) then
if ( not IsRareFish(id, forced) ) then
local link = "item:"..item;
-- fetch the data (may disconnect)
FishingBuddyTooltip:SetHyperlink(link);
-- now that we have it in our cache, get the name
local nm,li,ra,ml,it,st,sc,el,tx,il = FL:GetItemInfo(link);
if ( nm ) then
count = count + 1;
FishingBuddy_Info["Fishies"][id][CurLoc] = nm;
FishingBuddy_Info["Fishies"][id].quest = (it == st);
end
end
end
end
FishingBuddy.Print(FBConstants.UPDATEDB_MSG, count);
return true;
end;
local resetfishdata = false;
FishingBuddy.Commands[FBConstants.FISHDATA] = {};
FishingBuddy.Commands[FBConstants.FISHDATA].help = FBConstants.FISHDATARESETHELP;
FishingBuddy.Commands[FBConstants.FISHDATA].func =
function()
if (resetfishdata) then
FishingBuddy_Info["FishTotals"] = {};
FishingBuddy_Info["FishingHoles"] = {};
FishingBuddy_Info["FishingSkill"] = {};
RunHandlers(FBConstants.RESET_FISHDATA_EVT);
FishingBuddy.Print(FBConstants.FISHDATARESET_MSG);
resetfishdata = false;
else
FishingBuddy.Print(FBConstants.FISHDATARESETMORE_MSG);
resetfishdata = true;
end
return true;
end;
-- Move a macro from global to perchar, or vice versa
local function GetMacroIndex(macroname)
for idx = 1, _G.MAX_ACCOUNT_MACROS + _G.MAX_CHARACTER_MACROS do
local name, icon, body = GetMacroInfo(idx)
if (name and macroname == name) then
return idx;
end
end
end
local function CreateOrUpdateMacro(name, icon, body, perchar)
local exists = GetMacroIndex(name);
if (exists) then
local isglobal = (exists <= _G.MAX_ACCOUNT_MACROS);
if ((perchar and isglobal) or (not perchar and not isglobal)) then
-- switch per char and global
DeleteMacro(name);
exists = nil;
end
end
if (exists) then
EditMacro(name, nil, icon, body, 1, perchar);
else
CreateMacro(name, icon, body, perchar);
end
end
local function CreateFishingMacro()
local GSB = FishingBuddy.GetSettingBool;
local _, fishing = FL:GetFishingSkillInfo();
local update, id, name = GetUpdateLure();
local bag, slot;
if (update) then
bag, slot = FL:FindThisItem(id);
end
local action = "";
if (slot) then
action = "/stopcasting\n/use "
if (bag) then
action = action..bag
end
action = action.." "..slot.."\n";
else
action = "/cast ";
if (GSB("PreventRecast")) then
action = action.." [nochanneling:"..fishing.."] ";
else
action = "/stopcasting\n"..action;
end
action = action..fishing
end
local numglobal,numperchar = GetNumMacros();
local perchar = nil;
local fullup;
if (GSB("ToonMacro")) then
if (numperchar >= _G.MAX_CHARACTER_MACROS) then
fullup = FBConstants.NOCREATEMACROPER;
end
perchar = 1;
else
if (numglobal >= _G.MAX_ACCOUNT_MACROS) then
fullup = FBConstants.NOCREATEMACROGLOB;
end
end
if (fullup) then
FishingBuddy.Message(fullup.."\""..FBConstants.MACRONAME.."\"", 1, 0, 0);
return;
end
CreateOrUpdateMacro(FBConstants.MACRONAME, "INV_Fishingpole_02", "#showtooltip Fishing\n/fb fishing start\n"..action, perchar);
end
FishingBuddy.Commands[FBConstants.FISHINGMODE] = {};
FishingBuddy.Commands[FBConstants.FISHINGMODE].help = FBConstants.FISHINGMODE_HELP;
FishingBuddy.Commands[FBConstants.FISHINGMODE].func =
function(what)
if(what and what == "stop") then
StopFishingMode();
else
StartFishingMode();
end
if (FishingBuddy.GetSettingBool("CreateMacro")) then
-- CreateFishingMacro();
end
return true;
end;
local function OptionsUpdate(changed, closing)
FL:WatchBobber(FishingBuddy.GetSettingBool("WatchBobber"));
FL:SetSAMouseEvent(FishingBuddy.GetSetting("MouseEvent"));
if (false) then
if (FishingBuddy.GetSettingBool("CreateMacro")) then
CreateFishingMacro();
else
DeleteMacro(FBConstants.MACRONAME);
end
end
RunHandlers(FBConstants.OPT_UPDATE_EVT, changed, closing);
end
FishingBuddy.OptionsUpdate = OptionsUpdate;
local function nextarg(msg, pattern)
if ( not msg or not pattern ) then
return nil, nil;
end
local s,e = string.find(msg, pattern);
if ( s ) then
local word = strsub(msg, s, e);
msg = strsub(msg, e+1);
return word, msg;
end
return nil, msg;
end
FishingBuddy.Command = function(msg)
if ( not msg ) then
return;
end
if ( FishingBuddy.IsLoaded() ) then
-- collect arguments (whee, lua string manipulation)
local cmd;
cmd, msg = nextarg(msg, "[%w]+");
-- the empty string gives us no args at all
if ( not cmd ) then
-- toggle window
if ( FishingBuddyFrame:IsVisible() ) then
HideUIPanel(FishingBuddyFrame);
else
ShowUIPanel(FishingBuddyFrame);
end
elseif ( cmd == FBConstants.HELP or cmd == "help" ) then
FishingBuddy.Output(FBConstants.WINDOW_TITLE);
if ( not FBConstants.HELPMSG ) then
FBConstants.HELPMSG = { "@PRE_HELP" };
for cmd,info in pairs(FishingBuddy.Commands) do
if ( info.help ) then
tinsert(FBConstants.HELPMSG, info.help);
end
end
tinsert(FBConstants.HELPMSG, "@POST_HELP");
FL:FixupEntry(FBConstants, "HELPMSG")
end
FishingBuddy.PrintHelp(FBConstants.HELPMSG);
else
local command = FishingBuddy.Commands[cmd];
if ( command ) then
local args = {};
local goodargs = true;
if ( command.args ) then
for _,pat in pairs(command.args) do
local w, msg = nextarg(msg, pat);
if ( not w ) then
goodargs = false;
break;
end
tinsert(args, w);
end
else
local a;
while ( msg ) do
a, msg = nextarg(msg, "[%w]+");
if ( not a ) then
break;
end
tinsert(args, a);
end
end
if ( not goodargs or not command.func(unpack(args)) ) then
if ( command.help ) then
FishingBuddy.PrintHelp(command.help);
else
FishingBuddy.Debug("command failed");
end
end
else
FishingBuddy.Command("help");
end
end
else
FishingBuddy.Error(FBConstants.FAILEDINIT);
end
end
FishingBuddy.TooltipBody = function(hintcheck)
local text = FBConstants.DESCRIPTION1.."\n"..FBConstants.DESCRIPTION2;
if ( hintcheck ) then
local hint = FBConstants.TOOLTIP_HINT.." ";
if (FishingBuddy.GetSettingBool(hintcheck)) then
hint = hint..FBConstants.TOOLTIP_HINTSWITCH;
else
hint = hint..FBConstants.TOOLTIP_HINTTOGGLE;
end
text = text.."\n"..Crayon:Green(hint);
end
return text;
end
local efsv = nil;
FishingBuddy.EnhanceFishingSounds = function(doit, logout)
local GSB = FishingBuddy.GetSettingBool;
local GSO = FishingBuddy.GetSettingOption;
if ( GSB("EnhanceFishingSounds") ) then
if ( not efsv and doit ) then
-- collect the current values
local mv = GetCVar("Sound_MasterVolume");
local mu = GetCVar("Sound_MusicVolume");
local av = GetCVar("Sound_AmbienceVolume");
local sv = GetCVar("Sound_SFXVolume");
local sb = GetCVar("Sound_EnableSoundWhenGameIsInBG");
local pd = GetCVar("particleDensity");
local eas = GetCVar("Sound_EnableAllSound");
local esfx = GetCVar("Sound_EnableSFX");
efsv = {};
if (GSB("TurnOnSound")) then
efsv["Sound_EnableAllSound"] = eas;
efsv["Sound_EnableSFX"] = esfx;
end
efsv["Sound_MasterVolume"] = mv;
efsv["Sound_MusicVolume"] = mu;
efsv["Sound_AmbienceVolume"] = av;
efsv["Sound_SFXVolume"] = sv;
efsv["Sound_EnableSoundWhenGameIsInBG"] = sb;
if (GSB("EnhancePools")) then
efsv["particleDensity"] = pd;
end
-- if we need to, turn 'em off!
for setting in pairs(efsv) do
local optionname = "Enhance"..setting;
local value = FishingBuddy.GetSetting(optionname);
value = tonumber(value);
local info = GSO(optionname);
if (info and info.scale) then
value = value / 100.0;
end
SetCVar(setting, value);
end
return; -- fall through and reset everything otherwise
end
end
if ( logout ) then
FishingBuddy_Player["ResetEnhance"] = efsv;
end
if ( efsv ) then
for setting, value in pairs(efsv) do
SetCVar(setting, tonumber(value));
end
efsv = nil;
end
end
local IsZoning;
local ZoneEvents;
local function TrackZoneEvents(evt)
if ( IsZoning ) then
if ( not ZoneEvents ) then
ZoneEvents = {};
end
if ( ZoneEvents[evt] ) then
ZoneEvents[evt] = ZoneEvents[evt] + 1;
else
ZoneEvents[evt] = 1;
end
end
end
local function DumpZoneEvents()
FishingBuddy.Dump(ZoneEvents);
ZoneEvents = nil;
end
local lootcache = {}
local lootcheck = false;
local lootcount = 0;
local function ProcessFishLoot()
local zone, subzone = FL:GetZoneInfo();
while (table.getn(lootcache) > 0) do
local info = table.remove(lootcache)
local texture, fishie, quantity, quality, link = info.texture, info.fishie, info.quantity, info.quality, info.link;
local nm,_,_,_,it,st,_,el,_,il = FL:GetItemInfo(link);
local color, id, name = FL:SplitFishLink(link);
-- handle things we can't actually count that might be in our fish (e.g. Garrison Resources)
if (id) then
-- Fishing pool check? poolhint and (index == 1)
AddFishie(color, id, name, zone, subzone, texture, quantity, quality, nil, it, st, false);
SetFishingLevel(nil, zone, subzone, id);
end
lootcount = lootcount + 1;
lootcheck = true;
end
lootframe:Hide();
lootcache = {};
end
lootframe:SetScript("OnUpdate", ProcessFishLoot);
FishingBuddy.OnEvent = function(self, event, ...)
-- local line = event;
-- for idx=1,select("#",...) do
-- line = line.." '"..select(idx,...).."'";
-- end
-- FishingBuddy.Debug(line);
local arg1 = ...;
-- TrackZoneEvents(event);
if ( event == "PLAYER_EQUIPMENT_CHANGED" or
event == "WEAR_EQUIPMENT_SET" or
event == "EQUIPMENT_SWAP_FINISHED") then
FishingMode();
elseif (event == "BAG_UPDATE" ) then
if (lootcheck) then
if (lootcount > 0) then
lootcount = lootcount - 1;
end
if (lootcount == 0) then
lootcheck = false;
FishingBuddy.WatchUpdate();
end
end
FishingMode();
elseif ( event == "LOOT_OPENED" ) then
local doautoloot = ShouldAutoLoot() and (GetCVar("autoLootDefault") ~= "1" );
if ( IsFishingLoot() ) then
local poolhint = nil;
-- How long ago did the achievement fire?
local elapsedtime = GetTime() - trackedtime;
if ( elapsedtime < TRACKING_DELAY ) then
poolhint = true;
end
-- if we want to autoloot, and Blizz isn't, let's grab stuff
local checkloot = LootSlotIsItem or LootSlotHasItem;
for index = 1, GetNumLootItems(), 1 do
local texture, fishie, quantity, quality, locked = GetLootSlotInfo(index);
if (checkloot(index)) then
local link = GetLootSlotLink(index);
-- should we track "locked" items we couldn't loot?'
tinsert(lootcache, {texture = texture, fishie = fishie, quantity = quantity, quality = quality, link = link});
local _, id, _ = FL:SplitFishLink(link);
-- handle things we can't actually count that might be in our fish (e.g. Garrison Resources)
if (id and quality == 0 and FL:IsMissedFish(id)) then
DoEscaped = 1;
end
end
if (not locked and doautoloot) then
LootSlot(index);
end
end
lootframe:Show();
ClearTooltipText();
FL:ExtendDoubleClick();
LureState = 0;
elseif (DoAutoOpenLoot) then
DoAutoOpenLoot = nil;
for index = 1, GetNumLootItems(), 1 do
if (doautoloot) then
LootSlot(index);
end
end
end
elseif ( event == "LOOT_CLOSED" ) then
-- nothing to do here at the moment
DoAutoOpenLoot = nil;
elseif ( event == "PLAYER_LOGIN" ) then
FL:CreateSAButton();
FL:SetSAMouseEvent(FishingBuddy.GetSetting("MouseEvent"));
RunHandlers(FBConstants.LOGIN_EVT);
elseif ( event == "PLAYER_LOGOUT" ) then
-- reset the fishing sounds, if we need to
StopFishingMode(true);
FishingBuddy.SavePlayerInfo();
RunHandlers(FBConstants.LOGOUT_EVT);
elseif ( event == "VARIABLES_LOADED" ) then
local _, name = FL:GetFishingSkillInfo();
FishingBuddy.Initialize();
FishingBuddy.Slider_Create(VolumeSlider);
FishingBuddy.OptionsFrame.HandleOptions(GENERAL, nil, GeneralOptions);
FishingBuddy.AddSchoolFish();
FishingBuddy.CreateFBMappedDropDown("FBEasyKeys", "EasyCastKeys", FBConstants.CONFIG_EASYCAST_ONOFF, FBConstants.Keys)
FishingBuddy.CreateFBMappedDropDown("FBMouseEvent", "MouseEvent", FBConstants.CONFIG_MOUSEEVENT_ONOFF, FBConstants.CastClick)
FishingBuddy.OptionsFrame.HandleOptions(name, "Interface\\Icons\\INV_Fishingpole_02", CastingOptions);
FishingBuddy.OptionsFrame.HandleOptions(nil, nil, InvisibleOptions);
FishingBuddy.OptionsUpdate();
-- make sure we have the Macro globals
-- if (not IsAddOnLoaded("Blizzard_MacroUI")) then
-- LoadAddOn("Blizzard_MacroUI");
-- end
self:UnregisterEvent("VARIABLES_LOADED");
-- tell all the listeners about this one
RunHandlers(event, ...);
elseif ( event == "PLAYER_ENTERING_WORLD" ) then
IsZoning = nil;
-- DumpZoneEvents();
-- we could watch for UNIT_INVENTORY_CHANGED, if we wanted to check for "player" in the args
self:RegisterEvent("PLAYER_EQUIPMENT_CHANGED");
self:RegisterEvent("EQUIPMENT_SWAP_FINISHED");
self:RegisterEvent("WEAR_EQUIPMENT_SET");
-- BAG_UPDATE
bagupdateframe:Show();
if (FishingBuddy.StartedFishing and not handlerframe:IsShown()) then
handlerframe:Show();
end
if (FishingBuddy_Player and FishingBuddy_Player["ResetEnhance"]) then
efsv = FishingBuddy_Player["ResetEnhance"];
FishingBuddy.EnhanceFishingSounds(false, false);
FishingBuddy_Player["ResetEnhance"] = nil;
end
elseif ( event == "PLAYER_ALIVE" ) then
FishingMode();
if (FishingBuddy.GetSettingBool("CreateMacro")) then
-- CreateFishingMacro();
end
self:UnregisterEvent("PLAYER_ALIVE");
elseif ( event == "PLAYER_LEAVING_WORLD") then
RunHandlers(FBConstants.LEAVING_EVT);
IsZoning = 1;
-- Don't reenable BAG_UPDATE until we're back
bagupdateframe:Hide();
self:UnregisterEvent("BAG_UPDATE");
self:UnregisterEvent("PLAYER_EQUIPMENT_CHANGED");
self:UnregisterEvent("EQUIPMENT_SWAP_FINISHED");
self:UnregisterEvent("WEAR_EQUIPMENT_SET");
if (handlerframe:IsShown()) then
handlerframe:Hide();
end
end
FishingBuddy.Extravaganza.IsTime(true);
end
FishingBuddy.OnLoad = function(self)
self:RegisterEvent("PLAYER_ENTERING_WORLD");
self:RegisterEvent("PLAYER_LEAVING_WORLD");
self:RegisterEvent("PLAYER_ALIVE");
self:RegisterEvent("PLAYER_LOGIN");
self:RegisterEvent("PLAYER_LOGOUT");
self:RegisterEvent("VARIABLES_LOADED");
-- we want to deal with fishing loot windows all the time
self:RegisterEvent("LOOT_OPENED");
self:RegisterEvent("LOOT_CLOSED");
-- Handle item lock separately to reduce churn during world load
-- self:RegisterEvent("ITEM_LOCK_CHANGED");
-- self:RegisterEvent("PLAYER_EQUIPMENT_CHANGED");
-- self:RegisterEvent("WEAR_EQUIPMENT_SET");
self:SetScript("OnEvent", FishingBuddy.OnEvent);
bagupdateframe.fbframe = self;
bagupdateframe:SetScript("OnUpdate", function(self, ...)
if (self.fbframe) then
self.fbframe:RegisterEvent("BAG_UPDATE");
self:Hide();
end
end);
RegisterHandlers(CaptureEvents);
RegisterHandlers(StatusEvents);
-- Set up command
SlashCmdList["fishingbuddy"] = FishingBuddy.Command;
SLASH_fishingbuddy1 = "/fishingbuddy";
SLASH_fishingbuddy2 = "/fb";
FishingBuddy.Output(FBConstants.WINDOW_TITLE.." loaded");
end
-- allow other parts of the code to watch for events when not fishing
local isunit = "UNIT_";
FishingBuddy.RegisterEvent = function(event, handler, frame)
frame = frame or FishingBuddyRoot;
if (string.sub(event, 1, string.len(isunit)) == isunit) then
frame:RegisterUnitEvent(event, "player");
else
frame:RegisterEvent(event);
end
if (handler) then
AddHandler(event, handler);
end
end
FishingBuddy.UnregisterEvent = function(event, handler)
FishingBuddyRoot:UnregisterEvent(event);
RemoveHandler(event, handler);
if ( event_handlers[event] and table.getn(event_handlers[event]) == 0 ) then
event_handlers[event] = nil;
FishingBuddyRoot:UnregisterEvent(event);
if (reg_events[event]) then
reg_events[event] = nil;
handlerframe:UnregisterEvent(event);
end
end
end
FishingBuddy.PrintHelp = function(tab)
if ( tab ) then
if ( type(tab) == "table" ) then
for _,line in pairs(tab) do
FishingBuddy.PrintHelp(line);
end
else
-- check for a reference to another help item
local _,_,w = string.find(tab, "^@([A-Z0-9_]+)$");
if ( w and FBConstants[w] ) then
FishingBuddy.PrintHelp(FBConstants[w]);
else
FishingBuddy.Output(tab);
end
end
end
end
FishingBuddy.FishSort = function(tab, forcename)
if ( forcename or not FishingBuddy.GetSettingBool("SortByPercent") ) then
table.sort(tab, function(a,b) return (a.index and b.index and a.index 1 ) then
fishie = string.sub(fishie, 1, s-1)..string.sub(fishie, e+1);
else
fishie = string.sub(fishie, e+1);
end
else
s,e = string.find(fishie, " "..raw);
if ( s ) then
fishie = string.sub(fishie, 1, s-1)..string.sub(fishie, e+1);
end
end
return fishie;
end
-- this means an import failed somewhere
return UNKNOWN;
end
FishingBuddy.ToggleDropDownMenu = function(level, value, menu, anchor, xOffset, yOffset)
ToggleDropDownMenu(level, value, menu, anchor, xOffset, yOffset);
if (not level) then
level = 1;
end
local anchorName;
if ( type(anchor) == "string" ) then
anchorName = anchor;
else
anchorName = anchor:GetName();
end
local frame = _G["DropDownList"..level];
local uiScale = UIParent:GetScale()
if ( frame:GetRight() > ( GetScreenWidth()*uiScale ) ) then
if ( anchorName == "cursor" ) then
if ( not xOffset ) then
xOffset = 0;
end
if ( not yOffset ) then
yOffset = 0;
end
local cursorX, cursorY = GetCursorPosition();
xOffset = -cursorX + xOffset;
yOffset = cursorY + yOffset;
else
if ( not xOffset or not yOffset ) then
xOffset = 8;
yOffset = 22;
end
end
frame:ClearAllPoints();
frame:SetPoint("TOPRIGHT", anchorName, "BOTTOMLEFT", -xOffset, yOffset);
end
if ( frame:GetBottom() < 0 ) then
frame:ClearAllPoints();
frame:SetPoint("BOTTOMRIGHT", anchorName, "BOTTOMLEFT", -xOffset, yOffset);
end
end
FishingBuddy.EnglishList = function(list, conjunction)
if ( list ) then
local n = table.getn(list);
local str = "";
for idx=1,n do
local name = list[idx];
if ( idx == 1 ) then
str = name;
elseif ( idx == n ) then
str = str .. ", ";
if ( conjunction ) then
str = str .. conjunction;
else
str = str .. "and";
end
str = str .. " " .. name;
else
str = str .. ", " .. name;
end
end
return str;
end
end
FishingBuddy.UIError = function(msg)
-- Okay, this check is probably not necessary...
if ( UIErrorsFrame ) then
UIErrorsFrame:AddMessage(msg, 1.0, 0.1, 0.1, 1.0, UIERRORS_HOLD_TIME);
else
FishingBuddy.Error(msg);
end
end
FishingBuddy.Testing = function(line)
if ( not FishingBuddy_Info["Testing"] ) then
FishingBuddy_Info["Testing"] = {};
end
tinsert(FishingBuddy_Info["Testing"], line);
end
if ( FishingBuddy.Debugging ) then
FishingBuddy.Commands["poles"] = {};
FishingBuddy.Commands["poles"].func =
function()
local _,_,_,_,fp_itemtype,fp_subtype,_,_,_,_ = FL:GetItemInfo(6256);
FishingBuddy.Debug("'"..fp_itemtype.."' '"..fp_subtype.."'");
for name,item in pairs(POLES) do
local link = "item:"..item;
if ( not FL:IsLinkableItem(item) ) then
FishingBuddy.Debug(link);
-- fetch the data (may disconnect)
FishingBuddyTooltip:SetHyperlink(link);
end
-- now that we have it in our cache, get the name
local nm,li,ra,ml,it,st,sc,el,tx,il = FL:GetItemInfo(link);
if ( nm ) then
FishingBuddy.Debug(" '"..it.."' '"..st.."'");
end
end
return true;
end
FishingBuddy.Commands["makeopen"] = {};
FishingBuddy.Commands["makeopen"].func =
function(id)
id = id or 7973;
QuestItems[id] = { open = true, };
FishingBuddy_Info["Fishies"][id].canopen = nil;
local name, _, _, _, _, _, _, _,_, _ = GetItemInfo(id) ;
FishingBuddy.Debug("Make "..name.." openable ("..GetItemCount(id)..")");
table.insert(OpenThisFishId, id);
return true;
end
FishingBuddy.Commands["showopen"] = {};
FishingBuddy.Commands["showopen"].func =
function()
-- FishingBuddy_Info["Fishies"][id].canopen
for id,info in pairs(FishingBuddy_Info["Fishies"]) do
if (FishingBuddy_Info["Fishies"][id].canopen) then
FishingBuddy.Debug("Id: %d Name: %s", id, info[CurLoc]);
end
end
return true;
end
FishingBuddy.Commands["nowopen"] = {};
FishingBuddy.Commands["nowopen"].func =
function()
-- 58856
for idx,info in pairs(OpenThisFishId) do
FishingBuddy.Debug(idx, info);
end
FishingBuddy.OpenThisFishId = OpenThisFishId;
return true;
end
FishingBuddy.Commands["macrotest"] = {};
FishingBuddy.Commands["macrotest"].func =
function()
CreateFishingMacro();
return true;
end
FishingBuddy.Commands["marksea"] = {};
FishingBuddy.Commands["marksea"].func =
function()
local fish = FishingBuddy_Info["Fishies"][111672];
local zone, subzone = FL:GetZoneInfo();
local nm,_,_,_,it,st,_,el,_,il = FL:GetItemInfo(111672);
local color, id, name = FL:SplitFishLink(il);
AddFishie(color, 111672, name, zone, subzone, fish["texture"], 1, fish["quality"], nil, it, st);
return true;
end
end
PK T}/Lz6 6 FishingBuddy/FishingBuddy.toc## Interface: 70300
## Title: Fishing Buddy
## Version: 1.8 Beta 7
## Notes: Help with fishing related tasks -- clothing, fish information, etc.
## Notes-deDE: Erleichtert das Angeln - Ausrüstung und Fish-Infos
## Notes-frFR: Vous facilite la vie de pecheur. Informations sur les poissons, changement d'habits, etc.
## Notes-esES: Ayude con las tareas relacionadas pesca -- ropa, información de los pescados
## Author: Sutorix=AT=hotmail.com
## OptionalDeps: FB_Debugging, Outfitter, myAddOns, Titan, InfoBar, FishWarden
## SavedVariables: FishingBuddy_Info
## SavedVariablesPerCharacter: FishingBuddy_Player
## X-Date: July 21, 2005
## X-Help: FBConstants.HELPMSG
Libs\Libs.xml
localization.lua
localization.de.lua
localization.es.lua
localization.fr.lua
localization.itIT.lua
localization.koKR.lua
localization.ptBR.lua
localization.ruRU.lua
localization.zhTW.lua
localization.zhCN.lua
FishingSetup.lua
FishingBuddy.xml
FishingBuddyAPI.lua
FishingBuddyFrame.xml
FishingOptionsFrame.lua
FishingScrollMenu.xml
FishingLocationsFrame.xml
FishingOutfitManager.lua
FishingOutfitter.xml
FishingGearManager.lua
FishingBuddyMinimap.lua
FishingQuests.lua
FishingExtravaganza.xml
FishingWatcher.xml
FishingSchools.lua
FishingAbout.lua
FishingPlans.lua
FishingPlans\Plans.xml
FishingFluff.xml
PK NKB~9 FishingBuddy/FishingBuddy.xml
FishingBuddy.OnLoad(self);
FishingBuddy.PostCastUpdate();
self:SetOwner(WorldFrame, "ANCHOR_NONE");
PK NK] 0 0 FishingBuddy/FishingBuddyAPI.lua--[[
Name: FishingBuddyApi-1.0
Maintainers: Sutorix
Description: A library for the Fishing Buddy functions usable by plugins and other code.
Copyright (c) by Bob Schumaker
Licensed under a Creative Commons "Attribution Non-Commercial Share Alike" License
--]]
local MAJOR_VERSION = "FishingBuddyApi-1.0"
local MINOR_VERSION = 90000 + tonumber(("$Rev: 676 $"):match("%d+"))
if not LibStub then error(MAJOR_VERSION .. " requires LibStub") end
local FBAPI, oldLib = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
if not FBAPI then
return
end
local FL = LibStub("LibFishing-1.0");
-- 5.0.4 has a problem with a global "_"
local _
-- Event handler support
function FBAPI:RegisterHandlers(handlers)
FishingBuddy.RegisterHandlers(handlers);
end
function FBAPI:GetHandlers(what)
return FishingBuddy.GetHandlers(what);
end
-- Settings support
function FBAPI:GetSettingBool(setting)
return FishingBuddy.GetSettingBool(setting);
end
function FBAPI:GetSetting(setting)
return FishingBuddy.GetSetting(setting);
end
function FBAPI:GetDefault(setting)
return FishingBuddy.GetDefault(setting);
end
-- Identify Fishing Buddy
function FBAPI:GetKey()
local key = FishingBuddy_Info["FishingBuddyKey"];
if ( not key ) then
-- This was removed in 3.1, lets just assume we have enough randomness already
-- math.randomseed(time());
-- generate a random key to identify this instance of the plugin
local n = 16 + random(4) + random(4);
key = "";
for idx=1,n do
key = key .. string.char(64+math.random(26));
end
FishingBuddy_Info["FishingBuddyKey"] = key;
end
return key;
end
function FBAPI:CheckForeignKey(foreignKey, foreignDate, saveKey)
if ( not FishingBuddy_Info["ForeignKeys"] ) then
FishingBuddy_Info["ForeignKeys"] = {};
end
if ( saveKey ) then
FishingBuddy_Info["ForeignKeys"][foreignKey] = foreignDate;
return;
end
if ( not FishingBuddy_Info["ForeignKeys"][foreignKey] ) then
FishingBuddy_Info["ForeignKeys"][foreignKey] = foreignDate;
return true;
end
return ( FishingBuddy_Info["ForeignKeys"][foreignKey] < foreignDate );
end
function FBAPI:ResetKey()
FishingBuddy_Info["FishingBuddyKey"] = nil;
local key = GetKey();
if (FB_MergeDatabase) then
FB_MergeDatabase.key = key;
end
FishingBuddy.Message("Key reset.");
return key;
end
-- Miscellaneous functions
function FBAPI:IsSwitchClick(setting)
if ( not setting ) then
setting = "ClickToSwitch";
end
local a = IsShiftKeyDown();
local b = FishingBuddy.GetSettingBool(setting);
return ( (a and (not b)) or ((not a) and b) );
end
function FBAPI:IsQuestFish(id)
return FishingBuddy.IsQuestFish(id);
end
function FBAPI:IsCountedFish(id)
return FishingBuddy.IsCountedFish(id);
end
function FBAPI:ReadyForFishing()
return FishingBuddy.ReadyForFishing();
end
function FBAPI:AreWeFishing()
return FishingBuddy.AreWeFishing();
end
PK nm/LN7/
/
" FishingBuddy/FishingBuddyFrame.lua
local LFH = LibStub("LibTabbedFrame-1.0");
local LO = LibStub("LibOptionsFrame-1.0");
local LS = LibStub("LibSideTabFrame-1.0");
local FBFRAMES = {
[1] = {
["frame"] = "FishingLocationsFrame",
["name"] = FBConstants.LOCATIONS_TAB,
["tooltip"] = FBConstants.LOCATIONS_INFO,
["toggle"] = "_LOC",
["first"] = 1,
},
[2] = {
["frame"] = "FishingOptionsFrame",
["name"] = FBConstants.OPTIONS_TAB,
["tooltip"] = FBConstants.OPTIONS_INFO,
["toggle"] = "_OPT",
["ultimate"] = 1,
}
};
local ManagedFrames = {};
local function DisableSubFrame(target)
FishingBuddyFrame:DisableSubFrame(target);
end
FishingBuddy.DisableSubFrame = DisableSubFrame;
local function EnableSubFrame(target)
FishingBuddyFrame:EnableSubFrame(target);
end
FishingBuddy.EnableSubFrame = EnableSubFrame;
local function ManageFrame(target, tabname, tooltip, toggle)
FishingBuddyFrame:ManageFrame(target, tabname, tooltip, toggle);
end
FishingBuddy.ManageFrame = ManageFrame;
local function Group_OnClick(tabframe, tabname)
for idx,group in ipairs(tabframe.target.groups) do
if group.name == tabname then
group.frame:Show()
else
group.frame:Hide()
end
end
end
local function CreateManagedFrameGroup(tabname, tooltip, toggle, groups, optiontab)
local target = FishingBuddyFrame:CreateManagedFrame("Managed"..tabname, tabname, tooltip, toggle);
LS:Embed(target)
target:SetScript("OnShow", function (self) self:HandleOnShow(self:GetSelected()); end);
target:SetScript("OnHide", function (self) self:HideTabs(); end);
target.groups = groups
for idx,group in ipairs(groups) do
local tabframe = target:CreateTab(group.name, group.icon, Group_OnClick, group.tooltip or group.name);
group.frame:SetParent(target)
group.frame:Hide()
end
if ( optiontab ) then
local frame = CreateFrame("Frame", "Options"..tabname, target)
FishingBuddy.EmbeddedOptions(frame)
frame:SetScript("OnShow", function (self)
self:ShowButtons();
end)
tinsert(groups, {
["name"] = optiontab.name,
["icon"] = optiontab.icon,
["frame"] = frame
})
frame.options = optiontab
frame.ontabclick = Group_OnClick
target.handoff = frame
FishingBuddy.OptionsFrame.HandleOptions(optiontab.name, optiontab.icon, optiontab.options, optiontab.setter, optiontab.getter, optiontab.last, target)
end
target:ResetTabFrames();
target:SelectTab(target:GetSelected());
end
FishingBuddy.CreateManagedFrameGroup = CreateManagedFrameGroup;
function ToggleFishingBuddyFrame(target)
FishingBuddyFrame:ToggleTab(target);
end
local function OnVariablesLoaded(self, event, ...)
-- set up mappings
for idx,info in pairs(FBFRAMES) do
local tf = FishingBuddyFrame:MakeFrameTab(info.frame, info.name, info.tooltip, info.toggle);
if ( info.first) then
FishingBuddyFrame:MakePrimary(info.frame);
elseif ( info.ultimate ) then
FishingBuddyFrame:MakeUltimate(info.frame);
end
end
FishingBuddyFrame:ShowSubFrame("FishingLocationsFrame");
end
local function OnShow()
FishingBuddy.RunHandlers(FBConstants.FRAME_SHOW_EVT);
end
FishingBuddyFrame = LFH:CreateFrameHandler("FishingBuddyFrame",
"Interface\\LootFrame\\FishingLoot-Icon", FBConstants.WINDOW_TITLE, "FISHINGBUDDY",
OnShow, nil, OnVariablesLoaded);
FishingBuddyFrame:Show();
FishingBuddyFrame:Hide();
PK &L1: : " FishingBuddy/FishingBuddyFrame.xml
PK NK:= $ FishingBuddy/FishingBuddyMinimap.lua-- Minimap Button Handling
FishingBuddy.Minimap = {};
local FL = LibStub("LibFishing-1.0");
local icon = LibStub("LibDBIcon-1.0");
local broker = LibStub:GetLibrary("LibDataBroker-1.1")
local GSB = FishingBuddy.GetSettingBool;
local function Minimap_OnClick(self, button, down)
if ( button == "RightButton" ) then
ToggleFishingBuddyFrame("FishingOptionsFrame");
elseif ( FishingBuddy.IsSwitchClick("MinimapClickToSwitch") ) then
FishingBuddy.Command(FBConstants.SWITCH);
else
ToggleFishingBuddyFrame("FishingLocationsFrame");
end
end
local MinimapOptions = {
["MinimapButtonVisible"] = {
["text"] = FBConstants.CONFIG_MINIMAPBUTTON_ONOFF,
["tooltip"] = FBConstants.CONFIG_MINIMAPBUTTON_INFO,
["v"] = 1,
["default"] = false,
},
["MinimapClickToSwitch"] = {
["text"] = FBConstants.CLICKTOSWITCH_ONOFF,
["tooltip"] = FBConstants.CLICKTOSWITCH_INFO,
["v"] = 1,
["default"] = false,
["parents"] = { ["MinimapButtonVisible"] = "d", },
},
};
local function setter(setting, value)
if (setting == "MinimapButtonVisible") then
FishingBuddy_Player["MinimapData"].hide = (not value);
else
FishingBuddy.BaseSetSetting(setting, value);
end
end
local function getter(setting)
if (setting == "MinimapButtonVisible") then
if (not FishingBuddy_Player["MinimapData"].hide) then
return true;
else
return false;
end
else
return FishingBuddy.BaseGetSetting(setting);
end
end
local MinimapEvents = {};
MinimapEvents[FBConstants.OPT_UPDATE_EVT] = function()
if (icon:IsRegistered(FBConstants.NAME)) then
FishingBuddy_Player["MinimapData"].hide = not GSB("MinimapButtonVisible");
icon:Refresh(FBConstants.NAME, FishingBuddy_Player["MinimapData"]);
end
end
MinimapEvents["VARIABLES_LOADED"] = function()
local _, info;
if ( not FishingBuddy_Player["MinimapData"] ) then
FishingBuddy_Player["MinimapData"] = { hide=false };
end
-- Fix Curse bug #246
if ( not FishingBuddy_Player["MinimapData"].minimapPos ) then
FishingBuddy_Player["MinimapData"]["minimapPos"] = 225;
end
if ( not icon:IsRegistered(FBConstants.NAME) ) then
local data = {
icon = "Interface\\Icons\\Trade_Fishing",
OnClick = Minimap_OnClick,
};
icon:Register(FBConstants.NAME, data, FishingBuddy_Player["MinimapData"]);
end
end
FishingBuddy.OptionsFrame.HandleOptions(GENERAL, nil, MinimapOptions, setter, getter);
FishingBuddy.RegisterHandlers(MinimapEvents);
PK NK $ FishingBuddy/FishingBuddyMinimap.xml
self:SetFrameLevel(0);
UIDropDownMenu_SetWidth(self, 180);
PK VKw45 45 $ FishingBuddy/FishingExtravaganza.lua-- Support for the Extravaganza
--
-- Map support liberally borrowed from GuildMap, by Bru on Blackhand
FishingBuddy.Extravaganza = {};
local Crayon = LibStub("LibCrayon-3.0");
local FL = LibStub("LibFishing-1.0");
local LT = LibStub("LibTourist-3.0");
local UPDATETIME_SCHOOLS = 5.0;
local UPDATETIME_COUNTER = 20.0;
local NUMMINIPOIS = 10;
local ICONPATH = "Interface\\AddOns\\FishingBuddy\\Icons\\";
local UpdateTimer = 0;
-- the actual names don't matter, except to help make sure I've got 'em all
local ExtravaganzaFish = {};
ExtravaganzaFish[19807] = "Speckled Tastyfish";
ExtravaganzaFish[19806] = "Dezian Queenfish";
ExtravaganzaFish[19805] = "Keefer's Angelfish";
-- makes you wonder what item 19804 is, doesn't it...
ExtravaganzaFish[19803] = "Brownell's Blue Striped Racer";
FishingBuddy.Extravaganza.Fish = ExtravaganzaFish;
local ContestIsOver;
local CurrentContest;
local Contests = {};
Contests[1] = {
["day"] = 1,
["hour"] = 14,
["dur"] = 2,
["fishid"] = 19807,
["count"] = 40,
["continent"] = "Eastern Kingdoms",
["zones"] = { "Stranglethorn Vale", "The Cape of Stranglethorn", "Northern Stranglethorn" },
["kind"] = FL.SCHOOL_TASTY,
["setting"] = "STVTimer",
["name"] = FBConstants.EXTRAVAGANZA,
["yell"] = FBConstants.RIGGLE_BASSBAIT,
};
-- Contests[2] = {
-- ["day"] = 7,
-- ["hour"] = 14,
-- ["dur"] = 1,
-- ["fishid"] = 50289,
-- ["count"] = 1,
-- ["continent"] = "Northrend",
-- -- ["zone"] -- any zone in Northrend
-- ["kind"] = FL.SCHOOL_FISH, -- normal fish pools
-- ["setting"] = "DerbyTimer",
-- ["name"] = FBConstants.DERBY,
-- ["yell"] = FBConstants.ELDER_CLEARWATER,
-- };
local FBGetSettingBool = FishingBuddy.GetSettingBool;
local function GetSettingBool(setting)
if (FBGetSettingBool("ContestSupport")) then
return FBGetSettingBool(setting);
end
-- return nil;
end
local function ExtravaganzaHijackCheck()
if ( FishingBuddy.NormalHijackCheck() ) then
-- also check to make sure we're over a pool
return FL:IsFishingPool();
end
end
local function IsContestZone()
if ( CurrentContest ) then
local zone,_ = FL:GetZoneInfo();
local landmass = LT:GetContinent(zone);
-- Are we on the right continent?
if ( landmass == CurrentContest.continent ) then
-- if not zone limited, we're there
if ( not CurrentContest.zones ) then
return true;
else
-- otherwise, see if we're in the right zone
for _,conzone in ipairs(CurrentContest.zones) do
if ( conzone == zone) then
return true;
end
end
end
end
end
-- return nil;
end
-- keep track of the pools we want to see
local iconcache = {};
local function GetFreePoolIcon()
local pdx = nil;
for idx=#iconcache,1,-1 do
if (not iconcache[idx].inuse ) then
pdx = idx;
end
end
if ( not pdx ) then
pdx = #iconcache + 1;
local pool = CreateFrame("BUTTON", "FBIcon"..pdx, UIParent);
pool:SetWidth(20);
pool:SetHeight(20);
local tex = pool:CreateTexture("FBIcon"..pdx.."Texture", "ARTWORK");
tex:SetTexture("Interface\\Minimap\\ObjectIcons");
tex:SetTexCoord(0.875, 1.0, 0.25, 0.5);
tex:SetVertexColor(1, 1, 1, 0.3);
tex:SetAllPoints();
pool:SetNormalTexture(tex);
pool.tex = tex;
tinsert(iconcache, pool);
pdx = #iconcache;
end
iconcache[pdx].inuse = true;
return iconcache[pdx];
end
local function CalendarGetDayEvent(monthOffset, monthDay, index)
local event = C_Calendar.GetDayEvent(monthOffset, monthDay, index);
if (event) then
local hour, minute;
if (event.sequenceType == "END") then
hour = event.endTime.hour;
minute = event.endTime.minute;
else
hour = event.startTime.hour;
minute = event.startTime.minute;
end
return event.title, hour, minute, event.calendarType, event.sequenceType, event.eventType, event.texture, event.modStatus, event.inviteStatus, event.invitedBy, event.difficulty, event.inviteType, event.sequenceIndex, event.numSequenceDays, event.difficultyName;
else
return nil, 0, 0, "", "", 0, "", "", 0, "", 0, 0, 0, 0, "";
end
end
-- Salty Badmunkay the Limnologist (@Shadow Council, a MST server with a EST player...guh)
-- Should we display the extravaganza message?
local checkedDay = nil;
local eventHour;
local function IsTime(activate)
local currentMonthOffset = 0;
-- This is *mostly* constant (gaming Saturday night in a marathon session?) but let's
-- set it every time and count on date() being reasonably fast as a C fall-through.
local currentDay = date("%d");
if (checkedDay == currentDay and CurrentContest) then
return true;
end
-- As of patch 5.1, extravaganza starts at 14:00 to 16:00 - PST for US realms, CET for
-- EU realms, and Australian EST for Oceanic realms regardless of server or player local
-- time. Luckily the start time is reflected in the CalendarHolidayEvent entry (so
-- Euro/Aussie/Oceanic players should be OK too). A limitation appears to be if the
-- player has selected to not to show weekly holiday events (but they're probably not
-- using FB anyway [thus lessening our competition!])
-- Can't find an API call to enable Calendar filters for holidays...would make this
-- less user dependent
local fishingEvent = nil;
local startHour = 14; -- default to 14 regardless of player time zone
-- Loop through all CalendarEvents for the currentDay
for idx=1, CalendarGetNumDayEvents(currentMonthOffset, currentDay) do
-- Can't use eventTitle as it is localized, but eventTexture does not appear to be localized.
local eventTexture;
local eventTitle, eh, _, calendarType, _, eventType, eventTexture, _, inviteStatus = CalendarGetDayEvent(currentMonthOffset, currentDay, idx);
eventHour = eh;
if eventTexture == "Calendar_FishingExtravaganza" then
fishingEvent = 1;
startHour = tonumber(eventHour)
elseif eventType == CALENDAR_EVENTTYPE_OTHER and string.find(eventTitle, "FISHING") then
local invited = true;
if (calendarType == "GUILD") then
invited = (inviteStatus == CALENDAR_INVITESTATUS_ACCEPTED or
inviteStatus == CALENDAR_INVITESTATUS_CONFIRMED or
inviteStatus == CALENDAR_INVITESTATUS_SIGNEDUP);
end
if (invited) then
fishingEvent = 1;
startHour = tonumber(eventHour)
end
end
end -- for CalendarGetNumDayEvents loop
checkedDay = currentDay;
-- Let's go fishing!
if fishingEvent then -- no fishingEvent, fall through
-- Loop through all available contests, even though as of patch 5.1 there is only one.
for idx=1,#Contests do
local c = Contests[idx];
-- Player is tracking this contest
if ( GetSettingBool(c.setting) ) then
-- Give player 2 hours lead time to get prepared
local currentHour = GetGameTime();
if ( currentHour >= (startHour - 2) ) and ( currentHour < (startHour + c.dur) ) then
-- Its time to go fishing!
CurrentContest = c;
FishingExtravaganzaFrame:Show();
-- Additional user preference checks
if ( GetSettingBool("STVPoolsOnly") ) then
if ( IsContestZone() ) then
FishingBuddy.SetHijackCheck(ExtravaganzaHijackCheck);
else
FishingBuddy.SetHijackCheck();
end
end -- end user preference checks
-- Signal the caller that we are in Extravaganza time
return true;
end -- startHour checks
end -- contest/day check
end -- for #Contests loop
else
FishingBuddy.SetHijackCheck();
CurrentContest = nil;
end -- fishingEvent check
end -- end IsTime
FishingBuddy.Extravaganza.IsTime = IsTime;
-- Check for mouse down event for dragging frame.
FishingBuddy.Extravaganza.OnDragStart = function(self, button)
if (not self.isMoving and (button == "LeftButton")) then
self:StartMoving();
self.isMoving = true;
end
end
-- Check for drag stop event to stop dragging.
FishingBuddy.Extravaganza.OnDragStop = function(self, button)
if (self.isMoving) then
self:StopMovingOrSizing();
self.isMoving = false;
end
end
local ExtravaganzaEvents = {}
ExtravaganzaEvents[FBConstants.ADD_FISHIE_EVT] = function(id, name, ...)
if ( CurrentContest and CurrentContest.fishid == id ) then
UpdateTimer = 0;
for _,contest in ipairs(Contests) do
local _,_,_,_,_,n = FishingBuddy.GetFishie(contest.fishid);
if ( n ) then
contest.fishname = n;
end
end
end
end
ExtravaganzaEvents[FBConstants.OPT_UPDATE_EVT] = function(changed)
IsTime();
end
ExtravaganzaEvents[FBConstants.FISHING_ENABLED_EVT] = function()
IsTime();
end
-- Handle watching the loot
FishingBuddy.Extravaganza.OnLoad = function(self)
self:RegisterEvent("PLAYER_LOGIN");
self:RegisterEvent("ZONE_CHANGED_NEW_AREA");
self:RegisterEvent("VARIABLES_LOADED");
self:RegisterForDrag("LeftButton");
self:Hide();
FishingBuddy.RegisterHandlers(ExtravaganzaEvents);
end
FishingBuddy.Extravaganza.OnShow = function(self)
-- check each of the bags on the player
UpdateTimer = 0;
FishingBuddy.Extravaganza.OnUpdate(self, 0);
end
FishingBuddy.Extravaganza.OnHide = function(self)
if ( FishingExtravaganzaPOIUpdate and
FishingExtravaganzaPOIUpdate:IsVisible() ) then
FishingExtravaganzaPOIUpdate:Hide();
end
end
-- Elder Clearwater yells: The Kalu'ak Fishing Derby starts in 5 minutes!
-- Elder Clearwater yells: The Kalu'ak Fishing Derby has begun! The first person to bring a blacktip shark to me in Dalaran will be declared the winner! Blacktip sharks can be caught anywhere you can catch a pygmy suckerfish.
-- Elder Clearwater yells: NAME has won the Kalu'ak Fishing Derby!
FishingBuddy.Extravaganza.OnEvent = function(self, event, ...)
if ( event == "CHAT_MSG_YELL" or event == "CHAT_MSG_MONSTER_YELL") then
if ( CurrentContest ) then
-- Riggle Bassbait yells: We have a winner! (.*) is the Master Angler!
local message = select(1, ...);
local name = string.match(message, CurrentContest.yell);
if ( name ) then
ContestIsOver = true;
end
end
elseif ( event == "ZONE_CHANGED_NEW_AREA" or event == "PLAYER_LOGIN" ) then
if ( IsContestZone() and IsTime() ) then
self:RegisterEvent("CHAT_MSG_YELL");
self:RegisterEvent("CHAT_MSG_MONSTER_YELL");
else
self:UnregisterEvent("CHAT_MSG_YELL");
self:UnregisterEvent("CHAT_MSG_MONSTER_YELL");
end
elseif ( event == "VARIABLES_LOADED" ) then
for _,contest in ipairs(Contests) do
local _,_,_,_,_,n = FishingBuddy.GetFishie(contest.fishid);
if ( n ) then
contest.fishname = n;
end
end
IsTime(true);
self:UnregisterEvent("VARIABLES_LOADED");
end
end
FishingBuddy.Extravaganza.OnUpdate = function(self, elapsed)
if ( IsTime() ) then
if ( not self:IsShown() ) then
self:Show();
end
UpdateTimer = UpdateTimer - elapsed;
if ( UpdateTimer <= 0 ) then
local numCaught = GetItemCount(CurrentContest.fishid);
local currentHour,minute = GetGameTime(); -- server time
local minleft;
local cname = CurrentContest.name;
local line;
local contestNow = false;
if ( currentHour >= eventHour ) then -- using global eventHour
if ( ContestIsOver ) then
line = FBConstants.FATLADYSINGS;
else
line = FBConstants.TIMELEFT;
end
line = line..FBConstants.DASH.." |cff";
line = line..Crayon:GetThresholdHexColor(numCaught/40);
line = line..FBConstants.FISHCAUGHT.."|r";
contestNow = true;
else
line = FBConstants.TIMETOGO;
end
minleft = (eventHour - currentHour)*60 - minute; -- using global eventHour
if ( minleft >= 0 ) then
if ( minleft < 10 ) then
FishingExtravaganzaFrameText:SetTextColor(1.0, 0.1, 0.1);
else
FishingExtravaganzaFrameText:SetTextColor(0.1, 1.0, 0.1);
end
local mod = math.fmod;
local fishname = CurrentContest.fishname;
if ( not fishname ) then
fishname = FBConstants.FISH;
end
line = string.format(line, cname, minleft/60, mod(minleft, 60), numCaught, CurrentContest.count, fishname);
FishingExtravaganzaFrameText:SetText(line);
local width = FishingExtravaganzaFrameText:GetWidth();
self:SetWidth(width + 16);
end
-- listen for yells, etc.?
FishingBuddy.Extravaganza.OnEvent(FishingExtravaganzaFrame, "ZONE_CHANGED_NEW_AREA");
if ( IsContestZone() ) then
UpdateTimer = UPDATETIME_SCHOOLS;
else
UpdateTimer = UPDATETIME_COUNTER;
end
end
else
self:Hide();
end
end
-- eventually, display what fish you caught here
FishingBuddy.Extravaganza.MiniMap_OnEnter = function(self)
end
FishingBuddy.Commands[FBConstants.TIMER] = {};
FishingBuddy.Commands[FBConstants.TIMER].help = FBConstants.TIMERRESET_HELP;
FishingBuddy.Commands[FBConstants.TIMER].func =
function(what)
if ( what == FBConstants.RESET ) then
FishingExtravaganzaFrame:ClearAllPoints();
FishingExtravaganzaFrame:SetPoint("CENTER", "UIParent", "CENTER", 0, 0);
IsTime(true);
end
return true;
end;
if ( FishingBuddy.Debugging ) then
FishingBuddy.Commands["contest"] = {};
FishingBuddy.Commands["contest"].func =
function(day, hour, zone, continent)
FishingBuddy.Debug("Contest debug: %q %q %s %s", continent, zone, day, hour);
-- Contests[1].zone = zone;
-- Contests[1].continent = continent;
-- Contests[1].day = day;
-- Contests[1].hour = hour;
-- Contests[1].kind = nil;
-- Contests[2].day = day;
-- Contests[2].hour = hour;
-- Contests[2].kind = nil;
IsTime(true);
return true;
end;
end
PK NKMS S $ FishingBuddy/FishingExtravaganza.xml
self:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b);
self:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b);
FishingBuddy.Extravaganza.OnLoad(self);
FishingBuddy.Extravaganza.OnShow(self);
FishingBuddy.Extravaganza.OnDragStart(self, button);
FishingBuddy.Extravaganza.OnDragStop(self, button);
FishingBuddy.Extravaganza.OnUpdate(self, elapsed);
FishingBuddy.Extravaganza.OnHide(self);
FishingBuddy.Extravaganza.OnEvent(self, event, ...);
PK O{/LsF F FishingBuddy/FishingFluff.lua-- Random fun things to do while fishing
--
-- Turn on the fish finder
-- Change your title to "Salty"
-- Bring out a "fishing buddy"
local FL = LibStub("LibFishing-1.0");
-- 5.0.4 has a problem with a global "_" (see some for loops below)
local _
local CurLoc = GetLocale();
-- wrap settings
local FBGetSetting = FishingBuddy.GetSetting;
local FBGetSettingBool = FishingBuddy.GetSettingBool;
local function GetSettingBool(setting)
if (FBGetSettingBool("FishingFluff")) then
return FBGetSettingBool(setting);
end
-- return nil;
end
local function GetSetting(setting)
if (FBGetSettingBool("FishingFluff")) then
return FBGetSetting(setting);
end
-- return nil;
end
local FluffEvents = {};
local unTrack = nil;
local resetPVP = nil;
local LastSpecialBait = nil;
local SpecialBait =
{
[7] = {
110274, -- Jawless Skulker Bait
110289, -- Fat Sleeper Bait
110290, -- Blind Lake Sturgeon Bait
110291, -- Fire Ammonite Bait
110292, -- Sea Scorpion Bait
110293, -- Abyssal Gulper Eel Bait
110294, -- Blackwater Whiptail Bait
},
[8] = {
139175, -- Arcane lure
}
};
FluffEvents[FBConstants.FISHING_ENABLED_EVT] = function()
LastSpecialBait = nil;
if ( FishingBuddy.GetSettingBool("FishingFluff")) then
if ( GetSettingBool("FindFish") ) then
local findid = FL:GetFindFishID();
if ( findid ) then
local _, _, active, _ = GetTrackingInfo(findid);
if (not active) then
unTrack = true;
SetTracking(findid, true);
end
end
end
if ( GetSettingBool("TurnOffPVP") ) then
if (1 == GetPVPDesired() ) then
resetPVP = true;
SetPVP(0);
end
end
end
end
local function Untrack(yes)
if ( yes ) then
local findid = FL:GetFindFishID();
if ( findid ) then
SetTracking(findid, false);
end
end
end
FluffEvents[FBConstants.FISHING_DISABLED_EVT] = function(started, logout)
if ( resetPVP ) then
SetPVP(1);
end
if ( logout ) then
FishingBuddy_Player["Untrack"] = unTrack;
else
Untrack(unTrack);
end
unTrack = nil;
resetPVP = nil;
LastSpecialBait = nil;
end
FluffEvents[FBConstants.LOGIN_EVT] = function()
if ( FishingBuddy_Player ) then
if ( FishingBuddy_Player["Untrack"] ) then
FishingBuddy_Player["Untrack"] = nil;
Untrack(1);
end
end
end
-- Don't cast the angler's raft if we're doing Scavenger Hunt or on Inkgill Mere
local GSB = FishingBuddy.GetSettingBool;
local function RaftBergUsable(info)
return ( GSB(info.setting) and not IsMounted() and
not FL:HasBuff(GetSpellInfo(201944)) and
not FL:HasBuff(GetSpellInfo(116032)) and
not FL:HasBuff(GetSpellInfo(119700)));
end
local function RaftBergCheck(info, buff, need, itemid)
if (GSB(info.option.setting) and need) then
return false;
end
if (info.time) then
local _, _, _, _, _, _, et, _, _, _, _ = UnitBuff("player", buff);
et = (et or 0) - GetTime();
need = (et <= info.time);
end
if (need) then
if (info.toy) then
_, itemid = C_ToyBox.GetToyInfo(itemid)
end
return true, itemid;
end
--return nil;
end
local QuestBaits = {
{
item = 114628, -- Icespine Stinger Bait
spell = 168448,
},
{
item = 114874, -- Moonshell Claw Bait
spell = 168868,
},
};
local objectiveMapID = { 941, 946, 947, 948, 949, 950 }
local function IsQuestFishing(item)
-- Check for hookshot
if (GetItemCount(116755) > 0) then
-- Better Nat's quest checking by Bodar (Curse)
local questLogIndex = GetQuestLogIndexByID(36611);
if (questLogIndex > 0) then
local currentMapID = GetCurrentMapAreaID();
local numObjectives = GetNumQuestLeaderBoards(questLogIndex);
for i = 1, numObjectives do
local text, objectiveType, finished = GetQuestLogLeaderBoard(i, questLogIndex);
if (not finished and currentMapID == objectiveMapID[i]) then
return true;
end
end
end
end
-- and intro quest baits
for _,bait in ipairs(QuestBaits) do
if (GetItemCount(bait.item) > 0 or FL:HasBuff(GetSpellInfo(bait.spell))) then
return true;
end
end
end
local function AlreadyUsedFishingItem(id, info)
SetupSpecialItem(id, info)
if (info.buff) then
return FL:HasBuff(info.buff)
end
end
local function CanUseFishingItems(setting, items)
if (GSB(setting)) then
local foundone = false;
for id,info in pairs(items) do
foundone = true;
if (AlreadyUsedFishingItem(id, info)) then
return false;
end
end
return foundone;
end
return false;
end
local FishingItems = {};
FishingItems[85973] = {
["enUS"] = "Ancient Pandaren Fishing Charm",
["tooltip"] = FBConstants.CONFIG_FISHINGCHARM_INFO,
spell = 125167,
setting = "UsePandarenCharm",
usable = function(item)
-- only usable in Pandoria
local C,_,_,_ = FL:GetCurrentPlayerPosition();
return (C == 6);
end,
["default"] = true,
};
FishingItems[122742] = {
["enUS"] = "Bladebone Hook", -- 1 hour duration
["spell"] = 182226,
setting = "UseBladeboneHook",
visible = function(option)
return true;
end,
usable = function(item)
-- only usable in Draenor
local C,_,_,_ = FL:GetCurrentPlayerPosition();
return (C == 7);
end,
["default"] = false,
};
FishingItems[116755] = {
["enUS"] = "Nat's Hookshot",
spell = 171740,
usable = IsQuestFishing,
};
-- Dalaran coin lures
local CoinLures = {};
local function CanUseCoinLure()
return CanUseFishingItems("DalaranLures", CoinLures);
end
CoinLures[138956] = {
["enUS"] = "Hypermagnetic Lure",
setting = "DalaranLures",
spell = 217835,
usable = CanUseCoinLure,
ignore = true,
};
CoinLures[138959] = {
["enUS"] = "Micro-Vortex Generator",
setting = "DalaranLures",
spell = 217838,
usable = CanUseCoinLure,
ignore = true,
};
CoinLures[138961] = {
["enUS"] = "Alchemical Bonding Agent",
setting = "DalaranLures",
spell = 217840,
usable = CanUseCoinLure,
ignore = true,
};
CoinLures[138962] = {
["enUS"] = "Starfish on a String",
setting = "DalaranLures",
spell = 217842,
usable = CanUseCoinLure,
ignore = true,
};
CoinLures[138957] = {
["enUS"] = "Auriphagic Sardine",
setting = "DalaranLures",
spell = 217836,
usable = CanUseCoinLure,
ignore = true,
};
CoinLures[138960] = {
["enUS"] = "Wish Crystal",
setting = "DalaranLures",
spell = 217839,
usable = CanUseCoinLure,
ignore = true,
};
CoinLures[138963] = {
["enUS"] = "Tiny Little Grabbing Apparatus",
setting = "DalaranLures",
spell = 217844,
usable = CanUseCoinLure,
ignore = true,
};
CoinLures[138958] = {
["enUS"] = "Glob of Really Sticky Glue",
setting = "DalaranLures",
spell = 217837,
usable = CanUseCoinLure,
ignore = true,
};
local seascorpion = {
["Shadowmoon Valley (Draenor)"] = {
["Darktide Strait"] = true,
["The Evanescent Sea"] = true,
["Karabor Harbor"] = true,
["Tanaan Channel"] = true,
},
["Gorgrond"] = {
["Colossal Depths"] = true,
["Barrier Sea"] = true,
["Iron Sea"] = true,
["Orunai Coast"] = true,
},
["Talador"] = {
["Aarko's Estate"] = true,
["Orunai Delta"] = true,
["The South Sea"] = true,
["Sha'tari Anchorage"] = true,
["Shattrath Port Authority"] = true,
["Beacon of Sha'tar"] = true,
["The Sunset Shore"] = true,
["Orunai Bay"] = true,
["Orunai Coast"] = true,
},
["Frostfire Ridge"] = {
["Colossal Depths"] = true,
["Frostboar Point"] = true,
["Frostbite Deep"] = true,
["Southwind Inlet"] = true,
["Ata'gar Promontory"] = true,
["Tor'goroth's Tooth"] = true,
["Cold Snap Coast"] = true,
["Zangar Sea"] = true,
["Frostangler Bay"] = true,
["Southwind Cliffs"] = true,
["The Pale Cove"] = true,
["Throm'var Landing"] = true,
["Glacier Bay"] = true,
["Ozgor's Launch"] = true,
["Iron Sea"] = true,
},
["Nagrand (Draenor)"] = {
["The Colossal's Fist"] = true,
["Lernaen Shore"] = true,
["Zangar Shore"] = true,
["Cerulean Lagoon"] = true,
["Ironfist Harbor"] = true,
["Zangar Sea"] = true,
["Windroc Bay"] = true,
["The South Sea"] = true,
["The Cliffs of Highmaul"] = true,
["Highmaul Harbor"] = true,
},
["Tanaan Jungle"] = {
["Tanaan Channel"] = true,
["Barrier Sea"] = true,
},
["Spires of Arak"] = {
["Pinchwhistle Gearworks"] = true,
["Echidnean Shelf"] = true,
["The South Sea"] = true,
["Wreck of the Mother Lode"] = true,
["The Writhing Mire"] = true,
["Southport"] = true,
["Bloodmane Pridelands"] = true,
["The Evanescent Sea"] = true,
},
};
local function CurrentSpecialBait()
local continent = GetCurrentMapContinent();
local baits = SpecialBait[continent];
if (baits) then
for _,id in ipairs(baits) do
local bait = FishingItems[id];
if (bait and FL:HasBuff(GetSpellInfo(bait.spell))) then
return id;
end
end
end
-- return nil
end
local function CheckSpecialBait(info, buff, need)
local continent = GetCurrentMapContinent();
if (SpecialBait[continent]) then
if ( GSB("DraenorBaitMaintainOnly") and LastSpecialBait ) then
return true, LastSpecialBait;
else
if (not info.buff) then
info.buff = GetSpellInfo(info.spell);
end
if (not FL:HasBuff(info.buff)) then
return true, info.id;
end
end
end
end
local function VerifySpecialBait(info, checkscorpion)
if (not IsQuestFishing()) then
if (GSB("EasyLures") and GSB("DraenorBait")) then
local continent = GetCurrentMapContinent();
if ( GSB("DraenorBaitMaintainOnly") ) then
local baitid = CurrentSpecialBait();
if ( not baitid and LastSpecialBait ) then
if (GetItemCount(LastSpecialBait) > 0) then
return true;
end
else
LastSpecialBait = baitid;
end
elseif (continent == 7 ) then
local zone, subzone = FL:GetBaseZoneInfo();
if ( checkscorpion ) then
return (seascorpion[zone] and seascorpion[zone][subzone]);
elseif ( zone == info.zone) then
return not seascorpion[zone][subzone];
end
end
end
end
-- return nil;
end
local function UseSeaScorpionBait(info)
return VerifySpecialBait(info, true);
end
local function UsableSpecialBait(info)
return VerifySpecialBait(info, false);
end
-- Blind Lake Sturgeon, 158035
FishingItems[110290] = {
["enUS"] = "Blind Lake Sturgeon Bait",
spell = 158035,
zone = "Shadowmoon Valley (Draenor)",
usable = UsableSpecialBait,
check = CheckSpecialBait,
};
FishingItems[110293] = {
["enUS"] = "Abyssal Gulper Eel Bait",
spell = 158038,
zone = "Spires of Arak",
usable = UsableSpecialBait,
check = CheckSpecialBait,
};
FishingItems[110294] = {
["enUS"] = "Blackwater Whiptail Bait",
spell = 158039,
zone = "Talador",
usable = UsableSpecialBait,
check = CheckSpecialBait,
};
FishingItems[110289] = {
["enUS"] = "Fat Sleeper Bait",
spell = 158034,
zone = "Nagrand (Draenor)",
usable = UsableSpecialBait,
check = CheckSpecialBait,
};
FishingItems[110291] = {
["enUS"] = "Fire Ammonite Bait",
spell = 158036,
zone = "Frostfire Ridge",
usable = UsableSpecialBait,
check = CheckSpecialBait,
};
FishingItems[110274] = {
["enUS"] = "Jawless Skulker Bait",
spell = 158031,
zone = "Gorgrond",
usable = UsableSpecialBait,
check = CheckSpecialBait,
};
FishingItems[128229] = {
["enUS"] = "Felmouth Frenzy Bait",
spell = 188904,
zone = "Tanaan Jungle",
usable = UsableSpecialBait,
check = CheckSpecialBait,
};
FishingItems[110292] = {
["enUS"] = "Sea Scorpion Bait",
spell = 158037,
zone = "Non-inland water",
usable = UseSeaScorpionBait,
check = CheckSpecialBait,
};
FishingItems[139175] = {
["enUS"] = "Arcane Lure",
spell = 218861,
usable = UsableSpecialBait,
check = CheckSpecialBait,
};
FishingBuddy.FishingItems = FishingItems;
local FluffOptions = {
["FishingFluff"] = {
["text"] = FBConstants.CONFIG_FISHINGFLUFF_ONOFF,
["tooltip"] = FBConstants.CONFIG_FISHINGFLUFF_INFO,
["v"] = 1,
["m1"] = 1,
["p"] = 1,
["default"] = true
},
["FindFish"] = {
["text"] = FBConstants.CONFIG_FINDFISH_ONOFF,
["tooltip"] = FBConstants.CONFIG_FINDFISH_INFO,
["v"] = 1,
["m"] = 1,
["parents"] = { ["FishingFluff"] = "d" },
["default"] = true
},
["DrinkHeavily"] = {
["text"] = FBConstants.CONFIG_DRINKHEAVILY_ONOFF,
["tooltip"] = FBConstants.CONFIG_DRINKHEAVILY_INFO,
["v"] = 1,
["m"] = 1,
["parents"] = { ["FishingFluff"] = "d" },
["default"] = true
},
};
local RAFT_RESET_TIME = 30
local RaftOptions = {
["enUS"] = "Angler's Fishing Raft",
["tooltip"] = FBConstants.CONFIG_FISHINGRAFT_INFO,
itemid = 85500;
spell = 124036,
toy = 1,
always = 1, -- this is now a toy!
time = RAFT_RESET_TIME,
setting = "UseAnglersRaft",
usable = RaftBergUsable,
check = RaftBergCheck,
["default"] = true,
["option"] = {
["setting"] = "BergMaintainOnly",
["text"] = FBConstants.CONFIG_MAINTAINRAFTBERG_ONOFF,
["tooltip"] = FBConstants.CONFIG_MAINTAINRAFT_INFO,
["default"] = true,
},
};
local BergOptions = {
["enUS"] = "Bipsi's Bobbing Berg",
-- Don't cast the angler's raft if we're doing Scavenger Hunt or on Inkgill Mere
["tooltip"] = FBConstants.CONFIG_BOBBINGBERG_INFO,
itemid = 107950;
spell = 152421,
time = RAFT_RESET_TIME,
setting = "UseBobbingBerg",
usable = RaftBergUsable,
check = RaftBergCheck,
["default"] = true,
["option"] = {
["setting"] = "BergMaintainOnly",
["text"] = FBConstants.CONFIG_MAINTAINRAFTBERG_ONOFF,
["tooltip"] = FBConstants.CONFIG_MAINTAINBERG_INFO,
["default"] = true,
},
};
local function PickRaft(info, buff, need, itemid)
local bergbuff = GetSpellInfo(BergOptions.spell);
local raftbuff = GetSpellInfo(RaftOptions.spell);
local hasberg = FL:HasBuff(bergbuff);
local hasraft = FL:HasBuff(raftbuff);
need = not (hasberg or hasraft);
-- if we need it, but we're maintaining only, skip it
if (GSB("BergMaintainOnly") and need) then
return false;
end
local it = nil;
if (not hasraft and GSB("UseBobbingBerg")) then
buff = bergbuff;
itemid = BergOptions.itemid;
else
buff = raftbuff;
_, itemid = C_ToyBox.GetToyInfo(RaftOptions.itemid)
-- it = "item"
end
local _, _, _, _, _, _, et, _, _, _, _ = UnitBuff("player", buff);
et = (et or 0) - GetTime();
if (need or et <= RAFT_RESET_TIME) then
return true, itemid, it;
end
--return nil;
end
local function HandleRaftItems()
local haveRaft = PlayerHasToy(RaftOptions.itemid);
local haveBerg = GetItemCount(BergOptions.itemid);
if (haveRaft and haveBerg) then
-- if we have both, be smarter about rafts
FluffOptions["UseRaft"] = {
["text"] = FBConstants.CONFIG_USERAFTS_ONOFF,
["tooltip"] = FBConstants.CONFIG_USERAFTS_INFO,
["v"] = 1,
["default"] = true
};
FluffOptions["BergMaintainOnly"] = {
["text"] = FBConstants.CONFIG_MAINTAINRAFTBERG_ONOFF,
["tooltip"] = FBConstants.CONFIG_MAINTAINRAFT_INFO,
["v"] = 1,
["default"] = true,
["parents"] = { ["UseRaft"] = "d", },
};
FluffOptions["UseBobbingBerg"] = {
["text"] = FBConstants.CONFIG_BOBBINGBERG_ONOFF,
["tooltip"] = FBConstants.CONFIG_BOBBINGBERG_INFO,
["v"] = 1,
["default"] = true,
["parents"] = { ["UseRaft"] = "d", },
};
FishingItems[RaftOptions.itemid] = {
setting = "UseRaft",
ignore = 1,
spell = 124036,
always = 1,
usable = RaftBergUsable,
check = PickRaft,
};
elseif (haveRaft) then
-- if we just have one or the other, then use our regular item option
FishingItems[RaftOptions.itemid] = RaftOptions;
else
FishingItems[BergOptions.itemid] = BergOptions;
end
end
local function ItemInit(option, button)
local n, _, _, _, _, _, _, _,_, _ = GetItemInfo(option.id);
if (n) then
option.text = n;
else
option.text = option.enUS;
end
end
local function ItemVisible(option)
return GetItemCount(option.id) > 0;
end
local function UpdateItemOption(id, info)
info.id = id;
if (info.setting and not info.ignore) then
local option = {};
option.id = id;
option.enUS = info.enUS;
if (info.visible) then
option.visible = info.visible;
else
option.visible = ItemCountVisible;
end
option.init = ItemInit;
option.tooltip = info.tooltip;
option.setup = info.setup;
option.enabled = info.enabled;
option.default = info.default;
option.v = 1;
-- option.deps = { ["FishingFluff"] = "d" };
FluffOptions[info.setting] = option;
if (info.option) then
local sub = {};
sub.text = info.option.text;
sub.tooltip = info.option.tooltip;
sub.default = info.option.default;
sub.visible = option.visible;
sub.v = 1;
sub.parents = {};
sub.parents[info.setting] = "d";
FluffOptions[info.option.setting] = sub;
end
end
end
local function UpdateItemOptions()
for id,info in pairs(FishingItems) do
UpdateItemOption(id, info)
end
FishingBuddy.FluffOptions = FluffOptions;
end
local function SetupSpecialItem(id, info, fixsetting, fixloc)
info.id = id
if (info.spell and not info.buff) then
info.buff = GetSpellInfo(info.spell);
end
if (fixsetting and info.enUS and not info.setting) then
info.setting = info.enUS:gsub("%s+", "")
end
if (fixloc and not info[CurLoc]) then
local link = "item:"..id;
local n,l,_,_,_,_,_,_ = FL:GetItemInfo(link);
if (n and l) then
info[CurLoc] = n
else
info[CurLoc] = info.enUS
end
end
return info;
end
FishingBuddy.SetupSpecialItem = SetupSpecialItem
local function SetupSpecialItems(items, fixsetting, fixloc, skipitem)
for id,info in pairs(items) do
info = SetupSpecialItem(id, info, fixsetting, fixloc);
if ( not skipitem ) then
FishingItems[id] = info;
UpdateItemOption(id, info)
end
end
end
FishingBuddy.SetupSpecialItems = SetupSpecialItems
FluffEvents["VARIABLES_LOADED"] = function(started)
-- Let's make sure we have buffs on all the items we currently know about
for id,info in pairs(FishingItems) do
SetupSpecialItem(id, info);
end
SetupSpecialItems(CoinLures);
-- we have to wait until the toys are actually available
local toydelayframe = CreateFrame("Frame");
toydelayframe:Hide();
toydelayframe:SetScript("OnUpdate", function(self, ...)
HandleRaftItems();
UpdateItemOptions();
FishingBuddy.OptionsFrame.HandleOptions(FBConstants.CONFIG_FISHINGFLUFF_ONOFF, "Interface\\Icons\\inv_misc_food_164_fish_seadog", FluffOptions);
self:Hide();
end);
toydelayframe:Show();
end
FishingBuddy.RegisterHandlers(FluffEvents);
if ( FishingBuddy.Commands["debug"] ) then
FishingBuddy.SeaScorpion = seascorpion;
FishingBuddy.CurrentSpecialBait = CurrentSpecialBait;
end
PK T%L-; FishingBuddy/FishingFluff.xml
PK VKOW! ! # FishingBuddy/FishingGearManager.lua-- Interface with the Blizz Equipment Manager
-- 5.0.4 has a problem with a global "_" (see some for loops below)
local _
local FL = LibStub("LibFishing-1.0");
local function GetEquipmentSetInfoByName(name)
local setId = C_EquipmentSet.GetEquipmentSetID(name);
if (setId) then
local n, iconFileID, setID, isEquipped, numItems, numEquipped, numInInventory, numLost, numIgnored = C_EquipmentSet.GetEquipmentSetInfo(setId);
return iconFileID, setID, isEquipped, numItems, numEquipped, numInInventory, numLost, numIgnored;
end
end
local function SaveEquipmentSet(name, icon)
local setId = C_EquipmentSet.GetEquipmentSetID(name);
if (setId) then
C_EquipmentSet.SaveEquipmentSet(setId, icon);
else
C_EquipmentSet.CreateEquipmentSet(name, icon);
end
end
local function DeleteEquipmentSet(name)
local setId = C_EquipmentSet.GetEquipmentSetID(name);
if (setId) then
C_EquipmentSet.DeleteEquipmentSet(setId);
end
end
local function EquipSetByName(name)
local setId = C_EquipmentSet.GetEquipmentSetID(name);
if (setId) then
EquipmentManager_EquipSet(setId);
end
end
local lastOutfit;
local FB_TEMP_OUTFIT = "FB_TEMP_OUTFIT";
local FINAL_STATE = 4;
local gearframe = CreateFrame("Frame");
gearframe:Hide();
gearframe:SetScript("OnUpdate", function(self)
-- FishingBuddy.Debug("gearframe state "..self.state);
if ( self.state == 0 ) then
local icon, idxm1 = GetEquipmentSetInfoByName(self.name);
if ( not icon or self.force ) then
-- make sure we're wearing everything we think we should be
local wearing = 1;
local mslot = GetInventorySlotInfo("MainHandSlot");
for invslot,info in pairs(self.outfit) do
local link = GetInventoryItemLink("player", invslot);
-- FishingBuddy.Debug("link "..link.." "..info.link);
if (link ~= info.link) then
wearing = nil;
end
if (not self.maintexture) then
if (mslot == invslot) then
local _, _, _, _, _, _, _, _, _, t, _ = GetItemInfo(info.link);
self.maintexture = gsub( strupper(t), "INTERFACE\\ICONS\\", "" );
-- FishingBuddy.Debug("texture "..self.maintexture);
end
end
end
-- Are we wearing everything?
if (wearing) then
SaveEquipmentSet(self.name, self.maintexture);
self.state = 1;
end
else
self.state = FINAL_STATE;
end
elseif ( self.state == 1 ) then
-- we have to save it again, after setting the ignore slots
for slot=1,17 do
C_EquipmentSet.IgnoreSlotForSave(slot);
end
for invslot,info in pairs(self.outfit) do
C_EquipmentSet.UnignoreSlotForSave(invslot);
end
SaveEquipmentSet(self.name, self.maintexture);
-- reset slot ignore flags
local icon, _ = GetEquipmentSetInfoByName(FB_TEMP_OUTFIT);
if ( icon ) then
EquipSetByName(FB_TEMP_OUTFIT);
self.state = 2;
self.nextstate = 3;
else
self.state = FINAL_STATE;
end
elseif ( self.state == 2 ) then
-- waiting for EQUIPMENT_SWAP_FINISHED
elseif (self.state == 3) then
local icon, _ = GetEquipmentSetInfoByName(FB_TEMP_OUTFIT);
if ( icon ) then
DeleteEquipmentSet(FB_TEMP_OUTFIT);
end
self.state = FINAL_STATE;
else
self.force = nil;
self:Hide();
end
end)
gearframe:SetScript("OnEvent", function(self,...)
self.state = self.nextstate;
end)
gearframe:RegisterEvent("EQUIPMENT_SWAP_FINISHED");
local function PrepGearFrame(name, outfit, force)
gearframe.laststate = -1;
gearframe.name = name;
gearframe.state = 0;
gearframe.outfit = outfit;
gearframe.force = force;
gearframe.maintexture = nil;
gearframe:Show();
end
local function GearManagerInitialize(force)
local known, name = FL:GetFishingSkillInfo();
if ( known ) then
if (force) then
-- FishingBuddy.Debug("GearManagerInitialize forced");
end
-- FishingBuddy.Debug("GearManagerInitialize name "..FBConstants.NAME);
local icon, setId = GetEquipmentSetInfoByName(FBConstants.NAME);
if ( icon ) then
-- Validate outfit, CurseForge bug #218
local itemArray = C_EquipmentSet.GetEquipmentSetIDs(setId);
-- If there is a Ranged slot, nuke this outfit
-- FishingBuddy.Dump(itemArray)
if (itemArray[18] and itemArray[18] ~= 0) then
force = true;
end
end
if ( not icon or force ) then
-- Let's build a fishing outfit
-- but we actually have to equip the items for this to work
-- let's save what we have on now...
C_EquipmentSet.ClearIgnoredSlotsForSave();
SaveEquipmentSet(FB_TEMP_OUTFIT, 1);
local outfit = FL:GetFishingOutfitItems(false) or {};
for invslot,info in pairs(outfit) do
EquipItemByName(info.link, invslot);
end -- for bags
-- let's save this puppy
PrepGearFrame(FBConstants.NAME, outfit, force);
end
end
-- we can (and need to) reinitialize every time we're selected
return false;
end
local function GuessCurrentOutfit()
local ret = {};
local numsets = C_EquipmentSet.GetNumEquipmentSets();
for set = 0, numsets-1 do
ret[set+1] = 0;
local location_array = C_EquipmentSet.GetItemLocations(set);
if (location_array) then
for s,location in pairs(location_array) do
local onplayer, _, bags, _, _, _ = EquipmentManager_UnpackLocation(location);
if onplayer and not bags then
ret[set+1] = ret[set+1] + 1;
end
end
end
end
local best_set = 1;
local best_value = 0;
for i = 1, #ret do
if (best_value < ret[i]) then
best_value = ret[i];
best_set = i-1;
end
end
local best_name, _, _ = C_EquipmentSet.GetEquipmentSetInfo(best_set);
return best_name;
end
local function GetCurrentOutfit()
local setId = PaperDollEquipmentManagerPane.selectedSetId;
if ( setId ) then
local name = C_EquipmentSet.GetEquipmentSetInfo(setId);
return name;
end
if ( C_EquipmentSet.GetNumEquipmentSets() == 0 ) then
return nil; -- there are no gear sets, give up
end
-- no gear set active, take best fit
return GuessCurrentOutfit();
end
local function GearManagerSwitch(outfitName)
local GSB = FishingBuddy.GetSettingBool;
if ( FL:IsFishingReady(GSB("PartialGear")) ) then
local name = FishingBuddy_Info["LastGearSet"];
if ( not name ) then
name = GetCurrentOutfit();
end
EquipSetByName(name);
FishingBuddy_Info["LastGearSet"] = nil;
return false;
else
local icon, setId = GetEquipmentSetInfoByName(FBConstants.NAME);
if ( icon ) then
FishingBuddy_Info["LastGearSet"] = GetCurrentOutfit();
EquipmentManager_EquipSet(setId);
return true;
end
end
-- return nil;
end
local function OutfitPoints(outfit)
local sp = 0;
local bp = 0;
if ( outfit )then
local isp = FishingBuddy.OutfitManager.ItemStylePoints;
local ibp = function(link) return FL:FishingBonusPoints(link); end;
local items = GetEquipmentSetLocations(outfit);
for slot,loc in pairs(items) do
local player, bank, bags, void, slot, bag = EquipmentManager_UnpackLocation(loc);
local link;
if ( not bags ) then -- and (player or bank)
link = GetInventoryItemLink("player", slot);
else -- bags
link = GetContainerItemLink(bag, slot);
end
if ( link ) then
_, link, _ = FL:SplitLink(link);
sp = sp + isp(link);
bp = bp + ibp(link);
end
end
end
return bp, sp;
end
local Saved_GearSetButton_OnEnter = GearSetButton_OnEnter;
local function Patch_GearSetButton_OnEnter(self)
Saved_GearSetButton_OnEnter(self);
local _, name = FL:GetFishingSkillInfo();
if ( self.name and self.name == FBConstants.NAME ) then
local bp, sp = OutfitPoints(self.name)
if ( bp >= 0 ) then
bp = "+"..bp;
else
bp = 0 - bp;
bp = "-"..bp;
end
bp = name.." "..bp;
local pstring;
if ( points == 1 ) then
pstring = FBConstants.POINT;
else
pstring = FBConstants.POINTS;
end
GameTooltip:AddDoubleLine(SKILL..": "..bp, "Draznar: "..sp, 1, 1, 1, 1, 1, 1);
GameTooltip:Show();
end
end
-- point to our new function so we get our own tooltip
GearSetButton_OnEnter = Patch_GearSetButton_OnEnter;
FishingBuddy.OutfitManager.RegisterManager(EQUIPMENT_MANAGER,
GearManagerInitialize,
function(useme) end,
GearManagerSwitch);
if ( FishingBuddy.Debugging ) then
FishingBuddy.Commands["checkset"] = {};
FishingBuddy.Commands["checkset"].func =
function(what)
local Debug = FishingBuddy.Debug;
local icon, setId = GetEquipmentSetInfoByName(self.name);
local set = GetEquipmentSetItemIDs(setId);
for slot, item in ipairs(set) do
if ( item == EQUIPMENT_SET_IGNORED_SLOT ) then
Debug("Ignored slot "..slot);
end
end
return true;
end
FishingBuddy.Commands["newset"] = {};
FishingBuddy.Commands["newset"].func =
function(what)
GearManagerInitialize(true);
return true;
end
end
PK nm/LyO yO FishingBuddy/FishingInit.lua-- FishingBuddy
--
-- Everything you wanted support for in your fishing endeavors
local FL = LibStub("LibFishing-1.0");
local gotSetupDone = false;
local lastVersion;
local lastPlayerVersion;
local playerName;
local realmName;
local zmto = FishingBuddy.ZoneMarkerTo;
local zmex = FishingBuddy.ZoneMarkerEx;
FishingBuddy.IsLoaded = function()
return gotSetupDone;
end
-- if the old information is still there, then we might not have per
-- character saved info, so let's save it away just in case. It'll go
-- away the second time we load the add-on
FishingBuddy.SavePlayerInfo = function()
if ( FishingBuddy_Info[realmName] and
FishingBuddy_Info[realmName]["Settings"] and
FishingBuddy_Info[realmName]["Settings"][playerName] ) then
local tabs = { "Settings", "Outfit", "WasWearing" };
for _,tab in pairs(tabs) do
for k,v in pairs(FishingBuddy_Player[tab]) do
FishingBuddy_Info[realmName][tab][playerName][k] = v;
end
end
end
end
local FishingInit = {};
local function copytable(tab, level)
return FL:copytable(tab, level);
end
FishingInit.ResetHelpers = function()
FishingBuddy.SortedZones = {};
FishingBuddy.SortedByZone = {};
FishingBuddy.SortedSubZones = {};
FishingBuddy.UniqueSubZones = {};
FishingBuddy.SubZoneMap = {};
end
FishingInit.CopyFishingHoles = function()
local sorted = FishingBuddy.SortedZones;
local zonecount = table.getn(sorted);
local fh = {};
local fbfh = FishingBuddy_Info[GetLocale()]["FishingHoles"];
for i=1,zonecount,1 do
local zone = sorted[i];
local subsorted = FishingBuddy.SortedByZone[zone];
if ( subsorted ) then
local subcount = table.getn(subsorted);
for s=1,subcount,1 do
local subzone = subsorted[s];
local where = FishingBuddy.GetZoneIndex(zone, subzone, true);
local _, total = FishingBuddy.FishCount(where);
if ( fbfh[where] and total > 0) then
if ( not fh[zone] ) then
fh[zone] = {};
end
if ( not fh[zone][subzone] ) then
fh[zone][subzone] = {};
end
for fishid,count in pairs(fbfh[where]) do
fh[zone][subzone][fishid] = count;
end
end
end
end
end
return fh;
end
FishingInit.CopyFishSchools = function()
schools = {};
if ( FishingBuddy_Info["FishSchools"] ) then
for zidx,holes in pairs(FishingBuddy_Info["FishSchools"]) do
local zone = FishingBuddy_Info["ZoneIndex"][zidx];
schools[zone] = copytable(holes);
end
end
return schools;
end
-- Fill in the player name and realm
FishingInit.SetupNameInfo = function()
playerName = UnitName("player");
realmName = GetRealmName();
return playerName, realmName;
end
FishingInit.CheckPlayerInfo = function()
local tabs = { "Settings", "Outfit", "WasWearing" };
if ( not FishingBuddy_Player ) then
FishingBuddy_Player = {};
for _,tab in pairs(tabs) do
FishingBuddy_Player[tab] = { };
end
if ( FishingBuddy_Info[realmName] and
FishingBuddy_Info[realmName]["Settings"] and
FishingBuddy_Info[realmName]["Settings"][playerName] ) then
for _,tab in pairs(tabs) do
if ( FishingBuddy_Info[realmName][tab] and
FishingBuddy_Info[realmName][tab][playerName] ) then
for k,v in pairs(FishingBuddy_Info[realmName][tab][playerName]) do
FishingBuddy_Player[tab][k] = v;
end
end
end
end
elseif ( FishingBuddy_Info[realmName] and
FishingBuddy_Info[realmName]["Settings"] ) then
-- the saved information is there, kill the old stuff
for _,tab in pairs(tabs) do
if ( FishingBuddy_Info[realmName][tab] ) then
FishingBuddy_Info[realmName][tab][playerName] = nil;
-- Duh, table.getn doesn't work because there
-- aren't any integer keys in this table
if ( next(FishingBuddy_Info[realmName][tab]) == nil ) then
FishingBuddy_Info[realmName][tab] = nil;
end
end
end
if ( next(FishingBuddy_Info[realmName]) == nil ) then
FishingBuddy_Info[realmName] = nil;
end
end
end
FishingInit.CheckPlayerSetting = function(setting, defaultvalue)
if ( not FishingBuddy_Player["Settings"] ) then
FishingBuddy_Player["Settings"] = { };
end
if ( not FishingBuddy_Player["Settings"][setting] ) then
FishingBuddy_Player["Settings"][setting] = defaultvalue;
end
end
FishingInit.CheckGlobalSetting = function(setting, defaultvalue)
if ( not FishingBuddy_Info[setting] ) then
if ( not defaultvalue ) then
FishingBuddy_Info[setting] = {};
else
FishingBuddy_Info[setting] = defaultvalue;
end
end
end
FishingInit.CheckRealm = function()
local tabs = { "Settings", "Outfit", "WasWearing" };
for _,tab in pairs(tabs) do
if ( FishingBuddy_Info[tab] ) then
local old = FishingBuddy_Info[tab][playerName];
if ( old ) then
if ( not FishingBuddy_Info[realmName] ) then
FishingBuddy_Info[realmName] = { };
for _,tab in pairs(tabs) do
FishingBuddy_Info[realmName][tab] = { };
end
end
FishingBuddy_Info[realmName][tab][playerName] = { };
for k, v in pairs(old) do
FishingBuddy_Info[realmName][tab][playerName][k] = v;
end
FishingBuddy_Info[tab][playerName] = nil;
end
-- clean out cruft, if we have some
FishingBuddy_Info[tab][UNKNOWNOBJECT] = nil;
FishingBuddy_Info[tab][UKNOWNBEING] = nil;
-- Duh, table.getn doesn't work because there
-- aren't any integer keys in this table
if ( next(FishingBuddy_Info[tab]) == nil ) then
FishingBuddy_Info[tab] = nil;
end
end
end
end
FishingInit.SetupZoneMapping = function()
local continentNames = { GetMapContinents() };
if ( not FishingBuddy_Info["ZoneIndex"] ) then
FishingBuddy_Info["ZoneIndex"] = {};
end
if ( not FishingBuddy_Info["SubZones"] ) then
FishingBuddy_Info["SubZones"] = {};
end
end
FishingInit.CleanLocales = function(loc)
local locales = {};
local havelocs = false;
for oldloc,_ in pairs(FishingBuddy_Info["Locales"]) do
if ( oldloc ~= loc ) then
locales[oldloc] = 1;
havelocs = true;
end
end
if (havelocs) then
FishingBuddy_Info["Locales"] = locales;
else
FishingBuddy_Info["Locales"] = nil;
end
return havelocs, locales;
end
FishingInit.ResetFishies = function(zones, subzones, holes, skills)
local AddFishie = FishingBuddy.AddFishie;
local questType = _G.GetItemClassInfo(LE_ITEM_CLASS_QUESTITEM);
FishingInit.ResetHelpers();
local loc = GetLocale();
local FI = FishingBuddy_Info["Fishies"];
for zidx,zone in ipairs(zones) do
local zmarker = zmto(zidx, 0);
local szcount = subzones[zmarker];
if ( szcount ) then
for sidx=1,szcount do
local marker = zmto(zidx,sidx);
local subzone = subzones[marker];
if ( subzone and holes[marker] ) then
subzone = FL:GetBaseSubZone(subzone);
local level = skills[marker];
for fid,count in pairs(holes[marker]) do
local color = FI[fid].color;
local texture = FI[fid].texture;
local name = FI[fid][loc];
local quality = FI[fid].quality;
local level = skills[marker] or nil;
local it, st;
if ( FI[fid].quest ) then
it = questType;
st = questType;
end
if ( zone == UNKNOWN ) then
zone = FBConstants.UNKNOWN;
end
AddFishie(color, fid, name, zone, subzone, texture, count, quality, level, it, st)
end
end
end
end
end
end
-- Now that we have LibBabble-SubZone, let's just use one table (yay!)
FishingInit.MergeLocale = function(loc)
if ( not FishingBuddy_Info[loc] ) then
FishingInit.CleanLocales(loc);
return;
end
local GetZoneIndex = FishingBuddy.GetZoneIndex;
local AddZoneIndex = FishingBuddy.AddZoneIndex;
local subzones = copytable(FishingBuddy_Info[loc]["SubZones"], 0);
local totals = copytable(FishingBuddy_Info[loc]["FishTotals"], 0);
local skills = copytable(FishingBuddy_Info[loc]["FishingSkill"], 0);
local holes = copytable(FishingBuddy_Info[loc]["FishingHoles"], 0);
FishingBuddy_Info[loc]["SubZones"] = nil;
FishingBuddy_Info[loc]["FishTotals"] = nil;
FishingBuddy_Info[loc]["FishingSkill"] = nil;
FishingBuddy_Info[loc]["FishingHoles"] = nil;
FishingBuddy_Info[loc] = nil;
-- moving data to the top if we're doing this the first time
if ( not FishingBuddy_Info["FishingHoles"] ) then
for zidx,name in pairs(FishingBuddy_Info["ZoneIndex"]) do
local zmarker = zmto(zidx, 0);
local szcount = subzones[zmarker];
if ( szcount ) then
for sidx=1,szcount do
local marker = zmto(zidx,sidx);
local name = subzones[marker];
local newname = FL:GetBaseSubZone(name);
if ( newname ~= name ) then
subzones[marker] = newname;
end
end
end
end
FishingBuddy_Info["SubZones"] = subzones;
FishingBuddy_Info["FishTotals"] = totals;
FishingBuddy_Info["FishingSkill"] = skills;
FishingBuddy_Info["FishingHoles"] = holes;
FishingInit.CleanLocales(loc);
-- we're done the first time...
return;
end
-- since we're leaving the zones "as is", we don't need to redo FishSchools
FishingInit.ResetFishies(FishingBuddy_Info["ZoneIndex"], subzones, holes, skills);
FishingInit.CleanLocales(loc);
end
FishingInit.ResetZones = function()
FishingInit.ResetHelpers();
local zones = copytable(FishingBuddy_Info["ZoneIndex"], 0);
local subzones = copytable(FishingBuddy_Info["SubZones"], 0);
local totals = copytable(FishingBuddy_Info["FishTotals"], 0);
local skills = copytable(FishingBuddy_Info["FishingSkill"], 0);
local holes = copytable(FishingBuddy_Info["FishingHoles"], 0);
FishingBuddy_Info["ZoneIndex"] = {};
tinsert(FishingBuddy_Info["ZoneIndex"], FBConstants.UNKNOWN);
FishingBuddy_Info["SubZones"] = {};
FishingBuddy_Info["FishTotals"] = {};
FishingBuddy_Info["FishingSkill"] = {};
FishingBuddy_Info["FishingHoles"] = {};
FishingInit.ResetFishies(zones, subzones, holes, skills);
local GetZoneIndex = FishingBuddy.GetZoneIndex;
local schools = copytable(FishingBuddy_Info["FishSchools"], 0);
FishingBuddy_Info["FishSchools"] = {};
for zold,school in pairs(schools) do
local zidx = GetZoneIndex(zones[zold]);
if ( zidx ) then
FishingBuddy_Info["FishSchools"][zidx] = school;
else
FishingBuddy.Debug("Failed to find zone '%s' (%d)", zones[zold] or "nil", zold);
end
end
end
FishingInit.UpdateFishingDB = function()
local version = FishingBuddy_Info["Version"];
if ( not version ) then
version = 8700; -- be really old
end
-- We should have been doing this all along, so let's go way, way back
playerversion = FishingBuddy_Player["Version"];
if ( not playerversion ) then
playerversion = 8700;
end
local loc = GetLocale();
-- keep doing this for really, really old versions.
if ( version < 9701 ) then
FishingBuddy_Info[loc] = {};
FishingBuddy_Info[loc]["SubZones"] = copytable(FishingBuddy_Info["SubZones"], 0);
FishingBuddy_Info[loc]["FishTotals"] = copytable(FishingBuddy_Info["FishTotals"], 0);
FishingBuddy_Info[loc]["FishingSkill"] = copytable(FishingBuddy_Info["FishingSkill"], 0);
FishingBuddy_Info[loc]["FishingHoles"] = copytable(FishingBuddy_Info["FishingHoles"], 0);
FishingBuddy_Info["SubZones"] = nil;
FishingBuddy_Info["FishTotals"] = nil;
FishingBuddy_Info["FishingSkill"] = nil;
FishingBuddy_Info["FishingHoles"] = nil;
for id,info in pairs(FishingBuddy_Info["Fishies"]) do
if ( info.name ) then
info[loc] = info.name;
info.name = nil;
end
end
end
if ( playerversion < 9701 ) then
if ( FishingBuddy_Player["Settings"]["ClickToSwitch"] ) then
FishingBuddy_Player["Settings"]["ClickToSwitch"] = 1;
end
if ( FishingBuddy_Player["Settings"]["MinimapClickToSwitch"] ) then
FishingBuddy_Player["Settings"]["MinimapClickToSwitch"] = 1;
end
end
if ( not FishingBuddy_Info["Locales"] ) then
local locales = {};
for k,v in pairs(FishingBuddy_Info) do
if ( type(v) == "table" and v["SubZones"] and v["FishingHoles"] ) then
locales[k] = 1;
end
end
FishingBuddy_Info["Locales"] = locales;
end
if (version < 9817) then
-- Same id, different fish :-(
local fish = FishingBuddy_Info["Fishies"][45328];
if ( fish ) then
local info = {};
info.mods = fish.mods;
info.quality = fish.quality;
info.quest = true;
info.level = fish.level;
info.skill = fish.skill;
info.texture = fish.texture;
FishingBuddy_Info["Fishies"][45328] = info;
end
end
if (version < 9901) then
FishingBuddy_Info["GreatAndSmall"] = nil;
local buddy = FishingBuddy_Info["FishingBuddy"];
if ( buddy and buddy > 0) then
FishingBuddy_Info["FishingPetBuddies"] = { buddy };
end
FishingBuddy_Info["FishingBuddy"] = nil;
end
if (version < 9907) then
-- throw away bad top level copies of these, we have "loc" versions, which we'll merge below
FishingBuddy_Info["SubZones"] = nil;
FishingBuddy_Info["FishTotals"] = nil;
FishingBuddy_Info["FishingSkill"] = nil;
FishingBuddy_Info["FishingHoles"] = nil;
-- for now, just do the current locale
FishingInit.MergeLocale(loc);
else
if ( FishingBuddy_Info["Locales"] and FishingBuddy_Info["Locales"][loc] ) then
-- for now, just do the current locale
FishingInit.MergeLocale(loc);
end
end
if ( not FishingBuddy_Info["Locales"] or #FishingBuddy_Info["Locales"] == 0 ) then
-- look for broken ZoneIndex
local broken = false;
local check = {};
for zidx,zone in ipairs(FishingBuddy_Info["ZoneIndex"]) do
if ( check[zone] ) then
broken = true;
else
check[zone] = zidx;
end
end
if ( broken ) then
FishingBuddy.Message("Duplicate zones, fixing");
FishingInit.ResetZones();
end
end
if ( playerversion < 10003 ) then
FishingBuddy_Player["MinimapButtonVisible"] = nil;
FishingBuddy_Player["ResetWatcher"] = nil;
end
if ( playerversion < 10005) then
if (not FishingBuddy_Player["WatcherLocation"]) then
FishingBuddy_Player["WatcherLocation"] = {};
local loc = FishingBuddy_Player["Settings"]["WatcherLocation"];
if (loc) then
FishingBuddy_Player["WatcherLocation"].y = loc.y;
FishingBuddy_Player["WatcherLocation"].x = loc.x;
FishingBuddy_Player["WatcherLocation"]["point"] = "TOPLEFT";
FishingBuddy_Player["WatcherLocation"]["scale"] = 1;
end
end
FishingBuddy_Player["Settings"]["WatcherLocation"] = nil;
end
if ( playerversion < 18000 ) then
if ( FishingBuddy_Player["Settings"]["SpecialBobbers"] ) then
-- Set to ALL
FishingBuddy_Player["Settings"]["SpecialBobbers"] = -2
else
-- Set to NONE
FishingBuddy_Player["Settings"]["SpecialBobbers"] = -1
end
end
if (type(FishingBuddy_Player["TotalTimeFishing"]) ~= "number") then
FishingBuddy_Player["TotalTimeFishing"] = 1;
end
-- save this for other pieces that might need to update
lastVersion = version;
lastPlayerVersion = playerversion;
FishingBuddy_Info["Version"] = FBConstants.CURRENTVERSION;
FishingBuddy_Player["Version"] = FBConstants.CURRENTVERSION;
end
FishingBuddy.GetLastVersion = function()
return lastVersion, lastPlayerVersion;
end
-- Based on code in QuickMountEquip
FishingInit.HookFunction = function(func, newfunc)
local oldValue = _G[func];
if ( oldValue ~= _G[newfunc] ) then
setglobal(func, _G[newfunc]);
return true;
end
return false;
end
-- set up alternate view of fish data. do this as startup to
-- lower overall dynamic hit when loading the window
FishingInit.SetupByFishie = function()
if ( not FishingBuddy.ByFishie ) then
local loc = GetLocale();
local fh = FishingBuddy_Info["FishingHoles"];
local ff = FishingBuddy_Info["Fishies"];
FishingBuddy.ByFishie = { };
FishingBuddy.SortedFishies = { };
for idx,info in pairs(fh) do
for id,quantity in pairs(info) do
if ( not FishingBuddy.ByFishie[id] ) then
FishingBuddy.ByFishie[id] = { };
if ( ff[id] ) then
tinsert(FishingBuddy.SortedFishies,
{ text = ff[id][loc], id = id });
end
end
if ( not FishingBuddy.ByFishie[id][idx] ) then
FishingBuddy.ByFishie[id][idx] = quantity;
else
FishingBuddy.ByFishie[id][idx] = FishingBuddy.ByFishie[id][idx] + quantity;
end
end
end
FishingBuddy.FishSort(FishingBuddy.SortedFishies, true);
end
end
FishingInit.InitSortHelpers = function()
local fh = FishingBuddy_Info["FishingHoles"];
FishingInit.ResetHelpers();
for zidx,zone in ipairs(FishingBuddy_Info["ZoneIndex"]) do
zone = FL:GetLocZone(zone);
tinsert(FishingBuddy.SortedZones, zone);
FishingBuddy.SortedByZone[zone] = {};
local idx = zmto(zidx, 0);
local count = FishingBuddy_Info["SubZones"][idx];
if ( count ) then
for s=1,count,1 do
idx = zmto(zidx,s);
local subzone = FL:GetLocSubZone(FishingBuddy_Info["SubZones"][idx]);
tinsert(FishingBuddy.SortedByZone[zone], subzone);
FishingBuddy.UniqueSubZones[subzone] = 1;
if ( not FishingBuddy.SubZoneMap[subzone] ) then
FishingBuddy.SubZoneMap[subzone] = {};
end
FishingBuddy.SubZoneMap[subzone][idx] = 1;
end
table.sort(FishingBuddy.SortedByZone[zone]);
end
end
table.sort(FishingBuddy.SortedZones);
for subzone,_ in pairs(FishingBuddy.UniqueSubZones) do
tinsert(FishingBuddy.SortedSubZones, subzone);
end
table.sort(FishingBuddy.SortedSubZones);
end
FishingInit.SetupSchoolCounts = function()
local counts = {};
local zmto = FishingBuddy.ZoneMarkerTo;
if ( FishingBuddy_Info["FishSchools"] ) then
for zidx,holes in pairs(FishingBuddy_Info["FishSchools"]) do
for _,hole in pairs(holes) do
local sidx = hole.sidx;
if ( sidx ) then
-- Fix bad data
if ( sidx < 1000 ) then
sidx = zmto(zidx, sidx);
hole.sidx = sidx;
end
if ( hole.fish ) then
counts[sidx] = counts[sidx] or {};
for fishid,count in pairs(hole.fish) do
counts[sidx][fishid] = counts[sidx][fishid] or 0;
counts[sidx][fishid] = counts[sidx][fishid] + count;
end
end
end
end
end
end
FishingBuddy.SZSchoolCounts = counts;
end
FishingInit.InitSettings = function()
if( not FishingBuddy_Info ) then
FishingBuddy_Info = { };
end
-- global stuff
FishingInit.SetupZoneMapping();
FishingInit.CheckRealm();
FishingInit.CheckGlobalSetting("ImppDBLoaded", 0);
FishingInit.CheckGlobalSetting("FishInfo2", 0);
FishingInit.CheckGlobalSetting("DataFish", 0);
FishingInit.CheckGlobalSetting("FishTotals");
FishingInit.CheckGlobalSetting("FishingHoles");
FishingInit.CheckGlobalSetting("FishingSkill");
FishingInit.CheckGlobalSetting("Fishies");
FishingInit.CheckGlobalSetting("HiddenFishies");
FishingInit.CheckPlayerInfo();
-- per user stuff
if ( not FishingBuddy_Player["Settings"] ) then
FishingBuddy_Player["Settings"] = { };
end
FishingInit.UpdateFishingDB();
FishingInit.SetupByFishie();
FishingInit.InitSortHelpers();
FishingInit.SetupSchoolCounts();
end
FishingInit.RegisterMyAddOn = function()
-- Register the addon in myAddOns
if (myAddOnsFrame_Register) then
local details = {
name = FBConstants.ID,
description = FBConstants.DESCRIPTION,
version = FBConstants.VERSION,
releaseDate = 'July 21, 2005',
author = 'Sutorix',
email = 'Windrunner',
category = MYADDONS_CATEGORY_PROFESSIONS,
frame = "FishingBuddy",
optionsframe = "FishingBuddyFrame",
};
myAddOnsFrame_Register(details);
end
end
FishingInit.RegisterFunctionTraps = function()
FishingBuddy.TrapWorldMouse();
end
FishingBuddy.Initialize = function()
if ( FishingInit ) then
-- Set everything up, then dump the code we don't need anymore
playerName, realmName = FishingInit.SetupNameInfo();
FishingInit.RegisterFunctionTraps();
FishingInit.InitSettings();
-- register with myAddOn
FishingInit.RegisterMyAddOn();
gotSetupDone = true;
FishingBuddy.WatchUpdate();
-- debugging state
FishingBuddy.Debugging = FishingBuddy.BaseGetSetting("FishDebug");
-- we don't need these functions anymore, gc 'em
FishingInit = nil;
end
end
PK NKX X &