Author Topic: [FF7PC] NSIS Installer Script Template (2011-04-12)  (Read 17369 times)

pyrozen

  • *
  • Posts: 791
  • Team Avalanche Member
    • View Profile

I created this a while back for TA release, but have decided that it may be helpful to other on Qhimm. It is an NSIS script that creates a spiffy installer for you after you declare a few different things. If you are inexperienced with NSIS scripting, this might be an easy way to ease into it, because I have done all of the difficult coding for you already. All you have to do is place your fies in the same directory, then declare them in the script and compile! It's a bit more involved than that, but i have fully commented the entire script, so nothing is difficult to locate. I would suggest using Notepad++ for ease of viewing. If you dont have NSIS experience i would recommend reading about it on the NSIS website, as well as the UltraModernUI website, since i will only provide basic support here.

First you will need to download NSIS and UltraModernUI:
Download

Full Documentation:
NSIS webpage
UltraModernUI webpage

Do a full installation. Without this package you cannot compile this script. There is also a fair chance that this may not compile the same on your computer as mine, I have never tried to transfer a raw NSIS script, but I am pretty sure everything is worked out.

Included in the installer:
=AutoFind FF7 directory (windows only)
=Aali Driver Check
=Spiffy Music
=Background graphics
=Spiffy ending fanfare

All of these elements are changable with the right knowledge. Most elements don't need to be changed, only things such as installer name, folder names, and a few text fields. Everything has been labeled in the script, so any important function will have its use listed next to it. There is also an example installer in the ZIP file so you can try it out before you decide if you want to use it.

Download Template


If you have any problems let me know, if they are graphical in nature, provide a picture. I ask you provide credit for me somewhere, but its not a big deal.

have fun!
lee
« Last Edit: 2014-07-18 18:29:59 by Covarr »

sl1982

  • Administrator
  • *
  • Posts: 3764
  • GUI Master :P
    • View Profile
Re: NSIS Installer Script
« Reply #1 on: 2011-04-13 01:39:53 »
*cough* credit *cough*

Vgr

  • Global moderator
  • *
  • Posts: 2163
  • If it quacks like a duck, it must be a duck
    • View Profile
Re: NSIS Installer Script
« Reply #2 on: 2011-04-13 01:41:40 »
*cough* credit *cough*

This... yeah, is awesome.

sithlord48

  • *
  • Posts: 1632
  • Dark Lord of the Savegame
    • View Profile
    • Blackchocobo
Re: NSIS Installer Script
« Reply #3 on: 2011-04-13 02:17:09 »
Sweet. gotta love Nsis.its my personal favorate install system for windows.

Quote
=AutoFind FF7 directory (windows only)
basicly as long as your doing something like this:
Code: [Select]
Section "Find FF7"
   ${If} ${RunningX64}
      ReadRegStr $1 HKLM "SOFTWARE\Wow6432Node\Square Soft, Inc.\Final Fantasy VII\" AppPath     
   ${Else}
      ReadRegStr $1 HKLM "SOFTWARE\Square Soft, Inc.\Final Fantasy VII\" AppPath     
   ${EndIf}
SectionEnd
then your path detection should work just fine in any version of windows or in wine.

yarLson

  • *
  • Posts: 708
  • spr nrd
    • View Profile
Re: NSIS Installer Script
« Reply #4 on: 2011-04-13 02:21:37 »
this is great, maybe now even I can make an installer :D

BloodShot

  • *
  • Posts: 687
    • View Profile
Re: NSIS Installer Script
« Reply #5 on: 2011-04-13 02:23:01 »
Wow, that's pretty bad ass. Maybe I'll make an Installer for my old bike mod.

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: NSIS Installer Script
« Reply #6 on: 2011-04-13 02:46:56 »
inno = Class.
« Last Edit: 2011-07-24 21:47:41 by DLPB »

pyrozen

  • *
  • Posts: 791
  • Team Avalanche Member
    • View Profile
Re: NSIS Installer Script
« Reply #7 on: 2011-04-13 03:28:14 »
Wow, that's pretty bad ass. Maybe I'll make an Installer for my old bike mod.
it'll move files around, but open/closing the LGPs is something that SL is much more familiar with. He helped me get going on this initially by providing me with the original TA installer script. It contains provisions for altering the LGPs, and ATM this script is more for the PNG based mods, though i am sure LGP functionality could easily be added *nudges SL. It would become more difficult to manage for an inexperienced user though.

