diff --git a/CMakeLists.txt b/CMakeLists.txt index e9f55eb..537ad85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,3 +12,7 @@ add_executable(HackNetOS add_custom_command(TARGET HackNetOS POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/ASCII $/ASCII) + +add_custom_command(TARGET HackNetOS POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_SOURCE_DIR}/Scripts $) \ No newline at end of file diff --git a/Scripts/generate_bgm.ps1 b/Scripts/generate_bgm.ps1 new file mode 100644 index 0000000..d6987d5 --- /dev/null +++ b/Scripts/generate_bgm.ps1 @@ -0,0 +1,40 @@ +if ($args.Count -gt 0) { + $srcD = $args[0]; +} + +if ($null -eq $srcD -or( Get-Content $srcD -eq $null)) { + # prompt user to input the path + $srcD = Read-Host -Prompt "Enter the path of the source directory: "; +} + +if ($null -eq (Get-ChildItem $srcD)) { + Write-Error "The source directory does not exist."; + exit 1; +} + +Write-Host -ForegroundColor Green "Generating bgm directory..."; + +$backgroundMusic = Get-ChildItem $srcD -Filter "*Revole*.mp3"; +$gotmail = Get-ChildItem $srcD -Filter "*You Got Mail*.mp3"; + +if ($null -eq (Get-ChildItem -Directory -Filter "bgm")) { + New-Item -Path "bgm" -Type Directory; +} + +if ($null -ne $backgroundMusic) { + Write-Host -ForegroundColor Green "Copying Revole..."; + Copy-Item $backgroundMusic -Destination "bgm/0.mp3"; +} else { + Write-Host -ForegroundColor Yellow "Cannot find Revole"; +} + +if ($null -ne $gotmail) { + Write-Host -ForegroundColor Green "Copying You Got Mail..."; + Copy-Item $gotmail -Destination "bgm/n0.mp3"; +} else { + Write-Host -ForegroundColor Yellow "Cannot find You Got Mail"; +} + +Write-Host -ForegroundColor Green "Operation completed." + + diff --git a/readme.md b/readme.md index d58d58e..36b6061 100644 --- a/readme.md +++ b/readme.md @@ -33,10 +33,8 @@ Currently, some part of the game supports Chinese only, the i18n is on the way, > This step is optional, the game can work properly without BGM feature. 1. Purchase and download [Hacknet OST](https://store.steampowered.com/app/408710/Hacknet_Official_Soundtrack/) -2. Create a directory called bgm on the program path. -3. Copy `Cinematrik - Hacknet OST - 09 Revole (R Mix).mp3` from OST directory to bgm directory and rename it to `0.mp3`. -4. Copy `Bit - Hacknet OST - 08 You Got Mail.mp3` from OST directory to bgm directory and rename it to `n0.mp3`. -5. Restart the game, now bgm should function properly. +2. Run `generate_bgm.ps1` using PowerShell to generate bgm directory automatically. +3. Restart the game if started, now bgm should function properly. ## 📷 Screenshots diff --git a/readme_cn.md b/readme_cn.md index ecc35ad..353f033 100644 --- a/readme_cn.md +++ b/readme_cn.md @@ -30,10 +30,8 @@ > 这步是可选的, 游戏在没有bgm文件的情况下也可正常工作. 1. 从Steam购买并下载 [Hacknet OST](https://store.steampowered.com/app/408710/Hacknet_Official_Soundtrack/) -2. 在游戏目录中创建一个文件夹, 名字为 `bgm`. -3. 从OST中复制 `Cinematrik - Hacknet OST - 09 Revole (R Mix).mp3` 到bgm目录并将其重命名为 `0.mp3`. -4. 从OST中复制 `Bit - Hacknet OST - 08 You Got Mail.mp3` 到bgm目录并将其重命名为 `n0.mp3`. -5. 如果你已经打开了HacknetOS, 重启游戏. +2. 使用PowerShell运行`generate_bgm.ps1`即可自动生成bgm目录. +3. 如果你已经打开了HacknetOS, 重启游戏. ## 📷 截图