WoWInterface SVN AutoReputationBar

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 1 to Rev 2
    Reverse comparison

Rev 1 → Rev 2

trunk/AutoReputationBar.xml New file
0,0 → 1,10
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ \FrameXML\UI.xsd">
<Script file="AutoReputationBar.lua"/>
<Script file="SilvanasAddonsLib.lua"/>
<Frame name="AutoReputationBarDummyFrame">
<Scripts>
<OnLoad> AutoReputationBar_Load(self); </OnLoad>
<OnEvent>AutoReputationBar_Event(event,...);</OnEvent>
</Scripts>
</Frame>
</Ui>
\ No newline at end of file
trunk/AutoReputationBar.lua New file
0,0 → 1,183
--[[
Changelog:
Version 2.0.0
Updated TOC Version
Updated SilvanasAddonLib
Removed enable / disable toggle
Repositioned the checkbox
 
Version 1.1.1
Updated TOC Version
Updated SilvanasAddonLib
Interface is back and working again
 
Version 1.1.0
Updated for 3.0.2
 
Version 1.0.1
Updated TOC Version
Updated SilvanasAddonLib
 
Version 1.0.0
First fully woking version
 
Known Bugs:
checkboxews are located in a wrong way so scaling the ui will case it tobe misplaced
 
Todo:
^^ fix that litle bug
--]]
 
--main global var
AutoReputationBar = {
["NAME"] = "|cFF3366FFAuto Reputation Bar|r",
["VERSION"] = "(|cFF9900001|cFFFFFFFF.|cFF9900001|cFFFFFFFF.|cFF9900000|cFFFFFFFF)|r",
}
--
 
--event array
local AutoReputationBarEventArray = {}
function AutoReputationBar_Event(event,...) AutoReputationBarEventArray[event](...) end
--
 
-------------------
--event triggered--
-------------------
--onload
function AutoReputationBar_Load(self)
--register events
AutoReputationBarEventArray = {
["VARIABLES_LOADED"] = AutoReputationBar_Event_Variables_Loaded,
["COMBAT_TEXT_UPDATE"] = AutoReputationBar_Event_Combat_Text_Update,
}
Silvanas.RegisterEvents(self,AutoReputationBarEventArray)
end
 
---on event
function AutoReputationBar_Event_Variables_Loaded()
---relaod saved vars
--if the saved var didnt load then set it whit default setting esle we assume all setting to exist
if (not AutoReputationBar_SavedVars) or (not AutoReputationBar_SavedVars["VERSION"]) or (AutoReputationBar_SavedVars["VERSION"] ~= AutoReputationBar["VERSION"]) then
AutoReputationBar_SavedVars = {
["ACTIVEONLY"] = false,
["VERSION"] = AutoReputationBar["VERSION"]
}
end
 
--build up the checkbox that shows up in the reputation tab
local checkbox,checkboxText
 
--active only button
checkbox = CreateFrame("CheckButton","AutoReputationBar_Interface_Button_ActiveOnly",ReputationFrame,"OptionsCheckButtonTemplate")
checkbox:SetWidth(20)
checkbox:SetHeight(20)
checkbox:SetFrameStrata("HIGH")
checkbox:SetChecked(AutoReputationBar_SavedVars["ACTIVEONLY"])
checkbox:RegisterForClicks("LeftButtonUp")
checkbox:SetScript("OnClick",function(self,button) AutoReputationBar_Interface_Button_ActiveOnly_Clicked(self); end)
checkbox:SetPoint("TOPLEFT",ReputationFrame,"TOPLEFT", 53, -18)
checkboxText = _G[checkbox:GetName() .."Text"]
checkboxText:SetText("Switch to active factions only")
 
--loaded message
Silvanas.Print(AutoReputationBar["NAME"] .." |cFFFFFFFFBy: ".. Silvanas.Author .." |cFFFFFFFFversion: ".. AutoReputationBar["VERSION"] .." |cFFFFFFFFloaded.|r")
end
 
function AutoReputationBar_Event_Combat_Text_Update(updatetype, updatefaction)
--see if we are updating a faction
if updatetype == "FACTION" then
--if we are not already watcinh that faction
if updatefaction ~= GetWatchedFactionInfo() then
--try to switch the bar
AutoReputationBar_SetBar(updatefaction)
end
end
end
--------------------
--------------------
--------------------
 
-----------------------
--Switching Functions--
-----------------------
function AutoReputationBar_SetBar(faction)
local x,factionID,factionName,factionHeader,factionWatched,factionColapsed,NumFactions
local AutoReputationBar_ColapsedList = {}
 
