Wow, only one person I gave credit to and I spelt their name wrong. Sorry about that. I have changed it, not because I felt I had to but because I felt stupid with it spelt wrong once I knew it.
Well, I'm going to change it back to regular fonts anyway. Bitmap fonts looked good on paper.
Edit:
No more bitmap fonts (and so can work without any media)
-"Click He" problem resolved itself due to this.
The "x" in the corner is an image, therefore looks better.
`| Version 1.1 |
lock pixels
` ______________________________________________
`| These types are necessary for the gui to |
`| work. They are here only because Dark Basic |
`| Pro requires that they are placed physically |
`| above where they are used. Just include this |
`| file in whatever you are using these |
`| functions for and don't worry about it. |
type window : ` |
name as string : spr as integer : img as integer : priority as integer : active as boolean
endtype : type button : ` |
name as string : win as integer : img as integer : spr as integer : clicked as boolean : active as boolean
endtype : type inputbox : ` |
name as string : win as integer : img as integer : spr as integer : txt as string : active as boolean
endtype : type checkbox : ` |
name as string : win as integer : spr as integer : value as boolean : active as boolean
endtype : type option : ` |
name as string : win as integer : spr as integer : value as boolean : group as integer : active as boolean
endtype : type user_input : ` |
click as boolean : mmx as integer : mmy as integer : mx as integer : my as integer
endtype : type selected_properties : ` |
window as integer : window_focus as integer : offsetx as integer : offsety as integer : inputbox as integer
endtype : type attached_sprites : ` |
spr as integer : win as integer : offsetx as integer : offsety as integer
endtype : type gui_system : ` |
delay as integer : holdc as boolean : holdo as boolean
endtype : type advanced_ink : ` |
r as integer : g as integer : b as integer
endtype : ` |
`|______________________________________________|
unlock pixels
setup()
` ______________________________________________
`| |
`| Main Loop |
`|______________________________________________|
do
sync
text 0,0,"Screen Fps: "+str$(screen fps())
if window_exist("Welcome!")=1
if l mod 200=0
a$="This is a scrolling string of text... Admire it! "
box_window("Welcome!",90,10,298,40,windowcolor3)
text_window("Welcome!",90,10,right$(a$,wrap(l/200,0,len(a$)-1))+left$(a$,len(a$)-wrap(l/200,0,len(a$)-1)-1),1)
endif
endif
if user.click=1
if button_exist("This is a text based button")=1
if button_clicked("This is a text based button")=1
if window_exist("This was generated")=0
make_window("This was generated")
size_window("This was generated",300,100)
text_window("This was generated",0,0,"This was made when you clicked the button. The text here returns automatically so I can make this message as long as I want.",2)
endif
endif
endif
if button_exist("An image button")=1
if button_clicked("An image button")=1
if window_exist("Owned!")=0
make_window("Owned!")
size_window("Owned!",200,50)
position_window("Owned!",150,300)
text_window("Owned!",0,0,"Wasn't that fancy!",1)
make_button("Click here",2)
attach_button("Click here","Owned!",112,17)
endif
endif
endif
if button_exist("Click here")=1
if button_clicked("Click here")=1
if window_exist("Input box")=0
make_window("Input box")
size_window("Input box",300,200)
position_window("Input box",50,20)
make_inputbox("Enter stuff:")
size_inputbox("Enter stuff:",280,165)
attach_inputbox("Enter stuff:","Input box",10,10)
endif
endif
endif
if button_exist("Collect Data")=1
if button_clicked("Collect Data")=1
if window_exist("Data:")=0
d_ink(0,128,255)
set text size 20
set text font "Kristen ITC"
make_window("Data:")
size_window("Data:",80,300)
position_window("Data:",550,170)
make_checkbox("Happy?")
size_checkbox("Happy?",15,15)
attach_checkbox("Happy?","Data:",2,10)
text_window("Data:",20,10,"You are happy",2)
make_checkbox("Useful?")
size_checkbox("Useful?",15,15)
attach_checkbox("Useful?","Data:",2,60)
text_window("Data:",20,60,"This gui seems useful",2)
text_window("Data:",5,150,"How do you rank this gui?",2)
make_option("Best")
size_option("Best",15,15)
group_option("Best",1)
attach_option("Best","Data:",10,220)
text_window("Data:",30,220,"Best",2)
make_option("Good")
size_option("Good",15,15)
group_option("Good",1)
attach_option("Good","Data:",10,240)
text_window("Data:",30,240,"Good",2)
make_option("W00t")
size_option("W00t",15,15)
group_option("W00t",1)
attach_option("W00t","Data:",10,260)
text_window("Data:",30,260,"W00t",2)
d_ink(255,255,255)
set text size 12
set text font "fixedsys"
endif
endif
endif
endif
if escapekey()=1
cleanup_gui()
end
endif
yrotate object 1,object angle y(1)+0.1
handle_gui()
inc l
loop
end
` ______________________________________________
`| |
`| Functions |
`|______________________________________________|
`| |
`| All functions were either created by me, |
`| modified by me, or will have credit given |
`| to the original author. |
`| |
`| It is not necessary that you use my free/use |
`| functions for images/sprites which are not |
`| the ones for the windows. You can if you |
`| want, either works. |
`| |
`| |
`| -Daemon |
`|______________________________________________|
`| |
`| Bitmap fonts made by Scraggle (Obsolete) |
`|______________________________________________|
` ______________________________________________
`| |
`| Setup |
`|______________________________________________|
`| |
`| These functions are specific to this program |
`| and only for organization. |
`|______________________________________________|
function setup()
sync on
sync rate 0
color backdrop 0,0
set image colorkey 255,0,255
randomize timer()
autocam off
disable escapekey
move camera -13
setup_required()
lock pixels
unlock pixels
box 0,0,10,10,rgb(rnd(255),rnd(255),rnd(255)),rgb(rnd(255),rnd(255),rnd(255)),rgb(rnd(255),rnd(255),rnd(255)),rgb(rnd(255),rnd(255),rnd(255))
get image free_image("Color Box"),0,0,10,10,1
size_image(val(images(0)),50,50)
setup_windows()
setup_buttons()
sprite free_sprite("Color Box"),0,0,use_image("Color Box")
attach_sprite(val(sprites(0)),"Welcome!",220,125)
make object sphere 1,10,3,20
set object wireframe 1,1
color object 1,rgb(0,255,255)
set object emissive 1,rgb(0,255,0)
endfunction
function setup_windows()
make_window("Welcome!")
position_window("Welcome!",200,250)
size_window("Welcome!",300,200)
text_window("Welcome!",0,0,"Hello",2)
text_window("Welcome!",61,60,"This is a really long line of text which does not fit onto one line on this window.",2)
paste_image_window("Welcome!",10,61,use_image("Color Box"))
make_window("Hi Max.")
position_window("Hi Max.",300,10)
make_window("Yet another test...")
size_window("Yet another test...",150,250)
text_window("Yet another test...",0,0,"You are probably wondering what my (awesome) color box image is for. Well, on this window it is actually a button!",2)
position_window("Yet another test...",0,200)
endfunction
function setup_buttons()
make_button("Collect Data",0)
size_button("Collect Data",60,100,2)
attach_button("Collect Data","Welcome!",70,150)
make_button("This is a text based button",2)
size_button("This is a text based button",67,100,2)
attach_button("This is a text based button","Hi Max.",15,10)
make_button_image("An image button",use_image("Color Box"))
attach_button("An image button","Yet another test...",70,140)
endfunction
` ______________________________________________
`| |
`| As the name of this function suggests, this |
`| is the necessary setup function for my |
`| windows. The constants can be changed to |
`| other values. |
`|______________________________________________|
function setup_required()
#Constant bmp 1
#Constant windowcolor1 rgb(0,30,90)
#Constant windowcolor2 rgb(240,40,10)
#Constant windowcolor3 rgb(50,70,80)
#Constant windowcolor4 rgb(0,60,180)
#Constant windowalpha 230
#Constant windowfontname "Gungsuh"
#Constant windowfontsize 15
#Constant windowfontcolor rgb(255,0,0)
#Constant buttoncolor1 rgb(140,190,210)
#Constant buttoncolor2 rgb(100,150,170)
#Constant buttonfontname "Arial"
#Constant buttonfontsize 17
#Constant buttonfontcolor rgb(255,255,0)
#Constant inputboxcolor rgb(0,255,255)
#Constant inputfontname "Times New Roman"
#Constant inputfontsize 20
#Constant inputfontcolor rgb(0,20,60)
#Constant checkboxcolor1 rgb(0,20,60)
#Constant checkboxcolor2 rgb(255,255,255)
#Constant optioncolor1 rgb(0,20,60)
#Constant optioncolor2 rgb(255,255,255)
global dim images(1) as string
global dim sprites(1) as string
global dim asprites(0) as attached_sprites
global dim win(0) as window
global dim but(0) as button
global dim inp(0) as inputbox
global dim che(0) as checkbox
global dim opt(0) as option
global dim misc(100) as string
global user as user_input
global selected as selected_properties
global gui as gui_system
global d_ink as advanced_ink
create bitmap bmp,screen width(),screen height()
set current bitmap 0
image_memblock(1,1,1)
make image from memblock free_image("Pointer"),1
sprite free_sprite("Pointer"),0,0,use_image("Pointer")
delete memblock 1
make_close_image()
make_checkbox_image()
make_option_image()
d_ink(255,255,255)
endfunction
` ______________________________________________
`| |
`| Cleanup Gui |
`|______________________________________________|
`| |
`| Have this run when exiting the program to |
`| delete files which my functions had to |
`| create. It is not necessary for the gui to |
`| work, it's just incase you don't want to |
`| leave a byte worth of files on people's |
`| computers. |
`|______________________________________________|
function cleanup_gui()
delete file "checkbox_temp.bmp"
delete file "option_temp.bmp"
endfunction
` ______________________________________________
`| |
`| Free/Use |
`|______________________________________________|
`| |
`| Give images/sprites/windows names instead of |
`| numbers. Window functions need the name of |
`| the window. |
`|______________________________________________|
function free_image(name$)
repeat
inc i
until image exist(i)=0
while i>array count(images(i))
array insert at bottom images(0)
endwhile
images(i)=name$
images(0)=str$(i)
endfunction i
function use_image(name$)
for i=1 to array count(images(0))
if images(i)=name$
a=i
exit
endif
next i
images(0)=str$(i)
endfunction a
function free_sprite(name$)
repeat
inc i
until sprite exist(i)=0
while i>array count(sprites(i))
array insert at bottom sprites(0)
endwhile
sprites(i)=name$
sprites(0)=str$(i)
endfunction i
function use_sprite(name$)
for i=1 to array count(sprites(0))
if sprites(i)=name$
a=i
exit
endif
next i
sprites(0)=str$(i)
endfunction a
function free_window(name$)
array insert at bottom win(0)
a=array count(win(0))
win(a).name=name$
win(0).name=str$(a)
endfunction a
function use_window(name$)
for i=1 to array count(win(0))
if win(i).name=name$
a=i
exit
endif
next i
win(0).name=str$(i)
endfunction a
function free_button(name$)
array insert at bottom but(0)
a=array count(but(0))
but(a).name=name$
but(0).name=str$(a)
endfunction a
function use_button(name$)
for i=1 to array count(but(0))
if but(i).name=name$
a=i
exit
endif
next i
but(0).name=str$(i)
endfunction a
function free_inputbox(name$)
array insert at bottom inp(0)
a=array count(inp(0))
inp(a).name=name$
inp(0).name=str$(a)
endfunction a
function use_inputbox(name$)
for i=1 to array count(inp(0))
if inp(i).name=name$
a=i
exit
endif
next i
inp(0).name=str$(i)
endfunction a
function free_checkbox(name$)
array insert at bottom che(0)
a=array count(che(0))
che(a).name=name$
che(0).name=str$(a)
endfunction a
function use_checkbox(name$)
for i=1 to array count(che(0))
if che(i).name=name$
a=i
exit
endif
next i
che(0).name=str$(i)
endfunction a
function free_option(name$)
array insert at bottom opt(0)
a=array count(opt(0))
opt(a).name=name$
opt(0).name=str$(a)
endfunction a
function use_option(name$)
for i=1 to array count(opt(0))
if opt(i).name=name$
a=i
exit
endif
next i
opt(0).name=str$(i)
endfunction a
function find_open_memblock()
repeat
inc i
until memblock exist(i)=0
endfunction i
` ______________________________________________
`| |
`| Window Controls |
`|______________________________________________|
`| |
`| These are the functions used to create and |
`| manipulate the windows. You should copy all |
`| of them into your code even if you do not |
`| use all of them, since some functions rely |
`| on other window functions. |
`|______________________________________________|
function make_window(name$)
ink windowfontcolor,0
tt=text background type()
ts=text size()
tf$=text font$()
set text transparent
set text size windowfontsize
set text font windowfontname
win(free_window(name$)).active=1
i=val(win(0).name)
win(i).img=free_image(name$)
win(i).spr=free_sprite(name$)
win(i).priority=use_window(name$)
set current bitmap bmp
box 0,0,100,15,windowcolor1,windowcolor1,windowcolor2,windowcolor2
box 0,15,100,100,windowcolor4,windowcolor4,windowcolor4,windowcolor4
box 1,15,99,99,windowcolor3,windowcolor3,windowcolor3,windowcolor3
sname$=truncate_string(name$,75)
text 10,0,sname$
get image win(i).img,0,0,100,100,1
set current bitmap 0
sprite win(i).spr,0,0,win(i).img
set sprite priority win(i).spr,i
set sprite alpha win(i).spr,windowalpha
make_button_image("x "+name$,use_image("Close image"))
attach_button("x "+name$,name$,86,-14)
ink rgb(d_ink.r,d_ink.g,d_ink.b),rgb(255,0,0)
if tt=1
set text opaque
endif
set text size ts
set text font tf$
endfunction
function make_close_image()
mem1=find_open_memblock()
image_memblock(mem1,25,25)
restore closedata
for y=0 to 24
for x=0 to 24
read a
if a=1
write memblock dword 1,(y*25+x)*4+12,windowcolor1
else
write memblock dword 1,(y*25+x)*4+12,windowcolor2
endif
next x
next y
make image from memblock free_image("Close image"),mem1
delete memblock mem1
size_image(use_image("Close image"),12,12)
endfunction
function size_window(name$,width,height)
ink windowfontcolor,0
tt=text background type()
ts=text size()
tf$=text font$()
set text transparent
set text size windowfontsize
set text font windowfontname
set current bitmap bmp
box 0,0,width,15,windowcolor1,windowcolor1,windowcolor2,windowcolor2
box 0,15,width,height,windowcolor4,windowcolor4,windowcolor4,windowcolor4
box 1,15,width-1,height-1,windowcolor3,windowcolor3,windowcolor3,windowcolor3
sname$=truncate_string(name$,width-15)
text 10,0,sname$
get image use_image(name$),0,0,width,height,1
set current bitmap 0
move sprite win(use_window(name$)).spr,0
detach_button("x "+name$)
attach_button("x "+name$,name$,width-14,-14)
ink rgb(d_ink.r,d_ink.g,d_ink.b),0
if tt=1
set text opaque
endif
set text size ts
set text font tf$
endfunction
function text_window(name$,x,y,text$,linebreak)
width=sprite width(win(use_window(name$)).spr)
a=val(win(0).name)
height=sprite height(win(a).spr)
th=text height(text$)
tw=text width(text$)
set current bitmap bmp
paste image win(a).img,0,0
if linebreak>0
repeat
if linebreak=1
misc(i)=truncate_string(text$,width-x-2)
endif
if linebreak=2
misc(i)=truncate_space_string(text$,width-x-2)
endif
text$=right$(text$,len(text$)-len(misc(i)))
inc i
until text$=""
if linebreak<2
for n=0 to i-1
text x+1,(th*n)+y+15,misc(n)
next n
else
for n=0 to i-1
text x+1,(th*n)+y+15,trim(misc(n))
next n
endif
else
text x+1,y+15,text$
endif
get image use_image(name$),0,0,width,height,1
set current bitmap 0
move sprite win(a).spr,0
endfunction
function paste_image_window(name$,x,y,img)
a=use_window(name$)
width=sprite width(win(a).spr)
height=sprite height(win(a).spr)
set current bitmap bmp
paste image win(a).img,0,0
paste image img,x+1,y+15
get image use_image(name$),0,0,width,height,1
set current bitmap 0
move sprite win(a).spr,0
endfunction
function cls_window(name$)
a=use_window(name$)
width=sprite width(win(a).spr)
height=sprite height(win(a).spr)
set current bitmap bmp
paste image win(a).img,0,0
box 1,15,width-1,height-1,windowcolor3,windowcolor3,windowcolor3,windowcolor3
get image use_image(name$),0,0,width,height,1
set current bitmap 0
move sprite win(a).spr,0
endfunction
function box_window(name$,left,top,right,bottom,color as dword)
a=use_window(name$)
img=win(a).img
mem1=find_open_memblock()
inc top,15
inc bottom,15
make memblock from image mem1,img
width=memblock dword(1,0)
for x=left to right
for y=top to bottom
write memblock dword mem1,(y*width+x)*4+12,color
next y
next x
make image from memblock img,mem1
delete memblock mem1
endfunction
function delete_window(window)
delete sprite win(window).spr
delete image win(window).img
for i=1 to array count(win(0))
if win(i).priority>win(window).priority
win(i).priority=win(i).priority-1
endif
next i
for i=1 to array count(but(0))
if but(i).win=window
delete_button(but(i).name)
dec i
else
if but(i).win>window
but(i).win=but(i).win-1
endif
endif
next i
for i=1 to array count(inp(0))
if inp(i).win=window
delete_inputbox(inp(i).name)
dec i
else
if inp(i).win>window
inp(i).win=inp(i).win-1
endif
endif
next i
for i=1 to array count(che(0))
if che(i).win=window
delete_checkbox(che(i).name)
dec i
else
if che(i).win>window
che(i).win=che(i).win-1
endif
endif
next i
for i=1 to array count(opt(0))
if opt(i).win=window
delete_option(opt(i).name)
dec i
else
if opt(i).win>window
opt(i).win=opt(i).win-1
endif
endif
next i
for i=1 to array count(asprites(0))
if asprites(i).win=window
delete sprite asprites(i).spr
detach_sprite(asprites(i).spr)
dec i
else
if asprites(i).win>window
asprites(i).win=asprites(i).win-1
endif
endif
next i
array delete element win(0),window
endfunction
function position_window(name$,xpos,ypos)
a=win(use_window(name$)).spr
position_sprite(a,xpos,ypos)
endfunction
function window_bringtofront(window)
for i=1 to array count(win(0))
if win(i).priority>win(window).priority and win(i).active=1
win(i).priority=win(i).priority-1
set sprite priority win(i).spr,win(i).priority
endif
next i
win(window).priority=array count(win(0))
set sprite priority win(window).spr,win(window).priority
endfunction
function window_exist(name$)
a=(use_window(name$)>0)
endfunction a
function set_window_active(name$)
win(use_window(name$)).active=1
endfunction
function set_window_inactive(name$)
win(use_window(name$)).active=0
endfunction
` ______________________________________________
`| |
`| If you expect your windows to move or close |
`| as one would expect windows to, you need to |
`| have this function in your loop. OBSOLETE: |
`| see handle_gui. |
`|______________________________________________|
function handle_windows()
if user.click=1
p=use_sprite("Pointer")
for i=1 to array count(win(0))
if win(i).active=1 and win(i).priority>highestpriority
if sprite collision(p,win(i).spr)
highestpriority=win(i).priority
winpos=i
endif
endif
next i
if highestpriority>0 and selected.window=0
selected.window_focus=winpos
if user.my<sprite y(win(winpos).spr)+15
if sprite collision(p,but(use_button("x "+win(winpos).name)).spr)=1
delete_window(winpos)
selected.window_focus=0
exitfunction
else
selected.window=winpos
selected.offsetx=sprite x(win(winpos).spr)-user.mx
selected.offsety=sprite y(win(winpos).spr)-user.my
endif
endif
window_bringtofront(winpos)
endif
else
selected.window=0
selected.window_focus=0
endif
if selected.window>0
position_window(win(selected.window).name,user.mx+selected.offsetx,user.my+selected.offsety)
endif
for i=1 to array count(asprites(0))
position_sprite(asprites(i).spr,sprite x(win(asprites(i).win).spr)+asprites(i).offsetx,sprite y(win(asprites(i).win).spr)+15+asprites(i).offsety)
set sprite priority asprites(i).spr,win(asprites(i).win).priority
next i
endfunction
function attach_sprite(spr,name$,xoff,yoff)
array insert at bottom asprites(0)
i=array count(asprites(0))
asprites(i).spr=spr
asprites(i).win=use_window(name$)
asprites(i).offsetx=xoff
asprites(i).offsety=yoff
endfunction
function detach_sprite(spr)
while a<>spr
inc i
if i>array count(asprites(0))
exitfunction
endif
a=asprites(i).spr
endwhile
array delete element asprites(0),i
endfunction
` ______________________________________________
`| |
`| Button Controls |
`|______________________________________________|
`| |
`| The second part to my gui system! Not that |
`| difficult with an attaching sprite function |
`| already made. |
`|______________________________________________|
function make_button(name$,linebreak)
ink buttonfontcolor,0
tt=text background type()
ts=text size()
tf$=text font$()
set text transparent
set text size buttonfontsize
set text font buttonfontname
but(free_button(name$)).active=1
i=val(but(0).name)
but(i).img=free_image(name$)
but(i).spr=free_sprite(name$)
but(i).name=name$
set current bitmap bmp
width=screen width()
x=0
text$=name$
tw=text width(text$)
th=text height(text$)
repeat
if linebreak=2
misc(a)=truncate_space_string(text$,width-x-2)
else
misc(a)=truncate_string(text$,width-x-2)
endif
text$=right$(text$,len(text$)-len(misc(a)))
inc a
until text$=""
if a>1
tw=width
endif
if linebreak=0
a=1
endif
n=a
box 0,0,tw,th*n-1,buttoncolor1,buttoncolor1,buttoncolor1,buttoncolor1
box 0,th*n-1,tw,th*n*2-1,buttoncolor2,buttoncolor2,buttoncolor2,buttoncolor2
for n=0 to a-1
text x,(th*n)+y,trim(misc(n))
next n
for n=0 to a-1
text x,(th*n)+y+th*a,trim(misc(n))
next n
get image but(i).img,0,0,tw,th*(n)*2-1,1
set current bitmap 0
if file exist("temp.bmp")=1
delete file "temp.bmp"
endif
save image "temp.bmp",but(i).img
create animated sprite but(i).spr,"temp.bmp",1,2,but(i).img
delete file "temp.bmp"
position_button(name$,0,0)
ink rgb(d_ink.r,d_ink.g,d_ink.b),rgb(255,0,0)
if tt=1
set text opaque
endif
set text size ts
set text font tf$
endfunction
function make_button_image(name$,image)
but(free_button(name$)).active=1
i=val(but(0).name)
but(i).name=name$
but(i).img=free_image(name$)
get image but(i).img,0,0,1,1
but(i).spr=free_sprite(name$)
mem1=find_open_memblock()
make memblock from image mem1,image
width=memblock dword(mem1,0)
height=memblock dword(mem1,4)
for x=0 to width-1
for y=0 to height-1
write memblock dword mem1,(y*width+x)*4+12,rgb(memblock byte(mem1,(y*width+x)*4+14)*.8,memblock byte(mem1,(y*width+x)*4+13)*.8,memblock byte(mem1,(y*width+x)*4+12)*.8)
next y
next x
make image from memblock but(i).img,mem1
delete memblock mem1
set current bitmap bmp
paste image image,0,0
paste image but(i).img,0,image height(image)
get image val(images(0)),0,0,image width(image),image height(image)*2,1
set current bitmap 0
save image "temp.bmp",val(images(0))
create animated sprite val(sprites(0)),"temp.bmp",1,2,val(images(0))
delete file "temp.bmp"
position_button(name$,0,0)
endfunction
function position_button(name$,xpos,ypos)
position_sprite(but(use_button(name$)).spr,xpos,ypos)
endfunction
` ______________________________________________
`| Size button is only for text buttons. Image |
`| buttons have their size changed by either |
`| changing the image size before they are |
`| created, or scaling the sprite. If you were |
`| to scale the sprite of a text button, the |
`| text size of the text on the button would |
`| change, thus the reason I created this |
`| function. |
`|______________________________________________|
function size_button(name$,width,height,linebreak)
ink buttonfontcolor,0
tt=text background type()
ts=text size()
tf$=text font$()
set text transparent
set text size buttonfontsize
set text font buttonfontname
i=use_button(name$)
set current bitmap bmp
x=0
text$=name$
tw=text width(text$)
th=text height(text$)
repeat
if linebreak=2
misc(a)=truncate_space_string(text$,width-x-2)
else
misc(a)=truncate_string(text$,width-x-2)
endif
text$=right$(text$,len(text$)-len(misc(a)))
inc a
until text$="" or a*th>=height
if a>1 or text$<>""
tw=width
endif
if linebreak=0
a=1
endif
n=a
box 0,0,tw,th*n-1,buttoncolor1,buttoncolor1,buttoncolor1,buttoncolor1
box 0,th*n-1,tw,th*n*2-1,buttoncolor2,buttoncolor2,buttoncolor2,buttoncolor2
for n=0 to a-1
text x,(th*n)+y,trim(misc(n))
next n
for n=0 to a-1
text x,(th*n)+y+th*a,trim(misc(n))
next n
get image but(i).img,0,0,tw,th*(n)*2-1,1
set current bitmap 0
save image "temp.bmp",but(i).img
delete sprite but(i).spr
create animated sprite but(i).spr,"temp.bmp",1,2,but(i).img
delete file "temp.bmp"
position_button(name$,0,0)
ink rgb(d_ink.r,d_ink.g,d_ink.b),rgb(255,0,0)
if tt=1
set text opaque
endif
set text size ts
set text font tf$
endfunction
function attach_button(name$,winname$,xoff,yoff)
a=use_button(name$)
b=use_window(winname$)
but(a).win=b
attach_sprite(but(a).spr,win(b).name,xoff,yoff)
endfunction
function detach_button(name$)
a=use_button(name$)
but(a).win=0
detach_sprite(but(a).spr)
endfunction
function delete_button(name$)
a=use_button(name$)
delete sprite but(a).spr
detach_button(name$)
array delete element but(0),a
endfunction
function button_exist(name$)
a=(use_button(name$)>0)
endfunction a
function button_clicked(name$)
a=but(use_button(name$)).clicked
endfunction a
function set_button_active(name$)
but(use_button(name$)).active=1
endfunction
function set_button_inactive(name$)
but(use_button(name$)).active=0
endfunction
function handle_buttons()
if array count(but(0))>0
if user.click=1
p=use_sprite("Pointer")
for i=1 to array count(but(0))
if sprite collision(p,but(i).spr)=1 and selected.window_focus=but(i).win and but(i).active=1
but(i).clicked=1
set sprite frame but(i).spr,2
else
but(i).clicked=0
set sprite frame but(i).spr,1
endif
next i
else
for i=1 to array count(but(0))
but(i).clicked=0
set sprite frame but(i).spr,1
next i
endif
endif
endfunction
` ______________________________________________
`| |
`| Input Boxes |
`|______________________________________________|
`| |
`| Not as difficult as you may think them to |
`| program, they are essential to anyone ever |
`| using my gui. |
`|______________________________________________|
function make_inputbox(name$)
ink inputfontcolor,0
tt=text background type()
ts=text size()
tf$=text font$()
set text transparent
set text size inputfontsize
set text font inputfontname
a=free_inputbox(name$)
inp(a).spr=free_sprite(name$)
inp(a).img=free_image(name$)
inp(a).active=1
set current bitmap bmp
box 0,0,100,100,inputboxcolor,inputboxcolor,inputboxcolor,inputboxcolor
text 0,0,name$
get image inp(a).img,0,0,100,100,1
set current bitmap 0
sprite inp(a).spr,0,0,inp(a).img
ink rgb(d_ink.r,d_ink.g,d_ink.b),rgb(255,0,0)
if tt=1
set text opaque
endif
set text size ts
set text font tf$
endfunction
function attach_inputbox(name$,winname$,xoff,yoff)
a=use_inputbox(name$)
b=use_window(winname$)
inp(a).win=b
attach_sprite(inp(a).spr,win(b).name,xoff,yoff)
endfunction
function detach_inputbox(name$)
a=use_inputbox(name$)
inp(a).win=0
detach_sprite(inp(a).spr)
endfunction
function delete_inputbox(name$)
a=use_inputbox(name$)
delete sprite inp(a).spr
detach_inputbox(name$)
array delete element inp(0),a
endfunction
function size_inputbox(name$,width,height)
ink inputfontcolor,0
tt=text background type()
ts=text size()
tf$=text font$()
set text transparent
set text size inputfontsize
set text font inputfontname
a=use_inputbox(name$)
set current bitmap bmp
box 0,0,width,height,inputboxcolor,inputboxcolor,inputboxcolor,inputboxcolor
text 0,0,name$+inp(a).txt
get image inp(a).img,0,0,width,height,1
set current bitmap 0
sprite inp(a).spr,0,0,inp(a).img
ink rgb(d_ink.r,d_ink.g,d_ink.b),rgb(255,0,0)
if tt=1
set text opaque
endif
set text size ts
set text font tf$
endfunction
function set_inputbox_active(name$)
inp(use_inputbox(name$)).active=1
endfunction
function set_inputbox_inactive(name$)
inp(use_inputbox(name$)).active=0
endfunction
function handle_inputboxes()
if array count(inp(0))>0
if user.click=1
p=use_sprite("Pointer")
selected.inputbox=0
for i=1 to array count(inp(0))
if sprite collision(p,inp(i).spr)=1 and selected.window_focus=inp(i).win and inp(i).active=1
selected.inputbox=i
clear entry buffer
endif
next i
endif
if selected.inputbox>0
a=selected.inputbox
new$=entry$()
n=keystate(14)
clear entry buffer
if returnkey()=1
new$=""
endif
if n=1
new$=""
if timer()-gui.delay=>100 and len(inp(a).txt)>0
gui.delay=timer()
backspace=1
endif
endif
if new$<>"" or backspace=1
ink inputfontcolor,0
tt=text background type()
ts=text size()
tf$=text font$()
set text transparent
set text size inputfontsize
set text font inputfontname
inp(a).txt=inp(a).txt+new$
if backspace=1
inp(a).txt=left$(inp(a).txt,len(inp(a).txt)-1)
endif
set current bitmap bmp
box 0,0,sprite width(inp(a).spr),sprite height(inp(a).spr),inputboxcolor,inputboxcolor,inputboxcolor,inputboxcolor
text$=inp(a).name+inp(a).txt
width=sprite width(inp(a).spr)
x=0
tw=text width(text$)
th=text height(text$)
n=1
repeat
misc(n)=truncate_space_string(text$,width-x-2)
text$=right$(text$,len(text$)-len(misc(n)))
inc n
until text$=""
if n>1
tw=width
endif
for l=1 to n-1
text 0,(l-1)*th,misc(l)
next l
get image inp(a).img,0,0,sprite width(inp(a).spr),sprite height(inp(a).spr),1
set current bitmap 0
ink rgb(d_ink.r,d_ink.g,d_ink.b),rgb(255,0,0)
if tt=1
set text opaque
endif
set text size ts
set text font tf$
endif
endif
endif
endfunction
` ______________________________________________
`| |
`| Check Box |
`|______________________________________________|
`| |
`| Yes, those boxes which you click and a check |
`| appears in them. They all use the same |
`| image, since there is no difference between |
`| them (size can be taken care of by scaling |
`| the sprite). |
`|______________________________________________|
function make_checkbox_image()
mem1=find_open_memblock()
image_memblock(mem1,25,50)
restore checkboxdata
for y=0 to 49
for x=0 to 24
read a
if a=1
write memblock dword 1,(y*25+x)*4+12,checkboxcolor1
else
write memblock dword 1,(y*25+x)*4+12,checkboxcolor2
endif
next x
next y
make image from memblock free_image("Checkbox image"),mem1
delete memblock mem1
if file exist("checkbox_temp.bmp")=1
delete file "checkbox_temp.bmp"
endif
save image "checkbox_temp.bmp",val(images(0))
endfunction
function make_checkbox(name$)
a=free_checkbox(name$)
che(a).active=1
che(a).spr=free_sprite(name$)
create animated sprite che(a).spr,"checkbox_temp.bmp",1,2,use_image("Checkbox image")
position_sprite(che(a).spr,0,0)
endfunction
function set_checkbox_active(name$)
che(use_checkbox(name$)).active=1
endfunction
function set_checkbox_inactive(name$)
che(use_checkbox(name$)).active=0
endfunction
function size_checkbox(name$,width,height)
size sprite che(use_checkbox(name$)).spr,width,height
endfunction
function attach_checkbox(name$,winname$,xoff,yoff)
a=use_checkbox(name$)
b=use_window(winname$)
che(a).win=b
attach_sprite(che(a).spr,win(b).name,xoff,yoff)
endfunction
function detach_checkbox(name$)
a=use_checkbox(name$)
che(a).win=0
detach_sprite(che(a).spr)
endfunction
function delete_checkbox(name$)
a=use_checkbox(name$)
delete sprite che(a).spr
detach_checkbox(name$)
array delete element che(0),a
endfunction
function handle_checkboxes()
if user.click=1
p=use_sprite("Pointer")
for i=0 to array count(che(0))
if sprite collision(p,che(i).spr) and che(i).active=1
a=i
endif
next i
if a=0
gui.holdc=0
else
if gui.holdc=0
gui.holdc=1
if sprite frame(che(a).spr)=1
che(a).value=1
set sprite frame che(a).spr,2
else
set sprite frame che(a).spr,1
che(a).value=0
endif
endif
endif
else
gui.holdc=0
endif
endfunction
` ______________________________________________
`| |
`| Option |
`|______________________________________________|
`| |
`| I didn't call them option buttons because: |
`| 1) That's way to long to keep typing. |
`| 2) It may get confusing calling it a |
`| button. |
`|______________________________________________|
function make_option_image()
mem1=find_open_memblock()
image_memblock(mem1,25,50)
restore optiondata
for y=0 to 49
for x=0 to 24
read a
if a=1
write memblock dword 1,(y*25+x)*4+12,optioncolor1
else
if a=0
write memblock dword 1,(y*25+x)*4+12,optioncolor2
else
write memblock byte 1,(y*25+x)*4+15,0
endif
endif
next x
next y
make image from memblock free_image("Option image"),mem1
delete memblock mem1
if file exist("option_temp.bmp")=1
delete file "option_temp.bmp"
endif
save image "option_temp.bmp",val(images(0))
endfunction
function make_option(name$)
a=free_option(name$)
opt(a).active=1
opt(a).spr=free_sprite(name$)
create animated sprite opt(a).spr,"option_temp.bmp",1,2,use_image("Option image")
position_sprite(opt(a).spr,0,0)
endfunction
function set_option_active(name$)
opt(use_option(name$)).active=1
endfunction
function set_option_inactive(name$)
opt(use_option(name$)).active=0
endfunction
function size_option(name$,width,height)
size sprite opt(use_option(name$)).spr,width,height
endfunction
function attach_option(name$,winname$,xoff,yoff)
a=use_option(name$)
b=use_window(winname$)
opt(a).win=b
attach_sprite(opt(a).spr,win(b).name,xoff,yoff)
endfunction
function detach_option(name$)
a=use_option(name$)
opt(a).win=0
detach_sprite(opt(a).spr)
endfunction
function delete_option(name$)
a=use_option(name$)
delete sprite opt(a).spr
detach_option(name$)
array delete element opt(0),a
endfunction
function group_option(name$,group)
opt(use_option(name$)).group=group
endfunction
function handle_options()
if user.click=1
p=use_sprite("Pointer")
for i=0 to array count(opt(0))
if sprite collision(p,opt(i).spr) and opt(i).active
a=i
endif
next i
if a=0
gui.holdo=0
else
if gui.holdo=0
gui.holdo=1
opt(a).value=1
set sprite frame opt(a).spr,2
cg=opt(a).group
for i=1 to array count(opt(0))
if a<>i and opt(i).group=cg
opt(i).value=0
set sprite frame opt(i).spr,1
endif
next i
endif
endif
else
gui.holdo=0
endif
endfunction
` ______________________________________________
`| |
`| Handle Gui |
`|______________________________________________|
`| |
`| The ULTIMATE function for my gui controls. |
`| Put it in the loop, and the gui works by |
`| itself. |
`|______________________________________________|
function handle_gui()
update_user()
handle_windows()
handle_buttons()
handle_inputboxes()
handle_checkboxes()
handle_options()
endfunction
` ______________________________________________
`| |
`| User Input |
`|______________________________________________|
`| |
`| This function is required for my window |
`| functions to work. If you want user input |
`| to be different from the standard mouse |
`| movement and clicking then change this |
`| function. |
`|______________________________________________|
function update_user()
user.click=mouseclick()
user.mmx=mousemovex()
user.mmy=mousemovey()
user.mx=mousex()
user.my=mousey()
move sprite use_sprite("Pointer"),-user.my+sprite y(use_sprite("Pointer"))
rotate sprite use_sprite("Pointer"),90
move sprite use_sprite("Pointer"),user.mx-sprite x(use_sprite("Pointer"))
rotate sprite use_sprite("Pointer"),0
endfunction
` ______________________________________________
`| |
`| Useful Functions |
`|______________________________________________|
`| |
`| These are useful functions that you may use |
`| elsewhere in your programs. Most are here |
`| just because I happen to use them in my |
`| demonstration. Notice, however, that there |
`| are some which are required for the windows |
`| to work. |
`|______________________________________________|
function wrap(value,min,max)
while value<min
value=value+max-min
endwhile
while value>max
value=value-max+min
endwhile
endfunction value
function image_memblock(num,width,height)
make memblock num,width*height*4+12
write memblock dword num,0,width
write memblock dword num,4,height
write memblock dword num,8,32
endfunction
function image_memblock_dot(num,x,y,color as dword)
write memblock dword num,(memblock dword(num,0)*y+x)*4+12,color
endfunction
function size_image(num,width,height)
mem1=find_open_memblock()
make memblock from image mem1,num
pwidth=memblock dword(mem1,0)
pheight=memblock dword(mem1,4)
mem2=find_open_memblock()
image_memblock(mem2,width,height)
for x=0 to width-1
for y=0 to height-1
image_memblock_dot(mem2,x,y,memblock dword(mem1,(pwidth*floor(y*pheight/(height+0.0))+floor(x*pwidth/(width+0.0)))*4+12))
next y
next x
delete image num
delete memblock mem1
make image from memblock num,mem2
delete memblock mem2
endfunction
function truncate_string(word$,length)
while text width(word$)>length
word$=left$(word$,len(word$)-1)
endwhile
endfunction word$
function truncate_space_string(word$,length)
nword$=word$
while text width(nword$)>length
nword$=left$(nword$,len(nword$)-1)
endwhile
if nword$<>word$
if mid$(word$,len(nword$)+1)<>" "
justincase$=nword$
repeat
a$=mid$(nword$,len(nword$))
b$=mid$(nword$,len(nword$)-1)
nword$=left$(nword$,len(nword$)-1)
until a$=" " and b$<>" " or len(nword$)<=1
if len(nword$)<=1
nword$=justincase$
endif
endif
endif
endfunction nword$
function trim(word$)
while mid$(word$,1)=" "
word$=right$(word$,len(word$)-1)
endwhile
while mid$(word$,len(word$))=" "
word$=left$(word$,len(word$)-1)
endwhile
endfunction word$
function d_ink(r,g,b)
d_ink.r=r
d_ink.g=g
d_ink.b=b
ink rgb(r,g,b),0
endfunction
function position_sprite(num,xpos,ypos)
move sprite num,sprite y(num)-ypos
rotate sprite num,90
move sprite num,-sprite x(num)+xpos
rotate sprite num,0
endfunction
` ______________________________________________
`| |
`| Labels |
`|______________________________________________|
`| |
`| Like any good programmer, I despise goto. |
`| These are for data statements. And yes, they |
`| are necessary. |
`|______________________________________________|
checkboxdata:
data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0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