View Single Post
05-31-09, 06:42 AM   #7
Samsan
An Aku'mai Servant
 
Samsan's Avatar
Join Date: May 2009
Posts: 33
OK her goes the mess LUA:

DWMP_NUM_FACTIONS_DISPLAYED = 15;
DWMPACKREPSCROLLFRAME_FACTIONHEIGHT = 26;
DWMPACKREPFRAME_ROWSPACING = 23;

--------------------------------------------------------------------------
-- Recolors Blizzards Rep Frame Bars and Watched Rep Bar per faction level
--------------------------------------------------------------------------
DWMP_FACTION_BAR_COLORS = {
[1] = {r = 1.0, g = 0, b = 0}, -- 36000 Hated - Red
[2] = {r = 1.0, g = 0.5019608, b = 0}, -- 3000 Hostile - Orange
[3] = {r = 1.0, g = 0.8196079, b = 0}, -- 3000 Unfriendly - Yellow
[4] = {r = 0.8, g = 0.9, b = 0.8}, -- 3000 Neutral - Grey
[5] = {r = 1.0, g = 1.0, b = 1.0}, -- 6000 Friendly - White
[6] = {r = 0, g = 0.6, b = 0.1}, -- 12000 Honored - Green
[7] = {r = 0, g = 0, b = 1.0}, -- 21000 Revered - Blue
[8] = {r = 0.5803922, g = 0, b = 0.827451}, -- 1000 Exalted - Purple
};

------------------------------
-- Tracking information table
------------------------------
--~ DWMPackRepData = { };

--~ DWMPackRepData["RCFactions"] = {
--~ [1] = "FACTIONS_DARKSPEAR",
--~ [2] = "FACTIONS_ORGRIMMAR",
--~ [3] = "FACTIONS_SILVERMOON",
--~ [4] = "FACTIONS_THUNDERBLUFF",
--~ [5] = "FACTIONS_UNDERCITY",
--~ [6] = "FACTIONS_DARNASSUS",
--~ [7] = "FACTIONS_EXODAR",
--~ [8] = "FACTIONS_GNOMEREGAN",
--~ [9] = "FACTIONS_IRONFORGE",
--~ [10] = "FACTIONS_STORMWIND",
--~ };

--~ DWMPackRepData["HodirFaction"] = {
--~ [1] = "UlduarRelic",
--~ [2] = "CrystalShard",
--~ };

--~ DWMPackRepData["CanarionFaction"] = {
--~ [1] = "CooilfangArms",
--~ [2] = "LackeyEars",
--~ };
--~ DWMPackRepData["Aldor"] = {
--~ [1] = "KiljadenMarks",
--~ [2] = "SargerasMarks",
--~ [3] = "FelArms",
--~ };
--~ DWMPackRepData["Scryers"] = {
--~ [1] = "FirewingSignet",
--~ [2] = "SunfurySignet",
--~ [3] = "ArcaneTomes",
--~ };

--local oldReputationFrame_Update;

function DWMPackRepFrame_OnLoad(self)
--oldReputationFrame_Update = ReputationFrame_Update;
--ReputationFrame_Update = DWMPackRepFrame_Update;
local DWMPackRepFrame_UpdateFrame
self:RegisterEvent("UPDATE_FACTION");
local _, race = UnitRace("player")
end

-- Round function for percentages
function round(x)
return floor(x + 0.5)
end

function DWMPackRepScrollFrame_Update(self)

local numFactions = GetNumFactions();
local numFactions, totalCount = GetNumFactions();
local line, name, _, standingID, bottomValue, topValue, earnedValue, _, _, isHeader, _, hasRep, isWatched, _;
--local name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild = GetFactionInfo(factionIndex);
local self, button, buttonText, FactionName, FactionItems, FactionStanding, FactionPercent, FactionSession, FactionNumbers, FactionRepToGo;
local dwmpackrepIndex, factionIndex;
local columnTable;
local dwmpackrepOffset = FauxScrollFrame_GetOffset(DWMPackRepScrollFrame);
local color = DWMP_FACTION_BAR_COLORS[standingID];

local showScrollBar = nil;
if ( numFactions > DWMP_NUM_FACTIONS_DISPLAYED ) then
showScrollBar = 1;
end
local displayedText = "";
if ( numFactions > DWMP_NUM_FACTIONS_DISPLAYED ) then
displayedText = format(button.buttonText);
end

local i;

for i = 1, GetNumFactions() do

