2017-04-17 18:06:29 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
using System.Xml.Serialization;
|
|
|
|
|
|
|
|
|
|
namespace CsbBuilder.Project
|
|
|
|
|
{
|
|
|
|
|
public class Settings : ICloneable
|
|
|
|
|
{
|
|
|
|
|
public enum ProjectDirectory
|
|
|
|
|
{
|
|
|
|
|
DirectoryOfProjects,
|
|
|
|
|
DirectoryOfCsb,
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-21 00:19:47 +02:00
|
|
|
|
public enum NAudioWavePlayer
|
|
|
|
|
{
|
|
|
|
|
WaveOut,
|
|
|
|
|
WasapiOut,
|
|
|
|
|
DirectSoundOut,
|
|
|
|
|
AsioOut,
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-17 18:06:29 +02:00
|
|
|
|
[DisplayName("Name node after its parent"), Category("General")]
|
2021-03-19 20:24:07 +01:00
|
|
|
|
[Description("Determines whether a node is going to be named after its parent when created.")]
|
2017-04-17 18:06:29 +02:00
|
|
|
|
public bool NameNodeAfterParent { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Buffer size"), Category("Stream")]
|
2021-03-19 20:24:07 +01:00
|
|
|
|
[Description("Buffer size to use for I/O operations.")]
|
2017-04-17 18:06:29 +02:00
|
|
|
|
public int BufferSize { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Default directory of new CSB projects"), Category("Project")]
|
2021-03-19 20:24:07 +01:00
|
|
|
|
[Description("Default output directory of new CSB projects.")]
|
2017-04-17 18:06:29 +02:00
|
|
|
|
public string ProjectsDirectory { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Default name of new CSB projects"), Category("Project")]
|
2021-03-19 20:24:07 +01:00
|
|
|
|
[Description("Default name of new CSB projects.")]
|
2017-04-17 18:06:29 +02:00
|
|
|
|
public string ProjectsName { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Default project directory of imported CSB files"), Category("Project")]
|
2021-03-19 20:24:07 +01:00
|
|
|
|
[Description("Default project directory of imported CSB files.")]
|
2017-04-17 18:06:29 +02:00
|
|
|
|
public ProjectDirectory ImportedCsbProjectDirectory { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Rename Sound node to referenced Sound Element node"), Category("Application")]
|
|
|
|
|
public bool RenameToSoundElement { get; set; }
|
|
|
|
|
|
2021-03-19 20:24:07 +01:00
|
|
|
|
[DisplayName("Enable multi-threading"), Category("Stream")]
|
|
|
|
|
[Description("Determines whether I/O operations are going to be multi-threaded.")]
|
2017-04-23 18:22:25 +02:00
|
|
|
|
public bool EnableThreading { get; set; }
|
|
|
|
|
|
2021-03-19 20:24:07 +01:00
|
|
|
|
[DisplayName("Max thread count"), Category("Stream")]
|
|
|
|
|
[Description("Max amount of threads to use for multi-threaded I/O operations.")]
|
2017-06-21 00:19:47 +02:00
|
|
|
|
public int MaxThreads { get; set; }
|
|
|
|
|
|
2021-03-19 20:24:07 +01:00
|
|
|
|
[DisplayName("Sound device"), Category("Sound")]
|
|
|
|
|
[Description("Sound device to use for audio playback. Application is going to crash if sound device is not supported.")]
|
2017-06-21 00:19:47 +02:00
|
|
|
|
public NAudioWavePlayer WavePlayer { get; set; }
|
|
|
|
|
|
2021-03-19 20:24:07 +01:00
|
|
|
|
[DisplayName("Loop count"), Category("Audio converter")]
|
|
|
|
|
[Description("How many times the audio is going to be looped when converting to .wav.")]
|
2017-06-21 00:19:47 +02:00
|
|
|
|
public int LoopCount { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Fade Out Time"), Category("Audio Converter")]
|
2021-03-19 20:24:07 +01:00
|
|
|
|
[Description("How much time it takes to fade out when converting to .wav.")]
|
2017-06-21 00:19:47 +02:00
|
|
|
|
public double FadeTime { get; set; }
|
|
|
|
|
|
|
|
|
|
[DisplayName("Fade Out Delay Time"), Category("Audio Converter")]
|
2021-03-19 20:24:07 +01:00
|
|
|
|
[Description("How much time it takes before starting to fade out when converting to .wav.")]
|
2017-06-21 00:19:47 +02:00
|
|
|
|
public double FadeDelay { get; set; }
|
2017-04-23 18:22:25 +02:00
|
|
|
|
|
2017-04-17 18:06:29 +02:00
|
|
|
|
public static Settings Load()
|
|
|
|
|
{
|
|
|
|
|
string path = Path.ChangeExtension(Application.ExecutablePath, "xml");
|
|
|
|
|
|
|
|
|
|
Settings settings = null;
|
|
|
|
|
|
2017-04-23 18:22:25 +02:00
|
|
|
|
if (File.Exists(path))
|
2017-06-21 00:19:47 +02:00
|
|
|
|
{
|
2017-04-17 18:06:29 +02:00
|
|
|
|
XmlSerializer serializer = new XmlSerializer(typeof(Settings));
|
|
|
|
|
|
|
|
|
|
using (Stream source = File.OpenRead(path))
|
|
|
|
|
{
|
|
|
|
|
settings = (Settings)serializer.Deserialize(source);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
settings = new Settings();
|
|
|
|
|
settings.Save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return settings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Save()
|
|
|
|
|
{
|
|
|
|
|
XmlSerializer serializer = new XmlSerializer(typeof(Settings));
|
|
|
|
|
|
|
|
|
|
using (Stream destination = File.Create(Path.ChangeExtension(Application.ExecutablePath, "xml"), BufferSize))
|
|
|
|
|
{
|
|
|
|
|
serializer.Serialize(destination, this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object Clone()
|
|
|
|
|
{
|
|
|
|
|
return MemberwiseClone();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Settings()
|
|
|
|
|
{
|
2017-06-21 00:19:47 +02:00
|
|
|
|
WavePlayer = NAudioWavePlayer.WaveOut;
|
2017-04-17 18:06:29 +02:00
|
|
|
|
NameNodeAfterParent = true;
|
|
|
|
|
BufferSize = 4096;
|
|
|
|
|
ProjectsDirectory = "Projects";
|
|
|
|
|
ProjectsName = "New CSB Project";
|
|
|
|
|
ImportedCsbProjectDirectory = ProjectDirectory.DirectoryOfCsb;
|
|
|
|
|
RenameToSoundElement = true;
|
2017-04-23 18:22:25 +02:00
|
|
|
|
EnableThreading = true;
|
2017-06-21 00:19:47 +02:00
|
|
|
|
MaxThreads = 4;
|
|
|
|
|
LoopCount = 2;
|
|
|
|
|
FadeTime = 10;
|
|
|
|
|
FadeDelay = 0;
|
2017-04-17 18:06:29 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|