Thread Tools Display Modes
03-12-12, 02:29 AM   #1
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
How to change Desaturated texture.

Hey does anyone know how to change the Desaturated texture?


  Reply With Quote
03-12-12, 04:30 AM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
SetDesaturated(true/false)

http://wowprogramming.com/docs/widge...SetDesaturated
http://code.google.com/p/rothui/sour...s/raid.lua#360
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
03-12-12, 06:02 AM   #3
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
I know that i wanted to changed these texture when its enabled.

If you check the screenshot you see its diffrent textures and i want the same :P
  Reply With Quote
03-12-12, 07:14 AM   #4
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
I don't think it can be changed because it runs on graphics API level (I think). If you want to change the texture manually you should create your own function for it.
  Reply With Quote
03-12-12, 08:18 AM   #5
Xus
A Fallenroot Satyr
 
Xus's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 25
Code:
obj:SetDisabledTexture(texture);	
obj.disabledtexture = obj:GetDisabledTexture();
obj.disabledtexture:SetDesaturated(1);
obj.disabledtexture:SetVertexColor(0.5,0.5,0.5);
This is what I use in FX to change the disabled texture for the checkbuttons, so this should work for you too You can also keep the disabled texture a local variable, no need to add it as a variable in the button.

If this is not what you're looking for, you probably need to replace the checkbutton (disabled) texture in your wow folder itself...
__________________
Xussie/Xusseh of Kazzak EU. Author of ForteXorcist

Last edited by Xus : 03-12-12 at 08:22 AM. Reason: added a remark
  Reply With Quote
03-12-12, 10:03 AM   #6
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Haleth View Post
I don't think it can be changed because it runs on graphics API level (I think). If you want to change the texture manually you should create your own function for it.
Originally Posted by Xus View Post
Code:
obj:SetDisabledTexture(texture);	
obj.disabledtexture = obj:GetDisabledTexture();
obj.disabledtexture:SetDesaturated(1);
obj.disabledtexture:SetVertexColor(0.5,0.5,0.5);
This is what I use in FX to change the disabled texture for the checkbuttons, so this should work for you too You can also keep the disabled texture a local variable, no need to add it as a variable in the button.

If this is not what you're looking for, you probably need to replace the checkbutton (disabled) texture in your wow folder itself...
Thanks both will try this Xus '

Works but it doesn't overwrite the old one, and it check it in even if its not checked

LUA Code:
  1. AftermathhUI.CheckBox = function(self)
  2.     self:SetNormalTexture("")
  3.     self:SetPushedTexture("")
  4.     self:SetHighlightTexture("")
  5.     self:SetWidth(28)
  6.     self:SetHeight(28)
  7.     self:SetBackdrop({
  8.         bgFile = AftermathhUI.media.backdrop,
  9.         insets = {top = 4, left = 4, bottom = 4, right = 4},
  10.     })
  11.     CreateBorderLight(self, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, -4)
  12.    
  13.     SetBorderLayer(self, "BORDER")
  14.  
  15.     local checkboxtexture = self:CreateTexture(nil, "OVERLAY")
  16.     checkboxtexture:SetWidth(25)
  17.     checkboxtexture:SetHeight(22)
  18.     checkboxtexture:SetPoint("LEFT", 2, 1)
  19.     checkboxtexture:SetTexture("Interface\\RAIDFRAME\\ReadyCheck-Ready")
  20.     self:SetCheckedTexture(checkboxtexture)
  21.  
  22.     local disabledtexture = self:CreateTexture(nil, "OVERLAY")
  23.     disabledtexture:SetWidth(25)
  24.     disabledtexture:SetHeight(22)
  25.     disabledtexture:SetPoint("LEFT", 2, 1)
  26.     disabledtexture:SetTexture("Interface\\RAIDFRAME\\ReadyCheck-Ready")
  27.     self:SetDisabledTexture(disabledtexture)
  28.    
  29.     self.disabledtexture = self:GetDisabledTexture();
  30.     self.disabledtexture:SetDesaturated(1);
  31.     self.disabledtexture:SetVertexColor(0.5,0.5,0.5);
  32.        
  33.     self:HookScript("OnEnter", function(self)
  34.         ColorBorder(self, 1.0, 0.82, 0)
  35.     end)
  36.    
  37.     self:HookScript("OnLeave", function(self)
  38.         ColorBorder(self, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor)
  39.     end)
  40. end

Last edited by Aftermathhqt : 03-12-12 at 10:46 AM.
  Reply With Quote
03-12-12, 10:52 AM   #7
Xus
A Fallenroot Satyr
 
Xus's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 25
Originally Posted by Game92 View Post
Thanks both will try this Xus '

