From 0d2814394221611af7391bda7a84db6bfb3b303b Mon Sep 17 00:00:00 2001 From: LaYt Date: Thu, 2 Feb 2017 15:40:03 +0700 Subject: [PATCH] v1.14 + Added MBB compatibility (better minimap button managment), + Added RUru localization by Maus + backported some fixes from original 1.14 release --- README.md | 30 + RecipeRadar/Availability.lua | 440 +++ RecipeRadar/AvailabilityTooltip.lua | 98 + RecipeRadar/AvailabilityTooltip.xml | 176 + RecipeRadar/Bindings.xml | 7 + RecipeRadar/ChangeLog.txt | 107 + RecipeRadar/DropDowns.lua | 546 +++ RecipeRadar/FrameTemplates.xml | 288 ++ RecipeRadar/Globals.lua | 267 ++ RecipeRadar/Images/Frame/FrameBottomLeft.blp | Bin 0 -> 175972 bytes RecipeRadar/Images/Frame/FrameBottomRight.blp | Bin 0 -> 175972 bytes RecipeRadar/Images/Frame/FrameTopLeft.blp | Bin 0 -> 88580 bytes RecipeRadar/Images/Frame/FrameTopRight.blp | Bin 0 -> 33940 bytes .../Images/Frame/HorizontalBarLeft.blp | Bin 0 -> 6820 bytes .../Images/Frame/HorizontalBarRight.blp | Bin 0 -> 6820 bytes .../Images/Frame/LockButton-Locked-Down.blp | Bin 0 -> 2564 bytes .../Images/Frame/LockButton-Locked-Up.blp | Bin 0 -> 2564 bytes .../Images/Frame/LockButton-Unlocked-Down.blp | Bin 0 -> 2564 bytes .../Images/Frame/LockButton-Unlocked-Up.blp | Bin 0 -> 2564 bytes RecipeRadar/Images/Frame/Tab-Right.blp | Bin 0 -> 1572 bytes RecipeRadar/Images/Icons/Alchemy.blp | Bin 0 -> 1540 bytes RecipeRadar/Images/Icons/Blacksmithing.blp | Bin 0 -> 1540 bytes RecipeRadar/Images/Icons/Cooking.blp | Bin 0 -> 1540 bytes RecipeRadar/Images/Icons/Enchanting.blp | Bin 0 -> 1540 bytes RecipeRadar/Images/Icons/Engineering.blp | Bin 0 -> 1540 bytes RecipeRadar/Images/Icons/First-Aid.blp | Bin 0 -> 1540 bytes RecipeRadar/Images/Icons/Fishing.blp | Bin 0 -> 1540 bytes RecipeRadar/Images/Icons/Highlight.blp | Bin 0 -> 1540 bytes RecipeRadar/Images/Icons/Leatherworking.blp | Bin 0 -> 1540 bytes RecipeRadar/Images/Icons/Tailoring.blp | Bin 0 -> 1540 bytes RecipeRadar/Images/Misc/Flag.blp | Bin 0 -> 1540 bytes RecipeRadar/Images/Misc/IconHighlight.blp | Bin 0 -> 1540 bytes RecipeRadar/Images/Misc/MinimapButtonDown.blp | Bin 0 -> 2564 bytes RecipeRadar/Images/Misc/MinimapButtonUp.blp | Bin 0 -> 2564 bytes RecipeRadar/Images/Misc/QuestionMark.blp | Bin 0 -> 3916 bytes RecipeRadar/Images/Misc/Radar.blp | Bin 0 -> 1540 bytes RecipeRadar/Images/Misc/RecipeHighlight.blp | Bin 0 -> 6820 bytes RecipeRadar/Images/Misc/Scroll.blp | Bin 0 -> 1540 bytes .../Images/Regions/Alterac-Mountains.blp | Bin 0 -> 132244 bytes .../Images/Regions/Arathi-Highlands.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Ashenvale.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Azshara.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Badlands.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Blasted-Lands.blp | Bin 0 -> 132244 bytes .../Images/Regions/Burning-Steppes.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Darkshore.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Darnassus.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Desolace.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Dun-Morogh.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Durotar.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Duskwood.blp | Bin 0 -> 132244 bytes .../Images/Regions/Dustwallow-Marsh.blp | Bin 0 -> 132244 bytes .../Images/Regions/Eastern-Plaguelands.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Elwynn-Forest.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Felwood.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Feralas.blp | Bin 0 -> 132244 bytes .../Images/Regions/Hillsbrad-Foothills.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Ironforge.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Loch-Modan.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Moonglade.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Mulgore.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Orgrimmar.blp | Bin 0 -> 132244 bytes .../Images/Regions/Redridge-Mountains.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Silithus.blp | Bin 0 -> 132244 bytes .../Images/Regions/Silverpine-Forest.blp | Bin 0 -> 132244 bytes .../Images/Regions/Stonetalon-Mountains.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Stormwind-City.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Stormwind.blp | Bin 0 -> 132244 bytes .../Images/Regions/Stranglethorn-Vale.blp | Bin 0 -> 132244 bytes .../Images/Regions/Swamp-of-Sorrows.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Tanaris.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Teldrassil.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/The-Barrens.blp | Bin 0 -> 132244 bytes .../Images/Regions/The-Hinterlands.blp | Bin 0 -> 132244 bytes .../Images/Regions/Thousand-Needles.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Thunder-Bluff.blp | Bin 0 -> 132244 bytes .../Images/Regions/Tirisfal-Glades.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Un-Goro-Crater.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Undercity.blp | Bin 0 -> 132244 bytes .../Images/Regions/Western-Plaguelands.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Westfall.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Wetlands.blp | Bin 0 -> 132244 bytes RecipeRadar/Images/Regions/Winterspring.blp | Bin 0 -> 132244 bytes RecipeRadar/Localization.lua | 1341 +++++++ RecipeRadar/MainFrame.lua | 356 ++ RecipeRadar/Maps.lua | 222 ++ RecipeRadar/Maps.xml | 125 + RecipeRadar/Minimap.lua | 209 ++ RecipeRadar/MinimapButton.lua | 91 + RecipeRadar/MinimapButton.xml | 47 + RecipeRadar/NameMap.lua | 107 + RecipeRadar/OptionsFrame.lua | 207 + RecipeRadar/OptionsFrame.xml | 241 ++ RecipeRadar/README.txt | 69 + RecipeRadar/RadarTab.lua | 498 +++ RecipeRadar/RecipeData.lua | 3328 +++++++++++++++++ RecipeRadar/RecipeRadar.lua | 628 ++++ RecipeRadar/RecipeRadar.toc | 19 + RecipeRadar/RecipeRadar.xml | 826 ++++ RecipeRadar/RecipesTab.lua | 510 +++ RecipeRadar/RegionData.lua | 3055 +++++++++++++++ RecipeRadar/SkillDB.lua | 429 +++ RecipeRadar/Worldmap.lua | 105 + 103 files changed, 14372 insertions(+) create mode 100644 README.md create mode 100644 RecipeRadar/Availability.lua create mode 100644 RecipeRadar/AvailabilityTooltip.lua create mode 100644 RecipeRadar/AvailabilityTooltip.xml create mode 100644 RecipeRadar/Bindings.xml create mode 100644 RecipeRadar/ChangeLog.txt create mode 100644 RecipeRadar/DropDowns.lua create mode 100644 RecipeRadar/FrameTemplates.xml create mode 100644 RecipeRadar/Globals.lua create mode 100644 RecipeRadar/Images/Frame/FrameBottomLeft.blp create mode 100644 RecipeRadar/Images/Frame/FrameBottomRight.blp create mode 100644 RecipeRadar/Images/Frame/FrameTopLeft.blp create mode 100644 RecipeRadar/Images/Frame/FrameTopRight.blp create mode 100644 RecipeRadar/Images/Frame/HorizontalBarLeft.blp create mode 100644 RecipeRadar/Images/Frame/HorizontalBarRight.blp create mode 100644 RecipeRadar/Images/Frame/LockButton-Locked-Down.blp create mode 100644 RecipeRadar/Images/Frame/LockButton-Locked-Up.blp create mode 100644 RecipeRadar/Images/Frame/LockButton-Unlocked-Down.blp create mode 100644 RecipeRadar/Images/Frame/LockButton-Unlocked-Up.blp create mode 100644 RecipeRadar/Images/Frame/Tab-Right.blp create mode 100644 RecipeRadar/Images/Icons/Alchemy.blp create mode 100644 RecipeRadar/Images/Icons/Blacksmithing.blp create mode 100644 RecipeRadar/Images/Icons/Cooking.blp create mode 100644 RecipeRadar/Images/Icons/Enchanting.blp create mode 100644 RecipeRadar/Images/Icons/Engineering.blp create mode 100644 RecipeRadar/Images/Icons/First-Aid.blp create mode 100644 RecipeRadar/Images/Icons/Fishing.blp create mode 100644 RecipeRadar/Images/Icons/Highlight.blp create mode 100644 RecipeRadar/Images/Icons/Leatherworking.blp create mode 100644 RecipeRadar/Images/Icons/Tailoring.blp create mode 100644 RecipeRadar/Images/Misc/Flag.blp create mode 100644 RecipeRadar/Images/Misc/IconHighlight.blp create mode 100644 RecipeRadar/Images/Misc/MinimapButtonDown.blp create mode 100644 RecipeRadar/Images/Misc/MinimapButtonUp.blp create mode 100644 RecipeRadar/Images/Misc/QuestionMark.blp create mode 100644 RecipeRadar/Images/Misc/Radar.blp create mode 100644 RecipeRadar/Images/Misc/RecipeHighlight.blp create mode 100644 RecipeRadar/Images/Misc/Scroll.blp create mode 100644 RecipeRadar/Images/Regions/Alterac-Mountains.blp create mode 100644 RecipeRadar/Images/Regions/Arathi-Highlands.blp create mode 100644 RecipeRadar/Images/Regions/Ashenvale.blp create mode 100644 RecipeRadar/Images/Regions/Azshara.blp create mode 100644 RecipeRadar/Images/Regions/Badlands.blp create mode 100644 RecipeRadar/Images/Regions/Blasted-Lands.blp create mode 100644 RecipeRadar/Images/Regions/Burning-Steppes.blp create mode 100644 RecipeRadar/Images/Regions/Darkshore.blp create mode 100644 RecipeRadar/Images/Regions/Darnassus.blp create mode 100644 RecipeRadar/Images/Regions/Desolace.blp create mode 100644 RecipeRadar/Images/Regions/Dun-Morogh.blp create mode 100644 RecipeRadar/Images/Regions/Durotar.blp create mode 100644 RecipeRadar/Images/Regions/Duskwood.blp create mode 100644 RecipeRadar/Images/Regions/Dustwallow-Marsh.blp create mode 100644 RecipeRadar/Images/Regions/Eastern-Plaguelands.blp create mode 100644 RecipeRadar/Images/Regions/Elwynn-Forest.blp create mode 100644 RecipeRadar/Images/Regions/Felwood.blp create mode 100644 RecipeRadar/Images/Regions/Feralas.blp create mode 100644 RecipeRadar/Images/Regions/Hillsbrad-Foothills.blp create mode 100644 RecipeRadar/Images/Regions/Ironforge.blp create mode 100644 RecipeRadar/Images/Regions/Loch-Modan.blp create mode 100644 RecipeRadar/Images/Regions/Moonglade.blp create mode 100644 RecipeRadar/Images/Regions/Mulgore.blp create mode 100644 RecipeRadar/Images/Regions/Orgrimmar.blp create mode 100644 RecipeRadar/Images/Regions/Redridge-Mountains.blp create mode 100644 RecipeRadar/Images/Regions/Silithus.blp create mode 100644 RecipeRadar/Images/Regions/Silverpine-Forest.blp create mode 100644 RecipeRadar/Images/Regions/Stonetalon-Mountains.blp create mode 100644 RecipeRadar/Images/Regions/Stormwind-City.blp create mode 100644 RecipeRadar/Images/Regions/Stormwind.blp create mode 100644 RecipeRadar/Images/Regions/Stranglethorn-Vale.blp create mode 100644 RecipeRadar/Images/Regions/Swamp-of-Sorrows.blp create mode 100644 RecipeRadar/Images/Regions/Tanaris.blp create mode 100644 RecipeRadar/Images/Regions/Teldrassil.blp create mode 100644 RecipeRadar/Images/Regions/The-Barrens.blp create mode 100644 RecipeRadar/Images/Regions/The-Hinterlands.blp create mode 100644 RecipeRadar/Images/Regions/Thousand-Needles.blp create mode 100644 RecipeRadar/Images/Regions/Thunder-Bluff.blp create mode 100644 RecipeRadar/Images/Regions/Tirisfal-Glades.blp create mode 100644 RecipeRadar/Images/Regions/Un-Goro-Crater.blp create mode 100644 RecipeRadar/Images/Regions/Undercity.blp create mode 100644 RecipeRadar/Images/Regions/Western-Plaguelands.blp create mode 100644 RecipeRadar/Images/Regions/Westfall.blp create mode 100644 RecipeRadar/Images/Regions/Wetlands.blp create mode 100644 RecipeRadar/Images/Regions/Winterspring.blp create mode 100644 RecipeRadar/Localization.lua create mode 100644 RecipeRadar/MainFrame.lua create mode 100644 RecipeRadar/Maps.lua create mode 100644 RecipeRadar/Maps.xml create mode 100644 RecipeRadar/Minimap.lua create mode 100644 RecipeRadar/MinimapButton.lua create mode 100644 RecipeRadar/MinimapButton.xml create mode 100644 RecipeRadar/NameMap.lua create mode 100644 RecipeRadar/OptionsFrame.lua create mode 100644 RecipeRadar/OptionsFrame.xml create mode 100644 RecipeRadar/README.txt create mode 100644 RecipeRadar/RadarTab.lua create mode 100644 RecipeRadar/RecipeData.lua create mode 100644 RecipeRadar/RecipeRadar.lua create mode 100644 RecipeRadar/RecipeRadar.toc create mode 100644 RecipeRadar/RecipeRadar.xml create mode 100644 RecipeRadar/RecipesTab.lua create mode 100644 RecipeRadar/RegionData.lua create mode 100644 RecipeRadar/SkillDB.lua create mode 100644 RecipeRadar/Worldmap.lua diff --git a/README.md b/README.md new file mode 100644 index 0000000..319dfe0 --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +# Recipe Radar + +##Description +Recipe Radar is a World of Warcraft UI addon that assists players in finding recipes. It knows about vendors who sell recipes in the current region or by profession. It has a number of filtering options and can even locate vendors on the world map. + + +![Main Window](http://imgur.com/5Dw3mCH) + + +When you get in game, you may want to map a key to toggle Recipe Radar. +You should be able to find the option to do this in your Key Bindings menu, +all the way at the bottom. Otherwise, you can hit the new icon on your +minimap to open Recipe Radar or use the slash command, '/rrdr'. + +#Last changes: + +- Added MBB compatibility (better minimap button managment), +- Added RUru localization by Maus + +#Download + +https://github.com/laytya/RecipeRadar-vanilla + +#Installation + +Just copy "RecipeRadar" folder to your addon's directory. + +#Credits + +originaly made by Jay Miller [jnmiller@cryptofreak.org] diff --git a/RecipeRadar/Availability.lua b/RecipeRadar/Availability.lua new file mode 100644 index 0000000..5d581f1 --- /dev/null +++ b/RecipeRadar/Availability.lua @@ -0,0 +1,440 @@ + +-- Availability.lua: logic for the availability of recipes to characters +-- $Id: Availability.lua 451 2006-09-11 03:23:04Z jnmiller $ + +----------------------------------------------------------------------------- +-- Generic, abstracted availability entry points +----------------------------------------------------------------------------- + +function RecipeRadar_Availability_Init() + + if (RecipeRadar_Options.RealmAvailability) then + RecipeRadar_RealmAvailDropDown:Show() + RecipeRadar_PersonAvailDropDown:Hide() + else + RecipeRadar_PersonAvailDropDown:Show() + RecipeRadar_RealmAvailDropDown:Hide() + end + +end + +function RecipeRadar_Availability_Toggle() + + if (RecipeRadar_RealmAvailDropDown:IsVisible()) then + RecipeRadar_PersonAvailDropDown:Show() + RecipeRadar_RealmAvailDropDown:Hide() + RecipeRadar_Options.RealmAvailability = false + else + RecipeRadar_RealmAvailDropDown:Show() + RecipeRadar_PersonAvailDropDown:Hide() + RecipeRadar_Options.RealmAvailability = true + end + + RecipeRadar_FrameUpdate() + +end + +----------------------------------------------------------------------------- +-- Indicator for vendor/recipe item lists +----------------------------------------------------------------------------- + +-- Returns a colored indication of a recipe's availability. +function RecipeRadar_Availability_GetIndicator(recipe) + + if (RecipeRadar_Options.RealmAvailability) then + return RecipeRadar_RealmAvail_GetIndicator(recipe) + else + return RecipeRadar_PersonAvail_GetIndicator(recipe) + end + +end + +-- Returns a string with the recipe's skill in parens. +function RecipeRadar_PersonAvail_GetIndicator(recipe) + + return format(TEXT(PARENS_TEMPLATE), recipe.Skill) + +end + +-- Returns a string with a little colored realm-wide availability +-- indicator for the main vendor/recipe list. +function RecipeRadar_RealmAvail_GetIndicator(recipe) + + local key = RecipeRadar_Availability_GetKey(recipe) + if (not key) then return "" end + + return RecipeRadar_ColorToCode(RecipeRadar_Availabilities[key].Color) .. + "*" .. FONT_COLOR_CODE_CLOSE + +end + +----------------------------------------------------------------------------- +-- Availability tooltip code +----------------------------------------------------------------------------- + +-- Populates the tooltip that displays on recipe button mouseover. +function RecipeRadar_Availability_CreateTooltip(recipe) + + local recipe_name = RecipeRadar_GetSafeItemInfo(recipe.ID) + + if (recipe_name == RRS("Uncached Recipe")) then + + -- uncached recipes have a special tooltip and warning + -- I'm just coloring 'Warning:' red here for max contrast + local warn = RRS("Warning: if your server has") + local colon = string.find(warn, ":") + local warning = + RecipeRadar_ColorToCode(RecipeRadar_Colors.TooltipWarning) .. + string.sub(warn, 1, colon) .. FONT_COLOR_CODE_CLOSE .. + string.sub(warn, colon + 1) + + -- the layout of the tooltip, with colors for each line + local tooltip = { + { text = RRS("Uncached Recipe"), color = RecipeRadar_Colors.UncachedRecipe }, + { text = "", color = nil }, + { text = RRS("You may mouse over the [?]"), color = RecipeRadar_Colors.TooltipHeading }, + { text = RRS("icon to lookup this recipe."), color = RecipeRadar_Colors.TooltipHeading }, + { text = "", color = nil }, + { text = warning, color = RecipeRadar_Colors.TooltipHeading }, + { text = RRS("not yet seen this item, you"), color = RecipeRadar_Colors.TooltipHeading }, + { text = RRS("will be disconnected!"), color = RecipeRadar_Colors.TooltipHeading }, } + for _, line in tooltip do + RecipeRadar_AvailabilityTooltip_AddLine(line.text, line.color) + end + return + + end + + local avail, prosp, known, line_info = { }, { }, { }, { } + local num_avail, num_prosp, num_known = 0, 0, 0 + + -- recipe labels are not saved in the skill database + recipe_name = RecipeRadar_TrimRecipeLabel(recipe_name) + + -- iterate through each character on this realm + for player, player_info in RecipeRadar_SkillDB[GetRealmName()] do + + -- do the rest only if the character has the profession + if (player_info.Professions[recipe.Type] and + player_info.Professions[recipe.Type].Rank > 0) then + + -- get player's rank + local rank = player_info.Professions[recipe.Type].Rank + + -- get player's relevant faction standing, if any + local rep = nil + if (recipe.Faction and player_info.Factions[recipe.Faction]) then + rep = getglobal("FACTION_STANDING_LABEL" .. + player_info.Factions[recipe.Faction]) + end + + -- get player's specialty, if any + local spec = nil + if (recipe.Specialty) then + spec = player_info.Professions[recipe.Type].Specialty + end + + -- now test all of the possible recipe statuses + if (RecipeRadar_Availability_IsAvailable(player, recipe)) then + num_avail = num_avail + 1 + avail[num_avail] = { + Name = player, Rank = rank, Rep = rep, Spec = spec } + + elseif (RecipeRadar_Availability_IsProspect(player, recipe)) then + num_prosp = num_prosp + 1 + prosp[num_prosp] = { + Name = player, Rank = rank, Rep = rep, Spec = spec } + + elseif (RecipeRadar_Availability_IsKnown(player, recipe)) then + num_known = num_known + 1 + known[num_known] = { + Name = player, Rank = rank, Rep = rep, Spec = spec } + + else + local bleh = 0 + if (knows) then bleh = 1 end + RecipeRadar_Print("ASSERT FAILED: " .. player .. " - " .. + recipe.Type .. ", " .. recipe_name .. ", " .. recipe.Skill .. + " (have " .. rank .. ") knows = " .. bleh) + end + + end + + end + + -- populate the "available now" entries + if (num_avail > 0) then + + RecipeRadar_AvailabilityTooltip_AddLine( + RecipeRadar_Availabilities["LearnableByPlayer"].Tooltip.Heading, + RecipeRadar_Colors.TooltipHeading) + table.sort(avail, RecipeRadar_Availability_NameSort) + + for _, line in avail do + + local color = RecipeRadar_Colors.LearnableByAlt + if (line.Name == UnitName("player")) then + color = RecipeRadar_Colors.LearnableByPlayer + end + + local rank_suffix = line.Rank + if (line.Rep) then -- reputation is relevant to this line + rank_suffix = rank_suffix .. " - " .. line.Rep + end + rank_suffix = format(TEXT(PARENS_TEMPLATE), rank_suffix) + + RecipeRadar_AvailabilityTooltip_AddLine( + " " .. line.Name .. " " .. rank_suffix, color) + + end + + end + + -- populate the "available soon" entries + if (num_prosp > 0) then + + if (num_avail > 0) then + RecipeRadar_AvailabilityTooltip_AddLine() + end + RecipeRadar_AvailabilityTooltip_AddLine( + RecipeRadar_Availabilities["ProspectForPlayer"].Tooltip.Heading, + RecipeRadar_Colors.TooltipHeading) + table.sort(prosp, RecipeRadar_Availability_NameSort) + + for _, line in prosp do + + local color = RecipeRadar_Colors.ProspectForAlt + if (line.Name == UnitName("player")) then + color = RecipeRadar_Colors.ProspectForPlayer + end + + local factors = RecipeRadar_Availability_GetLimitingFactors( + line.Name, recipe) + + local rank = string.format(RRS("%d of %d"), line.Rank, recipe.Skill) + if (factors["rank"]) then + rank = RecipeRadar_HighlightString(rank, color) + end + local suffix = rank -- always include rank in the tooltip + + if (line.Rep) then + local rep = line.Rep + if (factors["rep"]) then + rep = RecipeRadar_HighlightString(rep, color) + end + suffix = suffix .. " - " .. rep + end + + if (line.Spec) then + local spec = line.Spec + if (factors["spec"]) then + spec = RecipeRadar_HighlightString(spec, color) + end + suffix = suffix .. " - " .. spec + end + + suffix = format(TEXT(PARENS_TEMPLATE), suffix) + RecipeRadar_AvailabilityTooltip_AddLine( + " " .. line.Name .. " " .. suffix, color) + + end + + end + + -- populate the "already known" entries + if (num_known > 0) then + + if (num_prosp > 0 or num_avail > 0) then + RecipeRadar_AvailabilityTooltip_AddLine() + end + RecipeRadar_AvailabilityTooltip_AddLine( + RecipeRadar_Availabilities["KnownByPlayer"].Tooltip.Heading, + RecipeRadar_Colors.TooltipHeading) + table.sort(known, RecipeRadar_Availability_NameSort) + + for _, line in known do + + local color = RecipeRadar_Colors.KnownByAlt + if (line.Name == UnitName("player")) then + color = RecipeRadar_Colors.KnownByPlayer + end + + local rank_suffix = line.Rank + if (line.Rep) then -- reputation is relevant to this line + rank_suffix = rank_suffix .. " - " .. line.Rep + end + rank_suffix = format(TEXT(PARENS_TEMPLATE), rank_suffix) + + RecipeRadar_AvailabilityTooltip_AddLine( + " " .. line.Name .. " " .. rank_suffix, color) + + end + + end + +end + +-- Boolean test for availability used by CreateTooltip(), above +function RecipeRadar_Availability_NameSort(line1, line2) + + return line1.Name < line2.Name + +end + +-- Returns a set of booleans from which one can derive the availability +-- of any recipe relative to any player. +function RecipeRadar_Availability_GetBooleans(player, recipe) + + local info = RecipeRadar_SkillDB_GetSafePlayerDB(player) + + -- if the player doesn't even have the profession, just return + if (not info.Professions[recipe.Type]) then return false end + + local recipe_name = RecipeRadar_GetSafeItemInfo(recipe.ID) + recipe_name = RecipeRadar_TrimRecipeLabel(recipe_name) + + if (recipe_name == RRS("Uncached Recipe")) then + return nil + end + + -- otherwise, get the other relevant booleans + local has_rec = info.Professions[recipe.Type].Recipes[recipe_name] + local has_rank = info.Professions[recipe.Type].Rank >= recipe.Skill + local has_rep = RecipeRadar_SkillDB_HasRep(player, recipe) + local has_spec = RecipeRadar_SkillDB_HasSpec(player, recipe) + + return true, has_rec, has_rank, has_rep, has_spec + +end + +-- Boolean test for availability used by CreateTooltip() and GetKey() +function RecipeRadar_Availability_IsAvailable(player, recipe) + + local has_prof, has_rec, has_rank, has_rep, has_spec = + RecipeRadar_Availability_GetBooleans(player, recipe) + + return (has_prof and not has_rec and has_rank and has_rep and has_spec) + +end + +-- Boolean test for availability used by CreateTooltip() and GetKey() +function RecipeRadar_Availability_IsProspect(player, recipe) + + local has_prof, has_rec, has_rank, has_rep, has_spec = + RecipeRadar_Availability_GetBooleans(player, recipe) + + return (has_prof and not has_rec and + (not has_rank or not has_rep or not has_spec)) + +end + +-- Boolean test for availability used by CreateTooltip() and GetKey() +function RecipeRadar_Availability_IsKnown(player, recipe) + + local has_prof, has_rec, has_rank, has_rep, has_spec = + RecipeRadar_Availability_GetBooleans(player, recipe) + + return (has_prof and has_rec and has_rank and has_rep and has_spec) + +end + +-- Returns a table of strings that specify why the given recipe is not +-- available to the given player. +function RecipeRadar_Availability_GetLimitingFactors(player, recipe) + + local has_prof, has_rec, has_rank, has_rep, has_spec = + RecipeRadar_Availability_GetBooleans(player, recipe) + local factors = { } + + if (not has_prof) then factors["prof"] = 1 end + if (not has_rec) then factors["rec"] = 1 end + if (not has_rank) then factors["rank"] = 1 end + if (not has_rep) then factors["rep"] = 1 end + if (not has_spec) then factors["spec"] = 1 end + + return factors + +end + +----------------------------------------------------------------------------- +-- Availability testing for filtering and dropdowns +----------------------------------------------------------------------------- + +-- This function tests whether the recipe is learnable either by +-- the player or an alt if realm-wide availability is on. +function RecipeRadar_Availability_IsLearnable(recipe, set_filter) + + local name = RecipeRadar_GetSafeItemInfo(recipe.ID) + + local avail = RecipeRadar_Availability_GetKey(recipe) + if (not avail) then return false end + + if (set_filter) then + recipe.IsFilteredByAvailability = + RecipeRadar_IsAvailabilityFiltered(avail) + end + + if (RecipeRadar_Options.RealmAvailability) then + return avail == "LearnableByPlayer" or avail == "LearnableByAlt" + else + return avail == "LearnableByPlayer" + end + +end + +-- Wrapper for the above that makes its functionality clearer. +function RecipeRadar_Availability_SetAvailabilityFilter(recipe) + + RecipeRadar_Availability_IsLearnable(recipe, true) + +end + +-- Generic function returns the key to the RecipeRadar_Availabilities +-- table so the caller can get whatever related info she needs. +function RecipeRadar_Availability_GetKey(recipe) + + if (RecipeRadar_Availability_IsAvailable(player, recipe)) then + return "LearnableByPlayer" + + elseif (RecipeRadar_Options.RealmAvailability and + RecipeRadar_Availability_IsSatisfiedByAlt(recipe, + RecipeRadar_Availability_IsAvailable)) then + return "LearnableByAlt" + + elseif (RecipeRadar_Availability_IsProspect(player, recipe)) then + return "ProspectForPlayer" + + elseif (RecipeRadar_Options.RealmAvailability and + RecipeRadar_Availability_IsSatisfiedByAlt(recipe, + RecipeRadar_Availability_IsProspect)) then + return "ProspectForAlt" + + elseif (RecipeRadar_Availability_IsKnown(player, recipe)) then + return "KnownByPlayer" + + elseif (RecipeRadar_Options.RealmAvailability and + RecipeRadar_Availability_IsSatisfiedByAlt(recipe, + RecipeRadar_Availability_IsKnown)) then + return "KnownByAlt" + + else + return "NotApplicable" + end + +end + +-- Boolean test for availability used by GetKey(), above. +function RecipeRadar_Availability_IsSatisfiedByAlt(recipe, sat_func) + + for player, player_info in RecipeRadar_SkillDB[GetRealmName()] do + + if (player_info.Team ~= RecipeRadar_GetOpposingFaction("player") and + player ~= UnitName("player") and + sat_func(player, recipe)) then + return true + end + + end + return false + +end diff --git a/RecipeRadar/AvailabilityTooltip.lua b/RecipeRadar/AvailabilityTooltip.lua new file mode 100644 index 0000000..7ba415b --- /dev/null +++ b/RecipeRadar/AvailabilityTooltip.lua @@ -0,0 +1,98 @@ + +-- AvailabilityTooltip.lua: handles the recipe availability tooltip +-- $Id: AvailabilityTooltip.lua 282 2006-04-12 08:41:25Z jnmiller $ + +function RecipeRadar_AvailabilityTooltip_AddLine(msg, color) + + if (RecipeRadarAvailabilityTooltip.Lines == + RecipeRadar_AvailabilityTooltip_MaxLines) then + RecipeRadar_Print("ASSERT FAILED: tooltip has too many lines.") + return + end + + local line_num = RecipeRadarAvailabilityTooltip.Lines + 1 + local line = getglobal("RecipeRadarAvailabilityTooltipText" .. line_num) + + -- handle null colors + if (color) then + line:SetTextColor(color.r, color.g, color.b) + else + line:SetTextColor(1, 1, 1) + end + + -- handle null messages + if (not msg or msg == "") then + line:SetText(" ") + else + line:SetText(msg) + end + + line:Show() + + RecipeRadarAvailabilityTooltip.Lines = line_num + +end + +function RecipeRadar_AvailabilityTooltip_Show(frame) + + if (not frame or RecipeRadarAvailabilityTooltip.Lines == 0) then + RecipeRadar_AvailabilityTooltip_Hide() + return + end + + -- calculate the width of the tooltip + local height = 20 + local width = 0 + for i = 1, RecipeRadarAvailabilityTooltip.Lines do + local line = getglobal("RecipeRadarAvailabilityTooltipText" .. i) + height = height + line:GetHeight() + 2 + if (line:GetWidth() + 20 > width) then + width = line:GetWidth() + 20 + end + end + + RecipeRadarAvailabilityTooltip:SetWidth(width) + RecipeRadarAvailabilityTooltip:SetHeight(height) + RecipeRadarAvailabilityTooltip:ClearAllPoints() + + -- place on the left or right according to the position of the main frame + local frame_left = (frame:GetLeft() or 0) - width + local frame_right = GetScreenWidth() - (frame:GetRight() or 0) - width + + local offset = 0 + if (RecipeRadar_Options.ActiveTab == 2) then + offset = RECIPERADAR_VENDOR_OFFSET + end + + if (frame_left < frame_right) then + if (RecipeRadarListScrollFrame:IsVisible()) then + RecipeRadarAvailabilityTooltip:SetPoint( + "TOPLEFT", frame:GetName(), "TOPRIGHT", 35, 0) + else + RecipeRadarAvailabilityTooltip:SetPoint( + "TOPLEFT", frame:GetName(), "TOPRIGHT", 13, 0) + end + else + RecipeRadarAvailabilityTooltip:SetPoint( + "TOPRIGHT", frame:GetName(), "TOPLEFT", -33 + offset, 0) + end + + -- basic drawing code + RecipeRadarAvailabilityTooltip:SetBackdropColor( + TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, + TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, + TOOLTIP_DEFAULT_BACKGROUND_COLOR.b) + RecipeRadarAvailabilityTooltip:Show() + +end + +function RecipeRadar_AvailabilityTooltip_Hide() + + for i = 1, RecipeRadarAvailabilityTooltip.Lines do + getglobal("RecipeRadarAvailabilityTooltipText" .. i):Hide() + end + + RecipeRadarAvailabilityTooltip.Lines = 0 + --RecipeRadarAvailabilityTooltip:Hide() + +end diff --git a/RecipeRadar/AvailabilityTooltip.xml b/RecipeRadar/AvailabilityTooltip.xml new file mode 100644 index 0000000..a8c77b4 --- /dev/null +++ b/RecipeRadar/AvailabilityTooltip.xml @@ -0,0 +1,176 @@ + + + + +