While many people won't agree with me, I found a nice way of making menus for Graal.
The menu is extremely flexible if set up right. Although there are a few aspects I could polish.
DISCLAIMER: It's late, I'm tired, don't feel like making everything 100% clear, I'll unfog later. It also might a little buggy, but this has worked before.
NPC Code:
if (created) {
setstring this.button_close,exit;
setstring this.button_next,next;
this.menux=80; //screenx of menu
this.menuy=120; //screen y of menu
this.menuwidth=300; //pixel width of menu
this.menuheight=400; //pixel height of menu
this.buttonxw=50; //pixel width of default buttons
this.buttonyh=20; //pixel height of default buttons
}
if (keypressed&&strequals(#p(1),q)&&this.menu_open != true) {
this.menu_open=true;
this.menu=1;
timeout=.05;
}
if (this.menu_open==true) {
//MENU 1
if (this.menu==1) {
setstring this.buttons,next,close; /*These will tell the show-function what buttons to show */
showimg 200,@b@This is a menu!,this.menux+20,this.menuy+10;
changeimgvis 200,5;
changeimgcolors 200,1,1,0,1;
}
if (this.menu==2) {
setstring this.buttons,close
showimg 200,@b@MENU #2 OMG!,this.menux+20,this.menuy+10;
changeimgvis 200,5;
changeimgcolors 200,1,1,0,1;
}
//button click control
for (i=0;i<strlen(this.buttons);i++) {
showimg 201+i,@b@#I(this.buttons,i),this.menux+10,this.men uy+this.menuheight-((this.buttonyh+1)*i);
changeimgvis 201,5;
if (mousescreenx in |this.menux+10,this.menux+10+this.buttonxw|&&mouse screeny in |this.menuy-((this.buttonyh+1)*i),this.menuy-((this.buttonyh+1)*i)-this.buttonyh|) {
changeimgcolors 201+i,1,0,0,1;
if (leftmousebutton) {
changeimgcolors 201+i,.2,0,0,1;
setstring this.cmd,#I(this.button_#I(this.buttons,i),1);
command(); //Calls the command for the button, should be within the
//strings declare at the start
}
}
}
function command() {
if (!strequals(#s(this.cmd),)) {
if (strequals(#s(this.cmd),exit)) {
close();
}
if (strequals(#s(this.cmd),next)) {
this.menu++;
}
}
setstrng this.cmd,;
clear();
}
timeout=.05;
}
function close() {
this.menu_open=0;
this.menu=0;
for (i=200;i=<300;i++) hideimg i;
}
function clear() {
for (i=0;i=<300;i++) hideimg i;
}
It's messy, simple, and probably not very ideal, but im tired, and it works for me, so blegh. Go knock yourselves out.
I would post the more complete version, but I'm not sure if the guys on Atrius would be mad or not.