--parse default nr of items
NumFactions = GetNumFactions()
 
--go over each faction to find the ID nummer
--set first fiction id
factionID = 1
while factionID <= NumFactions do
--get factions name
factionName,x,x,x,x,x,x,x,factionHeader,factionColapsed,factionWatched = GetFactionInfo(factionID)
 
--only contine if its not already watched
if not factionWatched then
 
--only contine if not a header
if factionHeader then
 
--if its closed then open it
if factionColapsed then
 
--open header
ExpandFactionHeader(factionID)
 
--recalc the number of factions
NumFactions = GetNumFactions()
 
--store header name to close it later
AutoReputationBar_ColapsedList[factionName] = true
end
else
--option only show active factions
if (AutoReputationBar_SavedVars["ACTIVEONLY"] and IsFactionInactive(factionID)) then break; end
 
--now lets see if its the correct name
if factionName == faction then
 
--oke let set the bar
SetWatchedFactionIndex(factionID)
 
--stop function
return
end
end
end
 
factionID = factionID + 1
end
 
--if we opened any headers lets now close them
if #AutoReputationBar_ColapsedList > 0 then
local factionID
 
--close any colapsed headers
for factionID=1, GetNumFactions() do
--if the faction name is in our list then close it
if AutoReputationBar_ColapsedList[GetFactionInfo(factionID)] then
CollapseFactionHeader(factionID)
end
end
 
--reset the list of closed headers
AutoReputationBar_ColapsedList = {}
end
end
-----------------------
-----------------------
-----------------------
 
-------------
--interface--
-------------
function AutoReputationBar_Interface_Button_ActiveOnly_Clicked(self)
--toggle activeonly
AutoReputationBar_SavedVars["ACTIVEONLY"] = not AutoReputationBar_SavedVars["ACTIVEONLY"]
end
-------------
-------------
-------------
\ No newline at end of file
trunk/AutoReputationBar.toc New file
0,0 → 1,13
## Interface: 40300
## Title: * |cFF3366FFAuto Reputation Bar|r
## Author: |cff993366Silvanas
## Version: 2.0.0
## Notes: |cff999999Automaticly switches the reputation bat to the last faction u got reputation for|n|cffffffffVersion: (|cFF9900002|cFFFFFFFF.|cFF9900000|cFFFFFFFF.|cFF9900000|cFFFFFFFF)|n|cFFFFFFFFAuthor: |cFF993366Silvanas|r
## eMail: westhof99@zonnet.nl
## URL: http://www.google.com
## License: None
## Secure:
## DefaultState: Enabled
## LoadOnDemand: 0
## SavedVariablesPerCharacter: AutoReputationBar_SavedVars
AutoReputationBar.xml
trunk/SilvanasAddonsLib.lua New file
0,0 → 1,219
--[[
--This Lib is made for addons made by Silvanas it gives some commen functions like print,printf,select,varstring
--i use it so i dont have to redecleare the function so i wont use duoble memory space, if u have multiple addons installed
--it is not a stand alone addon just a file to include. and other ui mods are welkome to use it aslog as they dont moddify it :P
]]--
 
SilvanasLibVersion = 5.7
 
if (not Silvanas) or (Silvanas.Version < SilvanasLibVersion) then
 
