lol, it's fun to fall into space, the camera tilted at an angle
the level editor was intuitive enough, although selecting what kind of thing you want to "draw" with (empty, wall, dirt, playerstart...etc) is a bit tedious, it might be nice if we didn't have to click on the level button everytime we wanted to change our drawing thing (maybe have a list of them to the right that you can click on?)
anyway, i would recommend using this function to load files (and save if you want) it basically opens up one of those windows open file things (except with whatever text on it you want, so it could be "save your file" or "select a file to load"...) and returns the full filepath (including the file) that the user chose...
it's hard to explain... just try it out... (three functions, the first uses the other two)
remstart
getFileName(FileBoxTitle$,FileFilter$)
- FileBoxTitle$ is the title of the dialog, with a character "^" at the end.
- FileFilter$ determines what kind of file the user will be able to choose.
It looks like this: "Image BMP, GIF, JPG^*.bmp;*.gif;*.jpg^^". The part
before the first "^" is what the user will see. The part between this "^" and
the "^^" at the end of the string is a list of filters (with ";" as separator).
remend
rem show the file identification dialog
function getFileName(FileBoxTitle$,FileFilter$,type$)
load dll "user32.dll",1
load dll "kernel32.dll",2
load dll "comdlg32.dll",3
rem Memblock Table
OFN_MB = 1
PathBuffer_MB = 2
FileFilter_MB = 3
FileBoxTitle_MB = 4
rem Offset Table OPENFILENAME Struct
lStructSize = 0
hwndOwner = 4
hInstance = 8
lpstrFilter = 12
lpstrCustomFilter = 16
nMaxCustFilter = 20
nFilterIndex = 24
lpstrFile = 28
nMaxFile = 32
lpstrFileTitle = 36
nMaxFileTitle = 40
lpstrInitialDir = 44
lpstrTitle = 48
Flags = 52
nFileOffset = 56
nFileExtension = 58
lpstrDefExt = 60
lCustData = 64
lpfnHook = 68
lpTemplateName = 72
StructEnd = 76
rem OPENFILENAME Flag Table
OFN_ALLOWMULTISELECT = 512:rem 0x00000200
OFN_CREATEPROMPT = 8192:rem 0x00002000
OFN_ENABLEHOOK = 32:rem 0x00000020
OFN_ENABLETEMPLATE = 64:rem 0x00000040
OFN_ENABLETEMPLATEHANDLE = 128:rem 0x00000080
OFN_EXPLORER = 524288:rem 0x00080000
OFN_EXTENSIONDIFFERENT = 1024:rem 0x00000400
OFN_FILEMUSTEXIST = 4096:rem 0x00001000
OFN_HIDEREADONLY = 4:rem 0x00000004
OFN_LONGNAMES = 2097152:rem 0x00200000
OFN_NOCHANGEDIR = 8:rem 0x00000008
OFN_NODEREFERENCELINKS = 1048576:rem 0x00100000
OFN_NOLONGNAMES = 262144:rem 0x00040000
OFN_NONETWORKBUTTON = 131072:rem 0x00020000
OFN_NOREADONLYRETURN = 32768:rem 0x00008000
OFN_NOTESTFILECREATE = 65536:rem 0x00010000
OFN_NOVALIDATE = 256:rem 0x00000100
OFN_OVERWRITEPROMPT = 2:rem 0x00000002
OFN_PATHMUSTEXIST = 2048:rem 0x00000800
OFN_READONLY = 1:rem 0x00000001
OFN_SHAREAWARE = 16384:rem 0x00004000
OFN_SHOWHELP = 16:rem 0x00000010
rem FileBox Info
FileBoxFlags = OFN_EXPLORER + OFN_FILEMUSTEXIST + OFN_PATHMUSTEXIST + OFN_LONGNAMES + OFN_HIDEREADONLY + OFN_NONETWORKBUTTON
PathBufferSize = 256
hWnd = call dll(1,"GetActiveWindow")
hMod = call dll(2,"GetModuleHandleA",0)
rem Create Memblock Struct
make memblock OFN_MB,StructEnd
make memblock PathBuffer_MB,PathBufferSize
make memblock FileFilter_MB,len(FileFilter$)
make memblock FileBoxTitle_MB,len(FileBoxTitle$)
OFN = get memblock ptr(OFN_MB)
PathBuffer = get memblock ptr(PathBuffer_MB)
FileFilter = get memblock ptr(FileFilter_MB)
FileBoxTitle = get memblock ptr(FileBoxTitle_MB)
rem Dump Strings to Memblock
dump(FileFilter_MB,FileFilter$)
dump(FileBoxTitle_MB,FileBoxTitle$)
rem Write to OPENFILENAME Struct
write memblock dword OFN_MB,lStructSize,StructEnd
write memblock dword OFN_MB,hWndOwner,hWnd
write memblock dword OFN_MB,hInstance,hMod
write memblock dword OFN_MB,lpstrFilter,FileFilter
write memblock dword OFN_MB,lpstrFile,PathBuffer
write memblock dword OFN_MB,nMaxFile,PathBufferSize
write memblock dword OFN_MB,Flags,FileBoxFlags
write memblock dword OFN_MB,lpstrTitle,FileBoxTitle
if type$ = "open"
rem Open FileBox
call dll 3,"GetOpenFileNameA",OFN
result$ = getstr(PathBuffer_MB)
endif
if type$ = "save"
rem Save FileBox
call dll 3,"GetSaveFileNameA",OFN
result$ = getstr(PathBuffer_MB)
endif
rem Delete Memblock Struct
delete memblock OFN_MB
delete memblock PathBuffer_MB
delete memblock FileFilter_MB
delete memblock FileBoxTitle_MB
delete dll 1
delete dll 2
delete dll 3
endfunction result$
rem fonctions utilisées pour l'identification d'une fichier
function dump(m,s$)
for p=1 to len(s$)
b=asc(mid$(s$,p))
if b=asc("^") then b=0
write memblock byte m,p-1,b
next p
endfunction
function getstr(m)
p=0:s$=""
do
b=memblock byte(m,p)
if b=0 then exit
s$=s$+chr$(b)
inc p
loop
endfunction s$
--Peter
"We make the worst games in the universe..."