Well, I created a browser once... Here is the code:
`***********************************************
`**** browser ****
`***********************************************
`**** Sven Boulanger ****
`***********************************************
sync on
standardmap$=get dir$()
current$=get dir$()
perform checklist for drives
drivenr=checklist quantity()
dim drives$(drivenr)
for x=1 to drivenr
drives$(x)=checklist string$(x)
next x
set dir current$
perform checklist for files
`* store/load *
if file exist("face.txt")=0
open to write 1,"face.txt"
writecolor(1,200,200,255)
writecolor(1,0,0,0)
writecolor(1,200,200,255)
writecolor(1,100,100,175)
close file 1
endif
open to read 1,"face.txt"
face$=current$+"\"
dim bckground(0)
bckground(0)=loadcolor()
dim text(0)
text(0)=loadcolor()
dim key(1)
key(0)=loadcolor()
key(1)=loadcolor()
close file 1
`start
y#=20
set text size 18
lastopened$="none"
do
`clear screen
cls bckground(0)
`search files
find first
find next
name$=get file name$()
`"previous"-button
if button(10,y#,"previous")>0 and hold=0 then gosub open : hold=1
`file buttons
for f=1 to checklist quantity()-2
find next
name$=get file name$()
if button(10,y#+f*20,name$)>0 and hold=0 then gosub open : hold=1
next f
`control keys
maxy#=(checklist quantity()-2)*20+40
ink bckground(0),0
box 500,1,639,479
if maxy#>480
if upkey()=1 then y#=y#+3
if downkey()=1 then y#=y#-3
if y#>20 then y#=20
if y#+maxy#<480
y#=480-maxy#
endif
endif
`create mouse lock
if mouseclick()=0 then hold=0
`display path
ink rgb(200,0,0),0
box 0,475,639,479
if mousey()>475
ink 0,0
box 0,450,639,479
ink rgb(255,255,255),0
set text size 10
text 2,465,current$
text 2,450,"last opened: "+lastopened$
set text size 18
endif
`create display-menu
if controlbutton(600,40,"options")>0 then gosub options
if controlbutton(600,80,"refresh")>0
open to read 1,face$+"face.txt"
bckground(0)=loadcolor()
text(0)=loadcolor()
key(0)=loadcolor()
key(1)=loadcolor()
close file 1
endif
if controlbutton(600,120,"exit")>0 then end
`create quick menu
if maxy#>480
if controlbutton(600,380,"top")>0 and hold=0 then hold=1 : y#=20
if controlbutton(600,440,"bottom")>0 and hold=0 then hold=1 : y#=480-maxy#
endif
sync
loop
`********** open clicked files **********
open:
`check file
if get file type()=1
current$=current$+"\"+name$
set dir current$
current$=get dir$()
set dir current$
perform checklist for files
else
`get file extension:
`-1 character extension
type$=mid$(name$,l-1)+mid$(name$,l)
if type$=".x" or type$=".X" then gosub view_obj
`-2 character extension
type$=mid$(name$,l-2)+mid$(name$,l-1)+mid$(name$,l)
if type$=".xt" or type$=".XT" then gosub view_mid
if type$=".it" or type$=".IT" then gosub view_mid
`-3 character extension
l=len(name$)
type$=mid$(name$,l-2)+mid$(name$,l-1)+mid$(name$,l)
if type$="BMP" or type$="bmp" then gosub view_bmp
if type$="JPG" or type$="jpg" then gosub view_bmp
if type$="rle" or type$="RLE" then gosub view_bmp
if type$="dib" or type$="DIB" then gosub view_bmp
if type$="png" or type$="PNG" then gosub view_bmp
if type$="dds" or type$="DDS" then gosub view_bmp
if type$="tga" or type$="TGA" then gosub view_bmp
if type$="pcx" or type$="PCX" then gosub view_bmp
if type$="psd" or type$="PSD" then gosub view_bmp
if type$="3ds" or type$="3DS" then gosub view_obj
if type$="avi" or type$="AVI" then gosub view_avi
if type$="mid" or type$="MID" then gosub view_mid
if type$="mp3" or type$="MP3" then gosub view_wav
if type$="mp2" or type$="MP2" then gosub view_wav
if type$="wma" or type$="WMA" then gosub view_mid
if type$="rmi" or type$="RMI" then gosub view_mid
if type$="mod" or type$="MOD" then gosub view_mid
if type$="s3m" or type$="S3M" then gosub view_mid
if type$="wav" or type$="WAV" then gosub view_wav
if type$="mpg" or type$="MPG" then gosub view_avi
`-4 character extension
type$=mid$(name$,l-3)+mid$(name$,l-2)+mid$(name$,l-1)+mid$(name$,l)
if type$="jpeg" or type$="JPEG" then gosub view_bmp
if type$="tiff" or type$="TIFF" then gosub view_bmp
if type$="mpeg" or type$="MPEG" then gosub view_avi
`remember the last opened file
lastopened$=name$
endif
y#=20
return
`********** view bitmaps ***********
view_bmp:
controlbutton(31,11,"return")
ink rgb(0,0,0),0 : box 62,0,123,21
ink rgb(255,255,255),0 : box 63,1,124,22
ink key(0),0 : box 63,1,123,21
ink text(0),0 : center text 93,3,"return"
get image 2,0,0,63,23
get image 3,62,0,125,23
paste image 2,10,100
paste image 3,10,200
`clear screen
cls
`load bitmap
load bitmap current$+"\"+name$,1
bx#=bitmap width(1)
by#=bitmap height(1)
get image 1,0,0,bx#,by#
`start
mx#=5
my#=5
sizex#=bx#
sizey#=by#
size#=100.0/bx#*by#
do
`control
if mouseclick()=1
mx#=mx#+mousemovex()
my#=my#+mousemovey()
else
if mouseclick()=2
if shiftkey()=0
sizex#=sizex#+mousemovex()
sizey#=sizey#+mousemovey()
else
sizex#=sizex#+mousemovex()
sizey#=sizex#/100.0*size#
endif
endif
endif
`reset
if controlkey()=1 then sizex#=bx : sizey#=by : mx#=5 : my#=5
`update sprite
if sizex#<1 then sizex#=1
if sizey#<1 then sizey#=1
sprite 1,mx#,my#,1
size sprite 1,sizex#,sizey#
`exit key
if returnkey()=1 then exit
sprite 2,569,439,2 : show sprite 2
sprite 3,569,439,3 : hide sprite 3
if mousex()>569 and mousex()<631
if mousey()>439 and mousey()<461
if mouseclick()=1 then show sprite 3 : hide sprite 2 : hold=1 : exit
endif
endif
sync
loop
`delete images
delete bitmap 1
for i=1 to 3
delete image i
delete sprite i
next i
cls
return
`********** view models **********
view_obj:
`set camera
cls
set camera range 1,100000
autocam on
backdrop on
color backdrop bckground(0)
fog on
fog distance 5000
fog color bckground(0)
`load object
load object current$+"\"+name$,1
if total object frames(1) > 0 then loop object 1
`camera fov
default# = 3.14 / 2.805
set camera fov default#
fov# = default#
oldfov# = fov#
do
angx#=object angle x(1)
angy#=object angle y(1)
angz#=object angle z(1)
`control object
if mouseclick()=1
yrotate object 1,wrapvalue(angy#-mousemovex())
xrotate object 1,wrapvalue(angx#-mousemovey())
endif
if controlkey()=1 then rotate object 1,0,0,0
`exit key
if returnkey()=1 then exit
if controlbutton(600,450,"return")>0 then hold=1 : exit
`option to convert to .X if 3DS
if type$="3ds" or type$="3DS"
ink 0,0
box 1,450,100,479
if button(5,465.0,"convert to X")>0 and hold=0
hold=1
l=len(name$)-4
for x=1 to l
char$=mid$(name$,x)
name2$=name2$+char$
next x
if file exist(current$+name2$+str$(2)+".X")=1 then delete file current$+name2$+str$(2)+".X"
if file exist(current$+name2$+str$(2)+".x")=1 then delete file current$+name2$+str$(2)+".x"
3DS2X current$+"\"+name$,current$+"\"+name2$+str$(2)+".X"
endif
endif
`handle fov
if mouseclick() = 2
fov# = fov# - (mousemovey() / 20.0)
if fov# < 0.1 then fov# = 0.1
if fov# > default#+1 then fov# = default# + 1
endif
if fov# <> oldfov#
set camera fov fov#
oldfov# = fov#
endif
sync
loop
`delete
delete object 1
cls
return
`********** view animation **********
view_avi:
`clear screen
cls
`load movie
load animation current$+"\"+name$,1
do
`update animation
place animation 1,160,120,480,360
`control
ink bckground(0),0
box 0,420,639,479
if controlbutton(40,450,"play")>0 and hold=0
if animation playing(1)=0
play animation 1
endif
hold=1
endif
if controlbutton(140,450,"stop")>0 and hold=0
if animation playing(1)=1
stop animation 1
endif
hold=1
endif
if mouseclick()=0 then hold=0
`exit key
if returnkey()=1 then exit
if controlbutton(600,450,"return")>0 then hold=1 : exit
sync
loop
`delete
delete animation 1
cls
return
`********** view music **********
view_mid:
if music exist(1)>0 then delete music 1
if sound exist(1)>0 then delete sound 1
`clear screen
cls
`load midi
load music current$+"\"+name$,1
music_name$=name$
if music playing(1)=1 then stop music 1
`start
do
ink rgb(255,0,0),0
set cursor 50,60
print music_name$
`control panel
ink bckground(0),0
box 0,420,639,479
if controlbutton(40,450,"play")>0 and hold=0
if music playing(1)=0 then play music 1
hold=1
endif
if controlbutton(140,450,"stop")>0 and hold=0
if music playing(1)>0 then stop music 1
hold=1
endif
if music paused(1)=0
if controlbutton(240,450,"pause")>0 and hold=0
hold=1
pause music 1
endif
else
if controlbutton(240,450,"resume")>0 and hold=0
hold=1
resume music 1
endif
endif
if mouseclick()=0 then hold=0
`exit key
if returnkey()=1 then exit
if controlbutton(600,450,"return")>0 then hold=1 : music_minimise=0 : exit
if button(320,450.0,"return but continue playing")>0 then music_minimise=1 : exit
sync
loop
`delete
if music_minimise=0 then delete music 1
cls
return
`********** view sounds **********
view_wav:
if music exist(1)>0 then delete music 1
if sound exist(1)>0 then delete sound 1
`clear screen
cls
`load sound
load sound current$+"\"+name$,1
if sound playing(1)=1 then stop sound 1
`start
eax=0
volume=get sound volume(1)
mute=0
do
cls
ink rgb(255,0,0),0
set cursor 50,60
print name$
`control
ink bckground(0),0
box 0,420,639,479
if controlbutton(40,450,"play")>0 and hold=0
if sound playing(1)=0 then play sound 1
hold=1
endif
if controlbutton(140,450,"stop")>0 and hold=0
if sound playing(1)=1 then stop sound 1
hold=1
endif
if sound paused(1)=0
if controlbutton(240,450,"pause")>0 and hold=0
hold=1
pause sound 1
endif
else
if controlbutton(240,450,"resume")>0 and hold=0
hold=1
resume sound 1
endif
endif
if mouseclick()=0 then hold=0
`volume
ink bckground(0),0
box 560,0,639,479
ink rgb(255,0,0),0
box 570,140,630,340
ink rgb(0,255,0),0
box 570,340-volume*2,630,340
if mute=0
if controlbutton(600,80,"mute on")>0 and hold=0
mute=1
oldvolume=volume
hold=1
endif
else
if controlbutton(600,80,"mute off")>0 and hold=0
mute=0
volume=oldvolume
hold=1
endif
endif
if mute=0
if controlbutton(600,120,"+")>0 then inc volume
if controlbutton(600,360,"-")>0 then dec volume
if volume<0 then volume=0
if volume>100 then volume=100
else
volume=0
endif
set sound volume 1,volume
`exit key
if returnkey()=1 then exit
if controlbutton(600,450,"return")>0 then hold=1 : music_minimise=0 : exit
if button(340,450.0,"return but continue playing")>0
hold=1
music_minimise=1
exit
endif
if spacekey()=1 and hold=0
if file exist("snap.bmp")>0 then delete file "snap.bmp"
get image 1,0,0,640,480
save image "snap.bmp",1
endif
sync
loop
`delete
if music_minimise=0 then delete sound 1
cls
return
`************************************ option menu *********************************
options:
open to read 1,face$+"face.txt"
read word 1,bckred
read word 1,bckgreen
read word 1,bckblue
read word 1,tred
read word 1,tgreen
read word 1,tblue
read word 1,bred
read word 1,bgreen
read word 1,bblue
close file 1
do
ink rgb(200,200,200),0
box 100,100,540,440
ink 0,0
center text 320,110,"*** background ***"
center text 320,210,"*** text ***"
center text 320,310,"*** button ***"
`control rgb
`background
ink 0,0
box 110,130,365,135 : set cursor 370,122 : print "red: "+str$(bckred)
box 110,140,365,145 : set cursor 370,133 : print "green: "+str$(bckgreen)
box 110,150,365,155 : set cursor 370,144 : print "blue: "+str$(bckblue)
ink rgb(255,0,0),0 : box 110,130,110+bckred,135
ink rgb(0,255,0),0 : box 110,140,110+bckgreen,145
ink rgb(0,0,255),0 : box 110,150,110+bckblue,155
ink rgb(bckred,bckgreen,bckblue),0
box 500,130,525,155
`text
ink 0,0
box 110,230,365,235 : set cursor 370,222 : print "red: "+str$(tred)
box 110,240,365,245 : set cursor 370,233 : print "green: "+str$(tgreen)
box 110,250,365,255 : set cursor 370,244 : print "blue: "+str$(tblue)
ink rgb(255,0,0),0 : box 110,230,110+tred,235
ink rgb(0,255,0),0 : box 110,240,110+tgreen,245
ink rgb(0,0,255),0 : box 110,250,110+tblue,255
ink rgb(tred,tgreen,tblue),0
box 500,230,525,255
`button
ink 0,0
box 110,330,365,335 : set cursor 370,322 : print "red: "+str$(bred)
box 110,340,365,345 : set cursor 370,333 : print "green: "+str$(bgreen)
box 110,350,365,355 : set cursor 370,344 : print "blue: "+str$(bblue)
ink rgb(255,0,0),0 : box 110,330,110+bred,335
ink rgb(0,255,0),0 : box 110,340,110+bgreen,345
ink rgb(0,0,255),0 : box 110,350,110+bblue,355
ink rgb(bred,bgreen,bblue),0
box 500,330,525,355
`control
if mousex()>110 and mouseclick()<365
if mousey()>130 and mousey()<135 and mouseclick()=1 then bckred=mousex()-110
if mousey()>140 and mousey()<145 and mouseclick()=1 then bckgreen=mousex()-110
if mousey()>150 and mousey()<155 and mouseclick()=1 then bckblue=mousex()-110
if mousey()>230 and mousey()<235 and mouseclick()=1 then tred=mousex()-110
if mousey()>240 and mousey()<245 and mouseclick()=1 then tgreen=mousex()-110
if mousey()>250 and mousey()<255 and mouseclick()=1 then tblue=mousex()-110
if mousey()>330 and mousey()<335 and mouseclick()=1 then bred=mousex()-110
if mousey()>340 and mousey()<345 and mouseclick()=1 then bgreen=mousex()-110
if mousey()>350 and mousey()<355 and mouseclick()=1 then bblue=mousex()-110
endif
if controlbutton(140,400,"save")>0
if file exist(standardmap$+"face.txt")=1 then delete file standardmap$+"face.txt"
open to write 1,standardmap$+"face.txt"
writecolor(1,bckred,bckgreen,bckblue)
writecolor(1,tred,tgreen,tblue)
writecolor(1,bred,bgreen,bblue)
writecolor(1,bred,bgreen,bblue)
close file 1
exit
endif
if controlbutton(240,400,"standard")>0
bckred=200 : bckgreen=200 : bckblue=255
tred=0 : tgreen=0 : tblue=0
bred=200 : bgreen=200 : bblue=255
endif
center text 320,520,"press a to apply, press s to save"
`color control
bckred=in(0,bckred,255) : bckgreen=in(0,bckgreen,255) : bckblue=in(0,bckblue,255)
tred=in(0,tred,255) : tgreen=in(0,tgreen,255) : tblue=in(0,tblue,255)
bred=in(0,bred,255) : bgreen=in(0,bgreen,255) : bblue=in(0,bblue,255)
if controlbutton(340,400,"apply")>0 then exit
sync
loop
bckground(0)=rgb(bckred,bckgreen,bckblue)
text(0)=rgb(tred,tgreen,tblue)
key(0)=rgb(bred,bgreen,bblue)
key(1)=rgb(bred,bgreen,bblue)
return
`********************
`functions
`********************
function button(x,y#,text$)
pressed=0
tx=text width(text$)
ty#=text height(text$)/2
if mousex()<x+tx and mousex()>x
if mousey()<y#+ty# and mousey()>y#-ty#
pressed=1
endif
endif
if pressed=1 then ink rgb(0,0,255),0 else ink text(0),0
set cursor x,y#-8
print text$
if mouseclick()=0 then pressed=0
ink 0,0
endfunction pressed
function controlbutton(x,y,text$)
pressed=0
if mousex()<x+30 and mousex()>x-30
if mousey()<y+10 and mousey()>y-10
pressed=1
endif
endif
if pressed=1 then inkr=1 else inkr=0
if mouseclick()=0 then pressed=0
if pressed=0
ink rgb(230,230,255),0 : box x-31,y-11,x+30,y+10
ink rgb(0,0,75),0 : box x-30,y-10,x+31,y+11
ink key(0),0 : box x-30,y-10,x+30,y+10
else
ink rgb(230,230,255),0 : box x-30,y-10,x+31,y+11
ink rgb(0,0,75),0 : box x-31,y-11,x+30,y+10
ink key(1),0 : box x-30,y-10,x+30,y+10
endif
if inkr=1 then ink rgb(255,0,0),0 else ink text(0),0
center text x,y-8,text$
endfunction pressed
function writecolor(file,red,green,blue)
write word 1,red
write word 1,green
write word 1,blue
endfunction
function loadcolor()
read word 1,red
read word 1,green
read word 1,blue
color=rgb(red,green,blue)
endfunction color
function in(min,val,max)
if val>max then val=max
if val<min then val=min
endfunction val
I'm not asking you to copy it, but you're free to use it as a reference...
Immunity and Annihalation makes Immunihalation...