OK, I have now made it work with as many submenus under submenus as you want!
You still use it in exactly the same way as before.
Here is the code for people with the matrixutils plugin:
sync on
type menutype
caption as string
submenu as word
stop as boolean
active as boolean
endtype
global dim menuitems(55) as menutype
global style1
global style2
global style3
global style4
global style5
global style6
global active
global selected
selected = -1
active = -1
style$ = "Fire"
select style$
case "Fire"
style1 = rgb(255,0,0)
style2 = rgb(255,255,0)
style3 = rgb(255,255,0)
style4 = rgb(255,0,0)
style5 = rgb(0,50,0)
style6 = rgb(0,100,0)
endcase
case "Ice"
style1 = rgb(255,255,255)
style2 = rgb(220,220,255)
style3 = rgb(220,220,255)
style4 = rgb(255,255,255)
style5 = rgb(128,128,128)
style6 = rgb(0,128,128)
endcase
case "Mud"
style1 = rgb(196,137,2)
style2 = rgb(162,114,2)
style3 = rgb(162,114,2)
style4 = rgb(196,137,2)
style5 = rgb(118,83,1)
style6 = rgb(255,255,0)
endcase
case "Black/White"
style1 = rgb(255,255,255)
style2 = rgb(255,255,255)
style3 = rgb(0,0,0)
style4 = rgb(0,0,0)
style5 = rgb(0,0,0)
style6 = rgb(255,255,255)
endcase
case "Sea"
style1 = rgb(0,255,128)
style2 = rgb(0,128,255)
style3 = rgb(0,128,255)
style4 = rgb(0,255,128)
style5 = rgb(0,0,0)
style6 = rgb(255,255,255)
endcase
case "Colourfull"
style1 = rgb(255,0,0)
style2 = rgb(0,0,255)
style3 = rgb(0,255,0)
style4 = rgb(255,255,0)
style5 = rgb(255,128,0)
style6 = rgb(0,0,0)
endcase
case "Grass"
style1 = rgb(0,255,0)
style2 = rgb(0,150,0)
style3 = rgb(0,150,0)
style4 = rgb(0,255,0)
style5 = rgb(0,0,0)
style6 = rgb(255,255,0)
endcase
case "Hell"
style1 = rgb(255,0,0)
style2 = rgb(0,0,0)
style3 = rgb(0,0,0)
style4 = rgb(255,0,0)
style5 = rgb(0,255,0)
style6 = rgb(255,255,0)
endcase
case "Blue"
style1 = rgb(0,0,255)
style2 = rgb(100,150,255)
style3 = rgb(100,150,255)
style4 = rgb(0,0,255)
style5 = rgb(128,200,255)
style6 = rgb(128,255,255)
endcase
case "Gold"
style1 = rgb(255,255,0)
style2 = rgb(155,105,0)
style3 = rgb(155,105,0)
style4 = rgb(255,255,0)
style5 = rgb(127,55,0)
style6 = rgb(127,0,0)
endcase
case "Silver"
style1 = rgb(128,128,128)
style2 = rgb(255,255,255)
style3 = rgb(255,255,255)
style4 = rgb(128,128,128)
style5 = rgb(50,50,50)
style6 = rgb(255,0,0)
endcase
case "Bronze"
style1 = rgb(215,172,0)
style2 = rgb(180,120,0)
style3 = rgb(180,120,0)
style4 = rgb(215,172,0)
style5 = rgb(0,0,0)
style6 = rgb(255,255,0)
endcase
endselect
`main
menuitems(0).caption = "File"
menuitems(0).submenu = 7
menuitems(1).caption = "Edit"
menuitems(1).submenu = 15
menuitems(2).caption = "View"
menuitems(2).submenu = 25
menuitems(3).caption = "Draw"
menuitems(3).submenu = 30
menuitems(4).caption = "Tools"
menuitems(4).submenu = 35
menuitems(5).caption = "Help"
menuitems(5).submenu = 40
menuitems(6).stop = 1
`file
menuitems(7).caption = "New"
menuitems(8).caption = "Open"
menuitems(9).caption = "Save"
menuitems(10).caption = "Save as"
menuitems(11).caption = "Export to text"
menuitems(12).caption = "Export to binary"
menuitems(13).caption = "Exit"
menuitems(14).stop = 1
`Edit
menuitems(15).caption = "Paste from prefabs"
menuitems(16).caption = "Paste from file"
menuitems(17).caption = "Set keyframe"
menuitems(18).stop = 1
`View
menuitems(25).caption = "Animation"
menuitems(26).caption = "Editor"
menuitems(27).stop = 1
`Draw
menuitems(30).caption = "Dynamic line"
menuitems(31).caption = "Static line"
menuitems(32).caption = "Erasor"
menuitems(33).stop = 1
`Tools
menuitems(35).caption = "Hide tool"
menuitems(36).caption = "Show tool"
menuitems(37).caption = "Options"
menuitems(38).stop = 1
`Help
menuitems(40).caption = "About StickAnimator"
menuitems(40).submenu = 45
menuitems(41).caption = "Help F1"
menuitems(42).stop = 1
menuitems(45).caption = "Stuff"
menuitems(46).caption = "More stuff"
menuitems(46).submenu = 48
menuitems(47).stop = 1
menuitems(48).caption = "Even more stuff"
menuitems(48).submenu = 50
menuitems(49).stop = 1
menuitems(50).caption = "Even more extra stuff"
menuitems(50).submenu = 52
menuitems(51).stop = 1
menuitems(52).caption = "Even more extra extra stuff"
menuitems(52).submenu = 54
menuitems(53).stop = 1
menuitems(54).caption = "Even more extra extra extra stuff"
menuitems(55).stop = 1
do
if selected > -1
msg$ = str$(selected)+" : "+menuitems(selected).caption
endif
ink rgb(255,255,255),0
text 0,500,msg$
text 0,520,str$(screen fps())
menu()
sync
cls 0
loop
function menu()
selected = -1
id = 0
mx = 0
do
if menuitems(id).stop then exit
cap$ = menuitems(id).caption
w = text width(cap$)+10
if (mousex() < mx or mousex() > mx + w or mousey() > 20) and active <> id
box mx,0,mx+w,20,style1,style2,style1,style2
ink style5,0
text mx+5,5,cap$
else
box mx,0,mx+w,20,style3,style4,style3,style4
ink style6,0
text mx+5,5,cap$
active = id
if menuitems(id).submenu > 0
submenu(mx,id)
else
if mouseclick()
selected = id
endif
endif
endif
inc mx,w+1
inc id
loop
box mx,0,screen width(),20,style1,style2,style1,style2
endfunction
function submenu(mx,id)
sub = menuitems(id).submenu
mw = 0
itemn = 0
itemo = 0
do
if menuitems(sub).stop then exit
mw = max(mw,text width(menuitems(sub).caption)+10)
inc itemn
inc sub
loop
sub = menuitems(id).submenu
box mx,21,mx+mw,(itemn*15)+22,style1,style2,style1,style2
ink style5,0
do
if menuitems(sub).stop then exit
if menuitems(sub).active then cact = sub
text mx+5,(itemo*15)+22,menuitems(sub).caption
inc sub
inc itemo
loop
sub = menuitems(id).submenu
if (mousex() >= mx and mousex() <= mx+mw and mousey() > 20 and mousey() < (itemn*15)+21) or (mousex() >= mx and mousex() <= mx+text width(menuitems(id).caption)+10 and mousey() <= 20) or cact > 0
sel = (mousey()-6)/15
if cact > 0 then sel = (cact-sub)+1
if sel > 0
box mx,(sel*15)+6,mx+mw,(sel*15)+22,style3,style4,style3,style4
ink style6,0
text mx+5,(sel*15)+7,menuitems((sub+sel)-1).caption
if menuitems((sub+sel)-1).submenu > 0
menuitems((sub+sel)-1).active = 1
subsubmenu(mx+mw+1,(sel*15)+6,(sel+sub)-1,mw)
else
if mouseclick()
selected = (sel+sub)-1
active = -1
endif
endif
endif
else
active = -1
endif
endfunction
function subsubmenu(x,y,id,omw)
sub = menuitems(id).submenu
mw = 0
itemn = 0
itemo = 0
oax = (x-omw)-1
oay = y
oaw = x-1
oah = y+15
do
if menuitems(sub).stop then exit
mw = max(mw,text width(menuitems(sub).caption)+10)
inc itemn
inc sub
loop
mh = itemn*15
if mh+y > screen height()
y = screen height()-mh
endif
if mw+x > screen width()
dec x,mw+omw+2
endif
sub = menuitems(id).submenu
box x,y,x+mw,y+mh+1,style1,style2,style1,style2
ink style5,0
do
if menuitems(sub).stop then exit
if menuitems(sub).active then cact = sub
text x+5,(itemo*15)+y+1,menuitems(sub).caption
inc sub
inc itemo
loop
sub = menuitems(id).submenu
if (mousex() >= x and mousex() <= x+mw and mousey() >= y and mousey() <= y+mh) or (mousex() >= oax and mousex() <= oaw and mousey() >= oay and mousey() <= oah) or cact > 0
if mousex() >= x and mousex() <= x+mw
sel = ((mousey()-y)+14)/15
else
sel = 0
endif
if cact > 0 then sel = (cact-sub)+1
if sel > 0
box x,((sel*15)+y)-15,x+mw,(sel*15)+y+1,style3,style4,style3,style4
ink style6,0
text x,((sel*15)+y)-13,menuitems((sub+sel)-1).caption
if menuitems((sub+sel)-1).submenu > 0
menuitems((sel+sub)-1).active = 1
subsubmenu(x+mw+1,(sel*15)+y-15,(sel+sub)-1,mw)
else
if mouseclick()
selected = (sel+sub)-1
menuitems(id).active = 0
prt = get_prt(id)
while prt <> 0
menuitems(prt).active = 0
prt = get_prt(prt)
endwhile
active = -1
endif
endif
endif
else
menuitems(id).active = 0
endif
endfunction
function get_prt(prt)
for d = 0 to array count(menuitems(0))
if menuitems(d).submenu = prt
exitfunction d
endif
next d
endfunction 0
Here is the code for people without it:
sync on
type menutype
caption as string
submenu as word
stop as boolean
active as boolean
endtype
global dim menuitems(55) as menutype
global style1
global style2
global style3
global style4
global style5
global style6
global active
global selected
selected = -1
active = -1
style$ = "Fire"
select style$
case "Fire"
style1 = rgb(255,0,0)
style2 = rgb(255,255,0)
style3 = rgb(255,255,0)
style4 = rgb(255,0,0)
style5 = rgb(0,50,0)
style6 = rgb(0,100,0)
endcase
case "Ice"
style1 = rgb(255,255,255)
style2 = rgb(220,220,255)
style3 = rgb(220,220,255)
style4 = rgb(255,255,255)
style5 = rgb(128,128,128)
style6 = rgb(0,128,128)
endcase
case "Mud"
style1 = rgb(196,137,2)
style2 = rgb(162,114,2)
style3 = rgb(162,114,2)
style4 = rgb(196,137,2)
style5 = rgb(118,83,1)
style6 = rgb(255,255,0)
endcase
case "Black/White"
style1 = rgb(255,255,255)
style2 = rgb(255,255,255)
style3 = rgb(0,0,0)
style4 = rgb(0,0,0)
style5 = rgb(0,0,0)
style6 = rgb(255,255,255)
endcase
case "Sea"
style1 = rgb(0,255,128)
style2 = rgb(0,128,255)
style3 = rgb(0,128,255)
style4 = rgb(0,255,128)
style5 = rgb(0,0,0)
style6 = rgb(255,255,255)
endcase
case "Colourfull"
style1 = rgb(255,0,0)
style2 = rgb(0,0,255)
style3 = rgb(0,255,0)
style4 = rgb(255,255,0)
style5 = rgb(255,128,0)
style6 = rgb(0,0,0)
endcase
case "Grass"
style1 = rgb(0,255,0)
style2 = rgb(0,150,0)
style3 = rgb(0,150,0)
style4 = rgb(0,255,0)
style5 = rgb(0,0,0)
style6 = rgb(255,255,0)
endcase
case "Hell"
style1 = rgb(255,0,0)
style2 = rgb(0,0,0)
style3 = rgb(0,0,0)
style4 = rgb(255,0,0)
style5 = rgb(0,255,0)
style6 = rgb(255,255,0)
endcase
case "Blue"
style1 = rgb(0,0,255)
style2 = rgb(100,150,255)
style3 = rgb(100,150,255)
style4 = rgb(0,0,255)
style5 = rgb(128,200,255)
style6 = rgb(128,255,255)
endcase
case "Gold"
style1 = rgb(255,255,0)
style2 = rgb(155,105,0)
style3 = rgb(155,105,0)
style4 = rgb(255,255,0)
style5 = rgb(127,55,0)
style6 = rgb(127,0,0)
endcase
case "Silver"
style1 = rgb(128,128,128)
style2 = rgb(255,255,255)
style3 = rgb(255,255,255)
style4 = rgb(128,128,128)
style5 = rgb(50,50,50)
style6 = rgb(255,0,0)
endcase
case "Bronze"
style1 = rgb(215,172,0)
style2 = rgb(180,120,0)
style3 = rgb(180,120,0)
style4 = rgb(215,172,0)
style5 = rgb(0,0,0)
style6 = rgb(255,255,0)
endcase
endselect
`main
menuitems(0).caption = "File"
menuitems(0).submenu = 7
menuitems(1).caption = "Edit"
menuitems(1).submenu = 15
menuitems(2).caption = "View"
menuitems(2).submenu = 25
menuitems(3).caption = "Draw"
menuitems(3).submenu = 30
menuitems(4).caption = "Tools"
menuitems(4).submenu = 35
menuitems(5).caption = "Help"
menuitems(5).submenu = 40
menuitems(6).stop = 1
`file
menuitems(7).caption = "New"
menuitems(8).caption = "Open"
menuitems(9).caption = "Save"
menuitems(10).caption = "Save as"
menuitems(11).caption = "Export to text"
menuitems(12).caption = "Export to binary"
menuitems(13).caption = "Exit"
menuitems(14).stop = 1
`Edit
menuitems(15).caption = "Paste from prefabs"
menuitems(16).caption = "Paste from file"
menuitems(17).caption = "Set keyframe"
menuitems(18).stop = 1
`View
menuitems(25).caption = "Animation"
menuitems(26).caption = "Editor"
menuitems(27).stop = 1
`Draw
menuitems(30).caption = "Dynamic line"
menuitems(31).caption = "Static line"
menuitems(32).caption = "Erasor"
menuitems(33).stop = 1
`Tools
menuitems(35).caption = "Hide tool"
menuitems(36).caption = "Show tool"
menuitems(37).caption = "Options"
menuitems(38).stop = 1
`Help
menuitems(40).caption = "About StickAnimator"
menuitems(40).submenu = 45
menuitems(41).caption = "Help F1"
menuitems(42).stop = 1
menuitems(45).caption = "Stuff"
menuitems(46).caption = "More stuff"
menuitems(46).submenu = 48
menuitems(47).stop = 1
menuitems(48).caption = "Even more stuff"
menuitems(48).submenu = 50
menuitems(49).stop = 1
menuitems(50).caption = "Even more extra stuff"
menuitems(50).submenu = 52
menuitems(51).stop = 1
menuitems(52).caption = "Even more extra extra stuff"
menuitems(52).submenu = 54
menuitems(53).stop = 1
menuitems(54).caption = "Even more extra extra extra stuff"
menuitems(55).stop = 1
do
if selected > -1
msg$ = str$(selected)+" : "+menuitems(selected).caption
endif
ink rgb(255,255,255),0
text 0,500,msg$
text 0,520,str$(screen fps())
menu()
sync
cls 0
loop
function menu()
selected = -1
id = 0
mx = 0
do
if menuitems(id).stop then exit
cap$ = menuitems(id).caption
w = text width(cap$)+10
if (mousex() < mx or mousex() > mx + w or mousey() > 20) and active <> id
box mx,0,mx+w,20,style1,style2,style1,style2
ink style5,0
text mx+5,5,cap$
else
box mx,0,mx+w,20,style3,style4,style3,style4
ink style6,0
text mx+5,5,cap$
active = id
if menuitems(id).submenu > 0
submenu(mx,id)
else
if mouseclick()
selected = id
endif
endif
endif
inc mx,w+1
inc id
loop
box mx,0,screen width(),20,style1,style2,style1,style2
endfunction
function submenu(mx,id)
sub = menuitems(id).submenu
mw = 0
itemn = 0
itemo = 0
do
if menuitems(sub).stop then exit
mw = max(mw,text width(menuitems(sub).caption)+10)
inc itemn
inc sub
loop
sub = menuitems(id).submenu
box mx,21,mx+mw,(itemn*15)+22,style1,style2,style1,style2
ink style5,0
do
if menuitems(sub).stop then exit
if menuitems(sub).active then cact = sub
text mx+5,(itemo*15)+22,menuitems(sub).caption
inc sub
inc itemo
loop
sub = menuitems(id).submenu
if (mousex() >= mx and mousex() <= mx+mw and mousey() > 20 and mousey() < (itemn*15)+21) or (mousex() >= mx and mousex() <= mx+text width(menuitems(id).caption)+10 and mousey() <= 20) or cact > 0
sel = (mousey()-6)/15
if cact > 0 then sel = (cact-sub)+1
if sel > 0
box mx,(sel*15)+6,mx+mw,(sel*15)+22,style3,style4,style3,style4
ink style6,0
text mx+5,(sel*15)+7,menuitems((sub+sel)-1).caption
if menuitems((sub+sel)-1).submenu > 0
menuitems((sub+sel)-1).active = 1
subsubmenu(mx+mw+1,(sel*15)+6,(sel+sub)-1,mw)
else
if mouseclick()
selected = (sel+sub)-1
active = -1
endif
endif
endif
else
active = -1
endif
endfunction
function subsubmenu(x,y,id,omw)
sub = menuitems(id).submenu
mw = 0
itemn = 0
itemo = 0
oax = (x-omw)-1
oay = y
oaw = x-1
oah = y+15
do
if menuitems(sub).stop then exit
mw = max(mw,text width(menuitems(sub).caption)+10)
inc itemn
inc sub
loop
mh = itemn*15
if mh+y > screen height()
y = screen height()-mh
endif
if mw+x > screen width()
dec x,mw+omw+2
endif
sub = menuitems(id).submenu
box x,y,x+mw,y+mh+1,style1,style2,style1,style2
ink style5,0
do
if menuitems(sub).stop then exit
if menuitems(sub).active then cact = sub
text x+5,(itemo*15)+y+1,menuitems(sub).caption
inc sub
inc itemo
loop
sub = menuitems(id).submenu
if (mousex() >= x and mousex() <= x+mw and mousey() >= y and mousey() <= y+mh) or (mousex() >= oax and mousex() <= oaw and mousey() >= oay and mousey() <= oah) or cact > 0
if mousex() >= x and mousex() <= x+mw
sel = ((mousey()-y)+14)/15
else
sel = 0
endif
if cact > 0 then sel = (cact-sub)+1
if sel > 0
box x,((sel*15)+y)-15,x+mw,(sel*15)+y+1,style3,style4,style3,style4
ink style6,0
text x,((sel*15)+y)-13,menuitems((sub+sel)-1).caption
if menuitems((sub+sel)-1).submenu > 0
menuitems((sel+sub)-1).active = 1
subsubmenu(x+mw+1,(sel*15)+y-15,(sel+sub)-1,mw)
else
if mouseclick()
selected = (sel+sub)-1
menuitems(id).active = 0
prt = get_prt(id)
while prt <> 0
menuitems(prt).active = 0
prt = get_prt(prt)
endwhile
active = -1
endif
endif
endif
else
menuitems(id).active = 0
endif
endfunction
function get_prt(prt)
for d = 0 to array count(menuitems(0))
if menuitems(d).submenu = prt
exitfunction d
endif
next d
endfunction 0
function max(val1, val2)
if val1 > val2
val3 = val1
else
val3 = val2
endif
endfunction val3