I am working on my first WOW mod. I am familiar with other programming languages but I am trying to get the hang of LUA and the XML commands.
In my mod I am trying to add a drop down where the user can select other Profiles to view their information.
I was going through the FrameXML files that Blizzard gives out in the Dev Kit and found the commands for the DropDown in the Options.
the button shows on my screen but it does not show the profile name. when you click on the button I do get the dropdown with my profiles names. when i click on a profile it does run the command set for it and does update the Mod.
But the dropdown list does not go away and the selected profile does not get displayed.
Is there something im missing?
Copied from the OptionsFrame.xml
Code:
<Frame name="OptionsFrameRefreshDropDown" inherits="UIDropDownMenuTemplate" id="2">
<Anchors>
<Anchor point="TOPLEFT" relativeTo="OptionsFrameResolutionDropDown" relativePoint="BOTTOMLEFT">
<Offset x="0" y="-10"/>
</Anchor>
</Anchors>
<Layers>
<Layer level="BACKGROUND">
<FontString name="$parentLabel" inherits="GameFontNormalSmall" text="REFRESH_RATE">
<Anchors>
<Anchor point="BOTTOMLEFT" relativePoint="TOPLEFT">
<Offset x="21" y="0"/>
</Anchor>
</Anchors>
</FontString>
</Layer>
</Layers>
<Scripts>
<OnLoad>
OptionsFrameRefreshDropDown_OnLoad();
</OnLoad>
<OnShow>
OptionsFrameRefreshDropDown_OnLoad();
</OnShow>
<OnEnter>
GameTooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
GameTooltip:SetText(OPTION_TOOLTIP_USE_REFRESH, nil, nil, nil, nil, 1);
</OnEnter>
<OnLeave>
GameTooltip:Hide();
</OnLeave>
</Scripts>
</Frame>
My Code
Code:
<Frame name="$parent_ProfileDropDown" inherits="UIDropDownMenuTemplate" enableMouse="true">
<Anchors>
<Anchor point="TOPRIGHT">
<Offset x="-165" y="-22"/>
</Anchor>
</Anchors>
<Layers>
<Layer level="ARTWORK">
<FontString name="$parentLabel" inherits="GameFontNormalSmall" text="Profile">
<Anchors>
<Anchor point="BOTTOMRIGHT" relativePoint="TOPRIGHT">
<Offset x="100" y="0"/>
</Anchor>
</Anchors>
</FontString>
</Layer>
</Layers>
<Scripts>
<OnLoad>
SupplyList_ProfileDropDown_OnLoad();
</OnLoad>
<OnShow>
SupplyLis_ProfileDropDown_OnLoad();
</OnShow>
<OnEnter>
GameTooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
GameTooltip:SetText("Select witch Profile you\nwould like to veiw.", nil, nil, nil, nil, 1);
</OnEnter>
<OnLeave>
GameTooltip:Hide();
</OnLeave>
</Scripts>
</Frame>
Copied from the OptionsFrame.lua
Code:
function OptionsFrameResolutionDropDown_OnLoad()
UIDropDownMenu_Initialize(this, OptionsFrameResolutionDropDown_Initialize);
UIDropDownMenu_SetSelectedID(this, GetCurrentResolution(), 1);
UIDropDownMenu_SetWidth(90, OptionsFrameResolutionDropDown);
end
function OptionsFrameResolutionDropDown_Initialize()
OptionsFrameResolutionDropDown_LoadResolutions(GetScreenResolutions());
end
function OptionsFrameResolutionDropDown_LoadResolutions(...)
local info = UIDropDownMenu_CreateInfo();
local resolution, xIndex, width, height;
for i=1, select("#", ...) do
resolution = (select(i, ...));
xIndex = strfind(resolution, "x");
width = strsub(resolution, 1, xIndex-1);
height = strsub(resolution, xIndex+1, strlen(resolution));
if ( width/height > 4/3 ) then
resolution = resolution.." "..WIDESCREEN_TAG;
end
info.text = resolution;
info.value = resolution;
info.func = OptionsFrameResolutionButton_OnClick;
info.checked = nil;
UIDropDownMenu_AddButton(info);
end
end
My Code
Code:
function SupplyList_ProfileDropDown_OnLoad()
UIDropDownMenu_Initialize(SupplyList_ProfileDropDown, SupplyList_ProfileDropDown_Initialize);
UIDropDownMenu_SetSelectedID(SupplyList_ProfileDropDown, SL["PROFILE"]);
UIDropDownMenu_SetWidth(90, SupplyList_ProfileDropDown);
end
function SupplyList_ProfileDropDown_Initialize()
local info = UIDropDownMenu_CreateInfo();
for key, value in pairs(SL_PROFILES) do
info.text = value;
info.value = value;
info.func = SupplyList_SetProfile(value);
info.checked = nil;
UIDropDownMenu_AddButton(info);
end
end
function SupplyList_SetProfile(var)
SL["PROFILE"] = var;
SupplyList_GUIUpdate();
end