Quantcast

Added guild repair, yet another attempt to fix the stupid chat, and hopefully fixed the unit frame color error.

Safturento [01-10-12 - 14:26]
Added guild repair, yet another attempt to fix the stupid chat, and hopefully fixed the unit frame color error.
Filename
SaftUI/SaftUI.xml
SaftUI/config/config.lua
SaftUI/core/functions.lua
SaftUI/modules/chat.lua
SaftUI/modules/merchant.lua
SaftUI/modules/unitframes/groups/general.lua
diff --git a/SaftUI/SaftUI.xml b/SaftUI/SaftUI.xml
index 11d85b5..2f8eb71 100644
--- a/SaftUI/SaftUI.xml
+++ b/SaftUI/SaftUI.xml
@@ -9,6 +9,7 @@
 	<Include file="modules\classbars\classbars.xml"/>
 	<Script file="modules\datatext\experience.lua"/>
 	<Script file="modules\threatbar.lua"/>
+	<Script file="modules\merchant.lua"/>

 	<Script file="frames\reskinframes.lua"/>
 	<Script file="frames\killframes.lua"/>
diff --git a/SaftUI/config/config.lua b/SaftUI/config/config.lua
index e8ff613..6a7b674 100644
--- a/SaftUI/config/config.lua
+++ b/SaftUI/config/config.lua
@@ -51,4 +51,8 @@ end

 do
 	C.datatext.exp = 7
+end
+
+do
+	C.merchant.guildrepair = true
 end
\ No newline at end of file
diff --git a/SaftUI/core/functions.lua b/SaftUI/core/functions.lua
index 5d05da5..55e3915 100644
--- a/SaftUI/core/functions.lua
+++ b/SaftUI/core/functions.lua
@@ -151,7 +151,7 @@ end
 T.PostUpdatePower = function(power, unit, min, max)
 	local self = power:GetParent()
 	local pType, pToken = UnitPowerType(unit)
-	local color = {1, 1, 1}
+	local color
 	--Overwrite oUF colors with Tukui's colors for consistency
 	if power.colorTapping and UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) then
 		color = T.UnitColor.tapped
@@ -167,6 +167,7 @@ T.PostUpdatePower = function(power, unit, min, max)
 	elseif(power.colorReaction and UnitReaction(unit, 'player')) then
 		color = T.UnitColors.reaction[UnitReaction(unit, "player")]
 	end
+	if not color then color = {1, 1, 1} end
 	local r, g, b = color[1], color[2], color[3]

 	if power.value then
diff --git a/SaftUI/modules/chat.lua b/SaftUI/modules/chat.lua
index 99bae3a..9441eda 100644
--- a/SaftUI/modules/chat.lua
+++ b/SaftUI/modules/chat.lua
@@ -27,12 +27,6 @@ local function SetupChat(self)
 		loot:SetPoint("BOTTOMLEFT", rightbg, "BOTTOMLEFT", 6, 6)
 		loot:SetPoint("TOPRIGHT", rightbg, "TOPRIGHT", -6, -32)

-
-		general._SetPoint = general.SetPoint
-		general.SetPoint = T.Dummy
-		loot._SetPoint = general.SetPoint
-		loot.SetPoint = T.Dummy
-
 		leftbg:ClearAllPoints()
 		leftbg:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 6, 6)

@@ -63,6 +57,11 @@ local function SetupChat(self)
 		FCF_UnDockFrame(loot)
 		loot:SetJustifyH("RIGHT")
 	end
+
+	general._SetPoint = general.SetPoint
+	general.SetPoint = T.Dummy
+	loot._SetPoint = general.SetPoint
+	loot.SetPoint = T.Dummy
 end

 local OnLoad = CreateFrame("Frame")
