Centauri Soldier
12-05-2008, 10:25 AM
Hey fellas,
ever get tired of sifting through millions of lines of code in your On Menu section. No worries here's the trick.
--this table creates your menu responses--best if it's in your globals and menu items can be in any order
tAFMenuItem = {};
tAFMenuItem[1] = {};
tAFMenuItem[1].Text = "&Exit";
tAFMenuItem[1].Code = [[
Application.Exit(0);
]]
tAFMenuItem[1].ID = 199; --this can be set to nil if you dont need a menu ID identifier. Use for duplicate Menu Item Names
--Put this table on startup somewhere
tAFMenuButtonProp = {};
tAFMenuButtonProp.Width = 1;
tAFMenuButtonProp.Height = 1;
tAFMenuButtonProp.Visible = false;
--put this function in your globals
--======================>>>>>>>>>>>>>>>>>>>>>>>>>>>
function Application.ClickMenu(tAFMenuTable) --[[>>
<< >>
<< >>
<<<<<<<<<<<<<<<<<<<<<==========================--]]
for nAFMenuIndex = 1, Table.Count(tAFMenuItem) do
if tAFMenuItem[nAFMenuIndex].ID then
if tAFMenuTable.Text == tAFMenuItem[nAFMenuIndex].Text and tAFMenuTable.ID == tAFMenuItem[nAFMenuIndex].ID then
Page.CreateObject(OBJECT_BUTTON, "btn AF menu code", tAFMenuButtonProp);
Page.SetObjectScript("btn AF menu code", "On Click", tAFMenuItem[nAFMenuIndex].Code);
Page.ClickObject("btn AF menu code");
Page.CreateObject(OBJECT_BUTTON, "btn AF menu code", tAFMenuButtonProp);
break;
end
else
if tAFMenuTable.Text == tAFMenuItem[nAFMenuIndex].Text then
Page.CreateObject(OBJECT_BUTTON, "btn AF menu code", tAFMenuButtonProp);
Page.SetObjectScript("btn AF menu code", "On Click", tAFMenuItem[nAFMenuIndex].Code);
Page.ClickObject("btn AF menu code");
Page.CreateObject(OBJECT_BUTTON, "btn AF menu code", tAFMenuButtonProp);
break;
end
end
end
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end--|||||||||||||END FUNCTION|||||||||||||||||
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
--call the function in your On Menu section
Application.ClickMenu(e_ItemInfo);
Please let me know if you find a bug,
Enjoy!
~CS
ever get tired of sifting through millions of lines of code in your On Menu section. No worries here's the trick.
--this table creates your menu responses--best if it's in your globals and menu items can be in any order
tAFMenuItem = {};
tAFMenuItem[1] = {};
tAFMenuItem[1].Text = "&Exit";
tAFMenuItem[1].Code = [[
Application.Exit(0);
]]
tAFMenuItem[1].ID = 199; --this can be set to nil if you dont need a menu ID identifier. Use for duplicate Menu Item Names
--Put this table on startup somewhere
tAFMenuButtonProp = {};
tAFMenuButtonProp.Width = 1;
tAFMenuButtonProp.Height = 1;
tAFMenuButtonProp.Visible = false;
--put this function in your globals
--======================>>>>>>>>>>>>>>>>>>>>>>>>>>>
function Application.ClickMenu(tAFMenuTable) --[[>>
<< >>
<< >>
<<<<<<<<<<<<<<<<<<<<<==========================--]]
for nAFMenuIndex = 1, Table.Count(tAFMenuItem) do
if tAFMenuItem[nAFMenuIndex].ID then
if tAFMenuTable.Text == tAFMenuItem[nAFMenuIndex].Text and tAFMenuTable.ID == tAFMenuItem[nAFMenuIndex].ID then
Page.CreateObject(OBJECT_BUTTON, "btn AF menu code", tAFMenuButtonProp);
Page.SetObjectScript("btn AF menu code", "On Click", tAFMenuItem[nAFMenuIndex].Code);
Page.ClickObject("btn AF menu code");
Page.CreateObject(OBJECT_BUTTON, "btn AF menu code", tAFMenuButtonProp);
break;
end
else
if tAFMenuTable.Text == tAFMenuItem[nAFMenuIndex].Text then
Page.CreateObject(OBJECT_BUTTON, "btn AF menu code", tAFMenuButtonProp);
Page.SetObjectScript("btn AF menu code", "On Click", tAFMenuItem[nAFMenuIndex].Code);
Page.ClickObject("btn AF menu code");
Page.CreateObject(OBJECT_BUTTON, "btn AF menu code", tAFMenuButtonProp);
break;
end
end
end
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end--|||||||||||||END FUNCTION|||||||||||||||||
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
--call the function in your On Menu section
Application.ClickMenu(e_ItemInfo);
Please let me know if you find a bug,
Enjoy!
~CS