mirror of
https://github.com/HypoxiE/rimworld-add-my-music-mod.git
synced 2025-12-06 05:45:58 +00:00
Added a script to save user settings
This commit is contained in:
@@ -13,14 +13,14 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
<description>
|
<description>
|
||||||
[EN]
|
[EN]
|
||||||
This mod adds the ability to put your own music in the game.
|
This mod adds the ability to play your own music in the game.
|
||||||
Quick guide:
|
Short guide:
|
||||||
1) Throw your music into the Sounds\Gameplay\ folder of this mod
|
1) Put your music files into the Sounds\Gameplay\ folder of this mod.
|
||||||
2) Run the add_my_music.bat script
|
2) Run the add_my_music.bat script.
|
||||||
|
|
||||||
After running add_my_music.bat, the Defs\SongDefs\Songs_Gameplay.xml file will be completely rewritten. After that, you can change the modifiers in this file, delete something from it or add. Initially, the default parameters are written to it, so you can change them at your discretion. In the future, we plan to make a script that adds and removes music, but does not touch the existing parameters.
|
After running add_my_music.bat, the file Defs\SongDefs\Songs_Gameplay.xml will be overwritten (existing settings will be preserved). After that, you can modify the settings in this file, delete entries, or add new ones. Initially, default parameters are written to the file, so you can customize them as you like.
|
||||||
|
|
||||||
Mod source code: https://github.com/HypoxiE/rimworld-ammp
|
Mod source code: https://github.com/HypoxiE/rimworld-add-my-music-mod
|
||||||
|
|
||||||
[RU]
|
[RU]
|
||||||
Данный мод добавляет возможность ставить свою музыку в игру.
|
Данный мод добавляет возможность ставить свою музыку в игру.
|
||||||
@@ -28,8 +28,8 @@ Mod source code: https://github.com/HypoxiE/rimworld-ammp
|
|||||||
1) Закиньте свою музыку в папку Sounds\Gameplay\ этого мода
|
1) Закиньте свою музыку в папку Sounds\Gameplay\ этого мода
|
||||||
2) Запустите скрипт add_my_music.bat
|
2) Запустите скрипт add_my_music.bat
|
||||||
|
|
||||||
После запуска add_my_music.bat файл Defs\SongDefs\Songs_Gameplay.xml полностью перезапишется. После этого вы можете менять модификаторы в этом файле, удалять что-либо из него или добавлять. Изначально в него записываются параметры по умолчанию, так что вы можете менять их на своё усмотрение. В будущем планируется сделать скрипт, который добавляет и удаляет музыку, но при этом не трогает уже существующие параметры.
|
После запуска add_my_music.bat файл Defs\SongDefs\Songs_Gameplay.xml перезапишется (уже существующие настройки останутся). После этого вы можете менять модификаторы в этом файле, удалять что-либо из него или добавлять. Изначально в него записываются параметры по умолчанию, так что вы можете менять их на своё усмотрение.
|
||||||
|
|
||||||
Исходный код мода: https://github.com/HypoxiE/rimworld-ammp
|
Исходный код мода: https://github.com/HypoxiE/rimworld-add-my-music-mod
|
||||||
</description>
|
</description>
|
||||||
</ModMetaData>
|
</ModMetaData>
|
||||||
21
README.md
21
README.md
@@ -1,7 +1,20 @@
|
|||||||
# Add my music, please! mod for rimworld
|
# Add my music, please!
|
||||||
|
|
||||||
## A short guide
|
## Short guide
|
||||||
|
Add your music in **.mp3** or **.ogg** format to the `Sounds\Gameplay` directory. Then run `add_my_music.bat` or `add_my_music.ps1`.
|
||||||
|
|
||||||
In this version, after installing the modification, you need to run add_my_music.bat. After that, in the folder C:\Users\<username>\AppData\LocalLow\Ludeon Studios\RimWorld by Ludeon Studios\AddMyMusic_data\music_is_here, leave your music and run add_my_music.bat again. After that, run rimworld, close it and load it again. After that, the music should load in the game
|
Done! The script will automatically create all the necessary files. You can now launch the game and enjoy your music.
|
||||||
|
|
||||||
~~To add your music, you just need to drop your music into the Sounds\Gameplay\ folder and run the add_my_music.bat script. After that, the Defs\SongDefs\Songs_Gameplay.xml file will be automatically overwritten and after you enable the mod in the game, your music will appear there.~~
|
In the new version, you can freely customize your tracks in `Defs\SongDefs\Songs_Gameplay.xml`.
|
||||||
|
The settings for existing songs will not be lost if you decide to delete old or add new tracks.
|
||||||
|
Simply run `add_my_music.bat` after removing or adding music, and the script will carry over your settings into the new `Songs_Gameplay.xml`.
|
||||||
|
|
||||||
|
|
||||||
|
## Короткое руководство
|
||||||
|
Добавьте свою музыку формата **.mp3** или **.ogg** в директорию `Sounds\Gameplay`. После этого запустите `add_my_music.bat` или `add_my_music.ps1`.
|
||||||
|
|
||||||
|
Готово, скрипт автоматически создаст нужные файлы. Можете заходить в игру и наслаждаться своей музыкой
|
||||||
|
|
||||||
|
В новой версии вы можете спокойно настраивать свои композиции в `Defs\SongDefs\Songs_Gameplay.xml`.
|
||||||
|
Настройки существующих песен не собьются, если вы решите удалить старые или добавить новые.
|
||||||
|
Просто нажмите `add_my_music.bat` после удаления/добавления музыки и скрипт перенесёт ваши настройки в новый `Songs_Gameplay.xml`
|
||||||
@@ -1,46 +1,2 @@
|
|||||||
@echo off
|
@echo off
|
||||||
echo This command will completely overwrite the Songs_Gameplay.xml file of this modification. If you agree, press Enter, and if not, close this window.
|
powershell -ExecutionPolicy Bypass -File %~dp0add_my_music.ps1
|
||||||
pause
|
|
||||||
|
|
||||||
setlocal enabledelayedexpansion
|
|
||||||
set "Songs_Gameplay_XML_path=Defs\SongDefs"
|
|
||||||
|
|
||||||
set "music_path=Sounds\Gameplay"
|
|
||||||
|
|
||||||
|
|
||||||
chcp 65001
|
|
||||||
echo ^<?xml version="1.0" encoding="utf-8" ?^> > "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo ^<Defs^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
|
|
||||||
for %%f in ("%music_path%\*") do (
|
|
||||||
set sound_name=%%~nf
|
|
||||||
|
|
||||||
echo ^<SongDef^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo ^<defName^>!sound_name!^</defName^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo ^<clipPath^>Gameplay/!sound_name!^</clipPath^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo. >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo ^<^^!--The probability of music appearing in the game--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo ^<commonality^>1.0^</commonality^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo. >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo ^<^^!--Music volume--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo ^<volume^>1.0^</volume^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo. >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo ^<^^!--If true, it only plays in a combat situation--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo ^<tense^>false^</tense^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo. >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo ^<^^!--If you want to limit the time of day, delete '^<^^!- -' and '- -^>' of the desired option--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo ^<^^!--^<allowedTimeOfDay^>Day^</allowedTimeOfDay^>--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo ^<^^!--^<allowedTimeOfDay^>Night^</allowedTimeOfDay^>--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo. >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo ^<^^!--Listing the seasons in which this song is played--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo ^<allowedSeasons^> ^<li^>Winter^</li^>^<li^>Spring^</li^>^<li^>Summer^</li^>^<li^>Fall^</li^> ^</allowedSeasons^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
|
|
||||||
echo ^</SongDef^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo. >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
echo Added !sound_name!
|
|
||||||
)
|
|
||||||
|
|
||||||
echo ^</Defs^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
|
||||||
|
|
||||||
echo Songs_Gameplay.xml overwritten. After restarting the game, music will be added.
|
|
||||||
pause
|
|
||||||
80
add_my_music.ps1
Normal file
80
add_my_music.ps1
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
# Включаем кодировку UTF8 для консоли
|
||||||
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
|
$lineBreak = [Environment]::NewLine
|
||||||
|
|
||||||
|
# Пути
|
||||||
|
$SongsGameplayXMLPath = "Defs\SongDefs"
|
||||||
|
$musicPath = "Sounds\Gameplay"
|
||||||
|
|
||||||
|
# Проверяем, что папка для xml существует, если нет — создаём
|
||||||
|
if (-not (Test-Path $SongsGameplayXMLPath)) {
|
||||||
|
New-Item -ItemType Directory -Path $SongsGameplayXMLPath | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Test-Path "$SongsGameplayXMLPath\Songs_Gameplay.xml") {
|
||||||
|
$content = Get-Content -Path "$SongsGameplayXMLPath\Songs_Gameplay.xml" -Raw
|
||||||
|
} else {
|
||||||
|
$content = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
$allSongDefs = @()
|
||||||
|
if ($content -ne "") {
|
||||||
|
$blockPattern = "<SongDef.*?</SongDef>"
|
||||||
|
$allSongDefs = [regex]::Matches($content, $blockPattern, [System.Text.RegularExpressions.RegexOptions]::Singleline)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Переменная для накопления текста
|
||||||
|
$xmlContent = @"
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<Defs>
|
||||||
|
"@
|
||||||
|
|
||||||
|
Get-ChildItem -Path $musicPath -File | ForEach-Object {
|
||||||
|
$soundName = $_.BaseName
|
||||||
|
$existingBlock = $null
|
||||||
|
|
||||||
|
foreach ($block in $allSongDefs) {
|
||||||
|
if ($block.Value -like "*<defName>$soundName</defName>*") {
|
||||||
|
$existingBlock = $block.Value
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($existingBlock) {
|
||||||
|
Write-Output "Found existing block for $soundName"
|
||||||
|
$xmlContent += "${lineBreak}$existingBlock${lineBreak}"
|
||||||
|
} else {
|
||||||
|
Write-Output "Added new block for $soundName"
|
||||||
|
$xmlContent += @"
|
||||||
|
${lineBreak}<SongDef>
|
||||||
|
<defName>$soundName</defName>
|
||||||
|
<clipPath>Gameplay/$soundName</clipPath>
|
||||||
|
|
||||||
|
<!--The probability of music appearing in the game-->
|
||||||
|
<commonality>1.0</commonality>
|
||||||
|
|
||||||
|
<!--Music volume-->
|
||||||
|
<volume>1.0</volume>
|
||||||
|
|
||||||
|
<!--If true, it only plays in a combat situation-->
|
||||||
|
<tense>false</tense>
|
||||||
|
|
||||||
|
<!--If you want to limit the time of day, delete '<!- -' and '- ->' of the desired option-->
|
||||||
|
<!--<allowedTimeOfDay>Day</allowedTimeOfDay>-->
|
||||||
|
<!--<allowedTimeOfDay>Night</allowedTimeOfDay>-->
|
||||||
|
|
||||||
|
<!--Listing the seasons in which this song is played-->
|
||||||
|
<allowedSeasons> <li>Winter</li><li>Spring</li><li>Summer</li><li>Fall</li> </allowedSeasons>
|
||||||
|
</SongDef>${lineBreak}
|
||||||
|
"@
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Закрываем тег
|
||||||
|
$xmlContent += "</Defs>"
|
||||||
|
|
||||||
|
# Записать в файл одним вызовом
|
||||||
|
$xmlContent | Out-File -FilePath "$SongsGameplayXMLPath\Songs_Gameplay.xml" -Encoding utf8
|
||||||
|
|
||||||
|
Write-Host "Songs_Gameplay.xml overwritten. After restarting the game, music will be added."
|
||||||
|
Read-Host "Press Enter to exit"
|
||||||
46
add_my_music_old.bat
Normal file
46
add_my_music_old.bat
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
@echo off
|
||||||
|
echo This command will completely overwrite the Songs_Gameplay.xml file of this modification. If you agree, press Enter, and if not, close this window.
|
||||||
|
pause
|
||||||
|
|
||||||
|
setlocal enabledelayedexpansion
|
||||||
|
set "Songs_Gameplay_XML_path=Defs\SongDefs"
|
||||||
|
|
||||||
|
set "music_path=Sounds\Gameplay"
|
||||||
|
|
||||||
|
|
||||||
|
chcp 65001
|
||||||
|
echo ^<?xml version="1.0" encoding="utf-8" ?^> > "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo ^<Defs^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
|
||||||
|
for %%f in ("%music_path%\*") do (
|
||||||
|
set sound_name=%%~nf
|
||||||
|
|
||||||
|
echo ^<SongDef^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo ^<defName^>!sound_name!^</defName^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo ^<clipPath^>Gameplay/!sound_name!^</clipPath^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo. >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo ^<^^!--The probability of music appearing in the game--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo ^<commonality^>1.0^</commonality^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo. >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo ^<^^!--Music volume--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo ^<volume^>1.0^</volume^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo. >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo ^<^^!--If true, it only plays in a combat situation--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo ^<tense^>false^</tense^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo. >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo ^<^^!--If you want to limit the time of day, delete '^<^^!- -' and '- -^>' of the desired option--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo ^<^^!--^<allowedTimeOfDay^>Day^</allowedTimeOfDay^>--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo ^<^^!--^<allowedTimeOfDay^>Night^</allowedTimeOfDay^>--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo. >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo ^<^^!--Listing the seasons in which this song is played--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo ^<allowedSeasons^> ^<li^>Winter^</li^>^<li^>Spring^</li^>^<li^>Summer^</li^>^<li^>Fall^</li^> ^</allowedSeasons^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
|
||||||
|
echo ^</SongDef^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo. >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo Added !sound_name!
|
||||||
|
)
|
||||||
|
|
||||||
|
echo ^</Defs^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
|
||||||
|
echo Songs_Gameplay.xml overwritten. After restarting the game, music will be added.
|
||||||
|
pause
|
||||||
Reference in New Issue
Block a user