View Single Post
06-10-05, 12:15 AM   #15
diiverr
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 67
OK, I think we're getting somewhere. I've gutted most of the original AddOn at this point. About the only thing left is the frames and functions we're discussing, and odds and ends relating to my funky options window.

Using the advice above, I'm mostly employing Beladona's code, with a few excepted suggestions by Gello, which did eliminate the odd error.

-- the bar --
Code:
<Frame name="DiivSkins_hbar1" frameStrata="BACKGROUND" inherits="DiivSkins_hbarTemplate" parent="UIParent">
	<Size>
		<AbsDimension x="512" y="46"/>
	</Size>
	<Layers>
		<Layer level="ARTWORK">
			<Texture name="DiivSkins_hbar1Texture" file="Interface\AddOns\DiivSkins\Skins\diivskins_01">
				<TexCoords left="0.0019531" right="1.0" top="0.0" bottom="0.0820312"/>
			</Texture>
		</Layer>
	</Layers>
	<Anchors>
		<Anchor point="BOTTOM">
			<Offset>
				<AbsDimension x="215" y="550"/>
			</Offset>
		</Anchor>
	</Anchors>
	<Scripts>
		<OnLoad>
			this:RegisterEvent("VARIABLES_LOADED");
		</OnLoad>
		<OnEvent>
			DS_TextureOnEvent();
		</OnEvent>
	</Scripts>
</Frame>
-- the slider --
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>
			if DiivSkinSettings then
				DiivSkinSettings.hbar1 = this:GetValue();
				DiivSkins_TextureUpdate();
			end
		</OnValueChanged>
	</Scripts>
</Slider>
-- the lua --
Code:
-- Variables ---------------------------------------
DiivSkinSettings = {};
DiivSkinSettings.hbar1 = 1

-- Global Functions ---------------------------------------
function DS_FirstLoad()
	DS_ControlConsole:Show();
	DS_startup:Show();
end
function DS_TextureOnEvent()
	if (event == "VARIABLES_LOADED") then 
		if (not DiivSkinSettings) then 
			DiivSkinSettings = {};
			DiivSkinSettings.hbar1 = 1;
			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[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};
Some of the variables stuff seems redundant to me, and I will re-read your posts tomorrow with a fresher brain Gello. That said, the changes (additions) I made did eliminate all errors except for this one:
[string "DiivSkins_hbar1Slider:OnValueChanged"]:2: attempt to index global `DiivSkins_TextureUpdate' (a nil value)
I get that whenever variables are loaded, or the slider is shown. Basically, the same "Update" function nil error as before.


The saved variable is saving correctly now and displaying the correct texture after VARIABLES_LOADED is triggered, and not displaying the original frame texture until an <OnShow> trigger as before.

Unfortunately, the slider is no longer working to dynamically update the texture in game. That is, it saves its variable, which is then displayed correctly the next time they are loaded, but nothing visually happens on screen when you adjust the slider. You need to reload to see the changes you have made. I can almost see where you are going with this however Beladona, so I'm more than willing to get it working if you are.

I'm getting tired, so I'll take a look at this again tomorrow with fresher eyes. I just wanted to give you both a status report.

I appreciate the help folks.
  Reply With Quote