View Single Post
06-10-05, 07:30 AM   #20
Beladona
A Molten Giant
 
Beladona's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 539
just an example, as I dont know the real texture coordinates you are wanting to use...

-- the bar --
Fine as it is, no changes necessary

-- the slider --
* changed DiivSkins_TextureUpdate(); to DS_TextureUpdate();
Code:
<Slider name="DiivSkins_hbar1Slider" inherits="OptionsSliderTemplate" minValue="1" maxValue="12" defaultValue="2" valueStep="1">
	<Size><AbsDimension x="160" y="17"/></Size>
	<Anchors><Anchor point="CENTER"/></Anchors>
	<Scripts>
		<OnLoad>
			getglobal(this:GetName().."Text"):SetText("Horizontal Bar 1");
			getglobal(this:GetName().."High"):SetText("12 slots");
			getglobal(this:GetName().."Low"):SetText("1 slot");
		</OnLoad>
		<OnShow>this:SetValue(DiivSkinSettings.hbar1);</OnShow>
		<OnValueChanged>
			DiivSkinSettings.hbar1 = this:GetValue();
			DS_TextureUpdate();
		</OnValueChanged>
		</Scripts>
	</Slider>
-- lua script --
* removed the first few lines as it will mess up your config settings
* changed the load detection a little pending inclusion of your other bars
* added DiivSkinTextures[1] since you now support settings 1 through 12 on the slider

Code:
-- Global Functions ---------------------------------------
function DS_FirstLoad()
	DS_ControlConsole:Show();
	DS_startup:Show();
	DiivSkinSettings.setup = true;
end
function DS_TextureOnEvent()
	if (event == "VARIABLES_LOADED") then 
		if (not DiivSkinSettings) then DiivSkinSettings = {}; end
		if (not DiivSkinSettings.hbar1) then DiivSkinSettings.hbar1 = 1; end
		if (not DiivSkinSettings.setup) then DS_FirstLoad(); end
		DS_TextureUpdate();
	end
end
function DS_TextureUpdate()
	local key = DiivSkinSettings.hbar1;
	local var = DiivSkinTextures[key];
	DiivSkins_hbar1Texture:SetTexCoord(var.a, var.b, var.c, var.d);
end
-- Configuration Variables ---------------------------------
DiivSkinTextures = {};
DiivSkinTextures[1] = {a = 0.0019531, b = 1.0, c = 0.0, d = 0.0820312};
DiivSkinTextures[2] = {a = 0.0, b = 1.0, c = 0.8984375, d = 0.9882812};
DiivSkinTextures[3] = {a = 0.0, b = 1.0, c = 0.8085937, d = 0.8984375};
DiivSkinTextures[4] = {a = 0.0, b = 1.0, c = 0.71875, d = 0.8085937};
DiivSkinTextures[5] = {a = 0.0, b = 1.0, c = 0.6289062, d = 0.71875};
DiivSkinTextures[6] = {a = 0.0, b = 1.0, c = 0.5390625, d = 0.6289062};
DiivSkinTextures[7] = {a = 0.0, b = 1.0, c = 0.4492187, d = 0.5390625};
DiivSkinTextures[8] = {a = 0.0, b = 1.0, c = 0.359375, d = 0.4492187};
DiivSkinTextures[9] = {a = 0.0, b = 1.0, c = 0.2695312, d = 0.359375};
DiivSkinTextures[10] = {a = 0.0, b = 1.0, c = 0.1796875, d = 0.2695312};
DiivSkinTextures[11] = {a = .0, b = 1.0, c = 0.0898437, d = 0.1796875};
DiivSkinTextures[12] = {a = 0.0, b = 1.0, c = 0.0, d = 0.0820312};
On a side note, your slider shouldn't be doing anything with the hbar1 setting until you actually open the config and start changing values. Based on that, you dont need to check for the setting before changing it. Just change it as I have it above, because by the time you actually even see this slider, you will already have run your onLoad for your bar, which makes sure the setting is there. It will ALWAYS be there by the time the slider is shown.

Last edited by Beladona : 06-10-05 at 07:35 AM.
  Reply With Quote