WoWInterface SVN Ranch

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 21 to Rev 22
    Reverse comparison

Rev 21 → Rev 22

trunk/ranch.lua
5,25 → 5,20
-- Create reference to the LDB Libarary
local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
 
-- Create a local variable to hold the Ranch Icon.
local ranchIcon = "Interface\\Addons\\Ranch\\Ranch.tga"
 
-- Create a local table to hold references to the options buttons.
local ranchInterface = {}
 
-- Register the data source.
local dataobj = ldb:NewDataObject("Ranch", {type = "data source", icon = "Interface\\Addons\\Ranch\\Ranch.tga", text = "Ranch"})
local dataobj = ldb:NewDataObject("Ranch", {type = "data source", icon = ranchIcon, text = "Ranch"})
 
-- Create a frame and register the "VARIABLES_LOADED" event on it.
CreateFrame("Frame", "RanchFrame");
RanchFrame:SetScript("OnEvent", function(self, event, ...) getglobal("Ranch_"..event)(event, ...) end);
RanchFrame:RegisterEvent("VARIABLES_LOADED")
 
if GetLocale() == "deDE" then
ranch_QGT = "Dieser Gegenstand startet eine Quest."
elseif GetLocale() == "esES" or GetLocale() == "esMX" then
ranch_QGT = "Este objeto inicia una misión"
elseif GetLocale() == "frFR" then
ranch_QGT = "Cet objet permet de lancer une quête"
else
ranch_QGT = "This Item Begins a Quest"
end
 
 
-- Event handler for the VARIABLES_LOADED event.
function Ranch_VARIABLES_LOADED(event, ...)
 
48,31 → 43,30
ranch_options = {}
end
 
-- Create the list of types, if it doesn't exist.
if ranch_options["types"] == nil then
ranch_options["types"] = {}
-- Create a local table to hold the default option values.
local rtemp_opts = {
["types"] = {},
["displayitems"] = true,
["mergeitems"] = false,
["questitems"] = true,
["ldbicon"] = true,
["ldbtext"] = true,
["ldbname"] = true,
}
 
-- Run through the default settings, copying any that don't currently exist to the user's settings.
local k, v
for k, v in pairs(rtemp_opts) do
if ranch_options[k] == nil then
ranch_options[k] = v
end
end
 
-- Create display items option, if it doesn't exist.
if ranch_options["displayitems"] == nil then
ranch_options["displayitems"] = true
 
-- If the user has chosen to hide the LDB text, then do so now.
if not ranch_options["ldbtext"] then
dataobj.text = ""
end
 
-- Create merge items option, if it doesn't exist.
if ranch_options["mergeitems"] == nil then
ranch_options["mergeitems"] = false
end
 
-- Create the quest giving items option, if it doesn't exist.
if ranch_options["questitems"] == nil then
ranch_options["questitems"] = true
end
 
--Create the LDB text option, if it doesn't exist
if ranch_options["ldbtext"] == nil then
ranch_options["ldbtext"] = true
end
 
-- Create an empty table to hold any temporary items.
ranch_temp = {}
 
95,24 → 89,26
displayitems:SetChecked(ranch_options["displayitems"])
 
-- Add Merge Items option.
local mergeitems = LibStub("tekKonfig-Checkbox").new(RanchItemOptions, nil, "Merge BoE items?", "TOPLEFT", displayitems, "BOTTOMLEFT", -2, -8)
local mergeitems = LibStub("tekKonfig-Checkbox").new(RanchItemOptions, nil, "Merge BoE items?", "TOPLEFT", displayitems, "BOTTOMLEFT", 0, -8)
local checksound = mergeitems:GetScript("OnClick")
mergeitems:SetScript("OnClick", function(self) checksound(self); ranch_options["mergeitems"] = not ranch_options["mergeitems"]; end)
mergeitems:SetChecked(ranch_options["mergeitems"])
 
-- Add Quest Giving Items option
local questitems = LibStub("tekKonfig-Checkbox").new(RanchItemOptions, nil, "Show items that give quests?", "TOPLEFT", mergeitems, "BOTTOMLEFT", -2, -8)
local questitems = LibStub("tekKonfig-Checkbox").new(RanchItemOptions, nil, "Show items that give quests?", "TOPLEFT", mergeitems, "BOTTOMLEFT", 0, -8)
local checksound = questitems:GetScript("OnClick")
questitems:SetScript("OnClick", function(self) checksound(self); ranch_options["questitems"] = not ranch_options["questitems"]; end)
questitems:SetChecked(ranch_options["questitems"])
 
-- Add Display LDB text option
--[[ Add Display LDB text option
local ldbtext = LibStub("tekKonfig-Checkbox").new(RanchItemOptions, nil, "Display LDB text when not tracking anything?", "TOPLEFT", questitems, "BOTTOMLEFT", -2, -8)
local checksound = ldbtext:GetScript("OnClick")
ldbtext:SetScript("OnClick", function(self) checksound(self); ranch_options["ldbtext"] = not ranch_options["ldbtext"]; Ranch_BAG_UPDATE(nil); end)
ldbtext:SetChecked(ranch_options["ldbtext"])
 
RanchItemOptions:SetScript("OnShow", function(self) displayitems:SetChecked(ranch_options["displayitems"]); mergeitems:SetChecked(ranch_options["mergeitems"]); questitems:SetChecked(ranch_options["questitems"]) end)
ldbtext:SetChecked(ranch_options["ldbtext"]) --]]
 
