PDA

View Full Version : ShowSignWindow


Warcaptain
05-16-2006, 06:35 AM
I made a little script to show the same type of window used in signs and Q-Menu.

It uses stretchx/stretchy for the sides and uses showpoly for the center so it uses a minimal ammount of images. (9 total) This is good because before we had to have hundreds of images. x_x

It also allows you to draw as many sign windows as you want (so long as theres not a limit to image indexes.. which I do not think there is)

Notes:

temp.letters (the last parameter that sets what letters file to use) does not have to be set, if its blank it will set it to the default player.letters that has been set in-game.
temp.vis does not have to be set either, by default it will draw the box on layer 4
included is the function HideSignBox(index) to hide the signbox with said index. DrawSignBox() returns the index of the sign it makes.. so you would do var = DrawSignBox(0,0,100,100); and var would be equal to the value of the drawn box.


Questions? Comments? Opinions?


function DrawSignBox(temp.x,temp.y,temp.w,temp.h,temp.lette rs,temp.vis){
this.signboxes++;
if (temp.letters=="") temp.letters=player.letters;
if (temp.x<0) temp.x=0;
if (temp.y<0) temp.y=0;
if (temp.w<32) temp.w=32;
if (temp.h<64) temp.h=64;
if (temp.x+temp.w>screenwidth) temp.w=screenwidth;
if (temp.y+temp.h>screenheight) temp.w=screenheight;
if (temp.vis<4) temp.vis=4;
temp.id=(this.signboxes*9);
showimg(1000+temp.id,temp.letters,temp.x,temp.y);
changeimgpart(1000+temp.id,0,192,16,32);
changeimgvis(1000+temp.id,temp.vis);
temp.id++;
showimg(1000+temp.id,temp.letters,temp.x-8+(temp.w/2),temp.y);
changeimgvis(1000+temp.id,temp.vis);
changeimgpart(1000+temp.id,64,192,16,32);
findImg(1000+temp.id).stretchx=(temp.w-32)/16;
temp.id++;
showimg(1000+temp.id,temp.letters,temp.x+temp.w-16,temp.y);
changeimgpart(1000+temp.id,16,192,16,32);
changeimgvis(1000+temp.id,temp.vis);
temp.id++;
showimg(1000+temp.id,temp.letters,temp.x,temp.y+te mp.h-32);
changeimgpart(1000+temp.id,32,192,16,32);
changeimgvis(1000+temp.id,temp.vis);
temp.id++;
showimg(1000+temp.id,temp.letters,temp.x-8+(temp.w/2),temp.y+temp.h-32);
changeimgvis(1000+temp.id,temp.vis);
changeimgpart(1000+temp.id,80,192,16,32);
findImg(1000+temp.id).stretchx=(temp.w-32)/16;
temp.id++;
showimg(1000+temp.id,temp.letters,temp.x+temp.w-16,temp.y+temp.h-32);
changeimgpart(1000+temp.id,48,192,16,32);
changeimgvis(1000+temp.id,temp.vis);
temp.id++;
showimg(1000+temp.id,temp.letters,temp.x,temp.y-16+(temp.h/2));
changeimgpart(1000+temp.id,96,192,16,32);
changeimgvis(1000+temp.id,temp.vis);
findImg(1000+temp.id).stretchy=(temp.h-32)/32;
temp.id++;
showimg(1000+temp.id,temp.letters,temp.x+temp.w-16,temp.y-16+(temp.h/2));
changeimgpart(1000+temp.id,112,192,16,32);
changeimgvis(1000+temp.id,temp.vis);
findImg(1000+temp.id).stretchy=(temp.h-32)/32;
temp.id++;
showpoly(1000+temp.id,{temp.x+16,temp.y+32,temp.x+ 16+(temp.w-32),temp.y+32,temp.x+16+(temp.w-32),temp.y+32+(temp.h-64),temp.x+16,temp.y+32+(temp.h-64)});
changeimgvis(1000+temp.id,temp.vis);
temp.colors=getimgpixel(temp.letters,72,222);
changeimgcolors(1000+temp.id,temp.colors[0],temp.colors[1],temp.colors[2],1);
return this.signboxes;
}

function HideSignBox(temp.i)
hideimgs(1000+(temp.i*9),1009+(temp.i*9));

Rick
05-16-2006, 09:40 AM
Don't put temp. in the function argument declaration.

Warcaptain
05-16-2006, 10:02 AM
Why? I thought it would be better, so that they were only used in that function and wouldnt affect other things.

napo_p2p
05-16-2006, 10:25 AM
Why? I thought it would be better, so that they were only used in that function and wouldnt affect other things.

No don't do that.

As Rick said, you don't need temp. in the function argument declaration. The temp. prefix is automatically added.