Skip to content

Commit

Permalink
Last Commits of the Night
Browse files Browse the repository at this point in the history
  • Loading branch information
CarJem committed Feb 18, 2020
1 parent 2f93dd8 commit 74d0196
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
; Headers

!include "MUI2.nsh"
!include "LogicLib.nsh"
!include "FileFunc.nsh"

;--------------------------------
; Defintions
Expand All @@ -24,18 +22,12 @@
!define INSTALLER_DEST_FILE "Setup.exe"
!define INSTALLER_DEST_DIR "D:\Users\CarJem\source\rsdk_repos\ManiacEditor-GenerationsEdition\Installer"
!define INSTALLER_DEST "${INSTALLER_DEST_DIR}\${INSTALLER_DEST_FILE}"
!define DEFAULT_NORMAL_DESTINATON "$PROGRAMFILES\${INSTALL_DIR_NAME}"
!define DEFAULT_PORTABLE_DESTINATON "$EXEPATH\${INSTALL_DIR_NAME}"
!define INSTALL_DIR_NAME "ManiacEditor"
!define MAIN_APP_EXE "ManiacEditor.exe"
!define MAKE_DIRECTORY "D:\Users\CarJem\source\rsdk_repos\ManiacEditor-GenerationsEdition\ManiacEditor\bin\Release\*.*"
!define STARTMENU_DIR_NAME "ManiacEditor"
!define APPDATA_DIRECTORY "ManiacEditor"

Var NormalDestDir
Var PortableDestDir
Var PortableMode

; Section Descriptors

!define DESC_Section1 "Maniac Editor's Core and Essential Files"
Expand Down Expand Up @@ -78,7 +70,8 @@ InstallDir "$PROGRAMFILES\${INSTALL_DIR_NAME}"
; Installer Pages ;---------

!insertmacro MUI_PAGE_WELCOME
Page Custom PortableModePageCreate PortableModePageLeave

!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY

!ifdef REG_START_MENU
Expand All @@ -94,18 +87,13 @@ Page Custom PortableModePageCreate PortableModePageLeave
!define MUI_FINISHPAGE_RUN "$INSTDIR\${MAIN_APP_EXE}"
!insertmacro MUI_PAGE_FINISH

;---------


; Uninstaller Pages ;---------

!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_COMPONENTS
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH

;---------

;--------------------------------
; Languages

Expand All @@ -117,41 +105,68 @@ Page Custom PortableModePageCreate PortableModePageLeave
Section "Essential Files" ESSENTIAL_FILES
SectionIn RO
SetOverwrite ifnewer
File /r "${MAKE_DIRECTORY}"
SetOutPath "$INSTDIR"
File /r "${MAKE_DIRECTORY}"
SectionEnd

Section /o "Portable Install" PORTABLE_INSTALL
SectionIn 1

CreateDirectory "$INSTDIR\Settings"
FileOpen $0 "$INSTDIR\Settings\internal_switches.json" w
FileWrite $0 "{$\"PortableMode$\":true}"
FileClose $0

${If} $PortableMode = 0
WriteUninstaller "$INSTDIR\uninstall.exe"
CreateDirectory "$SMPROGRAMS\${STARTMENU_DIR_NAME}"
CreateShortCut "$SMPROGRAMS\${STARTMENU_DIR_NAME}\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
CreateShortCut "$SMPROGRAMS\${STARTMENU_DIR_NAME}\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
${Else}
CreateDirectory "$INSTDIR\Settings"
FileOpen $0 "$INSTDIR\Settings\internal_switches.json" w
FileWrite $0 "{$\"PortableMode$\":true}"
FileClose $0
${EndIf}
SectionEnd

