Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-22-2004, 11:28 AM
middo middo is offline
VHE Monkey
middo's Avatar
Join Date: Aug 2002
Location: California
Posts: 327
middo is on a distinguished road
Send a message via AIM to middo
A Great Menu GUI Method

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.

Last edited by Loriel; 11-22-2004 at 02:43 PM..
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:41 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.