Code center > Darwinbots Program Source Code
NSIS-based installer
Numsgil:
When I first started the simulation, I still get an empty sim. This might not be an issue with the installer but with the exe. I'm not sure. Hitting F1 and then start new started up a proper sim (this is what the program should do automatically in my mind). The mutation rates could do with some tweaking (way too high at present). I had some difficulty loading new settings (kept reverting to my old settings), but that might be an issue with the program and not the installer or the settings. The uninstaller seemed to work just fine, so no issues there.
goffrie:
--- Quote ---Assuming we did it, though, would it be able to update all the shortcuts to point to the newest version? It's really a pain trying to find the newest version to run from a list of 20 exes in the directory.
--- End quote ---
It would update just during installation, and I'm pretty sure I could get the shortcut to point to the right executable. I guess I could make a separate automatic update program, although it'd be tied to my installer (for shortcut updating).
Numsgil:
NSIS is free software, right? I don't mind tying the program to free software if it makes users' lives easier, especially with updates.
goffrie:
Hint: its website is http://nsis.sourceforge.net/ Yup, it's free software.
Speaking of "free as in freedom" software, here's the NSIS source:
--- Code: ---!include MUI2.nsh
!include VB6RunTime.nsh
Name "Darwinbots 2.4"
OutFile "Darwin_setup.exe"
InstallDir "$PROGRAMFILES\DarwinbotsII"
InstallDirRegKey HKLM "Software\Darwinbots" "InstallDir"
RequestExecutionLevel admin
BrandingText " "
XPStyle on
CRCCheck on
SilentInstall normal
SetCompressor /SOLID lzma
Var AlreadyInstalled
!define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Darwinbots"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "ShortcutDir"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
Var StartMenuFolder
!insertmacro MUI_PAGE_STARTMENU "DarwinbotsII" $StartMenuFolder
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
Section "Install" Install
SetShellVarContext current
SetOutPath "$INSTDIR"
File "/home/goffrie/Darwinbots/DarwinBotsII/Darwin2.43.1l.exe"
File "/home/goffrie/Darwinbots/DarwinBotsII/How to setup a DarwinBots server.txt"
SetOverwrite off
File "/home/goffrie/Darwinbots/DarwinBotsII/intsett.ini"
File /r "/home/goffrie/Darwinbots/DarwinBotsII/Robots"
File /r "/home/goffrie/Darwinbots/DarwinBotsII/Settings"
SetOutPath "$INSTDIR\Autosave"
SetOutPath "$INSTDIR\Saves"
SetOutPath "$INSTDIR\Transfers"
SetOutPath "$INSTDIR\Transfers\F1"
SetOutPath "$INSTDIR\Transfers\F1\in"
SetOutPath "$INSTDIR\Transfers\F1\out"
SetOutPath "$SYSDIR"
File "/home/goffrie/Darwinbots/OCX/*.OCX"
RegDLL "$SYSDIR\COMCT232.OCX"
RegDLL "$SYSDIR\COMDLG32.OCX"
RegDLL "$SYSDIR\MSCOMCTL.OCX"
RegDLL "$SYSDIR\MSINET.OCX"
RegDLL "$SYSDIR\RICHTX32.OCX"
RegDLL "$SYSDIR\TABCTL32.OCX"
File "msstdfmt.dll"
RegDLL "$SYSDIR\msstdfmt.dll"
SetOverwrite on
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
;Create Start Menu shortcuts
!insertmacro MUI_STARTMENU_WRITE_BEGIN "DarwinbotsII"
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Darwinbots.lnk" "$INSTDIR\Darwin2.43.1l.exe"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Darwinbots folder.lnk" "$INSTDIR"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
!insertmacro MUI_STARTMENU_WRITE_END
CreateShortCut "$DESKTOP\Darwinbots.lnk" "$INSTDIR\Darwin2.43.1l.exe"
;Store installation folder
WriteRegStr HKLM "Software\Darwinbots" "InstallDir" $INSTDIR
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DarwinbotsII" "DisplayName" "Darwinbots II"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DarwinbotsII" "UninstallString" "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DarwinbotsII" "InstallLocation" "$INSTDIR"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DarwinbotsII" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DarwinbotsII" "NoRepair" 1
;Install VB runtime
IfFileExists "$INSTDIR\Darwin.exe" 0 new_installation
StrCpy $AlreadyInstalled 1
new_installation:
!insertmacro VB6RunTimeInstall /home/goffrie/Darwinbots/vb6 $AlreadyInstalled
SectionEnd
Section "Uninstall"
SetShellVarContext current
Delete "$INSTDIR\Darwin2.43.1l.exe"
Delete "$INSTDIR\How to setup a DarwinBots server.txt"
Delete "$INSTDIR\intsett.ini"
Delete "$INSTDIR\Uninstall.exe"
Delete "$INSTDIR\Robots\Alga_Minimalis.txt"
Delete "$INSTDIR\Robots\Animal_Minimalis.txt"
Delete "$INSTDIR\Robots\Dominator_Invicibalis.txt"
Delete "$INSTDIR\Robots\Excalibur.txt"
Delete "$INSTDIR\Robots\Republican_Bee.txt"
Delete "$INSTDIR\Robots\Seasnake_1.0.txt"
Delete "$INSTDIR\Settings\default.set"
Delete "$INSTDIR\Settings\lastexit.set"
Delete "$INSTDIR\Settings\AnimalMinimalis-mutation.set"
Delete "$INSTDIR\Settings\Dominator.set"
Delete "$INSTDIR\Settings\DominatorVsSeasnake.set"
Delete "$INSTDIR\Settings\RepublicanBee.set"
Delete "$INSTDIR\Settings\RepublicanBeeVsDominator.set"
Delete "$INSTDIR\Settings\Seasnake.set"
Delete "$INSTDIR\Settings\SeasnakeVsRepublicanBee.set"
IfErrors 0 +2
MessageBox MB_OK "Could not delete some files. Ensure that they are not in use and delete them manually."
ClearErrors
RMDir "$INSTDIR\Autosave"
RMDir "$INSTDIR\Robots"
RMDir "$INSTDIR\Saves"
RMDir "$INSTDIR\Settings"
RMDir "$INSTDIR\Transfers\F1\in"
RMDir "$INSTDIR\Transfers\F1\out"
RMDir "$INSTDIR\Transfers\F1"
RMDir "$INSTDIR\Transfers"
RMDir "$INSTDIR"
IfErrors 0 okay
MessageBox MB_YESNO "One or more folders were not deleted because they contain extra files, such as custom settings, save files or robots. Delete them?" IDNO okay
ClearErrors
MessageBox MB_YESNO "Are you sure you want to perform this operation? This will delete ALL files in $INSTDIR." IDNO okay
RMDir /r "$INSTDIR"
IfErrors 0 okay
MessageBox MB_YESNO "Deleting all files recursively failed. Do you want to delete them on the next reboot?" IDNO okay
RMDIR /r /REBOOTOK "$INSTDIR"
okay:
!insertmacro MUI_STARTMENU_GETFOLDER "DarwinbotsII" $StartMenuFolder
Delete "$SMPROGRAMS\$StartMenuFolder\Darwinbots.lnk"
Delete "$SMPROGRAMS\$StartMenuFolder\Darwinbots folder.lnk"
Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk"
RMDir "$SMPROGRAMS\$StartMenuFolder"
Delete "$DESKTOP\Darwinbots.lnk"
DeleteRegKey /ifempty HKLM "Software\Darwinbots"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DarwinbotsII"
;Remove VB runtime
!insertmacro VB6RunTimeUnInstall
SectionEnd
--- End code ---
Numsgil:
Yup, I have no problems with having everything use an installer. Unless Eric rejects the idea, I'm behind it 100%. It'll make it easier to package DB with some custom DLLs if the need arises, and makes it much easier on the casual user.
As far as automatically detecting new versions: how exactly are you envisioning it would work? Like would I re-run the old installer and it would tell me if it has a new version to install, and then do it automatically?
Maybe when you click the Darwinbots shortcut in the start menu, it would run a bridge application that would check for new updates, and install them. Otherwise it would just run the latest DB version. That way people's versions are kept up to date automagically.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version