name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild= GetFactionInfo(i);
dwmpackrepIndex = dwmpackrepOffset + i;
button = getglobal("DWMPackRepEntryButton"..i);
button.dwmpackrepIndex = dwmpackrepIndex;
FactionName, FactionItems, FactionStanding, FactionPercent, FactionSession, FactionNumbers, FactionRepToGo = GetText(dwmpackrepIndex);
columnTable = { FactionName, FactionItems, FactionStanding, FactionPercent, FactionSession, FactionNumbers, FactionRepToGo};
if isHeader then
buttonText = getglobal("DWMPackRepEntryButton"..i.."FactionName");
button.buttonText:SetText(name);
return;
end
if isHeader == 1 and hasRep == nil and barValue ~= 0 then
hasRep = 1
if description == '' then
description = GRAY_FONT_COLOR_CODE .. '(hidden reputation)' .. FONT_COLOR_CODE_CLOSE
end
end
return name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep;
end
buttonText = getglobal("DWMPackRepEntryButton"..i.."FactionName");
button.Text:SetText(name);
buttonText = getglobal("DWMPackRepEntryButton"..i.."FactionItems");
button.Text:SetText("items");
buttonText = getglobal("DWMPackRepEntryButton"..i.."FactionStanding");
button.Text:SetText(standingText);
buttonText = getglobal("DWMPackRepEntryButton"..i.."FactionPercent");
button.Text:SetText(math.floor( (earnedValue-bottomValue)/(topValue-bottomValue) * 100).."% ");
buttonText = getglobal("DWMPackRepEntryButton"..i.."FactionSession");
button.Text:SetText("session");
buttonText = getglobal("DWMPackRepEntryButton"..i.."FactionNumbers");
button.Text:SetText(earnedValue-bottomValue.."/"..topValue-bottomValue);
buttonText = getglobal("DWMPackRepEntryButton"..i.."FactionRepToGo");
button.Text:SetText(topValue-earnedValue);


for i = 1, NumFactions() do
name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild= GetFactionInfo(i);
if not isHeader then
buttonText = getglobal("DWMPackRepEntryButton"..i.."FactionName");
buttonText:SetText(name);
buttonText = getglobal("DWMPackRepEntryButton"..i.."FactionItems");
buttonText:SetText("items");
buttonText = getglobal("DWMPackRepEntryButton"..i.."FactionStanding");
buttonText:SetText(standingText);
buttonText = getglobal("DWMPackRepEntryButton"..i.."FactionPercent");
buttonText:SetText(math.floor( (earnedValue-bottomValue)/(topValue-bottomValue) * 100).."% ");
buttonText = getglobal("DWMPackRepEntryButton"..i.."FactionSession");
buttonText:SetText("session");
buttonText = getglobal("DWMPackRepEntryButton"..i.."FactionNumbers");
buttonText:SetText(earnedValue-bottomValue.."/"..topValue-bottomValue);
buttonText = getglobal("DWMPackRepEntryButton"..i.."FactionRepToGo");
buttonText:SetText(topValue-earnedValue);
end

standingText = ""
if standingID == 1 then
standingText = "|cff8b0000Hated|r";
elseif standingID == 2 then
standingText = "|cffff1919Hostile|r";
elseif standingID == 3 then
standingText = "|cffff8C00Unfriendly|r";
elseif standingID == 4 then
standingText = "|cffc0c0c0Neutral|r";
elseif standingID == 5 then
standingText = "|cffffffffFriendly|r";
elseif standingID == 6 then
standingText = "|cff19ff19Honored|r";
elseif standingID == 7 then
standingText = "|cff4169e1Revered|r";
elseif standingID == 8 then
standingText = "|cff9932ccExalted|r";
end
DWMPackRepScrollFrame:Show();
end
end

function DWMPackRepFrame_OnLoad()
local numFactions = GetNumFactions();
name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild = GetFactionInfo();
for i=1,50 do
DWMPackRepIndexData[i] = name.."items"..standingText..math.floor( (earnedValue-bottomValue)/(topValue-bottomValue) * 100).."% ".."session"..earnedValue-bottomValue.."/"..topValue-bottomValue..topValue-earnedValue;
end
DWMPackRepScrollFrame:Show()
end

--~ function DWMPackRepScrollFrame_Update()
--~ local DWMPackRepIndexData = { };
--~ local line, lineplusoffset
--~ FauxScrollFrame_Update(DWMPackRepScrollFrame,50,15,20)
--~ -- 50 is max entries, 15 is number of lines, 20 is pixel height of each line
--~ for line = 1, 15 do
--~ lineplusoffset = line + FauxScrollFrame_GetOffset(DWMPackRepScrollFrame)
--~ if lineplusoffset < 50 then
--~ _G["DWMPackRepEntryButton"..line]:SetText(DWMPackRepIndexData[lineplusoffset])
--~ _G["DWMPackRepEntryButton"..line]:Show()
--~ else
--~ _G["DWMPackRepEntryButton"..line]:Hide()
--~ end
--~ end
--~ end

function DWMPackRepFrame_OnEvent(self, event, ...)
if ( event == "UPDATE_FACTION" ) then
if ( self:IsVisible() ) then
DWMPackRepFrame_Update();
end
end
end

function DWMPackRepFrame_OnShow(self)

if ( DWMPackRepFrame:IsShown() ) then
DWMPackRepFrame_Update();
DWMPackRepScrollFrame_Update(self);
end
end
__________________
To give is to receive so the more that you give the more that you receive.
  Reply With Quote