mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-05 03:19:23 +00:00
New mods: AvatarSyncedLook
and PlayersInstanceNotifier
Minor changes
This commit is contained in:
parent
72aeffb656
commit
e13bb8af23
28 changed files with 841 additions and 16 deletions
82
ml_pin/ResourcesHandler.cs
Normal file
82
ml_pin/ResourcesHandler.cs
Normal file
|
@ -0,0 +1,82 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ml_pin
|
||||
{
|
||||
static class ResourcesHandler
|
||||
{
|
||||
const string c_modName = "PlayersInstanceNotifier";
|
||||
|
||||
static readonly List<string> ms_audioResources = new List<string>()
|
||||
{
|
||||
"Chime.wav",
|
||||
"DoorClose.wav"
|
||||
};
|
||||
|
||||
public static void ExtractAudioResources()
|
||||
{
|
||||
string l_dirPath = MelonLoader.Utils.MelonEnvironment.UserDataDirectory;
|
||||
if(!Directory.Exists(l_dirPath))
|
||||
Directory.CreateDirectory(l_dirPath);
|
||||
|
||||
l_dirPath = Path.Combine(l_dirPath, c_modName);
|
||||
if(!Directory.Exists(l_dirPath))
|
||||
Directory.CreateDirectory(l_dirPath);
|
||||
|
||||
string l_filePath = Path.Combine(l_dirPath, "player_join.wav");
|
||||
if(!File.Exists(l_filePath))
|
||||
ExtractAudioFile(ms_audioResources[0], l_filePath);
|
||||
|
||||
l_filePath = Path.Combine(l_dirPath, "player_leave.wav");
|
||||
if(!File.Exists(l_filePath))
|
||||
ExtractAudioFile(ms_audioResources[1], l_filePath);
|
||||
|
||||
l_filePath = Path.Combine(l_dirPath, "friend_join.wav");
|
||||
if(!File.Exists(l_filePath))
|
||||
ExtractAudioFile(ms_audioResources[0], l_filePath);
|
||||
|
||||
l_filePath = Path.Combine(l_dirPath, "friend_leave.wav");
|
||||
if(!File.Exists(l_filePath))
|
||||
ExtractAudioFile(ms_audioResources[1], l_filePath);
|
||||
}
|
||||
|
||||
static void ExtractAudioFile(string p_name, string p_path)
|
||||
{
|
||||
Assembly l_assembly = Assembly.GetExecutingAssembly();
|
||||
string l_assemblyName = l_assembly.GetName().Name;
|
||||
|
||||
try
|
||||
{
|
||||
Stream l_resourceStream = l_assembly.GetManifestResourceStream(l_assemblyName + ".resources." + p_name);
|
||||
Stream l_fileStream = File.Create(p_path);
|
||||
l_resourceStream.CopyTo(l_fileStream);
|
||||
l_fileStream.Flush();
|
||||
l_fileStream.Close();
|
||||
l_resourceStream.Close();
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
MelonLoader.MelonLogger.Warning("Unable to write '" + p_path + "' file, problems can occur.");
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetEmbeddedResource(string p_name)
|
||||
{
|
||||
string l_result = "";
|
||||
Assembly l_assembly = Assembly.GetExecutingAssembly();
|
||||
string l_assemblyName = l_assembly.GetName().Name;
|
||||
|
||||
try
|
||||
{
|
||||
Stream l_libraryStream = l_assembly.GetManifestResourceStream(l_assemblyName + ".resources." + p_name);
|
||||
StreamReader l_streadReader = new StreamReader(l_libraryStream);
|
||||
l_result = l_streadReader.ReadToEnd();
|
||||
}
|
||||
catch(Exception) { }
|
||||
|
||||
return l_result;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue