所以我一直在寻找Lua表上的信息,但有点卡住了。
local profiles = {
{ text = "Profile 1", name = "Profile 1", func = fuction() loadProfile("Profile 1");, INT = .5, STR = .5, AGI = .5, CRIT = .5, HASTE = .5, MAS = .5, MS = .5, VERS = .5},
{ text = "Profile 2", name = "Profile 2", INT = .6, STR = .6, AGI = .6, CRIT = .6, HASTE = .6, MAS = .6, MS = .6, VERS = .6},
{ text = "Profile 3", name = "Profile 3", INT = .7, STR = .7, AGI = .7, CRIT = .7, HASTE = .7, MAS = .7, MS = .7, VERS = .7},
{ text = "Profile 4", name = "Profile 4", INT = .8, STR = .8, AGI = .8, CRIT = .8, HASTE = .8, MAS = .8, MS = .8, VERS = .8},
}
function loadProfile(name)
--Loop through table using pairs
--Once name is found, load INT into INTELLECTSTAT, etc
end
local profilesDropDown = CreateFrame("Frame", nil, ActualValue, "UIDropDownMenuTemplate")
menuFrame:SetPoint("TOPLEFT", ActualValue, 300, -40)
EasyMenu(profiles, profilesDropDown, ActualValue, 300 , -40, "Profiles");
如您所见,我被困在加载信息中,当用户单击这些菜单项之一时,它将触发该菜单项的功能,在本例中为loadProfile。
接下来,我认为我需要遍历表以查找名称,一旦找到就加载所有变量,但是我不确定如何执行此操作,或者不确定是否以最佳方式构造表。
最后,我很难从函数调用的角度了解DropDown的文档,并且想知道我是否做对了?(在底部http://www.wowwiki.com/API_EasyMenu处使用的示例)
谢谢大家的帮助!
将GUI与“业务逻辑”混合使用并不理想。
首先,将配置文件创建为单独的表:
local profiles = {
["Profile 1"] = {
INT = .5, STR = .5, AGI = .5,
},
["Profile 2"] = {
INT = .6, STR = .6, AGI = .6,
},
}
然后,这样编写菜单项:
local function loadProfile(_, prof)
INTELLECTSTAT = prof.INT
end
local menuItems = {
{ text = "Profile 1", func = loadProfile, arg1 = profiles["Profile 1"] },
{ text = "Profile 2", func = loadProfile, arg1 = profiles["Profile 2"] },
}
...
EasyMenu(menuItems, ...)
(您可以轻松地以编程方式构建menuItems,而无需像我在此处那样手动进行。)
我对《魔兽世界》不熟悉。我从您链接到的站点获取了信息:它说菜单回调具有签名(self,arg1,arg2,checked)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句