Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
1.0.5
Browse files Browse the repository at this point in the history
Added CLI
Added logs
Added DiscordRPC via API
Fixed some bugs
  • Loading branch information
NaysKutzu committed May 5, 2023
1 parent 4f70509 commit 1a9adad
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 20 deletions.
Binary file modified .vs/MythicalLauncher/v17/.suo
Binary file not shown.
81 changes: 65 additions & 16 deletions FrmLoading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -40,44 +47,47 @@ 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[]
{
btns,
btns2
},
});

Console.WriteLine("[{0:HH:mm:ss}] Discord RPC was successfully loaded", DateTime.Now);

}

private void lblexit_Click(object sender, EventArgs e)
Expand All @@ -86,29 +96,41 @@ 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
{
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);
Expand All @@ -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
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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();

}
Expand Down
58 changes: 56 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -11,13 +13,65 @@ internal static class Program
/// <summary>
/// The main entry point for the application.
/// </summary>
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());
}
}
Expand Down
2 changes: 1 addition & 1 deletion buildnumber
Original file line number Diff line number Diff line change
@@ -1 +1 @@
250
293
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.2
1.0.5

0 comments on commit 1a9adad

Please sign in to comment.