Skip to content

Commit

Permalink
add dist/
Browse files Browse the repository at this point in the history
  • Loading branch information
cryham committed Dec 3, 2023
1 parent 4b4c0d8 commit 632474f
Show file tree
Hide file tree
Showing 2 changed files with 211 additions and 0 deletions.
158 changes: 158 additions & 0 deletions dist/installer.nsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@

; the path where to whole game binaries with data
; CHANGE to yours when starting script
!define BINARY_DIR "d:\_\sr\SR3_inst\sr"
; also change Release Version
!define PRODUCT_VERSION "3.0"

; redist path should contain both VC_redist.x86.exe and VC_redist.x64.exe
; got from https://learn.microsoft.com/en-GB/cpp/windows/latest-supported-vc-redist?view=msvc-170#visual-studio-2015-2017-2019-and-2022
;
; DirectX files: DSETUP.dll, dsetup32.dll, DXSETUP.exe, dxupdate.cab
; and (depending on which DX SDK was used when compiling OGRE)
; Jun2010_D3DCompiler_43_x86.cab, Jun2010_d3dx*_43_x86.cab
; both _x64 too?
!define REDIST_DIR "d:\_\sr\SR3_inst\redist"


; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "Stunt Rally"
!define PRODUCT_PUBLISHER "Crystal Hammer"
!define PRODUCT_WEB_SITE "https://stuntrally.tuxfamily.org/"
!define PRODUCT_DONATIONS "https://cryham.tuxfamily.org/donate/"
!define PRODUCT_DOCS "https://github.com/stuntrally/stuntrally3/blob/main/docs/_menu.md"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\StuntRally.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define INST_SR_DIR "${PRODUCT_NAME} ${PRODUCT_VERSION}"

SetCompressor lzma

; MUI 1.67 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-blue.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall-blue.ico"

; Language Selection Dialog Settings
!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!insertmacro MUI_PAGE_LICENSE "${BINARY_DIR}\License.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES

; Finish page - wont start from anywhere, cant set start dir..
;!define MUI_FINISHPAGE_RUN "$INSTDIR\sr\bin\Release\StuntRally3.exe"
;!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\sr\R1eadme.md"
;!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Spanish"
!insertmacro MUI_LANGUAGE "Italian"
!insertmacro MUI_LANGUAGE "Finnish"
!insertmacro MUI_LANGUAGE "Russian"
!insertmacro MUI_LANGUAGE "PortugueseBR"
!insertmacro MUI_LANGUAGE "Polish"
!insertmacro MUI_LANGUAGE "Slovak"
!insertmacro MUI_LANGUAGE "Romanian"

; Reserve files
!insertmacro MUI_RESERVEFILE_LANGDLL
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "StuntRally-${PRODUCT_VERSION}-installer.exe"
InstallDir "$PROGRAMFILES\${INST_SR_DIR}"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show

Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd

Section "Redist" SEC01
SetOutPath "$INSTDIR\redist"
SetOverwrite try
File "${REDIST_DIR}\*.*"
DetailPrint "Updating DirectX this may take a few moments..."
ExecWait "$INSTDIR\redist\dxsetup.exe /silent"
DetailPrint "Installing VC redistributables..."
ExecWait "$INSTDIR\redist\VC_redist.x86.exe /install /quiet /norestart"
ExecWait "$INSTDIR\redist\VC_redist.x64.exe /install /quiet /norestart"
SectionEnd

Section "StuntRally" SEC02
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File /r "${BINARY_DIR}"
CreateDirectory "$SMPROGRAMS\${INST_SR_DIR}"
SetOutPath "$INSTDIR\sr\bin\Release"
CreateShortCut "$SMPROGRAMS\${INST_SR_DIR}\Stunt Rally 3.lnk" "$INSTDIR\sr\bin\Release\StuntRally3.exe"
CreateShortCut "$SMPROGRAMS\${INST_SR_DIR}\SR3 Track Editor.lnk" "$INSTDIR\sr\bin\Release\SR-Editor3.exe"
;CreateShortCut "$DESKTOP\Stunt Rally 3.lnk" "$INSTDIR\sr\bin\Release\StuntRally3.exe"
SectionEnd

Section -AdditionalIcons
SetOutPath $INSTDIR
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
WriteIniStr "$INSTDIR\Documentation.url" "InternetShortcut" "URL" "${PRODUCT_DOCS}"
WriteIniStr "$INSTDIR\Donations.url" "InternetShortcut" "URL" "${PRODUCT_DONATIONS}"
CreateShortCut "$SMPROGRAMS\${INST_SR_DIR}\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\${INST_SR_DIR}\Documentation.lnk" "$INSTDIR\Documentation.url"
CreateShortCut "$SMPROGRAMS\${INST_SR_DIR}\Donations.lnk" "$INSTDIR\Donations.url"
CreateShortCut "$SMPROGRAMS\${INST_SR_DIR}\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\StuntRally.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\sr\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\sr\StuntRally.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd


Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) has been succesfully removed."
FunctionEnd

Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Do you want to remove $(^Name) ?" IDYES +2
Abort
FunctionEnd

Section Uninstall
Delete "$SMPROGRAMS\${INST_SR_DIR}\*.lnk"
RMDir "$SMPROGRAMS\${INST_SR_DIR}"
;Delete "$DESKTOP\Stunt Rally.lnk"

RMDir /r "$INSTDIR\*.*"
RMDir "$INSTDIR"

DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
SectionEnd
53 changes: 53 additions & 0 deletions dist/make_roadstats_xml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/python3
#!/usr/bin/env python3
from xml.dom.minidom import parseString
import os
import re

def get_dirs(dir):
return [name for name in os.listdir(dir) if os.path.isdir(os.path.join(dir, name))]

pre = '..'; # path
tdir = pre+'/data/tracks'
trks = get_dirs(tdir)
#print(trks)

stats = open('roadstats.xml','w') # out file
stats.write('<roadstats>\n')

map = {'': 0} # result map
r = re.compile('[ ,:=\n]+')

times = open(pre+'/config/tracks.ini','r') # path
for line in times:
if len(line) > 0 and line[0] >= '0' and line[0] <= '9':
tr = r.split(line)
trk = tr[1]
#print(tr)
tim = tr[20]
map[trk] = tim
print(trk + " " + tim)
times.close()

i = 0;
for t in trks:
if t.find('-') != -1:
# get road stats
#print(t)
file = open(tdir+'/'+t+'/road.xml','r')
data = file.read()
file.close()

dom = parseString(data)
xTag = dom.getElementsByTagName('stats')[0].toxml()
#print(xTag)
xNew = xTag.replace('<stats','<s n="'+t+'" t="'+map.get(t,'0')+'"').replace('yaw="0"','').replace('pitch="0" ','').replace('roll="0" ','')
xNew = xNew.replace('height=','h=').replace('length=','l=').replace('width=','w=').replace('bnkAvg=','ba=').replace('bnkMax=','bm=')
xNew = xNew.replace('onPipe=','op=').replace('onTer=','ot=').replace('pipes=','p=')
#print(xNew)
i += 1
stats.write(xNew+'\n')

stats.write('</roadstats>')
stats.close()
print('All: '+str(i))

0 comments on commit 632474f

Please sign in to comment.