12-25-08, 07:17 PM | #1 | |
XML Slider Question
I am working on developing a config GUI for Scott's nUI. I've used XML for the frames and buttons etc... Its worked well for buttons but I cant get my sliders to work. Here is what I am trying to do:
I need a slider that will perform the function of /nui framerate {n} From the readme:
Code:
<Slider name="FramerateSlider" virtual="false" setAllPoints="false" hidden="false" alpha="1" toplevel="false" frameStrata="PARENT" id="0" enableMouse="true" enableKeyboard="false" drawLayer="OVERLAY" minValue="10" maxValue="60" defaultValue="30" valueStep="2" orientation="HORIZONTAL"> <Size x="241" y="20" /> <Anchors> <Anchor point="TOPLEFT"> <Offset x="121" y="-358" /> </Anchor> </Anchors> <Scripts> </Scripts> </Slider> for example with the button to switch from round <--> square minimap I'm using the following: Code:
<Button name="SquareMiniMapButton" inherits="UIPanelButtonTemplate" text="On / Off"> <Size x="100" y="20" /> <Anchors> <Anchor point="TOPLEFT"> <Offset x="16" y="-332" /> </Anchor> </Anchors> <Scripts> <OnClick>local editbox = CreateFrame("EditBox", "myEditBox", UIParent, "ChatFrameEditBoxTemplate"); editbox:SetText("/nui roundmap"); ChatEdit_SendText(editbox);</OnClick> </Scripts> </Button> Code:
<Scripts> <OnClick>local editbox = CreateFrame("EditBox", "myEditBox", UIParent, "ChatFrameEditBoxTemplate"); editbox:SetText("/nui framerate {value from slider}"); ChatEdit_SendText(editbox);</OnClick> </Scripts> ~Fludder |
||
12-25-08, 08:44 PM | #2 | |
Hrmmm Maybe this?
I am at work tonight and I dont have a UI simulator installed here (If anyone knows of a good lightweight [Preferably Portable] simulator let me know please)
Digging arround in other people's code (Im not an engineer, Im a reverse-Engineer) I came up with this: Frame.xml Code:
<Slider name="FramerateSlider" inherits="OptionsSliderTemplate" minvalue="1" maxvalue="120" defaultvalue="30" valuestep="1"> <Anchors> <Anchor point="TOPLEFT"> <Offset x="121" y="-358" /> </Anchor> </Anchors> <Scripts> <OnLoad> FramerateSlider_InitSlider(this:GetName()); </OnLoad> <OnValueChanged> getglobal(this:GetName().."FrameRate"):SetText(getglobal(this:GetName()):GetValue()); local editbox = CreateFrame("EditBox", "myEditBox", UIParent, "ChatFrameEditBoxTemplate"); editbox:SetText("/nui framerate" .."Framerate"..); ChatEdit_SendText(editbox); <OnValueChanged> </Scripts> </Slider> Frame.lua Code:
function FramerateSlider_InitSlider(slider) local sl = getglobal(slider) sl.tooltipText = "Increase for smoothness, decrease for performance. The default is 30 frames per second"; getglobal(slider .. "Low"):SetText("1"); getglobal(slider .. "High"):SetText("120"); getglobal(slider .. "FrameRate"):SetText("30"); end Will this corectly send
~Fludder |
||
12-29-08, 08:29 AM | #3 |
I had trouble getting my sliders to work too. I'm a beginner lua author and used the same approach you did. I did as much XML as I could for the layout and then used LUA for the logic. My code is kinda well commented because I copied a lot of other code that was well commented!
Take a look at this slider code (xml): Code:
<Slider name="$parent_Scale" inherits="OptionsSliderTemplate" minValue="1" maxValue="20" defaultValue="5" orientation="HORIZONTAL"> <Size> <AbsDimension x="200" y="16"/> </Size> <Anchors> <Anchor point="BOTTOMLEFT" relativeTo="$parent_Locked"> <Offset> <AbsDimension x="0" y="-60"/> </Offset> </Anchor> </Anchors> <Scripts> <OnLoad> getglobal(self:GetName().."High"):SetText("Big"); getglobal(self:GetName().."Low"):SetText("Small"); getglobal(self:GetName().."Text"):SetText("Scale"); </OnLoad> <OnValueChanged> RuneFrameC_Scale_OnValueChanged(self); </OnValueChanged> </Scripts> </Slider> Code:
function RuneFrameC_Scale_OnValueChanged(self) local scaleParam = self:GetValue()/5; RuneFrameC:SetScale(scaleParam); end |
|
WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » XML Slider Question |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|