Section "Standard Install" STANDARD_INSTALL
SectionIn 2
WriteUninstaller "$INSTDIR\uninstall.exe"
CreateDirectory "$SMPROGRAMS\${STARTMENU_DIR_NAME}"
CreateShortCut "$SMPROGRAMS\${STARTMENU_DIR_NAME}\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
CreateShortCut "$SMPROGRAMS\${STARTMENU_DIR_NAME}\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
SectionEnd


Function .onInit
StrCpy $1 ${STANDARD_INSTALL}
FunctionEnd

Function .onSelChange
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${PORTABLE_INSTALL}
!insertmacro RadioButton ${STANDARD_INSTALL}
!insertmacro EndRadioButtons
FunctionEnd

;--------------------------------
; Uninstall Section

Section "Un.Essential Files" UN_ESSENTIAL_FILES
SectionIn RO

RmDir /r "$INSTDIR"

SectionEnd

Section /o "Un.Application Data" UN_APP_DATA

RmDir /r "$APPDATA\${APPDATA_DIRECTORY}"

SectionEnd

Section "Un.Shortcuts and Uninstaller" UN_SHORTCUTS
SectionIn RO

Delete "$SMPROGRAMS\${STARTMENU_DIR_NAME}\${APP_NAME}.lnk"
Delete "$SMPROGRAMS\${STARTMENU_DIR_NAME}\Uninstall ${APP_NAME}.lnk"
Delete "$DESKTOP\${APP_NAME}.lnk"
RmDir "$SMPROGRAMS\${STARTMENU_DIR_NAME}"

DeleteRegKey ${REG_ROOT} "${REG_APP_PATH}"
DeleteRegKey ${REG_ROOT} "${UNINSTALL_PATH}"
RmDir /r "$INSTDIR"
SectionEnd

Section /o "Un.Application Data" UN_APP_DATA
RmDir /r "$APPDATA\${APPDATA_DIRECTORY}"
SectionEnd

;--------------------------------
Expand All @@ -169,45 +184,4 @@ SectionEnd
!insertmacro MUI_DESCRIPTION_TEXT ${UN_SHORTCUTS} "${DESC_Section5}"
!insertmacro MUI_UNFUNCTION_DESCRIPTION_END

;--------------------------------
; Portable Mode Selection Page

Function SetModeDestinationFromInstdir
${If} $PortableMode = 0
StrCpy $NormalDestDir $InstDir
${Else}
StrCpy $PortableDestDir $InstDir
${EndIf}
FunctionEnd

Function PortableModePageCreate
Call SetModeDestinationFromInstdir ; If the user clicks BACK on the directory page we will remember their mode specific directory
!insertmacro MUI_HEADER_TEXT "Install Mode" "Choose how you want to install ${APP_NAME}."
nsDialogs::Create 1018
Pop $0
${NSD_CreateLabel} 0 10u 100% 24u "Select install mode:"
Pop $0
${NSD_CreateRadioButton} 30u 50u -30u 8u "Normal install"
Pop $1
${NSD_CreateRadioButton} 30u 70u -30u 8u "Portable"
Pop $2
${If} $PortableMode = 0
SendMessage $1 ${BM_SETCHECK} ${BST_CHECKED} 0
${Else}
SendMessage $2 ${BM_SETCHECK} ${BST_CHECKED} 0
${EndIf}
nsDialogs::Show
FunctionEnd

Function PortableModePageLeave
${NSD_GetState} $1 $0
${If} $0 <> ${BST_UNCHECKED}
StrCpy $PortableMode 0
StrCpy $InstDir $NormalDestDir
${Else}
StrCpy $PortableMode 1
StrCpy $InstDir $PortableDestDir
${EndIf}
FunctionEnd

;--------------------------------
115 changes: 71 additions & 44 deletions Installer/ManiacEditor-GenerationsEdition.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
; Headers

!include "MUI2.nsh"
!include "LogicLib.nsh"
!include "FileFunc.nsh"