-- Add an "OnShow" script to ensure the options are displayed correctly.
--RanchItemOptions:SetScript("OnShow", function(self) displayitems:SetChecked(ranch_options["displayitems"]); mergeitems:SetChecked(ranch_options["mergeitems"]); questitems:SetChecked(ranch_options["questitems"]) end)
 
-- Add Items Options to the Interface Menu.
InterfaceOptions_AddCategory(RanchItemOptions)
 
139,9 → 135,45
end)
InterfaceOptions_AddCategory(RanchTradeOptions)
 
-- Register the BAG_UPDATE event.
RanchFrame:RegisterEvent("BAG_UPDATE");
-- Create the LDB feed options
local RanchLDBOptions = CreateFrame("Frame", "RanchLDBOpts", InterfaceOptionsFramePanelContainer)
RanchLDBOptions.name = "Data Broker"
RanchLDBOptions.parent = "Ranch"
local title, subtitle = LibStub("tekKonfig-Heading").new(RanchLDBOptions, "Ranch Data Broker Options", "This panel controls Ranch's Data Broker feed.")
ranchInterface.ldb = {}
 
-- Add Display LDB text option
ranchInterface.ldb.text = LibStub("tekKonfig-Checkbox").new(RanchLDBOptions, nil, "Display LDB text when not tracking anything?", "TOPLEFT", subtitle, "BOTTOMLEFT", -2, -8)
local checksound = ranchInterface.ldb.text:GetScript("OnClick")
ranchInterface.ldb.text:SetScript("OnClick", function(self)
checksound(self);
ranch_options["ldbtext"] = not ranch_options["ldbtext"];
if ranchtrack == nil then
if ranch_options["ldbtext"] then
dataobj.text = "Ranch";
else
dataobj.text = "";
end;
end;
end)
ranchInterface.ldb.text:SetChecked(ranch_options["ldbtext"])
 
-- Add Display item icon option
ranchInterface.ldb.icon = LibStub("tekKonfig-Checkbox").new(RanchLDBOptions, nil, "Change Ranch icon to item icon when tracking?", "TOPLEFT", ranchInterface.ldb.text, "BOTTOMLEFT", 0, -8)
local checksound = ranchInterface.ldb.icon:GetScript("OnClick")
ranchInterface.ldb.icon:SetScript("OnClick", function(self) checksound(self); ranch_options["ldbicon"] = not ranch_options["ldbicon"]; Ranch_BAG_UPDATE(nil); if ranch_options["ldbicon"] then ranchInterface.ldb.name:Enable(); else ranchInterface.ldb.name:Disable(); end; end)
ranchInterface.ldb.icon:SetChecked(ranch_options["ldbicon"])
 
-- Add Display item name option
ranchInterface.ldb.name = LibStub("tekKonfig-Checkbox").new(RanchLDBOptions, nil, "Show item name when tracking?", "TOPLEFT", ranchInterface.ldb.icon, "BOTTOMLEFT", 20, -8)
local checksound = ranchInterface.ldb.name:GetScript("OnClick")
ranchInterface.ldb.name.tiptext = "This options controls whether the item's name will appear in the data broker text when tracking an item."
ranchInterface.ldb.name:SetScript("OnClick", function(self) checksound(self); ranch_options["ldbname"] = not ranch_options["ldbname"]; Ranch_BAG_UPDATE(nil); end)
ranchInterface.ldb.name:SetChecked(ranch_options["ldbname"])
 
-- Add the LDB options page to the Interface Options panel.
InterfaceOptions_AddCategory(RanchLDBOptions)
 
-- Initialise the slash command handler.
SLASH_RANCH1 = "/ranch"
SlashCmdList["RANCH"] = Ranch_Command;
157,10 → 189,22
if firstWord == "track" then
if restOfString == "" or restOfString == nil then
ranchtrack = nil
RanchFrame:UnregisterEvent("BAG_UPDATE");
if ranch_options["ldbtext"] then
dataobj.text = "Ranch";
dataobj.icon = ranchIcon
else
dataobj.text = "";
dataobj.icon = ranchIcon
end
else
ranchtrack = restOfString
Ranch_BAG_UPDATE(nil)
 
-- Register the BAG_UPDATE event.
RanchFrame:RegisterEvent("BAG_UPDATE");
end
Ranch_BAG_UPDATE(nil)
 
elseif firstWord == "temp" then
ranch_temp[Ranch_ItemID(restOfString)] = true
elseif firstWord == "add" then
259,7 → 303,7
local iRow
for iRow = 2, 4 do
if _G["RanchGameTipTextLeft"..iRow] ~= nil then
if _G["RanchGameTipTextLeft"..iRow]:GetText() == ranch_QGT then
if _G["RanchGameTipTextLeft"..iRow]:GetText() == ITEM_STARTS_QUEST then
tinsert(ranch_qg, itemId)
end
end
368,11 → 412,13
 
function Ranch_BAG_UPDATE(...)
if ranchtrack ~= nil then
local itemIcon = GetItemIcon(ranchtrack)
if itemIcon ~= nil and ranch_options["ldbicon"] then
dataobj.icon = itemIcon
else
dataobj.icon = ranchIcon
end
dataobj.text = "|r|"..ranchtrack.." - "..GetItemCount(ranchtrack);
elseif ranch_options["ldbtext"] then
dataobj.text = "Ranch";
else
dataobj.text = "";
end
end