Works but it doesn't overwrite the old one, and it check it in even if its not checked

LUA Code:
  1. AftermathhUI.CheckBox = function(self)
  2.     self:SetNormalTexture("")
  3.     self:SetPushedTexture("")
  4.     self:SetHighlightTexture("")
  5.     self:SetWidth(28)
  6.     self:SetHeight(28)
  7.     self:SetBackdrop({
  8.         bgFile = AftermathhUI.media.backdrop,
  9.         insets = {top = 4, left = 4, bottom = 4, right = 4},
  10.     })
  11.     CreateBorderLight(self, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, -4)
  12.    
  13.     SetBorderLayer(self, "BORDER")
  14.  
  15.     local checkboxtexture = self:CreateTexture(nil, "OVERLAY")
  16.     checkboxtexture:SetWidth(25)
  17.     checkboxtexture:SetHeight(22)
  18.     checkboxtexture:SetPoint("LEFT", 2, 1)
  19.     checkboxtexture:SetTexture("Interface\\RAIDFRAME\\ReadyCheck-Ready")
  20.     self:SetCheckedTexture(checkboxtexture)
  21.  
  22.     local disabledtexture = self:CreateTexture(nil, "OVERLAY")
  23.     disabledtexture:SetWidth(25)
  24.     disabledtexture:SetHeight(22)
  25.     disabledtexture:SetPoint("LEFT", 2, 1)
  26.     disabledtexture:SetTexture("Interface\\RAIDFRAME\\ReadyCheck-Ready")
  27.     self:SetDisabledTexture(disabledtexture)
  28.    
  29.     self.disabledtexture = self:GetDisabledTexture();
  30.     self.disabledtexture:SetDesaturated(1);
  31.     self.disabledtexture:SetVertexColor(0.5,0.5,0.5);
  32.        
  33.     self:HookScript("OnEnter", function(self)
  34.         ColorBorder(self, 1.0, 0.82, 0)
  35.     end)
  36.    
  37.     self:HookScript("OnLeave", function(self)
  38.         ColorBorder(self, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor)
  39.     end)
  40. end
I probably should have mentioned that the 'texture' is the texture path, not an actually texture object So it's easier than you think.

Edit: Actually, upon taking a closer look, I probably had the same problem you had. Because this is the full code I used to make my checkbuttons with:
Code:
local function NewCheckButton(parent)
	local obj = CreateFrame("Button",nil,parent);
	obj.parent = parent;
	obj:SetWidth(20);
	obj:SetHeight(20);
	
	obj:SetNormalTexture("Interface\\AddOns\\Forte_Core\\Textures\\CheckButton");
	obj.normaltexture = obj:GetNormalTexture();
	obj.normaltexture:ClearAllPoints();
	obj.normaltexture:SetWidth(16);
	obj.normaltexture:SetHeight(16);
	obj.normaltexture:SetPoint("CENTER",obj,"CENTER",0,0);
	
	obj:SetDisabledTexture("Interface\\AddOns\\Forte_Core\\Textures\\CheckButton");	
	obj.disabledtexture = obj:GetDisabledTexture();
	obj.disabledtexture:ClearAllPoints();
	obj.disabledtexture:SetWidth(16);
	obj.disabledtexture:SetHeight(16);
	obj.disabledtexture:SetPoint("CENTER",obj,"CENTER",0,0);
	obj.disabledtexture:SetVertexColor(0.5,0.5,0.5);
	--obj.disabledtexture:SetDesaturated(1);
	
	obj.background = obj:CreateTexture(nil,"BACKGROUND");
	obj.background:SetTexture(0,0,0,0.2);
	obj.background:SetWidth(10);
	obj.background:SetHeight(10);
	obj.background:SetPoint("CENTER",obj,"CENTER",0,0);
	
	obj.texture = obj:CreateTexture(nil,"OVERLAY");
	obj.texture:SetTexture("Interface\\Buttons\\UI-CheckBox-Check");
	obj.texture:SetAllPoints(obj);
	
	obj.title = "[click to toggle]";
	obj.tip = "";
	obj.SetEnabled = function(self,enabled)
		if enabled then
			obj.texture:SetDesaturated(false);
			self:Enable();	
		else
			self:Disable();
			obj.texture:SetDesaturated(true);	
		end		
	end
	obj.SetChecked = function(self,checked)
		if checked then
			obj.texture:SetVertexColor(1,1,1,1);
		else
			obj.texture:SetVertexColor(1,1,1,0);
		end
	end
	
	obj:SetScript("OnEnter",function(self)
		obj.background:SetTexture(1,1,1,0.05);
		FW:ShowOptionsTip(self);
	end);
	obj:SetScript("OnLeave",function(self)
		FW:HideTip(self);
		obj.background:SetTexture(0,0,0,0.1);
	end);

	return obj;
