ok well i was workng on my form functions and realized that the way i'm doing it i would need about 300 or 400 images/sprites.
i know theres a better way i just don't know how :/ any suggestions
write now i have a seperate form image for each(wich has the text printed on it already) and 2 images per button i allow for 50 buttons 50 forms ad hopefully later many things this would mean for hundreds and hundreds and hundreds of sprites/images for scrollers, text boxes, minimize buttons, exc...exc..... i don't want this plus this would probly bog down the app alot :/ not a very helpful function set then now is it? lol
heres the code
remstart
-------------------------------------------------------------------
program name: Form Functions
-------------------------------------------------------------------
written by: Caleb Stewart
date:
-------------------------------------------------------------------
comments:
-------------------------------------------------------------------
remend
Dim Forms(101) : Dim FormX(101)
Dim FormY(101) : Dim Forminfo(2,101)
Dim Buttons(101,150) : Dim NumButtons(101)
Dim ButtonWidth(101,150) : Dim ButtonHeight(101,150)
dim ButtonX(100,150) : Dim ButtonY(101,150)
dim buttonimg(101,150,1) : Dim ClosebuttonX(101)
DIm ClosebuttonY(101) : Dim WinOrder(100)
Dim FImage(101) : Dim Cbutton(100) : dim Title$(100)
Sync on
Sync rate 0
WinX=(640/2)/2+25
WinY=(480/2)/2+25
Set window on
Set window position WinX,WinY
set display mode 800,600,32
for X=1 to 10
Make form(X,"Form "+Str$(X),300,400,0,0,0,0,0,"")
next x
Make button(10,1,"Hi",100,100,25,20,700)
setup
ink rgb(255,255,255),0
Do
update forms
if cbutton(1)=1 then print "Hehe"
Sync
cls
Loop
function setup
make memblock 10,9
endfunction
Function Form text(Form,Text$,X,Y)
Paste image Form+600,0,0
Text x,y,Text$
Get image form+600,0,0,forminfo(1,form),Forminfo(2,Form)
endfunction
Function Make Form(formnum,title$,width,height,X,Y,Color,tx,ty,text$)
Forms(formnum)=1
FormX(Formnum)=X
FormY(Formnum)=Y
Forminfo(1,formnum)=width
Forminfo(2,Formnum)=height
ClosebuttonX(Formnum)=Width-11
ClosebuttonY(formnum)=Height+2
exitbutton(Formnum)
numforms=numforms+1
Fimage(Formnum)=Formnum+600
Title$(Formnum)=Title$
Ink RGB(192,192,192),0
Box 1,11,width,height
ink RGB(0,0,255),0
box 1,1,width,12
ink Rgb(0,0,0),0
line 1,13,width,13
line width,1,width,Height
line 1,Height,Width,Height
ink RGB(255,255,255),0
line 0,0,width,0
line 0,0,0,height
ink RGB(0,0,0),0
Line width,0,width,height
line 0,height,width,height
Tsize=text size()
Set text size tsize-1
text 0,0," "+Title$
set text size tsize
if text$>""
Text tx,ty,Text$
endif
Get image formnum+600,0,0,width+1,height+1
cls
endfunction
Function Make Button(Form,button,Text$,X,Y,width,Height,img)
if buttons(form,button)!0 then break "Whoops"
buttons(Form,button)=1
ButtonX(Form,button)=X
ButtonY(Form,button)=Y
ButtonWidth(form,button)=width
ButtonHeight(Form,Button)=Height
Numbuttons(form)=NumButtons(Form)+1
Width=width
height=Height
buttonimg(form,button,0)=img
buttonimg(form,button,1)=img+1
Ink RGB(192,192,192),0
Box 1,1,width+1,Height+1
ink RGB(255,255,255),0
line 0,0,width,0
line 0,0,0,height
ink RGB(0,0,0),0
Line width,0,width,height
line width,height,0,height
Text 0,0," "+Text$
Get image img,0,0,width+1,Height+1
Ink RGB(192,192,192),0
Box 1,1,width+1,Height+1
ink RGB(0,0,0),0
line 0,0,width,0
line 0,0,0,height
ink RGB(255,255,255),0
Line width,0,width,height
line width,height,0,height
ink rgb(0,0,0),0
Text 0,0," "+Text$
Get image img+1,0,0,width+1,Height+1
endfunction
function Update forms
for X=1 to 100
if mouseclick()
For Y=1 to 100
if forms(y)=1
if On form(Y) and On form(Selected)=0
selected=Y
endif
endif
next y
endif
Priority_Check:
if forms(X)=1
Sprite X+600,formx(X),FormY(X),X+600
set sprite X+600,1,0
if mouseclick()
if move=0 and selected=X
if on title(X)
move=X
endif
endif
if move=X and selected=x
if MF=0
diffx=mouseX()-formX(X)
diffY=MouseY()-formY(X)
mf=1
endif
formX(X)=mouseX()-diffX
formY(X)=MouseY()-DiffY
move=X
endif
endif
X1=FormX(X)+ClosebuttonX(X)
X2=FormX(X)+ClosebuttonX(X)+11
Y1=FormY(X)+1
Y2=FormY(X)+11
if mouseclick() and mouseinside(X1,Y1,X2,Y2) and selected=x
sprite (X+50),X1,Y1,802
set sprite (X+50),1,0
Repeat : sync : until mouseclick()=0
if mouseinside(X1,Y1,X2,Y2) then Close form(X)
else
sprite (X+50),X1,Y1,801
set sprite (X+50),1,0
endif
if mouseclick()=0 then move=0 : title=0 : MF=0
oldb=cbutton(0)
for y=1 to numbuttons(X)
if buttons(X,Y)=1
for Z=1 to 100
if mouseclick() and on button(x,y) and on form(Z)=0 and selected=x
sprite Buttonimg(X,Y,1),buttonX(x,y)+FormX(X),buttonY(X,Y)+FormY(X),buttonimg(x,y,1)
show sprite Buttonimg(X,Y,1)
set sprite Buttonimg(X,Y,1),1,0
Cbutton(X)=Y
else
if sprite exist(Buttonimg(X,Y,1)) then hide sprite Buttonimg(X,Y,1)
sprite Buttonimg(X,Y,0),buttonX(x,y)+FormX(X),buttonY(X,Y)+FormY(X),buttonimg(x,y,0)
set sprite Buttonimg(X,Y,0),1,0
endif
next z
endif
next y
first=0
endif
next x
Update(Selected)
endfunction
function on button(form,button)
clicked=0
if mouseX()>buttonX(form,button)+FormX(form) and MouseX()<(buttonX(form,button)+FormX(form))+buttonwidth(form,button)
if mouseY()>ButtonY(form,button)+FormY(Form) and MouseY()<(buttonY(form,button)+FormY(Form))+buttonheight(Form,button)
clicked=1
exitfunction clicked
endif
endif
endfunction
function on title(form)
if mouseX()>formX(form) and MouseX()<FormX(form)+Forminfo(1,Form)-10
If mouseY()>FormY(Form) and Mousey()<FormY(form)+10
on=1
exitfunction on
endif
endif
endfunction 0
function on form(Form)
if mouseX()>formX(form) and mouseX()<formX(form)+Forminfo(1,form)
if mouseY()>formY(form) and mouseY()<formY(form)+Forminfo(2,form)
exitfunction 1
endif
endif
endfunction 0
function exitbutton(Form)
img=801
width=10
height=10
Ink RGB(192,192,192),0
Box 1,1,width+1,Height+1
ink RGB(255,255,255),0
line 0,0,width,0
line 0,0,0,height
ink RGB(0,0,0),0
Line width,0,width,height
line width,height,0,height
tsize=text size()
set text size tsize-1
Text 2,-2,"X"
Get image 801,0,0,width+1,Height+1
Ink RGB(192,192,192),0
Box 1,1,width+1,Height+1
ink RGB(0,0,0),0
line 0,0,width,0
line 0,0,0,height
ink RGB(255,255,255),0
Line width,0,width,height
line width,height,0,height
ink rgb(0,0,0),0
Text 2,-2,"X"
Get image 802,0,0,width+1,Height+1
set text size tsize
endfunction
Function mouseinside(X1,Y1,X2,Y2)
if mouseX()>X1 and MouseX()<X2
If MouseY()>Y1 and MouseY()<Y2
exitfunction 1
endif
endif
endfunction 0
Function Close Form(Form)
For X=1 to numbuttons(Form)
if buttons(form,X)=1
buttons(Form,X)=0
ButtonX(Form,X)=0
ButtonY(Form,X)=0
ButtonWidth(form,X)=0
ButtonHeight(Form,X)=0
Width=0
height=0
delete sprite buttonimg(form,X,0)
if sprite exist(Buttonimg(form,x,1)) then delete sprite buttonimg(form,x,1)
delete image buttonimg(form,X,0)
buttonimg(form,X,0)=0
delete image buttonimg(form,X,1)
buttonimg(form,X,1)=0
endif
next x
numbuttons(Form)=0
Forms(form)=0
FormX(Form)=0
FormY(Form)=0
Forminfo(1,form)=0
Forminfo(2,Form)=0
ClosebuttonX(Form)=0
ClosebuttonY(form)=0
Delete sprite Form+600
delete sprite form+50
endfunction
Function SetupDims
endfunction
Function update(X)
if forms(X)=1
Sprite 1000,formx(X),FormY(X),X+600
set sprite 1000,1,0
if mouseclick()
if move=0 and selected=X
if on title(X)
move=X
endif
endif
if move=X and selected=x
if MF=0
diffx=mouseX()-formX(X)
diffY=MouseY()-formY(X)
mf=1
endif
formX(X)=mouseX()-diffX
formY(X)=MouseY()-DiffY
move=X
endif
endif
X1=FormX(X)+ClosebuttonX(X)
X2=FormX(X)+ClosebuttonX(X)+11
Y1=FormY(X)+1
Y2=FormY(X)+11
if mouseclick() and mouseinside(X1,Y1,X2,Y2) and selected=x
sprite (X+50),X1,Y1,802
set sprite (X+50),1,0
Repeat : sync : until mouseclick()=0
if mouseinside(X1,Y1,X2,Y2) then Close form(X)
else
sprite (X+50),X1,Y1,801
set sprite (X+50),1,0
endif
if mouseclick()=0 then move=0 : title=0 : MF=0
oldb=cbutton(0)
for y=1 to numbuttons(X)
if buttons(X,Y)=1
for Z=1 to 100
if mouseclick() and on button(x,y) and on form(Z)=0 and selected=x
sprite Buttonimg(X,Y,1),buttonX(x,y)+FormX(X),buttonY(X,Y)+FormY(X),buttonimg(x,y,1)
show sprite Buttonimg(X,Y,1)
set sprite Buttonimg(X,Y,1),1,0
Cbutton(X)=Y
else
if sprite exist(Buttonimg(X,Y,1)) then hide sprite Buttonimg(X,Y,1)
sprite Buttonimg(X,Y,0),buttonX(x,y)+FormX(X),buttonY(X,Y)+FormY(X),buttonimg(x,y,0)
set sprite Buttonimg(X,Y,0),1,0
endif
next z
endif
next y
first=0
endif
endfunction
ok i know i might need to redo my hole code i have thought about it. i have the window drawing code write there. witch was annoying and the other stuff i understand so it shouldn't be to hard now that i know but i need some oppinions first
priority is "working" exept when you click on a window it goes to the front but you don't see the buttons trying to fix that now.