Silvanas = {
--Libary version
Version = SilvanasLibVersion,
--author
Author = "|cff993366Silvanas|r",
--hold a list of mods and thier info of registred mods --removed
LoadedMods = {},
 
--Basic print function
Print = function(msg)
if msg and DEFAULT_CHAT_FRAME then
DEFAULT_CHAT_FRAME:AddMessage(msg)
else
Silvanas.Message(msg)
end
end,
 
--Basic print function to the 2nd chat window
Print2 = function(msg)
if msg then
if ChatFrame2 then
ChatFrame2:AddMessage(msg)
elseif DEFAULT_CHAT_FRAME then
DEFAULT_CHAT_FRAME:AddMessage(msg)
else
Silvanas.Message(msg)
end
end
end,
 
--Print whit text formatting
Printf = function(...)
Silvanas.Print(string.format(unpack(arg)))
end,
 
--Returns a string represention of the variable
VarString = function(variable)
local vartype = type(variable)
if vartype == "string" then
return variable
elseif vartype == "number" then
return tostring(variable)
elseif vartype == "boolean" then
if variable then
return "true"
else
return "false"
end
else
return vartype
end
end,
 
--Placeholder for old function
VarPrint = function(variable)
return Silvanas.VarString(variable)
end,
 
--Argument selector
Select = select,
 
--Popup message
Message = function(msg)
message("|cFFFFFFFF".. msg .."|r")
end,
 
--/ Command addfunction
AddCmd = function(Name,Function,CmdTable)
if (type(CmdTable) == "table") and (type(Function) == "function") and (type(Name) == "string") then
if #CmdTable > 0 then
SlashCmdList[Name] = Function
 
local i
for i=1,#CmdTable,1 do
setglobal("SLASH_".. Name .. i,"/".. CmdTable[i])
end
end
end
end,
 
--register all events for the frame that are inside the table
RegisterEvents = function(self,EventArray)
if type(EventArray) == "table" then
local Event
for Event in pairs(EventArray) do
self:RegisterEvent(Event)
end
end
end,
 
--Registers a mod in the libary (removed)
AddMod = function() end,
 
--The player his name (has tobe a function since u can't get UnitName() at load time)
Me = UnitName("player"),
 
--Prints out the entire variable to chat (should be called whitout (dept))
DebugVar = function(variable,name,dept)
local prefix,vartype,key,value,suffix
if not dept then dept = 0 end
if dept > 0 then suffix = ',' else suffix = ';' end
if not name then name = "Variable" end
 
prefix = string.rep(' ',(dept*4))
vartype = type(variable)
 
if vartype == "string" then
Silvanas.Print(prefix .. name .." = \"".. variable .."\"".. suffix)
elseif vartype == "number" then
Silvanas.Print(prefix .. name .." = ".. variable .. suffix)
elseif vartype == "boolean" then
if variable then
Silvanas.Print(prefix .. name .." = true".. suffix)
else
Silvanas.Print(prefix .. name .." = false".. suffix)
end
elseif vartype == "table" then
if type(name) == "number" then name = "[".. name .."]" end
Silvanas.Print(prefix .. name .." = {")
 
if dept >= 5 then
Silvanas.Print(prefix .. string.rep(' ',4) .. "..." .. suffix)
return
end
 
for key,value in pairs(variable) do
if(value == variable) then
Silvanas.DebugVar("SELF-REFERENCE",key,(dept+1))
else
Silvanas.DebugVar(value,key,(dept+1))
end
end
Silvanas.Print(prefix .."}".. suffix)
else
Silvanas.Print(prefix .. name .." = ".. vartype .. suffix)
end
end,
 
--transform the colored version string into a number for easyer comparisation
GetVersionNumber = function(version)
local Vb,Vm,Vs
Vb,Vm,Vs = string.match(version,"%x%x%x%x%x%x%x%x(%d)|.*%x%x%x%x%x%x%x%x(%d)|.*%x%x%x%x%x%x%x%x(%d)|")
 
if Vb then
return tonumber(Vb .. Vm .. Vs)
else
return -1
end
end,
 
--queued functions
DelayTable = {},
 
--timescale hook
InitTimeDelay = function()
if not Silvanas.OnUpdate then
Silvanas.OnUpdate = function()
Silvanas.DelayCore()
end
 
CreateFrame("Frame"):SetScript("OnUpdate",Silvanas.OnUpdate)
end
end,
 
DelayCore = function()
local time = time()
for k,v in pairs(Silvanas.DelayTable) do
if time >= v.time then
local funct = v
table.remove(Silvanas.DelayTable,k)
funct.run(unpack(funct.arg))
end
end
end,
 
DelayFunc = function(secs,func,...)
if not Silvanas.OnUpdate then
Silvanas.Message("'Silvanas.DelayFunc(secs,func,<params>)' called while not Intialsed whit 'Silvanas.InitTimeDelay()'")
return
end
if type(func) ~= "function" or type(secs) ~= "number" then
Silvanas.Message("'Silvanas.DelayFunc(secs,func,<params>)' usage: seconds to delay, function to call, optional parametes'")
return
end
table.insert(Silvanas.DelayTable,{
time = time() + secs,
run = func,
arg = {...},
})
end,
 
RemoveDelayedFunc = function(func)
if type(func) ~= "function" then
Silvanas.Message("'Silvanas.RemoveDelayedFunc(func)' usage: function to remove of the list call")
return
end
 
local newTable = {}
local _, value
for _, value in pairs(Silvanas.DelayTable) do
if value.func ~= func then
table.insert(newTable, value)
end
end
 
Silvanas.DelayTable = newTable
end,
}
end
\ No newline at end of file