view Modules/Options.lua @ 9:374dd1a90d02

Changed the way things are stored so that items known only by name, usually from AH mail, will be stored by their name, but will get converted if the link is discovered through a tooltip. This version is funcioning again
author Asa Ayers <Asa.Ayers@Gmail.com>
date Fri, 25 Jun 2010 01:17:58 -0700
parents bbba2fae0f69
children 6a6296dd249f
line wrap: on
line source
 local addonName, addonTable = ...; 
local addon = _G[addonName]

local utils = addonTable.utils

local options = {
	name = "ItemAuditor",
	handler = addon,
	type = 'group',
	args = {
		debug = {
			type = "toggle",
			name = "Debug",
			desc = "Toggles debug messages in chat",
			handler = utils,
			get = "GetDebug",
			set = "SetDebug"
		},
		dump = {
			type = "execute",
			name = "dump",
			desc = "dumps IA database",
			func = "DumpInfo",
		},
		options = {
			type = "execute",
			name = "options",
			desc = "Show Blizzard's options GUI",
			func = "ShowOptionsGUI",
			guiHidden = true,
		},
	},
}

function addon:RegisterOptions()
	self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ItemAuditor", "ItemAuditor")
	LibStub("AceConfig-3.0"):RegisterOptionsTable("ItemAuditor", options, {"ia"})
end

local function pairsByKeys (t, f)
	local a = {}
		for n in pairs(t) do table.insert(a, n) end
		table.sort(a, f)
		local i = 0      -- iterator variable
		local iter = function ()   -- iterator function
			i = i + 1
			if a[i] == nil then return nil
			else return a[i], t[a[i]]
			end
		end
	return iter
end

function addon:DumpInfo()
	for itemName, value in pairsByKeys(self.db.factionrealm.item_account) do
		self:Print(itemName .. ": " .. utils:FormatMoney(value))
	end
end


function addon:ShowOptionsGUI()
	InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
end

function addon:GetDebug(info)
       return self.db.char.debug
end

function addon:SetDebug(info, input)
       self.db.char.debug = input
       local value = "off"
       if input then
               value = "on"
       end
       self:Print("Debugging is now: " .. value)
end