blob: 2e61f7b691c77927a64df32346b22f1a345f2711 [file] [log] [blame]
; =========================================================
; This file was generated by NSISDialogDesigner 1.3.0.0
; http://coolsoft.altervista.org/nsisdialogdesigner
;
; Do not edit it manually, use NSISDialogDesigner instead!
; =========================================================
; handle variables
Var hCtl_HaxmPage
Var hCtl_HaxmPage_LabelWarning
Var hCtl_HaxmPage_ListUnits
Var hCtl_HaxmPage_NumberCustom
Var hCtl_HaxmPage_LabelRecommended
Var hCtl_HaxmPage_LabelBounds
Var hCtl_HaxmPage_RadioCustom
Var hCtl_HaxmPage_RadioRecommended
Var hCtl_HaxmPage_LabelAboutHaxmEnd
Var hCtl_HaxmPage_LinkAboutHaxm
Var hCtl_HaxmPage_LabelAboutHaxmStart
Var hCtl_HaxmPage_LabelHeader
; HeaderCustomScript
Var var_HaxmPage_MinMB
Var var_HaxmPage_MaxMB
Var var_HaxmPage_RecommendedMB
Var var_HaxmPage_SelectedMB
Var var_HaxmPage_MinStr
Var var_HaxmPage_MaxStr
Var var_HaxmPage_RecommendedStr
!define HAXM_LINK "http://www.intel.com/software/android/"
!define 4GB 4096
!define 2GB 2048
!define 1GB 1024
!define STR_RANGE "* This value must be between $var_HaxmPage_MinStr and $var_HaxmPage_MaxStr"
!define STR_RECOMMENDED "$var_HaxmPage_RecommendedStr"
; dialog create function
Function fnc_HaxmPage_Create
; === HaxmPage (type: Dialog) ===
nsDialogs::Create 1018
Pop $hCtl_HaxmPage
${If} $hCtl_HaxmPage == error
Abort
${EndIf}
!insertmacro MUI_HEADER_TEXT "Configuration Settings" "Emulator Setup"
; === LabelWarning (type: Label) ===
${NSD_CreateLabel} 0u 123.08u 296.2u 16.62u "Note: Setting aside a large memory reservation may cause other programs to run slowly when using the x86 Android emulator with HAXM."
Pop $hCtl_HaxmPage_LabelWarning
; === ListUnits (type: DropList) ===
${NSD_CreateDropList} 117.82u 91.08u 32.91u 12.92u "GB"
Pop $hCtl_HaxmPage_ListUnits
EnableWindow $hCtl_HaxmPage_ListUnits 0
${NSD_CB_AddString} $hCtl_HaxmPage_ListUnits "GB"
${NSD_CB_AddString} $hCtl_HaxmPage_ListUnits "MB"
${NSD_CB_SelectString} $hCtl_HaxmPage_ListUnits "GB"
; === NumberCustom (type: Number) ===
${NSD_CreateNumber} 72.41u 91.69u 41.47u 12.31u ""
Pop $hCtl_HaxmPage_NumberCustom
EnableWindow $hCtl_HaxmPage_NumberCustom 0
; === LabelRecommended (type: Label) ===
${NSD_CreateLabel} 72.41u 81.85u 65.82u 9.23u "2 GB"
Pop $hCtl_HaxmPage_LabelRecommended
; === LabelBounds (type: Label) ===
${NSD_CreateLabel} 72.41u 105.85u 184.3u 11.08u "* This value must be between 512MB and 32GB. "
Pop $hCtl_HaxmPage_LabelBounds
; === RadioCustom (type: RadioButton) ===
${NSD_CreateRadioButton} 0u 92.92u 68.46u 9.23u "Custom:"
Pop $hCtl_HaxmPage_RadioCustom
${NSD_AddStyle} $hCtl_HaxmPage_RadioCustom ${WS_GROUP}
${NSD_OnClick} $hCtl_HaxmPage_RadioCustom fnc_HaxmPage_RadioChanged
; === RadioRecommended (type: RadioButton) ===
${NSD_CreateRadioButton} 0u 81.23u 68.46u 9.23u "Recommended:"
Pop $hCtl_HaxmPage_RadioRecommended
${NSD_OnClick} $hCtl_HaxmPage_RadioRecommended fnc_HaxmPage_RadioChanged
${NSD_Check} $hCtl_HaxmPage_RadioRecommended
; === LabelAboutHaxmEnd (type: Label) ===
${NSD_CreateLabel} 0u 57.23u 89.52u 12.31u "for more information."
Pop $hCtl_HaxmPage_LabelAboutHaxmEnd
; === LinkAboutHaxm (type: Link) ===
${NSD_CreateLink} 202.08u 48.62u 92.81u 12.31u "Intel HAXM Documentation"
Pop $hCtl_HaxmPage_LinkAboutHaxm
${NSD_OnClick} $hCtl_HaxmPage_LinkAboutHaxm fnc_HaxmPage_LinkAboutHaxm_OnClick
; === LabelAboutHaxmStart (type: Label) ===
${NSD_CreateLabel} 0u 48.62u 208u 10.46u "You can change these settings at any time. Please refer to the"
Pop $hCtl_HaxmPage_LabelAboutHaxmStart
; === LabelHeader (type: Label) ===
${NSD_CreateLabel} 0u 0u 296.2u 40u "We have detected that your system can run the Android emulator in an accelerated performance mode.$\r$\n$\r$\nPlease set the maximum amount of RAM available for the Intel Hardware Accelerated Manager (HAXM) to use for all x86 emulator instances."
Pop $hCtl_HaxmPage_LabelHeader
; CreateFunctionCustomScript
Call fnc_HaxmPage_InitializeControls
FunctionEnd
; dialog show function
Function fnc_HaxmPage_Show
Call fnc_HaxmPage_Create
nsDialogs::Show $hCtl_HaxmPage
FunctionEnd
; FooterCustomScript
Function fnc_HaxmPage_RadioChanged
# Store values
Push $0 # Check state
Push $1 # Enable boolean
${NSD_GetState} $hCtl_HaxmPage_RadioCustom $0
${If} $0 == ${BST_CHECKED}
StrCpy $1 1
${Else}
StrCpy $1 0
${EndIf}
EnableWindow $hCtl_HaxmPage_NumberCustom $1
EnableWindow $hCtl_HaxmPage_ListUnits $1
# Restore values
Pop $1
Pop $0
FunctionEnd
Function fnc_HaxmPage_LinkAboutHaxm_OnClick
ExecShell "open" ${HAXM_LINK}
FunctionEnd
# Initializes various HAXM page values based on the passed in system memory.
# Call this after pushing the amount of system memory (in MB) on the stack.
# It is assumed this method will not get called if the user has less than 1GB
# of memory!
Function fnc_HaxmPage_SetSystemMemory
Exch $0 # Save existing $0. Now set to amount of system memory in MB
Push $1 # Save existing $1. Used as a temp var later.
# Pseudo-code for the following logic:
# min = 512MB
# if (mem > 4GB) {
# max = mem - 2GB;
# default = 2GB;
# }
# else {
# max = mem / 2;
# default = (mem > 2GB) ? 1GB : 512MB;
# }
# Initialize memory bounds (max, max, recommended)
StrCpy $var_HaxmPage_MinMB 512
${If} $0 >= ${4GB}
IntOp $var_HaxmPage_MaxMB $0 - ${2GB}
StrCpy $var_HaxmPage_RecommendedMB ${2GB}
${Else}
IntOp $var_HaxmPage_MaxMB $0 / 2
${If} $var_HaxmPage_MaxMB >= ${2GB}
StrCpy $var_HaxmPage_RecommendedMB ${1GB}
${Else}
StrCpy $var_HaxmPage_RecommendedMB 512
${EndIf}
${EndIf}
# Max can be less than min only if a user's memory < 1GB, but really we
# should never be getting here ever. But it's easy enough to handle it
# here just in case.
${If} $var_HaxmPage_MaxMB < $var_HaxmPage_MinMB
StrCpy $var_HaxmPage_MaxMB $var_HaxmPage_MinMB
${EndIf}
# Update strings
StrCpy $var_HaxmPage_MinStr "$var_HaxmPage_MinMB MB"
${If} $var_HaxmPage_MaxMB >= ${1GB}
IntOp $0 $var_HaxmPage_MaxMB / ${1GB}
StrCpy $var_HaxmPage_MaxStr "$0 GB"
${Else}
StrCpy $var_HaxmPage_MaxStr "$var_HaxmPage_MaxMB MB"
${EndIf}
${If} $var_HaxmPage_RecommendedMB >= ${1GB}
IntOp $0 $var_HaxmPage_RecommendedMB / ${1GB}
StrCpy $var_HaxmPage_RecommendedStr "$0 GB"
${Else}
StrCpy $var_HaxmPage_RecommendedStr "$var_HaxmPage_RecommendedMB MB"
${EndIf}
# Update controls
# If we pressed back to come back to this page, var_HaxmPage_SelectedMB
# will already be set, and we should use that value.
# After this point, $0 will be the amount of memory to show for the Custom
# radio button.
${If} $var_HaxmPage_SelectedMB > 0
StrCpy $0 $var_HaxmPage_SelectedMB
# Use the recommended radio button if possible, but select custom if
# we are coming back to this page and the user changed it before.
${If} $var_HaxmPage_SelectedMB != $var_HaxmPage_RecommendedMB
${NSD_Uncheck} $hCtl_HaxmPage_RadioRecommended
${NSD_Check} $hCtl_HaxmPage_RadioCustom
Call fnc_HaxmPage_RadioChanged
${EndIf}
${Else}
StrCpy $0 $var_HaxmPage_RecommendedMB
${EndIf}
# Set custom text input to GB if $0 is a multiple of 1024, else MB for the
# extra precision (NSIS doesn't have floats, so 2560 MB, not 2.5 GB).
# However, GB looks better, so use it if possible
IntOp $1 $0 % ${1GB}
${If} $0 >= ${1GB}
${AndIf} $1 == 0
IntOp $0 $0 / ${1GB}
${NSD_SetText} $hCtl_HaxmPage_NumberCustom $0
${NSD_CB_SelectString} $hCtl_HaxmPage_ListUnits "GB"
${Else}
${NSD_SetText} $hCtl_HaxmPage_NumberCustom $0
${NSD_CB_SelectString} $hCtl_HaxmPage_ListUnits "MB"
${EndIf}
${NSD_SetText} $hCtl_HaxmPage_LabelBounds "${STR_RANGE}"
${NSD_SetText} $hCtl_HaxmPage_LabelRecommended "${STR_RECOMMENDED}"
# Restore old values
Pop $1
Pop $0
FunctionEnd
# This verifies that the current memory setting that the user chose is correct.
# Pushes 1 onto the stack if valid, 0 otherwise. The value
# var_HaxmPage_SelectedMB will be set after this function is complete.
Function fnc_HaxmPage_Leave
Push $0 # Save existing $0. Will be used to hold radio checked state
Push $1 # Save existing $1. Will be used to hold "MB" or "GB"
${NSD_GetState} $hCtl_HaxmPage_RadioRecommended $0
${If} $0 == ${BST_CHECKED}
StrCpy $var_HaxmPage_SelectedMB $var_HaxmPage_RecommendedMB
${Else}
${NSD_GetText} $hCtl_HaxmPage_NumberCustom $var_HaxmPage_SelectedMB
${NSD_GetText} $hCtl_HaxmPage_ListUnits $1
${If} $1 == "GB"
IntOp $var_HaxmPage_SelectedMB $var_HaxmPage_SelectedMB * 1024
${EndIf}
${EndIf}
# Restore old values
Pop $1
Pop $0
${If} $var_HaxmPage_SelectedMB < $var_HaxmPage_MinMB
${OrIf} $var_HaxmPage_SelectedMB > $var_HaxmPage_MaxMB
MessageBox MB_OK|MB_ICONEXCLAMATION 'The selected amount of RAM is not in range.'
Abort
${EndIf}
FunctionEnd