;--------------------------------
; Defintions
Expand All @@ -22,12 +24,18 @@
!define INSTALLER_DEST_FILE "Setup.exe"
!define INSTALLER_DEST_DIR "D:\Users\CarJem\source\rsdk_repos\ManiacEditor-GenerationsEdition\Installer"
!define INSTALLER_DEST "${INSTALLER_DEST_DIR}\${INSTALLER_DEST_FILE}"
!define DEFAULT_NORMAL_DESTINATON "$PROGRAMFILES\${INSTALL_DIR_NAME}"
!define DEFAULT_PORTABLE_DESTINATON "$EXEPATH\${INSTALL_DIR_NAME}"
!define INSTALL_DIR_NAME "ManiacEditor"
!define MAIN_APP_EXE "ManiacEditor.exe"
!define MAKE_DIRECTORY "D:\Users\CarJem\source\rsdk_repos\ManiacEditor-GenerationsEdition\ManiacEditor\bin\Release\*.*"
!define STARTMENU_DIR_NAME "ManiacEditor"
!define APPDATA_DIRECTORY "ManiacEditor"

Var NormalDestDir
Var PortableDestDir
Var PortableMode

; Section Descriptors

!define DESC_Section1 "Maniac Editor's Core and Essential Files"
Expand Down Expand Up @@ -70,8 +78,7 @@ InstallDir "$PROGRAMFILES\${INSTALL_DIR_NAME}"
; Installer Pages ;---------

!insertmacro MUI_PAGE_WELCOME

!insertmacro MUI_PAGE_COMPONENTS
Page Custom PortableModePageCreate PortableModePageLeave
!insertmacro MUI_PAGE_DIRECTORY

!ifdef REG_START_MENU
Expand All @@ -87,13 +94,18 @@ InstallDir "$PROGRAMFILES\${INSTALL_DIR_NAME}"
!define MUI_FINISHPAGE_RUN "$INSTDIR\${MAIN_APP_EXE}"
!insertmacro MUI_PAGE_FINISH

;---------


; Uninstaller Pages ;---------

!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_COMPONENTS
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH

;---------

;--------------------------------
; Languages

Expand All @@ -107,66 +119,40 @@ SectionIn RO
SetOverwrite ifnewer
SetOutPath "$INSTDIR"
File /r "${MAKE_DIRECTORY}"
SectionEnd

Section /o "Portable Install" PORTABLE_INSTALL
SectionIn 1

CreateDirectory "$INSTDIR\Settings"
FileOpen $0 "$INSTDIR\Settings\internal_switches.json" w
FileWrite $0 "{$\"PortableMode$\":true}"
FileClose $0

SectionEnd
${If} $PortableMode = 0
WriteUninstaller "$INSTDIR\uninstall.exe"
CreateDirectory "$SMPROGRAMS\${STARTMENU_DIR_NAME}"
CreateShortCut "$SMPROGRAMS\${STARTMENU_DIR_NAME}\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
CreateShortCut "$SMPROGRAMS\${STARTMENU_DIR_NAME}\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
${Else}
CreateDirectory "$INSTDIR\Settings"
FileOpen $0 "$INSTDIR\Settings\internal_switches.json" w
FileWrite $0 "{$\"PortableMode$\":true}"
FileClose $0
${EndIf}

Section "Standard Install" STANDARD_INSTALL
SectionIn 2
WriteUninstaller "$INSTDIR\uninstall.exe"
CreateDirectory "$SMPROGRAMS\${STARTMENU_DIR_NAME}"
CreateShortCut "$SMPROGRAMS\${STARTMENU_DIR_NAME}\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
CreateShortCut "$SMPROGRAMS\${STARTMENU_DIR_NAME}\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
SectionEnd


Function .onInit
StrCpy $1 ${STANDARD_INSTALL}
FunctionEnd

Function .onSelChange
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${PORTABLE_INSTALL}
!insertmacro RadioButton ${STANDARD_INSTALL}
!insertmacro EndRadioButtons
FunctionEnd

