PageRenderTime 94ms CodeModel.GetById 41ms app.highlight 9ms RepoModel.GetById 41ms app.codeStats 0ms

/TelUI_AddonSkins/skins/ArkInventory.lua

http://github.com/Asphyxia/Tukui
Lua | 267 lines | 108 code | 13 blank | 146 comment | 14 complexity | 4e1cab611287dee76dcc8fceb036073a MD5 | raw file
  1--[[
  2    ArkInventory skin for TelUI
  3
  4    TODO:
  5     + Add Integration options
  6	 + Strip config options
  7
  8	Based partially on the work done by devxwill / Mankar - Runetotem
  9	 
 10	File version v91.109
 11	(C)2010 Darth Android / Telroth - The Venture Co.
 12]]
 13
 14if not Mod_AddonSkins or not IsAddOnLoaded("ArkInventory") then return end
 15local ArkInventory = LibStub("AceAddon-3.0"):GetAddon("ArkInventory")
 16if not ArkInventory then return end
 17
 18local _G = _G
 19Mod_AddonSkins:RegisterSkin("ArkInventory",function(Skin,skin,Layout,layout,config)
 20	
 21	-- Hook paint function to strip background and borders
 22	ArkInventory.Frame_Main_Paint_ = ArkInventory.Frame_Main_Paint
 23	ArkInventory.Frame_Main_Paint = function(frame)
 24		--ArkInventory.Frame_Main_Paint_(frame) 
 25		if not ArkInventory.ValidFrame(frame, true) then return	end
 26		for i = 1, select("#",frame:GetChildren()) do
 27			local subframe = select(i,frame:GetChildren())
 28			local name = subframe:GetName()
 29			if name then
 30				if _G[name.."ArkBorder"] then _G[name.."ArkBorder"]:Hide() end
 31				if _G[name.."Background"] then _G[name.."Background"]:Hide() end
 32			end
 33			skin:SkinBackgroundFrame(subframe)
 34			-- Whew! We just saved the wasteful creation of over 7 tables!
 35		end
 36	end
 37	
 38	--[[ Item Containers ]]
 39	ArkInventory.Frame_Container_Draw_ = ArkInventory.Frame_Container_Draw
 40	ArkInventory.Frame_Container_Draw = function(frame)
 41		local loc_id = frame.ARK_Data.loc_id
 42		-- lock a few settings
 43		ArkInventory.LocationOptionSet(loc_id, "bar", "pad", "external", 2)
 44		ArkInventory.LocationOptionSet(loc_id, "window", "pad", 0)
 45		return ArkInventory.Frame_Container_Draw_(frame)
 46	end
 47	
 48	--[[ Scaling ]]
 49	ArkInventory.Frame_Main_Scale_ = ArkInventory.Frame_Main_Scale
 50	ArkInventory.Frame_Main_Scale = function(loc_id)
 51		-- Lock the scale at 1 to protect our pixel-perfect borders!
 52		ArkInventory.Frame_Main_Get( loc_id ):SetScale(1)
 53		ArkInventory.Frame_Main_Anchor_Set(loc_id)
 54	end
 55	
 56	--[[ Anchoring ]]
 57	ArkInventory.Frame_Main_Anchor_Set_ = ArkInventory.Frame_Main_Anchor_Set
 58	ArkInventory.Frame_Main_Anchor_Set = function(loc_id)
 59		ArkInventory.Frame_Main_Anchor_Set_(loc_id)
 60		local frame = ArkInventory.Frame_Main_Get(loc_id)
 61		frame = frame:GetName()
 62		local title = _G[frame..ArkInventory.Const.Frame.Title.Name]
 63		local search = _G[frame..ArkInventory.Const.Frame.Search.Name]
 64		local container = _G[frame..ArkInventory.Const.Frame.Container.Name]
 65		local changer = _G[frame..ArkInventory.Const.Frame.Changer.Name]
 66		local status = _G[frame..ArkInventory.Const.Frame.Status.Name]
 67		title:ClearAllPoints()
 68		title:SetPoint("TOPLEFT")
 69		title:SetPoint("TOPRIGHT")
 70		search:ClearAllPoints()
 71		search:SetPoint("TOPLEFT",title,"BOTTOMLEFT",0,-config.buttonSpacing)
 72		search:SetPoint("TOPRIGHT",title,"BOTTOMRIGHT",0,-config.buttonSpacing)
 73		container:ClearAllPoints()
 74		container:SetPoint("TOPLEFT",search,"BOTTOMLEFT",0,-config.buttonSpacing)
 75		container:SetPoint("TOPRIGHT",search,"BOTTOMRIGHT",0,-config.buttonSpacing)
 76		changer:ClearAllPoints()
 77		changer:SetPoint("TOPLEFT",container,"BOTTOMLEFT",0,-config.buttonSpacing)
 78		changer:SetPoint("TOPRIGHT",container,"BOTTOMRIGHT",0,-config.buttonSpacing)
 79		status:ClearAllPoints()
 80		status:SetPoint("TOPLEFT",changer,"BOTTOMLEFT",0,-config.buttonSpacing)
 81		status:SetPoint("TOPRIGHT",changer,"BOTTOMRIGHT",0,-config.buttonSpacing)
 82		-- Reanchor & resize internal components
 83		-- Status
 84		ArkInventory.Const.Frame.Status.Height = config.fontSize + config.borderWidth * 4
 85		_G[status:GetName().."EmptyText"]:SetPoint("LEFT",config.borderWidth,0)
 86		_G[status:GetName().."EmptyText"]:SetFont(config.font,config.fontSize+5,config.fontFlags)
 87		-- Restructure the gold display
 88		_G[status:GetName().."GoldCopperButton"]:SetPoint("RIGHT",-config.borderWidth,0)
 89		_G[status:GetName().."GoldCopperButtonText"]:SetFont(config.font,config.fontSize+5,config.fontFlags)
 90		--_G[status:GetName().."GoldCopperButtonText"]:SetPoint("RIGHT",-13,1)
 91		
 92		_G[status:GetName().."GoldSilverButton"]:SetPoint("RIGHT",_G[status:GetName().."GoldCopperButtonText"],"LEFT",-config.borderWidth,0)
 93		_G[status:GetName().."GoldSilverButtonText"]:SetFont(config.font,config.fontSize+5,config.fontFlags)
 94		--_G[status:GetName().."GoldSilverButtonText"]:SetPoint("RIGHT",-13,1)
 95		
 96		_G[status:GetName().."GoldGoldButton"]:SetPoint("RIGHT",_G[status:GetName().."GoldSilverButtonText"],"LEFT",-config.borderWidth,0)
 97		_G[status:GetName().."GoldGoldButtonText"]:SetFont(config.font,config.fontSize+5,config.fontFlags)
 98		--_G[status:GetName().."GoldSilverButtonText"]:SetPoint("RIGHT",-13,1)
 99	end
100	
101	ArkInventory.Const.Frame.Title.Height2 = 32
102	
103	-- Skin each bar
104	ArkInventory.Frame_Bar_Paint_ = ArkInventory.Frame_Bar_Paint
105	ArkInventory.Frame_Bar_Paint = function(bar)
106		-- Option overrides
107		local loc_id = bar.ARK_Data.loc_id
108		ArkInventory.LocationOptionSet(loc_id, "bar", "pad", "internal" , 2)
109		ArkInventory.LocationOptionSet(loc_id, "bar", "name", "height", 18)
110		ArkInventory.Frame_Bar_Paint_(bar)
111		if not bar then return end
112		local name = bar:GetName()
113		if _G[name.."ArkBorder"] then _G[name.."ArkBorder"]:Hide() end
114		if _G[name.."Background"] then _G[name.."Background"]:Hide() end
115		skin:SkinFrame(bar)
116		-- Edit mode
117		if ArkInventory.Global.Mode.Edit then
118			bar:SetBackdropBorderColor(1,0,0,1)
119			bar:SetBackdropColor(1,0,0,.1)
120		end
121	end
122	
123	--[[ Item Icons ]]
124	ArkInventory.SetItemButtonTexture_ = ArkInventory.SetItemButtonTexture
125	ArkInventory.SetItemButtonTexture = function(frame, texture, r, g, b)
126		if not frame or not _G[frame:GetName().."IconTexture"] then return end
127		local obj = _G[frame:GetName().."IconTexture"]
128		if not texture then
129			obj:Hide()
130		else
131			obj:SetTexture(texture)
132			obj:SetTexCoord(unpack(config.buttonZoom))
133			obj:SetVertexColor(r or 1, r and g or 1, r and b or 1)
134			obj:ClearAllPoints()
135			obj:SetPoint("TOPLEFT",config.borderWidth,-config.borderWidth)
136			obj:SetPoint("BOTTOMRIGHT",-config.borderWidth,config.borderWidth)
137		end
138	end
139	
140	--[[ Item Border ]]
141	ArkInventory.Frame_Item_Update_Border_ = ArkInventory.Frame_Item_Update_Border
142	ArkInventory.Frame_Item_Update_Border = function(frame)
143		ArkInventory.Frame_Item_Update_Border_(frame)
144		if not frame or not _G[frame:GetName().."ArkBorder"] then return end
145		local obj = _G[frame:GetName().."ArkBorder"]
146		local r,g,b,a = obj:GetBackdropBorderColor()
147		obj:Hide()
148		skin:SkinFrame(frame)
149		frame:SetBackdropBorderColor(r,g,b,a)
150
151	end
152end)
153--[[
154do
155	
156	-- hook the main draw function
157	ArkInventory.Frame_Main_Draw_ = ArkInventory.Frame_Main_Draw
158	ArkInventory.Frame_Main_Draw = function( frame )
159		ArkInventory.Frame_Main_Draw_( frame )
160		local af = frame:GetName( )
161		for _, v in pairs{ "Title", "Search", "Container", "Changer", "Status" } do
162			TukuiDB:SetTemplate( _G[af..v] )
163		end
164	end
165	
166	TukuiDB:SetTemplate( _G["ARKINV_RulesTitle"] )
167	TukuiDB:SetTemplate( _G["ARKINV_RulesFrame"] )
168	TukuiDB:SetTemplate( _G["ARKINV_RulesFrameViewTitle"] )
169	TukuiDB:SetTemplate( _G["ARKINV_RulesFrameViewSearch"] )
170	TukuiDB:SetTemplate( _G["ARKINV_RulesFrameViewSort"] )
171	TukuiDB:SetTemplate( _G["ARKINV_RulesFrameViewTable"] )
172	TukuiDB:SetTemplate( _G["ARKINV_RulesFrameViewMenu"] )
173	TukuiDB:SetTemplate( _G["ARKINV_RulesFrame"] )
174	TukuiDB:SetTemplate( _G["ARKINV_RulesFrameModifyTitle"] )
175	TukuiDB:SetTemplate( _G["ARKINV_RulesFrameModifyMenu"] )
176	TukuiDB:SetTemplate( _G["ARKINV_RulesFrameModifyData"] )
177	TukuiDB:SetTemplate( _G["ARKINV_RulesFrameModifyDataScrollTextBorder"] )
178	
179	TukuiDB:SetTemplate( _G["ARKINV_SearchTitle"] )
180	TukuiDB:SetTemplate( _G["ARKINV_SearchFrameViewSearch"] )
181	TukuiDB:SetTemplate( _G["ARKINV_SearchFrameViewTable"] )
182	TukuiDB:SetTemplate( _G["ARKINV_SearchFrame"] )
183	
184	TukuiDB:SetTemplate( _G["ARKINV_Frame4Log"] )
185	
186	-- hook the anchors
187	ArkInventory.Frame_Main_Anchor_Set_ = ArkInventory.Frame_Main_Anchor_Set
188	ArkInventory.Frame_Main_Anchor_Set = function( loc_id, rescale )
189		local frame = ArkInventory.Frame_Main_Get( loc_id )
190		
191		local f1 = _G[frame:GetName( ) .. ArkInventory.Const.Frame.Title.Name]
192		local f2 = _G[frame:GetName( ) .. ArkInventory.Const.Frame.Search.Name]
193		local f3 = _G[frame:GetName( ) .. ArkInventory.Const.Frame.Container.Name]
194		local f4 = _G[frame:GetName( ) .. ArkInventory.Const.Frame.Changer.Name]
195		local f5 = _G[frame:GetName( ) .. ArkInventory.Const.Frame.Status.Name]
196		
197		frame:ClearAllPoints( )
198		f1:ClearAllPoints( )
199		f2:ClearAllPoints( )
200		f3:ClearAllPoints( )
201		f4:ClearAllPoints( )
202		f5:ClearAllPoints( )
203		
204		if loc_id == 3 or loc_id == 4 or loc_id == 5 then
205			frame:SetPoint( "BOTTOMLEFT", InfoLeft, "TOPLEFT", 0, TukuiDB:Scale( 5 ) )
206			
207			f5:SetPoint( "BOTTOMLEFT", frame )
208			f5:SetPoint( "RIGHT", frame )
209		
210			f4:SetPoint( "BOTTOMLEFT", f5, "TOPLEFT", 0, -3 )
211			f4:SetPoint( "RIGHT", frame )
212		
213			f3:SetPoint( "BOTTOMLEFT", f4, "TOPLEFT", 0, -3 )
214			f3:SetPoint( "RIGHT", frame )
215		
216			f2:SetPoint( "BOTTOMLEFT", f3, "TOPLEFT", 0, -4 )
217			f2:SetPoint( "RIGHT", frame )
218
219			f1:SetPoint( "BOTTOMLEFT", f2, "TOPLEFT", 0, -3 )
220			f1:SetPoint( "RIGHT", frame )
221		else
222			frame:SetPoint( "BOTTOMRIGHT", InfoRight, "TOPRIGHT", 0, TukuiDB:Scale( 5 ) )
223			
224			f5:SetPoint( "BOTTOMRIGHT", frame )
225			f5:SetPoint( "LEFT", frame )
226		
227			f4:SetPoint( "BOTTOMRIGHT", f5, "TOPRIGHT", 0, -3 )
228			f4:SetPoint( "LEFT", frame )
229		
230			f3:SetPoint( "BOTTOMRIGHT", f4, "TOPRIGHT", 0, -3 )
231			f3:SetPoint( "LEFT", frame )
232		
233			f2:SetPoint( "BOTTOMRIGHT", f3, "TOPRIGHT", 0, -4 )
234			f2:SetPoint( "LEFT", frame )
235
236			f1:SetPoint( "BOTTOMRIGHT", f2, "TOPRIGHT", 0, -3 )
237			f1:SetPoint( "LEFT", frame )
238		end
239		
240		if ArkInventory.LocationOptionGet( loc_id, { "anchor", loc_id, "locked" } ) then
241			frame:RegisterForDrag( )
242		else
243			frame:RegisterForDrag( "LeftButton" )
244		end
245
246		if rescale then
247			ArkInventory.Frame_Main_Anchor_Save( frame )
248		end
249	end
250	
251	-- Set some settings to make it look better
252	for i = 1, 9 do
253		ArkInventory.LocationOptionSet( i, { "changer", "hide" }, true )
254		ArkInventory.LocationOptionSet( i, { "title", "size" }, ArkInventory.Const.Window.Title.SizeThin )
255	
256		if TukuiDB["panels"].tinfowidth >= 405 then
257			ArkInventory.LocationOptionSet( i, { "window", "width" }, 12 )
258		elseif TukuiDB["panels"].tinfowidth >= 370 and TukuiDB["panels"].tinfowidth < 405 then
259			ArkInventory.LocationOptionSet( i, { "window", "width" }, 11 )
260		elseif TukuiDB["panels"].tinfowidth >= 335 and TukuiDB["panels"].tinfowidth < 370 then
261			ArkInventory.LocationOptionSet( i, { "window", "width" }, 10 )
262		else
263			ArkInventory.LocationOptionSet( i, { "window", "width" }, 9 )
264		end
265	end
266end
267]]