Quote: "I get an error "Path cannot be created" when I try to use it."
I wonder, does it matter which way the slash is pointing? cause I used "" try switching the "" to "/" near the start of the sub SetupFile:
I got a new Mode 2. It's only for loading while playing the game and only uses arrow keys and return key, no mouse. Use mode2 the same as mode 0.
REM File Input Opuput Function >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function FileIO(FileMode)
sync on
esc = 0
REM First sets up the window and get file names.
gosub SetupFile
REM Mode 2 is Game mode. Using only keyboard no mouse.
if FileMode = 2
keySelect = 1
KeyR = 1
hide mouse
FileSelect$ = file$(KeySelect-1)
else
keySelect = 0
show mouse
endif
REM FileIO Loop
do
REM Mouse Input
if FileMode < 2
mx = mousex()
my = mousey()
mc = mouseclick()
if mc =0 then KeyM = 0
endif
sprite 1,mx,my,101+mp
REM Sub
gosub UpdateFile
REM Update the Screen
bitmap = current bitmap()
if bitmap > 0 then copy bitmap bitmap,0
sync
REM Exits this sub when variable esc is flaged.
REM Also Change Directory back to Original path
if esc = 1 then cd FilePath$: goto FileEsc
loop
SetupFile:
REM Setting up the File Scanner Window.
REM This searches for a usable Image number to store Images.
dim FileImage(5)
FileZ = 0
for lpy = 0 to 5
FileImage(lpy) = 0
repeat
FileZ = FileZ + 1
if image exist(FileZ) = 0 then FileImage(lpy) = FileZ
until FileImage(lpy) > 0
next lpy
REM Stores the background to FileImageBG.
get image FileImage(0),0,0,screen width(),screen height()
REM This section Loads up the Folder/File/FolderUP images.
REM Images are stored into FileImage(3,4 and 5)
cls 0
x = 63:y = 1
ink rgb(10,10,10),0:box 3+x,y,14+x,12+y
ink rgb(255,255,255),0:box 3+x+1,y+1,14+x-1,12+y-1
ink rgb(10,10,10),0:box 3+x+2,y+3,14+x-2,y+3
box 3+x+2,y+5,14+x-2,y+5:box 3+x+2,y+7,14+x-2,y+7
box 3+x+2,y+9,14+x-2,y+9
x = 95:y = 1
ink rgb(10,10,10),0:box x+1,y+2,x+14,y+12
box x+1,y,x+5,y+2:ink rgb(155,155,0),0
box x+2,y+3,x+13,y+11:box x+2,y+1,x+4,y+2
ink rgb(10,10,10),0:box x+5,y+4,x+18,y+6
box x+4,y+7,x+17,y+9:box x+3,y+10,x+16,y+12
ink rgb(155,155,0),0:box x+6,y+5,x+17,y+6
box x+5,y+7,x+16,y+9:box x+4,y+10,x+15,y+11
x = 95+32:y = 1
ink rgb(10,10,10),0:box x+1,y+2,x+14,y+12
box x+1,y,x+5,y+2:ink rgb(155,155,0),0
box x+2,y+3,x+13,y+11:box x+2,y+1,x+4,y+2
ink rgb(10,10,10),0:box x+5,y+4,x+18,y+6
box x+4,y+7,x+17,y+9:box x+3,y+10,x+16,y+12
ink rgb(155,155,0),0:box x+6,y+5,x+17,y+6
box x+5,y+7,x+16,y+9:box x+4,y+10,x+15,y+11
ink rgb(10,10,10),0:dot x+13,y
box x+13-1,y+1,x+13+1,y+1:box x+13-2,y+2,x+13+2,y+2
box x+13-3,y+3,x+13+3,y+3:box x+13-1,y+4,x+13+1,y+10
ink rgb(0,255,0),0:dot x+13,y+1
box x+13-1,y+2,x+13+1,y+2:box x+13-2,y+3,x+13+2,y+3
box x+13,y+4,x+13,y+9
REM Grabing the images
for lpx = 2 to 4
get image FileImage(lpx+1),lpx*32,0,lpx*32+32,32,1
next lpx
REM Setting the default xy for the window cause it can be moved around.
fileX = screen width()*.2
fileY = screen height()*.2
REM Setting path to /Maps and saving as String to print on screen.
cls 0
FilePath$ = get dir$()
FileDir$ = ""
FileSelect$ = ""
REM Make folder "Maps" if it dont exist.
if path exist(FilePath$+"/Maps") = 0 then make directory "Maps"
REM Changing Directory to "/Maps". Changes back when exits Main Loop.
cd FilePath$+"/Maps"
FileDir$ = left$(FilePath$,1)+":/.../"+"Maps"
REM Search for Files.
dim file$(100)
dim fileType(100)
file = 0
REM Search 2 times first for folders then second for files.
for lp = 1 to 0 step -1
find first
repeat
if get file type() = lp
i$ = get file name$()
if left$(i$,1) <> "."
file$(file) = get file name$()
fileType(file) = lp
file = file + 1
endif
endif
find next
until get file type() = -1
next lp
c0 = rgb(10,10,10)
c1 = rgb(255,255,255)
c2 = rgb(70,70,70)
REM Drawing the Window.
REM OutLine Black Box.
ink c0,0:box 0,0,384,288
REM Light Blue near top.
ink rgb(180,190,200),0:box 1,1,383,288-1
REM Dark Blue.
ink rgb(120,130,150),0:box 2,2,384-1,288-1
REM Print Text OPEN FILE on Dark Blue.
set cursor 3,2:ink c1,0
if FileMode = 0 or FileMode = 2 then print "Opening File" else print "Saving File"
REM Black Inside.
ink c0,0:box 3,19,384-2,14*16+5
REM Directory/Path Box.
ink 16777215,0:box 4,1*16+4,384-3,2*16+4
set cursor 4,1*16+4:ink c0,0:print FileDir$
paste image FileImage(5),384-20,1*16+4,1
REM Selected File name Box.
ink c0,0:box 4*16+3,15*16-1,19*16-2,16*16+1
ink 16777215,0:box 4*16+4,15*16,19*16-3,16*16
set cursor 3,15*16:ink 16777215,0:print "File Name:"
REM List Box.
ink 0,0:box 4,2*16+6,380-16,14*16+4
if FileMode < 2
REM Grey OPEN/SAVE button.
ink c0,0:box 20*16+3-5 ,15*16-1,24*16-5 ,16*16+1
ink rgb(150,150,150),0:box 20*16+4-5 ,15*16,24*16-6 ,16*16
set cursor 21*16-1,15*16:ink c0,0
if FileMode = 0 or FileMode = 2 then print "Open" else print "Save"
REM Grey CLOSE/CANCEL button.
ink c0,0:box 20*16-2,16*16+7,24*16-5,17*16+8
ink rgb(150,150,150),0:box 20*16-1,16*16+8,(24*16)-6,17*16+7
set cursor 21*16-3,16*16+7:ink c0,0
if FileMode = 0 or FileMode = 2 then print "Close" else print "Cancel"
endif
REM Saving the File Scanner Window skin into Image 13.
get image FileImage(1),0,0,385,289,1
cls 0
REM Calculations for the Slider.
REM The slider height is (PixelHeight/100) * ((WinHeight/FileNum)*100)
if file < 12 then fpy = 100 else fpY = (12/abs(file)*100)
fSliderY = ((12*16-1)/abs(100)) * fpY
Return
UpdateFile:
REM File Selection list Clicked.
if mc = 1 & KeyM = 0 & CheckArea(fileX+2,fileY+37,fileX+378-13,fileY+14*16+5) = 1
if (my+fileScrY-fileY-7)/16-2 > 0 & (my+fileScrY-fileY-7)/16-2 < file+fileY/16
FileSelect$ = file$((my+fileScrY-fileY-7)/16-2)
KeyM=1
endif
endif
REM Mode 2, Return key is pressed.
if FileMode = 2 & returnkey() = 1
if KeyR = 0
FileSelect$ = FilePath$+"Maps"+FileSelect$
esc = 1:KeyM=1:KeyR = 1:return
endif
KeyR = 1
else
KeyR = 0
endif
REM Open/Save button Clicked
if mc = 1 & KeyM = 0 & CheckArea(fileX+20*16-2,fileY+15*16-1,fileX+24*16-5,fileY+16*16+1) = 1
REM FileMode = 0 is to Open.
if FileMode = 0
if Len(FileSelect$) > 0
if file exist(FileSelect$)
FileSelect$ = FilePath$+"Maps"+FileSelect$
REM Flaging the esc variable will exit File Scanner.
esc = 1:KeyM=1:return
endif
endif
endif
REM FileMode = 1 is to Save.
if FileMode = 1
if Len(FileSelect$) > 0
FileSelect$ = FilePath$+"Maps"+FileSelect$
REM Flaging the esc variable will exit File Scanner.
esc = 1:KeyM=1:return
endif
endif
endif
REM Close/Cancel button Clicked.
if mc = 1 & KeyM = 0 & CheckArea(fileX+20*16-2,fileY+16*16+7,fileX+24*16-5,fileY+17*16+8) = 1
REM Flaging the esc variable will exit File Scanner.
esc = 1 : FileSelect$="":KeyM=1:return
endif
REM Slider Clicked
REM Math is not really my subject, to hard to explain this.
if mc = 1 & KeyM = 0 & file > 12 or mc = 1 & KeyM = 5
y = (fileScrY/abs(16)) * (16/abs(100)) * fpY
if CheckArea(fileX+367,fileY+y+2*16+7,fileX+380,fileY+y+2*16+6+fSliderY) = 1 or KeyM = 5
if KeyM = 0
mx2 = mx
my2 = my
scrX2 = filescrX
scrY2 = filescrY
KeyM = 5
endif
fileScrY = scrY2+(my-my2)*(file/abs(12))
endif
endif
REM Arrow Keys pressed to Scroll up down.
if upkey() = 1 & file > 12
if FileMode = 2
if KeyU = 0 & keySelect > 1
if KeySelect < (filescrY/16)+2 then fileScrY = fileScrY - 16
keySelect = KeySelect - 1
FileSelect$ = file$(KeySelect-1)
KeyC = 0
endif
else
fileScrY = fileScrY - 1
endif
KeyU = 1
KeyC = KeyC + 1
if KeyC > 10 then KeyU = 0
else
KeyU = 0
endif
if downkey() = 1 & file > 12
if FileMode = 2
if KeyD = 0 & keySelect < file
if KeySelect > (filescrY/16)+11 then fileScrY = fileScrY + 16
keySelect = KeySelect + 1
FileSelect$ = file$(KeySelect-1)
KeyC = 0
endif
else
fileScrY = fileScrY + 1
endif
KeyD = 1
KeyC = KeyC + 1
if KeyC > 10 then KeyD = 0
else
KeyD = 0
endif
REM Checks if Slider is up too far or down too low.
if fileScrY < 0 then fileScrY = 0
if fileScrY > (file-12)*16 & file > 11 then fileScrY = (file-12)*16
REM Moving the File Scanner Window
REM Checks if it's the first click or already clicked.
if mc = 1 & KeyM = 0 or mc = 1 & KeyM = 6
REM Checks if click is in Top Blue "Open/Save file" box
if CheckArea(fileX,fileY,fileX+384,fileY+16) = 1 or KeyM = 6
REM First Time Click will store old xy of Window.
if KeyM = 0
mx2 = mx-fileX
my2 = my-fileY
KeyM = 6
REM Also store the Current Window as Image 8.
get image FileImage(2),fileX,fileY,fileX+384,fileY+288
endif
REM CurrentXY = MouseXY - OldXY
fileX = mx-mx2
fileY = my-my2
REM Checks for out of bounce.
if fileX < 0 then fileX = 0
if fileX > 640-384 then fileX = 640-384
if fileY < 0 then fileY = 0
if fileY > 480-288 then fileY = 480-288
REM Restore the Background.
paste image FileImage(0),0,0
REM Restore the Window in new position.
REM This is faster than re-drawing the whole thing again.
paste image FileImage(2),fileX,fileY
endif
endif
REM Input keys from Typing.
REM Function Typing(String$,MaxLimit,Mode).
g$ = Typing(FileSelect$,0,0)
REM Flags the UpdateFileRefresh if Keyboard typing.
if g$ <> FileSelect$ then FileSelect$ = g$
REM Draws the Background
paste image FileImage(0),0,0
REM Draws the File Manager Window.
REM Draw the File List or contents.
y = fileScrY-fileScrY/16*16
for lp = 0 to 12
REM Checks lp for out of bounce. Has to be lower than files scaned.
if file > 0 & lp < file+1
REM Blue or White color select
if file$(lp+(fileScrY/16)) = FileSelect$ then ufcolor=1 else ufcolor=0
if ufcolor = 1 then ink 25855,0 else ink 16777215,0
box fileX+4,fileY+lp*16+32+6-y,fileX+378-14,fileY+16+lp*16+32+6-y
if ufcolor = 1 then ink 16777215,0 else ink 0,0
REM Draw Box
paste image FileImage(3+filetype(lp+(fileScrY/16))),fileX+7,fileY+lp*16+32+6-y,1
REM File Name
set cursor fileX+10+16,fileY+lp*16+32+6-y
print file$(lp+(fileScrY/16))
REM File Size
if filetype(lp + (fileScrY/16)) = 0
size = file size(file$(lp + fileScrY/16 ))
if size/1000 = 0
filesize$ = str$(size)
s$=" Bytes"
else
filesize$ = str$(size/1000)
s$=" KB"
endif
set cursor fileX+326-len(filesize$)*7,fileY+lp*16+32+6-y
print filesize$+s$
endif
else
REM While doing lp check, draw an empty white box if no files.
ink 16777215,0
box fileX+4,fileY+lp*16+16+6,fileX+378-14,fileY+lp*16+32+6
endif
next fY
REM Draw the window skin.
paste image FileImage(1),fileX,fileY,1
REM Draws the Slider
y = (fileScrY/abs(16)) * (16/abs(100)) * fpY
ink 8224125,0:box fileX+366,fileY+2*16+6,fileX+381,fileY+14*16+4
ink c2,0:box fileX+367,fileY+y+2*16+7,fileX+380,fileY+y+2*16+4+fSliderY
REM Prints the Selected or Typed Filename onto the Filename box.
ink 16777215,0:box fileX+4*16+4,fileY+15*16,fileX+19*16-3,fileY+16*16
ink 0,0:set cursor fileX+4*16+6,fileY+15*16:print FileSelect$+Blinker()
return
FileEsc:
REM Clearing Unused.
for lpy = 0 to 5
if image exist(FileImage(lpy)) then delete image FileImage(lpy)
next lpy
undim FileImage(5)
EndFunction FileSelect$
Function Typing(TypingMod$,TypingL,TypingMode)
REM Inputs Keys from Keyboard to modify String$
REM Typing Limit, Zero will make it unlimited suposively.
if TypingL = 0 Then TypingL = 1000
REM Typing Input.
TypingI$ = inkey$()
REM Reset TypingG$ if there's no input.
if TypingI$ = "" then TypingG$ = ""
REM Reset keyTyping if BackSpace is not pressed.
if asc(TypingI$) <> 8 then KeyTyping = 0
REM BackSpace is Pressed. Erase one off of TypingMod$.
if asc(TypingI$) = 8
REM If first time pressing BackSpace
if KeyTyping = 0
REM Resets the TypingCounter used to time the key repeat.
TypingC = 0
REM Checks if String$ has anything.
if len(TypingMod$) > 0
REM Erase the last letter in TypingMod$.
TypingMod$ = left$(TypingMod$,len(TypingMod$)-1)
endif
endif
REM Flag this variable to not alow TypingMod$ erase.
KeyTyping = 1
REM Clear the input so it's not added to TypingG$
TypingI$=""
REM Handle the repeat of BackSpace
inc TypingC,1
if TypingC > 6 then KeyTyping = 0
endif
REM Setting up variable for checks.
z = asc(TypingI$)
REM If anything other Numbers are pressed the clear TypingI$
if TypingMode = 1 & z > 57 or TypingMode = 1 & z < 48 then TypingI$=""
REM If anything other Numbers + Leters are pressed the clear TypingI$
if TypingMode = 0 & z > 127 or TypingMode = 0 & z < 32 then TypingI$=""
REM Checks if new/old Input are different and TypingMod$ is in Limit.
if TypingG$ <> TypingI$ & len(TypingMod$) < TypingL then TypingMod$=TypingMod$+TypingI$
REM Stores the last Input. Used for checking key repeat.
TypingG$ = TypingI$
EndFunction TypingMod$
REM File Input Opuput Function <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Function Blinker()
Blink = Blink + 1
if Blink > 3
Blink = 0
if Blinker$ = "" then Blinker$ = "|" else Blinker$ = ""
endif
EndFunction Blinker$
Function CheckArea(x1,y1,x2,y2)
retval = 0
if mousex() > x1 & mousex() < x2 & mousey() > y1 & mousey() < y2 then retval = 1
EndFunction retval
[edit] For some funny reason the reverse slash cant be displayed on the forum. I swaped it with the regular slash, It should be working now and it's updated. This is why the codes didn't work for you.
Note: Befor calling this function make sure you return to the current directory to where the game is if you changed befor. This function will change directory to /maps but will change back when done.
[edit]
Updates, I added a file arrangement so it will list out the file names in alphabetical order instead of by the date created.
REM File Input Opuput Function >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function FileIO(FileMode)
sync on
esc = 0
REM First sets up the window and get file names.
gosub SetupFile
REM Mode 2 is Game mode. Using only keyboard no mouse.
if FileMode = 2
keySelect = 1
KeyR = 1
hide mouse
FileSelect$ = file$(KeySelect-1)
else
keySelect = 0
show mouse
endif
REM FileIO Loop
do
REM Mouse Input
if FileMode < 2
mx = mousex()
my = mousey()
mc = mouseclick()
if mc =0 then KeyM = 0
endif
sprite 1,mx,my,101+mp
REM Sub
gosub UpdateFile
REM Update the Screen
bitmap = current bitmap()
if bitmap > 0 then copy bitmap bitmap,0
sync
REM Exits this sub when variable esc is flaged.
REM Also Change Directory back to Original path
if esc = 1 then cd FilePath$: goto FileEsc
loop
SetupFile:
REM Setting up the File Scanner Window.
REM This searches for a usable Image number to store Images.
dim FileImage(5)
FileZ = 0
for lpy = 0 to 5
FileImage(lpy) = 0
repeat
FileZ = FileZ + 1
if image exist(FileZ) = 0 then FileImage(lpy) = FileZ
until FileImage(lpy) > 0
next lpy
REM Stores the background to FileImageBG.
get image FileImage(0),0,0,screen width(),screen height()
REM This section Loads up the Folder/File/FolderUP images.
REM Images are stored into FileImage(3,4 and 5)
cls 0
x = 63:y = 1
ink rgb(10,10,10),0:box 3+x,y,14+x,12+y
ink rgb(255,255,255),0:box 3+x+1,y+1,14+x-1,12+y-1
ink rgb(10,10,10),0:box 3+x+2,y+3,14+x-2,y+3
box 3+x+2,y+5,14+x-2,y+5:box 3+x+2,y+7,14+x-2,y+7
box 3+x+2,y+9,14+x-2,y+9
x = 95:y = 1
ink rgb(10,10,10),0:box x+1,y+2,x+14,y+12
box x+1,y,x+5,y+2:ink rgb(155,155,0),0
box x+2,y+3,x+13,y+11:box x+2,y+1,x+4,y+2
ink rgb(10,10,10),0:box x+5,y+4,x+18,y+6
box x+4,y+7,x+17,y+9:box x+3,y+10,x+16,y+12
ink rgb(155,155,0),0:box x+6,y+5,x+17,y+6
box x+5,y+7,x+16,y+9:box x+4,y+10,x+15,y+11
x = 95+32:y = 1
ink rgb(10,10,10),0:box x+1,y+2,x+14,y+12
box x+1,y,x+5,y+2:ink rgb(155,155,0),0
box x+2,y+3,x+13,y+11:box x+2,y+1,x+4,y+2
ink rgb(10,10,10),0:box x+5,y+4,x+18,y+6
box x+4,y+7,x+17,y+9:box x+3,y+10,x+16,y+12
ink rgb(155,155,0),0:box x+6,y+5,x+17,y+6
box x+5,y+7,x+16,y+9:box x+4,y+10,x+15,y+11
ink rgb(10,10,10),0:dot x+13,y
box x+13-1,y+1,x+13+1,y+1:box x+13-2,y+2,x+13+2,y+2
box x+13-3,y+3,x+13+3,y+3:box x+13-1,y+4,x+13+1,y+10
ink rgb(0,255,0),0:dot x+13,y+1
box x+13-1,y+2,x+13+1,y+2:box x+13-2,y+3,x+13+2,y+3
box x+13,y+4,x+13,y+9
REM Grabing the images
for lpx = 2 to 4
get image FileImage(lpx+1),lpx*32,0,lpx*32+32,32,1
next lpx
REM Setting the default xy for the window cause it can be moved around.
fileX = screen width()*.2
fileY = screen height()*.2
REM Setting path to /Maps and saving as String to print on screen.
cls 0
FilePath$ = get dir$()
FileDir$ = ""
FileSelect$ = ""
REM Make folder "Maps" if it dont exist.
if path exist(FilePath$+"/Maps") = 0 then make directory "Maps"
REM Changing Directory to "/Maps". Changes back when exits Main Loop.
cd FilePath$+"/Maps"
FileDir$ = left$(FilePath$,1)+":/.../"+"Maps"
REM Search for Files.
dim file$(100)
dim fileType(100)
file = 0
REM Search 2 times first for folders then second for files.
for lp = 1 to 0 step -1
find first
repeat
if get file type() = lp
i$ = get file name$()
if left$(i$,1) <> "."
file$(file) = get file name$()
fileType(file) = lp
file = file + 1
endif
endif
find next
until get file type() = -1
next lp
REM File Arrangement -------------------------------------------------
repeat
order = 0
for lp = 1 to file-1
if len(file$(lp)) > len(file$(lp-1))
length = len(file$(lp))
else
length = len(file$(lp-1))
endif
lpx=0
for lp2 = 1 to length-4
file1 = asc(mid$(file$(lp),lp2))
file2 = asc(mid$(file$(lp-1),lp2))
if file1 > 47 & file1 < 58 & file2 > 47 & file2 < 58
i$ = ""
lp3 = lp2
repeat
g$=mid$(file$(lp),lp3)
if asc(g$) >47 & asc(g$) < 58
i$ = i$ + g$
else
g$ =""
endif
lp3=lp3+1
until g$=""
file1 = val(i$)
i$ = ""
lp3 = lp2
repeat
g$=mid$(file$(lp-1),lp3)
if asc(g$) >47 & asc(g$) < 58
i$ = i$ + g$
else
g$ =""
endif
lp3=lp3+1
until g$=""
file2 = val(i$)
endif
if file1 = file2 & lpx = 0 then lpx = 0
if file1 < file2 & lpx = 0 then lpx = 1
if file1 > file2 & lpx = 0 then lpx = 2
next lp2
if lpx = 1
filebuffer$=file$(lp-1)
file$(lp-1)=file$(lp)
file$(lp)=filebuffer$
filebuffer$ = ""
order = 1
endif
next lp
until order = 0
REM End File Arrangement ------------------------------------------
c0 = rgb(10,10,10)
c1 = rgb(255,255,255)
c2 = rgb(70,70,70)
REM Drawing the Window.
REM OutLine Black Box.
ink c0,0:box 0,0,384,288
REM Light Blue near top.
ink rgb(180,190,200),0:box 1,1,383,288-1
REM Dark Blue.
ink rgb(120,130,150),0:box 2,2,384-1,288-1
REM Print Text OPEN FILE on Dark Blue.
set cursor 3,2:ink c1,0
if FileMode = 0 or FileMode = 2 then print "Opening File" else print "Saving File"
REM Black Inside.
ink c0,0:box 3,19,384-2,14*16+5
REM Directory/Path Box.
ink 16777215,0:box 4,1*16+4,384-3,2*16+4
set cursor 4,1*16+4:ink c0,0:print FileDir$
paste image FileImage(5),384-20,1*16+4,1
REM Selected File name Box.
ink c0,0:box 4*16+3,15*16-1,19*16-2,16*16+1
ink 16777215,0:box 4*16+4,15*16,19*16-3,16*16
set cursor 3,15*16:ink 16777215,0:print "File Name:"
REM List Box.
ink 0,0:box 4,2*16+6,380-16,14*16+4
if FileMode < 2
REM Grey OPEN/SAVE button.
ink c0,0:box 20*16+3-5 ,15*16-1,24*16-5 ,16*16+1
ink rgb(150,150,150),0:box 20*16+4-5 ,15*16,24*16-6 ,16*16
set cursor 21*16-1,15*16:ink c0,0
if FileMode = 0 or FileMode = 2 then print "Open" else print "Save"
REM Grey CLOSE/CANCEL button.
ink c0,0:box 20*16-2,16*16+7,24*16-5,17*16+8
ink rgb(150,150,150),0:box 20*16-1,16*16+8,(24*16)-6,17*16+7
set cursor 21*16-3,16*16+7:ink c0,0
if FileMode = 0 or FileMode = 2 then print "Close" else print "Cancel"
endif
REM Saving the File Scanner Window skin into Image 13.
get image FileImage(1),0,0,385,289,1
cls 0
REM Calculations for the Slider.
REM The slider height is (PixelHeight/100) * ((WinHeight/FileNum)*100)
if file < 12 then fpy = 100 else fpY = (12/abs(file)*100)
fSliderY = ((12*16-1)/abs(100)) * fpY
Return
UpdateFile:
REM File Selection list Clicked.
if mc = 1 & KeyM = 0 & CheckArea(fileX+2,fileY+37,fileX+378-13,fileY+14*16+5) = 1
if (my+fileScrY-fileY-7)/16-2 > 0 & (my+fileScrY-fileY-7)/16-2 < file+fileY/16
FileSelect$ = file$((my+fileScrY-fileY-7)/16-2)
KeyM=1
endif
endif
REM Mode 2, Return key is pressed.
if FileMode = 2 & returnkey() = 1
if KeyR = 0
FileSelect$ = FilePath$+"\Maps\"+FileSelect$
esc = 1:KeyM=1:KeyR = 1:return
endif
KeyR = 1
else
KeyR = 0
endif
REM Open/Save button Clicked
if mc = 1 & KeyM = 0 & CheckArea(fileX+20*16-2,fileY+15*16-1,fileX+24*16-5,fileY+16*16+1) = 1
REM FileMode = 0 is to Open.
if FileMode = 0
if Len(FileSelect$) > 0
if file exist(FileSelect$)
FileSelect$ = FilePath$+"\Maps\"+FileSelect$
REM Flaging the esc variable will exit File Scanner.
esc = 1:KeyM=1:return
endif
endif
endif
REM FileMode = 1 is to Save.
if FileMode = 1
if Len(FileSelect$) > 0
FileSelect$ = FilePath$+"\Maps\"+FileSelect$
REM Flaging the esc variable will exit File Scanner.
esc = 1:KeyM=1:return
endif
endif
endif
REM Close/Cancel button Clicked.
if mc = 1 & KeyM = 0 & CheckArea(fileX+20*16-2,fileY+16*16+7,fileX+24*16-5,fileY+17*16+8) = 1
REM Flaging the esc variable will exit File Scanner.
esc = 1 : FileSelect$="":KeyM=1:return
endif
REM Slider Clicked
REM Math is not really my subject, to hard to explain this.
if mc = 1 & KeyM = 0 & file > 12 or mc = 1 & KeyM = 5
y = (fileScrY/abs(16)) * (16/abs(100)) * fpY
if CheckArea(fileX+367,fileY+y+2*16+7,fileX+380,fileY+y+2*16+6+fSliderY) = 1 or KeyM = 5
if KeyM = 0
mx2 = mx
my2 = my
scrX2 = filescrX
scrY2 = filescrY
KeyM = 5
endif
fileScrY = scrY2+(my-my2)*(file/abs(12))
endif
endif
REM Arrow Keys pressed to Scroll up down.
if upkey() = 1 & file > 12
if FileMode = 2
if KeyU = 0 & keySelect > 1
if KeySelect < (filescrY/16)+2 then fileScrY = fileScrY - 16
keySelect = KeySelect - 1
FileSelect$ = file$(KeySelect-1)
KeyC = 0
endif
else
fileScrY = fileScrY - 1
endif
KeyU = 1
KeyC = KeyC + 1
if KeyC > 10 then KeyU = 0
else
KeyU = 0
endif
if downkey() = 1 & file > 12
if FileMode = 2
if KeyD = 0 & keySelect < file
if KeySelect > (filescrY/16)+11 then fileScrY = fileScrY + 16
keySelect = KeySelect + 1
FileSelect$ = file$(KeySelect-1)
KeyC = 0
endif
else
fileScrY = fileScrY + 1
endif
KeyD = 1
KeyC = KeyC + 1
if KeyC > 10 then KeyD = 0
else
KeyD = 0
endif
REM Checks if Slider is up too far or down too low.
if fileScrY < 0 then fileScrY = 0
if fileScrY > (file-12)*16 & file > 11 then fileScrY = (file-12)*16
REM Moving the File Scanner Window
REM Checks if it's the first click or already clicked.
if mc = 1 & KeyM = 0 or mc = 1 & KeyM = 6
REM Checks if click is in Top Blue "Open/Save file" box
if CheckArea(fileX,fileY,fileX+384,fileY+16) = 1 or KeyM = 6
REM First Time Click will store old xy of Window.
if KeyM = 0
mx2 = mx-fileX
my2 = my-fileY
KeyM = 6
REM Also store the Current Window as Image 8.
get image FileImage(2),fileX,fileY,fileX+384,fileY+288
endif
REM CurrentXY = MouseXY - OldXY
fileX = mx-mx2
fileY = my-my2
REM Checks for out of bounce.
if fileX < 0 then fileX = 0
if fileX > 640-384 then fileX = 640-384
if fileY < 0 then fileY = 0
if fileY > 480-288 then fileY = 480-288
REM Restore the Background.
paste image FileImage(0),0,0
REM Restore the Window in new position.
REM This is faster than re-drawing the whole thing again.
paste image FileImage(2),fileX,fileY
endif
endif
REM Input keys from Typing.
REM Function Typing(String$,MaxLimit,Mode).
g$ = Typing(FileSelect$,0,0)
REM Flags the UpdateFileRefresh if Keyboard typing.
if g$ <> FileSelect$ then FileSelect$ = g$
REM Draws the Background
paste image FileImage(0),0,0
REM Draws the File Manager Window.
REM Draw the File List or contents.
y = fileScrY-fileScrY/16*16
for lp = 0 to 12
REM Checks lp for out of bounce. Has to be lower than files scaned.
if file > 0 & lp < file+1
REM Blue or White color select
if file$(lp+(fileScrY/16)) = FileSelect$ then ufcolor=1 else ufcolor=0
if ufcolor = 1 then ink 25855,0 else ink 16777215,0
box fileX+4,fileY+lp*16+32+6-y,fileX+378-14,fileY+16+lp*16+32+6-y
if ufcolor = 1 then ink 16777215,0 else ink 0,0
REM Draw Box
paste image FileImage(3+filetype(lp+(fileScrY/16))),fileX+7,fileY+lp*16+32+6-y,1
REM File Name
set cursor fileX+10+16,fileY+lp*16+32+6-y
print file$(lp+(fileScrY/16))
REM File Size
if filetype(lp + (fileScrY/16)) = 0
size = file size(file$(lp + fileScrY/16 ))
if size/1000 = 0
filesize$ = str$(size)
s$=" Bytes"
else
filesize$ = str$(size/1000)
s$=" KB"
endif
set cursor fileX+326-len(filesize$)*7,fileY+lp*16+32+6-y
print filesize$+s$
endif
else
REM While doing lp check, draw an empty white box if no files.
ink 16777215,0
box fileX+4,fileY+lp*16+16+6,fileX+378-14,fileY+lp*16+32+6
endif
next fY
REM Draw the window skin.
paste image FileImage(1),fileX,fileY,1
REM Draws the Slider
y = (fileScrY/abs(16)) * (16/abs(100)) * fpY
ink 8224125,0:box fileX+366,fileY+2*16+6,fileX+381,fileY+14*16+4
ink c2,0:box fileX+367,fileY+y+2*16+7,fileX+380,fileY+y+2*16+4+fSliderY
REM Prints the Selected or Typed Filename onto the Filename box.
ink 16777215,0:box fileX+4*16+4,fileY+15*16,fileX+19*16-3,fileY+16*16
ink 0,0:set cursor fileX+4*16+6,fileY+15*16:print FileSelect$+Blinker()
return
FileEsc:
REM Clearing Unused.
for lpy = 0 to 5
if image exist(FileImage(lpy)) then delete image FileImage(lpy)
next lpy
undim FileImage(5)
EndFunction FileSelect$
Function Typing(TypingMod$,TypingL,TypingMode)
REM Inputs Keys from Keyboard to modify String$
REM Typing Limit, Zero will make it unlimited suposively.
if TypingL = 0 Then TypingL = 1000
REM Typing Input.
TypingI$ = inkey$()
REM Reset TypingG$ if there's no input.
if TypingI$ = "" then TypingG$ = ""
REM Reset keyTyping if BackSpace is not pressed.
if asc(TypingI$) <> 8 then KeyTyping = 0
REM BackSpace is Pressed. Erase one off of TypingMod$.
if asc(TypingI$) = 8
REM If first time pressing BackSpace
if KeyTyping = 0
REM Resets the TypingCounter used to time the key repeat.
TypingC = 0
REM Checks if String$ has anything.
if len(TypingMod$) > 0
REM Erase the last letter in TypingMod$.
TypingMod$ = left$(TypingMod$,len(TypingMod$)-1)
endif
endif
REM Flag this variable to not alow TypingMod$ erase.
KeyTyping = 1
REM Clear the input so it's not added to TypingG$
TypingI$=""
REM Handle the repeat of BackSpace
inc TypingC,1
if TypingC > 6 then KeyTyping = 0
endif
REM Setting up variable for checks.
z = asc(TypingI$)
REM If anything other Numbers are pressed the clear TypingI$
if TypingMode = 1 & z > 57 or TypingMode = 1 & z < 48 then TypingI$=""
REM If anything other Numbers + Leters are pressed the clear TypingI$
if TypingMode = 0 & z > 127 or TypingMode = 0 & z < 32 then TypingI$=""
REM Checks if new/old Input are different and TypingMod$ is in Limit.
if TypingG$ <> TypingI$ & len(TypingMod$) < TypingL then TypingMod$=TypingMod$+TypingI$
REM Stores the last Input. Used for checking key repeat.
TypingG$ = TypingI$
EndFunction TypingMod$
REM File Input Opuput Function <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Function Blinker()
Blink = Blink + 1
if Blink > 3
Blink = 0
if Blinker$ = "" then Blinker$ = "|" else Blinker$ = ""
endif
EndFunction Blinker$
Function CheckArea(x1,y1,x2,y2)
retval = 0
if mousex() > x1 & mousex() < x2 & mousey() > y1 & mousey() < y2 then retval = 1
EndFunction retval