;--------------------------------
; Uninstall Section

Section "Un.Essential Files" UN_ESSENTIAL_FILES
SectionIn RO

RmDir /r "$INSTDIR"

SectionEnd

Section /o "Un.Application Data" UN_APP_DATA

RmDir /r "$APPDATA\${APPDATA_DIRECTORY}"

SectionEnd

Section "Un.Shortcuts and Uninstaller" UN_SHORTCUTS
SectionIn RO

Delete "$SMPROGRAMS\${STARTMENU_DIR_NAME}\${APP_NAME}.lnk"
Delete "$SMPROGRAMS\${STARTMENU_DIR_NAME}\Uninstall ${APP_NAME}.lnk"
Delete "$DESKTOP\${APP_NAME}.lnk"
RmDir "$SMPROGRAMS\${STARTMENU_DIR_NAME}"

DeleteRegKey ${REG_ROOT} "${REG_APP_PATH}"
DeleteRegKey ${REG_ROOT} "${UNINSTALL_PATH}"
RmDir /r "$INSTDIR"
SectionEnd

Section /o "Un.Application Data" UN_APP_DATA
RmDir /r "$APPDATA\${APPDATA_DIRECTORY}"
SectionEnd

;--------------------------------
Expand All @@ -184,4 +170,45 @@ SectionEnd
!insertmacro MUI_DESCRIPTION_TEXT ${UN_SHORTCUTS} "${DESC_Section5}"
!insertmacro MUI_UNFUNCTION_DESCRIPTION_END

;--------------------------------
; Portable Mode Selection Page

Function SetModeDestinationFromInstdir
${If} $PortableMode = 0
StrCpy $NormalDestDir $InstDir
${Else}
StrCpy $PortableDestDir $InstDir
${EndIf}
FunctionEnd

Function PortableModePageCreate
Call SetModeDestinationFromInstdir ; If the user clicks BACK on the directory page we will remember their mode specific directory
!insertmacro MUI_HEADER_TEXT "Install Mode" "Choose how you want to install ${APP_NAME}."
nsDialogs::Create 1018
Pop $0
${NSD_CreateLabel} 0 10u 100% 24u "Select install mode:"
Pop $0
${NSD_CreateRadioButton} 30u 50u -30u 8u "Normal install"
Pop $1
${NSD_CreateRadioButton} 30u 70u -30u 8u "Portable"
Pop $2
${If} $PortableMode = 0
SendMessage $1 ${BM_SETCHECK} ${BST_CHECKED} 0
${Else}
SendMessage $2 ${BM_SETCHECK} ${BST_CHECKED} 0
${EndIf}
nsDialogs::Show
FunctionEnd

Function PortableModePageLeave
${NSD_GetState} $1 $0
${If} $0 <> ${BST_UNCHECKED}
StrCpy $PortableMode 0
StrCpy $InstDir $NormalDestDir
${Else}
StrCpy $PortableMode 1
StrCpy $InstDir $PortableDestDir
${EndIf}
FunctionEnd

;--------------------------------
6 changes: 3 additions & 3 deletions ManiacEditor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("20.02.16.0")]
[assembly: AssemblyVersion("20.02.16.0")]
[assembly: AssemblyFileVersion("20.02.16.0")]
// [assembly: AssemblyVersion("20.02.17.5")]
[assembly: AssemblyVersion("20.02.17.5")]
[assembly: AssemblyFileVersion("20.02.17.5")]
4 changes: 2 additions & 2 deletions ManiacEditor/Properties/Versioning/build_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"BuildNumber": 0
},
{
"LastBuilt": "2020-02-16T00:00:00-05:00",
"LastBuilt": "2020-02-17T00:00:00-05:00",
"Identifier": "Maniac Editor",
"BuildNumber": 0
"BuildNumber": 5
}
]
}

0 comments on commit 74d0196

Please sign in to comment.