《七色★星露》 汉化补丁1.0 NSIS脚本

这东西总算也结束了……我基本上可以安心离开汉化圈子了。

嘛,这脚本跟前面的 BMW夜明的脚本基本上是一样的,所以也没什么太多可解释的。
而且继续偷懒……懒得做目录操作所以那graph目录我做成了一个自解压exe文件,复制到安装目录后自动展开。

目录结构:
│  nanadoro.nsi
│  nana_patch_chs.ex
│
├─files
│      GAME.ini
│      graph.exe
│      nana_chs.exe
│      scenario.dat
│      textdata.dat
│
├─icon
│      nana.ico
│
├─image
│      side.bmp
│      splash.bmp
│
├─music
│      BGM.mp3
│
└─txt
        license.txt


NSIS脚本代码:
SetCompressor lzma

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "七色★星露 汉化补丁"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "奥克汉化组"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\yoake_chs"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"

; MUI 1.67 compatible ------
!include "MUI.nsh"
!define MUI_WELCOMEFINISHPAGE_BITMAP ".\image\side.bmp"
!include "FileFunc.nsh"
!include "nsisbass.nsh"
!include "nsisbassmacros.nsh"
!insertmacro DirState

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON ".\icon\nana.ico"
!define MUI_UNICON ".\icon\nana.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
!define MUI_LICENSEPAGE_CHECKBOX
!insertmacro MUI_PAGE_LICENSE ".\txt\license.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Start menu page
var /GLOBAL ICONS_GROUP
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "奥克汉化组"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_RUN "$INSTDIR\nana_chs.exe"
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "SimpChinese"
VIProductVersion "1.0.0.0"
VIAddVersionKey /LANG=2052 "FileDescription" "${PRODUCT_NAME}"
VIAddVersionKey /LANG=2052 "ProductName" "${PRODUCT_NAME}"
VIAddVersionKey /LANG=2052 "LegalCopyright" ""
VIAddVersionKey /LANG=2052 "CompanyName" "${PRODUCT_PUBLISHER}"
VIAddVersionKey /LANG=2052 "FileVersion" "${PRODUCT_VERSION}"

ReserveFile ".\image\splash.bmp"
ReserveFile "${NSISDIR}\Plugins\system.dll"
ReserveFile "${NSISDIR}\Contrib\nsisbass\bass.dll"
ReserveFile ".\music\bgm.mp3"

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "nana_patch_chs.exe"
InstallDir "$EXEDIR"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show

Function .onInit
  InitPluginsDir
  File "/oname=$PLUGINSDIR\Splash_Splash.bmp" ".\image\splash.bmp"
  ; 使用闪屏插件显示闪屏
  advsplash::show 1500 600 400 -1 "$PLUGINSDIR\Splash_Splash"
  Pop $0 ; $0 返回 '1' 表示用户提前关闭闪屏, 返回 '0' 表示闪屏正常结束, 返回 '-1' 表示闪屏显示出错
  ;!insertmacro MUI_LANGDLL_DISPLAY
  StrCpy $INSTDIR "C:\ユニゾンシフト\ななついろ★ドロップス"
  ; Insert the NSISBASS_INIT macro
  !insertmacro NSISBASS_INIT
  ; We can extract a song file as well (so you got something to play).
  File "/oname=$PLUGINSDIR\tempsong.mp3" ".\music\BGM.mp3"
  !insertmacro NSISBASS_PLAY "$PLUGINSDIR\tempsong.mp3"
FunctionEnd

Function .onVerifyInstDir
  IfFileExists "$INSTDIR\nana.exe" PathGood
    Abort ; if $INSTDIR is not a NanaDoro directory, don't let us install there
  PathGood:
FunctionEnd


Section "MainSection" SEC01
;--------------------------copy----------------------------
  SetOutPath "$INSTDIR"
  DetailPrint "正在复制文件..."
  SetOverwrite ifnewer
  File ".\files\nana_chs.exe"
  File ".\files\scenario.dat"
  File ".\files\textdata.dat"
  File ".\files\GAME.ini"
  File ".\files\graph.exe"
  ExecWait '"$INSTDIR\graph.exe"'
  Delete "$INSTDIR\graph.exe"
SectionEnd

Section "Add Start Menu Shortcuts" SEC02
  ; shortcuts
  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
  SetOutPath "$INSTDIR"
  CreateDirectory "$SMPROGRAMS\$ICONS_GROUP"
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\七色★星露 汉化版.lnk" "$INSTDIR\nana_chs.exe"
  CreateShortCut "$DESKTOP\七色★星露 汉化版.lnk" "$INSTDIR\nana_chs.exe"
  !insertmacro MUI_STARTMENU_WRITE_END
SectionEnd

Section -AdditionalIcons
  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
  CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\卸载简体中文补丁.lnk" "$INSTDIR\uninst.exe"
  !insertmacro MUI_STARTMENU_WRITE_END
SectionEnd

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


Function un.onUninstSuccess
  HideWindow
  MessageBox MB_ICONINFORMATION|MB_OK "「七色★星露 汉化补丁」已成功地从你的计算机删除。"
FunctionEnd

Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "你确实要完全删除「七色★星露 汉化补丁」,其及所有組件?" IDYES +2
  Abort
FunctionEnd

Section Uninstall
  !insertmacro MUI_STARTMENU_GETFOLDER "Application" $ICONS_GROUP
;----------------------delete_files------------------------
  Delete "$INSTDIR\uninst.exe"
  Delete "$INSTDIR\GAME.ini"
  Delete "$INSTDIR\textdata.dat"
  Delete "$INSTDIR\scenario.dat"
  Delete "$INSTDIR\nana_chs.exe"
  RMDir /r "$INSTDIR\graph"
;--------------------delete_shortcuts----------------------
  Delete "$SMPROGRAMS\$ICONS_GROUP\七色★星露 汉化版.lnk"
  Delete "$SMPROGRAMS\$ICONS_GROUP\卸载简体中文补丁.lnk"
  Delete "$DESKTOP\七色★星露 汉化版.lnk"
  RMDir "$SMPROGRAMS\$ICONS_GROUP"
;-----------------delete_uninst_reg_keys-------------------
  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
;--------------------close_after_unist---------------------
  SetAutoClose true
SectionEnd

你可能感兴趣的:(游戏,windows,脚本,Microsoft,Blog)