This version of the program only loads ".x"(if its not obvious).In theory this can be used for loading any type of file, just need to adjust the way the program handle the file.
Sync on:Sync Rate 0:Backdrop On
Gosub int_fb
Global OldLoaded,PreOldLoaded,ObjecA
Do
//Browse files for object and return the object number
NewLoaded = ObjFileBrowser(Models_Folder,".x",50,90)
//Handle the newly loaded object
If NewLoaded > 0
//Store the new number before its deleted
If NewLoaded <> OldLoaded
//Store the number of the object you wish to delete later
PreOldLoaded = OldLoaded
//Get a new old number...
OldLoaded = NewLoaded
//Delete the old loaded object
If PreOldLoaded > 0 Then If Object Exist(PreOldLoaded) = 1 Then Delete Object PreOldLoaded
Endif
Endif
//Rotate Loaded Object
If OldLoaded > 0 Then If Object Exist(OldLoaded) = 1 Then Yrotate Object OldLoaded,ObjecA
ObjecA = WrapValue(ObjecA+1)
`Text 200,100,Str$(ObjecA)
`Text 200,110,Str$(OldLoaded)
Sync
Loop
int_fb:
//
Type FB_bR
file as String
filefolder as String
folder as String
ext as string
eNDTYPE
//
dim fb_browser(999) as FB_bR
//
Global Models_Folder as String
Models_Folder = "Assets\Models\"
//
Fill.FB(Models_Folder,2)
Return
//
Function Clean.FB()
For n = 0 to 999
fb_browser(n).file = ""
fb_browser(n).folder = ""
fb_browser(n).filefolder = ""
fb_browser(n).ext = ""
Next n
Endfunction
//
Function Add.FB(File$,Folder$)
//
If File$ <> ""
For n = 1 to 999
If File$ <> ""
If fb_browser(n).file = ""
fb_browser(n).file = File$
fb_browser(n).filefolder = Folder$
If Right$(File$,2) = ".x" Then fb_browser(n).ext = ".x"
If Right$(File$,4) = ".obj" Then fb_browser(n).ext = ".obj"
EXIT
Endif
Endif
Next n
Endif
If Folder$ <> "" `and File$ = ""
For n = 0 to 999
If fb_browser(n).folder = "" and Folder$ <> ".."
fb_browser(n).file = File$
fb_browser(n).folder = Folder$
If Right$(File$,2) = ".x" Then fb_browser(n).ext = ".x"
If Right$(File$,4) = ".obj" Then fb_browser(n).ext = ".obj"
If Right$(File$,4) = ".bmp" Then fb_browser(n).ext = ".bmp"
If Right$(File$,4) = ".jpg" Then fb_browser(n).ext = ".jpg"
If Right$(File$,5) = ".jpeg" Then fb_browser(n).ext = ".jpeg"
EXIT
Endif
Next n
Endif
Endfunction
//
Function Fill.FB(Folder as String ,FolderBacksteps as Integer )
//
Clean.FB()
//
CD Folder
//Fill array
Perform Checklist For Files
Find First
While FTypee <> -1
//gET THE TYPE OF FILE BEING READ
FTypee = GET FILE TYPE()
//Get File
If FTypee = 0
` If FTypee = -1 Then Exit
Add.FB(Get File Name$(),Folder)
Endif
//Get Dir name
If FTypee = 1
`If FTypee = -1 Then Exit
Add.FB("",Get File Name$())
Endif
If FTypee = -1 Then Exit
Find Next
Endwhile
// For n = 1 to Checklist Quantity()
// StringM$ = Checklist String$(n)
// If Right$(StringM$,2) = ".x" or Right$(StringM$,4) = ".obj"
// Add.FB(Checklist String$(n),"")
// index = index + 1
// Endif
// Next n
While 1
CD ".."
If Right$(Get Dir$(),12) = "PlayerEditor"
Exit
Else
If Right$(Get Dir$(),8) = "Projects"
CD "Projects"
Exit
Endif
Endif
Endwhile
Endfunction
//File Browser
Function ObjFileBrowser(folder$,ext$,x,y)
offsetx = 300
`Text 50,80,"Dir:..."+Right$(Get Dir$(),12)
Text x,y,"Folders:"
Text x+offsetx,y,"Files:"+ext$
//Id confirmed as valid
For n = 0 to 999
`If fb_browser(n).file <> "" Then Text 150,100+(n*10),fb_browser(n).file
`If fb_browser(n).folder <> "" Then Text 50,100+(n*10),fb_browser(n).folder
BoxClick = LineBoxButton(fb_browser(n).folder,x,(y+10)+(n*10),100,10)
`If Lower$ (Right$(fb_browser(n).file,Len(ext$)))= Lower$(ext$) Then
If fb_browser(n).file <> "" Then BxClick = LineBoxButton(fb_browser(n).file,x+offsetx,100+(n*10),100,10)
//Use file
//Change Folder
If BoxClick > 0 : If fb_browser(n).folder <> "" :Change.Folder.FB(folder$+fb_browser(n).folder):Wait 300:Endif:Endif
If BxClick > 0 and Lower$(right$(fb_browser(n).file,2)) = ext$
If File Exist(fb_browser(n).filefolder+"\"+fb_browser(n).file) = 1
//Return this objects number
MODELlLoad = B3D Load Object (fb_browser(n).filefolder+"\"+fb_browser(n).file) `,4564
Text x,y,"Loading "+fb_browser(n).file
Sync
Wait 500
Endif
Endif
Next n
Endfunction MODELlLoad
//
Function LineBoxButton(Text$ as String,x,y,width,height )
//Line Box, over the cube on the image
Text x,y,Text$
If Mousex() > x and mousex() < x + width and Mousey() > y and mousey() < y+height
If Text$ <> ""
`Line x,y,x,y+height
`Line x,y,x+width,y
` Line x+width,y,x+width,y+height
Line x,y+height+2,x+width,y+height+2
Text x,y,Text$
iF mOUSECLICK() = 1 tHEN RETURCLICKED = 1
Endif
Endif
//RETURN 1 WHEN CLICKED
Endfunction RETURCLICKED
//
Function Change.Folder.FB(Folder$)
If Path Exist(Folder$) = 1
If Folder$ = "."
Fill.FB(Models_Folder,1)
Else
Fill.FB(Folder$,3)
Endif
Endif
Endfunction
Mental Feedback