end
You should be able to figure something out with that! I'm just not sure if it's worth it when you can just replace the texture for your whole interface by adding a replacement in your interface folder.
__________________
Xussie/Xusseh of Kazzak EU. Author of ForteXorcist

Last edited by Xus : 03-12-12 at 11:07 AM. Reason: oops
  Reply With Quote
03-12-12, 11:00 AM   #8
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Xus View Post
I probably should have mentioned that the 'texture' is the texture path, not an actually texture object So it's easier than you think.
You kinda lost me xD
  Reply With Quote
03-12-12, 11:02 AM   #9
Xus
A Fallenroot Satyr
 
Xus's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 25
Originally Posted by Game92 View Post
You kinda lost me xD
Yeah, sorry, see edit above. It really wasn't easier... :P
__________________
Xussie/Xusseh of Kazzak EU. Author of ForteXorcist
  Reply With Quote
03-12-12, 11:06 AM   #10
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Xus View Post
Yeah, sorry, see edit above. It really wasn't easier... :P
No problem i will take a closer look in to this
  Reply With Quote
03-13-12, 01:51 AM   #11
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Its not working




LUA Code:
  1. AftermathhUI.CheckBox = function(self)
  2.     self:SetNormalTexture("")
  3.     self:SetPushedTexture("")
  4.     self:SetHighlightTexture("")
  5.     self:SetWidth(28)
  6.     self:SetHeight(28)
  7.     self:SetBackdrop({
  8.         bgFile = AftermathhUI.media.backdrop,
  9.         insets = {top = 4, left = 4, bottom = 4, right = 4},
  10.     })
  11.     CreateBorderLight(self, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, -4)
  12.  
  13.     SetBorderLayer(self, "BORDER")
  14.  
  15.     --[[
  16.     local checkboxtexture = self:CreateTexture(nil, "OVERLAY")
  17.     checkboxtexture:SetWidth(25)
  18.     checkboxtexture:SetHeight(22)
  19.     checkboxtexture:SetPoint("LEFT", 2, 1)
  20.     --checkboxtexture:SetTexture("Interface\\RAIDFRAME\\ReadyCheck-Ready")
  21.     self:SetCheckedTexture(checkboxtexture)
  22.     --]]
  23.    
  24.     self:SetNormalTexture("Interface\\RAIDFRAME\\ReadyCheck-Ready");
  25.     self.normaltexture = self:GetNormalTexture();
  26.     self.normaltexture:ClearAllPoints();
  27.     self.normaltexture:SetWidth(25);
  28.     self.normaltexture:SetHeight(22);
  29.     self.normaltexture:SetPoint("LEFT", 2, 1);
  30.    
  31.     self:SetDisabledTexture("Interface\\RAIDFRAME\\ReadyCheck-Ready"); 
  32.     self.disabledtexture = self:GetDisabledTexture();
  33.     self.disabledtexture:ClearAllPoints();
  34.     self.disabledtexture:SetWidth(25);
  35.     self.disabledtexture:SetHeight(22);
  36.     self.disabledtexture:SetPoint("LEFT", 2, 1);
  37.     self.disabledtexture:SetVertexColor(0.5,0.5,0.5);
  38.  
  39.     self.texture = self:CreateTexture(nil,"OVERLAY");
  40.     self.texture:SetTexture("Interface\\Buttons\\UI-CheckBox-Check");
  41.     self.texture:SetAllPoints(self);
  42.    
  43.     self.SetEnabled = function(self,enabled)
  44.         if enabled then
  45.             self.texture:SetDesaturated(false);
  46.             self:Enable(); 
  47.         else
  48.             self:Disable();
  49.             self.texture:SetDesaturated(true); 
  50.         end    
  51.     end
  52.    
  53.     self.SetChecked = function(self,checked)
  54.         if checked then
  55.             self.texture:SetVertexColor(1,1,1,1);
  56.         else
  57.             self.texture:SetVertexColor(1,1,1,0);
  58.         end
  59.     end
  60.    
  61.     self:HookScript("OnEnter", function(self)
  62.         ColorBorder(self, 1.0, 0.82, 0)
  63.     end)
  64.    
  65.     self:HookScript("OnLeave", function(self)
  66.         ColorBorder(self, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor)
  67.     end)
  68.    
  69.     return self
  70. end
  Reply With Quote
03-16-12, 08:51 AM   #12
Xus
A Fallenroot Satyr
 
Xus's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 25
I haven't tested your code to see what goes wrong exactly, but as I understand it, the problem is that you want to change the existing checkbox. My code creates an entirely new one (from a Button frame).

