From 1a9adad51e7a6b8887d1bd05837c460405249748 Mon Sep 17 00:00:00 2001 From: NaysKutzu <87282334+NaysKutzu@users.noreply.github.com> Date: Fri, 5 May 2023 22:49:44 +0200 Subject: [PATCH] 1.0.5 Added CLI Added logs Added DiscordRPC via API Fixed some bugs --- .vs/MythicalLauncher/v17/.suo | Bin 223744 -> 403456 bytes FrmLoading.cs | 81 +++++++++++++++++++++++++++------- Program.cs | 58 +++++++++++++++++++++++- buildnumber | 2 +- version | 2 +- 5 files changed, 123 insertions(+), 20 deletions(-) diff --git a/.vs/MythicalLauncher/v17/.suo b/.vs/MythicalLauncher/v17/.suo index 8c4ca5327e2711f872cad30aa5048060b599ffb6..7ba6b606a9d12812f7f2bbf9ac78b8e877d8c436 100644 GIT binary patch delta 8375 zcmds+d303O9mnr|cP5kNWhKi5LP!uoFa&0@P9Tt#7(&=(5o1d*Xo4YNGLbDX!GQZh za?$G_Rx9nHbvYIYGS=FfqHV2WNm{jHRTP&3;)0S22%+EK%M2MKoHo#-$KIUJ-1~m- z?#u7@yD!bJ1~+$FH;>7+FrN^{n2tvc^qf6=mfmnM2)qEgKsdMzgn%8D5AZgvHe^u? z+ui2c&;JHl{&2ZQTf=XY-P-hEj!Mp&A*EP$MT{_);lV9ei?U#LIg-?p_g!#32~7Aw z2$0+~q#_0>dL4{-h$l_eg@QAXQ|H4(Z<;zxvOrHhB+m}@q~j3B0?HGKcra+KjO1r_ zR5lnR$S*y$^U_D)@*M%SPayzpQNO5d3N#KH7Y#HBkc`Gdu{Y4TylIN5ydPu~(|BoI zl1C)(R-hV?}Hxy8%Uh%nI1G%*krlO(;H@twOpOsTHgN@9b1ilQ`^#Hp1$CdQqu^WR6jq1gPF9JSs;)GCm*c5`)uU0WI-RQSEo%Ha(B}lC z;(@mTy$%olfI?eRu`IUd%H|{|pCY@HX6Q7aDg<=A(IaC8`HiwMWQI9Qz0PihhC|4(;_+1MfSKa@jq*h<`$1wc3qu=x|y7{V3^v9moARA)qnsdU- z4kEx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8}0gD|)gDv7^5Mcu#EG(fUH*k%kWv<%UKM+i!^!jgtmTt(LBHDv5=LR)F zPpdSrm04(TiGZ~7vdKCvGg)83q@`}huftfzglK#Eb(li~p^uP#6cmpNupQ$pCyoYk}iLEj+TR)!Nhw zPt51R{Y(TqnPzzgWnWIBqKhb6G>M|q=zE%?eW4w|_QpZBLc3tl!S$1&V^6{v(CK8^ zh)!-!J4{Yf*@EA{#r_Xr{S!nlVk;uibXtt=hX5aH3gl@;dQEoTPn+-givP*d=8=Ev z_KlZ2+vOTq&TyS zsSp;scd}0L>IG#9xcS!B8QKj}$(jeYZ0U(EilJk_U;_@MUU(0&8&mEJ*u$2%?zw-} zA1QlL(|1vsmwge4Il$><`3!{oI)60FL(93C_RWhdZ zv%G-`>8ydr(`~~#@(*PhST3f12IAa7)+$>4>e$r&3EQDJ=t*CMFpf{mt&iU+zdpzk z*2$@=;qaOh9j+aqSd}c#)#~pVm+$piA=RN}L{Bu1jM7Cv`L7@|dT6h|F03jvQ4@!S z_-=5eqv!uRa6bGMi@|t2(1!lOkr6Zk#Ni=D5x1*qiI{tmJ!O4;nCza|Np0XHwjV=W hDNNcXY)9TWg>8CzT{%n^I7Q?WW#H25>cv8J=wEns|9k)d diff --git a/FrmLoading.cs b/FrmLoading.cs index 1f2ac96..02fb6c3 100644 --- a/FrmLoading.cs +++ b/FrmLoading.cs @@ -27,6 +27,13 @@ public FrmLoading() public static string applogo; public static string applang; public static string version; + public static string enable_discordrpc; + public static string discord_id; + public static string discordrpc_button1_text; + public static string discordrpc_button1_url; + public static string discordrpc_button2_text; + public static string discordrpc_button2_url; + public static string discordrpc_description; public static JObject GetDataFromUrl(string url) { @@ -40,37 +47,37 @@ public static JObject GetDataFromUrl(string url) void InitializeRPC() { - client = new DiscordRpcClient("1038164770244788254"); + Console.WriteLine("[{0:HH:mm:ss}] [DISCORD RPC] Please wait while we load RPC", DateTime.Now); + client = new DiscordRpcClient(discord_id); client.Logger = new ConsoleLogger() { Level = LogLevel.Warning }; client.OnReady += (sender, e) => { - Console.WriteLine("Received Ready from user {0}", e.User.Username); + Console.WriteLine("[{0:HH:mm:ss}] [DISCORD RPC] Received Ready from user {0}", e.User.Username, DateTime.Now); }; client.OnPresenceUpdate += (sender, e) => { - Console.WriteLine("Received Update! {0}", e.Presence); + Console.WriteLine("[{0:HH:mm:ss}] [DISCORD RPC] Received Update! {0}", e.Presence, DateTime.Now); }; client.Initialize(); - // TODO: ADDD CUSTOM RPC VIA API DiscordRPC.Button btns = new DiscordRPC.Button(); DiscordRPC.Button btns2 = new DiscordRPC.Button(); - btns.Label = "Github"; - btns.Url = "https://github.com/MythicalLTD/MythicalLauncher"; - //btns2.Label = ""; - //btns2.Url = "https://my.mythicalnodes.xyz"; + btns.Label = discordrpc_button1_text; + btns.Url = discordrpc_button1_url; + btns2.Label = discordrpc_button2_text; + btns2.Url = discordrpc_button2_url; client.SetPresence(new RichPresence() { - Details = "MythicalSystems", - State = "Free custom minecraft launcher!", + Details = "Playing on "+appname, + State = discordrpc_description, Assets = new Assets() { LargeImageKey = "logo", - LargeImageText = "MythicalSystems", + LargeImageText = appname, }, Buttons = new DiscordRPC.Button[] { @@ -78,6 +85,9 @@ void InitializeRPC() btns2 }, }); + + Console.WriteLine("[{0:HH:mm:ss}] Discord RPC was successfully loaded", DateTime.Now); + } private void lblexit_Click(object sender, EventArgs e) @@ -86,10 +96,13 @@ private void lblexit_Click(object sender, EventArgs e) } private void GetSettings() { + Console.WriteLine("[{0:HH:mm:ss}] [SETTINGS] We are trying to load the server settings please wait", DateTime.Now); var appcfg = new ConfigParser(appConfig); var r_key = appcfg.GetValue("RemoteLauncher", "key"); if (r_key == "") { + Console.WriteLine("[{0:HH:mm:ss}] [SETTINGS] There was a problem while connecting", DateTime.Now); + Console.WriteLine("[{0:HH:mm:ss}] [SETTINGS] No server was specified, please make sure to specify it into the config file", DateTime.Now); Alert("Please specify a server for the launcher to connect", FrmAlert.enmType.Error); } else @@ -97,18 +110,27 @@ private void GetSettings() string jsonFilePath = r_key+ "/api/mythicallauncher/settings/getconfig.php"; using (var client = new WebClient()) { + Console.WriteLine("[{0:HH:mm:ss}] [SETTINGS] We are downloading the server side settings", DateTime.Now); string json = client.DownloadString(jsonFilePath); dynamic data = JsonConvert.DeserializeObject(json); - string version = data.Version; - string appname = data.appName; - string applogo = data.appLogo; - string applang = data.appLang; + Console.WriteLine("[{0:HH:mm:ss}] [SETTINGS] Done downloading now please wait while we save the server settings on your local pc",DateTime.Now); + version = data.Version; + appname = data.appName; + applogo = data.appLogo; + applang = data.appLang; string appbg = data.appBg; string appcolour = data.appMainColour; string appdiscord = data.appDiscord; string appvote = data.appVote; string appweb = data.appWebsite; string appstore = data.appStore; + enable_discordrpc = data.enable_discordrpc; + discord_id = data.discord_id; + discordrpc_button1_text = data.discordrpc_button1_text; + discordrpc_button1_url = data.discordrpc_button1_url; + discordrpc_button2_text = data.discordrpc_button2_text; + discordrpc_button2_url = data.discordrpc_button2_url; + discordrpc_description = data.discordrpc_description; lblver.Text = "V" +version; appcfg.SetValue("RemoteLauncher", "Version", version); appcfg.SetValue("RemoteLauncher", "appName", appname); @@ -120,13 +142,22 @@ private void GetSettings() appcfg.SetValue("RemoteLauncher", "appVote", appvote); appcfg.SetValue("RemoteLauncher", "appStore", appstore); appcfg.SetValue("RemoteLauncher", "appLang", applang); + appcfg.SetValue("RemoteLauncher", "enable_discordrpc", enable_discordrpc); + appcfg.SetValue("RemoteLauncher", "discord_id", discord_id); + appcfg.SetValue("RemoteLauncher", "discordrpc_button1_text", discordrpc_button1_text); + appcfg.SetValue("RemoteLauncher", "discordrpc_button1_url", discordrpc_button1_url); + appcfg.SetValue("RemoteLauncher", "discordrpc_button2_text", discordrpc_button2_text); + appcfg.SetValue("RemoteLauncher", "discordrpc_button2_url", discordrpc_button2_url); + appcfg.SetValue("RemoteLauncher", "discordrpc_description", discordrpc_description); appcfg.Save(); loader.Color = ColorTranslator.FromHtml(appcolour); + Console.WriteLine("[{0:HH:mm:ss}] [SETTINGS] Done", DateTime.Now); } } } private Boolean checkUpdate() { + Console.WriteLine("[{0:HH:mm:ss}] [UPDATER] Please wait while we check for updates",DateTime.Now); Boolean versionStatu; try { @@ -147,6 +178,7 @@ private void askUpdate() if (checkUpdate()) { + Console.WriteLine("[{0:HH:mm:ss}] [UPDATER] Update found!",DateTime.Now); DialogResult dr = MessageBox.Show("New update is available. \n\r Would you like to install it now?", "Update found", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dr == DialogResult.Yes) { @@ -198,14 +230,31 @@ private void DisplayImage() } private async void FrmLoading_Load(object sender, EventArgs e) { + Console.WriteLine("[{0:HH:mm:ss}] [PRELOADER] Please wait while we load all plugins", DateTime.Now); + Console.WriteLine("[{0:HH:mm:ss}] [PRELOADER] Loading updater..", DateTime.Now); askUpdate(); + Console.WriteLine("[{0:HH:mm:ss}] [PRELOADER] Done..", DateTime.Now); + Console.WriteLine("[{0:HH:mm:ss}] [PRELOADER] Loading settings..", DateTime.Now); GetSettings(); - InitializeRPC(); + Console.WriteLine("[{0:HH:mm:ss}] [PRELOADER] Done..", DateTime.Now); + Console.WriteLine("[{0:HH:mm:ss}] [PRELOADER] Loading Discord RPC..", DateTime.Now); + if (enable_discordrpc == "true") + { + InitializeRPC(); + } + else + { + Console.WriteLine("[{0:HH:mm:ss}] [PRELOADER] We disabled Discord RPC..", DateTime.Now); + } + Console.WriteLine("[{0:HH:mm:ss}] [PRELOADER] Please wait while we display the server imagine", DateTime.Now); DisplayImage(); + Console.WriteLine("[{0:HH:mm:ss}] [PRELOADER] Done..", DateTime.Now); lblver.Text = "V"+File.ReadAllText(versionfile); await Task.Delay(5000); + Console.WriteLine("[{0:HH:mm:ss}] [PRELOADER] Loading login form", DateTime.Now); FrmLogin x = new FrmLogin(); x.Show(); + Console.WriteLine("[{0:HH:mm:ss}] [PRELOADER] Done..", DateTime.Now); this.Hide(); } diff --git a/Program.cs b/Program.cs index 01f733c..83d9e41 100644 --- a/Program.cs +++ b/Program.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Windows.Forms; @@ -11,13 +13,65 @@ internal static class Program /// /// The main entry point for the application. /// - public static string version = "1.0.2"; + public static string version = "1.0.5"; + public static string debugmdoe; + [DllImport("kernel32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + static extern bool AttachConsole(int dwProcessId); + private const int ATTACH_PARENT_PROCESS = -1; + + [STAThread] - static void Main() + static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); + + + if (args.Contains("-version")) + { + AttachConsole(ATTACH_PARENT_PROCESS); + Console.Title = "MythicalLauncher | CLI"; + Console.WriteLine("@echo off"); + Console.Clear(); + Console.WriteLine("MythicalLauncher version "+version+" by MythicalSystems"); + Console.WriteLine(""); + return; + } + if (args.Contains("-debug")) + { + AttachConsole(ATTACH_PARENT_PROCESS); + Console.Title = "MythicalLauncher | CLI"; + Console.WriteLine("@echo off"); + Console.Clear(); + Console.WriteLine("MythicalLauncher version " + version + " by MythicalSystems"); + Console.WriteLine(""); + Console.WriteLine("DEBUG MODE ACTIVE"); + Console.WriteLine("Please do not use this mode if you are not a developer"); + debugmdoe = "true"; + Application.Run(new FrmLoading()); + return; + } + if (args.Contains("-help")) + { + AttachConsole(ATTACH_PARENT_PROCESS); + Console.Title = "MythicalLauncher | CLI"; + Console.WriteLine("@echo off"); + Console.Clear(); + Console.WriteLine("Welcome to MythicalLauncher version " + version); + Console.WriteLine(""); + Console.WriteLine("Thanks for using MythicalLauncher CLI here are the commands that may help you"); + Console.WriteLine(""); + Console.WriteLine("-help | Shows this promot"); + Console.WriteLine("-version | Shows the version of the application"); + Console.WriteLine("-debug | Shows the debug console for problems"); + Console.WriteLine("-verify | SOON"); + Console.WriteLine(""); + Console.WriteLine("Press any key to continue!"); + return; + } + debugmdoe = "true"; Application.Run(new FrmLoading()); } } diff --git a/buildnumber b/buildnumber index cb1a40d..8975db9 100644 --- a/buildnumber +++ b/buildnumber @@ -1 +1 @@ -250 +293 \ No newline at end of file diff --git a/version b/version index 6d7de6e..1464c52 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.0.2 +1.0.5 \ No newline at end of file