diff --git a/ARCHBLOXLauncher1.csproj.user b/ARCHBLOXLauncher1.csproj.user index 3494964..7ac85d8 100644 --- a/ARCHBLOXLauncher1.csproj.user +++ b/ARCHBLOXLauncher1.csproj.user @@ -1,7 +1,7 @@  - <_LastSelectedProfileId>C:\Users\Thomas\source\repos\ARCHBLOXLauncher1\Properties\PublishProfiles\x64.pubxml + <_LastSelectedProfileId>C:\Users\Thomas\source\repos\ARCHBLOXLauncher1\Properties\PublishProfiles\x86.pubxml diff --git a/Form1.cs b/Form1.cs index 70a2d3f..934c5e7 100644 --- a/Form1.cs +++ b/Form1.cs @@ -16,6 +16,7 @@ namespace ARCHBLOXLauncher1 { public partial class Form1 : Form { + bool exitafterarg = false; bool lockanims = true; bool rbxl = false; private DiscordRpcClient client; @@ -149,6 +150,87 @@ namespace ARCHBLOXLauncher1 public Form1() { InitializeComponent(); + var lastword = ""; + var info1 = ""; + var info2 = ""; + string[] args = ARCHBLOXProtocol.SharedVariables.Arguments.Split('/'); + foreach (var word in args) + { + if (lastword == "host") { + exitafterarg = true; + lastword = "stop"; + string[] info = word.Split('|'); + foreach (var word2 in info) + { + if (info1 == "") { + info1 = word2; + } else { + info2 = word2; + } + } + if (info1 == "" || info2 == "") + { + MessageBox.Show("Paramaters are invalid. Please try again. (ID: 500)", "ARCHBLOX", MessageBoxButtons.OK, MessageBoxIcon.Error); + Environment.Exit(0); + } + var pProcess = new Process(); + hosting = true; + pProcess.StartInfo.FileName = filePath; + pProcess.StartInfo.Arguments = "-a \"http://www.morblox.us/\" -j \"http://www.morblox.us/game/gameserver.php?port=" + info1 + "&rbxl=" + info2 + "\" -t \"1\""; + pProcess.StartInfo.UseShellExecute = false; + pProcess.StartInfo.RedirectStandardOutput = true; + pProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; + pProcess.StartInfo.CreateNoWindow = false; + pProcess.Start(); + MessageBox.Show("Starting game server on port " + info1 + " using " + info2, "ARCHBLOX", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + if (lastword == "join") + { + exitafterarg = true; + lastword = "stop"; + string[] info = word.Split('|'); + foreach (var word2 in info) + { + if (info1 == "") + { + info1 = word2; + } + else + { + info2 = word2; + } + } + if (info1 == "" || info2 == "") { + MessageBox.Show("Paramaters are invalid. Please try again. (ID: 500)", "ARCHBLOX", MessageBoxButtons.OK, MessageBoxIcon.Error); + Environment.Exit(0); + } + var pProcess = new Process(); + hosting = true; + pProcess.StartInfo.FileName = filePath; + pProcess.StartInfo.Arguments = "-a \"http://www.morblox.us/\" -j \"http://www.morblox.us/game/join.ashx?port=" + info1 + "&ip=" + info2 + "\" -t \"1\""; + pProcess.StartInfo.UseShellExecute = false; + pProcess.StartInfo.RedirectStandardOutput = true; + pProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; + pProcess.StartInfo.CreateNoWindow = false; + pProcess.Start(); + MessageBox.Show("Joining " + info2 + ":" + info1, "ARCHBLOX", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + if (word == "install") + { + ARCHBLOXLauncher1.Form2 form2 = new ARCHBLOXLauncher1.Form2(); + form2.Show(); + } + if (word == "") { } else + { + lastword = word; + } + } + + if (exitafterarg == true) + { + Environment.Exit(0); + } + AnimationHandler_SlideOutHostBox.Tick += new EventHandler(slideOutHostBox); AnimationHandler_SlideInHostBox.Tick += new EventHandler(slideInHostBox); diff --git a/Form2.cs b/Form2.cs index 8c6336d..e99222d 100644 --- a/Form2.cs +++ b/Form2.cs @@ -15,7 +15,6 @@ using System.Threading.Tasks; using System.IO; using System.DirectoryServices; using System.Windows.Forms; - namespace ARCHBLOXLauncher1 { public partial class Form2 : Form @@ -25,7 +24,6 @@ namespace ARCHBLOXLauncher1 private static WebClient wc = new WebClient(); private static ManualResetEvent handle = new ManualResetEvent(true); - private static long GetDirectorySize(string folderPath) { DirectoryInfo di = new DirectoryInfo(folderPath); @@ -47,6 +45,7 @@ namespace ARCHBLOXLauncher1 DialogResult res = MessageBox.Show("Do you want to delete previous installs of ARCHBLOX? Current size of ARCHBLOX folder: " + GetDirectorySize(folderPath) + "MB.", "ARCHBLOX", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (res == DialogResult.Yes) { + ARCHBLOXProtocol.ARCHBLOXURIProtocol.Unregister(); label1.Text = "Removing previous installs..."; Directory.Delete(folderPath, true); @@ -101,6 +100,7 @@ namespace ARCHBLOXLauncher1 ZipFile.ExtractToDirectory(filePath, clientPath); File.Delete(filePath); label1.Text = "Install completed!"; + ARCHBLOXProtocol.ARCHBLOXURIProtocol.Register(); } } diff --git a/Program.cs b/Program.cs index 7abaa2e..cd8346a 100644 --- a/Program.cs +++ b/Program.cs @@ -12,11 +12,18 @@ namespace ARCHBLOXLauncher1 /// The main entry point for the application. /// [STAThread] - static void Main() + static void Main(string[] args) { Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); + if (args.Length > 0) + { + foreach (string s in args) + { + ARCHBLOXProtocol.SharedVariables.Arguments = s; + } + } Application.Run(new Form1()); } } diff --git a/Properties/PublishProfiles/x64.pubxml.user b/Properties/PublishProfiles/x64.pubxml.user index 5ad9010..a596579 100644 --- a/Properties/PublishProfiles/x64.pubxml.user +++ b/Properties/PublishProfiles/x64.pubxml.user @@ -4,6 +4,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - True|2022-07-12T14:37:23.7218937Z;True|2022-07-13T00:35:56.1276705+10:00;True|2022-07-12T20:31:31.4891674+10:00;True|2022-07-12T07:42:57.8030421+10:00;True|2022-07-12T07:24:22.2110673+10:00;True|2022-07-12T07:12:22.1327523+10:00;True|2022-07-12T01:02:07.4142780+10:00;True|2022-07-12T01:01:55.1054218+10:00;True|2022-07-12T00:57:05.7704097+10:00;True|2022-07-11T19:45:06.3965836+10:00;True|2022-07-11T03:03:05.5235378+10:00;True|2022-07-11T01:29:52.2575986+10:00;True|2022-07-11T01:29:03.7081553+10:00;True|2022-07-11T01:07:30.8355486+10:00;True|2022-07-11T00:18:27.1107980+10:00;True|2022-07-10T21:59:11.0753271+10:00;True|2022-07-10T19:15:49.4105023+10:00;True|2022-07-10T19:13:41.3098116+10:00;True|2022-07-10T19:12:41.5715908+10:00; + True|2022-07-13T06:20:04.4747082Z;True|2022-07-13T00:37:48.5001758+10:00;True|2022-07-13T00:37:23.7218937+10:00;True|2022-07-13T00:35:56.1276705+10:00;True|2022-07-12T20:31:31.4891674+10:00;True|2022-07-12T07:42:57.8030421+10:00;True|2022-07-12T07:24:22.2110673+10:00;True|2022-07-12T07:12:22.1327523+10:00;True|2022-07-12T01:02:07.4142780+10:00;True|2022-07-12T01:01:55.1054218+10:00;True|2022-07-12T00:57:05.7704097+10:00;True|2022-07-11T19:45:06.3965836+10:00;True|2022-07-11T03:03:05.5235378+10:00;True|2022-07-11T01:29:52.2575986+10:00;True|2022-07-11T01:29:03.7081553+10:00;True|2022-07-11T01:07:30.8355486+10:00;True|2022-07-11T00:18:27.1107980+10:00;True|2022-07-10T21:59:11.0753271+10:00;True|2022-07-10T19:15:49.4105023+10:00;True|2022-07-10T19:13:41.3098116+10:00;True|2022-07-10T19:12:41.5715908+10:00; \ No newline at end of file diff --git a/Properties/PublishProfiles/x86.pubxml.user b/Properties/PublishProfiles/x86.pubxml.user index b1913c6..557b34b 100644 --- a/Properties/PublishProfiles/x86.pubxml.user +++ b/Properties/PublishProfiles/x86.pubxml.user @@ -4,6 +4,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - True|2022-07-12T14:37:19.8958675Z;True|2022-07-13T00:36:07.1078472+10:00;True|2022-07-12T20:31:25.7325840+10:00;True|2022-07-12T07:43:08.7666080+10:00;True|2022-07-12T07:24:17.3722228+10:00;True|2022-07-12T07:12:29.3685122+10:00;True|2022-07-12T01:01:59.7182995+10:00;True|2022-07-12T00:56:51.3800489+10:00;True|2022-07-11T19:45:17.8917634+10:00;True|2022-07-11T03:02:35.7176035+10:00;True|2022-07-11T01:29:59.8179775+10:00;True|2022-07-11T01:28:57.8645143+10:00;True|2022-07-11T01:07:39.1190996+10:00;True|2022-07-11T00:18:18.9541704+10:00;True|2022-07-10T21:59:16.0892178+10:00;True|2022-07-10T19:13:19.3369745+10:00;True|2022-07-10T19:13:01.5256770+10:00; + True|2022-07-13T06:19:59.8973544Z;True|2022-07-13T00:38:04.2388491+10:00;True|2022-07-13T00:37:19.8958675+10:00;True|2022-07-13T00:36:07.1078472+10:00;True|2022-07-12T20:31:25.7325840+10:00;True|2022-07-12T07:43:08.7666080+10:00;True|2022-07-12T07:24:17.3722228+10:00;True|2022-07-12T07:12:29.3685122+10:00;True|2022-07-12T01:01:59.7182995+10:00;True|2022-07-12T00:56:51.3800489+10:00;True|2022-07-11T19:45:17.8917634+10:00;True|2022-07-11T03:02:35.7176035+10:00;True|2022-07-11T01:29:59.8179775+10:00;True|2022-07-11T01:28:57.8645143+10:00;True|2022-07-11T01:07:39.1190996+10:00;True|2022-07-11T00:18:18.9541704+10:00;True|2022-07-10T21:59:16.0892178+10:00;True|2022-07-10T19:13:19.3369745+10:00;True|2022-07-10T19:13:01.5256770+10:00; \ No newline at end of file diff --git a/URI_Maker.cs b/URI_Maker.cs new file mode 100644 index 0000000..674a3f4 --- /dev/null +++ b/URI_Maker.cs @@ -0,0 +1,91 @@ +using System; +using System.Windows.Forms; +using System.Security.Permissions; +using Microsoft.Win32; + +namespace ARCHBLOXProtocol +{ + class SharedVariables + { + public static string Arguments = ""; + }; + [PrincipalPermission(SecurityAction.Demand, Role = @"BUILTIN\Administrators")] + internal static class ARCHBLOXURIProtocol + { + private const string _Protocol = "archblox"; + private const string _ProtocolHandler = "url.archblox"; + + private static readonly string _launch = string.Format( + "{0}{1}{0} {0}%1{0}", (char)34, Application.ExecutablePath); + + private static readonly Version _win8Version = new Version(6, 2, 9200, 0); + private static readonly bool _isWin8 = + Environment.OSVersion.Platform == PlatformID.Win32NT && + Environment.OSVersion.Version >= _win8Version; + + internal static void Register() + { + if (_isWin8) RegisterWin8(); + else RegisterWin7(); + } + + private static void RegisterWin7() + { + var regKey = Registry.ClassesRoot.CreateSubKey(_Protocol); + + regKey.CreateSubKey("DefaultIcon") + .SetValue(null, string.Format("{0}{1},1{0}", (char)34, + Application.ExecutablePath)); + + regKey.SetValue(null, "URL:archblox Protocol"); + regKey.SetValue("URL Protocol", ""); + + regKey = regKey.CreateSubKey(@"shell\open\command"); + regKey.SetValue(null, _launch); + } + + private static void RegisterWin8() + { + RegisterWin7(); + + var regKey = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Classes") + .CreateSubKey(_ProtocolHandler); + + regKey.SetValue(null, _Protocol); + + regKey.CreateSubKey("DefaultIcon") + .SetValue(null, string.Format("{0}{1},1{0}", (char)34, + Application.ExecutablePath)); + + regKey.CreateSubKey(@"shell\open\command").SetValue(null, _launch); + + Registry.LocalMachine.CreateSubKey(string.Format( + @"SOFTWARE\{0}\{1}\Capabilities\ApplicationDescription\URLAssociations", + Application.CompanyName, Application.ProductName)) + .SetValue(_Protocol, _ProtocolHandler); + + Registry.LocalMachine.CreateSubKey(@"SOFTWARE\RegisteredApplications") + .SetValue(Application.ProductName, string.Format( + @"SOFTWARE\{0}\Capabilities", Application.ProductName)); + } + + internal static void Unregister() + { + if (!_isWin8) + { + Registry.ClassesRoot.DeleteSubKeyTree("archblox", false); + return; + } + + // extra work required. + Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Classes") + .DeleteSubKeyTree(_ProtocolHandler, false); + + Registry.LocalMachine.DeleteSubKeyTree(string.Format(@"SOFTWARE\{0}\{1}", + Application.CompanyName, Application.ProductName)); + + Registry.LocalMachine.CreateSubKey(@"SOFTWARE\RegisteredApplications") + .DeleteValue(Application.ProductName); + } + } +} diff --git a/bin/Release/netcoreapp3.1/ARCHBLOXLauncher1.dll b/bin/Release/netcoreapp3.1/ARCHBLOXLauncher1.dll index 70436e2..6bc5cf3 100644 Binary files a/bin/Release/netcoreapp3.1/ARCHBLOXLauncher1.dll and b/bin/Release/netcoreapp3.1/ARCHBLOXLauncher1.dll differ diff --git a/bin/Release/netcoreapp3.1/ARCHBLOXLauncher1.pdb b/bin/Release/netcoreapp3.1/ARCHBLOXLauncher1.pdb index ca8680a..08c6317 100644 Binary files a/bin/Release/netcoreapp3.1/ARCHBLOXLauncher1.pdb and b/bin/Release/netcoreapp3.1/ARCHBLOXLauncher1.pdb differ diff --git a/bin/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.dll b/bin/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.dll index 0a34564..53783d3 100644 Binary files a/bin/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.dll and b/bin/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.dll differ diff --git a/bin/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.pdb b/bin/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.pdb index 064446c..78333d8 100644 Binary files a/bin/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.pdb and b/bin/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.pdb differ diff --git a/bin/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.dll b/bin/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.dll index cdd956c..9542ef0 100644 Binary files a/bin/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.dll and b/bin/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.dll differ diff --git a/bin/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.pdb b/bin/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.pdb index 872a518..c4cf968 100644 Binary files a/bin/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.pdb and b/bin/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.pdb differ diff --git a/obj/Release/netcoreapp3.1/ARCHBLOXLauncher1.csproj.CoreCompileInputs.cache b/obj/Release/netcoreapp3.1/ARCHBLOXLauncher1.csproj.CoreCompileInputs.cache index 550f768..7de54f7 100644 --- a/obj/Release/netcoreapp3.1/ARCHBLOXLauncher1.csproj.CoreCompileInputs.cache +++ b/obj/Release/netcoreapp3.1/ARCHBLOXLauncher1.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -128067f77a5132928ef0df2bcb245ccf31195143 +385c2bf7542a20aa95b73838276be171671d87eb diff --git a/obj/Release/netcoreapp3.1/ARCHBLOXLauncher1.csproj.GenerateResource.cache b/obj/Release/netcoreapp3.1/ARCHBLOXLauncher1.csproj.GenerateResource.cache index 89c8c37..8052579 100644 Binary files a/obj/Release/netcoreapp3.1/ARCHBLOXLauncher1.csproj.GenerateResource.cache and b/obj/Release/netcoreapp3.1/ARCHBLOXLauncher1.csproj.GenerateResource.cache differ diff --git a/obj/Release/netcoreapp3.1/ARCHBLOXLauncher1.dll b/obj/Release/netcoreapp3.1/ARCHBLOXLauncher1.dll index 70436e2..6bc5cf3 100644 Binary files a/obj/Release/netcoreapp3.1/ARCHBLOXLauncher1.dll and b/obj/Release/netcoreapp3.1/ARCHBLOXLauncher1.dll differ diff --git a/obj/Release/netcoreapp3.1/ARCHBLOXLauncher1.pdb b/obj/Release/netcoreapp3.1/ARCHBLOXLauncher1.pdb index ca8680a..08c6317 100644 Binary files a/obj/Release/netcoreapp3.1/ARCHBLOXLauncher1.pdb and b/obj/Release/netcoreapp3.1/ARCHBLOXLauncher1.pdb differ diff --git a/obj/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.csproj.CoreCompileInputs.cache b/obj/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.csproj.CoreCompileInputs.cache index 75eb520..c480e74 100644 --- a/obj/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.csproj.CoreCompileInputs.cache +++ b/obj/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -a55a3629e84240fda0adac3b720301c89ebdfc41 +4651e0e314f61e88d5433c1b3fbe41abe99d39a3 diff --git a/obj/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.csproj.GenerateResource.cache b/obj/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.csproj.GenerateResource.cache index 89c8c37..8052579 100644 Binary files a/obj/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.csproj.GenerateResource.cache and b/obj/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.csproj.GenerateResource.cache differ diff --git a/obj/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.dll b/obj/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.dll index 0a34564..53783d3 100644 Binary files a/obj/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.dll and b/obj/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.dll differ diff --git a/obj/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.pdb b/obj/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.pdb index 064446c..78333d8 100644 Binary files a/obj/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.pdb and b/obj/Release/netcoreapp3.1/win-x64/ARCHBLOXLauncher1.pdb differ diff --git a/obj/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.csproj.CoreCompileInputs.cache b/obj/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.csproj.CoreCompileInputs.cache index 15a6ec5..bd0b537 100644 --- a/obj/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.csproj.CoreCompileInputs.cache +++ b/obj/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -f1fedbda7f00c658ab970e51562779c105404b1c +8627b0f4c4219191e032f43f8955ac859e5a6336 diff --git a/obj/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.csproj.GenerateResource.cache b/obj/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.csproj.GenerateResource.cache index 89c8c37..8052579 100644 Binary files a/obj/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.csproj.GenerateResource.cache and b/obj/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.csproj.GenerateResource.cache differ diff --git a/obj/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.dll b/obj/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.dll index cdd956c..9542ef0 100644 Binary files a/obj/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.dll and b/obj/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.dll differ diff --git a/obj/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.pdb b/obj/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.pdb index 872a518..c4cf968 100644 Binary files a/obj/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.pdb and b/obj/Release/netcoreapp3.1/win-x86/ARCHBLOXLauncher1.pdb differ