2011-05-08 09:07:46 +00:00
|
|
|
|
using System;
|
2012-10-29 08:37:22 +00:00
|
|
|
|
using System.Runtime.InteropServices;
|
2011-08-08 01:48:31 +00:00
|
|
|
|
using System.Reflection;
|
2011-05-08 09:07:46 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
2011-06-20 09:09:21 +00:00
|
|
|
|
//cue format preferences notes
|
|
|
|
|
|
|
|
|
|
//pcejin -
|
|
|
|
|
//does not like session commands
|
|
|
|
|
//it can handle binpercue
|
|
|
|
|
//it seems not to be able to handle binpertrack, or maybe i am doing something wrong (still havent ruled it out)
|
|
|
|
|
|
2011-05-08 09:07:46 +00:00
|
|
|
|
namespace BizHawk
|
|
|
|
|
{
|
|
|
|
|
class DiscoHawk
|
|
|
|
|
{
|
2011-08-08 01:48:31 +00:00
|
|
|
|
|
|
|
|
|
public static string GetExeDirectoryAbsolute()
|
|
|
|
|
{
|
2012-10-29 08:37:22 +00:00
|
|
|
|
var uri = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase);
|
|
|
|
|
string module = uri.LocalPath + System.Web.HttpUtility.UrlDecode(uri.Fragment);
|
|
|
|
|
return Path.GetDirectoryName(module);
|
2011-08-08 01:48:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-10-29 08:37:22 +00:00
|
|
|
|
static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
//load missing assemblies by trying to find them in the dll directory
|
|
|
|
|
string dllname = new AssemblyName(args.Name).Name + ".dll";
|
|
|
|
|
string directory = System.IO.Path.Combine(GetExeDirectoryAbsolute(), "dll");
|
|
|
|
|
string fname = Path.Combine(directory, dllname);
|
|
|
|
|
if (!File.Exists(fname)) return null;
|
|
|
|
|
//it is important that we use LoadFile here and not load from a byte array; otherwise mixed (managed/unamanged) assemblies can't load
|
|
|
|
|
return Assembly.LoadFile(fname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//declared here instead of a more usual place to avoid dependencies on the more usual place
|
|
|
|
|
#if WINDOWS
|
|
|
|
|
[DllImport("kernel32.dll", SetLastError = true)]
|
|
|
|
|
static extern bool SetDllDirectory(string lpPathName);
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-08-07 03:21:03 +00:00
|
|
|
|
[STAThread]
|
2011-05-08 09:07:46 +00:00
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
2012-10-29 08:37:22 +00:00
|
|
|
|
#if WINDOWS
|
|
|
|
|
// this will look in subdirectory "dll" to load pinvoked stuff
|
|
|
|
|
SetDllDirectory(System.IO.Path.Combine(GetExeDirectoryAbsolute(), "dll"));
|
|
|
|
|
|
|
|
|
|
//in case assembly resolution fails, such as if we moved them into the dll subdiretory, this event handler can reroute to them
|
|
|
|
|
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
SubMain(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void SubMain(string[] args)
|
|
|
|
|
{
|
|
|
|
|
var ffmpegPath = Path.Combine(GetExeDirectoryAbsolute(), "ffmpeg.exe");
|
|
|
|
|
if(!File.Exists(ffmpegPath))
|
|
|
|
|
ffmpegPath = Path.Combine(Path.Combine(GetExeDirectoryAbsolute(), "dll"), "ffmpeg.exe");
|
|
|
|
|
DiscSystem.FFMpeg.FFMpegPath = ffmpegPath;
|
|
|
|
|
AudioExtractor.FFmpegPath = ffmpegPath;
|
2011-05-08 09:07:46 +00:00
|
|
|
|
new DiscoHawk().Run(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Run(string[] args)
|
|
|
|
|
{
|
2011-08-07 03:22:41 +00:00
|
|
|
|
bool gui = true;
|
2011-08-07 03:21:03 +00:00
|
|
|
|
foreach (var arg in args)
|
|
|
|
|
{
|
2011-08-07 03:22:41 +00:00
|
|
|
|
if (arg.ToUpper() == "COMMAND") gui = false;
|
2011-08-07 03:21:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (gui)
|
|
|
|
|
{
|
2011-09-01 01:24:26 +00:00
|
|
|
|
var dialog = new MainDiscoForm();
|
2011-08-07 03:21:03 +00:00
|
|
|
|
dialog.ShowDialog();
|
2011-08-07 09:05:10 +00:00
|
|
|
|
return;
|
2011-08-07 03:21:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-05-08 09:07:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|