《更胜黎明前的琉璃色》简体中文汉化版安装包1.1 NSIS脚本

这次这补丁的安装包是赶出来的,真糟糕。不过至少能拿BMW3补丁的NSIS脚本作为基础来改,倒也没多麻烦。
这次有几个需求:
1、需要做splash
2、需要添加左侧的图片
3、需要播放背景音乐
4、需要备份若干个原始文件
相比之下,之前BMW补丁的安装包功能似乎还更多些,例如说检查注册表什么的。这次偷懒就不检查了。

显示splash图像用的是NSIS自带的一个splash plugin。这个跟BMW那个补丁里用的一样。
播放背景音乐则用到了 nsisbass插件。这个插件下载下来之后文件都混在了一起,要自己把.nsh文件复制到NSIS的%NSISDIR%\include目录里,并且把bass.dll复制到%NSISDIR%\Contrib\nsisbass目录里。

本来有另外一个插件看起来似乎更好用, EBanner,下次有时间再看看吧。多谢师兄帮忙找插件啦~~

==============================================================================

补丁的工作目录结构:
workingdir
│  bass.dll
│  yoake.nsi
│  
├─bmp
│      inst.bmp
│      splash.bmp
│      
├─files
│      arc00.arc
│      arc63.arc
│      BGI_CHS.exe
│      sysgrp.arc
│      sysprg.arc
│      system.arc
│      
├─icon
│      yak966464.ico
│      
├─music
│      bgm.mp3
│      
└─txt
        License.txt


相应的脚本:
yoake.nsi
; Script generated by the HM NIS Edit Script Wizard.
SetCompressor lzma

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "更胜黎明前的琉璃色 汉化补丁"
!define PRODUCT_VERSION "1.1"
!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 ".\bmp\inst.bmp"
!include "FileFunc.nsh"
!include "nsisbass.nsh"
!include "nsisbassmacros.nsh"
!insertmacro DirState

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON ".\icon\yak966464.ico"
!define MUI_UNICON ".\icon\yak966464.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\BGI_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 ".\bmp\splash.bmp"
ReserveFile "${NSISDIR}\Plugins\system.dll"
ReserveFile ".\bass.dll"
ReserveFile ".\music\bgm.mp3"

; MUI end ------

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

Function .onInit
  InitPluginsDir
  File "/oname=$PLUGINSDIR\Splash_Splash.bmp" ".\bmp\splash.bmp"
  ; 使用闪屏插件显示闪屏
  advsplash::show 1500 600 400 -1 "$PLUGINSDIR\Splash_Splash"
  Pop $0 ; $0 返回 '1' 表示用户提前关闭闪屏, 返回 '0' 表示闪屏正常结束, 返回 '-1' 表示闪屏显示出错
  ;!insertmacro MUI_LANGDLL_DISPLAY
  StrCpy $INSTDIR "C:\Program Files\August\YoakemaeyoriRuriirona"
  ; 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

Var /GLOBAL dirStatus

Section "MainSection" SEC01
;-------------------------backup----------------------------
  DetailPrint "正在备份文件..."
  CreateDirectory "$INSTDIR\backup"
  SetOverwrite on
  SetOutPath "$INSTDIR\backup"
  CopyFiles /SILENT "$INSTDIR\sysgrp.arc" "$INSTDIR\backup"
  CopyFiles /SILENT "$INSTDIR\sysprg.arc" "$INSTDIR\backup"
  CopyFiles /SILENT "$INSTDIR\system.arc" "$INSTDIR\backup"
  CopyFiles /SILENT "$INSTDIR\arc63.arc" "$INSTDIR\backup"
;--------------------------copy----------------------------
  SetOutPath "$INSTDIR"
  DetailPrint "正在复制文件..."
  SetOverwrite ifnewer
  File ".\files\BGI_CHS.exe"
  SetOverwrite on
  File ".\files\arc00.arc"
  File ".\files\arc63.arc"
  File ".\files\sysgrp.arc"
  File ".\files\sysprg.arc"
  File ".\files\system.arc"
  ${DirState} "$INSTDIR\UserData" $dirStatus
  StrCmp $dirStatus "-1" nosavedata donesavedata
  nosavedata:
    CreateDirectory "$INSTDIR\UserData"
  donesavedata:
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\BGI_CHS.exe"
  CreateShortCut "$DESKTOP\更胜黎明前的琉璃色 汉化版.lnk" "$INSTDIR\BGI_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\bmw_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\bmw_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\arc00.arc"
  Delete "$INSTDIR\arc63.arc"
  Delete "$INSTDIR\BGI_CHS.exe"
;--------------------delete_shortcuts----------------------
  Delete "$SMPROGRAMS\$ICONS_GROUP\更胜黎明前的琉璃色 汉化版.lnk"
  Delete "$SMPROGRAMS\$ICONS_GROUP\卸载简体中文补丁.lnk"
  Delete "$DESKTOP\更胜黎明前的琉璃色 汉化版.lnk"
  RMDir "$SMPROGRAMS\$ICONS_GROUP"
;------------------restore_backup_files--------------------
  SetOverwrite on
  CopyFiles "$INSTDIR\backup\arc63.arc" "$INSTDIR"
  CopyFiles "$INSTDIR\backup\sysgrp.arc" "$INSTDIR"
  CopyFiles "$INSTDIR\backup\sysprg.arc" "$INSTDIR"
  CopyFiles "$INSTDIR\backup\system.arc" "$INSTDIR"
  RMDir /r "$INSTDIR\backup"
;-----------------delete_uninst_reg_keys-------------------
  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
;--------------------close_after_unist---------------------
  SetAutoClose true
SectionEnd

赶工的痕迹挺明显的……不过反正能满足组里的发布需要就算了。

夜明所使用的版本的BGI读取文件有特殊顺序:游戏安装目录->arc00.arc中->arc01.arc中->...->arc99.arc中,或者直接从sysgrp.arc、sysprg.arc、system.arc中读。而游戏本身使用的归档文件是从arc01.arc开始的,也就意味着可以把补丁所需要的非系统类的文件放在arc00.arc里而不用去改动其它arcXX.arc文件,节省了补丁空间。系统类文件则只能对应的放到sysgrp.arc、sysprg.arc、system.arc里。
AUGUST出过两个夜明的升级补丁,其中ver2增添了一个arc63.arc。于是这次做的汉化补丁也顺便把这个arc63.arc带上了,以免使用该补丁的人没有打过官方补丁而出现错误。

======================================================

昨天终于把这个补丁做出来发了出去,怎么说呢,觉得松了口气,但并没有很激动很兴奋的感觉。可能是因为就在补丁发出不久就看到汉公退出的事。不能继续跟汉公真是个巨大的损失。

汉公加油!

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