Covarr

  • Covarr-Let
  • Administrator
  • *
  • Posts: 3941
  • Just Covarr. No "n".
    • View Profile
Re: NSIS Installer Script
« Reply #8 on: 2011-04-13 03:37:57 »
I already figured most of this out on my own (by which I mean with sl's help), but I will give this a look to see how you did the background graphics and music.

sl1982

  • Administrator
  • *
  • Posts: 3764
  • GUI Master :P
    • View Profile
Re: NSIS Installer Script
« Reply #9 on: 2011-04-13 05:04:46 »
Ugh, yeah it can be done. I dont have the original installer script handy right now though.

yarLson

  • *
  • Posts: 708
  • spr nrd
    • View Profile
Re: NSIS Installer Script
« Reply #10 on: 2011-04-13 06:58:33 »
just made a test installer to make sure I understand everything and its working great, at least for pngs! This will make distributing my project a lot easier. Thank you :D

pyrozen

  • *
  • Posts: 791
  • Team Avalanche Member
    • View Profile
Re: NSIS Installer Script
« Reply #11 on: 2011-04-14 04:13:27 »
I already figured most of this out on my own (by which I mean with sl's help), but I will give this a look to see how you did the background graphics and music.
background and graphics are easily done by using the UltraModernUI. The music and finished sound were a bit trickier to get working properly, and making sure they ended up in the TEMP directory so they are deleted later on. Outside of that, its a fairly straight forward script, and anyone with NSIS experience won't be wow'd by it, but its a good starting point for people who have never used it before.

I encourage anyone to modify it and add functionality, I have already revised the initial script a bit, so a few updates are sure to materialize over time. If anyone has any suggestions please post up the code.

lee

sl1982

  • Administrator
  • *
  • Posts: 3764
  • GUI Master :P
    • View Profile
Re: NSIS Installer Script
« Reply #12 on: 2011-04-14 04:28:21 »
Code to unlgp an lgp:

Code: [Select]
nsExec::ExecToLog /OEM '"$INSTDIR\unlgp.exe" "$INSTDIR\Backup Files\battle.lgp" "$INSTDIR\Temp\"'

Code: [Select]
nsExec::ExecToLog /OEM '"$INSTDIR\lgp.exe" "$INSTDIR\Temp" "$INSTDIR\data\battle\battle.lgp"'

Be careful with the quotes, removing one or using a different one instead as it will not work. Replace directories as needed.

pyrozen

  • *
  • Posts: 791
  • Team Avalanche Member
    • View Profile
Re: NSIS Installer Script
« Reply #13 on: 2011-04-14 09:54:24 »
Code to unlgp an lgp:

Code: [Select]
nsExec::ExecToLog /OEM '"$INSTDIR\unlgp.exe" "$INSTDIR\Backup Files\battle.lgp" "$INSTDIR\Temp\"'

Code: [Select]
nsExec::ExecToLog /OEM '"$INSTDIR\lgp.exe" "$INSTDIR\Temp" "$INSTDIR\data\battle\battle.lgp"'

Be careful with the quotes, removing one or using a different one instead as it will not work. Replace directories as needed.

very nice, i'll definitely make sure that gets in there

StrayOff

  • Guest
Re: NSIS Installer Script
« Reply #14 on: 2011-07-23 14:13:34 »
i found a little tool called reg2nsis and generated the registry-values of ff7 for my personal use. but for any purpose of making some nice mods and creating nsis installer - here's the code:

Quote
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc." "" ""
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII" "DataDrive" "M:\"
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII" "AppPath" "$INSTDIR\"
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII" "DataPath" "$INSTDIR\Data\"
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII" "MoviePath" "$INSTDIR\movies\"
WriteRegDWORD HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII" "DiskNo" 0x0
WriteRegDWORD HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII" "FullInstall" 0x1
WriteRegBin HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII" "SSI_DEBUG" 53484f574d455448454150504c4f4700
WriteRegDWORD HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII" "DiscNo" 0x1
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII\1.00" "" ""
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII\1.00\Graphics" "DriverPath" "ff7_opengl.fgd"
WriteRegDWORD HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII\1.00\Graphics" "Driver" 0x3
WriteRegDWORD HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII\1.00\Graphics" "Mode" 0x2
WriteRegBin HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII\1.00\Graphics" "DD_GUID" 00000000000000000000000000000000
WriteRegDWORD HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII\1.00\Graphics" "Options" 0x12
WriteRegDWORD HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII\1.00\MIDI" "MIDI_DeviceID" 0x0
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII\1.00\MIDI" "MIDI_data" "GENERAL_MIDI"
WriteRegDWORD HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII\1.00\MIDI" "MusicVolume" 0x64
WriteRegDWORD HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII\1.00\MIDI" "Options" 0x1
WriteRegBin HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII\1.00\Sound" "Sound_GUID" 640316afafc34b40b88077dc5685fe91
WriteRegDWORD HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII\1.00\Sound" "Options" 0x0
WriteRegDWORD HKEY_LOCAL_MACHINE "SOFTWARE\Square Soft, Inc.\Final Fantasy VII\1.00\Sound" "SFXVolume" 0x64

you have to put this in a section

and if you like to create some shortcuts, you can use for example:

Quote
CreateDirectory "$SMPROGRAMS\Final Fantasy 7"
 CreateShortCut "$SMPROGRAMS\Final Fantasy 7\Final Fantasy 7 [Englisch - Hardcore].lnk" "$INSTDIR\FF7.bat" "" "$INSTDIR\ff7.ico"
 CreateShortCut "$SMPROGRAMS\Final Fantasy 7\Final Fantasy 7 [Deutsch - Normal].lnk" "$INSTDIR\FF7ger.bat" "" "$INSTDIR\ff7.ico"
 CreateShortCut "$DESKTOP\Final Fantasy 7 [Englisch - Hardcore].lnk" "$INSTDIR\FF7.bat" "" "$INSTDIR\ff7.ico"
 CreateShortCut "$DESKTOP\Final Fantasy 7 [Deutsch - Normal].lnk" "$INSTDIR\FF7ger.bat" "" "$INSTDIR\ff7.ico"

post this in section too
« Last Edit: 2011-07-23 14:15:31 by StrayOff »

StrayOff

  • Guest
Re: NSIS Installer Script
« Reply #15 on: 2011-07-25 10:22:11 »
hey

i just performed a little ff7_opengl.cfg tweak. i wrote a bat which automatically changes the window_size in config to the given display size. maybe you can use this code to do other straight things changing in textfiles. there is also the possibility to convert the batch to exe with a simple tool called "BatToExe".

graphics.bat looks like that:
Quote
@echo off & setlocal enabledelayedexpansion

wmic desktopmonitor get screenwidth > ff7winx.tx
wmic desktopmonitor get screenheight > ff7winy.tx

more +1 ff7winx.tx > ff7winx2.tx
more +1 ff7winy.tx > ff7winy2.tx

for /f "delims=;" %%i in (ff7winx2.tx) do @set winxsiz=%%i
for /f "delims=;" %%j in (ff7winy2.tx) do @set winysiz=%%j

del ff7winx.tx
del ff7winy.tx
del ff7winx2.tx
del ff7winy2.tx

set winxout= "window_size_x = %winxsiz%"
set winyout= "window_size_y = %winysiz%"


%windir%\system32\cmd.exe /C "START /WAIT CScript //NoLogo ff7winx.vbs ff7_opengl.cfg ff7_opengl.cfg_temp %winxout%"
del ff7_opengl.cfg
ren ff7_opengl.cfg_temp ff7_opengl.cfg

%windir%\system32\cmd.exe /C "START /WAIT CScript //NoLogo ff7winy.vbs ff7_opengl.cfg ff7_opengl.cfg_temp %winyout%"
del ff7_opengl.cfg
ren ff7_opengl.cfg_temp ff7_opengl.cfg

the *.vbs look like this:

Quote
Const ForReading = 1
Const ForWriting = 2

Set fso = CreateObject("Scripting.FileSystemObject")
Set objRE01 = CreateObject("VBScript.RegExp")
objRE01.Global     = True
objRE01.IgnoreCase = True
InputFile = WScript.Arguments(0)
OutoutFile = WScript.Arguments(1)

repl = WScript.Arguments(2)

Set inFile = fso.OpenTextFile(InputFile, ForReading)
Set outFile = fso.OpenTextFile(OutoutFile, ForWriting, True)
Do Until inFile.AtEndOfStream
   strLine = inFile.ReadLine
   Set colMatches01 = objRE01.Execute(strLine)
       If colMatches01.Count > 0 Then 
      objRE01.Pattern = ".*window_size_x.*"   
      strLine = objRE01.Replace(strLine, repl)
      End If
   outFile.WriteLine strLine
Loop



you can use this things to create once some specific settings for the installing process of your mod.
just ask me if you have problems with getting smart with this code