Quantcast

* Added proper localization beginnings for core

James Whitehead II [12-31-06 - 18:53]
* Added proper localization beginnings for core
* Core now displays names and status bar/status text only, no buffs, etc.
* Added header-based options for classcolor, severitycolor and reverse bar fill
Filename
Localization.enUS.lua
PerfectRaid.lua
PerfectRaid.toc
diff --git a/Localization.enUS.lua b/Localization.enUS.lua
index 3db9c96..10910a7 100644
--- a/Localization.enUS.lua
+++ b/Localization.enUS.lua
@@ -1,2 +1,5 @@
 PerfectRaidLocals = {
+	["Dead"] = "Dead",
+	["Ghost"] = "Ghost",
+	["Offline"] = "Offline",
 }
diff --git a/PerfectRaid.lua b/PerfectRaid.lua
index 3351339..b52db5d 100644
--- a/PerfectRaid.lua
+++ b/PerfectRaid.lua
@@ -33,16 +33,23 @@ local frames = {}
 local unavail = {}

 local L = PerfectRaidLocals
+local utils = DongleStub("DongleUtils")
 PerfectRaid = DongleStub("Dongle"):New("PerfectRaid")

 function PerfectRaid:Initialize()
 	self.defaults = {
 		profile = {
-			headers = {
-			},
+			headers = {},
+			positions = {},
 		},
 	}

+	self.headerDefaults = {
+		Reverse = true,
+		ColorClass = false,
+		ColorSeverity = true,
+	}
+
 	self.db = self:InitializeDB("PerfectRaidDB", self.defaults)

 	if not ClickCastFrames then
@@ -63,38 +70,22 @@ function PerfectRaid:Enable()
 	self:RegisterEvent("UNIT_MAXENERGY", "UNIT_MAXMANA")
 	self:RegisterEvent("UNIT_MAXFOCUS", "UNIT_MAXMANA")

