-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.cs
More file actions
84 lines (79 loc) · 2.9 KB
/
Copy pathProgram.cs
File metadata and controls
84 lines (79 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
namespace CustomStreamMaker
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
try
{
var appDomain = AppDomain.CurrentDomain;
appDomain.AssemblyResolve += OnAssemblyResolve;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
CheckGamePath();
Application.Run(new StreamEditor());
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
static Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
{
string requestedAssemblyName = args.Name.Split(',')[0];
string gamePath;
try
{
if (requestedAssemblyName == "Assembly-CSharp")
{
CheckGamePath();
gamePath = GameLocation.InitializeValidGamePath();
return Assembly.LoadFrom(gamePath + @"\Windose_Data\Managed\" + requestedAssemblyName + ".dll");
}
return Assembly.LoadFrom(Path.Combine(Directory.GetCurrentDirectory(), "Assemblies", requestedAssemblyName + ".dll"));
}
catch
{
return null;
}
}
static void CheckGamePath()
{
DialogResult msg;
string gamePath = GameLocation.InitializeValidGamePath();
if ((gamePath == null && string.IsNullOrEmpty(Properties.Settings.Default.GameDirectory)) || !Directory.Exists(gamePath))
{
do
{
msg = MessageBox.Show("Could not find game path! \n\nTo continue, please open the folder containing the game executable. (NEEDY GIRL OVERDOSE)", "", MessageBoxButtons.OKCancel);
if (msg == DialogResult.Cancel)
Environment.Exit(0);
} while ((gamePath = OpenGamePath()) == null);
Properties.Settings.Default.GameDirectory = gamePath;
Properties.Settings.Default.Save();
}
}
static string OpenGamePath()
{
var openNsoStream = new FolderBrowserDialog();
openNsoStream.RootFolder = Environment.SpecialFolder.MyComputer;
if (openNsoStream.ShowDialog() == DialogResult.OK)
{
if (!File.Exists(openNsoStream.SelectedPath + @"\Windose_Data\Managed\Assembly-CSharp.dll"))
{
return null;
}
return openNsoStream.SelectedPath;
}
return null;
}
}
}