I've searched and searched but can't find a simple file requester that will work in fullscreen 3D.
Anyone got one? I want to load levels.
Thanks
Dog
Anyone got one? I want to load levels.
Thanks
Dog
;..... Global eg_keyb_repeattime = 100 ;--> Keyboard Repetierzeit (in ms) Global eg_keyb_timetorepeat = 350 ;--> Zeit bis zum Einsetzen des Repeatiervorgangs (in ms) Global eg_keyb_timer ;--> Zeitmesser für Keyboard Global eg_curs_pos ;--> Position Cursor Global eg_curs_blinkspeed = 250 ;--> Blinkgeschwindigkeit des Cursors (in ms) Global eg_curs_blinkstate ;--> Status für Cursorblinken Global eg_curs_timer ;--> Timer für Cursorblinken ;.....and so on
; This Procedure is for free MPZ (@) from Berlin ; Version 0.2 1/2004 ; ; in the USERLIBS must be the file kernel32.decls ;.lib "kernel32.dll" ;api_RtlMoveMemory(Destination*,Source,Length) : "RtlMoveMemory" ; in the USERLIBS must be the file comdlg32.decls ;.lib "comdlg32.dll" ;api_GetOpenFileName% (pOpenfilename*) : "GetOpenFileNameA" ;api_GetSaveFileName% (pOpenfilename*) : "GetSaveFileNameA" ;Graphics 800,600;,0,2 Global hWnd=SystemProperty("AppHWND") ; GetOpen/saveFileName consts Flags (useful ones only!)... Const OFN_CREATEPROMPT = $2000 ; Prompts the user as to whether they want to create a file that doesnt exist. Const OFN_FILEMUSTEXIST = $1000 ; File must exist for it to be returned. Const OFN_HIDEREADONLY = 4 ; Hides the read only button in the dialog... Const OFN_NOCHANGEDIR = 8 ; Stops the user from changing the initial directory. Const OFN_NONETWORKBUTTON = $20000 ; Hides and disables the network button. Const OFN_NOREADONLYRETURN = $8000 ; Stops the requester returning readonly files.. Const OFN_NOVALIDATE = 256 ; If selected, no check will be done for invalid characters. Const OFN_OVERWRITEPROMPT = 2 ; Prompt for overwrite file... Const OFN_PATHMUSTEXIST = $800 ; Specifies that the path MUST exist for it to be able to be selected. Const OFN_READONLY = 1 ; Makes the read only checkbox in the dialog box to be checked immediately. ; getopenfile $(Title_of_Requester$, SearchPath$,Files_with_ending$, Flags); ; getsavefile $(Title_of_Requester$, Save_File_name$,Files_with_ending$, Flags); ; ; Title_of_Requester$= "Name of the Requester / Name des Dateifragefensters ; SearchPath$ = "C:" ; Path for File searching / Pfad wo nach der Datei gesuchet werden soll ; Files_with_ending$ = "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0) ; = "Blitzbasic" + Chr$(0) + "*.bb" + Chr$(0) + "Text" + Chr$(0) + "*.txt" + Chr$(0) ; Flags = See Flag lists ; Save_File_name$ = "C:\test.bb" ; Name of the Savefile with Path / Name der Datei mit Pfad zum speichern ;file$ = getopenfile$("File open / Datei öffnen","c:\documents and settings","*.bmp" + Chr$(0) + "*.bmp" + Chr$(0)); flags optional ;image = LoadImage(file) ;DebugLog file$ ;DrawImage image,0,0 ;file$ = getopenfile$("File open / Datei öffnen","c:\documents and settings","*.bmp" + Chr$(0) + "*.bmp" + Chr$(0)); flags optional ;image = LoadImage(file) ;DebugLog file$ ;DrawImage image,0,500 ;temp$ = getsavefile$("File Save / Datei sichern","c:\hello.bb","Blitzbasic" + Chr$(0) + "*.bb" + Chr$(0) + "Text" + Chr$(0) + "*.txt" + Chr$(0));; flags optional ;DebugLog(temp$) ;While MouseHit(1) <> 1 ;Wend ;End ;--------------------------You can use it as BlitzLIB Function getOpenFile$(lpstrTitle$,lpstrInitialDir$,lpstrFilter$,flags=$1000) nextOffset%=0 theBank=CreateBank(76) lStructSize=76 PokeInt theBank,nextOffset%,lStructSize nextOffset%=nextOffset%+4 hwndOwner=hWnd PokeInt theBank,nextOffset%,hwndOwner nextOffset%=nextOffset%+4 hInstance=0 PokeInt theBank,nextOffset%,hInstance nextOffset%=nextOffset%+4 If lpstrFilter$ = "" Then lpstrFilter$ = "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)+ Chr$(0) Else lpstrFilter$ = lpstrFilter$ + Chr$(0) End If lpstrFilter_ = CreateBank(Len(lpstrFilter$)) string_in_bank(lpstrFilter$,lpstrFilter_) PokeInt theBank,nextOffset%,AddressOf(lpstrFilter_) nextOffset%=nextOffset%+4 lpstrCustomFilter=0 PokeInt theBank,nextOffset%,lpstrCustomFilter nextOffset%=nextOffset%+4 nMaxCustFilter=0 PokeInt theBank,nextOffset%,nMaxCustFilter nextOffset%=nextOffset%+4 nFilterIndex=0 PokeInt theBank,nextOffset%,nFilterIndex nextOffset%=nextOffset%+4 lpstrFile$= String$ (" ", 254) lpstrFile_ = CreateBank(Len(lpstrFile$)) string_in_bank(lpstrFile$,lpstrFile_) PokeInt theBank,nextOffset%,AddressOf(lpstrFile_) nextOffset%=nextOffset%+4 nMaxFile=255 PokeInt theBank,nextOffset%,nMaxFile nextOffset%=nextOffset%+4 lpstrFileTitle$=String$ (" ", 254) lpstrFileTitle_ = CreateBank(Len(lpstrFileTitle$)) string_in_bank(lpstrFileTitle$,lpstrFileTitle_) PokeInt theBank,nextOffset%,AddressOf(lpstrFileTitle_) nextOffset%=nextOffset%+4 nMaxFileTitle=255 PokeInt theBank,nextOffset%,nMaxFileTitle nextOffset%=nextOffset%+4 If lpstrInitialDir$="" Then lpstrInitialDir$="c:"+Chr$(0) Else lpstrInitialDir$=lpstrInitialDir$+Chr$(0) End If lpstrInitialDir_ = CreateBank(Len(lpstrInitialDir$)) string_in_bank(lpstrInitialDir$,lpstrInitialDir_) PokeInt theBank,nextOffset%,AddressOf(lpstrInitialDir_) nextOffset%=nextOffset%+4 If lpstrTitle$="" Then lpstrTitle$="Open"+Chr$(0) Else lpstrTitle$ = lpstrTitle$ + Chr$(0) End If lpstrTitle_ = CreateBank(Len(lpstrTitle$)) string_in_bank(lpstrTitle$,lpstrTitle_) PokeInt theBank,nextOffset%,AddressOf(lpstrTitle_) nextOffset%=nextOffset%+4 PokeInt theBank,nextOffset%,flags nextOffset%=nextOffset%+4 nFileOffset=0 PokeShort theBank,nextOffset%,nFileOffset nextOffset%=nextOffset%+2 nFileExtension=0 PokeShort theBank,nextOffset%,nFileExtension nextOffset%=nextOffset%+2 lpstrDefExt=0 PokeInt theBank,nextOffset%,lpstrDefExt nextOffset%=nextOffset%+4 lCustData=0 PokeInt theBank,nextOffset%,lCustData nextOffset%=nextOffset%+4 lpfnHook=0 PokeInt theBank,nextOffset%,lpfnHook nextOffset%=nextOffset%+4 lpTemplateName$=""+Chr$(0) lpTemplateName_ = CreateBank(Len(lpTemplateName$)) string_in_bank(lpTemplateName$,lpTemplateName_) PokeInt theBank,nextOffset%,AddressOf(lpTemplateName_) nextOffset%=nextOffset%+4 If api_GetOpenFileName (theBank) Then lpstrFile$ = bank_in_string$(lpstrFile_) Else lpstrFile$ ="" End If FreeBank theBank FreeBank lpstrFilter_ FreeBank lpstrFile_ FreeBank lpstrFileTitle_ FreeBank lpstrInitialDir_ FreeBank lpstrTitle_ FreeBank lpTemplateName_ Return lpstrFile$ End Function Function getsaveFile$(lpstrTitle$,lpstrFile$,lpstrFilter$,flags=2) ; Get a SAVEFILENAME nextOffset%=0 theBank=CreateBank(76) lStructSize=76 PokeInt theBank,nextOffset%,lStructSize nextOffset%=nextOffset%+4 hwndOwner=hWnd PokeInt theBank,nextOffset%,hwndOwner nextOffset%=nextOffset%+4 hInstance=0 PokeInt theBank,nextOffset%,hInstance nextOffset%=nextOffset%+4 If lpstrFilter$ = "" Then lpstrFilter$ = "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)+ Chr$(0) Else lpstrFilter$ = lpstrFilter$ + Chr$(0) End If lpstrFilter_ = CreateBank(Len(lpstrFilter$)) string_in_bank(lpstrFilter$,lpstrFilter_) PokeInt theBank,nextOffset%,AddressOf(lpstrFilter_) nextOffset%=nextOffset%+4 lpstrCustomFilter=0 PokeInt theBank,nextOffset%,lpstrCustomFilter nextOffset%=nextOffset%+4 nMaxCustFilter=0 PokeInt theBank,nextOffset%,nMaxCustFilter nextOffset%=nextOffset%+4 nFilterIndex=0 PokeInt theBank,nextOffset%,nFilterIndex nextOffset%=nextOffset%+4 lpstrFile_ = CreateBank(255) string_in_bank(lpstrFile$+Chr$(0),lpstrFile_) PokeInt theBank,nextOffset%,AddressOf(lpstrFile_) nextOffset%=nextOffset%+4 nMaxFile=255 PokeInt theBank,nextOffset%,nMaxFile nextOffset%=nextOffset%+4 lpstrFileTitle$=String$ (" ", 254) lpstrFileTitle_ = CreateBank(Len(lpstrFileTitle$)) string_in_bank(lpstrFileTitle$,lpstrFileTitle_) PokeInt theBank,nextOffset%,AddressOf(lpstrFileTitle_) nextOffset%=nextOffset%+4 nMaxFileTitle=255 PokeInt theBank,nextOffset%,nMaxFileTitle nextOffset%=nextOffset%+4 lpstrInitialDir$=""+Chr$(0) lpstrInitialDir_ = CreateBank(Len(lpstrInitialDir$)) string_in_bank(lpstrInitialDir$,lpstrInitialDir_) PokeInt theBank,nextOffset%,AddressOf(lpstrInitialDir_) nextOffset%=nextOffset%+4 If lpstrTitle$="" Then lpstrTitle$="Save"+Chr$(0) Else lpstrTitle$ = lpstrTitle$ + Chr$(0) End If lpstrTitle_ = CreateBank(Len(lpstrTitle$)) string_in_bank(lpstrTitle$,lpstrTitle_) PokeInt theBank,nextOffset%,AddressOf(lpstrTitle_) nextOffset%=nextOffset%+4 PokeInt theBank,nextOffset%,flags nextOffset%=nextOffset%+4 nFileOffset=0 PokeShort theBank,nextOffset%,nFileOffset nextOffset%=nextOffset%+2 nFileExtension=0 PokeShort theBank,nextOffset%,nFileExtension nextOffset%=nextOffset%+2 lpstrDefExt=0 PokeInt theBank,nextOffset%,lpstrDefExt nextOffset%=nextOffset%+4 lCustData=0 PokeInt theBank,nextOffset%,lCustData nextOffset%=nextOffset%+4 lpfnHook=0 PokeInt theBank,nextOffset%,lpfnHook nextOffset%=nextOffset%+4 lpTemplateName$=""+Chr$(0) lpTemplateName_ = CreateBank(Len(lpTemplateName$)) string_in_bank(lpTemplateName$,lpTemplateName_) PokeInt theBank,nextOffset%,AddressOf(lpTemplateName_) If api_GetSaveFileName (theBank) Then lpstrFile$ = bank_in_string$(lpstrFile_) Else lpstrFile$ ="" End If FreeBank theBank FreeBank lpstrFilter_ FreeBank lpstrFile_ FreeBank lpstrFileTitle_ FreeBank lpstrInitialDir_ FreeBank lpstrTitle_ FreeBank lpTemplateName_ Return lpstrFile$ End Function Function AddressOf(Bank) ; Find the correct Adress of a Bank (for C *Pointer) Local Address = CreateBank(4) api_RtlMoveMemory(Address,Bank+4,4) Return PeekInt(Address,0) End Function Function string_in_bank(s$,bankhandle) ; Put a String in a Bank Local pos=1 Local pos2=0 Repeat PokeByte(bankhandle,pos2,Asc(Mid(s$,pos,Len(s$)))) pos=pos+1 pos2=pos2+1 Until pos=Len(s$)+1 End Function Function bank_in_string$(bankhandle) ; Get a String from a Bank Local s$="" Local pos=0 Repeat s$=s$+Chr(PeekByte(bankhandle,pos)) pos=pos+1 Until pos=BankSize(bankhandle) s$=Replace$(s$,Chr(0)," ") Return s$ End Function
file$ = getopenfile$("File open",file_path$,"*.b3d" + Chr$(0) + "*.b3d" + Chr$(0) + "*.3ds" + Chr$(0) + "*.3ds" + Chr$(0)); flags optional
;File requester ; ;activePath$ = the active path ; ;selectedFile$ = the selected file ; ;drv$(drive) = the selected drive ; ;------------------------------------------------------------------------- Graphics 640, 480, 0, 3 SetBuffer BackBuffer() ;cam=CreateCamera () ;light=CreateLight() ;CameraClsColor cam,40, 40, 55 ;------------------------GLOBALS------------------------------------------ Global filter$=".que" ;file filter Dim drctrs$(0) ;temp directories Dim realfiles$(0) ;temp files Dim txtfiles$(0) ;temp filtered files Dim drv$(0) ;drives Global selectedFile$ ;current selected file $ Global directories ;temp no. of directories Global drvcnt ;no. of drives Global check$ ;$ to compare with filter$ Global txtcount ;temp no. of files in a directory Global drd1 ;start position of directories to display Global drd2 ;end -"- -"- Global trd1 ;start position of files to display Global trd2 ;end -"- -"- Global dscr ;how many more directories then 20 Global tscr ;how many more files then 20 Global drive ;current drive no. Global mouseInUse ;if mouse in use Global activePath$ ="levels" ;the active path ;----------------OPEN FILE------------------------------------------------ count_drives ;--------------------loop While Not KeyHit(1) Cls ;RenderWorld ;highlight ^up-------------------------------------------------- If MouseY()>47 And MouseY()<60 And MouseX()>144 And MouseX()<170 Color 64,80,110 Rect 144,47,27,12 If MouseDown(1) ypos=0 ypos2=0 actualpos=0 pos=1 While (pos>actualpos)And (pos<Len(activePath$)) actualpos=pos pos=Instr(activePath$,"",pos+1) Wend If (actualpos=1) Then actualpos=0 activePath$ =Left$(activePath$,actualpos) read_dir(drive,activePath$) selectedFile$="" Repeat Until (Not MouseDown(1)) EndIf EndIf ;---------------------- Color 56,78,112:Rect 0,30,40,270:Rect 0,0,400,29 Line 41,45,400,45:Line 41,60,400,60 Line 384,46,384,300:Line 180,46,180,300:Line 196,46,196,300 Color 50,50,75:Rect 41,30,359,15 Color 50,255,100:Line 40,0,40,300:Line 0,29,400,29 Text 1,2,"Select" Text 1,13,"Drive" Text 50,7,"Open file Back" Text 50,48,"Directories File:" Text 50,32,"Path: " Color 255,255,80:Text 80,32,drv$(drive)+":"+Left$(activePath$, 60) Text 145,48,"|^Up|":Text 233,48,Left$(selectedFile$,29) Text 200,7,"Filter: "+filter$ ;----------------------------------------------------- If MouseY()<29 ;----open file -------------------- If MouseX()>50 And MouseX()<100 Color 50,170,170:Rect 47,3,51,23,0 ;Put here your action when open file is pressed If MouseDown(1) Then End EndIf ; back-------------------------- If MouseX()>113 And MouseX()<145 Color 50,170,170:Rect 113,3,36,23,0 If MouseDown(1) Then End EndIf EndIf ;------------------------------------------------ For t=0 To drvcnt-1 Color 50,255,100 Text 16,35+t*20,drv$(t)+":" If MouseX()<29 And MouseY()>30+t*20 If MouseY()<30+(drvcnt)*20 And MouseDown(1) drive=(MouseY()-30)/20 read_dir(drive,"") activePath$="" selectedFile$="" ypos=0 ypos2=0 EndIf ;--------------------------------------------- If MouseY()>30+(drvcnt)*20 Then Goto skip Color 50,170,170 Rect 1,31+t*20,38,20,0 If t=0 Then Goto skip Color 56,78,112 Rect 1,31+(t-1)*20,38,20,0 .skip EndIf Next ;--------------------scroller position---------------------------- If directories>19 FlushMouse() If MouseDown(1) If (MouseX()>179 And MouseX()<197 Or (mouseInUse And MouseX()<210 And MouseX()>160)) And MouseY()>61 And MouseY()<299 ypos = MouseY()-6 If dscr >0 met#=227.0/dscr drd1=Floor ((ypos-56)/met#) drd2=drd1+19 EndIf mouseInUse =True EndIf Else mouseInUse =False EndIf Color 255,234,99 If (ypos<62) Then ypos=62 If (ypos>284) Then ypos=284 Rect 182,ypos,13,15 EndIf ;----------------------------------------------- If txtcount>19 FlushMouse() If MouseDown(1) If (MouseX()>383 And MouseX()<400 Or (mouseInUse And MouseX()<400 And MouseX()>360)) And MouseY()>61 And MouseY()<292 ypos2 = MouseY()-6 If tscr >0 met2#=227.0/tscr trd1=Floor ((ypos2-56)/met2#) trd2=trd1+19 EndIf mouseInUse =True EndIf Else mouseInUse =False EndIf Color 255,234,99 If (ypos2<62) Then ypos2=62 If (ypos2>284) Then ypos2=284 Rect 386,ypos2,13,15 EndIf ;---------------------file selector highlight----------------------------- If MouseY()>60 And MouseX()>50 And MouseX()<180 And (Not mouseInUse) Color 64,80,110 Rect 49,49+((MouseY()-46)/12)*12,130,11 FlushMouse() If MouseDown(1) dirmet=(drd1+Floor ((MouseY()-46)/12))-1 If dirmet<directories activePath$ = activePath$+drctrs$(dirmet)+"" read_dir(drive,activePath$) ypos=0 ypos2=0 selectedFile$="" EndIf Repeat Until Not MouseDown(1) EndIf EndIf ;-------------------------------------------------------------------- If MouseY()>60 And MouseX()>202 And MouseX()<384 And (Not mouseInUse) Color 64,80,110 Rect 201,49+((MouseY()-46)/12)*12,182,11 If MouseDown(1) filmet=(trd1+Floor ((MouseY()-46)/12))-1 If filmet<txtcount selectedFile$ = txtfiles$(filmet) EndIf Repeat Until Not MouseDown(1) EndIf EndIf ;----------display Directories and Files------------- display Flip Wend ;---------------F U N C T I O N S ---------------------------------------- ;---------------READ_DIR-------------------------------------------------- Function read_dir(drive,path$) directories=0 drf=0 drd1=0 trd1=0 dir=ReadDir (drv$(drive)+":"+path$) Repeat file$=NextFile$(dir) If file$="" Then Goto readfiles drf=drf+1 If file$<>".." And file$<>"." If FileType (drv$(drive)+":"+path$+file$)=2 Then directories=directories+1 EndIf Forever ;--------readfiles--------------------------- .readfiles Dim drctrs$(directories) Dim realfiles$(drf-directories) tempdir=(ReadDir(drv$(drive)+":"+path$)) tmpcnt=0 For i=0 To drf-1 temp$=NextFile$(tempdir) If FileType (drv$(drive)+":"+path$+temp$)=2 If temp$<>".." And temp$<>"." drctrs$(tmpcnt)=temp$ tmpcnt=tmpcnt+1 EndIf Else realfiles$(i-tmpcnt)=temp$ EndIf Next ; sort directories For i=1 To directories-1 If Upper(drctrs$(i))< Upper(drctrs$(i-1)) temp$ = Upper(drctrs$(i-1)) drctrs$(i-1) = Upper(drctrs$(i)) drctrs$(i) =Upper$(temp$) For j= i-1 To 1 Step -1 If drctrs$(j)<drctrs$(j-1) temp$ = Upper(drctrs$(j-1)) drctrs$(j-1) = Upper(drctrs$(j)) drctrs$(j) =Upper(temp$) Else j=1 EndIf Next EndIf Next ; get only filtered files tmpcnt=0 For i=0 To drf-directories-1 check$ = Right(realfiles$(i),4) check$=Lower(check$) If (check$=filter$) tmpcnt=tmpcnt+1 EndIf Next txtcount =tmpcnt Dim txtfiles$(txtcount+21) tmpcnt=0 For i=0 To drf-directories-1 check$ = Right(realfiles$(i),4) check$=Lower(check$) If (check$=filter$) txtfiles$(tmpcnt)=realfiles$(i) tmpcnt=tmpcnt+1 EndIf Next ; sort filtered files For i=1 To txtcount-1 If Upper(txtfiles$(i)) < Upper(txtfiles$(i-1)) temp$ = Upper(txtfiles$(i-1)) txtfiles$(i-1) = Upper(txtfiles$(i)) txtfiles$(i) =temp$ For j= i-1 To 1 Step -1 If txtfiles$(j)<txtfiles$(j-1) temp$ = Upper(txtfiles$(j-1)) txtfiles$(j-1) = Upper(txtfiles$(j)) txtfiles$(j) = Upper(temp$) Else j=1 EndIf Next EndIf Next ;---if more then 20 directories or files calculate how many more If directories<20 drd2=directories-1 Else drd2=19:dscr=directories-20 EndIf If txtcount<20 trd2=txtcount-1 Else trd2=19:tscr=txtcount-20 EndIf End Function ;-------------------DISPLAY----------------------------------------------- Function display() Color 70,255,220 For i=drd1 To drd2 Text 50,60+12*(i-drd1), Left$(drctrs$(i),25) Next Color 180,180,230 For i=trd1 To trd2 Text 205,60+12*(i-trd1), Left$(txtfiles$(i),35) Next End Function ;---------COUNT_DRIVES---------------------------------------------------- Function count_drives() drvcnt=0 Dim drv$(14) For i=Asc("C") To Asc("K") ;For i=Asc("c") To Asc("k");put this if the above doesn't work fr=ReadDir(Chr$(i)+":") If fr<>0 Then drv$(drvcnt)=Chr$(i) drvcnt=drvcnt+1 CloseDir(fr) EndIf Next End Function