• 0

    posted a message on FuBar - TrackerFu Lives!
    This is my TrackerFu, it is based on the post above me. Additional change: Show icon instead of checkmark, highlight the text yellow for the active tracking.

    local dewdrop = AceLibrary("Dewdrop-2.0")
    local tablet = AceLibrary("Tablet-2.0")
    local L = AceLibrary("AceLocale-2.2"):new("FuBar_TrackerFu")
    
    local optionsTable = {
    	type = 'group',
    	args = {
    		showMinimap = {
    			order = 10,
    			type = 'toggle',
    			name = L["TRACKER_SHOW_MINIMAP"],
    			desc = L["TRACKER_SHOW_MINIMAP"],
    			set = "ToggleShowMiniMap",
    			get = "IsShowingMiniMap",
    		},		
    	}	
    }
    
    TrackerFu = AceLibrary("AceAddon-2.0"):new("FuBarPlugin-2.0", "AceEvent-2.0", "AceConsole-2.0", "AceDB-2.0")
    TrackerFu.hasIcon = true
    TrackerFu.clickableTooltip = true
    TrackerFu.cannotDetachTooltip = true
    
    TrackerFu.OnMenuRequest = optionsTable
    
    TrackerFu:RegisterDB("TrackerFuDB")
    TrackerFu:RegisterDefaults('profile', {
    	showMiniMap = false
    })
    
    -- Methods
    function TrackerFu:IsShowingMiniMap()
    	return self.db.profile.showMiniMap
    end
    	
    function TrackerFu:ToggleShowMiniMap()
    	self.db.profile.showMiniMap = not self.db.profile.showMiniMap
    	if ( self.db.profile.showMiniMap ) then
    		MiniMapTracking:Show()
    	else
    		MiniMapTracking:Hide()
    	end
    	return self.db.profile.showMiniMap
    end
    
    function TrackerFu:OnEnable()
    	self:RegisterEvent("MINIMAP_UPDATE_TRACKING")
    end
    
    function TrackerFu:MINIMAP_UPDATE_TRACKING()
    	self:Update()
    end
    
    function TrackerFu:OnTextUpdate()
    	self:SetIcon(GetTrackingTexture())
    
    	local name, texture, active, category;
    	local anyActive, checked;
    	local count = GetNumTrackingTypes();
    
    	local have_active = 0;
    	for id=1, count do
    		name, texture, active, category = GetTrackingInfo(id);
    		if ( active ) then
    			self:SetText(name);
    			have_active=1;
    		end
    	end
    	if (have_active == 0) then
       self:SetText(L["TRACKER_NOTTRACKING"]);
    	end
    	if ( self.db.profile.showMiniMap ) then
    		MiniMapTracking:Show()
    	else
    		MiniMapTracking:Hide()
    	end	
    end
    
    function TrackerFu:OnTooltipUpdate()
    	
    	local cat = {};
    
    	cat['other'] = tablet:AddCategory(
    		'columns', 1
    	)
    	
    	local name, texture, active, category;
    	local anyActive, checked;
    	local count = GetNumTrackingTypes();
    
    	local is_spell=0;
    	local is_trade=0;
    	local is_npc=0;
    	for id=1, count do
    		name, texture, active, category = GetTrackingInfo(id);
    
    		local line = {};
    		
    		line['justify'] = "LEFT";
    		line['text'] = name;
    
    		line['func'] = SetTracking;
    		line['arg1'] = id;
    		line['hasCheck'] = true;
    		line['checked'] = true;
    		line['checkIcon'] = texture;
    		
    		line['textR'] = active and 1 or 1;
    		line['textG'] = active and 0.82 or 1;
    		line['textB'] = active and 0 or 1;
    		
    		if ( name == L["TRACKER_SPELL_FIND_FISH"] or name == L["TRACKER_SPELL_FIND_HERBS"] or name == L["TRACKER_SPELL_FIND_MINERALS"] or name == L["TRACKER_SPELL_FIND_TREASURE"] ) then
    			if (is_trade == 0) then
    			cat['trades'] = tablet:AddCategory(
    			  'columns', 1
    			)
    			cat['trades']:AddLine(
    				'justify', 'LEFT',
    				'text', L["TRACKER_TRADESKILL_HEADER"]
    			);
    			is_trade = 1;
    			end
    			cat['trades']:AddLine(line);
    		elseif ( category == 'spell' ) then
    			if (is_spell == 0) then
    			cat['spell'] = tablet:AddCategory(
    			  'columns', 1
    			)
    			cat['spell']:AddLine(
    				'justify', 'LEFT',
    				'text', L["TRACKER_ENEMY_HEADER"]
    			);
    			is_spell = 1;
    			end
    			cat['spell']:AddLine(line);
    		elseif ( category == 'other' ) then
    			if (is_npc == 0) then
    			cat['npc'] = tablet:AddCategory(
    			  'columns', 1
    			)
    			cat['npc']:AddLine(
    				'justify', 'LEFT',
    				'text', L["TRACKER_NPC_HEADER"]
    			);
    			is_npc = 1;
    			end
    			cat['npc']:AddLine(line);
    		end
    		
    		if ( active ) then
    			anyActive = active;
    		end
    	end
    	
    	line = {};	
    	
    	line['justify'] = "LEFT";
    	line['text'] = NONE;
    
    	line['func'] = SetTracking;
    	line['arg1'] = nil;
    	line['hasCheck'] = true;
    
    	line['textR'] = anyActive and 1 or 1;
    	line['textG'] = anyActive and 1 or 0.82;
    	line['textB'] = anyActive and 1 or 0;
    	
    	cat['other'] = tablet:AddCategory(
    		'columns', 1,
    		'hideBlankLine', true
    	)
    	cat['other']:AddLine('justify', 'LEFT',	'text', " ");
    	cat['other']:AddLine(line)			
    
    end


    localization:
    local L = AceLibrary("AceLocale-2.2"):new("FuBar_TrackerFu")
    
    L:RegisterTranslations("enUS", function() return {
    	TRACKER_SHOW_MINIMAP = "Show Minimap Tracking Icon",
    	
    	TRACKER_TRADESKILL_HEADER = "Trade Skills",
    	TRACKER_ENEMY_HEADER   = "Track Enemies",
    	TRACKER_NPC_HEADER    = "Find NPCs",
    	
    	TRACKER_SPELL_FIND_FISH   = "Find Fish",
    	TRACKER_SPELL_FIND_HERBS  = "Find Herbs",
    	TRACKER_SPELL_FIND_MINERALS = "Find Minerals",
    	TRACKER_SPELL_FIND_TREASURE = "Find Treasure",
    	
    	TRACKER_NOTTRACKING					= "Not Tracking",
    } end )
    Posted in: FuBar AddOns
  • To post a comment, please or register a new account.