Darwinbots Forum
Code center => Darwinbots Program Source Code => Topic started by: goffrie on June 07, 2008, 07:09:41 PM
-
I created an NSIS-based installer for Darwinbots 2.43.1L. It currently installs all the OCX's installed by the original installer as well as msstdfmt.dll (needed for the custom costs dialog), and registers them all. It does not install comdlg32.dll, which is usually already present. If it should be added, tell me. Currently the installed bots consist of Alga Minimalis, Animal Minimalis, Seasnake, and Republican Bee. If you want to recommend any example bots, then do so
I tested it on a brand-new Windows XP SP2 install (hosed my old VirtualBox image thanks to a lack of disk space when merging a snapshot) and it seems to work mostly fine, although for some reason the Settings directory didn't seem to get created (it's in the script though as a recursive copy, although with only default.set).
If you were to make a consistent way of downlloading the newest Darwinbots executable (I.e. in a single place which doesn't change between versions), I could make the installer download the newest version during the installation, using NSISdl. ZIP decompression is also supported in NSIS so that isn't a problem.
The installer is internally compressed with solid LZMA compression so don't bother compressing it again.
(edit: new installer below)
Oh, and here is the NSIS script. It'll need some adjusting to work on Windows since I use it on Linux and it is using Unix-style paths.
Right now, it doesn't uninstall any of the DLLs/OCXs which it installs. If that's an issue I can still add the removal to the uninstall code, but I'd have to add more registry keys to remember whether or not it existed before the installer ran.
!include MUI2.nsh
!include VB6RunTime.nsh
Name "DarwinBots 2.4"
OutFile "Darwin_setup.exe"
InstallDir "$PROGRAMFILES\DarwinBots"
InstallDirRegKey HKCU "Software\DarwinBots" ""
RequestExecutionLevel admin
BrandingText " "
XPStyle on
CRCCheck on
SilentInstall normal
SetCompressor /SOLID lzma
Var AlreadyInstalled
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!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
SetOutPath "$INSTDIR"
File "/home/goffrie/Darwinbots/DarwinBotsII/Darwin.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"
;Store installation folder
WriteRegStr HKCU "Software\Darwinbots" "" $INSTDIR
;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"
Delete "$INSTDIR\Darwin.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\Gridlock.txt"
Delete "$INSTDIR\Robots\Republican_Bee.txt"
Delete "$INSTDIR\Robots\Seasnake_1.0.txt"
Delete "$INSTDIR\Settings\default.set"
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"
DeleteRegKey /ifempty HKCU "Software\Darwinbots"
;Remove VB runtime
!insertmacro VB6RunTimeUnInstall
SectionEnd
Gah, another thing I forgot to mention: It doesn't install any shortcuts, I forgot to add it in. I'll put it in... later
-
Nobody wants to comment?
-
Nobody wants to comment?
Speaking for myself: not commenting is a sign of lack of knowledge on my part, not for lack of respect for the work done...
-
It looks good, but like you say it needs to add shortcuts (one of the shortcuts should be to the actual folder itself, since much work needs to be done in that folder). Also, the directory name should be DarwinbotsII (even though it's confusing since most haven't seen DB1). Mostly this is to allow me to eventually have a Darwinbots3 directory that's distinct without causing people to panic when they can't find DB2. You should also keep the exe name unchanged, so users can find a way to know what version they're using by opening up their directory. Any maybe a text file that explains where to find the latest patches and what to do with them. When I start up the exe, it prompts me about missing settings files. It would be nice if the installer handled all of that, and we could do away with that whole clause. After I click through the dialogs, my new install does not start a simulation, or it starts an empty simulation (hard to tell either way). I would set up some quick settings for the different bots included, so people can load them immediately when they first start the game. It's especially important that these default settings be something that they can leave running for a time and see some mutations going on. So the settings should be set to let it run without crashing (the population, not the program ). The default settings that the program launches with should be animal minimalis (but then again, I'm hardly an impartial judge ) When I uninstalled the program, I accidentally left the game running, so not everything got deleted. The uninstaller should give me a warning message or something to let me know.
Also, some notes to Eric: the splash screen that used to launch when the program was run no longer does. At the very least it should spash the first time the game is run (which you can detect if there's no lastexit.sim file maybe?). intsett.ini should remove any irrelevant data (such as the bogus http), to prevent users from thinking that it is important, and not knowing what to set it to.
And I would include the bot Dominator Invincibalis. It's a good middle tier bot that's very resistant to breaking changes in newer versions.
I'm appreciative of the effort. Don't think my long list of complaints is anything but nitpicking
-
Shortcuts have been added to the script (on my hard drive for now.)
Just a question - is the proper capitalization "DarwinBots" or "Darwinbots"? It's been used both ways, so I'm wondering which I should use for paths and such.
After I click through the dialogs, my new install does not start a simulation, or it starts an empty simulation (hard to tell either way). I would set up some quick settings for the different bots included, so people can load them immediately when they first start the game.
Sorry, I don't really understand you here - what file(s) should be added?
About uninstalling, I already have the "confirm" page, which lists the install directory. What else should I add there?
-
DarwinBots is what Carlo uses (the original coder). I use Darwinbots. I would say that Darwinbots is the modern spelling, and DarwinBots is an archaic spelling.
For adding files: are you familiar with the fact that you can save different simulating settings in settings files? These have a .set file type. Which is different than saving a simulation with file type .sim. Basically they're a template for a new simulation. I would add a few that set up some good settings for the different bots you're including.
And as for uninstalling, I think there should just be a warning if it wasn't able to delete something for some reason. Don't know if the software allows that or not, though, but it would be nice.
-
Okay, I'll use "Darwinbots" then.
I am aware of .set files, although I wasn't too sure what you meant by "my new install does not start a simulation". Anyways, I did add Dominator Invincibalis, and created some basic (more or less tested) .set files. The only problem is that Republican Bee is significantly better at combat than the other bots, so I basically had to rig the settings in favour of the other bot, but it would still usually win in the end.
Also, I get what you mean by the warnings now. I'll see if I can do anything about that.
-
Much appreciated
Oh, also, Excalibur might be another good bot to include. It's had some fans recently, and been praised highly for its strength vs. ease of understanding.
-
Okay, new version time!
Has Alga Minimalis, Animal Minimalis, Dominator Invincibalis, Excalibur, Republican Bee, and Seasnake 1.0.
It now creates shortcuts on the desktop (always, just one) and in the start menu (there is an installer page for that). It also creates an entry in Add/Remove Programs.
If the uninstaller is unable to remove any files, it will warn the user. If it cannot then delete the folder, it will prompt to recursively delete the folders, and if it still cannot do so, it will ask if it can schedule the deletion for the next bootup. Yay NSIS.
It includes several basic setting files, although none of them include Excalibur because that was added at the last minute and I was lazy
It's been tested a few times (*cough* I've installed/uninstalled around... what, 20 times already? ) although I don't know if the delete-on-reboot works (it is an NSIS option so it should be okay.)
Once again, if you can put the latest version of Darwinbots in a standard place, I can have the installer automatically download it. You can have a zip called 'Darwin.zip' and it can contain the properly versioned .exe and it should be okay.
Hope you like it
[attachment=957:Darwin_setup.exe]
P.S. Go LZMA, 9MB executable -> 2.5MB installer = win
-
Once again, if you can put the latest version of Darwinbots in a standard place, I can have the installer automatically download it. You can have a zip called 'Darwin.zip' and it can contain the properly versioned .exe and it should be okay.
That's really Eric's area, since he's the one that'll have to place the new versions in the appropriate place. 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.
I'm testing the installer now...
-
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.
-
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.
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).
-
NSIS is free software, right? I don't mind tying the program to free software if it makes users' lives easier, especially with updates.
-
Hint: its website is http://nsis.sourceforge.net/ (http://nsis.sourceforge.net/) Yup, it's free software.
Speaking of "free as in freedom" software, here's the NSIS source:
!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
-
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.
-
I was thinking of having a separate executable which would try to fetch a new version installed as part of the package, although maybe re-running the installer might be better concerning code duplication. It is definitely possible to have the installer provide an option to update a current installation.
Actually, thinking about it, it might be even better to turn the uninstaller into one of those modify/remove things and provide an option to update. This way you wouldn't have to keep the original installer, just the installed package. Seems pretty counter-intuitive though.
-
I seemed to have missed this post
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.
I don't include a saved .sim, just some .set files. I don't think the program supports automatically starting settings files.
Hitting F1 and then start new started up a proper sim (this is what the program should do automatically in my mind).
I think it should prompt, in case your old .set happened to have some really long bots (*cough* Guardian *cough*) and you don't want it to take a really long time parsing the bots.
The mutation rates could do with some tweaking (way too high at present).
I think there's a bug with loading the option "Disable All Mutations". Mutation rates are loaded though.
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.
Loading the settings seems to work for me...
-
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.
I don't include a saved .sim, just some .set files. I don't think the program supports automatically starting settings files.
It used to, but I think it was sort of forgotten about once the lastexit.sim thing was set up. Eric'll have to look in to the code.
Hitting F1 and then start new started up a proper sim (this is what the program should do automatically in my mind).
I think it should prompt, in case your old .set happened to have some really long bots (*cough* Guardian *cough*) and you don't want it to take a really long time parsing the bots.
Yes, definately agree.
The mutation rates could do with some tweaking (way too high at present).
I think there's a bug with loading the option "Disable All Mutations". Mutation rates are loaded though.
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.
Loading the settings seems to work for me...
Eric'll need to look at these, too. I'll write up some proper bug reports if I have time.
-
This installer is a good idea it is much improved over the 2.1 installer which is ready for greener pastures. I suggest a few changes to the setting for animal minimalis evolution. Number one the field is set too big, animal minimalis is not well designed for such a field as big as the one set by default and most of the time it just sits around and gets boring. Number two is that you need to add costs or the whole simulation will grind to a halt with population bloat. While this isn't that hard for someone who has ran sims before, it may become a problem for the beginners who I would expect to use this setting. All around I think the installer is quite good.
I believe I encountered the same bug as numsgil with the settings reverting to the previous settings I'm not sure how that will effect the validity of my suggestions.
-
New installer for 2.43.1m. Nothing new really.
Note: Doesn't automatically uninstall a previous version, so either uninstall first or install over the previous version.
[attachment=991:Darwin_setup.exe]
-
He, the installer doesn't seem to work well on school-computers, I can't register anything.
Probably I need admin-rights.
-
Maybe we should set up a DB "install" that has everything in a single folder so you can dump it on a thumbstick
-
Yep, you need admin rights because the installer needs into install a bunch of DLLs and register them.
About installing in a folder... seems like a good idea except that I don't know if VB will allow that.