diff --git a/SaftUI/modules/merchant.lua b/SaftUI/modules/merchant.lua
new file mode 100644
index 0000000..9dd1d18
--- /dev/null
+++ b/SaftUI/modules/merchant.lua
@@ -0,0 +1,66 @@
+local T,C,L = unpack(Tukui)
+
+local filter = {
+	[6289]  = true, -- Raw Longjaw Mud Snapper
+	[6291]  = true, -- Raw Brilliant Smallfish
+	[6308]  = true, -- Raw Bristle Whisker Catfish
+	[6309]  = true, -- 17 Pound Catfish
+	[6310]  = true, -- 19 Pound Catfish
+	[41808] = true, -- Bonescale Snapper
+	[42336] = true, -- Bloodstone Band
+	[42337] = true, -- Sun Rock Ring
+	[43244] = true, -- Crystal Citrine Necklace
+	[43571] = true, -- Sewer Carp
+	[43572] = true, -- Magic Eater
+}
+
+local function MerchantScript()
+	if C["merchant"].sellgrays or C["merchant"].sellmisc then
+		local c = 0
+		for b=0,4 do
+			for s=1,GetContainerNumSlots(b) do
+				local l,lid = GetContainerItemLink(b, s), GetContainerItemID(b, s)
+				if l and lid then
+					local p = select(11, GetItemInfo(l))*select(2, GetContainerItemInfo(b, s))
+					if C["merchant"].sellgrays and select(3, GetItemInfo(l))==0 and p > 0 then
+						UseContainerItem(b, s)
+						PickupMerchantItem()
+						c = c+p
+					end
+					if C["merchant"].sellmisc and filter[ lid ] then
+						UseContainerItem(b, s)
+						PickupMerchantItem()
+						c = c+p
+					end
+				end
+			end
+		end
+		if c>0 then
+			local g, s, c = math.floor(c/10000) or 0, math.floor((c%10000)/100) or 0, c%100
+			DEFAULT_CHAT_FRAME:AddMessage(L.merchant_trashsell.." |cffffffff"..g..L.goldabbrev.." |cffffffff"..s..L.silverabbrev.." |cffffffff"..c..L.copperabbrev..".",255,255,0)
+		end
+	end
+	if not IsShiftKeyDown() then
+		if CanMerchantRepair() and C["merchant"].autorepair then
+			local cost, possible = GetRepairAllCost()
+			if cost>0 then
+				if possible then
+					local c = cost%100
+					local s = math.floor((cost%10000)/100)
+					local g = math.floor(cost/10000)
+					if C.merchant.guildrepair then RepairAllItems(1) end
+					if GetRepairAllCost() == 0 then
+						DEFAULT_CHAT_FRAME:AddMessage("(Guild Bank)"..L.merchant_repaircost.." |cffffffff"..g..L.goldabbrev.." |cffffffff"..s..L.silverabbrev.." |cffffffff"..c..L.copperabbrev..".",255,255,0)
+					else
+						DEFAULT_CHAT_FRAME:AddMessage(L.merchant_repaircost.." |cffffffff"..g..L.goldabbrev.." |cffffffff"..s..L.silverabbrev.." |cffffffff"..c..L.copperabbrev..".",255,255,0)
+					end
+					RepairAllItems()
+				else
+					DEFAULT_CHAT_FRAME:AddMessage(L.merchant_repairnomoney,255,0,0)
+				end
+			end
+		end
+	end
+end
+
+TukuiMerchant:SetScript("OnEvent", MerchantScript)
\ No newline at end of file
diff --git a/SaftUI/modules/unitframes/groups/general.lua b/SaftUI/modules/unitframes/groups/general.lua
index 5736052..95e6ba1 100644
--- a/SaftUI/modules/unitframes/groups/general.lua
+++ b/SaftUI/modules/unitframes/groups/general.lua
@@ -17,10 +17,12 @@ T.groupframefuncs["general"] = function(self)

 	self.Name:SetFont(T.GetPixelFont())

-	self.Power:ClearAllPoints()
-	self.Power:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", 2, 2)
-	self.Power:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -2, 2)
-	self.Power:SetFrameLevel(self.Health:GetFrameLevel()+2)
+	if self.Power then
+		self.Power:ClearAllPoints()
+		self.Power:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", 2, 2)
+		self.Power:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -2, 2)
+		self.Power:SetFrameLevel(self.Health:GetFrameLevel()+2)
+	end

 	self:UpdateAllElements()
 end
\ No newline at end of file