Help with GUI
Blitz3D Forums/Blitz3D Programming/Help with GUI
| ||
| . |
| ||
| . |
| ||
| Write a function which does the following: And simply call the function each time you wish to create a button. Ie NewButton("ButtonUp.jpg","ButtonOver.jpg",0,0,1,1) as an example.. Function NewButton(ImageName1$,ImageName2$,X#,Y#,Scalex#,ScaleY#) Button.button_type=new button_type Button\image1=LoadImage(ImageName1$) Button\image2=LoadImage(ImageName2$) Button\x#=x Button\y#=y Button\scalex#=ScaleX Button\scaley#=ScaleY Button\width#=ImageWidth(Button\image1) Button\height#=ImageHeight(Button\image1 end function |
| ||
| . |
| ||
Just some pseudo code...
Global B_Norm = Normal Image
Global B_Over = Mouse-over Image
Global B_Down = Mouse-click Image
Type Button
Parent.Object
Caption
Identifier ;used in a Select:Case:End Select to update it
X,Y,Width,Height
End Type
Function AddButton.Button(P.Object,Image
If Not (All the parameters are true values) Then Return Null
B = New Button
;Assign all the same values to the new object
Return B
End Function
Function UpdateButtons()
Local B.Button
For B = Each Button
Select B.Identifier
Case Button type 1
;update accordingly
if (within(mousex(),mousey(),b.width,b.height)) then
if (mousedown(1) or mousehit(1) then
;draw the click image
else
;draw the mouse-over image
endif
else
;draw the normal image
endif
Case Button type 2
;repeat but with slightly different stuff
End Select
Next
Return True
End Function
That's basically how I did my old GUI... except that 'code' doesn't work. |
| ||
| Thanks XMLspy I was wondering how to do this! |
| ||
| . |
| ||
| Noel... gonna try and implement yours... will scream for help if I need the Dread Pirate Cower... ;) RZ |
| ||
| Good lord, that code I wrote is horrible... |
| ||
| yes but it can be saved... we can rebuild it... make it better... stronger... faster... The Six Million Dollar Button Code.... dunh dunh da nah... RZ |