mirror of
https://github.com/HypoxiE/rimworld-add-my-music-mod.git
synced 2025-12-06 05:45:58 +00:00
Getting back to basics
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,5 +1,2 @@
|
|||||||
.vdf
|
Defs/
|
||||||
DLLSourceCode/**/*.dll
|
Sounds/
|
||||||
DLLSourceCode/bin/*
|
|
||||||
DLLSourceCode/obj/*
|
|
||||||
DLLSourceCode/References/*
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
3523549667
|
|
||||||
Binary file not shown.
@@ -1,24 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="0Harmony">
|
|
||||||
<HintPath>References/0Harmony.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Assembly-CSharp">
|
|
||||||
<HintPath>References/Assembly-CSharp.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="UnityEngine">
|
|
||||||
<HintPath>References/UnityEngine.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="UnityEngine.CoreModule">
|
|
||||||
<HintPath>References/UnityEngine.CoreModule.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
|
||||||
<Copy SourceFiles="$(TargetPath)" DestinationFolder="K:\SteamLibrary\steamapps\common\RimWorld\Mods\custom_music\Assemblies\" />
|
|
||||||
</Target>
|
|
||||||
</Project>
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using Verse;
|
|
||||||
|
|
||||||
[StaticConstructorOnStartup]
|
|
||||||
public static class CopyDefsAtStartup
|
|
||||||
{
|
|
||||||
static CopyDefsAtStartup()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
string localPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
|
||||||
string localLowPath = Path.Combine(Path.GetDirectoryName(localPath), "LocalLow");
|
|
||||||
|
|
||||||
string songsGameplayXMLSourcePath = Path.Combine(localLowPath, @"Ludeon Studios\RimWorld by Ludeon Studios\AddMyMusic_data\Songs_Gameplay.xml");
|
|
||||||
string songsDBSourcePath = Path.Combine(localLowPath, @"Ludeon Studios\RimWorld by Ludeon Studios\AddMyMusic_data\music_is_here");
|
|
||||||
|
|
||||||
string modDefsDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Mods", "custom_music", "Defs", "SongDefs");
|
|
||||||
string modSoundsDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Mods", "custom_music", "Sounds", "Gameplay");
|
|
||||||
|
|
||||||
if (!Directory.Exists(modDefsDir))
|
|
||||||
Directory.CreateDirectory(modDefsDir);
|
|
||||||
|
|
||||||
string modDefsPath = Path.Combine(modDefsDir, "Songs_Gameplay.xml");
|
|
||||||
|
|
||||||
|
|
||||||
if (File.Exists(songsGameplayXMLSourcePath))
|
|
||||||
{
|
|
||||||
bool symlinkCreated = SymlinkHelper.CreateDirectorySymlink(modSoundsDir, songsDBSourcePath);
|
|
||||||
File.Copy(songsGameplayXMLSourcePath, modDefsPath, true);
|
|
||||||
Log.Message("[MyMod] Songs_Gameplay.xml скопирован в папку мода.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Log.Warning("[MyMod] Исходный файл Songs_Gameplay.xml не найден.");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log.Error("[MyMod] Ошибка при копировании Songs_Gameplay.xml: " + e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class SymlinkHelper
|
|
||||||
{
|
|
||||||
public static bool CreateDirectorySymlink(string linkPath, string targetPath)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var psi = new ProcessStartInfo("cmd.exe", $"mklink /D \"{linkPath}\" \"{targetPath}\"")
|
|
||||||
{
|
|
||||||
FileName = "cmd.exe",
|
|
||||||
Arguments = $"/c mklink /D \"{linkPath}\" \"{targetPath}\"",
|
|
||||||
RedirectStandardOutput = true,
|
|
||||||
RedirectStandardError = true,
|
|
||||||
UseShellExecute = false,
|
|
||||||
CreateNoWindow = true,
|
|
||||||
Verb = "runas"
|
|
||||||
};
|
|
||||||
|
|
||||||
using var process = Process.Start(psi);
|
|
||||||
process.WaitForExit();
|
|
||||||
|
|
||||||
string output = process.StandardOutput.ReadToEnd();
|
|
||||||
string error = process.StandardError.ReadToEnd();
|
|
||||||
|
|
||||||
if (process.ExitCode == 0)
|
|
||||||
{
|
|
||||||
Log.Message($"Symlink создан: {output}");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Log.Error($"Ошибка создания symlink: {error}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log.Error($"Exception: {e}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,47 +3,44 @@ echo This command will completely overwrite the Songs_Gameplay.xml file of this
|
|||||||
pause
|
pause
|
||||||
|
|
||||||
setlocal enabledelayedexpansion
|
setlocal enabledelayedexpansion
|
||||||
|
set "Songs_Gameplay_XML_path=Defs\SongDefs"
|
||||||
|
|
||||||
set "localappdata=%USERPROFILE%\AppData\LocalLow"
|
set "music_path=Sounds\Gameplay"
|
||||||
set "mod_user_dir=%localappdata%\Ludeon Studios\RimWorld by Ludeon Studios\AddMyMusic_data"
|
|
||||||
if not exist "%mod_user_dir%" mkdir "%mod_user_dir%"
|
|
||||||
|
|
||||||
set "music_database=%mod_user_dir%\music_is_here"
|
|
||||||
if not exist "%music_database%" mkdir "%music_database%"
|
|
||||||
|
|
||||||
|
|
||||||
chcp 65001
|
chcp 65001
|
||||||
echo ^<?xml version="1.0" encoding="utf-8" ?^> > "%mod_user_dir%\Songs_Gameplay.xml"
|
echo ^<?xml version="1.0" encoding="utf-8" ?^> > "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
echo ^<Defs^> >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo ^<Defs^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
|
||||||
for %%f in ("%music_database%\*") do (
|
for %%f in ("%music_path%\*") do (
|
||||||
set sound_name=%%~nf
|
set sound_name=%%~nf
|
||||||
|
|
||||||
echo ^<SongDef^> >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo ^<SongDef^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
echo ^<defName^>!sound_name!^</defName^> >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo ^<defName^>!sound_name!^</defName^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
echo ^<clipPath^>Gameplay/!sound_name!^</clipPath^> >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo ^<clipPath^>Gameplay/!sound_name!^</clipPath^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
echo. >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo. >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
echo ^<^^!--The probability of music appearing in the game--^> >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo ^<^^!--The probability of music appearing in the game--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
echo ^<commonality^>1.0^</commonality^> >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo ^<commonality^>1.0^</commonality^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
echo. >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo. >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
echo ^<^^!--Music volume--^> >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo ^<^^!--Music volume--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
echo ^<volume^>1.0^</volume^> >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo ^<volume^>1.0^</volume^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
echo. >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo. >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
echo ^<^^!--If true, it only plays in a combat situation--^> >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo ^<^^!--If true, it only plays in a combat situation--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
echo ^<tense^>false^</tense^> >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo ^<tense^>false^</tense^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
echo. >> "%mod_user_dir%\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--^> >> "%mod_user_dir%\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^>--^> >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo ^<^^!--^<allowedTimeOfDay^>Day^</allowedTimeOfDay^>--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
echo ^<^^!--^<allowedTimeOfDay^>Night^</allowedTimeOfDay^>--^> >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo ^<^^!--^<allowedTimeOfDay^>Night^</allowedTimeOfDay^>--^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
echo. >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo. >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
echo ^<^^!--Listing the seasons in which this song is played--^> >> "%mod_user_dir%\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^> >> "%mod_user_dir%\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^> >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo ^</SongDef^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
echo. >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo. >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
echo Added !sound_name!
|
||||||
)
|
)
|
||||||
|
|
||||||
echo ^</Defs^> >> "%mod_user_dir%\Songs_Gameplay.xml"
|
echo ^</Defs^> >> "%Songs_Gameplay_XML_path%\Songs_Gameplay.xml"
|
||||||
|
|
||||||
echo Songs_Gameplay.xml overwritten. After restarting the game, music will be added.
|
echo Songs_Gameplay.xml overwritten. After restarting the game, music will be added.
|
||||||
pause
|
pause
|
||||||
Reference in New Issue
Block a user