-	-- Register slash command
-	self.cmd = self:InitializeSlashCommand("PerfectRaid Options", "PERFECTRAID", "praid", "perfectraid")
-	self.cmd:RegisterSlashHandler("Show Options", "", "ShowOptions")
-
-	-- Force a roster update
-	self:RAID_ROSTER_UPDATE()
-end
-
-function PerfectRaid:CreateRaidHeaders()
-	local list = self.db.profile.headers
-	self.headers = self.headers or {}
-
-	local inraid = GetNumRaidMembers() > 0
-	self:Print("Checking", #list, "headers")
-	for i=1,#list do
-		local entry = list[i]
+	--TODO: Make this so we can actually instantiate frames as the users wants
+	for i=1,8 do
 		local name = "PRHeader"..i
-		local filters = strjoin(",", unpack(entry.filters))
-
-		if self.headers[i] then
-			self:ChangeRaidFrame(name, entry.name, filters, entry.strict)
-		else
-			self.headers[i] = self:CreateRaidFrame(name, entry.name, filters, entry.strict)
-			self:RestorePosition("PRHeader"..i)
-		end
-
-		if not inraid then
-			self.headers[i]:Hide()
-		else
-			self.headers[i]:Show()
-		end
+		self.db.profile.headers[name] = setmetatable({}, {__index=self.headerDefaults})
+		local header = self:CreateRaidFrame(name, "Group "..i, tostring(i), nil, PRHeader1)
 	end
+
+	PRHeader1:ClearAllPoints()
+	self:RestorePosition("PRHeader1")
+	PRHeader2:SetPoint("TOP", PRHeader1, "BOTTOM", 0, -20)
+	PRHeader3:SetPoint("TOP", PRHeader2, "BOTTOM", 0, -20)
+	PRHeader4:SetPoint("TOP", PRHeader3, "BOTTOM", 0, -20)
+	PRHeader5:SetPoint("TOPLEFT", PRHeader1, "TOPRIGHT", 10, 0)
+	PRHeader6:SetPoint("TOP", PRHeader5, "BOTTOM", 0, -20)
+	PRHeader7:SetPoint("TOP", PRHeader6, "BOTTOM", 0, -20)
+	PRHeader8:SetPoint("TOP", PRHeader7, "BOTTOM", 0, -20)
 end

 function PerfectRaid:SavePosition(name)
@@ -138,18 +129,8 @@ function PerfectRaid:RestorePosition(name)
 	f:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", x, y)
 end

-function PerfectRaid:ChangeRaidFrame(name, title, filter, strict, dragparent)
-	local frame = getglobal(name)
-	frame.title:SetText(title or "")
-	frame:SetAttribute("groupFilter", filter)
-	frame:SetAttribute("strictFiltering", strict)
-	frame:SetAttribute("dragparent", dragparent or frame)
-	frame:Hide()
-	frame:Show()
-end
-
 local function OnDragStart(frame)
-	local parent = frame:GetAttribute("dragparent")
+	local parent = frame.dragparent
 	if not parent.locked then
 		parent:StartMoving()
 		PerfectRaid.moving = parent
@@ -157,7 +138,7 @@ local function OnDragStart(frame)
 end

 local function OnDragStop(frame)
-	local parent = frame:GetAttribute("dragparent")
+	local parent = frame.dragparent
 	parent:StopMovingOrSizing()
 	PerfectRaid:SavePosition(parent:GetName())
 	PerfectRaid.moving = nil
@@ -175,7 +156,7 @@ function PerfectRaid:CreateRaidFrame(name, title, filter, strict, dragparent)
 	frame:SetAttribute("yOffset", -2)
 	frame:SetAttribute("sortMethod", "NAME")
 	frame:SetAttribute("strictFiltering", strict)
-	frame:SetAttribute("dragparent", dragparent or frame)
+	frame.dragparent = dragparent or frame
 	frame.initialConfigFunction = PerfectRaid.ConfigureButton
 	frame:SetMovable(true)
 	frame:SetClampedToScreen(true)
@@ -213,11 +194,11 @@ function PerfectRaid:UNIT_HEALTH(event, unit)
 		unavail[unit] = true

 		if UnitIsDead(unit) then
-			status = L.STATUS_DEAD
+			status = L["Dead"]
 		elseif UnitIsGhost(unit) then
-			status = L.STATUS_GHOST
+			status = L["Ghost"]
 		elseif not UnitIsConnected(unit) then
-			status = L.STATUS_OFFLINE
+			status = L["Offline"]
 		end

 		for frame in pairs(frames[unit]) do
@@ -231,21 +212,38 @@ function PerfectRaid:UNIT_HEALTH(event, unit)
 	else
 		if unavail[unit] then
 			for frame in pairs(frames[unit]) do
-				frame.healthbar:SetMinMaxValues(0, UnitHealthMax(unit))
-				frame.healthbar:SetValue(UnitHealth(unit))
-
-				local color = frame.manacolor
-				frame.manabar:SetMinMaxValues(0, UnitManaMax(unit))
-				frame.manabar:SetValue(UnitMana(unit))
-
+				local options = self.db.profile.headers[frame.headerName]
+				if options.ColorClass then
+					local c = frame.classcolor
+					frame.healthbar:SetStatusBarColor(c.r,c.g,c.b)
+				elseif options.ColorSeverity then
+					frame.healthbar:SetStatusBarColor(utils.GetHPSeverity(perc))
+				end
+
+				local value = health
+				if options.Reverse then
+					value = max - health
+				end
+
+				frame.healthbar:SetMinMaxValues(0, max)
+				frame.healthbar:SetValue(value)
 				frame.status:SetText(nil)
 			end
 			unavail[unit] = nil
 		end

 		for frame in pairs(frames[unit]) do
-			local class = select(2, UnitClass(unit))
-			frame.healthbar:SetValue(health)
+			local options = self.db.profile.headers[frame.headerName]
+			if options.ColorSeverity then
+				frame.healthbar:SetStatusBarColor(utils.GetHPSeverity(perc))
+			end
+
+			local value = health
+			if options.Reverse then
+				value = max - health
+			end
+
+			frame.healthbar:SetValue(value)
 			frame.status:SetText(deficit)
 		end
 	end
@@ -280,7 +278,6 @@ function PerfectRaid:UNIT_MAXMANA(event, unit)
 	end
 end

-
 local function OnShow(frame)
 	local self = PerfectRaid
 	local unit = frame:GetAttribute("unit")
@@ -347,6 +344,8 @@ local function OnAttributeChanged(frame, name, value)
 				parent.title:Show()
 			end
 		end
+	else
+		parent.title:Show()
 	end
 end

@@ -361,7 +360,9 @@ function PerfectRaid.ConfigureButton(button)
 	button:SetAttribute("*type1", "target")

 	local parent = button:GetParent()
-	button:SetAttribute("dragparent", parent:GetAttribute("dragparent"))
+	button.dragparent = parent.dragparent
+	button.header = parent
+	button.headerName = parent:GetName()

 	local leftbox = CreateFrame("Frame", nil, button)
 	leftbox:SetPoint("TOPLEFT", 0, 0)
@@ -442,240 +443,3 @@ function PerfectRaid:RAID_ROSTER_UPDATE()
 		self.moving:StopMovingOrSizing()
 	end
 end
-
-function PerfectRaid:ShowOptions()
-	if not PROptions then
-		self:CreateOptions()
-	end
-	if PROptions:IsVisible() then
-		PROptions:Show()
-	else
-		PROptions:Hide()
-	end
-end
-
-local menuItems = {}
-function PerfectRaid:CreateOptions()
-	local frame = self:CreateFrame("PROptions", UIParent)
-	frame:SetHeight(250)
-	frame:SetWidth(400)
-	frame:SetPoint("CENTER", 0, 0)
-
-	local frame = self:CreateFrame("PROptionsMenu", PROptions)
-	frame:SetWidth(150)
-	frame:SetPoint("TOPRIGHT", PROptions, "TOPLEFT", 0, 0)
-	frame:SetPoint("BOTTOMRIGHT", PROptions, "BOTTOMLEFT", 0, 0)
-
-	local frame = CreateFrame("Frame", "PROptions_General", PROptions)
-	self:AddMenuItem("General Options", 1, PROptions_General)
-
-	self:CreateFrameEditor()
-end
-
-function PerfectRaid:CreateFrame(name, parent)
-	local frame = CreateFrame("Frame", name, parent)
-	frame:SetBackdrop(StaticPopup1:GetBackdrop())
-	frame:SetBackdropColor(0,0,0)
-	return frame
-end
-
-local function sortFunction(a,b)
-	return a.order < b.order
-end
-
-local OnClick = function(button)
-	if PROptions.current then
-		PROptions.current:Hide()
-		PROptions.lastButton:SetChecked(nil)
-	end
-	button.frame:SetAllPoints(PROptions)
-	button.frame:Show()
-	PROptions.current = button.frame
-	PROptions.lastButton = button
-end
-
-local buttons = {}
-function PerfectRaid:AddMenuItem(name, order, frame)
-	local num = #menuItems + 1
-	local button = CreateFrame("CheckButton", "PRMenuItem"..num, PROptionsMenu)
-	button:SetHeight(20)
-	button:SetWidth(120)
-	button:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
-	button:SetCheckedTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
-	button:SetScript("OnClick", OnClick)
-
-	local texture = button:CreateTexture(nil, "BACKGROUND")
-	texture:SetTexture(0,0,0,0.8)
-	texture:SetAllPoints()
-
-	local label = button:CreateFontString(nil, "OVERLAY")
-	label:SetFontObject(GameFontNormalSmall)
-	label:SetPoint("CENTER")
-	label:SetJustifyH("CENTER")
-	label:SetText(name)
-	button.label = label
-
-	buttons[num] = button
-
-	local entry = {}
-	entry.name = name
-	entry.order = order
-	entry.frame = frame
-
-	table.insert(menuItems, entry)
-
-	-- Re-order the menu items
-	table.sort(menuItems, sortFunction)
-	for idx,entry in ipairs(menuItems) do
-		local button = buttons[idx]
-		button.label:SetText(entry.name)
-		button.frame = entry.frame
-	end
-
-	PRMenuItem1:SetPoint("TOP", 0, -15)
-	for i=2,#menuItems do
-		local button = buttons[i]
-		button:SetPoint("TOP", buttons[i-1], "BOTTOM", 0, -2)
-	end
-end
-
-function PerfectRaid:CreateFrameEditor()
-	local frame = CreateFrame("Frame", "PROptions_Frames")
-	self:AddMenuItem("Frame Editor", 2, PROptions_Frames)
-
-	frame.entries = {}
-
-	local NUM_ENTRIES = 9
-	local selected,Entry_OnClick
-
-	for i=1,NUM_ENTRIES do
-		local button = CreateFrame("CheckButton", nil, frame)
-		button:SetHeight(20)
-		frame.entries[i] = button
-
-		button.idx = i
-		button.desc = button:CreateFontString(nil, "OVERLAY")
-		button.desc:SetFontObject(GameFontNormalSmall)
-		button.desc:SetPoint("LEFT", 0, 0)
-		button.desc:SetText("Description: " .. i)
-		button:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
-		button:SetCheckedTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
-		button:SetScript("OnClick", Entry_OnClick)
-	end
-
-	frame.entries[1]:SetPoint("TOPLEFT", 8, -5)
-	frame.entries[1]:SetPoint("TOPRIGHT", -28, -5)
-
-	for i=2,NUM_ENTRIES do
-		frame.entries[i]:SetPoint("TOPLEFT", frame.entries[i-1], "BOTTOMLEFT", 0, -2)
-		frame.entries[i]:SetPoint("TOPRIGHT", frame.entries[i-1], "BOTTOMRIGHT", 0, -2)
-	end
-
-	local OnEnter = function(button)
-		button:SetBackdropBorderColor(1,1,1)
-	end
-
-	local OnLeave = function(button)
-		button:SetBackdropBorderColor(0.3, 0.3, 0.3)
-	end
-
-	local createButton = function(name)
-		local button = CreateFrame("Button", "PROptions_Frames_"..name, PROptions_Frames)
-		button:SetHeight(30)
-		button:SetWidth(80)
-		button:SetBackdrop(GameTooltip:GetBackdrop())
-		button:SetBackdropColor(0,0,0)
-		button:SetBackdropBorderColor(0.3, 0.3, 0.3)
-		button:SetScript("OnEnter", OnEnter)
-		button:SetScript("OnLeave", OnLeave)
-
-		button.label = button:CreateFontString(nil, "ARTWORK")
-		button.label:SetFontObject(GameFontNormalSmall)
-		button.label:SetPoint("CENTER")
-		button.label:SetText(name)
-		button.enableText = name
-		return button
-	end
-
-	local button_new = createButton("New")
-	button_new:SetPoint("BOTTOMLEFT", 8, 5)
-
-	local button_edit = createButton("Edit")
-	button_edit:SetPoint("LEFT", button_new, "RIGHT", 5, 0)
-
-	local button_delete = createButton("Delete")
-	button_delete:SetPoint("LEFT", button_edit, "RIGHT", 5, 0)
-
-	PROptions_Frames:SetScript("OnShow", function(frame)
-		for idx,entry in ipairs(frame.entries) do
-			entry:SetChecked(nil)
-		end
-		selected = nil
-		button_edit:Disable()
-		button_delete:Disable()
-	end)
-
-	PROptions_Frames:GetScript("OnShow")(PROptions_Frames)
-
-	Entry_OnClick = function(button)
-		if selected then
-			frame.entries[selected]:SetChecked(nil)
-		end
-		button:SetChecked(true)
-		selected = button.idx
-		button_edit:Enable()
-		button_delete:Enable()
-	end
-
-	for idx,button in ipairs(frame.entries) do
-		button:SetScript("OnClick", Entry_OnClick)
-	end
-
-	-- Create the scroll frame
-	local scrollframe = CreateFrame("ScrollFrame", "PROptions_Frames_Scroll", PROptions_Frames, "FauxScrollFrameTemplate")
-	scrollframe:SetPoint("TOPLEFT", frame.entries[1], "TOPLEFT", 0, 0)
-	scrollframe:SetPoint("BOTTOMRIGHT", frame.entries[NUM_ENTRIES], "BOTTOMRIGHT", 0, 0)
-
-	local texture = scrollframe:CreateTexture(nil, "BACKGROUND")
-	texture:SetTexture("Interface\\ChatFrame\\ChatFrameBackground")
-	texture:SetPoint("TOPLEFT", scrollframe, "TOPRIGHT", 14, 0)
-	texture:SetPoint("BOTTOMRIGHT", 23, 0)
-	texture:SetVertexColor(0,0,0,0.3)
-
-	local texture = scrollframe:CreateTexture(nil, "BACKGROUND")
-	texture:SetTexture("Interface\\ChatFrame\\ChatFrameBackground")
-	texture:SetPoint("TOPLEFT", scrollframe, "TOPRIGHT", 4, 0)
-	texture:SetPoint("BOTTOMRIGHT", 14,0)
-	texture:SetVertexColor(0,0,0,0.3)
-end
-
---PerfectRaid:CreateOptions()
-
---[[
-foo = CreateFrame("Frame", "PRTestOptions", UIParent, "PROptionsTemplate")
-foo:SetHeight(300) foo:SetWidth(450)
-foo:SetPoint("CENTER", 0, 0)
-foo:Show()
-
-local tab1 = CreateFrame("Button", "PRTab1", foo, "PRTabTemplate")
-tab1:SetPoint("TOPLEFT", foo, "BOTTOMLEFT", 10, 12)
-tab1:Show()
-
-local tab2 = CreateFrame("Button", "PRTab2", foo, "PRTabTemplate")
-tab2:SetPoint("TOPLEFT", tab1, "TOPRIGHT", 3, 0)
-tab2:Show()
-
-local tab3 = CreateFrame("Button", "PRTab3", foo, "PRTabTemplate")
-tab3:SetPoint("TOPLEFT", tab2, "TOPRIGHT", 3, 0)
-tab3:SetWidth(150)
-tab3:Show()
-
-local check1 = CreateFrame("CheckButton", "PRCheck1", foo, "PRCheckTemplate")
-check1:SetHeight(16) check1:SetWidth(16)
-check1:SetPoint("TOPLEFT", 20, -30)
-check1:Show()
-
-local button1 = CreateFrame("Button", "PRButton1", foo, "PRButtonTemplate")
-button1:SetPoint("BOTTOMRIGHT", foo, -15, 17)
-button1:Show()
---]]
\ No newline at end of file
diff --git a/PerfectRaid.toc b/PerfectRaid.toc
index 27b7e58..81a1190 100644
--- a/PerfectRaid.toc
+++ b/PerfectRaid.toc
@@ -6,6 +6,7 @@
 ## OptionalDeps: Dongle
 Dongle.lua
 DongleUtils.lua
+Localization.enUS.lua
 PerfectRaid.xml
 PerfectRaid.lua