Here's a little something I just knocked up:
remstart
button maker - by spooky
parameters for makebutton:
01 = x position
02 = y position
03 = text for button
04 = font
05 = font size
06 = text colour (normal)
07 = text colour (mouse over)
08 = border colour (normal)
09 = border colour (mouse over)
10 = button width (0=automatic, or fixed pixel size)
11 = button height (0=automatic, or fixed pixel height)
12 = x justification (0=centred, 1=left, 2=right)
13 = y justification (0=centered, 1=top, 2=bottom)
remend
sync on : sync rate 0
gosub initbuttons
f$="Arial" : fs=14
blue as dword
white as dword
red as dword
green as dword
blue = rgb(0,0,255)
white = rgb(255,255,255)
red = rgb(255,0,0)
green = rgb(0,255,0)
makebutton(10,50,"Button 1",f$,fs,white,blue,white,white,120,0,0,0)
makebutton(10,100,"Another Button",f$,fs,white,blue,white,white,120,0,0,0)
makebutton(10,150,"Yet Another Button",f$,fs,white,blue,white,white,120,0,0,0)
makebutton(10,200,"BIG BUTTON","Times New Roman",40,white,green,white,red,0,0,0,0)
makebutton(150,50,"Option 1",f$,fs,white,red,blue,white,0,0,0,0)
makebutton(150,100,"Option 2",f$,fs,white,red,blue,white,0,0,0,0)
makebutton(150,150,"Option 456",f$,fs,white,red,blue,white,0,0,0,0)
makebutton(300,50,"Start Game",f$,fs,blue,white,blue,white,120,0,1,0)
makebutton(300,100,"Options",f$,fs,blue,white,blue,white,120,0,1,0)
makebutton(300,150,"Quit",f$,fs,blue,white,blue,white,120,0,1,0)
do
cls
butpressed=drawbuttons()
if butpressed > 0
ink rgb(255,255,255),0
text 0,0,"You are pressing button "+str$(butpressed)
endif
sync
loop
function makebutton(x as integer, y as integer, s$ as string, f$ as string, fs as integer, sc as dword, sr as dword, bc as dword, br as dword, bw as integer, bh as integer, xj as integer, yj as integer)
inc bt
b(bt).x=x : b(bt).y=y
b(bt).s=s$
b(bt).f=f$ : b(bt).fs=fs
b(bt).sc=sc : b(bt).sr=sr
b(bt).bc=bc : b(bt).br=br
b(bt).bw=bw : b(bt).bh=bh
b(bt).xj=xj : b(bt).yj=yj
endfunction
function drawbuttons
v=0 : mx=mousex() : my=mousey() : mc=mouseclick()
for f=1 to bt
set text font b(f).f : set text size b(f).fs
s$=b(f).s : tw=text width(s$) : th=text height(s$)
w=b(f).bw : if w = 0 then w=tw+10
h=b(f).bh : if h = 0 then h=th+10
xj=b(f).xj : yj=b(f).yj : x=b(f).x : y=b(f).y
x1=x : x2=x+w : y1=y : y2=y+h
rollover=0
if mx >= x1 and mx <= x2 and my >= y1 and my <= y2
rollover=1
if mc = 1
v=f
endif
endif
if rollover=1 : ink b(f).sc,0 : else : ink b(f).sr,0 : endif
if xj=1 : l=x+5 : else : if xj=0 : l=((x1+x2)/2)-(tw/2) : else : l=x2-5-tw : endif : endif
if yj=1 : t=y+5 : else : if yj=0 : t=((y1+y2)/2)-(th/2) : else : t=y2-5-th : endif : endif
text l,t,s$
if rollover=1 : ink b(f).bc,0 : else : ink b(f).br,0 : endif
line x1,y1,x2,y1 : line x2,y1,x2,y2 : line x2,y2,x1,y2 : line x1,y2,x1,y1
next f
set text font defaultfont$ : set text size defaultsize
endfunction v
initbuttons:
type but
x as integer
y as integer
s as string
f as string
fs as integer
sc as dword
sr as dword
bc as dword
br as dword
bw as integer
bh as integer
xj as integer
yj as integer
endtype
dim b(50) as but
global bt,defaultfont$,defaultsize
bt=0 : defaultfont$ = text font$() : defaultsize = text size()
return
If your mansion house needs haunting, just call Rentaghost!