In order to edit the existing ones, you'd first have to know exactly how they are built up. Here's an example of one of the standard templates:
Code:
<CheckButton name="OptionsBaseCheckButtonTemplate" virtual="true">
	<Size>
		<AbsDimension x="26" y="26"/>
	</Size>
	<HitRectInsets>
		<AbsInset left="0" right="-100" top="0" bottom="0"/>
	</HitRectInsets>
	<Scripts>
		<OnClick>
			if ( self:GetChecked() ) then
				PlaySound("igMainMenuOptionCheckBoxOn");
			else
				PlaySound("igMainMenuOptionCheckBoxOff");
			end
			BlizzardOptionsPanel_CheckButton_OnClick(self);
		</OnClick>
		<OnEnter>
			if ( self.tooltipText ) then
				GameTooltip:SetOwner(self, self.tooltipOwnerPoint or "ANCHOR_RIGHT");
				GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1);
			end
			if ( self.tooltipRequirement ) then
				GameTooltip:AddLine(self.tooltipRequirement, 1.0, 1.0, 1.0, 1.0);
				GameTooltip:Show();
			end
		</OnEnter>
		<OnLeave>
			GameTooltip:Hide();
		</OnLeave>
	</Scripts>
	<NormalTexture urgency="5" file="Interface\Buttons\UI-CheckBox-Up"/>
	<PushedTexture urgency="5" file="Interface\Buttons\UI-CheckBox-Down"/>
	<HighlightTexture urgency="5" file="Interface\Buttons\UI-CheckBox-Highlight" alphaMode="ADD"/>
	<CheckedTexture urgency="5" file="Interface\Buttons\UI-CheckBox-Check"/>
	<DisabledCheckedTexture urgency="5" file="Interface\Buttons\UI-CheckBox-Check-Disabled"/>		
</CheckButton>
So it should be as easy as doing this:
CheckButton:SetDisabledCheckedTexture(texture) or CheckButton:SetDisabledCheckedTexture("filename")

Easy after all right?

ps. you should remove all the code you added after your first post, it's not needed anymore...
__________________
Xussie/Xusseh of Kazzak EU. Author of ForteXorcist

Last edited by Xus : 03-16-12 at 08:53 AM. Reason: added ps
  Reply With Quote
03-16-12, 11:31 AM   #13
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Xus View Post
I haven't tested your code to see what goes wrong exactly, but as I understand it, the problem is that you want to change the existing checkbox. My code creates an entirely new one (from a Button frame).

In order to edit the existing ones, you'd first have to know exactly how they are built up. Here's an example of one of the standard templates:
Code:
<CheckButton name="OptionsBaseCheckButtonTemplate" virtual="true">
	<Size>
		<AbsDimension x="26" y="26"/>
	</Size>
	<HitRectInsets>
		<AbsInset left="0" right="-100" top="0" bottom="0"/>
	</HitRectInsets>
	<Scripts>
		<OnClick>
			if ( self:GetChecked() ) then
				PlaySound("igMainMenuOptionCheckBoxOn");
			else
				PlaySound("igMainMenuOptionCheckBoxOff");
			end
			BlizzardOptionsPanel_CheckButton_OnClick(self);
		</OnClick>
		<OnEnter>
			if ( self.tooltipText ) then
				GameTooltip:SetOwner(self, self.tooltipOwnerPoint or "ANCHOR_RIGHT");
				GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, 1);
			end
			if ( self.tooltipRequirement ) then
				GameTooltip:AddLine(self.tooltipRequirement, 1.0, 1.0, 1.0, 1.0);
				GameTooltip:Show();
			end
		</OnEnter>
		<OnLeave>
			GameTooltip:Hide();
		</OnLeave>
	</Scripts>
	<NormalTexture urgency="5" file="Interface\Buttons\UI-CheckBox-Up"/>
	<PushedTexture urgency="5" file="Interface\Buttons\UI-CheckBox-Down"/>
	<HighlightTexture urgency="5" file="Interface\Buttons\UI-CheckBox-Highlight" alphaMode="ADD"/>
	<CheckedTexture urgency="5" file="Interface\Buttons\UI-CheckBox-Check"/>
	<DisabledCheckedTexture urgency="5" file="Interface\Buttons\UI-CheckBox-Check-Disabled"/>		
</CheckButton>
So it should be as easy as doing this:
CheckButton:SetDisabledCheckedTexture(texture) or CheckButton:SetDisabledCheckedTexture("filename")

Easy after all right?

ps. you should remove all the code you added after your first post, it's not needed anymore...
Thanks alot Xus! Hope i didn't bother you too much! works prefect very easy haha, really silly actually!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to change Desaturated texture.


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off