i have made a mp3d Installer file, ready today. Please test it carefully, bugs message to me. For all who want to use a exe file:
and for all fearful user the sourcecode, please activate administratormode.
P.S. With the CheckBoxGadget("MP3D_lib only") it is possible to install the lib only if a make a new beta lib
Code: Select all
;////////////////////////////////////////////////////////////////
;//
;// Project Title: MP 3D Engine Demo Programs
;// Dateiname: MP3d_Installer.pb
;// Erstellt am: 3.Mai.2014
;// Update am :
;// Author: Michael Paulwitz
;//
;// Info:
;// Simple Installer fro Mp3d
;//
;//
;////////////////////////////////////////////////////////////////
; http://www.flasharts.de/mpz/mp33_beta/MP3D_Installer.exe
Global MP_http.s = "http://www.flasharts.de/mpz/",PurebasicHome.s
InitNetwork()
UseZipPacker()
Global mainwindow
Global frm
Global pbcombo
Global pbcombo2
Global progressbar
Global optional_title_gadget
Global threadsave
Global pbdir_title
Global PurebasicHome.s
Global pbhome
Global install
Global exitinstall
Global pbeditor
Global mp3d_libonly
Procedure OpenWindow_0(x = 0, y = 0, width = 450, height = 550)
mainwindow = OpenWindow(#PB_Any, x, y, width, height, "MP3D Installer - V.0.3", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
pbcombo_title = TextGadget(#PB_Any, 60, 80, 100, 20, "Select PB Version: ")
pbcombo = ComboBoxGadget(#PB_Any, 60, 100, 180, 20)
AddGadgetItem(pbcombo, 0, "Purebasic 4.60 < 5.11")
AddGadgetItem(pbcombo, 1, "Purebasic 5.24 < 5.31")
pbcombo2_title = TextGadget(#PB_Any, 290, 80, 150, 20, "Select OS Type: ")
pbcombo2 = ComboBoxGadget(#PB_Any, 290, 100, 100, 20)
AddGadgetItem(pbcombo2, 0, "x86 (32 bit)")
AddGadgetItem(pbcombo2, 1, "x64 (64 bit)")
SetGadgetState(pbcombo, 1)
SetGadgetState(pbcombo2, 0)
optional_title_gadget = TextGadget(#PB_Any, 107, 30, 220, 20, "Hello to all, have fun with MP3D!", #PB_Text_Center)
pbdir_title = TextGadget(#PB_Any, 180, 135, 100, 20, "Purebasic directory")
PurebasicHome.s = GetEnvironmentVariable("PUREBASIC_HOME")
If PurebasicHome = ""
PurebasicHome = GetEnvironmentVariable("ProgramFiles") + "\Purebasic\"
EndIf
pbhome = StringGadget(#PB_Any, 60, 155, 330, 20, PurebasicHome)
install = ButtonGadget(#PB_Any, 60, 500, 100, 25, "Install")
exitinstall = ButtonGadget(#PB_Any, 290, 500, 100, 25, "Exit Installer")
progressbar = ProgressBarGadget(#PB_Any, 60, 460, 330, 20, 0, 1000, #PB_ProgressBar_Smooth)
pbeditor = EditorGadget(#PB_Any, 60, 280, 330, 160, #PB_Editor_WordWrap)
miscellaneous = TextGadget(#PB_Any, 187, 185, 125, 20, "Miscellaneous")
mp3d_libonly = CheckBoxGadget(#PB_Any, 60, 200, 100, 20, "MP3D_lib only")
threadsafe = CheckBoxGadget(#PB_Any, 60, 220, 150, 20, "Threadsafe (coming soon)")
DisableGadget(threadsafe, 1)
EndProcedure
Procedure Write_help()
file$=GetTemporaryDirectory()+"mp3d"
If ReceiveHTTPFile( MP_http + "mp33_beta/Help/MP3D_Library.chm",file$)=0
MessageRequester("Error :: 404","Help File not found - Please check your internet connection & try again later...")
ProcedureReturn
EndIf
CreateDirectory(PurebasicHome+"Help")
Text$ = PurebasicHome+"Help\MP3D_Library.chm"
If CopyFile(file$, PurebasicHome+"Help\MP3D_Library.chm")
AddGadgetItem(pbeditor, -1, "Wrote "+Text$+" Successfully!")
EndIf
SetGadgetState(progressbar, 100)
EndProcedure
Procedure Write_lib()
file$=GetTemporaryDirectory()+"mp3d"
If GetGadgetState(pbcombo2)=0
If ReceiveHTTPFile( MP_http + "mp33_beta/lib32/Lib32.zip",file$)=0
MessageRequester("Error 404 (32-bit)","File(s) not found - Please check your internet connection & try again later...")
ProcedureReturn
EndIf
ElseIf GetGadgetState(pbcombo2)=1
If ReceiveHTTPFile( MP_http + "mp33_beta/lib64/Lib64.zip",file$)=0
MessageRequester("Error 404 (64-bit)","File(s) not found - Please check your internet connection & try again later...")
ProcedureReturn
EndIf
EndIf
If OpenPack(0, file$)
If ExaminePack(0)
While NextPackEntry(0)
Text$ = PurebasicHome+"PureLibraries\Windows\Libraries"+PackEntryName(0)
If UncompressPackFile(0, Text$)
AddGadgetItem(pbeditor, -1, "Wrote "+Text$+" Successfully!")
Else
AddGadgetItem(pbeditor, -1, "Can´t write File: "+Text$+" ERROR !")
EndIf
WindowEvent()
Wend
EndIf
ClosePack(0)
EndIf
SetGadgetState(progressbar, 200)
EndProcedure
Procedure Write_Demos()
SetGadgetText(pbeditor, "Decompressing demo files... ")
file$=GetTemporaryDirectory()+"mp3d"
If ReceiveHTTPFile(MP_http + "mp33_beta/Examples/MP3D_Demos.zip",file$)=0
MessageRequester("Error :: 404","File(s) not found..."+Chr(13)+Chr(10)+Chr(13)+Chr(10)+"Please check your internet connection & try again later...")
ProcedureReturn
EndIf
CreateDirectory(PurebasicHome+"Examples\MP3D Demos")
count = 200
If OpenPack(0, file$)
If ExaminePack(0)
While NextPackEntry(0)
Text$ = PurebasicHome+"Examples\"+PackEntryName(0)
If UncompressPackFile(0, Text$) = -1
CreateDirectory( GetPathPart(Text$))
UncompressPackFile(0, Text$)
EndIf
txt.s = txt.s + "Wrote "+Text$+" Successfully!"+Chr(13)+Chr(10)
AddGadgetItem(pbeditor, -1, txt.s)
SetGadgetState(progressbar, count)
count + 1
WindowEvent()
Wend
EndIf
ClosePack(0)
EndIf
SetGadgetState(progressbar, 800)
EndProcedure
Procedure Write_Mp3dlib()
file$=GetTemporaryDirectory()+"mp3d"
If GetGadgetState(pbcombo) = 1
If GetGadgetState(pbcombo2) = 0
Text$ = MP_http + "mp33_beta/dx9/pb522_32/MP3D_Library.zip"
Else
Text$ = MP_http + "mp33_beta/dx9/pb522_64/MP3D_Library.zip"
EndIf
ElseIf GetGadgetState(pbcombo) = 0
If GetGadgetState(pbcombo2) = 0
Text$ = MP_http + "mp33_beta/dx9/pb511_32/MP3D_Library.zip"
Else
Text$ = MP_http + "mp33_beta/dx9/pb511_64/MP3D_Library.zip"
EndIf
EndIf
If ReceiveHTTPFile( Text$,file$)=0
MessageRequester("Error :: 404","File(s): '"+Text$+"' not found..."+Chr(13)+Chr(10)+Chr(13)+Chr(10)+"Please check your internet connection & try again later...")
ProcedureReturn
EndIf
CreateDirectory(PurebasicHome+"SubSystems\dx9")
Text$ = PurebasicHome+"SubSystems\dx9\purelibraries"
CreateDirectory(Text$)
If OpenPack(0, file$)
If ExaminePack(0)
While NextPackEntry(0)
Text$+"\MP3D_Library"
If UncompressPackFile(0, Text$)
AddGadgetItem(pbeditor, -1, "Wrote File: "+Text$+" Successfully!")
Else
AddGadgetItem(pbeditor, -1, "Can´t write File: "+Text$+" ERROR !")
EndIf
WindowEvent()
Wend
EndIf
ClosePack(0)
EndIf
AddGadgetItem(pbeditor, 0, "* * * * * * * * * * * * * * * * * * * * * * *")
AddGadgetItem(pbeditor, 0, "*")
AddGadgetItem(pbeditor, 0, "* Installation of MP3D Successfully! *")
AddGadgetItem(pbeditor, 0, "*")
AddGadgetItem(pbeditor, 0, "* * * * * * * * * * * * * * * * * * * * * * *")
SetGadgetState(progressbar, 1000)
EndProcedure
Procedure Window_0_Events(event)
Select event
Case #PB_Event_CloseWindow
ProcedureReturn #False
Case #PB_Event_Gadget
Select EventGadget()
Case install
SetGadgetState(install, 0)
PBdir.s = GetGadgetText(pbhome)
If ExamineDirectory(0, PBdir, "*.*")
a = 1
FinishDirectory(0)
EndIf
If a = 0
MessageRequester("Error :: 404","File(s) not found in directory '"+PBdir+"'...", #PB_MessageRequester_Ok)
ProcedureReturn
EndIf
PurebasicHome = GetGadgetText(pbhome)
If GetGadgetState(mp3d_libonly) ; Install mp3dlib only
Write_Mp3dlib()
Else
Write_help()
Write_lib()
Write_Demos()
Write_Mp3dlib()
EndIf
Case exitinstall
End
EndSelect
EndSelect
ProcedureReturn #True
EndProcedure
OpenWindow_0()
Repeat
Event = WindowEvent()
Select EventWindow()
Case MainWindow
Window_0_Events(event)
EndSelect
Until Event = #PB_Event_CloseWindow
; IDE Options = PureBasic 5.22 LTS (Windows - x86)
; CursorPosition = 229
; FirstLine = 177
; Folding = --
; EnableAsm
; EnableXP
; EnableAdmin
; DisableDebugger